From owner-freebsd-bugs@FreeBSD.ORG Thu Feb 22 02:40:07 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 560D316A401 for ; Thu, 22 Feb 2007 02:40:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 363B213C4A6 for ; Thu, 22 Feb 2007 02:40:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l1M2e7Sj058657 for ; Thu, 22 Feb 2007 02:40:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l1M2e7C8058656; Thu, 22 Feb 2007 02:40:07 GMT (envelope-from gnats) Resent-Date: Thu, 22 Feb 2007 02:40:07 GMT Resent-Message-Id: <200702220240.l1M2e7C8058656@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, siflus Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3190616A40D for ; Thu, 22 Feb 2007 02:30:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 0A2C213C4AC for ; Thu, 22 Feb 2007 02:30:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l1M2UF3U008300 for ; Thu, 22 Feb 2007 02:30:15 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l1M2UFkS008299; Thu, 22 Feb 2007 02:30:15 GMT (envelope-from nobody) Message-Id: <200702220230.l1M2UFkS008299@www.freebsd.org> Date: Thu, 22 Feb 2007 02:30:15 GMT From: siflus To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: misc/109416: pam_group doesn't check login_group membership in some situations X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Feb 2007 02:40:07 -0000 >Number: 109416 >Category: misc >Synopsis: pam_group doesn't check login_group membership in some situations >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Feb 22 02:40:06 GMT 2007 >Closed-Date: >Last-Modified: >Originator: siflus >Release: 6.2-RELEASE >Organization: >Environment: FreeBSD trashed.local 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 23:30:59 UTC 2007 root@s-dallas.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC sparc64 >Description: if a group is empty as per /etc/group, pam_group.so fails before checking if the user's login_group matches. >How-To-Repeat: set a user's login group to the gid of some group. make sure there aren't any usernames in /etc/group add this to something like /etc/pam.d/su auth required pam_group.so no_warn group=YOUR_GROUP that way you're required to be in the wheel group in order to su. try to su. :) >Fix: it looks to me like the author intended to check the gid..however due to the initial check if the group is empty...it fails before it gets to that point. ---------- 8< ---- snip ---- 8< ----------- if ((group = openpam_get_option(pamh, "group")) == NULL) group = "wheel"; if ((grp = getgrnam(group)) == NULL || grp->gr_mem == NULL) goto failed; A /* check if the group is empty */ A if (*grp->gr_mem == NULL) A goto failed; B /* check membership */ B if (pwd->pw_gid == grp->gr_gid) B goto found; for (list = grp->gr_mem; *list != NULL; ++list) if (strcmp(*list, pwd->pw_name) == 0) goto found; ---------- 8< ---- snip ---- 8< ----------- Currently the logic is -> if group.members is Empty: goto failed if user.group = group.gid: goto found if user in group.members: goto found I think A and B should be swapped, that way the logic looks like -> if user.group = group.gid: goto found if group.members is empty: goto failed if user in group.members: goto found Patch attached with submission follows: diff -cru libpam/modules/pam_group/pam_group.c /home/siflus/pam_group/pam_group.c --- libpam/modules/pam_group/pam_group.c Thu Dec 11 08:55:15 2003 +++ /home/siflus/pam_group/pam_group.c Wed Feb 21 21:02:13 2007 @@ -80,13 +80,14 @@ 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 */ if (pwd->pw_gid == grp->gr_gid) goto found; + + /* check if there are no members in the group */ + if (*grp->gr_mem == NULL) + goto failed; + for (list = grp->gr_mem; *list != NULL; ++list) if (strcmp(*list, pwd->pw_name) == 0) goto found; >Release-Note: >Audit-Trail: >Unformatted: