1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

util.users: Logging improved

This commit is contained in:
Игорь Чудов 2020-07-29 17:33:09 +04:00
parent 0d7a1e9740
commit 4f6f17024e
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -18,9 +18,8 @@
import os
import pwd
import logging
from .logging import slogm
from .logging import log
def is_root():
@ -75,9 +74,11 @@ def set_privileges(username, uid, gid, groups=list()):
#except Exception as exc:
# print('setgroups')
logging.debug(
slogm('Set process permissions to UID {} and GID {} for user {}'.format(
uid, gid, username)))
logdata = dict()
logdata['uid'] = uid
logdata['gid'] = gid
logdata['username'] = username
log('D37', logdata)
def with_privileges(username, func):
@ -103,7 +104,7 @@ def with_privileges(username, func):
try:
out = func()
except Exception as exc:
logging.debug(slogm(exc))
log(str(exc))
# Restore privileges
set_privileges('root', current_uid, 0, current_groups)