Skip to content

fpm allow to ptrace/make the the process dumpable for FreeBSD. #7375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sapi/fpm/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ AC_DEFUN([AC_FPM_PRCTL],
])
])

AC_DEFUN([AC_FPM_PROCCTL],
[
AC_MSG_CHECKING([for procctl])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/procctl.h>]], [[procctl(0, 0, 0, 0);]])], [
AC_DEFINE([HAVE_PROCCTL], 1, [do we have procctl?])
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
])

AC_DEFUN([AC_FPM_CLOCK],
[
have_clock_gettime=no
Expand Down Expand Up @@ -494,6 +506,7 @@ if test "$PHP_FPM" != "no"; then

AC_FPM_STDLIBS
AC_FPM_PRCTL
AC_FPM_PROCCTL
AC_FPM_CLOCK
AC_FPM_TRACE
AC_FPM_BUILTIN_ATOMIC
Expand Down
11 changes: 11 additions & 0 deletions sapi/fpm/fpm/fpm_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <sys/prctl.h>
#endif

#ifdef HAVE_PROCCTL
#include <sys/procctl.h>
#endif

#ifdef HAVE_APPARMOR
#include <sys/apparmor.h>
#endif
Expand Down Expand Up @@ -409,6 +413,13 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
}
#endif

#ifdef HAVE_PROCCTL
int dumpable = PROC_TRACE_CTL_ENABLE;
if (wp->config->process_dumpable && -1 == procctl(P_PID, getpid(), PROC_TRACE_CTL, &dumpable)) {
zlog(ZLOG_SYSERROR, "[pool %s] failed to procctl(PROC_TRACE_CTL)", wp->config->name);
}
#endif

if (0 > fpm_clock_init()) {
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion sapi/fpm/www.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ listen = 127.0.0.1:9000
; Default Value: no set
; process.priority = -19

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