diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 20:21:35 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-06 20:21:35 +0100 |
| commit | 1826e01b2a3ef53e048389b44cc35f9c32258a02 (patch) | |
| tree | f38a31c11c994ca14a20d8b8da139044c1ea1328 | |
| parent | b6838536fcd0f4361d3907e95f3247b1f1281a62 (diff) | |
Also drop supplementary groups on startup
| -rw-r--r-- | src/opentracker.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/opentracker.c b/src/opentracker.c index 123f20a..759a6d0 100644 --- a/src/opentracker.c +++ b/src/opentracker.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <errno.h> | 7 | #include <errno.h> |
| 8 | #include <limits.h> | 8 | #include <limits.h> |
| 9 | #include <pthread.h> | 9 | #include <pthread.h> |
| 10 | #include <grp.h> | ||
| 10 | #include <pwd.h> | 11 | #include <pwd.h> |
| 11 | #include <signal.h> | 12 | #include <signal.h> |
| 12 | #include <stdint.h> | 13 | #include <stdint.h> |
| @@ -360,10 +361,10 @@ int drop_privileges(const char *const serveruser, const char *const serverdir) { | |||
| 360 | /* If we can't find server user, revert to nobody's default uid */ | 361 | /* If we can't find server user, revert to nobody's default uid */ |
| 361 | if (!pws) { | 362 | if (!pws) { |
| 362 | fprintf(stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser); | 363 | fprintf(stderr, "Warning: Could not get password entry for %s. Reverting to uid -2.\n", serveruser); |
| 363 | if (setegid((gid_t)-2) || setgid((gid_t)-2) || setuid((uid_t)-2) || seteuid((uid_t)-2)) | 364 | if (setgroups(0, NULL) || setegid((gid_t)-2) || setgid((gid_t)-2) || setuid((uid_t)-2) || seteuid((uid_t)-2)) |
| 364 | panic("Could not set uid to value -2"); | 365 | panic("Could not set uid to value -2"); |
| 365 | } else { | 366 | } else { |
| 366 | if (setegid(pws->pw_gid) || setgid(pws->pw_gid) || setuid(pws->pw_uid) || seteuid(pws->pw_uid)) | 367 | if (setgroups(0, NULL) || setegid(pws->pw_gid) || setgid(pws->pw_gid) || setuid(pws->pw_uid) || seteuid(pws->pw_uid)) |
| 367 | panic("Could not set uid to specified value"); | 368 | panic("Could not set uid to specified value"); |
| 368 | } | 369 | } |
| 369 | 370 | ||
