diff options
| author | Roy Marples <roy@marples.name> | 2020-01-21 20:17:27 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-01-21 20:17:27 +0000 |
| commit | 056aca1c31239c8a65ef5a1c42fe4de841d2c064 (patch) | |
| tree | c2ae44d8f7c9202ef9dc0369eaf933e6a1e9551d /src/privsep.c | |
| parent | 8a4cd387823dc5e122839af9d9463985cb99f383 (diff) | |
| download | dhcpcd-056aca1c31239c8a65ef5a1c42fe4de841d2c064.tar.xz | |
privsep: Only fetch PRIVSEP_USER at init
And not each time it's needed - we don't want a sudden change in
the details to affect a running dhcpcd.
Diffstat (limited to 'src/privsep.c')
| -rw-r--r-- | src/privsep.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/privsep.c b/src/privsep.c index ffd32de0..af9e27bf 100644 --- a/src/privsep.c +++ b/src/privsep.c @@ -93,11 +93,11 @@ ps_mkdir(char *path) int ps_init(struct dhcpcd_ctx *ctx) { - struct passwd *pw; char path[PATH_MAX]; + struct passwd *pw = ctx->ps_user; errno = 0; - if ((pw = getpwnam(PRIVSEP_USER)) == NULL) { + if ((ctx->ps_user = pw = getpwnam(PRIVSEP_USER)) == NULL) { ctx->options &= ~DHCPCD_PRIVSEP; if (errno == 0) { logerrx("no such user %s", PRIVSEP_USER); @@ -122,15 +122,7 @@ ps_init(struct dhcpcd_ctx *ctx) int ps_dropprivs(struct dhcpcd_ctx *ctx) { - struct passwd *pw; - - if ((pw = getpwnam(PRIVSEP_USER)) == NULL) { - if (errno == 0) - logerrx("no such user %s", PRIVSEP_USER); - else - logerr("getpwnam"); - return -1; - } + struct passwd *pw = ctx->ps_user; if (!(ctx->options & DHCPCD_FORKED)) logdebugx("chrooting to `%s'", pw->pw_dir); |
