mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 14:44:50 -04:00
Added more debug logging & FINALLY corrected permission fixer
This commit is contained in:
parent
81e616ddd1
commit
cd07807a80
2 changed files with 13 additions and 6 deletions
|
@ -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
|
||||
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:
|
||||
os.chown(os.path.join(root, dName), new_uid, new_gid)
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue