1 |
on 09/16/2008 01:31 AM Duncan wrote the following: |
2 |
> Thanasis <thanasis@××××××××××.org> posted 48CE7EAE.9080404@××××××××××.org, |
3 |
> excerpted below, on Mon, 15 Sep 2008 18:26:38 +0300: |
4 |
> |
5 |
>> on 09/15/2008 05:57 PM Sebastian Redl wrote the following: |
6 |
>>> Thanasis wrote: |
7 |
>>>> I attach the /etc/init.d/clock which shows a local "readonly" variable |
8 |
>>>> that controls a "--noadjfile" option. What does the following test do? |
9 |
>>>> |
10 |
>>>> if ! touch /etc/adjtime 2>/dev/null ; then |
11 |
>>>> readonly="yes" |
12 |
>>>> elif [[ ! -s /etc/adjtime ]] ; then |
13 |
>>>> echo "0.0 0 0.0" > /etc/adjtime |
14 |
>>>> fi |
15 |
>>> First it tests if a touch of /etc/adjtime succeeds. If not, the file is |
16 |
>>> not writeable, and it sets the readonly variable. |
17 |
>>> |
18 |
>>> Then it tests if /etc/adjtime exists (it does, since the touch |
19 |
>>> succeeded) and has non-zero size. If not, it writes a zero adjust into |
20 |
>>> the file. |
21 |
>>> |
22 |
>>> Sebastian |
23 |
>> How can I make /etc/adjtime readonly? I tried "chmod a-w /etc/adjtime", |
24 |
>> but root can always write to it :-) , unless the init script doesn't run |
25 |
>> as root. |
26 |
> |
27 |
> A caveat in that the below are all untested ideas. I'm just throwing |
28 |
> them out as possible solutions I'd explore further if it were me. They |
29 |
> may work, or not, but it's probably worth investigating them further and/ |
30 |
> or testing them. |
31 |
> |
32 |
> There's a spot in /etc/conf.d/clock to set your own options, right? From |
33 |
> the script, perhaps it's ${CLOCK_OPTS}. If you can set your own |
34 |
> arbitrary options, you can try adding --noadjfile to them. Except |
35 |
> hwclock is called several times (twice for start, once for stop if you |
36 |
> have it set to do so) with different options, and I've not checked to see |
37 |
> what effect setting --noadjfile will have in all those calls. You could |
38 |
> reason it out or just try it and see. |
39 |
> |
40 |
> Alternatively, the manpage says there's an --adjfile=filename option. |
41 |
> You could try adding that option and pointing it elsewhere, so the |
42 |
> scripts don't look in the right place. |
43 |
> |
44 |
> A third thing to try would be making the adjfile a directory (make it an |
45 |
> empty one just in case) instead of a file. Obviously it won't be |
46 |
> possible to write a valid adjust into it then, but I'm not sure what the |
47 |
> failure mode would be, tho it shouldn't blow up the system so it should |
48 |
> be safe to try. |
49 |
> |
50 |
> Finally, a combination of options two and three above, pointing |
51 |
> --adjfile= at a different location, an empty directory, might work. |
52 |
> |
53 |
> As I said, those are ideas I'd try. |
54 |
> |
55 |
> Something else I HAVE done on occasion, is hack whatever initscript a bit |
56 |
> to fit my needs. If you do so, make sure portage's (assuming that's the |
57 |
> PM you're using, others... I expect you'd know what to configure in them) |
58 |
> CONFIG_PROTECT variables are set to include that dir (IIRC it does as |
59 |
> it's under /etc, but the mask variable may unprotect it, so check that), |
60 |
> so an update lets you manage the changes instead of overwriting it |
61 |
> without asking. |
62 |
> |
63 |
Thanks Duncan. You gave me an idea: |
64 |
# ls -l /etc/adjtime |
65 |
lrwxrwxrwx 1 root root 9 2008-09-16 16:19 /etc/adjtime -> /dev/null |
66 |
|
67 |
It seems to work well so far. :-) |
68 |
Do you think it might cause any problems, to /dev/null maybe? |