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.