r22318: If we're running as non root we might not be able to dump the core file
[abartlet/samba.git/.git] / source3 / lib / fault.c
index b214d9027ea5b1fb8b068e5231bcaf8382880c9a..26b48a80cd05401e8ecb080f2d2c3847309ab9bf 100644 (file)
@@ -161,6 +161,13 @@ void dump_core_setup(const char *progname)
        }
 
 #if DUMP_CORE
+       /* If we're running as non root we might not be able to dump the core
+        * file to the corepath.  There must not be an unbecome_root() before
+        * we call abort(). */
+       if (getuid() != 0) {
+               become_root();
+       }
+
        if (*corepath != '\0') {
                /* The chdir might fail if we dump core before we finish
                 * processing the config file.