Adjusting time on a secured FreeBSD machine.
Oliver Fromme
olli at lurza.secnetix.de
Thu Feb 3 10:52:16 PST 2005
Sorry for replying to myself ...
Oliver Fromme <olli at lurza.secnetix.de> wrote:
> Adding to that, the following /bin/sh snippet should do
> (untested!). You have to kill ntpd before.
>
> STEP=100 # number of seconds to step forward
> while [ $STEP -gt 0 ]; do
> date -f %s $(( `date +%s` + 1 ))
> sleep 1
> STEP=$(( $STEP - 1 ))
> done
>
> It will take about 100 seconds to correct the clock forward
> by another 100 seconds. If you need to correct backwards,
> replace "+ 1" by "- 1". For different numbers of seconds
> to correct, replace the 100 in the first line.
>
> When you have approached the correct time sufficiently (i.e.
> within a few seconds), restart ntpd with the -x option.
Stepping backwards with that script won't work, I guess,
because the steps will be larger than 1 second. If you
have to step backwards, try to replace the "date" line
with these:
NOW=`date +%s`
sleep 0.9
date -f %s $NOW
Again: it's untested.
Also beware that it might be a very bad idea to step the
time on a live multi-user system. Some programs don't like
it at all.
Best regards
Oliver
--
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
"The scanf() function is a large and complex beast that often does
something almost but not quite entirely unlike what you desired."
-- Chris Torek
More information about the freebsd-stable
mailing list