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

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