summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>1996-08-30 16:32:08 +0000
committerderaadt <>1996-08-30 16:32:08 +0000
commit2bc288467763c9abeed2f111efe819ebfd6c5da1 (patch)
tree0bb46ab5c75632a1b7576bcbe9e5d7562c696cb6
parent7c879143c6af188f0f2bce32888bc5381e355397 (diff)
downloadopenbsd-2bc288467763c9abeed2f111efe819ebfd6c5da1.tar.gz
openbsd-2bc288467763c9abeed2f111efe819ebfd6c5da1.tar.bz2
openbsd-2bc288467763c9abeed2f111efe819ebfd6c5da1.zip
avoid port 1023 more
-rw-r--r--src/lib/libc/net/rcmd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c
index 2530c9d5a2..5c3dd78a8f 100644
--- a/src/lib/libc/net/rcmd.c
+++ b/src/lib/libc/net/rcmd.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: rcmd.c,v 1.12 1996/08/30 04:07:43 millert Exp $"; 35static char *rcsid = "$OpenBSD: rcmd.c,v 1.13 1996/08/30 16:32:08 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <sys/param.h> 38#include <sys/param.h>
@@ -75,8 +75,10 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
75 /* use rsh(1) if non-root and remote port is shell. */ 75 /* use rsh(1) if non-root and remote port is shell. */
76 if (geteuid()) { 76 if (geteuid()) {
77 struct servent *sp = getservbyname("shell", "tcp"); 77 struct servent *sp = getservbyname("shell", "tcp");
78
78 if (sp && sp->s_port == rport) 79 if (sp && sp->s_port == rport)
79 return(rcmdsh(ahost, rport, locuser, remuser, cmd, NULL)); 80 return (rcmdsh(ahost, rport, locuser, remuser,
81 cmd, NULL));
80 } 82 }
81 83
82 pid = getpid(); 84 pid = getpid();
@@ -246,11 +248,13 @@ rresvport(alport)
246 if (s < 0) 248 if (s < 0)
247 return (-1); 249 return (-1);
248 sin.sin_port = htons((u_short)*alport); 250 sin.sin_port = htons((u_short)*alport);
249 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 251 if (alport != IPPORT_RESERVED - 1) {
250 return (s); 252 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
251 if (errno != EADDRINUSE) { 253 return (s);
252 (void)close(s); 254 if (errno != EADDRINUSE) {
253 return (-1); 255 (void)close(s);
256 return (-1);
257 }
254 } 258 }
255 sin.sin_port = 0; 259 sin.sin_port = 0;
256 if (bindresvport(s, &sin) == -1) { 260 if (bindresvport(s, &sin) == -1) {