on 09/16/2008 01:31 AM Duncan wrote the following:
Thanasis <[EMAIL PROTECTED]> posted [EMAIL PROTECTED],
excerpted below, on  Mon, 15 Sep 2008 18:26:38 +0300:

on 09/15/2008 05:57 PM Sebastian Redl wrote the following:
Thanasis wrote:
I attach the /etc/init.d/clock which shows a local "readonly" variable
that controls a "--noadjfile" option. What does the following test do?

if ! touch /etc/adjtime 2>/dev/null ; then
               readonly="yes"
elif [[ ! -s /etc/adjtime ]] ; then
               echo "0.0 0 0.0" > /etc/adjtime
fi
First it tests if a touch of /etc/adjtime succeeds. If not, the file is
not writeable, and it sets the readonly variable.

Then it tests if /etc/adjtime exists (it does, since the touch
succeeded) and has non-zero size. If not, it writes a zero adjust into
the file.

Sebastian
How can I make /etc/adjtime readonly? I tried "chmod a-w /etc/adjtime",
but root can always write to it :-) , unless the init script doesn't run
as root.

A caveat in that the below are all untested ideas. I'm just throwing them out as possible solutions I'd explore further if it were me. They may work, or not, but it's probably worth investigating them further and/
or testing them.

There's a spot in /etc/conf.d/clock to set your own options, right? From the script, perhaps it's ${CLOCK_OPTS}. If you can set your own arbitrary options, you can try adding --noadjfile to them. Except hwclock is called several times (twice for start, once for stop if you have it set to do so) with different options, and I've not checked to see what effect setting --noadjfile will have in all those calls. You could reason it out or just try it and see.

Alternatively, the manpage says there's an --adjfile=filename option. You could try adding that option and pointing it elsewhere, so the scripts don't look in the right place.

A third thing to try would be making the adjfile a directory (make it an empty one just in case) instead of a file. Obviously it won't be possible to write a valid adjust into it then, but I'm not sure what the failure mode would be, tho it shouldn't blow up the system so it should be safe to try.

Finally, a combination of options two and three above, pointing --adjfile= at a different location, an empty directory, might work.

As I said, those are ideas I'd try.

Something else I HAVE done on occasion, is hack whatever initscript a bit to fit my needs. If you do so, make sure portage's (assuming that's the PM you're using, others... I expect you'd know what to configure in them) CONFIG_PROTECT variables are set to include that dir (IIRC it does as it's under /etc, but the mask variable may unprotect it, so check that), so an update lets you manage the changes instead of overwriting it without asking.

Thanks Duncan. You gave me an idea:
# ls -l /etc/adjtime
lrwxrwxrwx 1 root root 9 2008-09-16 16:19 /etc/adjtime -> /dev/null

It seems to work well so far. :-)
Do you think it might cause any problems, to /dev/null maybe?


Reply via email to