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)