Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/user Report usage() if getopt() returns '?'



details:   https://anonhg.NetBSD.org/src/rev/ca01c8c0bac8
branches:  trunk
changeset: 545676:ca01c8c0bac8
user:      dsl <dsl%NetBSD.org@localhost>
date:      Mon Apr 14 09:49:15 2003 +0000

description:
Report usage() if getopt() returns '?'
Partial fix for bin/21146

diffstat:

 usr.sbin/user/user.c |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (90 lines):

diff -r 51e104783829 -r ca01c8c0bac8 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Mon Apr 14 08:45:51 2003 +0000
+++ b/usr.sbin/user/user.c      Mon Apr 14 09:49:15 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.67 2003/03/14 16:56:39 jrf Exp $ */
+/* $NetBSD: user.c,v 1.68 2003/04/14 09:49:15 dsl 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.67 2003/03/14 16:56:39 jrf Exp $");
+__RCSID("$NetBSD: user.c,v 1.68 2003/04/14 09:49:15 dsl Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1558,6 +1558,8 @@
        defaultfield = bigD = 0;
        while ((c = getopt(argc, argv, "DG:b:c:d:e:f:g:k:mou:s:" ADD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("useradd");
                case 'D':
                        bigD = 1;
                        break;
@@ -1689,6 +1691,8 @@
        have_new_user = 0;
        while ((c = getopt(argc, argv, "G:c:d:e:f:g:l:mos:u:" MOD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("usermod");
                case 'G':
                        while ((u.u_groupv[u.u_groupc] = strsep(&optarg, ",")) != NULL &&
                               u.u_groupc < NGROUPS_MAX) {
@@ -1799,6 +1803,8 @@
        defaultfield = bigD = rmhome = 0;
        while ((c = getopt(argc, argv, "r" DEL_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("userdel");
 #ifdef EXTENSIONS
                case 'D':
                        bigD = 1;
@@ -1879,6 +1885,8 @@
        dupgid = 0;
        while ((c = getopt(argc, argv, "g:o" GROUP_ADD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("groupadd");
                case 'g':
                        if (!is_number(optarg)) {
                                errx(EXIT_FAILURE, "When using [-g gid], the gid must be numeric");
@@ -1931,6 +1939,8 @@
 
        while ((c = getopt(argc, argv, "" GROUP_DEL_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("groupdel");
 #ifdef EXTENSIONS
                case 'v':
                        verbose = 1;
@@ -1975,6 +1985,8 @@
        newname = NULL;
        while ((c = getopt(argc, argv, "g:on:" GROUP_MOD_OPT_EXTENSIONS)) != -1) {
                switch(c) {
+               default:
+                       usermgmt_usage("groupmod");
                case 'g':
                        if (!is_number(optarg)) {
                                errx(EXIT_FAILURE, "When using [-g gid], the gid must be numeric");
@@ -2047,6 +2059,8 @@
        exists = 0;
        while ((i = getopt(argc, argv, "ev")) != -1) {
                switch(i) {
+               default:
+                       usermgmt_usage("userinfo");
                case 'e':
                        exists = 1;
                        break;
@@ -2107,6 +2121,8 @@
        exists = 0;
        while ((i = getopt(argc, argv, "ev")) != -1) {
                switch(i) {
+               default:
+                       usermgmt_usage("groupinfo");
                case 'e':
                        exists = 1;
                        break;



Home | Main Index | Thread Index | Old Index