Blame 0066-report-client-check-owner-of-var-cache-abrt-di-when-.patch

3a204fb
From 9e047438fa16f7e06d6049c35fcf1db2c48f6645 Mon Sep 17 00:00:00 2001
3a204fb
From: Matej Habrnal <mhabrnal@redhat.com>
3a204fb
Date: Tue, 12 May 2015 14:54:20 +0200
3a204fb
Subject: [PATCH] report client: check owner of /var/cache/abrt-di when
3a204fb
 unpacking fails
3a204fb
3a204fb
If unpacking of debuginfo fails and '/vat/cache/abrt-di' is not owned by
3a204fb
abrt.abrt the client provides a solution how to fix the issue.
3a204fb
3a204fb
Related to rhbz#1213485
3a204fb
3a204fb
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
3a204fb
---
3a204fb
 src/client-python/debuginfo.py | 12 ++++++++++--
3a204fb
 1 file changed, 10 insertions(+), 2 deletions(-)
3a204fb
3a204fb
diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
3a204fb
index a019d25..98bfd0c 100644
3a204fb
--- a/src/client-python/debuginfo.py
3a204fb
+++ b/src/client-python/debuginfo.py
3a204fb
@@ -5,6 +5,7 @@
3a204fb
 
3a204fb
 import sys
3a204fb
 import os
3a204fb
+import pwd
3a204fb
 import time
3a204fb
 import errno
3a204fb
 import shutil
3a204fb
@@ -30,7 +31,6 @@ def ensure_abrt_uid(fn):
3a204fb
         the function.
3a204fb
     """
3a204fb
 
3a204fb
-    import pwd
3a204fb
     current_uid = os.getuid()
3a204fb
     current_gid = os.getgid()
3a204fb
     abrt = pwd.getpwnam("abrt")
3a204fb
@@ -499,7 +499,15 @@ class DebugInfoDownload(YumBase):
3a204fb
                                            exact_files=download_exact_files)
3a204fb
                 if unpack_result == RETURN_FAILURE:
3a204fb
                     # recursively delete the temp dir on failure
3a204fb
-                    print _("Unpacking failed, aborting download...")
3a204fb
+                    print(_("Unpacking failed, aborting download..."))
3a204fb
+
3a204fb
+                    s = os.stat(self.cachedir)
3a204fb
+                    abrt = pwd.getpwnam("abrt")
3a204fb
+                    if (s.st_uid != abrt.pw_uid) or (s.st_gid != abrt.pw_gid):
3a204fb
+                        print(_("'{0}' must be owned by abrt. "
3a204fb
+                                 "Please run '# chown -R abrt.abrt {0}' "
3a204fb
+                                 "to fix the issue.").format(self.cachedir))
3a204fb
+
3a204fb
                     clean_up()
3a204fb
                     return RETURN_FAILURE
3a204fb
 
3a204fb
-- 
3a204fb
2.1.0
3a204fb