diff options
| author | Jacques Vidrine <nectar@FreeBSD.org> | 2002-04-15 12:52:29 +0000 |
|---|---|---|
| committer | Jacques Vidrine <nectar@FreeBSD.org> | 2002-04-15 12:52:29 +0000 |
| commit | ead2e88ae14d32d952ffdd3625a3927661df3387 (patch) | |
| tree | 071e51c42e5ea966bd1675abe9cb936f888defdd /lib | |
| parent | f60eb376e9750e93f6c2e00597c6ae4ba0fa8d15 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/net/Makefile.inc | 4 | ||||
| -rw-r--r-- | lib/libc/net/rcmd.c | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index ca382c619799..f7e688407d0c 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -16,7 +16,7 @@ SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c getaddrinfo.c \ inet_pton.c ip6opt.c linkaddr.c map_v4v6.c name6.c ns_addr.c \ ns_name.c ns_netint.c \ ns_ntoa.c ns_parse.c ns_print.c ns_ttl.c nsap_addr.c \ - rcmd.c recv.c res_comp.c res_data.c res_debug.c \ + rcmd.c rcmdsh.c recv.c res_comp.c res_data.c res_debug.c \ res_init.c res_mkquery.c res_mkupdate.c res_query.c res_send.c \ res_update.c rthdr.c send.c vars.c # not supported: iso_addr.c @@ -32,7 +32,7 @@ MAN+= addr2ascii.3 byteorder.3 ethers.3 getaddrinfo.3 gethostbyname.3 \ getnameinfo.3 getnetent.3 getprotoent.3 getservent.3 if_indextoname.3 \ inet.3 inet_net.3 \ inet6_option_space.3 inet6_rthdr_space.3 linkaddr.3 \ - rcmd.3 resolver.3 + rcmd.3 rcmdsh.3 resolver.3 # not installed: iso_addr.3 ns.3 MLINKS+=addr2ascii.3 ascii2addr.3 diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 3392cd532e21..f6720418fd0f 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -47,6 +47,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include <signal.h> #include <fcntl.h> #include <netdb.h> +#include <stdlib.h> #include <unistd.h> #include <pwd.h> #include <errno.h> @@ -103,11 +104,29 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) long oldmask; pid_t pid; int s, aport, lport, timo, error; - char c; + char c, *p; int refused, nres; char num[8]; static char canonnamebuf[MAXDNAME]; /* is it proper here? */ + /* call rcmdsh() with specified remote shell if appropriate. */ + if (!issetugid() && (p = getenv("RSH"))) { + struct servent *sp = getservbyname("shell", "tcp"); + + if (sp && sp->s_port == rport) + return (rcmdsh(ahost, rport, locuser, remuser, + cmd, p)); + } + + /* 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(); memset(&hints, 0, sizeof(hints)); |
