]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Fix tracing disable on FreeBSD.
authorDarren Tucker <dtucker@dtucker.net>
Sat, 5 Nov 2022 23:50:01 +0000 (10:50 +1100)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 7 Nov 2022 00:01:20 +0000 (11:01 +1100)
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.

platform-tracing.c

index c2810f2d0b36bb1d62f6e51d740e2c149244a3d1..80488bf701042f83adb35f8edc48d74da0d8cfd0 100644 (file)
@@ -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