|
57 | 57 | #define kCFPlatformInterfaceStringEncoding CFStringGetSystemEncoding()
|
58 | 58 | #endif
|
59 | 59 |
|
| 60 | +#ifndef __GLIBC_PREREQ |
| 61 | +#define __GLIBC_PREREQ(maj, min) 0 |
| 62 | +#endif |
| 63 | + |
60 | 64 | extern void __CFGetUGIDs(uid_t *euid, gid_t *egid);
|
61 | 65 |
|
62 | 66 | #if TARGET_OS_MAC
|
@@ -2274,6 +2278,31 @@ CF_EXPORT int _CFPosixSpawnFileActionsAddClose(_CFPosixSpawnFileActionsRef file_
|
2274 | 2278 | return posix_spawn_file_actions_addclose((posix_spawn_file_actions_t *)file_actions, filedes);
|
2275 | 2279 | }
|
2276 | 2280 |
|
| 2281 | +CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_actions, const char *path) { |
| 2282 | + #if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29) |
| 2283 | + // Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting: |
| 2284 | + // - Amazon Linux 2 (EoL mid-2025) |
| 2285 | + return ENOSYS; |
| 2286 | + #elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) |
| 2287 | + // Pre-standard posix_spawn_file_actions_addchdir_np version available in: |
| 2288 | + // - Solaris 11.3 (October 2015) |
| 2289 | + // - Glibc 2.29 (February 2019) |
| 2290 | + // - macOS 10.15 (October 2019) |
| 2291 | + // - musl 1.1.24 (October 2019) |
| 2292 | + // - FreeBSD 13.1 (May 2022) |
| 2293 | + // - Android 14 (October 2023) |
| 2294 | + return posix_spawn_file_actions_addchdir_np((posix_spawn_file_actions_t *)file_actions, path); |
| 2295 | + #else |
| 2296 | + // Standardized posix_spawn_file_actions_addchdir version (POSIX.1-2024, June 2024) available in: |
| 2297 | + // - Solaris 11.4 (August 2018) |
| 2298 | + // - NetBSD 10.0 (March 2024) |
| 2299 | + // Currently missing as of: |
| 2300 | + // - OpenBSD 7.5 (April 2024) |
| 2301 | + // - QNX 8 (December 2023) |
| 2302 | + return posix_spawn_file_actions_addchdir((posix_spawn_file_actions_t *)file_actions, path); |
| 2303 | + #endif |
| 2304 | +} |
| 2305 | + |
2277 | 2306 | CF_EXPORT int _CFPosixSpawn(pid_t *_CF_RESTRICT pid, const char *_CF_RESTRICT path, _CFPosixSpawnFileActionsRef file_actions, _CFPosixSpawnAttrRef _Nullable _CF_RESTRICT attrp, char *_Nullable const argv[_Nullable _CF_RESTRICT], char *_Nullable const envp[_Nullable _CF_RESTRICT]) {
|
2278 | 2307 | return posix_spawn(pid, path, (posix_spawn_file_actions_t *)file_actions, (posix_spawnattr_t *)attrp, argv, envp);
|
2279 | 2308 | }
|
|
0 commit comments