diff options
author | Darren Tucker <dtucker@dtucker.net> | 2022-11-06 00:50:01 +0100 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2022-11-07 00:54:29 +0100 |
commit | 0f7e1eba55259ec037f515000b4c4afbf446230a (patch) | |
tree | 8ab99209f33faecbf70af807a9f4bd3aaafcf81d /platform-tracing.c | |
parent | Fix setres*id checks to work with clang-16. (diff) | |
download | openssh-0f7e1eba55259ec037f515000b4c4afbf446230a.tar.xz openssh-0f7e1eba55259ec037f515000b4c4afbf446230a.zip |
Fix tracing disable on FreeBSD.
Some versions of FreeBSD do not support using id 0 to refer to the
current pid for procctl, so pass getpid() explicitly. From
emaste at freebsd.org.
Diffstat (limited to 'platform-tracing.c')
-rw-r--r-- | platform-tracing.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/platform-tracing.c b/platform-tracing.c index c2810f2d0..80488bf70 100644 --- a/platform-tracing.c +++ b/platform-tracing.c @@ -32,6 +32,7 @@ #include <stdarg.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #include "log.h" @@ -42,7 +43,16 @@ platform_disable_tracing(int strict) /* On FreeBSD, we should make this process untraceable */ int disable_trace = PROC_TRACE_CTL_DISABLE; - if (procctl(P_PID, 0, PROC_TRACE_CTL, &disable_trace) && strict) + /* + * On FreeBSD, we should make this process untraceable. + * pid=0 means "this process" and but some older kernels do not + * understand that, so retry with our own pid before failing. + */ + if (procctl(P_PID, 0, PROC_TRACE_CTL, &disable_trace) == 0) + return; + if (procctl(P_PID, getpid(), PROC_TRACE_CTL, &disable_trace) == 0) + return; + if (strict) fatal("unable to make the process untraceable: %s", strerror(errno)); #endif |