From 423ad02026a37dc128e0b879cadf9dbaf6377af7 Mon Sep 17 00:00:00 2001 From: Dean Jansa Date: Fri, 27 Jun 2008 16:18:35 +0000 Subject: chdir() to users home dir --- qarshd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qarshd.c b/qarshd.c index 8d79e79..84be036 100644 --- a/qarshd.c +++ b/qarshd.c @@ -67,8 +67,16 @@ setup_user(char *user, char *group) setgid(pw->pw_gid); initgroups(pw->pw_name, pw->pw_gid); } + /* setuid is last so we can still do setgid and initgroups */ setuid(pw->pw_uid); + + if (chdir(pw->pw_dir) < 0) { + syslog(LOG_WARNING, "Unable to chdir() to %s: %s\n", + pw->pw_dir, strerror(errno)); + return 0; + } + return 1; } -- cgit