On Fri, Mar 01, 2019 at 01:33:48AM +0100, Klemens Nanni wrote:
> tedu's apm(8) diff reminded me that certain vmctl(8) commands are too
> relaxed:
> 
>       $ vmctl start a b
>       vmctl: start vm command failed: Operation not permitted
>       $ vmctl stop a b
>       stopping vm a: vm not found
>       $ vmctl create a b
>       could not create a: missing size argument
>       usage:  vmctl [-v] create disk [-b base | -i disk] [-s size]
>       $ vmctl create a b -s 1G
>       could not create a: missing size argument
>       usage:  vmctl [-v] create disk [-b base | -i disk] [-s size]
>       $ vmctl create a -s 1G b
>       vmctl: raw imagefile created
> 
> `start', `stop' and `create' are the only commands with a variable
> number of options; other commands have strict checks already.
> 
> With diff below, all examples above print usage directly without doing
> anything else.
> 
> OK?
> 

sure

-ml


> Index: usr.sbin/vmctl/main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/vmctl/main.c,v
> retrieving revision 1.52
> diff -u -p -r1.52 main.c
> --- usr.sbin/vmctl/main.c     14 Dec 2018 07:56:17 -0000      1.52
> +++ usr.sbin/vmctl/main.c     1 Mar 2019 00:29:12 -0000
> @@ -599,6 +599,9 @@ ctl_create(struct parse_result *res, int
>               }
>       }
>  
> +     if (argc > 0)
> +             ctl_usage(res->ctl);
> +
>       if (input) {
>               if (base && input)
>                       errx(1, "conflicting -b and -i arguments");
> @@ -913,6 +916,9 @@ ctl_start(struct parse_result *res, int 
>               }
>       }
>  
> +     if (argc > 0)
> +             ctl_usage(res->ctl);
> +
>       for (i = res->nnets; i < res->nifs; i++) {
>               /* Add interface that is not attached to a switch */
>               if (parse_network(res, "") == -1)
> @@ -953,6 +959,9 @@ ctl_stop(struct parse_result *res, int a
>                       /* NOTREACHED */
>               }
>       }
> +
> +     if (argc > 0)
> +             ctl_usage(res->ctl);
>  
>       /* VM id is only expected without the -a flag */
>       if ((res->action != CMD_STOPALL && ret == -1) ||
> 

Reply via email to