]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7088 #resolve Set flag to enable core dump from non-root users.
authorHumberto Diógenes <hdiogenes@gmail.com>
Tue, 16 Dec 2014 18:12:28 +0000 (15:12 -0300)
committerHumberto Diógenes <hdiogenes@gmail.com>
Tue, 6 Jan 2015 00:06:29 +0000 (21:06 -0300)
When FreeSWITCH is running as a non-privileged user, we need to enable
PR_SET_DUMPABLE for it to be able to generate core dumps.

Instead of a generic __linux__ check, there's a new configure.ac flag
to check directly for prctl.h, which could also be used in other
places in the code.

configure.ac
src/switch_core.c

index a91690aeca76577edafffabb07224460a3eb0828..160c79f72a1edbfd4491680df184036200e7791f 100644 (file)
@@ -766,7 +766,7 @@ AC_SUBST(LIBTOOL_LIB_EXTEN)
 # Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([sys/types.h sys/resource.h sched.h wchar.h sys/filio.h sys/ioctl.h sys/select.h netdb.h execinfo.h])
+AC_CHECK_HEADERS([sys/types.h sys/resource.h sched.h wchar.h sys/filio.h sys/ioctl.h sys/prctl.h sys/select.h netdb.h execinfo.h])
 
 if test x"$ac_cv_header_wchar_h" = xyes; then
   HAVE_WCHAR_H_DEFINE=1
index 59682df609f8627e71930b56f3ecf873a67644c2..b2216ec2b5e0c0a88815ec3dd7789f87a981973d 100644 (file)
@@ -51,6 +51,9 @@
 #endif
 #include <errno.h>
 #include <sqlite3.h>
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 
 
 SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
@@ -1029,6 +1032,12 @@ SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group)
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to change uid!\n");
                        return -1;
                }
+#ifdef HAVE_SYS_PRCTL_H
+               if (prctl(PR_SET_DUMPABLE, 1) < 0) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to enable core dumps!\n");
+                       return -1;
+               }
+#endif
        }
 #endif
        return 0;