Hi Patrik,

Patrik Lundin wrote on Thu, Oct 09, 2014 at 09:02:14PM +0200:

> While working on rcctl(8) support for ansible I have run into a
> situation I am not sure how to deal with.
> 
> Basically, if the user has supplied arguments we append
> "flags <whatever the user requested>" and this works good.
> 
> If the user supplied no arguments, but there currently are flags set
> in rc.conf.local we append an empty "flags" argument to reset the
> default value.
> 
> The later behaviour causes a problem when modifying special services
> like pf. When disabling pf a "pf=NO" is added to rc.conf.local as
> expected, but when trying to enable it again it will fail because the
> ansible module notices that flags are currently set ("NO"), and tries to
> call "rcctl enable pf flags" which fails: 
> 
> ---
> # rcctl enable pf flags 
> rcctl: "pf" is a special variable, cannot set "flags"
> ---
> 
> I am not sure how to deal with this properly since I do not want to
> duplicate the _special_services variable in the module.

Indeed, i'd consider that a bad idea.

Besides, i see your problem.  I don't see a good way either to
find out that for running a service without flags

 - both "enable sshd" and "enable sshd flags" works
 - only "enable tftpd flags" works, but "enable tftpd" sets an argument
 - only "enable pf" works, "enable pf flags" errors out

I agree that always allowing the "flags" keyword simplifies usage.

> A possible solution to this would be to relax the flags check in rcctl,
> so it only cares if there are actual flags supplied. See diff below for
> a suggestion on how to deal with this which seems to work.

The first half of the patch seems pointless to me.
Why do you want to allow "disable foo flags"?
Or am i overlooking something?

The second half is ok schwarze@ if Antoine wants to commit,
though i'd slightly prefer the simplified version given below.

Yours,
  Ingo


Index: rcctl.sh
===================================================================
RCS file: /cvs/src/usr.sbin/rcctl/rcctl.sh,v
retrieving revision 1.38
diff -u -p -r1.38 rcctl.sh
--- rcctl.sh    1 Sep 2014 18:01:55 -0000       1.38
+++ rcctl.sh    9 Oct 2014 19:41:57 -0000
@@ -276,7 +276,7 @@ if [ -n "$flag" ]; then
                if [ "$action" != "enable" ]; then
                        _rc_err "${0##*/}: \"flags\" can only be set with 
\"enable\""
                fi
-               if svc_is_special $svc; then
+               if svc_is_special $svc && [ -n "$4" ]; then
                        _rc_err "${0##*/}: \"$svc\" is a special variable, 
cannot set \"flags\""
                fi
                if [ "$4" = "NO" ]; then


> Index: rcctl.sh
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rcctl/rcctl.sh,v
> retrieving revision 1.38
> diff -u -p -u -r1.38 rcctl.sh
> --- rcctl.sh  1 Sep 2014 18:01:55 -0000       1.38
> +++ rcctl.sh  9 Oct 2014 18:17:56 -0000
> @@ -274,10 +274,14 @@ fi
>  if [ -n "$flag" ]; then
>       if [ "$flag" = "flags" ]; then
>               if [ "$action" != "enable" ]; then
> -                     _rc_err "${0##*/}: \"flags\" can only be set with 
> \"enable\""
> +                     if [ -n "$4" ]; then
> +                             _rc_err "${0##*/}: \"flags\" can only be set 
> with \"enable\""
> +                     fi
>               fi
>               if svc_is_special $svc; then
> -                     _rc_err "${0##*/}: \"$svc\" is a special variable, 
> cannot set \"flags\""
> +                     if [ -n "$4" ]; then
> +                             _rc_err "${0##*/}: \"$svc\" is a special 
> variable, cannot set \"flags\""
> +                     fi
>               fi
>               if [ "$4" = "NO" ]; then
>                       _rc_err "${0##*/}: \"flags NO\" contradicts \"enable\""

Reply via email to