diff options
author | des <des@FreeBSD.org> | 2014-07-19 20:55:13 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2014-07-19 20:55:13 +0000 |
commit | 79931797441bc166c7381ef7865f139e5cdb47e8 (patch) | |
tree | 3f396a945c76eb2faf652bd213cbd07dd00d190d /lib | |
parent | d3e404ac25a60a1da01332f6d06ad1fded3f45dd (diff) | |
download | FreeBSD-src-79931797441bc166c7381ef7865f139e5cdb47e8.zip FreeBSD-src-79931797441bc166c7381ef7865f139e5cdb47e8.tar.gz |
Check if the specified group is the user's primary group before
iterating over the (possibly empty) list of members. Otherwise, we
get a false negative when the target group has no members listed in
/etc/group. This went mostly unnoticed because root is explicitly
listed as a member of wheel, so the bug is never triggered in the most
common use case, which is su(8).
PR: 109416
MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpam/modules/pam_group/pam_group.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/libpam/modules/pam_group/pam_group.c b/lib/libpam/modules/pam_group/pam_group.c index a6e32cd..5b918c0 100644 --- a/lib/libpam/modules/pam_group/pam_group.c +++ b/lib/libpam/modules/pam_group/pam_group.c @@ -96,14 +96,12 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, if ((grp = getgrnam(group)) == NULL || grp->gr_mem == NULL) goto failed; - /* check if the group is empty */ - if (*grp->gr_mem == NULL) - goto failed; - - /* check membership */ + /* check if user's own primary group */ if (pwd->pw_gid == grp->gr_gid) goto found; - for (list = grp->gr_mem; *list != NULL; ++list) + + /* iterate over members */ + for (list = grp->gr_mem; list != NULL && *list != NULL; ++list) if (strcmp(*list, pwd->pw_name) == 0) goto found; |