From bbb85d353ef1ac6007cd6de6797597ad43de1257 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Fri, 15 Jan 2021 20:22:22 +0100 Subject: [PATCH] Drop root after unshare. Apparently only the unshare call needs root. The fork which results in a new PID namespace does not. --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index fc79ba5..b4c30a5 100644 --- a/main.c +++ b/main.c @@ -84,6 +84,9 @@ int main(int argc, const char** argv) return err; } + // Drop root privileges, we only needed those for the unshare call. + drop_root(); + pid_t pid = fork(); if (pid == -1) @@ -93,9 +96,6 @@ int main(int argc, const char** argv) return err; } - // Drop root privileges, we only needed those for the unshare call and fork above. - drop_root(); - if (pid != 0) { /// Head process