#531 rc.d-scripts, start_precmd variable a little bit too global


I was playing with rc.d-files (embedded, 0.7 4427), and stumbled across some unexpected behaviour.

Let's say I've got the following rc.d file there:


command_args = "-some -very -bad -arguments"
run_rc_command "$1"

Expected result would be that this function will be called once, when "test-rc-file" is run to init/start the daemon. The script is run exactly once, as it should, but the start_precmd function is called a couple times more often. I found out that some other rc.d-files that don't define their own start_precmd will execute that function, like nut_upsmon, nut_upslog, powerd, local...

As long as that function only inits some files or something it wouldn't matter, but in this case the function changes a global variable. Result is e.g. a upsmon running with the following arguments:

/usr/local/sbin/upsmon -u root localhost -some -very -bad -arguments

which is not quite what it should look like.

I tried to globally unset that function in every rc file by hacking rc.subr, which is called by every single rc-script (except "hosts"):

echo "start_precmd=" >>/etc/rc.subr

and that did the trick without any ill side effects as far as I can see, I haven't tested anything in detail yet. Maybe it would be a good idea to reset some other global variables (that actually shouldn't be that global) as well?

Maybe someone with more knowledge about the whole rc.d mechanisms could look into that? This has potential for really hard to diagnose problems. I only noticed the problem when I found a "-some" file with a couple lines of "-very -bad -arguments" in the root dir after booting.


  • Volker

    Volker - 2009-03-19

    Did not realize this till now but as you've mentioned it has some bad potential.
    I'll check that issue.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks