diff options
author | imp <imp@FreeBSD.org> | 2001-10-23 06:22:15 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-10-23 06:22:15 +0000 |
commit | af77ecc6756f2a8a3deefa094081fdd84bcd4009 (patch) | |
tree | bb8033dfd8113080366eda59916a622a5912eabd /lib/libc/net/rcmd.c | |
parent | ee3d6fba102d0dbd9d72b3a156e7714083c8833e (diff) | |
download | FreeBSD-src-af77ecc6756f2a8a3deefa094081fdd84bcd4009.zip FreeBSD-src-af77ecc6756f2a8a3deefa094081fdd84bcd4009.tar.gz |
Allow users to specify a command to use as remote command instead of
using rcmd directly. This has been in my tree for a long time, but we
may need to sync with OpenBSD before MFC.
Obtained from: openbsd
PR: 15830
MFC after: 2 months
Diffstat (limited to 'lib/libc/net/rcmd.c')
-rw-r--r-- | lib/libc/net/rcmd.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 3fad8d6..68ccb71 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -48,6 +48,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> @@ -105,11 +106,29 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) sigset_t oldmask, newmask; 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)); @@ -579,9 +598,6 @@ __ivaliduser_af(hostf, raddr, luser, ruser, af, len) return __ivaliduser_sa(hostf, sa, sa->sa_len, luser, ruser); } -/* - * Returns 0 if ok, -1 if not ok. - */ int __ivaliduser_sa(hostf, raddr, salen, luser, ruser) FILE *hostf; |