Repository: trafficserver Updated Branches: refs/heads/master 52a1d2600 -> 3935dca18
Use common libts code to enable core dumps Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3935dca1 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3935dca1 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3935dca1 Branch: refs/heads/master Commit: 3935dca18d0d0dbeea466606d210b56ecee13ee9 Parents: 52a1d26 Author: James Peach <[email protected]> Authored: Fri Sep 12 09:16:48 2014 -0700 Committer: James Peach <[email protected]> Committed: Fri Sep 12 09:16:48 2014 -0700 ---------------------------------------------------------------------- cmd/traffic_manager/traffic_manager.cc | 18 +----------------- lib/ts/ink_cap.cc | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3935dca1/cmd/traffic_manager/traffic_manager.cc ---------------------------------------------------------------------- diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc index 087795a..423fca9 100644 --- a/cmd/traffic_manager/traffic_manager.cc +++ b/cmd/traffic_manager/traffic_manager.cc @@ -243,22 +243,6 @@ initSignalHandlers() sigaction(SIGCHLD, &sigChldHandler, NULL); } -#if defined(linux) -#include <sys/prctl.h> -#endif -static int -setup_coredump() -{ -#if defined(linux) -#ifndef PR_SET_DUMPABLE -#define PR_SET_DUMPABLE 4 /* Ugly, but we cannot compile with 2.2.x otherwise. - Should be removed when we compile only on 2.4.x */ -#endif - prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); -#endif // linux check - return 0; -} - static void init_dirs() { @@ -542,7 +526,7 @@ main(int argc, char **argv) set_process_limits(fds_throttle); // as root runAsUser(userToRunAs); - setup_coredump(); + EnableCoreFile(true); check_lockfile(); url_init(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3935dca1/lib/ts/ink_cap.cc ---------------------------------------------------------------------- diff --git a/lib/ts/ink_cap.cc b/lib/ts/ink_cap.cc index 7091144..26bb910 100644 --- a/lib/ts/ink_cap.cc +++ b/lib/ts/ink_cap.cc @@ -26,10 +26,13 @@ # include "ink_cap.h" # include "ink_thread.h" -# if TS_USE_POSIX_CAP -# include <sys/capability.h> -# include <sys/prctl.h> -# endif +#if HAVE_SYS_CAPABILITY_H +#include <sys/capability.h> +#endif + +#if HAVE_SYS_PRCTL_H +#include <sys/prctl.h> +#endif # if !TS_USE_POSIX_CAP ink_mutex ElevateAccess::lock = INK_MUTEX_INIT; @@ -98,15 +101,17 @@ RestrictCapabilities() { int EnableCoreFile(bool flag) { int zret = 0; -# if defined(linux) - int state = flag ? 1 : 0; - if (0 > (zret = prctl(PR_SET_DUMPABLE, state, 0, 0, 0))) { - Warning("Unable to set PR_DUMPABLE : %s", strerror(errno)); - } else if (state != prctl(PR_GET_DUMPABLE)) { - zret = ENOSYS; // best guess - Warning("Call to set PR_DUMPABLE was ineffective"); - } + +# if defined(PR_SET_DUMPABLE) + int state = flag ? 1 : 0; + if (0 > (zret = prctl(PR_SET_DUMPABLE, state, 0, 0, 0))) { + Warning("Unable to set PR_DUMPABLE : %s", strerror(errno)); + } else if (state != prctl(PR_GET_DUMPABLE)) { + zret = ENOSYS; // best guess + Warning("Call to set PR_DUMPABLE was ineffective"); + } # endif // linux check + Debug("proxy_priv", "[EnableCoreFile] zret : %d\n", zret); return zret; }
