tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Making powerd=YES default

On 01.08.2011 16:17, Martin Husemann wrote:
>> So now, I suggest you propose an alternative, so that we can make some
>> progress. Thanks.
> But I did! If postinstall just checks wether there is a powerd= line in
> rc.conf (even if it would not be required functionally), everything is
> fine. You could slightly tweak the failure message to hint at this
> possibility, but I wouldn't mind to just keep it as in your suggested
> patch.

It isn't easy: by design, rc.conf executes /etc/defaults/rc.conf by default:

# Load the defaults in from /etc/defaults/rc.conf (if it's readable).
# These can be overridden below.
if [ -r /etc/defaults/rc.conf ]; then
        . /etc/defaults/rc.conf

So I can't easily know where the powerd=NO line comes from
(/etc/defaults/rc.conf or /etc/rc.conf).

Grepping for it is not really deterministic; anyone is free to add shell
semantic, and hide the value of "powerd" behind shell commands.

Hacking around this without patching /etc/rc.conf (two steps needed, one
to patch, and another one to test value) requires a modification from

Index: etc/defaults/rc.conf
RCS file: /cvsroot/src/etc/defaults/rc.conf,v
retrieving revision 1.113
diff -u -p -u -p -r1.113 rc.conf
--- etc/defaults/rc.conf        27 May 2011 09:28:42 -0000      1.113
+++ etc/defaults/rc.conf        1 Aug 2011 15:20:58 -0000
@@ -26,6 +26,12 @@

+# If RC_SKIP_DEFAULTS is set, ignore the rest of the file. Used to
+# /etc/defaults/rc.conf and /etc/rc.conf contents.
+if [ -z "${RC_SKIP_DEFAULTS}" ]; then
+       return
 # If rc_silent is true then /etc/rc will suppress most output to
 # the console.  The default is taken from the AB_SILENT flag passed
 # from the boot loader to the kernel in the boothowto(9) variable.

Obviously, for the first time, this has to be applied _before_ testing
the rcvar value. Which means that upon postinstall, "check" => "fix" =>
"check" won't return deterministic results upon first update.

We might as well provide a MD /etc/defaults/rc.conf file, things are
becoming ugly there...

Jean-Yves Migeon

Home | Main Index | Thread Index | Old Index