/*
* 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 1999 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 */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <myrcmd.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <netdb.h>
#include <fcntl.h>
#include <libintl.h>
#include <memutils.h>
char *strchr();
char *inet_ntoa();
int
char *cmd)
{
int tries = 0;
char c;
int lport;
int saverr;
if (hp == 0) {
char *straddr;
return (MYRCMD_NOHOST);
} else {
(void) snprintf(myrcmd_stderr,
sizeof (myrcmd_stderr),
return (MYRCMD_NOHOST);
}
sizeof (numhostname));
numaddrlist[0] = &numaddr;
}
}
/* This provides a bounds-test for the bcopy()s below. */
gettext("rcmd: address size: %d larger than limit %d\n"),
return (MYRCMD_EBAD);
}
/* ignore SIGPIPE */
/* block SIGURG */
timo = 1;
/*
* Use 0 as lport means that rresvport() will bind to a port in
* the anonymous priviledged port range.
*/
lport = 0;
for (;;) {
if (s < 0) {
int err;
(void) snprintf(myrcmd_stderr,
sizeof (myrcmd_stderr),
gettext("socket: All ports in use\n"));
} else {
(void) snprintf(myrcmd_stderr,
sizeof (myrcmd_stderr),
gettext("rcmd: socket: %s\n"),
}
/* restore original SIGPIPE handler */
(struct sigaction *)0);
/* restore original signal mask */
(sigset_t *)0);
return (err);
}
/* Can't fail, according to fcntl(2) */
break;
(void) close(s);
if (saverr == EADDRINUSE) {
continue;
}
timo *= 2;
continue;
}
gettext("connect to address %s: "),
perror(0);
hp->h_addr_list++;
continue;
}
/* restore original SIGPIPE handler */
(struct sigaction *)0);
/* restore original signal mask */
return (MYRCMD_ENOCONNECT);
}
(void) close(s);
return (MYRCMD_ENOCONNECT);
}
if (retval == -1)
else
gettext("write unexpectedly truncated\n"));
goto bad;
}
if (retval != 1) {
if (retval == 0) {
/*
* Solaris 2.0 bug alert. Sometimes, if the
* tapehost is a Solaris 2.0 system, the connection
* will be dropped at this point. Let's try again,
* three times, before we throw in the towel.
*/
if (++tries < 3) {
(void) close(s);
goto again;
}
gettext("Protocol error, %s closed connection\n"),
*ahost);
} else if (retval < 0) {
} else {
gettext("Protocol error, %s sent %d bytes\n"),
}
goto bad;
}
if (c != 0) {
*cp++ = c;
break;
}
*cp = '\0';
goto bad;
}
/* restore original SIGPIPE handler */
/* restore original signal mask */
return (s);
bad:
(void) close(s);
/* restore original SIGPIPE handler */
/* restore original signal mask */
return (MYRCMD_EBAD);
}