aboutsummaryrefslogtreecommitdiff
path: root/src/daemon.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-15 16:47:21 +0100
committerMax Kellermann <max@duempel.org>2009-02-15 16:47:21 +0100
commit98994c59390afd09fdb4f81c35da2545f2e64328 (patch)
tree8f6f624d9eb15deec16efa3812427e5717a5135d /src/daemon.c
parent59e62d95bd7746cfebb9458ec17d216d9b86633e (diff)
daemon: ignore "user" setting if already running as that user
If mpd.conf specifies a user, and MPD is invoked by exactly this user, ignore the "user" setting. Don't bother to look up its groups and don't attempt to change uid, it won't work anyway.
Diffstat (limited to 'src/daemon.c')
-rw-r--r--src/daemon.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 51503bc7..3071175f 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -192,9 +192,12 @@ void
daemonize_init(const char *user, const char *_pidfile)
{
#ifndef WIN32
- user_name = g_strdup(user);
- if (user_name != NULL) {
- struct passwd *pwd = getpwnam(user_name);
+ if (user != NULL && strcmp(user, g_get_user_name()) != 0) {
+ struct passwd *pwd;
+
+ user_name = g_strdup(user);
+
+ pwd = getpwnam(user_name);
if (pwd == NULL)
g_error("no such user \"%s\"", user_name);