Skip to content

Commit 83697aa

Browse files
authored
fpm allow to ptrace/make the the process dumpable for FreeBSD. (#7375)
1 parent ed03204 commit 83697aa

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

sapi/fpm/config.m4

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ AC_DEFUN([AC_FPM_PRCTL],
2525
])
2626
])
2727

28+
AC_DEFUN([AC_FPM_PROCCTL],
29+
[
30+
AC_MSG_CHECKING([for procctl])
31+
32+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/procctl.h>]], [[procctl(0, 0, 0, 0);]])], [
33+
AC_DEFINE([HAVE_PROCCTL], 1, [do we have procctl?])
34+
AC_MSG_RESULT([yes])
35+
], [
36+
AC_MSG_RESULT([no])
37+
])
38+
])
39+
2840
AC_DEFUN([AC_FPM_CLOCK],
2941
[
3042
have_clock_gettime=no
@@ -494,6 +506,7 @@ if test "$PHP_FPM" != "no"; then
494506

495507
AC_FPM_STDLIBS
496508
AC_FPM_PRCTL
509+
AC_FPM_PROCCTL
497510
AC_FPM_CLOCK
498511
AC_FPM_TRACE
499512
AC_FPM_BUILTIN_ATOMIC

sapi/fpm/fpm/fpm_unix.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <sys/prctl.h>
1616
#endif
1717

18+
#ifdef HAVE_PROCCTL
19+
#include <sys/procctl.h>
20+
#endif
21+
1822
#ifdef HAVE_APPARMOR
1923
#include <sys/apparmor.h>
2024
#endif
@@ -409,6 +413,13 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
409413
}
410414
#endif
411415

416+
#ifdef HAVE_PROCCTL
417+
int dumpable = PROC_TRACE_CTL_ENABLE;
418+
if (wp->config->process_dumpable && -1 == procctl(P_PID, getpid(), PROC_TRACE_CTL, &dumpable)) {
419+
zlog(ZLOG_SYSERROR, "[pool %s] failed to procctl(PROC_TRACE_CTL)", wp->config->name);
420+
}
421+
#endif
422+
412423
if (0 > fpm_clock_init()) {
413424
return -1;
414425
}

sapi/fpm/www.conf.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ listen = 127.0.0.1:9000
7070
; Default Value: no set
7171
; process.priority = -19
7272

73-
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
73+
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
74+
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
7475
; or group is different than the master process user. It allows to create process
7576
; core dump and ptrace the process for the pool user.
7677
; Default Value: no

0 commit comments

Comments
 (0)