[Yum-devel] [PATCH 1/4] Add caching getloginuid, so we can use it outside of history
James Antill
james at and.org
Thu Jun 10 20:47:57 UTC 2010
---
yum/misc.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/yum/misc.py b/yum/misc.py
index 921b95c..35b8056 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -899,7 +899,7 @@ def unlink_f(filename):
if e.errno != errno.ENOENT:
raise
-def getloginuid():
+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
@@ -914,6 +914,16 @@ def getloginuid():
except ValueError:
return None
+_cached_getloginuid = None
+def getloginuid():
+ """ Get the audit-uid/login-uid, if available. None is returned if there
+ was a problem. The value is cached, so you don't have to save it. """
+ global _cached_getloginuid
+ if _cached_getloginuid is None:
+ _cached_getloginuid = _getloginuid()
+ return _cached_getloginuid
+
+
# ---------- i18n ----------
import locale
import sys
--
1.7.0.1
More information about the Yum-devel
mailing list