From owner-svn-src-head@FreeBSD.ORG Sat Jul 19 20:55:13 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B4D92C7B; Sat, 19 Jul 2014 20:55:13 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A21762DDD; Sat, 19 Jul 2014 20:55:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6JKtDuB071839; Sat, 19 Jul 2014 20:55:13 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6JKtD4o071838; Sat, 19 Jul 2014 20:55:13 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201407192055.s6JKtD4o071838@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Sat, 19 Jul 2014 20:55:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268888 - head/lib/libpam/modules/pam_group X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jul 2014 20:55:13 -0000 Author: des Date: Sat Jul 19 20:55:13 2014 New Revision: 268888 URL: http://svnweb.freebsd.org/changeset/base/268888 Log: 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 Modified: head/lib/libpam/modules/pam_group/pam_group.c Modified: head/lib/libpam/modules/pam_group/pam_group.c ============================================================================== --- head/lib/libpam/modules/pam_group/pam_group.c Sat Jul 19 20:13:01 2014 (r268887) +++ head/lib/libpam/modules/pam_group/pam_group.c Sat Jul 19 20:55:13 2014 (r268888) @@ -96,14 +96,12 @@ pam_sm_authenticate(pam_handle_t *pamh, 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;