From: Alan T. DeKok Date: Sat, 25 Sep 2010 15:57:09 +0000 (+0200) Subject: Fix long-standing bug where unix Groupcmp didn't work X-Git-Tag: release_3_0_0_beta0~1224 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=af01b3459b549ba843912545202a4c6a1e807bd6 Fix long-standing bug where unix Groupcmp didn't work It was looking in the wrong list for the user name. --- diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index 0ae1b7a..e0ca724 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -71,7 +71,7 @@ static const CONF_PARSER module_config[] = { /* * The Group = handler. */ -static int groupcmp(void *instance, UNUSED REQUEST *req, VALUE_PAIR *request, +static int groupcmp(void *instance, REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check, VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs) { @@ -89,23 +89,18 @@ static int groupcmp(void *instance, UNUSED REQUEST *req, VALUE_PAIR *request, /* * No user name, doesn't compare. */ - vp = pairfind(request, PW_STRIPPED_USER_NAME, 0); - if (!vp) { - vp = pairfind(request, PW_USER_NAME, 0); - if (!vp) { - return -1; - } + if (!req->username) { + return -1; } - username = (char *)vp->vp_strvalue; - pwd = getpwnam(username); + pwd = getpwnam(req->username->vp_strvalue); if (pwd == NULL) return -1; - grp = getgrnam((char *)check->vp_strvalue); + grp = getgrnam(check->vp_strvalue); if (grp == NULL) return -1; - + retval = (pwd->pw_gid == grp->gr_gid) ? 0 : -1; if (retval < 0) { for (member = grp->gr_mem; *member && retval; member++) {