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

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