From 9f3c877131ee9380150d27afa87af238d9812446 Mon Sep 17 00:00:00 2001 From: Mahdi Ali-Raihan Date: Sun, 30 Aug 2026 18:28:48 -0400 Subject: [PATCH] Unix: Add `_PATH_BSHELL` and `_PATH_DEFPATH` where available. The following are sources to each platform's `paths.h`: From BSD: * [Apple](https://github.com/apple-oss-distributions/Libc/blob/71bbe350ab79eef58113991d817ccc6165061a64/include/paths.h#L65): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [Dragonfly](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/42aaacafd14ddb7f660730a5ca5da0a2d941723a/include/paths.h#L40): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [FreeBSD](https://github.com/freebsd/freebsd-src/blob/551b7c5e12bfea623a47edf97ad5689732a1233f/include/paths.h#L40): Has `_PATH_BSHELL` and `_PATH_DEFPATH` (verified same values on version 11+) * [NetBSD](https://github.com/NetBSD/src/blob/f66621237dc60126bd8a972b6064639892b344b7/include/paths.h#L43): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [OpenBSD](https://github.com/openbsd/src/blob/7d89a3e823169cb6a1d989e3f5f93f7f3c4b5db4/include/paths.h#L39): Has `_PATH_BSHELL` and `_PATH_DEFPATH` From Linux: * [Android](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/paths.h#48): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [glibc](https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/paths.h;h=1342ab3a96ab12065311b718e57e7235e07587f8;hb=HEAD#l36): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [musl](https://git.musl-libc.org/cgit/musl/tree/include/paths.h?id=f21a96538f78fa8e2040831b4209b35f2fb581da#n4): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [uClibc](https://github.com/kraj/uClibc/blob/ca1c74d67dd115d059a875150e10b8560a9c35a8/include/paths.h#L36): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [emscripten](https://github.com/emscripten-core/emscripten/blob/a2059f978ed206b688daf4a8774211949610c2aa/system/lib/libc/musl/include/paths.h#L4): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * l4re: There's [musl](https://github.com/l4re/l4re-core/blob/d09b1619c45d17786bc256ea219688f8ba3ff1fe/libc/musl/contrib/musl/include/paths.h#L4) and [uclibc](https://github.com/l4re/l4re-core/blob/d09b1619c45d17786bc256ea219688f8ba3ff1fe/libc/uclibc-ng/contrib/uclibc/include/paths.h#L36) `paths.h` file containing `_PATH_BSHELL` and `_PATH_DEFPATH` values Miscellaneous Platforms: * [Haiku](https://github.com/haiku/haiku/blob/8a33129223e93ea046dc62e9e09f8c93f45cfb7b/headers/compatibility/bsd/paths.h#L45): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [Hurd](https://github.com/joshumax/hurd/blob/83a6fc7641eecdb2b96c2dee2261da92573693de/hurd/paths.h#L20): Doesn't have `_PATH_BSHELL` and `_PATH_DEFPATH` in paths.h (wouldn't hurt to confirm this though in terminal) * [Cygwin](https://github.com/cygwin/cygwin/blob/cf61e0140e3d6cd21e743a38d35efc98194b63f3/winsup/cygwin/include/paths.h#L12): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [newlib](https://github.com/ourairquality/newlib/blob/0dea38754696422d526543262274703acd8317c5/newlib/libc/include/paths.h#L7): Has `_PATH_BSHELL` * [Redox](https://gitlab.redox-os.org/redox-os/relibc/-/blob/c3b3f2773a3a2622fdb632a9bfa1a77d68778150/include/paths.h): Has `_PATH_BSHELL` Platforms I'm unsure if they have `_PATH_BSHELL`/`_PATH_DEFPATH`: * Solarish: I'm unsure how to get this info since I believe Solaris is closed source? * AIX: I think this is also closed source? However, I saw this [archive repo](https://github.com/Arquivotheca/AIX-4.1.3/blob/d6fe8fe8299ececc0db4fae9c19cd3babffd28ae/bos/usr/include/paths.h#L36) of AIX 4.13 that has `_PATH_BSHELL`. * [nuttx](https://github.com/apache/nuttx): Couldn't find a `include/paths.h` file. * [NTO/QNX](https://github.com/qnx): Couldn't find a `include/paths.h` file. --- libc-test/build/main.rs | 11 +++++++++++ libc-test/semver/android.txt | 2 ++ libc-test/semver/apple.txt | 2 ++ libc-test/semver/cygwin.txt | 2 ++ libc-test/semver/dragonfly.txt | 2 ++ libc-test/semver/espidf.txt | 1 + libc-test/semver/freebsd.txt | 2 ++ libc-test/semver/linux.txt | 2 ++ libc-test/semver/netbsd.txt | 2 ++ libc-test/semver/openbsd.txt | 2 ++ libc-test/semver/redox.txt | 1 + src/macros.rs | 1 + src/types.rs | 8 ++++++++ src/unix/bsd/apple/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/dragonfly/mod.rs | 6 ++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 5 +++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 4 ++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 5 +++++ src/unix/cygwin/mod.rs | 4 ++++ src/unix/haiku/mod.rs | 4 ++++ src/unix/linux_like/android/mod.rs | 8 ++++++++ src/unix/linux_like/emscripten/mod.rs | 4 ++++ src/unix/linux_like/l4re/uclibc/mod.rs | 4 ++++ src/unix/linux_like/linux/gnu/mod.rs | 4 ++++ src/unix/linux_like/linux/musl/mod.rs | 4 ++++ src/unix/linux_like/linux/uclibc/mod.rs | 4 ++++ src/unix/newlib/mod.rs | 3 +++ src/unix/redox/mod.rs | 3 +++ 28 files changed, 104 insertions(+) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 9cc1aa565e934..490f0f2c84c2f 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -200,6 +200,7 @@ fn test_apple(t: &Target) { "os/lock.h", "os/signpost.h", "os/os_sync_wait_on_address.h", + "paths.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -473,6 +474,7 @@ fn test_openbsd(t: &Target) { "sys/shm.h", "sys/param.h", "sys/auxv.h", + "paths.h", ); cfg.rename_type(|ty| match ty { @@ -574,6 +576,7 @@ fn test_cygwin(t: &Target) { "net/if.h", "netdb.h", "netinet/tcp.h", + "paths.h", "poll.h", "pthread.h", "pty.h", @@ -875,6 +878,7 @@ fn test_redox(t: &Target) { "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", + "paths.h", "poll.h", "pwd.h", "semaphore.h", @@ -1303,6 +1307,7 @@ fn test_netbsd(t: &Target) { "iconv.h", "utmp.h", "utmpx.h", + "paths.h", ); cfg.rename_type(move |ty| { @@ -1546,6 +1551,7 @@ fn test_dragonflybsd(t: &Target) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -2077,6 +2083,7 @@ fn test_android(t: &Target) { // generate the error 'Your time_t is already 64-bit' (t.p32(), "time64.h"), (x86, "sys/reg.h"), + "paths.h", ); // Include linux headers at the end: @@ -2560,6 +2567,7 @@ fn test_freebsd(t: &Target) { "netinet/tcp.h", "netinet/udp.h", "netinet6/in6_var.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -3247,6 +3255,7 @@ fn test_emscripten(t: &Target) { "utmp.h", "utmpx.h", "wchar.h", + "paths.h", ); cfg.rename_struct_ty(move |ty| { @@ -4106,6 +4115,7 @@ fn test_linux(t: &Target) { // https://www.openwall.com/lists/musl/2015/04/09/3 // is not present on uclibc. (!(musl || uclibc), "execinfo.h"), + "paths.h", ); // Include linux headers at the end: @@ -5494,6 +5504,7 @@ fn test_haiku(t: &Target) { "netinet6/in6.h", "nl_types.h", "null.h", + "paths.h", "poll.h", "pthread.h", "pwd.h", diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 80cc88cfd7d26..bd838a4e46768 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3175,6 +3175,8 @@ X_OK _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 23ecfd6c19507..52f0c2afe1f3b 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1627,6 +1627,8 @@ _NSGetArgc _NSGetArgv _NSGetEnviron _NSGetProgname +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 691271e61ac7b..6fa71843e3084 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -472,6 +472,8 @@ WINDOWS_SEND XTABS _CS_PATH _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6a14a615b8bb5..aa69de5cbadcf 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1171,6 +1171,8 @@ _CS_PATH _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_ACL_PATH_MAX diff --git a/libc-test/semver/espidf.txt b/libc-test/semver/espidf.txt index f9f9089b9e371..df8bd8b8037e7 100644 --- a/libc-test/semver/espidf.txt +++ b/libc-test/semver/espidf.txt @@ -32,6 +32,7 @@ SIGSEGV SIGTERM SOL_SOCKET SOMAXCONN +_PATH_BSHELL __errno cmsghdr dirent diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 252f7fff46866..f905fc33f0849 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1766,6 +1766,8 @@ _IOR _IOW _IOWINT _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_ACL_EXTENDED _PC_ACL_NFS4 _PC_ACL_PATH_MAX diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index a97e1a31f8362..71b5ebcca04d9 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3873,6 +3873,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 1169ec12b0128..9e5c18f1ce67d 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1127,6 +1127,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_FILESIZEBITS diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index f7933a856d640..5fc4cb13add75 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -985,6 +985,8 @@ _IOR _IOW _IOWR _MAX_PAGE_SHIFT +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 8753284191f4b..f308714962bc8 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -258,6 +258,7 @@ _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _IOFBF _IOLBF _IONBF +_PATH_BSHELL _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/src/macros.rs b/src/macros.rs index 6e5aafd637408..a8b38a0d6cff5 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -112,6 +112,7 @@ macro_rules! prelude { pub(crate) use crate::types::u32_cast_ioctl; #[allow(unused_imports)] pub(crate) use crate::types::{ + cstr, replace_array_items, u16_cast_short, u32_cast_int, diff --git a/src/types.rs b/src/types.rs index 7be6e78bce3fe..96322d3d3954f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -138,3 +138,11 @@ pub const fn replace_array_items( } dst } + +/// Constructs a compile time cstring literal from a byte array +// FIXME(msrv): we can opt to use C-string literals directly in 1.77 +#[allow(dead_code)] +pub(crate) const fn cstr(bytes: &[u8]) -> *const c_char { + assert!(!bytes.is_empty() && bytes[bytes.len() - 1] == 0); + bytes.as_ptr().cast::() +} diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9cbf2c807a350..cb26571b690e5 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4111,6 +4111,10 @@ pub const VMADDR_CID_RESERVED: c_uint = 1; pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn __DARWIN_ALIGN32(p: usize) -> usize { const __DARWIN_ALIGNBYTES32: usize = size_of::() - 1; (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 17610214e5e60..54511cf013f2e 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1232,6 +1232,12 @@ pub const RTAX_MPLS3: c_int = 10; /// for details. pub const RTAX_MAX: c_int = 11; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/pkg/bin:/usr/pkg/sbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn _CMSG_ALIGN(n: usize) -> usize { (n + (size_of::() - 1)) & !(size_of::() - 1) } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 2d9e00c49a638..395839932cd42 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4318,6 +4318,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 8b7bfd24824c9..e7fa6cdc23597 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1813,6 +1813,10 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 89348d7ec1560..220bd0cb3dc80 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1831,6 +1831,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 5645bdd2b2dcf..6681080e81d66 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1678,6 +1678,10 @@ pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x0008; pub const FALLOC_FL_INSERT_RANGE: c_int = 0x0010; pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index a98e4b17bcce6..cb0b3393e7ff9 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1386,6 +1386,10 @@ pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20; pub const POSIX_SPAWN_SETSID: c_short = 0x40; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 3173c04a13438..872f9426aae15 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3410,6 +3410,14 @@ pub const RWF_NOAPPEND: c_int = 0x00000020; pub const RWF_ATOMIC: c_int = 0x00000040; pub const RWF_DONTCACHE: c_int = 0x00000080; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/product/bin:/apex/com.android.runtime/bin:\ + /apex/com.android.art/bin:/system_ext/bin:/system/bin:\ + /system/xbin:/odm/bin:/vendor/bin:/vendor/xbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/system/bin/sh\0"); + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 73b6cf71f11b3..f06e99fa8873a 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1279,6 +1279,10 @@ pub const PRIO_USER: c_int = 2; pub const SOMAXCONN: c_int = 128; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 5d819e0212a68..7e5aa699f0f59 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -478,6 +478,10 @@ pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3; pub const __LT_SPINLOCK_INIT: c_int = 0; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { __status: 0, __spinlock: __LT_SPINLOCK_INIT, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 5202303d196c9..ba5b0b9f08410 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -944,6 +944,10 @@ pub const GLOB_TILDE_CHECK: c_int = 1 << 14; pub const MADV_COLLAPSE: c_int = 25; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(any( target_arch = "arm", diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index d301713cd8fe4..c8db3875d4b31 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -790,6 +790,10 @@ pub const UT_HOSTSIZE: usize = 256; pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index dd54a15e25fb0..7b2299b4b317e 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -335,6 +335,10 @@ pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; pub const UDP_SEGMENT: c_int = 103; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index f5c7396d67d94..211027239f953 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -842,6 +842,9 @@ pub const PRIO_PROCESS: c_int = 0; pub const PRIO_PGRP: c_int = 1; pub const PRIO_USER: c_int = 2; +// include/paths.h from newlib's libc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let bits = size_of_val(&(*set).fds_bits[0]) * 8; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index d092f0eee9041..5ba06617fb2a1 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1102,6 +1102,9 @@ pub const PRIO_USER: c_int = 2; pub const RENAME_NOREPLACE: c_uint = 1; +// include/paths.h from relibc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { //sys/socket.h pub const unsafe fn CMSG_ALIGN(len: size_t) -> size_t {