[openssh-commits] [openssh] 01/03: check for setsockopt IP_TOS in OpenBSD pledge
git+noreply at mindrot.org
git+noreply at mindrot.org
Mon Aug 18 16:50:08 AEST 2025
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 9184fa363687fcb5dac056b093fb3b8e9d327242
Author: Damien Miller <djm at mindrot.org>
AuthorDate: Mon Aug 18 16:45:15 2025 +1000
check for setsockopt IP_TOS in OpenBSD pledge
OpenBSD has recently relaxed the pledge(2) sandbox to allow some
setsockopt options to be changed without the "inet" promise.
This adds compatibility for OpenBSD that predates this relaxation.
---
clientloop.c | 4 ++--
configure.ac | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/clientloop.c b/clientloop.c
index b9a010414..577771f06 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -975,11 +975,11 @@ client_repledge(void)
} else if (options.forward_agent != 0) {
/* agent forwarding needs to open $SSH_AUTH_SOCK at will */
debug("pledge: agent");
- if (pledge("stdio unix proc tty", NULL) == -1)
+ if (pledge(PLEDGE_EXTRA_INET "stdio unix proc tty", NULL) == -1)
fatal_f("pledge(): %s", strerror(errno));
} else {
debug("pledge: fork");
- if (pledge("stdio proc tty", NULL) == -1)
+ if (pledge(PLEDGE_EXTRA_INET "stdio proc tty", NULL) == -1)
fatal_f("pledge(): %s", strerror(errno));
}
/* XXX further things to do:
diff --git a/configure.ac b/configure.ac
index 460ebd3b4..bc1900af7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1128,6 +1128,35 @@ mips-sony-bsd|mips-sony-newsos4)
AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
[syslog_r function is safe to use in in a signal handler])
TEST_MALLOC_OPTIONS="SJRU"
+ AC_MSG_CHECKING([whether pledge(2) allows IP_TOS])
+ need_pledge_inet=""
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <err.h>
+ ]], [[
+int s, one = 1;
+if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ err(1, "socket");
+if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+if (setsockopt(s, IPPROTO_IP, IP_TOS, &one, sizeof(one)) == -1)
+ err(1, "setsockopt");
+ ]])],
+ [ AC_MSG_RESULT([yes]) ], [
+ AC_MSG_RESULT([no])
+ need_pledge_inet=1
+ ],
+ [ AC_MSG_WARN([cross compiling: cannot test]) ])
+ if test -z "$need_pledge_inet" ; then
+ AC_DEFINE_UNQUOTED([PLEDGE_EXTRA_INET], [])
+ else
+ AC_DEFINE_UNQUOTED([PLEDGE_EXTRA_INET], ["inet "],
+ [need inet in pledge for setsockopt IP_TOS])
+ fi
;;
*-*-solaris*)
if test "x$withval" != "xno" ; then
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list