logging: raise warning when not adjusting perms

This commit is contained in:
Dan Bungert 2022-03-14 09:33:05 -06:00
parent 953998b23a
commit 4698dcd935
1 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,7 @@
import contextlib
import datetime
import grp
import logging
import os
import tempfile
@ -24,9 +25,13 @@ import yaml
_DEF_PERMS_FILE = 0o640
_DEF_GROUP = 'adm'
log = logging.getLogger('subiquitycore.file_util')
def set_log_perms(target, *, isdir=True, group_write=False, mode=None):
if os.getuid() != 0:
log.warning('set_log_perms: running as non-root - not adjusting' +
' group owner or permissions for ' + target)
return
if mode is None:
mode = _DEF_PERMS_FILE