diff --git a/docker/entrypoint.py b/docker/entrypoint.py index 589f13a..1483579 100755 --- a/docker/entrypoint.py +++ b/docker/entrypoint.py @@ -33,14 +33,20 @@ def change_uid_grp(): new_uid = int(os.getenv('UID', str(uid))) os.chown("/home/py-kms", new_uid, new_gid) os.chown("/usr/bin/start.py", new_uid, new_gid) - if os.path.isfile(dbPath): + if os.path.isdir(dbPath): # Corret permissions recursively, as to access the database file, also its parent folder must be accessible - for root, dirs, files in os.walk(dbPath): - for dName in dirs: - os.chown(os.path.join(root, dName), new_uid, new_gid) + loggersrv.debug(f'Correcting owner permissions on {dbPath}.') + os.chown(dbPath, new_uid, new_gid) + for root, dirs, files in os.walk(dbPath): + for dName in dirs: + dPath = os.path.join(root, dName) + loggersrv.debug(f'Correcting owner permissions on {dPath}.') + os.chown(dPath, new_uid, new_gid) for fName in files: - os.chown(os.path.join(root, fName), new_uid, new_gid) - loggersrv.debug(str(subprocess.check_output(['ls', '-la', dbPath]))) + fPath = os.path.join(root, fName) + loggersrv.debug(f'Correcting owner permissions on {fPath}.') + os.chown(fPath, new_uid, new_gid) + loggersrv.debug(subprocess.check_output(['ls', '-la', dbPath]).decode()) if 'LOGFILE' in os.environ and os.path.exists(os.environ['LOGFILE']): # Oh, the user also wants a custom log file -> make sure start.py can access it by setting the correct permissions (777) os.chmod(os.environ['LOGFILE'], 777) diff --git a/py-kms/pykms_Sql.py b/py-kms/pykms_Sql.py index 1e8c47d..6afa889 100644 --- a/py-kms/pykms_Sql.py +++ b/py-kms/pykms_Sql.py @@ -18,6 +18,7 @@ loggersrv = logging.getLogger('logsrv') def sql_initialize(dbName): if not os.path.isfile(dbName): # Initialize the database. + loggersrv.debug(f'Initializing database file "{dbName}"...') con = None try: con = sqlite3.connect(dbName)