Patch from Fillod Stephane:
authorEric Andersen <andersen@codepoet.org>
Fri, 19 Dec 2003 11:29:29 +0000 (11:29 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 19 Dec 2003 11:29:29 +0000 (11:29 -0000)
* The "rdate.patch" file makes rdate to NOT settimeofday if the date to be
set equals current date. This prevents the system from experiencing nasty time
discontinuities caused by sub-second changes, with a protocol that has only
over second resolution. Depending on your taste, the "fprintf(stderr..." may be
removed.

util-linux/rdate.c

index c9a7ffeabe2970ae7ce5ca664c6043fa0fd8b3b2..0b5f8e460eecb9483a257dc549917f0eff1e46d4 100644 (file)
@@ -103,8 +103,14 @@ int rdate_main(int argc, char **argv)
        remote_time = askremotedate(argv[optind]);
 
        if (setdate) {
-               if (stime(&remote_time) < 0)
-                       bb_perror_msg_and_die("Could not set time of day");
+               time_t current_time;
+
+               time(&current_time);
+               if (current_time == remote_time)
+                       bb_error_msg("Current time matches remote time.");
+               else
+                       if (stime(&remote_time) < 0)
+                               bb_perror_msg_and_die("Could not set time of day");
        }
 
        if (printdate)