From 6fdfc9ef36ae78ec88890b53ebc96429410f6e6d Mon Sep 17 00:00:00 2001 From: agc Date: Tue, 14 Jun 2005 18:29:58 +0000 Subject: [PATCH] Be consistent when deleting a non-existent group - tell if the group is non-existent. Problem noted by Geert Hendrickx, fix from Liam J. Foy. --- usr.sbin/user/user.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index e732974d7dc3..67fd82a278a5 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $NetBSD: user.c,v 1.79 2005/04/05 22:54:26 agc Exp $ */ +/* $NetBSD: user.c,v 1.80 2005/06/14 18:29:58 agc Exp $ */ /* * Copyright (c) 1999 Alistair G. Crooks. All rights reserved. @@ -35,7 +35,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1999 \ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: user.c,v 1.79 2005/04/05 22:54:26 agc Exp $"); +__RCSID("$NetBSD: user.c,v 1.80 2005/06/14 18:29:58 agc Exp $"); #endif #include @@ -1990,6 +1990,9 @@ groupdel(int argc, char **argv) if (argc != 1) { usermgmt_usage("groupdel"); } + if (getgrnam(*argv) == NULL) { + errx(EXIT_FAILURE, "No such group `%s'", *argv); + } checkeuid(); openlog("groupdel", LOG_PID, LOG_USER); if (!modify_gid(*argv, NULL)) { @@ -2057,7 +2060,7 @@ groupmod(int argc, char **argv) err(EXIT_FAILURE, "Duplicate which gid?"); } if ((grp = getgrnam(*argv)) == NULL) { - err(EXIT_FAILURE, "can't find group `%s' to modify", *argv); + errx(EXIT_FAILURE, "can't find group `%s' to modify", *argv); } if (!is_local(*argv, _PATH_GROUP)) { errx(EXIT_FAILURE, "Group `%s' must be a local group", *argv);