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_2_1_12~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d647e2249b6df9a8fdb0a8b2de03f46bb351546d;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 e2d13a5aae9..4e48f0bcfe4 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -1884,6 +1884,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) { @@ -1896,6 +1898,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 */ @@ -1933,7 +1937,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",