about summary refs log tree commit diff
path: root/support/subprocess.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2021-04-09 20:55:45 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2021-04-12 19:03:19 +0530
commit716a3bdc41b2b4b864dc64475015ba51e35e1273 (patch)
tree103a573114c8263cec174ca7fd655ff4612f0ee9 /support/subprocess.h
parent8d4d77f6c848538cfb9e5ad0a14825e7ae4a1657 (diff)
downloadglibc-716a3bdc41b2b4b864dc64475015ba51e35e1273.tar.gz
glibc-716a3bdc41b2b4b864dc64475015ba51e35e1273.tar.xz
glibc-716a3bdc41b2b4b864dc64475015ba51e35e1273.zip
support: Add capability to fork an sgid child
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.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'support/subprocess.h')
-rw-r--r--support/subprocess.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/support/subprocess.h b/support/subprocess.h
index 11cfc6a07f..40d82c7e4d 100644
--- a/support/subprocess.h
+++ b/support/subprocess.h
@@ -38,6 +38,11 @@ struct support_subprocess support_subprocess
 struct support_subprocess support_subprogram
   (const char *file, char *const argv[]);
 
+/* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it
+   to complete.  Return program exit status.  */
+int support_subprogram_wait
+  (const char *file, char *const argv[]);
+
 /* Wait for the subprocess indicated by PROC::PID.  Return the status
    indicate by waitpid call.  */
 int support_process_wait (struct support_subprocess *proc);