mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-04 19:00:09 +00:00
db8cbc6a7a
This patch replaces the fork+exec by posix_spawn on wordexp, which allows a better scability on Linux and simplifies the thread cancellation handling. The only change which can not be implemented with posix_spawn the /dev/null check to certify it is indeed the expected device. I am not sure how effetive this check is since /dev/null tampering means something very wrong with the system and this is the least of the issues. My view is the tests is really out of the place and the hardening provided is minimum. If the idea is still to provide such check, I think a possibilty would be to open /dev/null, check it, add a dup2 file action, and close the file descriptor. Checked on powerpc64le-linux-gnu and x86_64-linux-gnu. * include/spawn.h (__posix_spawn_file_actions_addopen): New prototype. * posix/spawn_faction_addopen.c (posix_spawn_file_actions_addopen): Add internal alias. * posix/wordexp.c (create_environment, free_environment): New functions. (exec_comm_child, exec_comm): Use posix_spawn instead of fork+exec. * posix/wordexp-test.c: Use libsupport.
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#ifndef _SPAWN_H
|
|
#include <posix/spawn.h>
|
|
|
|
# ifndef _ISOMAC
|
|
__typeof (posix_spawn) __posix_spawn;
|
|
libc_hidden_proto (__posix_spawn)
|
|
|
|
__typeof (posix_spawn_file_actions_addclose)
|
|
__posix_spawn_file_actions_addclose attribute_hidden;
|
|
|
|
__typeof (posix_spawn_file_actions_adddup2)
|
|
__posix_spawn_file_actions_adddup2 attribute_hidden;
|
|
|
|
__typeof (posix_spawn_file_actions_addopen)
|
|
__posix_spawn_file_actions_addopen attribute_hidden;
|
|
|
|
__typeof (posix_spawn_file_actions_destroy)
|
|
__posix_spawn_file_actions_destroy attribute_hidden;
|
|
|
|
__typeof (posix_spawn_file_actions_init) __posix_spawn_file_actions_init
|
|
attribute_hidden;
|
|
|
|
__typeof (posix_spawnattr_init) __posix_spawnattr_init
|
|
attribute_hidden;
|
|
|
|
__typeof (posix_spawnattr_destroy) __posix_spawnattr_destroy
|
|
attribute_hidden;
|
|
|
|
__typeof (posix_spawnattr_setflags) __posix_spawnattr_setflags
|
|
attribute_hidden;
|
|
|
|
__typeof (posix_spawnattr_setsigdefault) __posix_spawnattr_setsigdefault
|
|
attribute_hidden;
|
|
|
|
__typeof (posix_spawnattr_setsigmask) __posix_spawnattr_setsigmask
|
|
attribute_hidden;
|
|
|
|
# endif /* !_ISOMAC */
|
|
#endif /* spawn.h */
|