dbus获取调用者信息

This commit is contained in:
wangsong 2022-10-25 10:31:00 +08:00
parent d16f036e08
commit 80784676e2
2 changed files with 7 additions and 7 deletions

View File

@ -716,13 +716,13 @@ def get_proc_from_dbus_name(dbus_name, bus=None):
dbus_interface="org.freedesktop.DBus")
proc = psutil.Process(int(pid))
with open("/proc/%s/status" % pid) as process:
values = [v for v in process.readlines() if v.startswith("Uid:")]
uid = int(values[0].split()[1])
# with open("/proc/%s/status" % pid) as process:
# values = [v for v in process.readlines() if v.startswith("Uid:")]
# uid = int(values[0].split()[1])
#检查是否root用户执行
if uid == 0:
return "root"
# #检查是否root用户执行
# if uid == 0:
# return "root"
return proc.name()

View File

@ -1047,7 +1047,7 @@ class UpdateInstallMode():
'org.freedesktop.login1', '/org/freedesktop/login1',
'org.freedesktop.login1.Manager', 'Inhibit',
GLib.Variant('(ssss)',
('shutdown',
('shutdown:sleep',
'Kylin System Updater', 'Updating System',
'delay')),
None, 0, -1, None, None)