Blob Blame History Raw
From 9e047438fa16f7e06d6049c35fcf1db2c48f6645 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Tue, 12 May 2015 14:54:20 +0200
Subject: [PATCH] report client: check owner of /var/cache/abrt-di when
 unpacking fails

If unpacking of debuginfo fails and '/vat/cache/abrt-di' is not owned by
abrt.abrt the client provides a solution how to fix the issue.

Related to rhbz#1213485

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
 src/client-python/debuginfo.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
index a019d25..98bfd0c 100644
--- a/src/client-python/debuginfo.py
+++ b/src/client-python/debuginfo.py
@@ -5,6 +5,7 @@
 
 import sys
 import os
+import pwd
 import time
 import errno
 import shutil
@@ -30,7 +31,6 @@ def ensure_abrt_uid(fn):
         the function.
     """
 
-    import pwd
     current_uid = os.getuid()
     current_gid = os.getgid()
     abrt = pwd.getpwnam("abrt")
@@ -499,7 +499,15 @@ class DebugInfoDownload(YumBase):
                                            exact_files=download_exact_files)
                 if unpack_result == RETURN_FAILURE:
                     # recursively delete the temp dir on failure
-                    print _("Unpacking failed, aborting download...")
+                    print(_("Unpacking failed, aborting download..."))
+
+                    s = os.stat(self.cachedir)
+                    abrt = pwd.getpwnam("abrt")
+                    if (s.st_uid != abrt.pw_uid) or (s.st_gid != abrt.pw_gid):
+                        print(_("'{0}' must be owned by abrt. "
+                                 "Please run '# chown -R abrt.abrt {0}' "
+                                 "to fix the issue.").format(self.cachedir))
+
                     clean_up()
                     return RETURN_FAILURE
 
-- 
2.1.0