Package: rdate Version: 1:1.1.2-1 Severity: normal Tags: d-i, patch rdate currently uses /etc/services to determine ntp ports. For the udeb in d-i, I'd rather avoid that, since the libnss_files library needed to read /etc/services is not currently included in d-i, and would use significant space (33k). Currently if these files are omitted, it fails:
rdate: pool.ntp.org: Servname not supported for ai_socktype. It seemed to me that if rdate is run with the -o option, it knows the port to use, and so shouldn't need to look in /etc/services at all. However the current use of getaddrinfo makes it look in /etc/services every time. Also, it currently doesn't support -o at all for NTP. The attached patch should fix this. PS: As I was reading the code, I noticed several innacuracies on the man page: * -u is not supported for NTP. Probably obvious, to those who know how NTP works, but wasn't to me. :-) * -4 and -6 only select the preferred address family. Ie, with -6, it will first try any ipv6 addresses, but if none are found, or connecting fails, it will then fall back to ipv4 addresses. PPS: The package description should mention that it can also use NTP. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.21-2-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages rdate depends on: ii libc6 2.6-2 GNU C Library: Shared libraries rdate recommends no packages. -- no debconf information -- see shy jo
diff -ur old/rdate-1.1.2/src/ntp.c rdate-1.1.2/src/ntp.c --- old/rdate-1.1.2/src/ntp.c 2006-09-28 22:12:55.000000000 -0400 +++ rdate-1.1.2/src/ntp.c 2007-07-23 18:15:07.000000000 -0400 @@ -109,7 +109,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 *); @@ -125,7 +125,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; @@ -134,7 +134,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*/ @@ -149,6 +149,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) { diff -ur old/rdate-1.1.2/src/rdate.c rdate-1.1.2/src/rdate.c --- old/rdate-1.1.2/src/rdate.c 2007-07-23 18:20:34.000000000 -0400 +++ rdate-1.1.2/src/rdate.c 2007-07-23 18:14:51.000000000 -0400 @@ -70,7 +70,7 @@ #endif void rfc868time_client (const char *, int, struct timeval *, struct timeval *, int, int, int); -void ntp_client (const char *, int, struct timeval *, struct timeval *, int); +void ntp_client (const char *, int, struct timeval *, struct timeval *, int, int); extern char *__progname; @@ -157,7 +157,7 @@ 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, useudp, port); diff -ur old/rdate-1.1.2/src/rfc868time.c rdate-1.1.2/src/rfc868time.c --- old/rdate-1.1.2/src/rfc868time.c 2007-07-23 18:20:34.000000000 -0400 +++ rdate-1.1.2/src/rfc868time.c 2007-07-23 18:13:02.000000000 -0400 @@ -83,7 +83,7 @@ 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*/
signature.asc
Description: Digital signature