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

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