arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

Blame SOURCES/0093-ccpp-postpone-changing-ownership-of-new-dump-directo.patch

8ec399
From a4794b39efc62c9ba92b38b419de3babbbcd8cfb Mon Sep 17 00:00:00 2001
8ec399
From: Jakub Filak <jfilak@redhat.com>
8ec399
Date: Wed, 15 Apr 2015 15:27:09 +0200
8ec399
Subject: [ABRT PATCH] ccpp: postpone changing ownership of new dump
8ec399
 directories
8ec399
8ec399
Florian Weimer <fweimer@redhat.com>:
8ec399
8ec399
    Currently, dd_create changes ownership of the directory immediately,
8ec399
    when it is still empty. This means that any operations within the
8ec399
    directory (which happen as the root user) can race with changes to
8ec399
    the directory contents by the user. If you delay changing directory
8ec399
    ownership until all the files have created and written, this is no
8ec399
    longer a problem.
8ec399
8ec399
Related: #1211835
8ec399
8ec399
Signed-off-by: Jakub Filak <jfilak@redhat.com>
8ec399
---
8ec399
 src/hooks/abrt-hook-ccpp.c | 9 ++++++++-
8ec399
 1 file changed, 8 insertions(+), 1 deletion(-)
8ec399
8ec399
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
8ec399
index ece1ece..7e05aa6 100644
8ec399
--- a/src/hooks/abrt-hook-ccpp.c
8ec399
+++ b/src/hooks/abrt-hook-ccpp.c
8ec399
@@ -672,8 +672,12 @@ int main(int argc, char** argv)
8ec399
 
8ec399
     /* use fsuid instead of uid, so we don't expose any sensitive
8ec399
      * information of suided app in /var/tmp/abrt
8ec399
+     *
8ec399
+     * dd_create_skeleton() creates a new directory and leaves ownership to
8ec399
+     * the current user, hence, we have to call dd_reset_ownership() after the
8ec399
+     * directory is populated.
8ec399
      */
8ec399
-    dd = dd_create(path, fsuid, DEFAULT_DUMP_DIR_MODE);
8ec399
+    dd = dd_create_skeleton(path, fsuid, DEFAULT_DUMP_DIR_MODE);
8ec399
     if (dd)
8ec399
     {
8ec399
         char *rootdir = get_rootdir(pid);
8ec399
@@ -831,6 +835,9 @@ int main(int argc, char** argv)
8ec399
         }
8ec399
 #endif
8ec399
 
8ec399
+        /* And finally set the right uid and gid */
8ec399
+        dd_reset_ownership(dd);
8ec399
+
8ec399
         /* We close dumpdir before we start catering for crash storm case.
8ec399
          * Otherwise, delete_dump_dir's from other concurrent
8ec399
          * CCpp's won't be able to delete our dump (their delete_dump_dir
8ec399
-- 
8ec399
1.8.3.1
8ec399