Commit 92c203d7 authored by Max Kellermann's avatar Max Kellermann

daemon: return early from daemonize_set_user()

If no "user" is configured, return from daemonize_set_user(). Save one level of indent.
parent 98994c59
...@@ -100,28 +100,29 @@ void ...@@ -100,28 +100,29 @@ void
daemonize_set_user(void) daemonize_set_user(void)
{ {
#ifndef WIN32 #ifndef WIN32
if (user_name != NULL) { if (user_name == NULL)
/* get uid */ return;
if (setgid(user_gid) == -1) {
g_error("cannot setgid for user \"%s\": %s", /* get uid */
user_name, g_strerror(errno)); if (setgid(user_gid) == -1) {
} g_error("cannot setgid for user \"%s\": %s",
user_name, g_strerror(errno));
}
#ifdef _BSD_SOURCE #ifdef _BSD_SOURCE
/* init suplementary groups /* init suplementary groups
* (must be done before we change our uid) * (must be done before we change our uid)
*/ */
if (initgroups(user_name, user_gid) == -1) { if (initgroups(user_name, user_gid) == -1) {
g_warning("cannot init supplementary groups " g_warning("cannot init supplementary groups "
"of user \"%s\": %s", "of user \"%s\": %s",
user_name, g_strerror(errno)); user_name, g_strerror(errno));
} }
#endif #endif
/* set uid */ /* set uid */
if (setuid(user_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));
}
} }
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment