* Copyright (c) 1980 Regents of the University of California.
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)rexec.c 5.8 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
char *getpass(), *getlogin();
rexec(ahost
, rport
, name
, pass
, cmd
, fd2p
)
struct sockaddr_in sin
, sin2
, from
;
hp
= gethostbyname(*ahost
);
ruserpass(hp
->h_name
, &name
, &pass
);
s
= socket(AF_INET
, SOCK_STREAM
, 0);
sin
.sin_family
= hp
->h_addrtype
;
bcopy(hp
->h_addr
, (caddr_t
)&sin
.sin_addr
, hp
->h_length
);
if (connect(s
, &sin
, sizeof(sin
)) < 0) {
if (errno
== ECONNREFUSED
&& timo
<= 16) {
s2
= socket(AF_INET
, SOCK_STREAM
, 0);
if (getsockname(s2
, (char *)&sin2
, &sin2len
) < 0 ||
sin2len
!= sizeof (sin2
)) {
port
= ntohs((u_short
)sin2
.sin_port
);
(void) sprintf(num
, "%u", port
);
(void) write(s
, num
, strlen(num
)+1);
{ int len
= sizeof (from
);
s3
= accept(s2
, &from
, &len
, 0);
(void) write(s
, name
, strlen(name
) + 1);
/* should public key encypt the password here */
(void) write(s
, pass
, strlen(pass
) + 1);
(void) write(s
, cmd
, strlen(cmd
) + 1);
if (read(s
, &c
, 1) != 1) {
while (read(s
, &c
, 1) == 1) {