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

util.users.with_privileges(): return function result

This commit is contained in:
Игорь Чудов 2020-05-14 16:02:01 +04:00
parent ad3624d73e
commit 2bd533acb8
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -99,11 +99,14 @@ def with_privileges(username, func):
# We need to catch exception in order to be able to restore
# privileges later in this function
out = None
try:
func()
out = func()
except Exception as exc:
logging.debug(slogm(exc))
# Restore privileges
set_privileges('root', current_uid, 0, current_groups)
return out