From: Alan T. DeKok Date: Tue, 5 Jul 2011 15:54:59 +0000 (+0200) Subject: chown if uid or gid is set X-Git-Tag: release_3_0_0_beta0~721 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e08eba12e6faf3a8f8db23941ceb834f1c57d5c;p=thirdparty%2Ffreeradius-server.git chown if uid or gid is set --- diff --git a/src/main/command.c b/src/main/command.c index 2e4334db8d5..f1d28a287e5 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -2017,6 +2017,8 @@ static int command_socket_parse(CONF_SECTION *cs, rad_listen_t *this) } sock->uid = pw->pw_uid; + } else { + sock->uid = -1; } if (sock->gid_name) { @@ -2029,6 +2031,8 @@ static int command_socket_parse(CONF_SECTION *cs, rad_listen_t *this) return -1; } sock->gid = gr->gr_gid; + } else { + sock->gid = -1; } #else /* can't get uid or gid of connecting user */ @@ -2066,7 +2070,7 @@ static int command_socket_parse(CONF_SECTION *cs, rad_listen_t *this) * Don't chown it from (possibly) non-root to root. * Do chown it from (possibly) root to non-root. */ - if ((sock->uid != 0) && (sock->gid != 0)) { + if ((sock->uid != -1) || (sock->gid != -1)) { fr_suid_up(); if (fchown(this->fd, sock->uid, sock->gid) < 0) { radlog(L_ERR, "Failed setting ownership of %s: %s",