close bug #361
authoraland <aland>
Tue, 18 Apr 2006 17:26:26 +0000 (17:26 +0000)
committeraland <aland>
Tue, 18 Apr 2006 17:26:26 +0000 (17:26 +0000)
Set dumpable after uid switch, if allow core dumps is set

configure.in
src/main/mainconfig.c

index d0298d5..9089c93 100644 (file)
@@ -534,6 +534,7 @@ AC_CHECK_HEADERS( \
        fcntl.h \
        sys/fcntl.h \
        sys/stat.h \
+       sys/prctl.h \
        prot.h \
        sia.h \
        siad.h
index 4d29287..c58c9c6 100644 (file)
@@ -49,6 +49,9 @@
 #include <grp.h>
 #include <pwd.h>
 
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 
 #ifdef WITH_UDPFROMTO
 #include "udpfromto.h"
@@ -1415,6 +1418,17 @@ int read_mainconfig(int reload)
        }
        switch_users();
 
+#ifdef HAVE_SYS_PRCTL_H
+#ifdef HAVE_PR_SET_DUMPABLE
+       if (mainconfig.allow_core_dumps) {
+               if (prctl(PR_SET_DUMPABLE, 1) < 0) {
+                       radlog(L_ERR|L_CONS,"Cannot enable core dumps: prctl(PR_SET_DUMPABLE) failed: '%s'",
+                              strerror(errno));
+               }
+       }
+#endif
+#endif
+
        /*
         *      Sanity check the configuration for internal
         *      consistency.