1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
From 0b2b5c29c1ec89269aef0862981ebf97e2730de9 Mon Sep 17 00:00:00 2001
From: Denis Ollier <larchunix@users.noreply.github.com>
Date: Thu, 26 Jul 2018 20:31:36 +0200
Subject: [PATCH] Fallback to os.getuid() if /proc/self/loginuid can't be read
(RhBug:1597005)
File /proc/self/loginuid may be missing on architectures (RISC-V) or
distributions (ArchLinux) where audit subsystem is not enabled.
---
dnf/yum/misc.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dnf/yum/misc.py b/dnf/yum/misc.py
index 93000ca4..457e8bf5 100644
--- a/dnf/yum/misc.py
+++ b/dnf/yum/misc.py
@@ -395,8 +395,8 @@ def stat_f(filename, ignore_EACCES=False):
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. """
+ """ Get the audit-uid/login-uid, if available. os.getuid() is returned
+ instead 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:
@@ -404,12 +404,13 @@ def _getloginuid():
data = fo.read()
return int(data)
except (IOError, ValueError):
- return None
+ return os.getuid()
_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. """
+ """ Get the audit-uid/login-uid, if available. os.getuid() is returned
+ instead 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()
--
2.18.0
|