Module Name:    src
Committed By:   khorben
Date:           Sun Mar 22 07:45:03 UTC 2020

Modified Files:
        src/sbin/umbctl: umbctl.8 umbctl.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/umbctl/umbctl.8 src/sbin/umbctl/umbctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/umbctl/umbctl.8
diff -u src/sbin/umbctl/umbctl.8:1.2 src/sbin/umbctl/umbctl.8:1.3
--- src/sbin/umbctl/umbctl.8:1.2	Wed Aug  1 17:26:30 2018
+++ src/sbin/umbctl/umbctl.8	Sun Mar 22 07:45:02 2020
@@ -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 <[email protected]>
 .\" 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:
Index: src/sbin/umbctl/umbctl.c
diff -u src/sbin/umbctl/umbctl.c:1.2 src/sbin/umbctl/umbctl.c:1.3
--- src/sbin/umbctl/umbctl.c:1.2	Thu Aug  2 03:40:51 2018
+++ src/sbin/umbctl/umbctl.c	Sun Mar 22 07:45:02 2020
@@ -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 <[email protected]>
  *
@@ -80,8 +80,8 @@ static const struct umb_valdescr _umb_be
 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 @@ static int _umbctl(char const * ifname, 
 
 
 /* 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 @@ static int _umbctl_file(char const * ifn
 	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 @@ static int _umbctl_socket(void)
 /* 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 @@ int main(int argc, char * argv[])
 	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]);
 }

Reply via email to