On Friday 11 December 2009, Frans Pop wrote:
> > debian:~# date
> > Tue Sep 9 20:18:34 CET 1902
> > debian:~# rdate -o 123 -nvv -p 0.debian.pool.ntp.org
> > .
> > Sun Sep 27 23:32:42 CET 1970
> > rdate: adjust local clock by 2147481499.516352 seconds
> > debian:~# rdate -o 123 -nvv 0.debian.pool.ntp.org
> > .
> > rdate: Could not set time of day: Invalid argument
Looking at the original strace, it seems to me that rdate may just be
calculating the new time value incorrectly.
> gettimeofday({2203525639, 202585}, NULL) = 0
> gettimeofday({2203525639, 203778}, NULL) = 0
> settimeofday({56041989, 2148687426}, NULL) = -1 EINVAL (Invalid argument)
The value for tv_sec looks low and the one for tv_usec way too high. Could
it be that the calculation is just wrong (maybe due to overflow) when the
current date is very old?
I can reproduce the problem by simply hardcoding the time to set in main():
if (!pr) {
if (!slidetime) {
logwtmp("|", "date", "");
+ new.tv_sec = 56041989;
+ new.tv_usec = 2148687426;
if (settimeofday(&new, NULL) == -1)
[...]
If I run with that I get the error:
rdate: Could not set time of day: Invalid argument
But if I change to the second added line to 'new.tv_usec = 0;', I get:
Mon Oct 11 16:13:27 CET 1971
rdate: adjust locale clock by 0.001926 seconds
So it looks to me that the "Invalid argument" is purely caused by the too
high value for tv_usec. And tv_sec does seem incorrect too as it
corresponds to a date in 1971 instead of one in 2009.
If I use 'new.tv_sec = 1256840868;' (from the strace with ntpdate) and
'new.tv_usec = 0;' I do get a date in 2009:
Thu Oct 29 19:27:48 CET 2009
rdate: adjust locale clock by -0.000648 seconds
So, to me this looks like a calculation error in rdate, probably in ntp.c.
Note that the tv_sec value for Sept 9 1902 is 2203525639 and the one for
Okt 29 2009 is 1256840868, which is *smaller*. So I suspect the first
value is actually negative (which would be correct given an epoch of Jan 1
1970).
Hope this helps,
FJP
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]