support: Add capability to fork an sgid child

System Internals / glibc - Siddhesh Poyarekar [] - 12 April 2021 13:33 UTC

Add a new function support_capture_subprogram_self_sgid that spawns an sgid child of the running program with its own image and returns the exit code of the child process. This functionality is used by at least three tests in the testsuite at the moment, so it makes sense to consolidate.

There is also a new function support_subprogram_wait which should provide simple system() like functionality that does not set up file actions. This is useful in cases where only the return code of the spawned subprocess is interesting.

This patch also ports tst-secure-getenv to this new function. A subsequent patch will port other tests. This also brings an important change to tst-secure-getenv behaviour. Now instead of succeeding, the test fails as UNSUPPORTED if it is unable to spawn a setgid child, which is how it should have been in the first place.

716a3bdc41 support: Add capability to fork an sgid child
stdlib/tst-secure-getenv.c | 199 ++++-------------------------------
support/capture_subprocess.h | 6 ++
support/subprocess.h | 5 +
support/support_capture_subprocess.c | 126 ++++++++++++++++++++++
support/support_subprocess.c | 13 +++
5 files changed, 168 insertions(+), 181 deletions(-)


  • Share