rcmd.c revision 5d54f3d8999eac1762fe0a8c7177d20f1f201fae
/*
* Copyright 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <pwd.h>
#include <netdb.h>
#include <errno.h>
#include <strings.h>
static char *domain;
int
rcmd(
char **ahost,
unsigned short rport,
const char *locuser,
const char *remuser,
const char *cmd,
int *fd2p)
{
char c;
if (hp == 0) {
return (-1);
}
for (;;) {
if (s < 0) {
else
perror("rcmd: socket");
return (-1);
}
break;
(void) close(s);
if (errno == EADDRINUSE) {
lport--;
continue;
}
timo *= 2;
continue;
}
perror(0);
hp->h_addr_list++;
continue;
}
return (-1);
}
lport--;
if (fd2p == 0) {
lport = 0;
} else {
char num[8];
if (s2 < 0)
goto bad;
perror("write: setting up stderr");
goto bad;
}
if (s3 < 0) {
perror("accept");
lport = 0;
goto bad;
}
"socket: protocol failure in circuit setup.\n");
goto bad2;
}
}
if (retval != 1) {
if (retval == 0) {
"Protocol error, %s closed connection\n", *ahost);
} else if (retval < 0) {
} else {
}
goto bad2;
}
if (c != 0) {
if (c == '\n')
break;
}
goto bad2;
}
return (s);
bad2:
if (lport)
bad:
(void) close(s);
return (-1);
}
int
{
struct sockaddr_in sin;
int s;
if (s < 0)
return (-1);
for (;;) {
return (s);
if (errno != EADDRINUSE) {
(void) close(s);
return (-1);
}
(*alport)--;
(void) close(s);
return (-1);
}
}
}
int
const char *rhost,
int superuser,
const char *ruser,
const char *luser)
{
char fhost[MAXHOSTNAMELEN];
const char *sp;
char *p;
int baselen = -1;
char pbuf[MAXPATHLEN];
int euid = -1;
p = fhost;
while (*sp) {
if (*sp == '.') {
if (baselen == -1)
*p++ = *sp++;
} else {
}
}
*p = '\0';
/* check /etc/hosts.equiv */
if (!superuser) {
return(0);
}
}
}
/* check ~/.rhosts */
return(-1);
/*
* Read .rhosts as the local user to avoid NFS mapping the root uid
* to something that can't read .rhosts.
*/
if (euid != -1)
return(-1);
}
if (euid != -1)
return(-1);
}
if (euid != -1)
return(0);
}
if (euid != -1)
return (-1);
}
int
{
char *user;
char ahost[MAXHOSTNAMELEN];
char *p;
(void) yp_get_default_domain(&domain);
}
p = ahost;
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
p++;
}
if (*p == ' ' || *p == '\t') {
*p++ = '\0';
while (*p == ' ' || *p == '\t')
p++;
user = p;
while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0')
p++;
} else
user = p;
*p = '\0';
hostmatch = 1;
break;
}
else if (ahost[0] == '-') {
break;
}
else
if (user[0]) {
usermatch = 1;
break;
}
else if (user[0] == '-') {
break;
}
else
}
else
return (0);
}
return (-1);
}
int
{
static char *ldomain;
static char *domainp;
static int nodomain;
char *cp;
if (ldomain == 0)
return (0);
}
if (len == -1)
return(0);
return(1);
return(0);
if (nodomain)
return(0);
if (!domainp) {
/*
* "domainp" points after the first dot in the host name
*/
nodomain = 1;
return(0);
}
nodomain = 1;
return(0);
}
domainp++;
while (*cp) {
cp++;
}
}
}