summaryrefslogtreecommitdiffstats
path: root/freebsd/lib/libc/net/rcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/lib/libc/net/rcmd.c')
-rw-r--r--freebsd/lib/libc/net/rcmd.c78
1 files changed, 25 insertions, 53 deletions
diff --git a/freebsd/lib/libc/net/rcmd.c b/freebsd/lib/libc/net/rcmd.c
index 2f5e593f..8458a34c 100644
--- a/freebsd/lib/libc/net/rcmd.c
+++ b/freebsd/lib/libc/net/rcmd.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#endif
#include <arpa/nameser.h>
#include "un-namespace.h"
+#include "libc_private.h"
extern int innetgr( const char *, const char *, const char *, const char * );
@@ -74,22 +75,15 @@ static int __icheckhost(const struct sockaddr *, socklen_t, const char *);
char paddr[NI_MAXHOST];
int
-rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
- char **ahost;
- u_short rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
+rcmd(char **ahost, int rport, const char *locuser, const char *remuser,
+ const char *cmd, int *fd2p)
{
return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET);
}
int
-rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
- char **ahost;
- u_short rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
- int af;
+rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser,
+ const char *cmd, int *fd2p, int af)
{
struct addrinfo hints, *res, *ai;
struct sockaddr_storage from;
@@ -150,7 +144,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
refused = 0;
sigemptyset(&newmask);
sigaddset(&newmask, SIGURG);
- _sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
+ __libc_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport_af(&lport, ai->ai_family);
if (s < 0) {
@@ -165,7 +159,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
(void)fprintf(stderr, "rcmd: socket: %s\n",
strerror(errno));
freeaddrinfo(res);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
NULL);
return (-1);
}
@@ -183,7 +177,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
(void)fprintf(stderr, "%s: %s\n",
*ahost, strerror(errno));
freeaddrinfo(res);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
NULL);
return (-1);
}
@@ -215,7 +209,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
}
}
lport--;
- if (fd2p == 0) {
+ if (fd2p == NULL) {
_write(s, "", 1);
lport = 0;
} else {
@@ -308,7 +302,7 @@ again:
}
goto bad2;
}
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
freeaddrinfo(res);
return (s);
bad2:
@@ -316,21 +310,19 @@ bad2:
(void)_close(*fd2p);
bad:
(void)_close(s);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
freeaddrinfo(res);
return (-1);
}
int
-rresvport(port)
- int *port;
+rresvport(int *port)
{
return rresvport_af(port, AF_INET);
}
int
-rresvport_af(alport, family)
- int *alport, family;
+rresvport_af(int *alport, int family)
{
int s;
struct sockaddr_storage ss;
@@ -381,9 +373,7 @@ int __check_rhosts_file = 1;
char *__rcmd_errstr;
int
-ruserok(rhost, superuser, ruser, luser)
- const char *rhost, *ruser, *luser;
- int superuser;
+ruserok(const char *rhost, int superuser, const char *ruser, const char *luser)
{
struct addrinfo hints, *res, *r;
int error;
@@ -416,10 +406,7 @@ ruserok(rhost, superuser, ruser, luser)
* Returns 0 if ok, -1 if not ok.
*/
int
-iruserok(raddr, superuser, ruser, luser)
- unsigned long raddr;
- int superuser;
- const char *ruser, *luser;
+iruserok(unsigned long raddr, int superuser, const char *ruser, const char *luser)
{
struct sockaddr_in sin;
@@ -437,11 +424,8 @@ iruserok(raddr, superuser, ruser, luser)
* Returns 0 if ok, -1 if not ok.
*/
int
-iruserok_sa(ra, rlen, superuser, ruser, luser)
- const void *ra;
- int rlen;
- int superuser;
- const char *ruser, *luser;
+iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser,
+ const char *luser)
{
char *cp;
struct stat sbuf;
@@ -460,7 +444,7 @@ iruserok_sa(ra, rlen, superuser, ruser, luser)
raddr = (struct sockaddr *)&ss;
first = 1;
- hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
+ hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
again:
if (hostf) {
if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) {
@@ -483,7 +467,7 @@ again:
*/
uid = geteuid();
(void)seteuid(pwd->pw_uid);
- hostf = fopen(pbuf, "r");
+ hostf = fopen(pbuf, "re");
(void)seteuid(uid);
if (hostf == NULL)
@@ -521,10 +505,7 @@ again:
* Returns 0 if ok, -1 if not ok.
*/
int
-__ivaliduser(hostf, raddr, luser, ruser)
- FILE *hostf;
- u_int32_t raddr;
- const char *luser, *ruser;
+__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser)
{
struct sockaddr_in sin;
@@ -542,11 +523,8 @@ __ivaliduser(hostf, raddr, luser, ruser)
* XXX obsolete API.
*/
int
-__ivaliduser_af(hostf, raddr, luser, ruser, af, len)
- FILE *hostf;
- const void *raddr;
- const char *luser, *ruser;
- int af, len;
+__ivaliduser_af(FILE *hostf, const void *raddr, const char *luser,
+ const char *ruser, int af, int len)
{
struct sockaddr *sa = NULL;
struct sockaddr_in *sin = NULL;
@@ -585,11 +563,8 @@ __ivaliduser_af(hostf, raddr, luser, ruser, af, len)
}
int
-__ivaliduser_sa(hostf, raddr, salen, luser, ruser)
- FILE *hostf;
- const struct sockaddr *raddr;
- socklen_t salen;
- const char *luser, *ruser;
+__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen,
+ const char *luser, const char *ruser)
{
char *user, *p;
int ch;
@@ -708,10 +683,7 @@ __ivaliduser_sa(hostf, raddr, salen, luser, ruser)
* Returns "true" if match, 0 if no match.
*/
static int
-__icheckhost(raddr, salen, lhost)
- const struct sockaddr *raddr;
- socklen_t salen;
- const char *lhost;
+__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost)
{
struct sockaddr_in sin;
struct sockaddr_in6 *sin6;