Re: svn commit: r328060 - head/usr.sbin/service

2018-01-16 Thread Jilles Tjoelker
On Tue, Jan 16, 2018 at 08:14:31PM +, Kyle Evans wrote:
> Author: kevans
> Date: Tue Jan 16 20:14:31 2018
> New Revision: 328060
> URL: https://svnweb.freebsd.org/changeset/base/328060

> Log:
>   service(8): Reset OPTIND properly now that we're parsing args twice

>   r328032 introduced a second round of argument parsing to proxy the request
>   through to a jail as needed, but failed to reset OPTIND before getting to
>   the second round of parsing to allow other flags to be set.

>   Reported by:Oleg Ginzburg 

> Modified:
>   head/usr.sbin/service/service.sh

> Modified: head/usr.sbin/service/service.sh
> ==
> --- head/usr.sbin/service/service.sh  Tue Jan 16 20:02:07 2018
> (r328059)
> +++ head/usr.sbin/service/service.sh  Tue Jan 16 20:14:31 2018
> (r328060)
> @@ -79,6 +79,7 @@ if [ -n "$JAIL" ]; then
>   exit $?
>  fi
>  
> +OPTIND=1
>  while getopts ${accepted_argstr} COMMAND_LINE_ARGUMENT ; do
>   case "${COMMAND_LINE_ARGUMENT}" in
>   e)  ENABLED=eopt ;;

Hi,

Although this solves the immediate problem of all existing options
becoming no-ops, the new -j option still behaves strangely if it is not
used with "-j" and the jail name as the first two arguments, since the
shift commands will shift away other arguments.

One way to fix this avoids depending on the exact options known by the
jailed service(8) and accepts that the -j option must be first (either
-j JAIL as two arguments or -jJAIL as one argument). This parsing would
be open-coded and there would be only one getopts loop.

Another way to fix this allows using the -j option as any other option.
This would also use one getopts loop and reconstruct a command line for
the jailed service(8) based on the variables like ENABLED (the values
for set options can be changed to simplify this since the rest of the
script only cares about non-empty or not).

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r328060 - head/usr.sbin/service

2018-01-16 Thread Kyle Evans
Author: kevans
Date: Tue Jan 16 20:14:31 2018
New Revision: 328060
URL: https://svnweb.freebsd.org/changeset/base/328060

Log:
  service(8): Reset OPTIND properly now that we're parsing args twice
  
  r328032 introduced a second round of argument parsing to proxy the request
  through to a jail as needed, but failed to reset OPTIND before getting to
  the second round of parsing to allow other flags to be set.
  
  Reported by:  Oleg Ginzburg 

Modified:
  head/usr.sbin/service/service.sh

Modified: head/usr.sbin/service/service.sh
==
--- head/usr.sbin/service/service.shTue Jan 16 20:02:07 2018
(r328059)
+++ head/usr.sbin/service/service.shTue Jan 16 20:14:31 2018
(r328060)
@@ -79,6 +79,7 @@ if [ -n "$JAIL" ]; then
exit $?
 fi
 
+OPTIND=1
 while getopts ${accepted_argstr} COMMAND_LINE_ARGUMENT ; do
case "${COMMAND_LINE_ARGUMENT}" in
e)  ENABLED=eopt ;;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"