Change directory to / when privileges are dropped or the user is changed

This commit is contained in:
Matthias Schiffer 2013-09-06 17:13:34 +02:00
parent 02c1cb4ce2
commit 467cc0f6c2

View file

@ -715,6 +715,9 @@ static void write_pid(fastd_context_t *ctx, pid_t pid) {
} }
static void set_user(fastd_context_t *ctx) { static void set_user(fastd_context_t *ctx) {
if (chdir("/"))
pr_error(ctx, "can't chdir to `/': %s", strerror(errno));
if (ctx->conf->user || ctx->conf->group) { if (ctx->conf->user || ctx->conf->group) {
if (setgid(ctx->conf->gid) < 0) if (setgid(ctx->conf->gid) < 0)
exit_errno(ctx, "setgid"); exit_errno(ctx, "setgid");