Source-Changes-HG archive

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

[src/trunk]: src/sbin/umbctl Forbid command line parameters when parsing conf...



details:   https://anonhg.NetBSD.org/src/rev/f7d5704278e1
branches:  trunk
changeset: 1008411:f7d5704278e1
user:      khorben <khorben%NetBSD.org@localhost>
date:      Sun Mar 22 07:45:02 2020 +0000

description:
Forbid command line parameters when parsing configuration files

This behaviour was ambiguous at best.
While there, also correct the usage screen, and the corresponding manual
page.

diffstat:

 sbin/umbctl/umbctl.8 |  12 +++++-------
 sbin/umbctl/umbctl.c |  19 ++++++++++---------
 2 files changed, 15 insertions(+), 16 deletions(-)

diffs (102 lines):

diff -r 521e431e2ff6 -r f7d5704278e1 sbin/umbctl/umbctl.8
--- a/sbin/umbctl/umbctl.8      Sun Mar 22 02:30:15 2020 +0000
+++ b/sbin/umbctl/umbctl.8      Sun Mar 22 07:45:02 2020 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: umbctl.8,v 1.2 2018/08/01 17:26:30 wiz Exp $
+.\"    $NetBSD: umbctl.8,v 1.3 2020/03/22 07:45:02 khorben Exp $
 .\"
 .\" Copyright (c) 2018 by Pierre Pronchery <khorben%defora.org@localhost>
 .\" All rights reserved.
@@ -26,11 +26,11 @@
 .\"
 .\" From: pppoectl.8,v 1.30 2016/09/12 05:35:20 sevan Exp $
 .\"
-.\" $Id: umbctl.8,v 1.2 2018/08/01 17:26:30 wiz Exp $
+.\" $Id: umbctl.8,v 1.3 2020/03/22 07:45:02 khorben Exp $
 .\"
 .\" last edit-date: [Thu Aug 31 10:47:33 2000]
 .\"
-.Dd July 24, 2018
+.Dd March 22, 2020
 .Dt UMBCTL 8
 .Os
 .Sh NAME
@@ -40,15 +40,13 @@
 .Nm umbctl
 .Op Fl v
 .Ar ifname
-.Op Ar parameter Ns Op \&= Ns Ar value
+.Op Ar parameter Op Ar value
 .Op Ar ...
 .Pp
 .Nm umbctl
 .Op Fl v
-.Op Fl f Ar config-file
+.Fl f Ar config-file
 .Ar ifname
-.Op Ar parameter Ns Op \&= Ns Ar value
-.Op Ar ...
 .Sh DESCRIPTION
 .Nm
 supports the following options:
diff -r 521e431e2ff6 -r f7d5704278e1 sbin/umbctl/umbctl.c
--- a/sbin/umbctl/umbctl.c      Sun Mar 22 02:30:15 2020 +0000
+++ b/sbin/umbctl/umbctl.c      Sun Mar 22 07:45:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umbctl.c,v 1.2 2018/08/02 03:40:51 roy Exp $ */
+/* $NetBSD: umbctl.c,v 1.3 2020/03/22 07:45:02 khorben Exp $ */
 /*
  * Copyright (c) 2018 Pierre Pronchery <khorben%defora.org@localhost>
  *
@@ -80,8 +80,8 @@
 static int _char_to_utf16(const char * in, uint16_t * out, size_t outlen);
 static int _error(int ret, char const * format, ...);
 static int _umbctl(char const * ifname, int verbose, int argc, char * argv[]);
-static int _umbctl_file(char const * ifname, char const * filename, int verbose,
-               int argc, char * argv[]);
+static int _umbctl_file(char const * ifname, char const * filename,
+               int verbose);
 static void _umbctl_info(char const * ifname, struct umb_info * umbi);
 static int _umbctl_ioctl(char const * ifname, int fd, unsigned long request,
                struct ifreq * ifr);
@@ -177,8 +177,7 @@
 
 
 /* umbctl_file */
-static int _umbctl_file(char const * ifname, char const * filename, int verbose,
-               int argc, char * argv[])
+static int _umbctl_file(char const * ifname, char const * filename, int verbose)
 {
        int fd;
        struct ifreq ifr;
@@ -216,7 +215,6 @@
        strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
        ifr.ifr_data = &umbp;
        if(_umbctl_ioctl(ifname, fd, SIOCGUMBPARAM, &ifr) != 0
-                       || _umbctl_set(ifname, &umbp, argc, argv) != 0
                        || _umbctl_ioctl(ifname, fd, SIOCSUMBPARAM, &ifr) != 0)
        {
                close(fd);
@@ -427,7 +425,7 @@
 /* usage */
 static int _usage(void)
 {
-       fputs("Usage: umbctl [-v] ifname [parameter[=value]] [...]\n"
+       fputs("Usage: umbctl [-v] ifname [parameter [value]] [...]\n"
 "       umbctl -f config-file ifname [...]\n",
                        stderr);
        return 1;
@@ -475,8 +473,11 @@
        if(optind == argc)
                return _usage();
        if(filename != NULL)
-               return _umbctl_file(argv[optind], filename, verbose,
-                               argc - optind - 1, &argv[optind + 1]);
+       {
+               if(optind + 1 != argc)
+                       return _usage();
+               return _umbctl_file(argv[optind], filename, verbose);
+       }
        return _umbctl(argv[optind], verbose, argc - optind - 1,
                        &argv[optind + 1]);
 }



Home | Main Index | Thread Index | Old Index