Module Name: src
Committed By: ginsbach
Date: Sat Aug 26 19:26:32 UTC 2017
Modified Files:
src/usr.sbin/rdate: rdate.8 rdate.c
Log Message:
Support -4 and -6.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/rdate/rdate.8
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/rdate/rdate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/rdate/rdate.8
diff -u src/usr.sbin/rdate/rdate.8:1.12 src/usr.sbin/rdate/rdate.8:1.13
--- src/usr.sbin/rdate/rdate.8:1.12 Sat Aug 26 18:16:05 2017
+++ src/usr.sbin/rdate/rdate.8 Sat Aug 26 19:26:32 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: rdate.8,v 1.12 2017/08/26 18:16:05 ginsbach Exp $
+.\" $NetBSD: rdate.8,v 1.13 2017/08/26 19:26:32 ginsbach Exp $
.\"
.\" Copyright (c) 1994 Christos Zoulas
.\" All rights reserved.
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 30, 1994
+.Dd August 26, 2017
.Dt RDATE 8
.Os
.Sh NAME
@@ -31,7 +31,7 @@
.Nd set the system's date from a remote host
.Sh SYNOPSIS
.Nm
-.Op Fl aps
+.Op Fl 46aps
.Ar host
.Sh DESCRIPTION
.Nm
@@ -43,6 +43,14 @@ protocol which is usually implemented as
Available options:
.Pp
.Bl -tag -width indent
+.It Fl 4
+Forces
+.Nm
+to use IPv4 addresses only.
+.It Fl 6
+Forces
+.Nm
+to use IPv6 addresses only.
.It Fl a
Use the
.Xr adjtime 2
Index: src/usr.sbin/rdate/rdate.c
diff -u src/usr.sbin/rdate/rdate.c:1.21 src/usr.sbin/rdate/rdate.c:1.22
--- src/usr.sbin/rdate/rdate.c:1.21 Sat Aug 26 18:16:05 2017
+++ src/usr.sbin/rdate/rdate.c Sat Aug 26 19:26:32 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: rdate.c,v 1.21 2017/08/26 18:16:05 ginsbach Exp $ */
+/* $NetBSD: rdate.c,v 1.22 2017/08/26 19:26:32 ginsbach Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rdate.c,v 1.21 2017/08/26 18:16:05 ginsbach Exp $");
+__RCSID("$NetBSD: rdate.c,v 1.22 2017/08/26 19:26:32 ginsbach Exp $");
#endif /* lint */
#include <sys/types.h>
@@ -59,7 +59,9 @@ static void usage(void);
static void
usage(void)
{
- (void) fprintf(stderr, "usage: %s [-aps] host\n", getprogname());
+ (void) fprintf(stderr, "usage: %s [-46aps] host\n", getprogname());
+ (void) fprintf(stderr, " -4: use IPv4 addresses only\n");
+ (void) fprintf(stderr, " -6: use IPv6 addresses only\n");
(void) fprintf(stderr, " -a: use adjtime instead of instant change\n");
(void) fprintf(stderr, " -p: just print, don't set\n");
(void) fprintf(stderr, " -s: just set, don't print\n");
@@ -78,22 +80,31 @@ main(int argc, char *argv[])
struct addrinfo hints, *res, *res0;
int c;
int error;
+ int family = AF_UNSPEC;
adjustment = 0;
- while ((c = getopt(argc, argv, "psa")) != -1)
+ while ((c = getopt(argc, argv, "46aps")) != -1)
switch (c) {
- case 'p':
- pr++;
+ case '4':
+ family = AF_INET;
break;
- case 's':
- silent++;
+ case '6':
+ family = AF_INET6;
break;
case 'a':
slidetime++;
break;
+ case 'p':
+ pr++;
+ break;
+
+ case 's':
+ silent++;
+ break;
+
default:
usage();
return 1;
@@ -106,7 +117,7 @@ main(int argc, char *argv[])
hname = argv[optind];
memset(&hints, 0, sizeof (hints));
- hints.ai_family = PF_UNSPEC;
+ hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
error = getaddrinfo(hname, "time", &hints, &res0);