]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
chown if uid or gid is set
authorAlan T. DeKok <aland@freeradius.org>
Tue, 5 Jul 2011 15:54:59 +0000 (17:54 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 5 Jul 2011 15:54:59 +0000 (17:54 +0200)
src/main/command.c

index e2d13a5aae9da4cdf77d2d5c9fa41546e095f106..4e48f0bcfe42a3ffd7bf709147f25426379ea0aa 100644 (file)
@@ -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",