]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Disable tracing on FreeBSD using procctl.
authorDavid Carlier <devnexen@gmail.com>
Wed, 8 Sep 2021 18:49:54 +0000 (19:49 +0100)
committerDarren Tucker <dtucker@dtucker.net>
Thu, 9 Sep 2021 08:13:27 +0000 (18:13 +1000)
Placed at the start of platform_disable_tracing() to prevent declaration
after code errors from strict C89 compilers (in the unlikely event that
more than one method is enabled).

configure.ac
platform-tracing.c

index f0eb24b867391557e92b473d49bde5479a646d35..413913a7c72edb3487783b67cf875c0b53a463c8 100644 (file)
@@ -454,6 +454,7 @@ AC_CHECK_HEADERS([ \
        sys/ndir.h \
        sys/poll.h \
        sys/prctl.h \
+       sys/procctl.h \
        sys/pstat.h \
        sys/ptrace.h \
        sys/random.h \
@@ -1868,6 +1869,7 @@ AC_CHECK_FUNCS([ \
        pledge \
        poll \
        prctl \
+       procctl \
        pselect \
        pstat \
        raise \
index 4c80a282c4930db549e42814c917626464c6b36d..0daf2a86f333455cb0844c169bc0d46eb26b1991 100644 (file)
@@ -17,6 +17,9 @@
 #include "includes.h"
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_PROCCTL_H
+#include <sys/procctl.h>
+#endif
 #if defined(HAVE_SYS_PRCTL_H)
 #include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */
 #endif
 void
 platform_disable_tracing(int strict)
 {
+#if defined(HAVE_PROCCTL) && defined(PROC_TRACE_CTL)
+       /* 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)
+               fatal("unable to make the process untraceable");
+#endif
 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
        /* Disable ptrace on Linux without sgid bit */
        if (prctl(PR_SET_DUMPABLE, 0) != 0 && strict)