NetBSD Problem Report #1463

From gnats  Thu Sep 14 16:46:16 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id QAA09072 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Thu, 14 Sep 1995 16:46:16 -0400
Message-Id: <199509142044.QAA29874@pain.lcs.mit.edu>
Date: Thu, 14 Sep 95 16:43:36 EDT
From: davide@PIPER.NECTAR.CS.CMU.EDU
Sender: davide@PIPER.NECTAR.CS.CMU.EDU
Reply-To: davide@PIPER.NECTAR.CS.CMU.EDU
To: gnats-bugs@NetBSD.ORG
Cc: davide@PIPER.NECTAR.CS.CMU.EDU
Subject: su doesn't correctly test for membership in "wheel"
X-Send-Pr-Version: 3.2

>Number:         1463
>Category:       bin
>Synopsis:       su checks /etc/groups for "wheel" membership, but not /etc/passwd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 14 16:50:00 +0000 1995
>Closed-Date:    Thu Apr 10 20:09:22 +0000 1997
>Last-Modified:  Thu Apr 10 20:10:32 +0000 1997
>Originator:     David Eckhardt
>Release:        NetBSD-0812
>Organization:
Carnegie Mellon University Computer Science
>Environment:
	System: NetBSD piper.nectar.cs.cmu.edu 1.0A NetBSD 1.0A (IJET) #152: Sat Jul 15 14:38:58 EDT 1995 kosak@river:/usr/src/sys/arch/i386/compile/IJET i386

>Description:
	% grep davide /etc/passwd
	davide:*:4435:0:Dave Eckhardt:/usr/davide:/bin/csh
	% grep wheel /etc/group
	wheel:*:0:root
	% id
	uid=4435(davide) gid=0(wheel) groups=0(wheel)
	% su
	su: you are not in the correct group to su root.

	The relevant code in su looks like:

	if (pwd->pw_uid == 0 && (gr = getgrgid((gid_t)0)))
		for (g = gr->gr_mem;; ++g) {
			if (!*g) {
				(void)fprintf(stderr,
			"su: you are not in the correct group to su %s.\n",
					user);
				exit(1);
			}
			if (!strcmp(username, *g))
				break;
	}

>How-To-Repeat:
	See above /etc/passwd and /etc/group lines
>Fix:
	Assuming this is an oversight rather than a policy decision, the
	check should be something like
	if (pwd->pw_uid == 0 && pwd->pw_gid != 0 && (gr = getgrgid((gid_t)0)))
	Interestingly enough, it looks like this code will let anybody su
	to root if there is no "wheel" entry in /etc/groups...is this a
	fail-safe?
>Release-Note:
>Audit-Trail:

From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
To: netbsd-bugs@NetBSD.ORG
Cc:  Subject: Re:  bin/1463: su doesn't correctly test for membership in "wheel"
Date: Fri, 15 Sep 1995 07:13:42 -0400

 > 	% grep davide /etc/passwd
 > 	davide:*:4435:0:Dave Eckhardt:/usr/davide:/bin/csh
 > 	% grep wheel /etc/group
 > 	wheel:*:0:root
 > 	% id
 > 	uid=4435(davide) gid=0(wheel) groups=0(wheel)
 > 	% su
 > 	su: you are not in the correct group to su root.

 > 	Assuming this is an oversight rather than a policy decision,
 > 	the check should be something like
 > 	if (pwd->pw_uid == 0 && pwd->pw_gid != 0 && (gr = getgrgid((gid_t)0)))

 But that assumes that wheel is GID 0.  This means that all the docs
 would have to be changed to say "group id 0" instead of "group wheel".

 > 	Interestingly enough, it looks like this code will let anybody
 > 	su to root if there is no "wheel" entry in /etc/groups...is
 > 	this a fail-safe?

 I would say it is correct.  If nothing else, it allows people who don't
 like the "only wheel may su to root" policy to get their desired
 behavior without having to hack the source.  (I certainly know if _I_
 had noticed that NetBSD had restricted-su-to-root, I would have gone
 looking for a way to disable it.)

 					der Mouse

 			    mouse@collatz.mcrcim.mcgill.edu


From: David Eckhardt <David_Eckhardt@piper.nectar.cs.cmu.edu>
To: gnats-bugs@netbsd.org
Cc:  Subject: Re: bin/1463
Date: Sun, 19 Jan 1997 11:09:13 -0500

 What is the status of this bug?  I just installed 1.2 and ran into
 it again.

 Thanks.

 Dave Eckhardt
 davide@cs.cmu.edu
State-Changed-From-To: open->closed 
State-Changed-By: jeremy 
State-Changed-When: Thu Apr 10 13:09:22 PDT 1997 
State-Changed-Why:  
This is the same issue discussed in PR#792, which is still open. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.