/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* rdate - get date from remote machine
*
* sets time, obtaining value from host
*/
#include <signal.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <netdb.h>
#include <stdio.h>
/*
* The timeserver returns with time of day in seconds since
* Jan 1, 1900. We must subtract 86400(365*70 + 17) to get time
* since Jan 1, 1970, which is what get/settimeofday uses.
*/
/*
* Before setting the system time, the value returned by the
* timeserver is checked for plausibility. If the returned date
* is before the time this program was written it cannot be
* correct.
*/
static void timeout(int);
int
{
int s, i;
unsigned int connect_timeout;
/* number of seconds to wait for something to happen. */
int rc;
if (argc != 2) {
}
/*
* getaddrinfo() may take a long time, because it can involve
* NIS, DNS, or LDAP lookups. Set an alarm timer. Note that this
* may still fail, depending on how SIGALRM is handled by the
* functions invoked by getaddrinfo().
*/
(void) alarm(rdate_timeout);
/*
* Note: memory not freed due to short lifetime of program.
*/
(void) alarm(0);
if (rc != 0) {
gai_strerror(rc));
}
res->ai_protocol);
if (s < 0) {
perror("rdate: socket");
}
perror("setsockopt TCP_CONN_ABORT_THRESHOLD");
}
break;
perror("rdate: connect");
(void) close(s);
}
(void) close(s);
}
(void) alarm(rdate_timeout);
perror("rdate: read");
}
(void) alarm(0);
/* date must be later than when program was written */
argv[1]);
}
timestruct.tv_usec = 0;
i = settimeofday(×truct, 0);
if (i == -1) {
perror("couldn't set time of day");
} else {
#if defined(i386)
#endif
}
return (EXIT_SUCCESS);
}
/*ARGSUSED*/
static void
{
/* NOTREACHED */
}