Problems with startup scripts

Paul Schmehl pschmehl_lists at tx.rr.com
Tue Jun 3 15:28:17 UTC 2008


--On Tuesday, June 03, 2008 13:19:37 +0100 RW <fbsd06 at mlists.homeunix.com> 
wrote:

> On Mon, 02 Jun 2008 22:13:15 -0500
> Paul Schmehl <pschmehl_lists at tx.rr.com> wrote:
>
>
>> Imagine my surprise when I discovered that *all* of my startup
>> scripts=20 were running double flags!
>>
>> So, I looked at /etc/rc.subr, and lo and behold:
>> Line 670 of /etc/rc.subr has "$command $rc_flags $command_args"
>>
>> So, the question is, is this an error in rc_subr?  Or was I
>> misinformed=20 about the use of cammand_args?  If the former, do I
>> submit a PR?  If the=20 latter, I have a lot of work to do.
>> {{{sigh}}}
>
> rc.subr seems to be self-consistent, if you look in the comments where
> these variables are documented.
>
> There are a number of /etc/rc.d scripts that follow similar usage, but
> they are mostly using flag variable names that don't match
> "${name}_flags". The exception is  auditd which presumably would
> get double flags, if it were actually given any.
>
>
> $ grep -Ei "command_args.*=.*flags" /etc/rc.d/*
> /etc/rc.d/auditd:command_args="${auditd_flags}"
> /etc/rc.d/nfsd:command_args="${nfs_server_flags}"
> /etc/rc.d/ypbind:command_args="${nis_client_flags}"
> /etc/rc.d/yppasswdd:command_args="${nis_yppasswdd_flags}"
> /etc/rc.d/ypserv:command_args="${nis_server_flags}"
> /etc/rc.d/ypset:command_args="${nis_ypset_flags}"
> /etc/rc.d/ypxfrd:command_args="${nis_ypxfrd_flags}"

I'm willing to bet that if you run some of these scripts through sh -x (auditd, 
for example) you will find that they use double flags, just like mine do.  The 
only reason that I found out about this problem is that one port, 
security/barnyard, complained about double flags.  The other ports that I 
checked were happily starting with commandline args like this: binary -D -D -c 
/usr/local/etc/binary.conf -i interface -i interface.

I suppose most binaries don't bother to check if flags are set twice and throw 
an error.  Most likely what they do is accept the last one set and ignore the 
previous ones.

I fixed the problem by removing flags from command_args:
command_args="-c ${name_conf}" instead of command_args="-c ${name_conf} 
${name_flags}

Since rc.subr will append the flags to the commandline, adding them to 
command_args is superfluous.  If you set flags defaults in the script such that 
/etc/rc.conf settings will override them, there's no need to add flags to the 
commandline.  Rc.subr does it for you.

Now I have to go back and fix all my other startups scripts, because, well, I'm 
a perfectionist.

-- 
Paul Schmehl
As if it wasn't already obvious,
my opinions are my own and not
those of my employer.


More information about the freebsd-ports mailing list