summaryrefslogtreecommitdiff
path: root/libc/inet/rpc/rcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet/rpc/rcmd.c')
-rw-r--r--libc/inet/rpc/rcmd.c159
1 files changed, 90 insertions, 69 deletions
diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c
index c76cf1ca7..4bdc8b3bc 100644
--- a/libc/inet/rpc/rcmd.c
+++ b/libc/inet/rpc/rcmd.c
@@ -35,28 +35,6 @@
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#endif /* LIBC_SCCS and not lint */
-#define bcopy __bcopy
-#define sysconf __sysconf
-#define getline __getline
-#define geteuid __geteuid
-#define seteuid __seteuid
-#define getpwnam_r __getpwnam_r
-#define gethostbyname __gethostbyname
-#define gethostbyname_r __gethostbyname_r
-#define fileno __fileno
-#define sleep __sleep
-#define inet_addr __inet_addr
-#define inet_ntoa __inet_ntoa
-#define herror __herror
-#define bind __bind
-#define connect __connect
-#define sigblock __sigblock
-#define snprintf __snprintf
-#define poll __poll
-#define accept __accept
-#define listen __listen
-#define sigsetmask __sigsetmask
-
#define __FORCE_GLIBC
#include <features.h>
@@ -79,9 +57,52 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <netinet/in.h>
#include <arpa/inet.h>
-
-extern int __rresvport(int *alport) attribute_hidden;
-extern int __getc_unlocked (FILE *__stream) attribute_hidden;
+libc_hidden_proto(memcmp)
+libc_hidden_proto(strcat)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(strnlen)
+libc_hidden_proto(bcopy)
+libc_hidden_proto(getpid)
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(perror)
+libc_hidden_proto(lstat)
+libc_hidden_proto(fstat)
+libc_hidden_proto(tolower)
+libc_hidden_proto(sysconf)
+libc_hidden_proto(getline)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(seteuid)
+libc_hidden_proto(getpwnam_r)
+libc_hidden_proto(gethostbyname)
+libc_hidden_proto(gethostbyname_r)
+libc_hidden_proto(fileno)
+libc_hidden_proto(sleep)
+libc_hidden_proto(inet_addr)
+libc_hidden_proto(inet_ntoa)
+libc_hidden_proto(herror)
+libc_hidden_proto(bind)
+libc_hidden_proto(connect)
+libc_hidden_proto(sigblock)
+libc_hidden_proto(snprintf)
+libc_hidden_proto(poll)
+libc_hidden_proto(accept)
+libc_hidden_proto(listen)
+libc_hidden_proto(sigsetmask)
+libc_hidden_proto(getc_unlocked)
+libc_hidden_proto(__fgetc_unlocked)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(fprintf)
+
+libc_hidden_proto(rresvport)
/* some forward declarations */
static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
@@ -110,7 +131,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
int s, lport, timo;
char c;
- pid = __getpid();
+ pid = getpid();
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
hstbuflen = 1024;
@@ -160,7 +181,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
*ahost = hp->h_name;
oldmask = sigblock(sigmask(SIGURG)); /* __sigblock */
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
- s = __rresvport(&lport);
+ s = rresvport(&lport);
if (s < 0) {
if (errno == EAGAIN)
(void)fprintf(stderr,
@@ -170,14 +191,14 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
sigsetmask(oldmask); /* sigsetmask */
return -1;
}
- __fcntl(s, F_SETOWN, pid); /* __fcntl */
+ fcntl(s, F_SETOWN, pid);
sin.sin_family = hp->h_addrtype;
bcopy(hp->h_addr_list[0], &sin.sin_addr,
MIN (sizeof (sin.sin_addr), hp->h_length));
sin.sin_port = rport;
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) /* __connect */
break;
- (void)__close(s);
+ (void)close(s);
if (errno == EADDRINUSE) {
lport--;
continue;
@@ -193,7 +214,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
(void)fprintf(stderr, "connect to address %s: ",
inet_ntoa(sin.sin_addr));
__set_errno (oerrno);
- __perror(0);
+ perror(0);
hp->h_addr_list++;
bcopy(hp->h_addr_list[0], &sin.sin_addr,
MIN (sizeof (sin.sin_addr), hp->h_length));
@@ -207,21 +228,21 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
}
lport--;
if (fd2p == 0) {
- __write(s, "", 1);
+ write(s, "", 1);
lport = 0;
} else {
char num[8];
- int s2 = __rresvport(&lport), s3;
+ int s2 = rresvport(&lport), s3;
socklen_t len = sizeof(from);
if (s2 < 0)
goto bad;
listen(s2, 1);
(void)snprintf(num, sizeof(num), "%d", lport); /* __snprintf */
- if (__write(s, num, __strlen(num)+1) != __strlen(num)+1) {
+ if (write(s, num, strlen(num)+1) != strlen(num)+1) {
(void)fprintf(stderr,
"rcmd: write (setting up stderr): %m\n");
- (void)__close(s2);
+ (void)close(s2);
goto bad;
}
pfd[0].fd = s;
@@ -232,11 +253,11 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
(void)fprintf(stderr, "rcmd: poll (setting up stderr): %m\n");
else
(void)fprintf(stderr, "poll: protocol failure in circuit setup\n");
- (void)__close(s2);
+ (void)close(s2);
goto bad;
}
s3 = accept(s2, (struct sockaddr *)&from, &len);
- (void)__close(s2);
+ (void)close(s2);
if (s3 < 0) {
(void)fprintf(stderr,
"rcmd: accept: %m\n");
@@ -253,17 +274,17 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
goto bad2;
}
}
- (void)__write(s, locuser, __strlen(locuser)+1);
- (void)__write(s, remuser, __strlen(remuser)+1);
- (void)__write(s, cmd, __strlen(cmd)+1);
- if (__read(s, &c, 1) != 1) {
+ (void)write(s, locuser, strlen(locuser)+1);
+ (void)write(s, remuser, strlen(remuser)+1);
+ (void)write(s, cmd, strlen(cmd)+1);
+ if (read(s, &c, 1) != 1) {
(void)fprintf(stderr,
"rcmd: %s: %m\n", *ahost);
goto bad2;
}
if (c != 0) {
- while (__read(s, &c, 1) == 1) {
- (void)__write(STDERR_FILENO, &c, 1);
+ while (read(s, &c, 1) == 1) {
+ (void)write(STDERR_FILENO, &c, 1);
if (c == '\n')
break;
}
@@ -273,21 +294,21 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
return s;
bad2:
if (lport)
- (void)__close(*fd2p);
+ (void)close(*fd2p);
bad:
- (void)__close(s);
+ (void)close(s);
sigsetmask(oldmask);
return -1;
}
-int attribute_hidden __rresvport(int *alport)
+int rresvport(int *alport)
{
struct sockaddr_in sin;
int s;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
- s = __socket(AF_INET, SOCK_STREAM, 0);
+ s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
return -1;
for (;;) {
@@ -295,12 +316,12 @@ int attribute_hidden __rresvport(int *alport)
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
return s;
if (errno != EADDRINUSE) {
- (void)__close(s);
+ (void)close(s);
return -1;
}
(*alport)--;
if (*alport == IPPORT_RESERVED/2) {
- (void)__close(s);
+ (void)close(s);
__set_errno (EAGAIN); /* close */
return -1;
}
@@ -308,7 +329,7 @@ int attribute_hidden __rresvport(int *alport)
return -1;
}
-strong_alias(__rresvport,rresvport)
+libc_hidden_def(rresvport)
static int __check_rhosts_file = 1;
static char *__rcmd_errstr;
@@ -386,7 +407,7 @@ iruserfopen (char *file, uid_t okuser)
root, if writeable by anyone but the owner, or if hardlinked
anywhere, quit. */
cp = NULL;
- if (__lstat (file, &st))
+ if (lstat (file, &st))
cp = "lstat failed";
else if (!S_ISREG (st.st_mode))
cp = "not regular file";
@@ -395,7 +416,7 @@ iruserfopen (char *file, uid_t okuser)
res = fopen (file, "r");
if (!res)
cp = "cannot open";
- else if (__fstat (fileno (res), &st) < 0)
+ else if (fstat (fileno (res), &st) < 0)
cp = "fstat failed";
else if (st.st_uid && st.st_uid != okuser)
cp = "bad owner";
@@ -478,10 +499,10 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
return -1;
#endif
- dirlen = __strlen (pwd->pw_dir);
+ dirlen = strlen (pwd->pw_dir);
pbuf = malloc (dirlen + sizeof "/.rhosts");
- __strcpy (pbuf, pwd->pw_dir);
- __strcat (pbuf, "/.rhosts");
+ strcpy (pbuf, pwd->pw_dir);
+ strcat (pbuf, "/.rhosts");
/* Change effective uid while reading .rhosts. If root and
reading an NFS mounted file system, can't read files that
@@ -546,18 +567,18 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
#ifdef HAVE_NETGROUP
/* Check nis netgroup. */
- if (__strncmp ("+@", lhost, 2) == 0)
+ if (strncmp ("+@", lhost, 2) == 0)
return innetgr (&lhost[2], rhost, NULL, NULL);
- if (__strncmp ("-@", lhost, 2) == 0)
+ if (strncmp ("-@", lhost, 2) == 0)
return -innetgr (&lhost[2], rhost, NULL, NULL);
#endif /* HAVE_NETGROUP */
/* -host */
- if (__strncmp ("-", lhost,1) == 0) {
+ if (strncmp ("-", lhost,1) == 0) {
negate = -1;
lhost++;
- } else if (__strcmp ("+",lhost) == 0) {
+ } else if (strcmp ("+",lhost) == 0) {
return 1; /* asking for trouble, but ok.. */
}
@@ -587,7 +608,7 @@ __icheckhost (u_int32_t raddr, char *lhost, const char *rhost)
/* Spin through ip addresses. */
for (pp = hp->h_addr_list; *pp; ++pp)
- if (!__memcmp (&raddr, *pp, sizeof (u_int32_t)))
+ if (!memcmp (&raddr, *pp, sizeof (u_int32_t)))
return negate;
/* No match. */
@@ -606,23 +627,23 @@ __icheckuser (const char *luser, const char *ruser)
#ifdef HAVE_NETGROUP
/* [-+]@netgroup */
- if (__strncmp ("+@", luser, 2) == 0)
+ if (strncmp ("+@", luser, 2) == 0)
return innetgr (&luser[2], NULL, ruser, NULL);
- if (__strncmp ("-@", luser,2) == 0)
+ if (strncmp ("-@", luser,2) == 0)
return -innetgr (&luser[2], NULL, ruser, NULL);
#endif /* HAVE_NETGROUP */
/* -user */
- if (__strncmp ("-", luser, 1) == 0)
- return -(__strcmp (&luser[1], ruser) == 0);
+ if (strncmp ("-", luser, 1) == 0)
+ return -(strcmp (&luser[1], ruser) == 0);
/* + */
- if (__strcmp ("+", luser) == 0)
+ if (strcmp ("+", luser) == 0)
return 1;
/* simple string match */
- return __strcmp (ruser, luser) == 0;
+ return strcmp (ruser, luser) == 0;
}
/*
@@ -664,16 +685,16 @@ __ivaliduser2(hostf, raddr, luser, ruser, rhost)
}
/* Skip lines that are too long. */
- if (__strchr (p, '\n') == NULL) {
- int ch = __getc_unlocked (hostf);
+ if (strchr (p, '\n') == NULL) {
+ int ch = getc_unlocked (hostf);
while (ch != '\n' && ch != EOF)
- ch = __getc_unlocked (hostf);
+ ch = getc_unlocked (hostf);
continue;
}
for (;*p && !isspace(*p); ++p) {
- *p = __tolower (*p);
+ *p = tolower (*p);
}
/* Next we want to find the permitted name for the remote user. */