From ccfd1ed924a2271157293edb02cc4088ebb7e30a Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Tue, 4 Mar 2025 01:14:43 +0100 Subject: [PATCH] Add some more convenience to validator --- validate.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) mode change 100644 => 100755 validate.py diff --git a/validate.py b/validate.py old mode 100644 new mode 100755 index ed30e69..121f388 --- a/validate.py +++ b/validate.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + ''' This script validates users.toml for several aspects The script requires at least Python 3.11 @@ -36,8 +38,15 @@ def main(): args = parser.parse_args() if args.db is None: - print("Error: no users.toml given. Please add with '--db '") - sys.exit(1) + usertoml = args.db + print("No custom users.toml given. You may add it with '--db '") + default_usertoml = "/etc/bffh/users.toml" + if os.path.isfile(default_usertoml): + print("Found default file: {}. Using this ...".format(default_usertoml)) + usertoml = default_usertoml + else: + print("Error: no (default) users.toml file given or found. Cannot continue!".format(default_usertoml)) + sys.exit(1) countUsers = 0 countUsersWithoutCardkeyOrPassword = 0 @@ -58,8 +67,6 @@ def main(): #a definition of valid keys within a user section of FabAccess knownKeys = ['roles', 'passwd', 'cardkey'] - usertoml = args.db - print("{} Checking database {}\n".format("*"*25, "*"*25)) file_stats = os.stat(usertoml)