daemon: removed unused variable "userpwd"
This causes a segmentation fault...
This commit is contained in:
12
src/daemon.c
12
src/daemon.c
@ -102,8 +102,6 @@ daemonize_set_user(void)
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (user_name != NULL) {
|
if (user_name != NULL) {
|
||||||
/* get uid */
|
/* get uid */
|
||||||
struct passwd *userpwd;
|
|
||||||
|
|
||||||
if (setgid(user_gid) == -1) {
|
if (setgid(user_gid) == -1) {
|
||||||
g_error("cannot setgid for user \"%s\": %s",
|
g_error("cannot setgid for user \"%s\": %s",
|
||||||
user_name, g_strerror(errno));
|
user_name, g_strerror(errno));
|
||||||
@ -120,15 +118,10 @@ daemonize_set_user(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set uid */
|
/* set uid */
|
||||||
if (setuid(userpwd->pw_uid) == -1) {
|
if (setuid(user_uid) == -1) {
|
||||||
g_error("cannot change to uid of user \"%s\": %s",
|
g_error("cannot change to uid of user \"%s\": %s",
|
||||||
user_name, g_strerror(errno));
|
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
|
#endif
|
||||||
}
|
}
|
||||||
@ -193,6 +186,9 @@ daemonize_init(const char *user, const char *_pidfile)
|
|||||||
|
|
||||||
user_uid = pwd->pw_uid;
|
user_uid = pwd->pw_uid;
|
||||||
user_gid = pwd->pw_gid;
|
user_gid = pwd->pw_gid;
|
||||||
|
|
||||||
|
/* this is needed by libs such as arts */
|
||||||
|
g_setenv("HOME", pwd->pw_dir, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pidfile = g_strdup(_pidfile);
|
pidfile = g_strdup(_pidfile);
|
||||||
|
Reference in New Issue
Block a user