From 5ba43e4ac2ea37166b583965ea024a8ace36aeea Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Jan 2009 18:42:44 +0100 Subject: daemon: removed unused variable "userpwd" This causes a segmentation fault... --- src/daemon.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/daemon.c') diff --git a/src/daemon.c b/src/daemon.c index 023655979..02b5a4ba9 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -102,8 +102,6 @@ daemonize_set_user(void) #ifndef WIN32 if (user_name != NULL) { /* get uid */ - struct passwd *userpwd; - if (setgid(user_gid) == -1) { g_error("cannot setgid for user \"%s\": %s", user_name, g_strerror(errno)); @@ -120,15 +118,10 @@ daemonize_set_user(void) #endif /* set uid */ - if (setuid(userpwd->pw_uid) == -1) { + if (setuid(user_uid) == -1) { g_error("cannot change to uid of user \"%s\": %s", user_name, g_strerror(errno)); } - - /* this is needed by libs such as arts */ - if (userpwd->pw_dir) { - g_setenv("HOME", userpwd->pw_dir, true); - } } #endif } @@ -193,6 +186,9 @@ daemonize_init(const char *user, const char *_pidfile) user_uid = pwd->pw_uid; user_gid = pwd->pw_gid; + + /* this is needed by libs such as arts */ + g_setenv("HOME", pwd->pw_dir, true); } pidfile = g_strdup(_pidfile); -- cgit v1.2.3