summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormillert <>1996-08-30 04:07:43 +0000
committermillert <>1996-08-30 04:07:43 +0000
commit7c879143c6af188f0f2bce32888bc5381e355397 (patch)
tree0bb93db87324ed88232401b5d2a88c204d597547 /src/lib
parent8d02734af47aa7ce280520bc702bc108ce70e83a (diff)
downloadopenbsd-7c879143c6af188f0f2bce32888bc5381e355397.tar.gz
openbsd-7c879143c6af188f0f2bce32888bc5381e355397.tar.bz2
openbsd-7c879143c6af188f0f2bce32888bc5381e355397.zip
call rcmdsh() if euid != 0 and port is shell/tcp. This lets us
get away with fewer setuid binaries.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/net/rcmd.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c
index ef98e882a2..2530c9d5a2 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.11 1996/08/19 08:29:39 tholo Exp $"; 35static char *rcsid = "$OpenBSD: rcmd.c,v 1.12 1996/08/30 04:07:43 millert 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>
@@ -72,6 +72,13 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
72 int s, lport, timo; 72 int s, lport, timo;
73 char c; 73 char c;
74 74
75 /* use rsh(1) if non-root and remote port is shell. */
76 if (geteuid()) {
77 struct servent *sp = getservbyname("shell", "tcp");
78 if (sp && sp->s_port == rport)
79 return(rcmdsh(ahost, rport, locuser, remuser, cmd, NULL));
80 }
81
75 pid = getpid(); 82 pid = getpid();
76 hp = gethostbyname(*ahost); 83 hp = gethostbyname(*ahost);
77 if (hp == NULL) { 84 if (hp == NULL) {
@@ -79,6 +86,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
79 return (-1); 86 return (-1);
80 } 87 }
81 *ahost = hp->h_name; 88 *ahost = hp->h_name;
89
82 oldmask = sigblock(sigmask(SIGURG)); 90 oldmask = sigblock(sigmask(SIGURG));
83 for (timo = 1, lport = IPPORT_RESERVED - 1;;) { 91 for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
84 s = rresvport(&lport); 92 s = rresvport(&lport);