--- rdate-1.1.3.orig/src/rfc868time.c +++ rdate-1.1.3/src/rfc868time.c @@ -69,7 +69,7 @@ void rfc868time_client (const char *hostname, int family, struct timeval *new, - struct timeval *adjust, int leapflag) + struct timeval *adjust, int leapflag, int useudp, int port) { struct addrinfo hints, *res0, *res; struct timeval old; @@ -80,10 +80,10 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = family; - hints.ai_socktype = SOCK_STREAM; + hints.ai_socktype = useudp ? SOCK_DGRAM : SOCK_STREAM; /* XXX what about rfc868 UDP * probably not due to the Y2038 issue -mirabile */ - error = getaddrinfo(hostname, "time", &hints, &res0); + error = getaddrinfo(hostname, port ? NULL : "time", &hints, &res0); if (error) { errx(1, "%s: %s", hostname, gai_strerror(error)); /*NOTREACHED*/ @@ -95,6 +95,10 @@ if (s < 0) continue; + if (port) { + ((struct sockaddr_in*)res->ai_addr)->sin_port = htons(port); + } + if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { close(s); s = -1; @@ -107,6 +111,10 @@ err(1, "Could not connect socket"); freeaddrinfo(res0); + /* UDP requires us to send an empty datagram first */ + if (useudp) + send(s, NULL, 0, 0); + if (read(s, &tim, sizeof(tim)) != sizeof(tim)) err(1, "Could not read data"); --- rdate-1.1.3.orig/src/rdate.c +++ rdate-1.1.3/src/rdate.c @@ -55,6 +55,7 @@ #include #include +#include #include #include #include @@ -68,22 +69,24 @@ #define logwtmp(a,b,c) #endif -void rfc868time_client (const char *, int, struct timeval *, struct timeval *, int); -void ntp_client (const char *, int, struct timeval *, struct timeval *, int); +void rfc868time_client (const char *, int, struct timeval *, struct timeval *, int, int, int); +void ntp_client (const char *, int, struct timeval *, struct timeval *, int, int); extern char *__progname; void usage(void) { - (void) fprintf(stderr, "Usage: %s [-46acnpsv] host\n", __progname); + (void) fprintf(stderr, "Usage: %s [-46acnpsv] [-o port] host\n", __progname); (void) fprintf(stderr, " -4: use IPv4 only\n"); (void) fprintf(stderr, " -6: use IPv6 only\n"); (void) fprintf(stderr, " -a: use adjtime instead of instant change\n"); (void) fprintf(stderr, " -c: correct leap second count\n"); (void) fprintf(stderr, " -n: use SNTP instead of RFC868 time protocol\n"); + (void) fprintf(stderr, " -o num: override time port with num\n"); (void) fprintf(stderr, " -p: just print, don't set\n"); (void) fprintf(stderr, " -s: just set, don't print\n"); + (void) fprintf(stderr, " -u: use UDP instead of TCP as transport\n"); (void) fprintf(stderr, " -v: verbose output\n"); } @@ -91,15 +94,16 @@ main(int argc, char **argv) { int pr = 0, silent = 0, ntp = 0, verbose = 0; - int slidetime = 0, corrleaps = 0; + int slidetime = 0, corrleaps = 0, useudp = 0; char *hname; extern int optind; int c; int family = PF_UNSPEC; + int port = 0; struct timeval new, adjust; - while ((c = getopt(argc, argv, "46psancv")) != -1) + while ((c = getopt(argc, argv, "46psancvuo:")) != -1) switch (c) { case '4': family = PF_INET; @@ -133,6 +137,14 @@ verbose++; break; + case 'u': + useudp++; + break; + + case 'o': + port = atoi(optarg); + break; + default: usage(); return 1; @@ -145,9 +157,9 @@ hname = argv[optind]; if (ntp) - ntp_client(hname, family, &new, &adjust, corrleaps); + ntp_client(hname, family, &new, &adjust, corrleaps, port); else - rfc868time_client(hname, family, &new, &adjust, corrleaps); + rfc868time_client(hname, family, &new, &adjust, corrleaps, useudp, port); if (!pr) { if (!slidetime) { --- rdate-1.1.3.orig/src/ntp.c +++ rdate-1.1.3/src/ntp.c @@ -110,7 +110,7 @@ u_int64_t xmitck; }; -void ntp_client(const char *, int, struct timeval *, struct timeval *, int); +void ntp_client(const char *, int, struct timeval *, struct timeval *, int, int); int sync_ntp(int, const struct sockaddr *, double *, double *); int write_packet(int, struct ntp_data *); int read_packet(int, struct ntp_data *, double *, double *); @@ -126,7 +126,7 @@ void ntp_client(const char *hostname, int family, struct timeval *new, - struct timeval *adjust, int leapflag) + struct timeval *adjust, int leapflag, int port) { struct addrinfo hints, *res0, *res; double offset, error; @@ -135,7 +135,7 @@ memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; - ierror = getaddrinfo(hostname, "ntp", &hints, &res0); + ierror = getaddrinfo(hostname, port ? NULL : "ntp", &hints, &res0); if (ierror) { errx(1, "%s: %s", hostname, gai_strerror(ierror)); /*NOTREACHED*/ @@ -150,6 +150,10 @@ s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (s < 0) continue; + + if (port) { + ((struct sockaddr_in*)res->ai_addr)->sin_port = htons(port); + } ret = sync_ntp(s, res->ai_addr, &offset, &error); if (ret < 0) { @@ -429,7 +433,7 @@ data->transmit = d / NTP_SCALE; /* See write_packet for why this isn't an endian problem. */ - data->recvck = *(u_int64_t *)(packet + NTP_ORIGINATE); + memcpy(&data->recvck,packet+NTP_ORIGINATE,8); } /* --- rdate-1.1.3.orig/docs/rdate.8 +++ rdate-1.1.3/docs/rdate.8 @@ -3,6 +3,7 @@ .\" .\" Copyright (c) 1994 Christos Zoulas .\" All rights reserved. +.\" Copyright (c) 2007 Anibal Monsalve Salazar .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -37,7 +38,8 @@ .Nd set the system's date from a remote host .Sh SYNOPSIS .Nm rdate -.Op Fl 46acnpsv +.Op Fl 46acnpsuv +.Op Fl o Ar port .Ar host .Sh DESCRIPTION .Nm @@ -76,10 +78,16 @@ controlled watch or phone service. .It Fl n Use SNTP (RFC 2030) instead of the RFC 868 time protocol. +.It Fl o Ar port +Use port +.Ar port +instead of port 37. .It Fl p Do not set, just print the remote time. .It Fl s Do not print the time. +.It Fl u +Use UDP instead of TCP as transport. .It Fl v Verbose output. Always show the adjustment. @@ -108,9 +116,22 @@ adjustment, put the following line into root's crontab: .Pp .D1 Li "58 * * * * rdate -ncav ptbtime1.ptb.de | logger -t NTP" +.Pp +To to set the time through an ssh tunnel, use something like so: +.Pp +.D1 Li ssh -f -L 10037:time.example.com:37 tyr.example.com sleep 10 +.D1 Li rdate -a -o 10037 locahost +.Pp .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , .Xr inetd 8 , .Xr ntpd 8 , .Xr timed 8 +.Sh AUTHORS +This +manual page was written by +.An Christos Zoulas. +It was changed by +.An Anibal Monsalve Salazar +for the Debian Project. --- rdate-1.1.3.orig/debian/changelog +++ rdate-1.1.3/debian/changelog @@ -0,0 +1,122 @@ +rdate (1:1.1.3-1) unstable; urgency=low + + * New upstream release + * Added debian/watch + * Added homepage control header + * Bumped Standards-Version to 3.7.3 + + -- Anibal Monsalve Salazar Fri, 29 Feb 2008 23:30:03 +1100 + +rdate (1:1.1.2-5) unstable; urgency=low + + * Allowed "rdate -o 123 -n" w/o needing libnss_files and + /etc/services, closes: #434452. + Patch by Joey Hess . + + -- Anibal Monsalve Salazar Tue, 24 Jul 2007 09:50:19 +1000 + +rdate (1:1.1.2-4) unstable; urgency=low + + * The packages description mentions SNTP support. Closes: #434244. + * Minimised the size of the rdate binary in the udeb. Closes: #434441. + + -- Anibal Monsalve Salazar Tue, 24 Jul 2007 08:29:49 +1000 + +rdate (1:1.1.2-3) unstable; urgency=low + + * Fixed "unaligned access in ntp code triggers SIGBUS on sparc, + others", closes: #434140. + Patch by Steve Langasek . + + -- Anibal Monsalve Salazar Sun, 22 Jul 2007 11:29:36 +1000 + +rdate (1:1.1.2-2) unstable; urgency=low + + * New binary package rdate-udeb as per D-I meeting during debconf7 + in Edinburgh. + + -- Anibal Monsalve Salazar Sat, 21 Jul 2007 15:17:52 +1000 + +rdate (1:1.1.2-1) unstable; urgency=low + + * New upstream release. + + -- Anibal Monsalve Salazar Sun, 08 Jul 2007 20:52:51 +1000 + +rdate (1.4-8) unstable; urgency=low + + * Set DH_COMPAT to 5. + * Set Standards-Version to 3.7.2. + + -- Anibal Monsalve Salazar Thu, 22 Jun 2006 18:45:50 +1000 + +rdate (1.4-7) unstable; urgency=low + + * Fixed "'Usage' is missing recently added 'u' option.", closes: + #339798. Patch by Gonzalo Paniagua Javier . + * Set Standards-Version to 3.6.2 and added homepage to description. + * Added watch file. + * Fixed lintian error "package-uses-deprecated-debhelper-compat- + version 2". + + -- Anibal Monsalve Salazar Sun, 27 Nov 2005 09:34:00 +1100 + +rdate (1.4-6) unstable; urgency=low + + * Fixed "rdate should have an option to use UDP" (Closes: #291522). + Patch by Adrian Frith . + * New maintainer's email address. + + -- Anibal Monsalve Salazar Mon, 07 Feb 2005 23:15:12 +1100 + +rdate (1.4-5) unstable; urgency=low + + * New maintainer. + + -- Anibal Monsalve Salazar Thu, 20 May 2004 10:06:28 +1000 + +rdate (1.4-4) unstable; urgency=low + + * Documented port argument. + * Print time using locale information (closes: #185143). + + -- Herbert Xu Sat, 5 Apr 2003 16:48:48 +1000 + +rdate (1.4-3) unstable; urgency=low + + * Added build-time dependency on pmake (closes: #168030, 168035). + + -- Herbert Xu Thu, 7 Nov 2002 07:10:57 +1100 + +rdate (1.4-2) unstable; urgency=low + + * Added optional port argument (closes: #156101). + * Added build-time dependency on debhelper. + + -- Herbert Xu Wed, 6 Nov 2002 20:06:24 +1100 + +rdate (1.4-1) unstable; urgency=low + + * Synchronised with NetBSD 20020411: + . Adds support for IPv6. + + -- Herbert Xu Thu, 11 Apr 2002 20:26:19 +1000 + +rdate (1.3-3) frozen unstable; urgency=low + + * Corrected the license in copyright (closes: #52289). + + -- Herbert Xu Fri, 26 Nov 1999 08:36:31 +1100 + +rdate (1.3-2) unstable; urgency=low + + * Fixed an Alpha bug introduced when applying the netstd patch. + + -- Herbert Xu Fri, 26 Nov 1999 08:36:31 +1100 + +rdate (1.3-1) unstable; urgency=low + + * Initial release. + + -- Herbert Xu Fri, 5 Nov 1999 20:22:06 +1100 + --- rdate-1.1.3.orig/debian/compat +++ rdate-1.1.3/debian/compat @@ -0,0 +1 @@ +5 --- rdate-1.1.3.orig/debian/dirs +++ rdate-1.1.3/debian/dirs @@ -0,0 +1 @@ +usr/bin --- rdate-1.1.3.orig/debian/rules +++ rdate-1.1.3/debian/rules @@ -0,0 +1,75 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +export DH_VERBOSE=1 + +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -Os +endif + +config.status: configure + dh_testdir + # Add here commands to configure the package. +ifneq "$(wildcard /usr/share/misc/config.sub)" "" + cp -f /usr/share/misc/config.sub config.sub +endif +ifneq "$(wildcard /usr/share/misc/config.guess)" "" + cp -f /usr/share/misc/config.guess config.guess +endif + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" + +build: build-stamp + +build-stamp: config.status + dh_testdir + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + [ ! -f Makefile ] || $(MAKE) distclean +ifneq "$(wildcard /usr/share/misc/config.sub)" "" + rm -f config.sub +endif +ifneq "$(wildcard /usr/share/misc/config.guess)" "" + rm -f config.guess +endif + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/rdate install + cp -p debian/rdate/usr/bin/rdate debian/rdate-udeb/usr/bin + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs ChangeLog + dh_installdocs + dh_installexamples + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums -a --no-package=rdate-udeb + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- rdate-1.1.3.orig/debian/control +++ rdate-1.1.3/debian/control @@ -0,0 +1,26 @@ +Source: rdate +Section: net +Priority: optional +Maintainer: Anibal Monsalve Salazar +Build-Depends: debhelper (>= 5), autotools-dev +Standards-Version: 3.7.3 +Homepage: http://sourceforge.net/projects/openrdate/ + +Package: rdate +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Replaces: netstd +Description: sets the system's date from a remote host + rdate displays and sets the local date and time from the host name + or address given as the argument. The time source may be an RFC 868 + TCP protocol server, which is usually implemented as a built-in + service of inetd(8), or an RFC 2030 protocol SNTP/NTP server. By + default, rdate uses the RFC 868 TCP protocol. + +Package: rdate-udeb +Section: debian-installer +Priority: optional +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +XC-Package-Type: udeb +Description: sets the system's date from a remote host --- rdate-1.1.3.orig/debian/copyright +++ rdate-1.1.3/debian/copyright @@ -0,0 +1,139 @@ +This package was debianized by Anibal Monsalve Salazar on +Sun, 08 Jul 2007 20:52:51 +1000. + +It was downloaded from http://sourceforge.net/projects/openrdate/ + +Upstream Author: + + David Snyder + + The original authors and copywrite holders of this code are as follows: + + David Mazieres + Thomas Roessler - thanx for the arc4random code! + N.M. Maclaren + Thorston "mirabile" Glaser + Christos Zoulas + +Copyright: + + Copyright 1996 David Mazieres . + Copyright (c) 2002 Thorsten Glaser. All rights reserved. + Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. + Copyright (c) 1996, 1997 by University of Cambridge. All rights reserved. + Copyright (c) 2002 by Thorsten "mirabile" Glaser. + Copyright (c) 1994 Christos Zoulas. All rights reserved. + +License: + +The code for openrdate is under various versions of the BSD-license. +The following are the different licenses and the files they apply to. + +arc4random.c, arc4random.h: +/* + * Arc4 random number generator for OpenBSD. + * Copyright 1996 David Mazieres . + * + * Modification and redistribution in source and binary forms is + * permitted provided that due credit is given to the author and the + * OpenBSD project by leaving this copyright notice intact. + */ + +ntpleaps.c, ntpleaps.h: +/* + * Copyright (c) 2002 Thorsten Glaser. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +ntp.c: +/* + * Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. + * Copyright (c) 1996, 1997 by University of Cambridge. All rights reserved. + * Copyright (c) 2002 by Thorsten "mirabile" Glaser. + * + * With very slight modifications by David Snyder, copywrite (c) 2004 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the university may be used to + * endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +rdate.c, rfc868time.c: +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * With slight modifications by David Snyder, copywrite (c) 2005 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +The Debian packaging is (C) 2007, Anibal Monsalve Salazar and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. --- rdate-1.1.3.orig/debian/rdate-udeb.dirs +++ rdate-1.1.3/debian/rdate-udeb.dirs @@ -0,0 +1 @@ +usr/bin --- rdate-1.1.3.orig/debian/docs +++ rdate-1.1.3/debian/docs @@ -0,0 +1,2 @@ +NEWS +README --- rdate-1.1.3.orig/debian/watch +++ rdate-1.1.3/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://sf.net/openrdate/ openrdate-([\d\.]+).tar.gz