[PATCH] rdate: bug fix (svn 11946)

Shaun Jackman sjackman at gmail.com
Thu May 25 17:40:45 UTC 2006


A bug introduced in svn 11946 broke rdate. It no longer sets the
current system time when no options are specified. The options have
the opposite sense from what one might think, and, oddly enough, -ps
is intentionally a no-op.

Quoth rdate(8) from the BSD System Manager's Manual:

     -p      Do not set, just print the remote time
     -s      Do not print the time.

Cheers,
Shaun

2006-05-25  Shaun Jackman  <sjackman at gmail.com>

	* util-linux/rdate.c (rdate_main): Buf fix. No options should set
	the current system time.

#
# old_revision [0ebbc658c9951d7f719a4d50b757b9553ee767c7]
#
# patch "util-linux/rdate.c"
#  from [555cb3960a83e6b9f7545b66399cc2a604529202]
#    to [6087a3a4119be0a2249351ca73f68e6d09cb9dcf]
#
============================================================
--- util-linux/rdate.c	555cb3960a83e6b9f7545b66399cc2a604529202
+++ util-linux/rdate.c	6087a3a4119be0a2249351ca73f68e6d09cb9dcf
@@ -69,7 +69,7 @@

  	remote_time = askremotedate(argv[optind]);

-	if (flags & 1) {
+	if ((flags & 2) == 0) {
 		time_t current_time;

 		time(&current_time);
@@ -78,10 +78,10 @@
 		else
  			if (stime(&remote_time) < 0)
 				bb_perror_msg_and_die("Could not set time of day");
+	}

-	/* No need to check for the -p flag as it's the only option left */
+	if ((flags & 1) == 0)
+		printf("%s", ctime(&remote_time));

-	} else printf("%s", ctime(&remote_time));
-
 	return EXIT_SUCCESS;
 }
-------------- next part --------------
2006-05-25  Shaun Jackman  <sjackman at gmail.com>

	* util-linux/rdate.c (rdate_main): Buf fix. No options should set
	the current system time.

# 
# old_revision [0ebbc658c9951d7f719a4d50b757b9553ee767c7]
# 
# patch "util-linux/rdate.c"
#  from [555cb3960a83e6b9f7545b66399cc2a604529202]
#    to [6087a3a4119be0a2249351ca73f68e6d09cb9dcf]
# 
============================================================
--- util-linux/rdate.c	555cb3960a83e6b9f7545b66399cc2a604529202
+++ util-linux/rdate.c	6087a3a4119be0a2249351ca73f68e6d09cb9dcf
@@ -69,7 +69,7 @@
 
 	remote_time = askremotedate(argv[optind]);
 
-	if (flags & 1) {
+	if ((flags & 2) == 0) {
 		time_t current_time;
 
 		time(&current_time);
@@ -78,10 +78,10 @@
 		else
 			if (stime(&remote_time) < 0)
 				bb_perror_msg_and_die("Could not set time of day");
+	}
 
-	/* No need to check for the -p flag as it's the only option left */
+	if ((flags & 1) == 0)
+		printf("%s", ctime(&remote_time));
 
-	} else printf("%s", ctime(&remote_time));
-
 	return EXIT_SUCCESS;
 }



More information about the busybox mailing list