Subject: bin/1226: enhancement request for rdate
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: Charlie Root <root@pure.com>
List: netbsd-bugs
Date: 07/13/1995 22:20:11
>Number: 1226
>Category: bin
>Synopsis: rdate sets date suddenly
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Jul 13 22:20:06 1995
>Originator: David Gluss
>Organization:
Pure Software
>Release: <NetBSD-current source date> NetBSD-current Aug/6/95
>Environment:
i386
System: NetBSD woodside.pure.com 1.0A NetBSD 1.0A (WOODSIDE) #48: Mon Jul 10 15:01:24 PDT 1995 root@woodside.pure.com:/usr/src/sys/arch/i386/compile/WOODSIDE i386
>Description:
It would be winning to have the time move gradually instead of
all at once, to preserve monotonicity of time. The change is
very easy. A patch is enclosed.
>How-To-Repeat:
>Fix:
Apply the following patch in the /usr/src/usr.sbin/rdate directory:
*** rdate.8 1995/07/14 02:15:58 1.2
--- rdate.8 1995/07/14 02:16:23
***************
*** 27,33 ****
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
! .\" $Id: rdate.8,v 1.2 1995/07/14 02:15:58 root Exp $
.\"
.Dd April 30, 1994
.Dt RDATE 8
--- 27,33 ----
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
! .\" $Id: rdate.8,v 1.1 1995/07/14 02:09:09 root Exp $
.\"
.Dd April 30, 1994
.Dt RDATE 8
***************
*** 37,43 ****
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm rdate
! .Op Fl psa
.Ar host
.Sh DESCRIPTION
.Nm Rdate
--- 37,43 ----
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm rdate
! .Op Fl ps
.Ar host
.Sh DESCRIPTION
.Nm Rdate
***************
*** 53,60 ****
Do not set, just print the remote time
.It Fl s
Do not print the time.
- .It Fl a
- Use the adjtime(2) call to gradually slew the local time to the
- remote time rather than just hopping.
.Sh SEE ALSO
.Xr inetd 1
--- 53,57 ----
*** rdate.c 1994/10/27 23:31:17 1.2
--- rdate.c 1994/06/02 22:55:07
***************
*** 27,33 ****
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
! * $Id: rdate.c,v 1.2 1994/10/27 23:31:17 root Exp $
*/
/*
--- 27,33 ----
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
! * $Id: rdate.c,v 1.1 1994/06/02 22:55:07 deraadt Exp $
*/
/*
***************
*** 38,44 ****
* midnight January 1st 1900.
*/
#ifndef lint
! static char rcsid[] = "$Id: rdate.c,v 1.2 1994/10/27 23:31:17 root Exp $";
#endif /* lint */
#include <sys/types.h>
--- 38,44 ----
* midnight January 1st 1900.
*/
#ifndef lint
! static char rcsid[] = "$Id: rdate.c,v 1.1 1994/06/02 22:55:07 deraadt Exp $";
#endif /* lint */
#include <sys/types.h>
***************
*** 64,71 ****
char *argv[];
{
int pr = 0, silent = 0, s;
- int slidetime = 0;
- int adjustment;
time_t tim;
char *hname;
struct hostent *hp;
--- 64,69 ----
***************
*** 76,82 ****
extern int optind;
int c;
! while ((c = getopt(argc, argv, "psa")) != -1)
switch (c) {
case 'p':
pr++;
--- 74,80 ----
extern int optind;
int c;
! while ((c = getopt(argc, argv, "ps")) != -1)
switch (c) {
case 'p':
pr++;
***************
*** 86,105 ****
silent++;
break;
- case 'a':
- slidetime++;
- break;
-
default:
goto usage;
}
if (argc - 1 != optind) {
usage:
! (void) fprintf(stderr, "Usage: %s [-psa] host\n", __progname);
! (void) fprintf(stderr, " -p: just print, don't set\n");
! (void) fprintf(stderr, " -s: just set, don't print\n");
! (void) fprintf(stderr, " -a: use adjtime instead of instant change\n");
return (1);
}
hname = argv[optind];
--- 84,96 ----
silent++;
break;
default:
goto usage;
}
if (argc - 1 != optind) {
usage:
! (void) fprintf(stderr, "Usage: %s [-ps] host\n", __progname);
return (1);
}
hname = argv[optind];
***************
*** 138,165 ****
tim = ntohl(tim) - DIFFERENCE;
if (!pr) {
! struct timeval tv;
! if (!slidetime) {
tv.tv_sec = tim;
tv.tv_usec = 0;
if (settimeofday(&tv, NULL) == -1)
err(1, "Could not set time of day");
- } else {
- struct timeval tv_current;
- if (gettimeofday(&tv_current, NULL) == -1)
- err(1, "Could not get local time of day");
- adjustment = tv.tv_sec = tim - tv_current.tv_sec;
- tv.tv_usec = 0;
- if (adjtime(&tv, NULL) == -1)
- err(1, "Could not adjust time of day");
- }
}
!
! if (!silent) {
(void) fputs(ctime(&tim), stdout);
- if (slidetime) {
- fprintf(stdout,"adjust local clock by %d seconds\n",adjustment);
- }
- }
return 0;
}
--- 129,141 ----
tim = ntohl(tim) - DIFFERENCE;
if (!pr) {
! struct timeval tv;
tv.tv_sec = tim;
tv.tv_usec = 0;
if (settimeofday(&tv, NULL) == -1)
err(1, "Could not set time of day");
}
! if (!silent)
(void) fputs(ctime(&tim), stdout);
return 0;
}
>Audit-Trail:
>Unformatted: