aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-15 16:58:52 +0100
committerMax Kellermann <max@duempel.org>2009-02-15 16:58:52 +0100
commit92c203d7056df229d5289e6c7d1f1000dbc7ce95 (patch)
tree4d4e4f1343b6c6e70acfb7f119ca4b30f9fb3100 /src
parent98994c59390afd09fdb4f81c35da2545f2e64328 (diff)
downloadmpd-92c203d7056df229d5289e6c7d1f1000dbc7ce95.tar.gz
mpd-92c203d7056df229d5289e6c7d1f1000dbc7ce95.tar.xz
mpd-92c203d7056df229d5289e6c7d1f1000dbc7ce95.zip
daemon: return early from daemonize_set_user()
If no "user" is configured, return from daemonize_set_user(). Save one level of indent.
Diffstat (limited to 'src')
-rw-r--r--src/daemon.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 3071175f5..d920ff6c5 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -100,28 +100,29 @@ void
daemonize_set_user(void)
{
#ifndef WIN32
- if (user_name != NULL) {
- /* get uid */
- if (setgid(user_gid) == -1) {
- g_error("cannot setgid for user \"%s\": %s",
- user_name, g_strerror(errno));
- }
+ if (user_name == NULL)
+ return;
+
+ /* get uid */
+ if (setgid(user_gid) == -1) {
+ g_error("cannot setgid for user \"%s\": %s",
+ user_name, g_strerror(errno));
+ }
#ifdef _BSD_SOURCE
- /* init suplementary groups
- * (must be done before we change our uid)
- */
- if (initgroups(user_name, user_gid) == -1) {
- g_warning("cannot init supplementary groups "
- "of user \"%s\": %s",
- user_name, g_strerror(errno));
- }
+ /* init suplementary groups
+ * (must be done before we change our uid)
+ */
+ if (initgroups(user_name, user_gid) == -1) {
+ g_warning("cannot init supplementary groups "
+ "of user \"%s\": %s",
+ user_name, g_strerror(errno));
+ }
#endif
- /* set uid */
- if (setuid(user_uid) == -1) {
- g_error("cannot change to uid of user \"%s\": %s",
- user_name, g_strerror(errno));
- }
+ /* set uid */
+ if (setuid(user_uid) == -1) {
+ g_error("cannot change to uid of user \"%s\": %s",
+ user_name, g_strerror(errno));
}
#endif
}