From 98994c59390afd09fdb4f81c35da2545f2e64328 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 15 Feb 2009 16:47:21 +0100 Subject: [PATCH] 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. --- NEWS | 1 + src/daemon.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 001c32fb5..5559c0b40 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,7 @@ ver 0.15 - (200?/??/??) * playlist_directory and music_directory are optional * playlist: recalculate the queued song after random is toggled * playlist: don't unpause on delete +* daemon: ignore "user" setting if already running as that user ver 0.14.2 (2009/02/13) diff --git a/src/daemon.c b/src/daemon.c index 51503bc7a..3071175f5 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);