Blame SOURCES/0029-setgid-instead-of-setuid-the-abrt-action-install-deb.patch

99f8fd
From 0641129e214fa1cd2a67740c3193944285781819 Mon Sep 17 00:00:00 2001
99f8fd
From: =?UTF-8?q?Miroslav=20Such=C3=BD?= <msuchy@redhat.com>
99f8fd
Date: Wed, 6 May 2020 19:10:48 +0200
99f8fd
Subject: [PATCH] setgid instead of setuid the
99f8fd
 abrt-action-install-debuginfo-to-abrt-cache [RHBZ 1796245]
99f8fd
99f8fd
This is called by abrt-action-install-debuginfo-to-abrt-cache which used to be setuid and now is setgid binary.
99f8fd
Therefore we do not need to setuid and we neither need it.
99f8fd
99f8fd
Resolves:
99f8fd
https://bugzilla.redhat.com/show_bug.cgi?id=1796245
99f8fd
---
99f8fd
 src/client-python/reportclient/debuginfo.py | 25 +++++++++------------
99f8fd
 1 file changed, 11 insertions(+), 14 deletions(-)
99f8fd
99f8fd
diff --git a/src/client-python/reportclient/debuginfo.py b/src/client-python/reportclient/debuginfo.py
99f8fd
index 561de52f..560629cc 100644
99f8fd
--- a/src/client-python/reportclient/debuginfo.py
99f8fd
+++ b/src/client-python/reportclient/debuginfo.py
99f8fd
@@ -35,41 +35,38 @@ from reportclient import (_, log1, log2, RETURN_OK, RETURN_FAILURE,
99f8fd
                           error_msg)
99f8fd
 
99f8fd
 
99f8fd
-def ensure_abrt_uid(fn):
99f8fd
+def ensure_abrt_gid(fn):
99f8fd
     """
99f8fd
-    Ensures that the function is called using abrt's uid and gid
99f8fd
+    Ensures that the function is called using abrt's gid
99f8fd
 
99f8fd
     Returns:
99f8fd
         Either an unchanged function object or a wrapper function object for
99f8fd
         the function.
99f8fd
     """
99f8fd
 
99f8fd
-    current_uid = os.getuid()
99f8fd
     current_gid = os.getgid()
99f8fd
     abrt = pwd.getpwnam("abrt")
99f8fd
 
99f8fd
     # if we're are already running as abrt, don't do anything
99f8fd
-    if abrt.pw_uid == current_uid and abrt.pw_gid == current_gid:
99f8fd
+    if abrt.pw_gid == current_gid:
99f8fd
         return fn
99f8fd
 
99f8fd
     def wrapped(*args, **kwargs):
99f8fd
         """
99f8fd
         Wrapper function around the called function.
99f8fd
 
99f8fd
-        Sets up uid and gid to match abrt's and after the function finishes
99f8fd
-        rolls its uid and gid back.
99f8fd
+        Sets up gid to match abrt's and after the function finishes
99f8fd
+        rolls its gid back.
99f8fd
 
99f8fd
         Returns:
99f8fd
             Return value of the wrapped function.
99f8fd
         """
99f8fd
 
99f8fd
-        # switch to abrt
99f8fd
+        # switch to abrt group
99f8fd
         os.setegid(abrt.pw_gid)
99f8fd
-        os.seteuid(abrt.pw_uid)
99f8fd
         # extract the files as abrt:abrt
99f8fd
         retval = fn(*args, **kwargs)
99f8fd
         # switch back to whatever we were
99f8fd
-        os.seteuid(current_uid)
99f8fd
         os.setegid(current_gid)
99f8fd
         return retval
99f8fd
 
99f8fd
@@ -79,7 +76,7 @@ def ensure_abrt_uid(fn):
99f8fd
 # TODO: unpack just required debuginfo and not entire rpm?
99f8fd
 # ..that can lead to: foo.c No such file and directory
99f8fd
 # files is not used...
99f8fd
-@ensure_abrt_uid
99f8fd
+@ensure_abrt_gid
99f8fd
 def unpack_rpm(package_full_path, files, tmp_dir, destdir, exact_files=False):
99f8fd
     """
99f8fd
     Unpacks a single rpm located in tmp_dir into destdir.
99f8fd
@@ -265,7 +262,7 @@ class DebugInfoDownload(object):
99f8fd
             else:
99f8fd
                 print("ERR: unmute called without mute?")
99f8fd
 
99f8fd
-    @ensure_abrt_uid
99f8fd
+    @ensure_abrt_gid
99f8fd
     def setup_tmp_dirs(self):
99f8fd
         if not os.path.exists(self.tmpdir):
99f8fd
             try:
99f8fd
@@ -406,9 +403,9 @@ class DebugInfoDownload(object):
99f8fd
 
99f8fd
                     s = os.stat(self.cachedir)
99f8fd
                     abrt = pwd.getpwnam("abrt")
99f8fd
-                    if (s.st_uid != abrt.pw_uid) or (s.st_gid != abrt.pw_gid):
99f8fd
-                        print(_("'{0}' must be owned by abrt. "
99f8fd
-                                "Please run '# chown -R abrt.abrt {0}' "
99f8fd
+                    if s.st_gid != abrt.pw_gid:
99f8fd
+                        print(_("'{0}' must be owned by group abrt. "
99f8fd
+                                "Please run '# chown -R :abrt {0}' "
99f8fd
                                 "to fix the issue.").format(self.cachedir))
99f8fd
 
99f8fd
                     clean_up(self.tmpdir)
99f8fd
-- 
99f8fd
2.21.3
99f8fd