aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartik Naik <kartik@bugqore.com>2026-08-01 00:29:46 +0530
committerKartik Naik <kartik@bugqore.com>2026-08-01 00:29:46 +0530
commit4445467b5ce6d39478918d17fe117511935452c0 (patch)
tree94274ddf90e2c9cf90c6f3c176e25c31439b8482
parent3c46654fb6b3082e2835d6250320fa9cdd50a077 (diff)
downloadportable-4445467b5ce6d39478918d17fe117511935452c0.tar.gz
portable-4445467b5ce6d39478918d17fe117511935452c0.tar.bz2
portable-4445467b5ce6d39478918d17fe117511935452c0.zip
don't override pledge and unveil when the host provides them
-rw-r--r--CMakeLists.txt10
-rw-r--r--include/compat/unistd.h5
-rw-r--r--m4/check-libc.m42
3 files changed, 16 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ffe67b..cae3cb9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -343,6 +343,16 @@ if(HAVE_GETPROGNAME)
343 add_definitions(-DHAVE_GETPROGNAME) 343 add_definitions(-DHAVE_GETPROGNAME)
344endif() 344endif()
345 345
346check_symbol_exists(pledge "unistd.h" HAVE_PLEDGE)
347if(HAVE_PLEDGE)
348 add_definitions(-DHAVE_PLEDGE)
349endif()
350
351check_symbol_exists(unveil "unistd.h" HAVE_UNVEIL)
352if(HAVE_UNVEIL)
353 add_definitions(-DHAVE_UNVEIL)
354endif()
355
346check_symbol_exists(syslog_r "syslog.h;stdarg.h" HAVE_SYSLOG_R) 356check_symbol_exists(syslog_r "syslog.h;stdarg.h" HAVE_SYSLOG_R)
347if(HAVE_SYSLOG_R) 357if(HAVE_SYSLOG_R)
348 add_definitions(-DHAVE_SYSLOG_R) 358 add_definitions(-DHAVE_SYSLOG_R)
diff --git a/include/compat/unistd.h b/include/compat/unistd.h
index 544cb27..0ce66dd 100644
--- a/include/compat/unistd.h
+++ b/include/compat/unistd.h
@@ -75,8 +75,13 @@ int getentropy(void *buf, size_t buflen);
75int getpagesize(void); 75int getpagesize(void);
76#endif 76#endif
77 77
78#ifndef HAVE_PLEDGE
78#define pledge(request, paths) 0 79#define pledge(request, paths) 0
80#endif
81
82#ifndef HAVE_UNVEIL
79#define unveil(path, permissions) 0 83#define unveil(path, permissions) 0
84#endif
80 85
81#ifndef HAVE_PIPE2 86#ifndef HAVE_PIPE2
82int pipe2(int fildes[2], int flags); 87int pipe2(int fildes[2], int flags);
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4
index eec3cb3..42867cc 100644
--- a/m4/check-libc.m4
+++ b/m4/check-libc.m4
@@ -61,7 +61,7 @@ AM_CONDITIONAL([HAVE_SYSLOG_R], [test "x$ac_cv_func_syslog_r" = xyes])
61]) 61])
62 62
63AC_DEFUN([CHECK_SYSCALL_COMPAT], [ 63AC_DEFUN([CHECK_SYSCALL_COMPAT], [
64AC_CHECK_FUNCS([accept4 pipe2 pledge poll socketpair]) 64AC_CHECK_FUNCS([accept4 pipe2 pledge poll socketpair unveil])
65AM_CONDITIONAL([HAVE_ACCEPT4], [test "x$ac_cv_func_accept4" = xyes]) 65AM_CONDITIONAL([HAVE_ACCEPT4], [test "x$ac_cv_func_accept4" = xyes])
66AM_CONDITIONAL([HAVE_PIPE2], [test "x$ac_cv_func_pipe2" = xyes]) 66AM_CONDITIONAL([HAVE_PIPE2], [test "x$ac_cv_func_pipe2" = xyes])
67AM_CONDITIONAL([HAVE_PLEDGE], [test "x$ac_cv_func_pledge" = xyes]) 67AM_CONDITIONAL([HAVE_PLEDGE], [test "x$ac_cv_func_pledge" = xyes])