From 5f2732ab6d77cd6dccb6a2d63b810569e00c702f Mon Sep 17 00:00:00 2001 From: mrg Date: Sun, 8 Mar 1998 23:36:46 +0000 Subject: [PATCH] - support RCMD_CMD, ala rcmd(3). - put paths for rsh and rmt into "pathnames.h" - document this. --- lib/librmt/pathnames.h | 32 ++++++++++++++++++++++++++++++++ lib/librmt/rmtlib.c | 22 +++++++++++++++++----- lib/librmt/rmtops.3 | 10 +++++++++- 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 lib/librmt/pathnames.h diff --git a/lib/librmt/pathnames.h b/lib/librmt/pathnames.h new file mode 100644 index 000000000000..028782297428 --- /dev/null +++ b/lib/librmt/pathnames.h @@ -0,0 +1,32 @@ +/* $NetBSD: pathnames.h,v 1.1 1998/03/08 23:36:46 mrg Exp $ */ + +/* + * Copyright (c) 1998 Matthew R. Green + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _PATH_RSH "/usr/bin/rsh" +#define _PATH_RMT "/etc/rmt" diff --git a/lib/librmt/rmtlib.c b/lib/librmt/rmtlib.c index 77b0593e03fd..d45ad2e98f70 100644 --- a/lib/librmt/rmtlib.c +++ b/lib/librmt/rmtlib.c @@ -1,4 +1,4 @@ -/* $NetBSD: rmtlib.c,v 1.9 1997/10/21 19:58:21 thorpej Exp $ */ +/* $NetBSD: rmtlib.c,v 1.10 1998/03/08 23:36:46 mrg Exp $ */ /* * rmt --- remote tape emulator subroutines @@ -60,6 +60,8 @@ #include #endif +#include "pathnames.h" + static int _rmt_close __P((int)); static int _rmt_ioctl __P((int, unsigned long, char *)); static off_t _rmt_lseek __P((int, off_t, int)); @@ -354,6 +356,8 @@ _rmt_open(path, oflag, mode) if (rc == 0) { + char *rshpath, *rsh; + close(0); dup(Ptc[i][0]); close(Ptc[i][0]); close(Ptc[i][1]); @@ -362,15 +366,23 @@ _rmt_open(path, oflag, mode) close(Ctp[i][0]); close(Ctp[i][1]); (void) setuid (getuid ()); (void) setgid (getgid ()); + + if ((rshpath = getenv("RCMD_CMD")) == NULL) + rshpath = _PATH_RSH; + if ((rsh = strrchr(rshpath, '/')) == NULL) + rsh = rshpath; + else + rsh++; + if (*login) { - execl("/usr/bin/rsh", "rsh", system, "-l", login, - "/etc/rmt", (char *) 0); + execl(rshpath, rsh, system, "-l", login, + _PATH_RMT, (char *) 0); } else { - execl("/usr/bin/rsh", "rsh", system, - "/etc/rmt", (char *) 0); + execl(rshpath, rsh, system, + _PATH_RMT, (char *) 0); } /* diff --git a/lib/librmt/rmtops.3 b/lib/librmt/rmtops.3 index e574e91a6177..d69238b11e10 100644 --- a/lib/librmt/rmtops.3 +++ b/lib/librmt/rmtops.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: rmtops.3,v 1.2 1996/08/09 03:39:02 jtc Exp $ +.\" $NetBSD: rmtops.3,v 1.3 1998/03/08 23:36:46 mrg Exp $ .\" .TH RMTOPS 3 .SH NAME @@ -191,6 +191,14 @@ file in the user's home directory, or that the application designer be willing to have .I rexec prompt the user for a login name and password on the remote host. +.SH ENVIRONMENT +The +.I RCMD_CMD +environment variable can be set to the name or pathname of a program +to use, instead of +.P /usr/bin/rsh , +and must have the same calling conventions as +.IR rsh(1). .SH AUTHORS Jeff Lee (gatech!jeff) wrote the original routines for accessing tape drives via