daemon: removed unused variable "userpwd"
This causes a segmentation fault...
This commit is contained in:
parent
9c93249412
commit
5ba43e4ac2
12
src/daemon.c
12
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);
|
||||
|
|
Loading…
Reference in New Issue