]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Cache timezone data in capsicum sandbox.
authorDarren Tucker <dtucker@dtucker.net>
Sat, 23 Apr 2022 10:17:26 +0000 (20:17 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Sat, 23 Apr 2022 11:14:01 +0000 (21:14 +1000)
From emaste at freebsd.org, originally part of FreeBSD commit r339216
fc3c19a9 with autoconf bits added by me.

configure.ac
sandbox-capsicum.c

index c285ea32b13d7d5735ac34f3f8730080a74c03f1..f25a638ea9142943fb333e528704a0d7e67bfb9e 100644 (file)
@@ -504,12 +504,20 @@ AC_CHECK_HEADERS([sys/audit.h], [], [], [
 ])
 
 # sys/capsicum.h requires sys/types.h
-AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
+AC_CHECK_HEADERS([sys/capsicum.h capsicum_helpers.h], [], [], [
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
 ])
 
+AC_MSG_CHECKING([for caph_cache_tzdata])
+AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([[ #include <capsicum_helpers.h> ]],
+       [[caph_cache_tzdata();]])],
+    [ AC_MSG_RESULT([yes]) ],
+    [ AC_MSG_RESULT([no]) ]
+)
+
 # net/route.h requires sys/socket.h and sys/types.h.
 # sys/sysctl.h also requires sys/param.h
 AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
index 883be185815a4d77afed570fc87e3f7f724404ed..11045251c88525bf7186e0b0323432a79081dccb 100644 (file)
@@ -29,6 +29,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#ifdef HAVE_CAPSICUM_HELPERS_H
+#include <capsicum_helpers.h>
+#endif
 
 #include "log.h"
 #include "monitor.h"
@@ -69,6 +72,10 @@ ssh_sandbox_child(struct ssh_sandbox *box)
        struct rlimit rl_zero;
        cap_rights_t rights;
 
+#ifdef HAVE_CAPH_CACHE_TZDATA
+       caph_cache_tzdata();
+#endif
+
        rl_zero.rlim_cur = rl_zero.rlim_max = 0;
 
        if (setrlimit(RLIMIT_FSIZE, &rl_zero) == -1)