Some fixes to process-wrapper / linux-sandbox.
- Refactoring to share more code between the two programs.
- Remove setuid() call in linux-sandbox. It was added due to a wrong understanding of what process-wrapper did in the beginning and unless someone installed linux-sandbox as a setuid binary, it was a no-op.
- Switch to a new process group in linux-sandbox to avoid accidentally killing our parent.
RELNOTES: None.
PiperOrigin-RevId: 156332503
diff --git a/src/main/tools/process-wrapper.cc b/src/main/tools/process-wrapper.cc
index 6140eba..c2eeee2 100644
--- a/src/main/tools/process-wrapper.cc
+++ b/src/main/tools/process-wrapper.cc
@@ -36,10 +36,9 @@
#include <string>
#include <vector>
+#include "src/main/tools/logging.h"
#include "src/main/tools/process-tools.h"
-bool global_debug = false;
-
static double global_kill_delay;
static pid_t global_child_pid;
static volatile sig_atomic_t global_signal;
@@ -136,7 +135,9 @@
HandleSignal(SIGALRM, OnSignal);
HandleSignal(SIGTERM, OnSignal);
HandleSignal(SIGINT, OnSignal);
- SetTimeout(timeout_secs);
+ if (timeout_secs > 0) {
+ SetTimeout(timeout_secs);
+ }
int status = WaitChild(global_child_pid);