From f4294538bbeb77c910b083f1d385cf98d752e5b2 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 9 Aug 2010 14:29:09 +0200 Subject: [PATCH] Daemon: make core files work if setuid is in use --- configure.ac | 2 +- src/daemon.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6e50432..c31a5e9 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl YAZ_DOC dnl dnl -AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h],[],[],[]) +AC_CHECK_HEADERS([dirent.h fnmatch.h wchar.h locale.h langinfo.h pwd.h unistd.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/times.h sys/types.h sys/un.h sys/wait.h sys/prctl.h netdb.h arpa/inet.h netinet/tcp.h netinet/in_systm.h],[],[],[]) AC_CHECK_HEADERS([net/if.h netinet/in.h netinet/if_ether.h],[],[],[ #if HAVE_SYS_TYPES_H #include diff --git a/src/daemon.c b/src/daemon.c index a4d0fd4..69c2330 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -33,6 +33,10 @@ #include #endif +#if HAVE_SYS_PRCTL_H +#include +#endif + #include #include #include @@ -199,6 +203,13 @@ int yaz_daemon(const char *progname, yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid"); exit(1); } + /* Linux don't produce core dumps evern if the limit is right and + files are writable.. This fixes this. See prctl(2) */ +#if HAVE_SYS_PRCTL_H +#ifdef PR_SET_DUMPABLE + prctl(PR_SET_DUMPABLE, 1, 0, 0); +#endif +#endif } if (flags & YAZ_DAEMON_FORK) -- 1.7.10.4