summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1998-06-04 22:30:53 +0000
committerSteve Price <steve@FreeBSD.org>1998-06-04 22:30:53 +0000
commit540077bd30ef54ecff457cce9baee1c5b2a87e02 (patch)
treea414e313d9820a43f8832b10d59cf7afd7b305fc /usr.bin
parent635c19efb681d3b580d163116769f1f331fde7cf (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/su/su.111
-rw-r--r--usr.bin/su/su.c19
2 files changed, 21 insertions, 9 deletions
diff --git a/usr.bin/su/su.1 b/usr.bin/su/su.1
index de68040c57a6..e6232ccfa789 100644
--- a/usr.bin/su/su.1
+++ b/usr.bin/su/su.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)su.1 8.2 (Berkeley) 4/18/94
-.\" $Id$
+.\" $Id: su.1,v 1.3.2.6 1998/02/18 12:15:58 markm Exp $
.\"
.\" this is for hilit19's braindeadness: "
.Dd April 18, 1994
@@ -152,13 +152,16 @@ option as understood by most shells. Note that
usually expects a single argument only; you have to quote it when
passing multiple words.
.Pp
-Only users listed in group 0 (normally
+Only users who are a member of group 0 (normally
.Dq wheel )
can
.Nm
to
-.Dq root ,
-unless this group is empty.
+.Dq root .
+\ If group 0 is missing or empty, any user can
+.Nm
+to
+.Dq root .
.Pp
By default (unless the prompt is reset by a startup file) the super-user
prompt is set to
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index a5bc1b3ce95e..fd7cdb18c934 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)su.c 8.3 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: su.c,v 1.14.2.6 1998/02/18 12:16:03 markm Exp $";
+ "$Id: su.c,v 1.14.2.7 1998/05/26 06:28:30 danny Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -113,6 +113,7 @@ main(argc, argv)
char *p, **g, *user, *shell=NULL, *username, **cleanenv, **nargv, **np;
struct group *gr;
uid_t ruid;
+ gid_t gid;
int asme, ch, asthem, fastlogin, prio, i;
enum { UNSET, YES, NO } iscsh = UNSET;
#ifdef LOGIN_CAP
@@ -203,6 +204,7 @@ main(argc, argv)
if (pwd == NULL)
errx(1, "who are you?");
username = strdup(pwd->pw_name);
+ gid = pwd->pw_gid;
if (username == NULL)
err(1, NULL);
if (asme) {
@@ -254,14 +256,21 @@ main(argc, argv)
}
#endif
{
- /* only allow those in group zero to su to root. */
+ /*
+ * Only allow those with pw_gid==0 or those listed in
+ * group zero to su to root. If group zero entry is
+ * missing or empty, then allow anyone to su to root.
+ * iswheelsu will only be set if the user is EXPLICITLY
+ * listed in group zero.
+ */
if (pwd->pw_uid == 0 && (gr = getgrgid((gid_t)0)) &&
gr->gr_mem && *(gr->gr_mem))
for (g = gr->gr_mem;; ++g) {
if (!*g)
- errx(1,
- "you are not in the correct group to su %s.",
- user);
+ if (gid == 0)
+ break;
+ else
+ errx(1, "you are not in the correct group to su %s.", user);
if (strcmp(username, *g) == 0) {
#ifdef WHEELSU
iswheelsu = 1;