From 467cc0f6c2ea7f005d55bb12605910d1c61c911c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 6 Sep 2013 17:13:34 +0200 Subject: Change directory to / when privileges are dropped or the user is changed --- src/fastd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fastd.c b/src/fastd.c index e5c1364..f281744 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -715,6 +715,9 @@ static void write_pid(fastd_context_t *ctx, pid_t pid) { } 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 (setgid(ctx->conf->gid) < 0) exit_errno(ctx, "setgid"); -- cgit v1.2.3