Tue, 6 Sep 2016 21:04:55 +0200 Antoine Jacoutot <ajacou...@bsdfrog.org>
> On Tue, Sep 06, 2016 at 09:01:08PM +0200, ludovic coues wrote:
> > 2016-09-06 20:53 GMT+02:00 Antoine Jacoutot <ajacou...@bsdfrog.org>:  
> > > On Tue, Sep 06, 2016 at 12:29:58PM -0400, Anthony Coulter wrote:  
> > >> Sometimes when I restart a service after changing its configuration file
> > >> I accidentally type:
> > >>
> > >>  # rcctl restart smtpd.conf
> > >>  /usr/sbin/rcctl: ${cached_svc_is_special_smtpd.conf}: bad substitution
> > >>  /usr/sbin/rcctl[556]: set: cached_svc_is_special_smtpd.conf: is not an
> > >>  identifier
> > >>  rcctl: service smtpd.conf does not exist
> > >>
> > >> The message about a bad substitution is not helpful to the user, who
> > >> only needs to know that smtpd.conf is not a service.
> > >>
> > >> The problem is the period in "smtpd.conf". Line 189 of rcctl fails:
> > >>   _cached=$(eval print \${cached_svc_is_special_${_svc}})
> > >>
> > >> Special service names are thus limited to underscores and alphanumerics
> > >> because they're concatenated into shell variable names. So instead of
> > >> checking for [ -n ${_svc} ] at the top of svc_is_special, we ought to
> > >> check that ${_svc} contains only legal characters.
> > >>
> > >> I check only in svc_is_special and not in any of the other places that
> > >> test [ -n ${_svc} ] my only goal is to fix the error message people get
> > >> when they try to start or enable configuration files, and this is the
> > >> only place that needs the error. Adding a similar check to svc_is_avail
> > >> would block an error message when someone creates an executable file
> > >> called /etc/rc.d/foo.bar and then calls "rcctl enable foo.bar", but in
> > >> that case I think the message "${foo.bar_flags}: bad substitution" is
> > >> more helpful---the user is trying to create a service with an illegal
> > >> name and the system is telling him why it will never work.  
> > >
> > > Yes I agree this should be fixed.
> > > What about this?
> > >
> > > Index: rcctl.sh
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/rcctl/rcctl.sh,v
> > > retrieving revision 1.104
> > > diff -u -p -r1.104 rcctl.sh
> > > --- rcctl.sh    30 Jul 2016 06:25:21 -0000      1.104
> > > +++ rcctl.sh    6 Sep 2016 18:51:18 -0000
> > > @@ -139,7 +139,7 @@ rcconf_edit_end()
> > >  svc_is_avail()
> > >  {
> > >         local _svc=$1
> > > -       [ -n "${_svc}" ] || return
> > > +       [[ "${_svc}" == +([_/+[:alnum:]]) ]] || return
> > >
> > >         [ -x "/etc/rc.d/${_svc}" ] && return
> > >         svc_is_special ${_svc}
> > >
> > >
> > > --
> > > Antoine
> > >  
> > 
> > If people are using daemon named like fastcgi.exemple.com, this will
> > break there config.  
> 
> The daemon name has no importance. Only the rc.d script name does.
> And in this case, we can install it as /etc/rc.d/fastcgi_exemple_com
> We need to draw a line somewhere to prevent the crazyness...

Hi tech@,

Daemon names historically match Antoine's alphanumeric proposal, and I
think underscore is a bit too much, if it's present use minus instead.
The logic behind this?  Match this to word termination symbols in ksh.

Kind regards,
Anton

Reply via email to