diff options
author | 1996-08-30 16:32:08 +0000 | |
---|---|---|
committer | 1996-08-30 16:32:08 +0000 | |
commit | 22c1ec3f040857e7c30cc49c558f2c3478767c79 (patch) | |
tree | c1973aed0c38569b96daf407b80f2521fd656f63 /lib/libc/net/rcmd.c | |
parent | fix warnings (diff) | |
download | wireguard-openbsd-22c1ec3f040857e7c30cc49c558f2c3478767c79.tar.xz wireguard-openbsd-22c1ec3f040857e7c30cc49c558f2c3478767c79.zip |
avoid port 1023 more
Diffstat (limited to 'lib/libc/net/rcmd.c')
-rw-r--r-- | lib/libc/net/rcmd.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 2530c9d5a28..5c3dd78a8f2 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: rcmd.c,v 1.12 1996/08/30 04:07:43 millert Exp $"; +static char *rcsid = "$OpenBSD: rcmd.c,v 1.13 1996/08/30 16:32:08 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -75,8 +75,10 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p) /* use rsh(1) if non-root and remote port is shell. */ if (geteuid()) { struct servent *sp = getservbyname("shell", "tcp"); + if (sp && sp->s_port == rport) - return(rcmdsh(ahost, rport, locuser, remuser, cmd, NULL)); + return (rcmdsh(ahost, rport, locuser, remuser, + cmd, NULL)); } pid = getpid(); @@ -246,11 +248,13 @@ rresvport(alport) if (s < 0) return (-1); sin.sin_port = htons((u_short)*alport); - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) - return (s); - if (errno != EADDRINUSE) { - (void)close(s); - return (-1); + if (alport != IPPORT_RESERVED - 1) { + if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) + return (s); + if (errno != EADDRINUSE) { + (void)close(s); + return (-1); + } } sin.sin_port = 0; if (bindresvport(s, &sin) == -1) { |