[Yum-devel] [PATCH 1/6] Add getloginuid(), so we can see who called "sudo yum"
James Antill
james at and.org
Wed Aug 26 00:15:16 UTC 2009
---
yum/misc.py | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/yum/misc.py b/yum/misc.py
index ab92b78..f0a0614 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -791,6 +791,21 @@ def unlink_f(filename):
if e.errno != errno.ENOENT:
raise
+def getloginuid():
+ """ Get the audit-uid/login-uid, if available. None is returned if there
+ was a problem. Note that no caching is done here. """
+ # We might normally call audit.audit_getloginuid(), except that requires
+ # importing all of the audit module. And it doesn't work anyway: BZ 518721
+ try:
+ fo = open("/proc/self/loginuid")
+ except IOError:
+ return None
+ data = fo.read()
+ try:
+ return int(data)
+ except ValueError:
+ return None
+
# ---------- i18n ----------
import locale
import sys
--
1.6.2.5
More information about the Yum-devel
mailing list