]> 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:56:37 +0000 (17:56 +0200)
src/main/command.c

index 2e4334db8d571a1cd91f918bd42b1ce22d1dbac8..f1d28a287e54cb243e70d1e7d621dce1797e77ab 100644 (file)
@@ -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",