summaryrefslogtreecommitdiff
path: root/usr.sbin/user
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-08 20:50:52 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-08 20:50:52 +0000
commit98138cc9227fae0eecdf562e895bd5fdc6f43fe0 (patch)
tree87594d4f741817cec99504a95ca39f5c21ea6d9e /usr.sbin/user
parent1ac2d22f7fc9e29616819c47fd4b43a7a5076ee0 (diff)
Add check for group too long and made an invalid group a fatal error
instead of just a warning which is consistent with the way an invalid user is treated.
Diffstat (limited to 'usr.sbin/user')
-rw-r--r--usr.sbin/user/user.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c
index 7152192ff8b..0731ca5a691 100644
--- a/usr.sbin/user/user.c
+++ b/usr.sbin/user/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.43 2003/06/08 20:43:25 millert Exp $ */
+/* $OpenBSD: user.c,v 1.44 2003/06/08 20:50:51 millert Exp $ */
/* $NetBSD: user.c,v 1.45 2001/08/17 08:29:00 joda Exp $ */
/*
@@ -578,6 +578,8 @@ valid_group(char *group)
return 0;
}
}
+ if (cp - group > MaxUserNameLen)
+ return 0;
return 1;
}
@@ -1629,15 +1631,15 @@ groupadd(int argc, char **argv)
usermgmt_usage("groupadd");
}
checkeuid();
+ if (!valid_group(*argv)) {
+ errx(EXIT_FAILURE, "invalid group name `%s'", *argv);
+ }
if (gid < 0 && !getnextgid(&gid, LowGid, HighGid)) {
errx(EXIT_FAILURE, "can't add group: can't get next gid");
}
if (!dupgid && getgrgid((gid_t) gid) != NULL) {
errx(EXIT_FAILURE, "can't add group: gid %d is a duplicate", gid);
}
- if (!valid_group(*argv)) {
- warnx("warning - invalid group name `%s'", *argv);
- }
if (!creategid(*argv, gid, "")) {
errx(EXIT_FAILURE, "can't add group: problems with %s file",
_PATH_GROUP);
@@ -1741,7 +1743,7 @@ groupmod(int argc, char **argv)
errx(EXIT_FAILURE, "can't find group `%s' to modify", *argv);
}
if (newname != NULL && !valid_group(newname)) {
- warnx("warning - invalid group name `%s'", newname);
+ errx(EXIT_FAILURE, "invalid group name `%s'", newname);
}
if ((cc = snprintf(buf, sizeof(buf), "%s:%s:%u:",
(newname) ? newname : grp->gr_name, grp->gr_passwd,