From owner-svn-src-head@freebsd.org Tue Jan 16 21:14:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CDE1EB8A94; Tue, 16 Jan 2018 21:14:57 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mailout.stack.nl (mailout05.stack.nl [IPv6:2001:610:1108:5010::202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.stack.nl", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DC4356D452; Tue, 16 Jan 2018 21:14:56 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from toad2.stack.nl (toad2.stack.nl [IPv6:2001:610:1108:5010::161]) by mailout.stack.nl (Postfix) with ESMTP id CAA986A; Tue, 16 Jan 2018 22:14:53 +0100 (CET) Received: by toad2.stack.nl (Postfix, from userid 1677) id C34FD892AE; Tue, 16 Jan 2018 22:14:53 +0100 (CET) Date: Tue, 16 Jan 2018 22:14:53 +0100 From: Jilles Tjoelker To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r328060 - head/usr.sbin/service Message-ID: <20180116211453.GA32669@stack.nl> References: <201801162014.w0GKEVXL048655@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201801162014.w0GKEVXL048655@repo.freebsd.org> User-Agent: Mutt/1.8.0 (2017-02-23) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jan 2018 21:14:57 -0000 On Tue, Jan 16, 2018 at 08:14:31PM +0000, 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