aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/generated.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/csource/generated.go')
-rw-r--r--pkg/csource/generated.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index fc7953842..cf1c9784a 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -394,6 +394,7 @@ void child()
#include <unistd.h>
+#include <pwd.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
@@ -710,13 +711,17 @@ static int do_sandbox_setuid(void)
initialize_tun(procid);
#endif
- const int nobody = 65534;
+ char pwbuf[1024];
+ struct passwd *pw, pwres;
+ if (getpwnam_r("nobody", &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || !pw)
+ fail("getpwnam_r(\"nobody\") failed");
+
if (setgroups(0, NULL))
fail("failed to setgroups");
- if (setresgid(nobody, nobody, nobody))
- fail("failed to setresgid");
- if (setresuid(nobody, nobody, nobody))
- fail("failed to setresuid");
+ if (setgid(pw->pw_gid))
+ fail("failed to setgid");
+ if (setuid(pw->pw_uid))
+ fail("failed to setuid");
loop();
doexit(1);