summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-08-30 04:07:44 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-08-30 04:07:44 +0000
commit443a3f9d2744afc70b626f98111e8b345b8133bd (patch)
tree1382711f945b78e93917ffe8bbcf5918724d06b8
parentfd8775d80c674f79324a50ba2731836fb4a3dfc3 (diff)
call rcmdsh() if euid != 0 and port is shell/tcp. This lets us
get away with fewer setuid binaries.
-rw-r--r--lib/libc/net/rcmd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index ef98e882a2f..2530c9d5a28 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.11 1996/08/19 08:29:39 tholo Exp $";
+static char *rcsid = "$OpenBSD: rcmd.c,v 1.12 1996/08/30 04:07:43 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -72,6 +72,13 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
int s, lport, timo;
char c;
+ /* 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));
+ }
+
pid = getpid();
hp = gethostbyname(*ahost);
if (hp == NULL) {
@@ -79,6 +86,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
return (-1);
}
*ahost = hp->h_name;
+
oldmask = sigblock(sigmask(SIGURG));
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport(&lport);