diff options
| author | Roy Marples <roy@marples.name> | 2020-01-21 16:11:37 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-01-21 16:11:37 +0000 |
| commit | 18043c2fba9868086534f99b072a7ef7f53a547f (patch) | |
| tree | bf13f7c1ff34f1b617a7202d6b10eac2a66df100 /src/privsep.c | |
| parent | 068e30162ae3259a5325ab90810332dbfad19881 (diff) | |
| download | dhcpcd-18043c2fba9868086534f99b072a7ef7f53a547f.tar.xz | |
privsep: Close stdout/stderr after forking processes
Well, redirect them to /dev/null anyway.
Also tidy a few things in common whilst here.
Diffstat (limited to 'src/privsep.c')
| -rw-r--r-- | src/privsep.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/privsep.c b/src/privsep.c index 57b76b82..8fe7256a 100644 --- a/src/privsep.c +++ b/src/privsep.c @@ -47,7 +47,7 @@ #include <pwd.h> #include <errno.h> #include <fcntl.h> -#include <grp.h> +#include <paths.h> #include <stddef.h> /* For offsetof, struct padding debug */ #include <signal.h> #include <stdlib.h> @@ -196,10 +196,8 @@ ps_dostart(struct dhcpcd_ctx *ctx, if (callback(recv_ctx) == -1) goto errexit; -#if 0 - /* XXX Why does this cause processes to exit? */ - close_std(); -#endif + freopen(_PATH_DEVNULL, "w", stdout); + freopen(_PATH_DEVNULL, "w", stderr); if (pw == NULL) return 0; @@ -217,8 +215,8 @@ ps_dostart(struct dhcpcd_ctx *ctx, dropprivs: if (setgroups(1, &pw->pw_gid) == -1 || - setgid(pw->pw_gid) == -1 || - setuid(pw->pw_uid) == -1) + setgid(pw->pw_gid) == -1 || + setuid(pw->pw_uid) == -1) logerr("failed to drop privileges"); return 0; |
