From 877f4ea4398d340d8655e6583f95535a52f4c8b7 Mon Sep 17 00:00:00 2001 From: andersen Date: Fri, 19 Dec 2003 11:29:29 +0000 Subject: Patch from Fillod Stephane: * 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. git-svn-id: svn://busybox.net/trunk/busybox@8127 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- util-linux/rdate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util-linux/rdate.c b/util-linux/rdate.c index c9a7ffeab..0b5f8e460 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c @@ -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(¤t_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) -- cgit v1.2.3-55-g6feb