From: Alan T. DeKok Date: Tue, 15 Dec 2009 10:52:03 +0000 (+0100) Subject: If we have "user=foo", and we're ALREADY running as that user, ignore it. X-Git-Tag: release_2_1_8~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41a0ea23d47f00fde51c88981b30ceda2d643390;p=thirdparty%2Ffreeradius-server.git If we have "user=foo", and we're ALREADY running as that user, ignore it. This prevents us from complaining when "initgroups" is run as non-root --- diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index 8f14ab0e5f6..58167da4adc 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -565,14 +565,20 @@ static int switch_users(CONF_SECTION *cs) progname, uid_name, strerror(errno)); return 0; } - server_uid = pw->pw_uid; + + if (getuid() == pw->pw_uid) { + uid_name = NULL; + } else { + + server_uid = pw->pw_uid; #ifdef HAVE_INITGROUPS - if (initgroups(uid_name, server_gid) < 0) { - fprintf(stderr, "%s: Cannot initialize supplementary group list for user %s: %s\n", - progname, uid_name, strerror(errno)); - return 0; - } + if (initgroups(uid_name, server_gid) < 0) { + fprintf(stderr, "%s: Cannot initialize supplementary group list for user %s: %s\n", + progname, uid_name, strerror(errno)); + return 0; + } #endif + } } else { server_uid = getuid(); }