BSD Networking commands for UNIX PC STARLAN. Part 1 of 3.

Roger Florkowski roger at taliesin.UUCP
Thu Sep 20 15:10:43 AEST 1990


    BSD Style Network Commands for UNIX PC(tm) STARLAN!

    Ever feel frustrated with your UNIX PC/3B1/PC7300 STARLAN setup,  
because all it provided was a faster way to login and faster uucp?  Don't
you feel something was missing since you only could just do uucp and cu
over your STARLAN network?  Well, I did.  So I ported a variety of BSD 
commands,  plus some that I wrote, to UNIX PC STARLAN.  Included herein 
are:

    uucpd	:= uucp login server
    rmtd 	:= remote tape server
    rtape	:= remote tape client
    rshd	:= remote shell server
    remsh	:= remote shell client
    rcp		:= remote copy
    rexecd	:= remote command execution server
    rexec	:= remote command execution client
    librcmd.a	:= STARLAN connection routines, plus rcmd(), rexec().

Roger Florkowski
cs.utexas.edu!taliesin!roger

==
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 3)."
# Contents:  MANIFEST Makefile README lib/Makefile lib/rexec.c
#   man/rcp.1 man/rexecd.8 man/rmt.8 man/rsh.1 rcmds.h rexec.c uucpd.c
# Wrapped by roger at taliesin on Wed Sep 19 23:37:47 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f MANIFEST -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"MANIFEST\"
else
echo shar: Extracting \"MANIFEST\" \(1450 characters\)
sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                  1	This shipping list
X Makefile                  1	Makefile to compile the BSD STARLAN Commands
X README                    1	Describes the Installation, Bugs, and Usage
X lib/Makefile              1	Makefile to compile the BSD STARLAN Command lib
X lib/openslan.c            2	Open up a STARLAN port, establish connection
X lib/rcmd.c                2	Open STARLAN, execute cmds, security checks
X lib/rexec.c               1	Open STARLAN, execute cmds, prompt for user/pswd
X lib/sigport.c             3	Manage signals between remote and local hosts
X man/rcp.1                 1	Manual page for rcp(1)
X man/rexecd.8              1	Manual page for rexecd(8)
X man/rmt.8                 1	Manual page for rmt(8)
X man/rsh.1                 1	Manual page for rsh(1) -- renamed remsh(1)
X man/rshd.8                2	Manual page for rshd(8)
X rcmds.h                   1	rcmds defs, missing ones from system includes
X rcp.c                     3	Remote Copy command
X remsh.c                   2	Remote Shell command
X rexec.c                   1	Remote Shell command, prompting for user/passwd
X rexecd.c                  2	Remote Execution Daemon
X rmtd.c                    2	Remote Tape Daemon
X rshd.c                    2	Remote Shell Daemon
X rtape.c                   3	Remote Tape command
X uucpd.c                   1	Remote UUCP Daemon
END_OF_MANIFEST
if test 1450 -ne `wc -c <MANIFEST`; then
    echo shar: \"MANIFEST\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(2152 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X# $Id: Makefile,v 1.1 90/09/19 23:27:20 roger C_1 $
X#
X# Makefile to compile UnixPC STARLAN BSD Networking utilities.
X# By Roger Florkowski
X# cs.utexas.edu!taliesin!roger
X#
XINCLUDES=-I./
XCFLAGS=-v -O $(INCLUDES)  # -DRMT_DEBUG # -DDO_DEBUG
XLDFLAGS=-s -G -L/usr/lib/net 
XLIBS=-lslan /lib/crt0s.o /lib/shlib.ifile
XDEST=/usr/net
X
XCMDS = uucpd rmtd rtape rshd remsh rcp rexecd rexec
XRLIB = lib/librcmd.a
X
Xall:	$(RLIB) $(CMDS)
Xclean:
X	rm -f *.o $(CMDS)
X	(cd lib; make clean)
X$(RLIB): force
X	(cd lib; make)
Xforce:
X#
Xuucpd:	uucpd.o 
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o uucpd uucpd.o $(LIBS) 
Xrmtd:	rmtd.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rmtd rmtd.o $(LIBS) 
Xrtape:	$(RLIB) rtape.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rtape rtape.o $(RLIB) $(LIBS)
Xrshd:	$(RLIB) rshd.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rshd rshd.o $(RLIB) $(LIBS)
Xremsh:	$(RLIB) remsh.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o remsh remsh.o $(RLIB) $(LIBS)
Xrcp:	$(RLIB) rcp.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rcp rcp.o $(RLIB) $(DLIB) $(LIBS)
Xrexecd:	$(RLIB) rexecd.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rexecd rexecd.o $(RLIB) $(DLIB) $(LIBS)
Xrexec:	$(RLIB) rexec.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o rexec rexec.o $(RLIB) $(DLIB) $(LIBS)
X
Xrmtd.o: rcmds.h
Xrtape.o: rcmds.h
Xrshd.o: rcmds.h
Xremsh.o: rcmds.h
Xrcp.o: rcmds.h
Xrexec.o: rcmds.h
Xrexecd.o: rcmds.h
X
X# you need to be root to do this.
Xinstall: all
X	cp uucpd $(DEST)/servers/.
X	cp rmtd $(DEST)/servers/.
X	cp rtape $(DEST)/bin/.
X	cp rshd $(DEST)/servers/.
X	cp remsh $(DEST)/bin/.
X	cp rcp $(DEST)/bin/.
X	cp rexec $(DEST)/bin/.
X	cp rexecd $(DEST)/servers/.
X	chown root $(DEST)/servers/uucpd $(DEST)/servers/rmtd \
X$(DEST)/bin/rtape $(DEST)/servers/rshd $(DEST)/bin/remsh $(DEST)/bin/rcp \
X$(DEST)/bin/rexec $(DEST)/servers/rexecd
X	chgrp bin $(DEST)/servers/uucpd $(DEST)/servers/rmtd \
X$(DEST)/bin/rtape $(DEST)/servers/rshd $(DEST)/bin/remsh $(DEST)/bin/rcp \
X$(DEST)/bin/rexec $(DEST)/servers/rexecd
X	chmod 511 $(DEST)/servers/rmtd $(DEST)/bin/rtape $(DEST)/bin/remsh \
X$(DEST)/bin/rcp
X	chmod 4511 $(DEST)/servers/uucpd $(DEST)/servers/rshd \
X$(DEST)/bin/rexec $(DEST)/servers/rexecd
X
END_OF_Makefile
if test 2152 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(7408 characters\)
sed "s/^X//" >README <<'END_OF_README'
X
X
X    BSD Style Network Commands for UNIX PC(tm) STARLAN!
X
X    Ever feel frustrated with your UNIX PC/3B1/PC7300 STARLAN setup,  
Xbecause all it provided was a faster way to login and faster uucp?  Don't
Xyou feel something was missing since you only could just do uucp and cu
Xover your STARLAN network?  Well, I did.  So I ported a variety of BSD 
Xcommands,  plus some that I wrote, to UNIX PC STARLAN.  Included herein 
Xare:
X
X    uucpd	:= uucp login server
X    rmtd 	:= remote tape server
X    rtape	:= remote tape client
X    rshd	:= remote shell server
X    remsh	:= remote shell client
X    rcp		:= remote copy
X    rexecd	:= remote command execution server
X    rexec	:= remote command execution client
X    librcmd.a	:= STARLAN connection routines, plus rcmd(), rexec().
X
X==
X
X    This was certainly a learning experience.  Almost to the point
Xof tearing my hair out, as I tried to figure out just what STARLAN
Xwas doing.  I believe I ended up with a fairly reliable set of
Xprograms (see KNOWN BUGS below).  Certainly the most beneficial
X(and also the most reliable) are rcp and rtape.  
X    I am not a man-page writer,  so I just included the BSD man
Xpages,  and wrote README's to fill in the rest.
X
XINSTALLATION:
X    This package will compile as-is, regardless of software set-up
Xon your machine.  The only requirement is that you have the STARLAN
Xsoftware in it's original location, /usr/net.
X    'make install'  will compile all the commands and install them
Xin /usr/net/servers and /usr/net/bin.  The library, librcmd.a, does
Xnot currently get installed.  You must be root to do a 'make install'.
X
XSET-UP:
X    Some programs require a one-time setup.
X
X    starlan.o:
X	    Due to the amount of network traffic that rtape and rcp
X	generate,   it is recommended that you configure your STARLAN
X	for HEAVY usage.  Somewhere in the UA windows there is an
X	option to due that,  or you can just run /usr/net/bin/SConfig.sh
X
X    uucpd:
X	    To register the new uucpd with STARLAN, you can install it with 
X	its own server number, which would require changing Dialers scripts 
X	everywhere, or remove uucplogin and replace it with uucpd (this 
X	is the recommended way).  uucpd is more preferred over uucplogin
X	since it records the proper entries in the /etc/wtmp file.
X
X	To register uucpd as a new server, type:
X
X	nlsadmin -a<server number> -c/usr/net/servers/uucpd -y "UUCP network daemon" starlan
X
X	To replace uucplogin with uucpd, type:
X
X	nlsadmin -r102 starlan
X	nlsadmin -a102 -c/usr/net/servers/uucpd -y "UUCP network daemon" starlan
X
X    rshd:
X	    rshd has it's port number defined in rcmd.h.  I use 202.
X
X	To register rshd as a new server, type:
X
X	nlsadmin -a202 -c/usr/net/servers/rshd -y "Remote Shell Server" starlan
X
X    rexecd:
X	    rexecd has it's port number defined in rcmd.h.  I use 203.
X
X	To register rexecd as a new server, type:
X
X	nlsadmin -a203 -c/usr/net/servers/rexecd -y "Remote Exec Server" starlan
X
X
X    remsh (renamed from rsh, since it conflicts with the restricted
X    Bourne Shell by the same name) also requires some further set-up for 
X    security authentification.  There are two ways to do this,  and 
X    depending on your set-up and needs, you may use a combination of the 
X    two.  The two set-up files are /etc/hosts.equiv, and $HOME/.rhosts.  
X    To explain how these files work,  I'll explain how the user 
X    authentification is done.
X
X    Lets say you are localUser on machineA, and want to issue a simple 
X    command, like:
X
X    remsh machineB -l remoteUser ls -FC
X
X    This will execute 'ls -FC' as if 'remoteUser' were logged in
X    on machineB.
X
X    Authentification:
X	-) does 'remoteUser' have a password?  
X		If not, execute the command.  Done.
X
X	-) if 'remoteUser' is identical to 'localUser', check
X		/etc/hosts.equiv for a line containing 'machineA'.
X		If found, execute the command.  Done.
X		/etc/hosts.equiv is a file contain a list of 
X		"equivalent hosts", one hostname per line, 
X		such that if you are a user on machineA,  then 
X		you can execute a command on machineB as the 
X		same user name.
X
X	-) if 'remoteUser' differs from 'localUser',  or we did
X		not have an entry in hosts.equiv,  check $HOME/.rhosts
X		in remoteUser's home on machineB.  .rhosts is
X		a list of hostname_user pairs, specifying that
X		user, initiating a command from hostname, is allowed
X		to execute a remote command.  So, in our example,
X		we would need an entry in $HOME/.rhosts like:
X
X		machineA	localUser
X
X		NOTE:  remote "root" requests *never* check hosts.equiv.
X			$HOME/.rhosts *must* be own by the user who's
X			home directory it resides in,  and must not
X			be writable by group or other, or it is ignored.
X
X
XCOMMAND USAGE:
X    All commands provide usage statements with <command> -?.
XHere are some quick hints:
X
X    rcp:  to copy files from machineA to machineB: (a verbose flag -v
X	  has also been added)
X	
X	rcp files machineB:/<destination>
X	rcp files remoteUser at machineB:/<destination>
X	rcp -r <source directory> remoteUser at machineB:/<destination>
X
X    rtape: backup machineA onto a tape drive that resides on machineB:
X
X	find <files> -print | cpio -ocvT124 | rtape -oT124 -d /dev/rft3 machineB
X
X	   restore files from tape drive on machineB:
X
X	rtape -iT124 -d /dev/rft3 machineB | cpio -icvT124
X
X	NOTE: rtape *does* support multiple tapes.  It will prompt
X	    you for the tape change.
X
X    remsh: execute some commands on machineB
X
X	remsh machineB tail -f somefile
X	remsh machineB ls -FC
X
X    rexec:
X	rexec is exactly like remsh, except that it prompts you
X	for the remote-user and remote-passwd every time.  It does
X	not check /etc/hosts.equiv or $HOME/.rhosts
X
X
XKNOWN BUGS:
X
X    -) STARLAN in datagram mode does not seem to work.
X
X    -) remsh/rshd are NOT for use with interactive programs.
X	This wouldn't be such a problem if STARLAN were a little
X	more reliable.  I experienced a lot of data lossage
X	with remsh.  To cut down on lost output,  I decided to
X	run the line in CHARACTER-ORIENTED urp-mode (see
X	/usr/net/tli/t_config).  This cut to zero the amount
X	of data-lossage on output,  but broke commands that
X	read from stdin.  This is probably due to the fact
X	that the remote is still in BLOCK-MODE from the listener.'
X	An example of a command that does not work:
X
X	cat somefile | remsh machineB od -c
X
X	This should cat "somefile" on the local machine, pipe it
X	to remsh, which then directs the stream to "od -c" on the
X	remote machine,  with the output from the remote returning
X	back to the local machine.
X
X    -) closing STARLAN file descriptors is a very bad thing to do.
X	I found it impossible to close a STARLAN file descriptor,
X	then dup it onto another descriptor.  The communications
X	link got messed up every time.
X
X    -) not a bug... but... rtape to a floppy does not write out
X	the magic Volume Number in the floppy VHB.  So a plain
X	"cpio" check of the floppy set will fail.
X
X
XCLOSING:
X
X    I would like to personally thank Lenny Tropiano for helping with
Xthe testing on these commands.  He also provided me with some good
Xideas which I incorporated into the package.
X
X    If anyone has any bug fixes for these programs,  please swing
Xthem by me before you post.  I spent a lot of time on these programs,
Xand would like to maintain an up-to-date copy.  Also if someone out
Xthere knows more about the UNIX PC STARLAN and cares to share his/her
Xknowledge about it, please email me as well.
X
XRoger Florkowski
Xcs.utexas.edu!taliesin!roger
X
X
END_OF_README
if test 7408 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f lib/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"lib/Makefile\"
else
echo shar: Extracting \"lib/Makefile\" \(537 characters\)
sed "s/^X//" >lib/Makefile <<'END_OF_lib/Makefile'
X# $Id: Makefile,v 1.1 90/09/19 23:24:58 roger C_1 $
X#
X# Makefile to compile UnixPC STARLAN BSD Networking utilities.
X# By Roger Florkowski
X# cs.utexas.edu!taliesin!roger
X#
XINCLUDES=-I../
XCFLAGS=-v -O $(INCLUDES)  # -DRMT_DEBUG -DDO_DEBUG
X
XRLIB = librcmd.a
X
Xall:	$(RLIB)
Xclean:
X	rm -f *.o $(RLIB)
X
XRLIBOBJ = \
X	rcmd.o\
X	rexec.o\
X	openslan.o\
X	sigport.o
X#
X$(RLIB): $(RLIBOBJ)
X	rm -f $(RLIB)
X	ar cr $(RLIB) `lorder $(RLIBOBJ) | tsort`
X
Xrcmd.o: ../rcmds.h
Xrexec.o: ../rcmds.h
Xopenslan.o: ../rcmds.h
Xsigport.o: ../rcmds.h
Xrexec.o: ../rcmds.h
END_OF_lib/Makefile
if test 537 -ne `wc -c <lib/Makefile`; then
    echo shar: \"lib/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f lib/rexec.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"lib/rexec.c\"
else
echo shar: Extracting \"lib/rexec.c\" \(3398 characters\)
sed "s/^X//" >lib/rexec.c <<'END_OF_lib/rexec.c'
X/* $Id: rexec.c,v 1.1 90/09/19 23:25:00 roger C_1 $
X *
X *	rexec.c: open a communications channel and execute
X *		a remote command.
X *
X *	Roger Florkowski
X *	cs.utexas.edu!taliesin!roger
X */
X
X/*
X * Copyright (c) 1980 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)rexec.c	5.7 (Berkeley) 1/4/89";
X#endif /* LIBC_SCCS and not lint */
X
X#include <net/sys/tiuser.h>
X#include <sys/types.h>
X
X#include <stdio.h>
X#include <errno.h>
X#include "rcmds.h"
X
Xextern	errno;
Xchar	*getpass(), *getlogin();
X
Xextern	int _protocol;
X
Xrexec(ahost, rport, name, pass, cmd, fd2p)
Xchar *ahost;
Xint rport;
Xchar *name, *pass, *cmd;
Xint *fd2p;
X{
X    int s, s2, rcvflags;
X    char c, locuser[80];
X
X    /* nls routines use the passwd routines, which messes up pw->pw_name */
X    strncpy (locuser, name, sizeof (locuser));
X
X    /* connect to service rport on ahost */
X    fprintf (stderr, "Trying %s...", ahost);
X    if ((s = connect_to (ahost, rport, _protocol ? _protocol : T_COTS)) < 0) {
X	fprintf (stderr, "Connection Failed (%s not listening?)\n", ahost);
X	return (s);
X    }
X    DEBUG1("connected to %s\n", ahost);
X
X    /* client might want the server to fire up a signal monitor */
X    if (fd2p) { 
X	DEBUG("trying to connect to signal port\n");
X	(void) t_snd (s, "\1", 1, NULL);
X	if ((s2 = rsignalPort (s)) < 0) {
X	    fprintf (stderr, "Can't establish signal port\n");
X	    DEBUG("signal port connection failed\n");
X	    disconnect (s);
X	    exit (1);
X	}
X	*fd2p = s2;
X    }
X    else 
X	(void) t_snd (s, "\0", 1, NULL);
X
X    /* tell remote who we are, user info, and command */
X    (void) t_snd(s, locuser, strlen(locuser)+1, NULL);
X
X    /* should public key encypt the password here */
X    (void) t_snd(s, pass, strlen(pass)+1, NULL);
X    (void) t_snd(s, cmd, strlen(cmd)+1, NULL);
X    DEBUG2("user: %s\npass: %s\n", 
X	    locuser, pass);
X    DEBUG1("cmd: %s\n", cmd);
X
X    /* read a single NULL char as an ack */
X    if (t_rcv (s, &c, 1, &rcvflags) != 1) {
X	perror (ahost);
X	goto bad;
X    }
X    /* oops, not an ack.  Read in error message from remote */
X    if (c != 0) {
X	while (t_rcv(s, &c, 1, &rcvflags) == 1) {
X	    (void) write(2, &c, 1);
X	    if (c == '\n')
X		break;
X	}
X	goto bad;
X    }
X    fprintf (stderr, "Connected\n");
X    return (s);
Xbad:
X    (void) disconnect (s);
X    return (-1);
X}
X
Xruserpass(host, name, pass)
Xchar *host, *name, *pass;
X{
X    char buf[512], *npass;
X
X    printf ("Name (%s:%s): ", host, name);
X    if (gets(buf) != NULL && strlen(buf))
X	strcpy (name, buf);
X    sprintf (buf, "Password (%s:%s): ", host, name);
X    if ((npass = getpass(buf)) != NULL)
X	strcpy (pass, npass);
X}
END_OF_lib/rexec.c
if test 3398 -ne `wc -c <lib/rexec.c`; then
    echo shar: \"lib/rexec.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/rcp.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/rcp.1\"
else
echo shar: Extracting \"man/rcp.1\" \(2836 characters\)
sed "s/^X//" >man/rcp.1 <<'END_OF_man/rcp.1'
X.\" Copyright (c) 1983 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)rcp.1	6.6 (Berkeley) 9/20/88
X.\"
X.TH RCP 1 "September 20, 1988"
X.UC 5
X.SH NAME
Xrcp \- remote file copy
X.SH SYNOPSIS
X.B rcp
X[
X.B \-p
X] file1 file2
X.br
X.B rcp
X[
X.B \-p
X] [
X.B \-r
X] file ... directory
X.SH DESCRIPTION
X.I Rcp
Xcopies files between machines.  Each
X.I file
Xor
X.I directory
Xargument is either a remote file name of the
Xform ``rhost:path'', or a local file name (containing no `:' characters,
Xor a `/' before any `:'s).
X.PP
XIf the
X.B \-r
Xoption
Xis specified and any of the source files are directories,
X.I rcp
Xcopies each subtree rooted at that name; in this case
Xthe destination must be a directory.
X.PP
XBy default, the mode and owner of
X.I file2
Xare preserved if it already existed; otherwise the mode of the source file
Xmodified by the
X.IR umask (2)
Xon the destination host is used.
XThe
X.B \-p
Xoption causes
X.I rcp
Xto attempt to preserve (duplicate) in its copies the modification
Xtimes and modes of the source files, ignoring the
X.IR umask .
X.PP
XIf
X.I path
Xis not a full path name, it is interpreted relative to
Xyour login directory on 
X.IR rhost .
XA 
X.I path
Xon a remote host may be quoted (using \e, ", or \(aa)
Xso that the metacharacters are interpreted remotely.
X.PP
X.I Rcp
Xdoes not prompt for passwords; your current local user name
Xmust exist on
X.I rhost
Xand allow remote command execution via
X.IR rsh (1).
X.PP
X.I Rcp
Xhandles third party copies, where neither source nor target files
Xare on the current machine.
XHostnames may also take the form ``rname at rhost'' to use
X.I rname
Xrather than the current user name on the remote host.
X.SH SEE ALSO
Xcp(1), ftp(1), rsh(1), rlogin(1)
X.SH BUGS
XDoesn't detect all cases where the target of a copy might
Xbe a file in cases where only a directory should be legal.
X.PP
XIs confused by any output generated by commands in a
X\&.login, \&.profile, or \&.cshrc file on the remote host.
X.PP
XThe destination user and hostname may have to be specified as
X``rhost.rname'' when the destination machine is running the 4.2BSD
Xversion of \fIrcp\fP.
X
END_OF_man/rcp.1
if test 2836 -ne `wc -c <man/rcp.1`; then
    echo shar: \"man/rcp.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/rexecd.8 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/rexecd.8\"
else
echo shar: Extracting \"man/rexecd.8\" \(3998 characters\)
sed "s/^X//" >man/rexecd.8 <<'END_OF_man/rexecd.8'
X.\" Copyright (c) 1983 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)rexecd.8	6.3 (Berkeley) 9/27/88
X.\"
X.TH REXECD 8 "September 27, 1988"
X.UC 5
X.SH NAME
Xrexecd \- remote execution server
X.SH SYNOPSIS
X.B /etc/rexecd
X.SH DESCRIPTION
X.I Rexecd
Xis the server for the 
X.IR rexec (3)
Xroutine.  The server provides remote execution facilities
Xwith authentication based on user names and
Xpasswords.
X.PP
X.I Rexecd
Xlistens for service requests at the port indicated in
Xthe ``exec'' service specification; see
X.IR services (5).
XWhen a service request is received the following protocol
Xis initiated:
X.IP 1)
XThe server reads characters from the socket up
Xto a null (`\e0') byte.  The resultant string is
Xinterpreted as an ASCII number, base 10.
X.IP 2)
XIf the number received in step 1 is non-zero,
Xit is interpreted as the port number of a secondary
Xstream to be used for the 
X.BR stderr .
XA second connection is then created to the specified
Xport on the client's machine.
X.IP 3)
XA null terminated user name of at most 16 characters
Xis retrieved on the initial socket.
X.IP 4)
XA null terminated, unencrypted password of at most
X16 characters is retrieved on the initial socket.  
X.IP 5)
XA null terminated command to be passed to a
Xshell is retrieved on the initial socket.  The length of
Xthe command is limited by the upper bound on the size of
Xthe system's argument list.  
X.IP 6)
X.I Rexecd
Xthen validates the user as is done at login time
Xand, if the authentication was successful, changes
Xto the user's home directory, and establishes the user
Xand group protections of the user.
XIf any of these steps fail the connection is
Xaborted with a diagnostic message returned.
X.IP 7)
XA null byte is returned on the initial socket
Xand the command line is passed to the normal login
Xshell of the user.  The
Xshell inherits the network connections established
Xby
X.IR rexecd .
X.SH DIAGNOSTICS
XExcept for the last one listed below,
Xall diagnostic messages are returned on the initial socket,
Xafter which any network connections are closed.
XAn error is indicated by a leading byte with a value of
X1 (0 is returned in step 7 above upon successful completion
Xof all the steps prior to the command execution).
X.PP
X.B ``username too long''
X.br
XThe name is
Xlonger than 16 characters.
X.PP
X.B ``password too long''
X.br
XThe password is longer than 16 characters.
X.PP
X.B ``command too long ''
X.br
XThe command line passed exceeds the size of the argument
Xlist (as configured into the system).
X.PP
X.B ``Login incorrect.''
X.br
XNo password file entry for the user name existed.
X.PP
X.B ``Password incorrect.''
X.br
XThe wrong was password supplied.
X.PP
X.B ``No remote directory.''
X.br
XThe 
X.I chdir
Xcommand to the home directory failed.
X.PP
X.B ``Try again.''
X.br
XA
X.I fork
Xby the server failed.
X.PP
X.B ``<shellname>: ...''
X.br
XThe user's login shell could not be started.
XThis message is returned
Xon the connection associated with the
X.BR stderr ,
Xand is not preceded by a flag byte.
X.SH SEE ALSO
Xrexec(3)
X.SH BUGS
XIndicating ``Login incorrect'' as opposed to ``Password incorrect''
Xis a security breach which allows people to probe a system for users
Xwith null passwords.
X.PP
XA facility to allow all data and password exchanges to be encrypted should be
Xpresent.
END_OF_man/rexecd.8
if test 3998 -ne `wc -c <man/rexecd.8`; then
    echo shar: \"man/rexecd.8\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/rmt.8 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/rmt.8\"
else
echo shar: Extracting \"man/rmt.8\" \(3965 characters\)
sed "s/^X//" >man/rmt.8 <<'END_OF_man/rmt.8'
X.\" Copyright (c) 1983 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)rmt.8	6.2 (Berkeley) 9/19/88
X.\"
X.TH RMT 8 "September 19, 1988"
X.UC 5
X.SH NAME
Xrmt \- remote magtape protocol module
X.SH SYNOPSIS
X.B /etc/rmt
X.SH DESCRIPTION
X.I Rmt
Xis a program used by the remote dump and restore programs
Xin manipulating a magnetic tape drive through an interprocess
Xcommunication connection.
X.I Rmt
Xis normally started up with an
X.IR rexec (3X)
Xor
X.IR rcmd (3X)
Xcall.
X.PP
XThe 
X.I rmt
Xprogram accepts requests specific to the manipulation of
Xmagnetic tapes, performs the commands, then responds with
Xa status indication.  All responses are in ASCII and in
Xone of two forms. 
XSuccessful commands have responses of
X.PP
X.ti +0.5i
X\fBA\fInumber\fR\en
X.PP
Xwhere 
X.I number
Xis an ASCII representation of a decimal number.
XUnsuccessful commands are responded to with
X.PP
X.ti +0.5i
X\fBE\fIerror-number\fR\en\fIerror-message\fR\en,
X.PP
Xwhere
X.I error-number
Xis one of the possible error
Xnumbers described in
X.IR intro (2)
Xand
X.I error-message
Xis the corresponding error string as printed
Xfrom a call to
X.IR perror (3).
XThe protocol is comprised of the
Xfollowing commands (a space is present between each token).
X.TP 15
X.B O device mode
XOpen the specified 
X.I device
Xusing the indicated
X.IR mode .
X.I Device
Xis a full pathname and
X.I mode
Xis an ASCII representation of a decimal
Xnumber suitable for passing to
X.IR open (2).
XIf a device had already been opened, it is
Xclosed before a new open is performed.
X.TP 15
X.B C device
XClose the currently open device.  The
X.I device
Xspecified is ignored.
X.TP 15
X.B L whence offset
XPerform an
X.IR lseek (2)
Xoperation using the specified parameters.
XThe response value is that returned from the
X.I lseek
Xcall.
X.TP 15
X.B W count
XWrite data onto the open device.
X.I Rmt
Xreads
X.I count
Xbytes from the connection, aborting if
Xa premature end-of-file is encountered.
XThe response value is that returned from
Xthe
X.IR write (2)
Xcall.
X.TP 15
X.B R count
XRead
X.I count
Xbytes of data from the open device.
XIf
X.I count
Xexceeds the size of the data buffer (10 kilobytes), it is
Xtruncated to the data buffer size.
X.I Rmt
Xthen performs the requested 
X.IR read (2)
Xand responds with 
X\fBA\fIcount-read\fR\en if the read was
Xsuccessful; otherwise an error in the
Xstandard format is returned.  If the read
Xwas successful, the data read is then sent.
X.TP 15
X.B I operation count 
XPerform a MTIOCOP 
X.IR ioctl (2)
Xcommand using the specified parameters.
XThe parameters are interpreted as the
XASCII representations of the decimal values
Xto place in the 
X.I mt_op
Xand
X.I mt_count
Xfields of the structure used in the
X.I ioctl
Xcall.  The return value is the
X.I count
Xparameter when the operation is successful.
X.TP 15
X.B S
XReturn the status of the open device, as
Xobtained with a MTIOCGET 
X.I ioctl
Xcall.  If the operation was successful,
Xan ``ack'' is sent with the size of the
Xstatus buffer, then the status buffer is
Xsent (in binary).
X.PP
XAny other command causes 
X.I rmt
Xto exit.
X.SH DIAGNOSTICS
XAll responses are of the form described above.
X.SH "SEE ALSO"
Xrcmd(3), rexec(3), mtio(4), rdump(8), rrestore(8)
X.SH BUGS
XPeople tempted to use this for a remote file access protocol
Xare discouraged.
END_OF_man/rmt.8
if test 3965 -ne `wc -c <man/rmt.8`; then
    echo shar: \"man/rmt.8\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f man/rsh.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"man/rsh.1\"
else
echo shar: Extracting \"man/rsh.1\" \(3287 characters\)
sed "s/^X//" >man/rsh.1 <<'END_OF_man/rsh.1'
X.\" Copyright (c) 1983 The Regents of the University of California.
X.\" All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms are permitted
X.\" provided that the above copyright notice and this paragraph are
X.\" duplicated in all such forms and that any documentation,
X.\" advertising materials, and other materials related to such
X.\" distribution and use acknowledge that the software was developed
X.\" by the University of California, Berkeley.  The name of the
X.\" University may not be used to endorse or promote products derived
X.\" from this software without specific prior written permission.
X.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X.\"
X.\"	@(#)rsh.1	6.2 (Berkeley) 9/20/88
X.\"
X.TH RSH 1 "September 20, 1988"
X.UC 5
X.SH NAME
Xrsh \- remote shell
X.SH SYNOPSIS
X.B rsh
Xhost
X[
X.B \-l
Xusername
X] [
X.B \-n
X] command
X.br
Xhost
X[
X.B \-l
Xusername
X] [
X.B \-n
X] command
X.SH DESCRIPTION
X.I Rsh
Xconnects to the specified
X.I host,
Xand executes the specified \fIcommand\fR.
X.I Rsh
Xcopies its standard input to the remote command, the standard
Xoutput of the remote command to its standard output, and the
Xstandard error of the remote command to its standard error.
XInterrupt, quit and terminate signals are propagated to the remote
Xcommand; \fIrsh\fP normally terminates when the remote command does.
X.PP
XThe remote username used is the same as your local username,
Xunless you specify a different remote name with the
X.B \-l
Xoption.
XThis remote name must be equivalent (in the sense of
X.IR rlogin (1C))
Xto the originating account; no provision
Xis made for specifying a password with a command.
X.PP
XIf you omit
X.I command,
Xthen instead of executing a single command, you will be logged in
Xon the remote host using
X.IR rlogin (1C).
X.PP
XShell metacharacters which are not quoted are interpreted
Xon local machine, while quoted metacharacters are interpreted on
Xthe remote machine.
XThus the command
X.PP
X\ \ \ rsh otherhost cat remotefile >> localfile
X.PP
Xappends the remote file
X.I remotefile
Xto the localfile
X.I localfile,
Xwhile
X.PP
X\ \ \ rsh otherhost cat remotefile ">>" otherremotefile
X.PP
Xappends
X.I remotefile
Xto
X.I otherremotefile.
X.PP
XHost names are given in the file /etc/hosts.  Each host
Xhas one standard name (the first name given in the file), which
Xis rather long and unambiguous, and optionally one or more nicknames.
XThe host names for local machines are also commands in the directory
X/usr/hosts; if you put this directory in your search path
Xthen the
X.B rsh
Xcan be omitted.
X.SH FILES
X.ta 2i
X/etc/hosts
X.br
X/usr/hosts/*
X.DT
X.SH SEE ALSO
Xrlogin(1)
X.SH BUGS
XIf you are using
X.IR csh (1)
Xand put a
X.IR rsh (1)
Xin the background without redirecting its input
Xaway from the terminal, it will block even if no reads
Xare posted by the remote command.  If no input is desired
Xyou should redirect the input of
X.I rsh
Xto /dev/null using the
X.B \-n
Xoption.
X.PP
XYou cannot run an interactive command
X(like
X.IR rogue (6)
Xor
X.IR vi (1));
Xuse
X.IR rlogin (1).
X.PP
XStop signals stop the local \fIrsh\fP process only; this is arguably
Xwrong, but currently hard to fix for reasons too complicated to
Xexplain here.
END_OF_man/rsh.1
if test 3287 -ne `wc -c <man/rsh.1`; then
    echo shar: \"man/rsh.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f rcmds.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"rcmds.h\"
else
echo shar: Extracting \"rcmds.h\" \(1119 characters\)
sed "s/^X//" >rcmds.h <<'END_OF_rcmds.h'
X/* $Id: rcmds.h,v 1.1 90/09/19 23:27:22 roger C_1 $
X *
X *	rcmds.h: some generic includes.
X *	Roger Florkowski
X *	cs.utexas.edu!taliesin!roger
X */
X
X/* 
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X/* missing from tiuser.h */
X#define T_CCOTS	04	/* connection orientated, character mode */
X
X/* missing from listen.h */
X#define nls_v2p_msg "NLPS:002:002:%d"
X
X/* port numbers for various servers */
X#define	RMTD_PORT	201		/* not used anymore */
X#define	RSHD_PORT	202
X#define	REXECD_PORT	203
X
X/* debug info */
X#if	defined(DO_DEBUG) || defined(RMT_DEBUG)
Xextern FILE *debug;
X#define DFLUSH()	if (debug) fflush(debug)
X#define	DEBUG(f)	if (debug) fprintf(debug, f)
X#define	DEBUG1(f,a)	if (debug) fprintf(debug, f, a)
X#define	DEBUG2(f,a1,a2)	if (debug) fprintf(debug, f, a1, a2)
X#define	DEBUG3(f,a1,a2,a3)	if (debug) fprintf(debug, f, a1, a2, a3)
X#else
X#define DFLUSH()
X#define	DEBUG(f)
X#define	DEBUG1(f,a)	
X#define	DEBUG2(f,a1,a2)
X#define	DEBUG3(f,a1,a2,a3)
X#endif
END_OF_rcmds.h
if test 1119 -ne `wc -c <rcmds.h`; then
    echo shar: \"rcmds.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f rexec.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"rexec.c\"
else
echo shar: Extracting \"rexec.c\" \(4873 characters\)
sed "s/^X//" >rexec.c <<'END_OF_rexec.c'
X/* $Id: rexec.c,v 1.1 90/09/19 23:27:24 roger C_1 $
X *
X *	rexec.   This is BSD's rsh, renamed to rexec, and
X *	modified to my memory of the real rexec.  Why is
X *	rexec missing from bsd's sources?   Missing from the 
X *	real rexec is an option to lookup user/passwd in 
X *	$HOME/.netrc   I did not add that in here.
X *
X *	Roger Florkowski
X *	cs.utexas.edu!taliesin!roger
X */
X
X/*
X * Copyright (c) 1983 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)rsh.c	5.7 (Berkeley) 9/20/88";
X#endif /* not lint */
X
X#include <net/sys/poll.h>
X#include <net/sys/tiuser.h>
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <sys/file.h>
X#include <fcntl.h>
X
X#include <stdio.h>
X#include <errno.h>
X#include <signal.h>
X#include <pwd.h>
X#include "rcmds.h"
X
X/*
X * rexec - remote execute 
X */
X/* VARARGS */
Xint	error();
Xchar	*malloc(), *strcpy(), *strrchr();
X
Xstruct	passwd *getpwuid();
X
Xextern errno, t_errno;
Xextern int	_protocol;	/* in rcmd.c */
Xint	rem, rfd2;
Xint	nflag;
Xint	sendsig();
X
X#define PROGNAME "rexec"
XFILE *debug;
X
Xmain(argc, argv0)
X	int argc;
X	char **argv0;
X{
X	int pid;
X	char *host, *cp, **ap, buf[BUFSIZ], *args, **argv = argv0, name[512];
X	register int cc;
X	struct passwd *pwd;
X	int readfrom;
X
X	if (argc < 2)
X	    goto usage;
X
X	argv++, --argc;
X	host = *argv++, --argc;
X
X	if (argv[0] == 0) 
X		exit(1);
X
X#ifdef DO_DEBUG
X	debug = fopen("/tmp/rexec.out", "a");
X	if (debug == 0)
X	    exit(1);
X	(void) setbuf(debug, (char *)0);
X	DEBUG1("rexec [%d] started\n", getpid());
X#endif
X	pwd = getpwuid(getuid());
X
X	if (pwd == 0) {
X		fprintf(stderr, "who are you?\n");
X		exit(1);
X	}
X	cc = 0;
X	for (ap = argv; *ap; ap++)
X		cc += strlen(*ap) + 1;
X	cp = args = malloc(cc);
X	for (ap = argv; *ap; ap++) {
X		(void) strcpy(cp, *ap);
X		while (*cp)
X			cp++;
X		if (ap[1])
X			*cp++ = ' ';
X	}
X
X	strcpy (name, pwd->pw_name);
X	*buf = '\0';
X	ruserpass (host, name, buf);
X	_protocol = T_CCOTS;	/* connection-orientated, character mode */
X        rem = rexec(host, REXECD_PORT, name, buf, args, &rfd2);
X        if (rem < 0)
X                exit(1);
X
X	(void) setuid(getuid());
X	signal(SIGINT, sendsig);
X	signal(SIGQUIT, sendsig);
X	signal(SIGTERM, sendsig);
X	if (nflag == 0) {
X		pid = fork();
X		if (pid < 0) {
X			perror("fork");
X			exit(1);
X		}
X	}
X
X	/* child, and we are running a command */
X	/* child reads from stdin, writes to remote */
X        if (nflag == 0 && pid == 0) {
X		char *bp; int wc, wflags;
X	reread:
X		errno = 0;
X		wflags = 0;
X		cc = read(0, buf, sizeof buf);
X		if (cc <= 0) {
X		    DEBUG("child: stdin closed, ending\n");
X		    goto done;
X		}
X		bp = buf;
X	rewrite:
X		/* can't poll for output on unixpc :-( */
X		errno = 0;
X		t_errno = 0;
X		wc = t_snd (rem, bp, cc, wflags);
X		if (wc < 0) {
X
X		    /* check for a stream that can't accept any data */
X		    DEBUG2("child: t_snd failed, errno %d, t_errno %d\n",
X				errno, t_errno);
X		    if (t_errno == TFLOW)
X			goto rewrite;
X		    goto done;
X		}
X		cc -= wc; bp += wc;
X		if (cc == 0)
X			goto reread;
X		wflags = T_MORE;
X		goto rewrite;
X	done:
X		(void) disconnect (rem);
X		(void) disconnect (rfd2);
X		exit (0);
X	}
X
X	/* parent.  reads from remote for input, and writes to stdout */
X	readfrom = 1;
X	do {
X	    int rcvflags;
X
X	    errno = 0;
X	    t_errno = 0;
X	    rcvflags = 0;
X
X	    cc = t_rcv (rem, buf, sizeof (buf), &rcvflags);
X	    if (cc <= 0) {
X		DEBUG2("parent: t_rcv failed, errno %d, t_errno %d\n",
X			    errno, t_errno);
X		if (t_errno != TNODATA || cc == 0) 
X		    readfrom = 0;
X	    } else
X		(void) write(1, buf, cc);
X	    if (rcvflags & T_MORE) 
X		continue;
X        } while (readfrom);
X
X	(void) disconnect (rem);
X	(void) disconnect (rfd2);
X	if (nflag == 0)
X	    (void) kill(pid, SIGKILL);
X	exit(0);
Xusage:
X	fprintf(stderr,
X	    "usage: rexec host command\n");
X	exit(1);
X}
X
Xsendsig(signo)
X	char signo;
X{
X    DEBUG1("sending sig %d\n", signo);
X    t_snd (rfd2, &signo, 1, NULL);
X    t_snd (rfd2, &signo, 1, NULL);
X    (void) disconnect (rem);
X    (void) disconnect (rfd2);
X    exit (0);
X}
END_OF_rexec.c
if test 4873 -ne `wc -c <rexec.c`; then
    echo shar: \"rexec.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f uucpd.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"uucpd.c\"
else
echo shar: Extracting \"uucpd.c\" \(4404 characters\)
sed "s/^X//" >uucpd.c <<'END_OF_uucpd.c'
X/* $Id: uucpd.c,v 1.1 90/09/19 23:27:29 roger C_1 $
X *
X *	This is a UnixPC STARLAN port of BSD's uucpd.
X *	Roger Florkowski
X *	cs.utexas.edu!taliesin!roger
X */
X
X/*
X * Copyright (c) 1985 The Regents of the University of California.
X * All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Rick Adams.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X#ifndef lint
Xchar copyright[] =
X"@(#) Copyright (c) 1985 The Regents of the University of California.\n\
X All rights reserved.\n";
X#endif /* not lint */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)uucpd.c	5.6 (Berkeley) 10/24/88";
X#endif /* not lint */
X
X/*
X * 4.2BSD TCP/IP server for uucico
X * uucico's TCP channel causes this server to be run at the remote end.
X */
X
X#include <net/sys/tiuser.h>
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/wait.h>
X#include <pwd.h>
X
X#define UUCICO "/usr/lib/uucp/uucico"
X
Xchar Username[64];
Xchar *nenv[] = {
X    Username,
X    NULL,
X};
Xextern char **environ;
Xextern int errno;
X
Xint childpid;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X    /* sync up starlan communications */
X    if (t_sync(0) != T_DATAXFER) {
X	t_error("t_sync returned wrong state");
X	exit(1);
X    }
X    environ = nenv;
X
X    if ((childpid = fork ()) == 0) {
X	doit ();
X	exit (1);
X    }
X    dologout ();
X    exit (0);
X}
X
Xdoit()
X{
X    char user[64], passwd[64];
X    char *xpasswd, *crypt();
X    struct passwd *pw, *getpwnam();
X
X    alarm (60);
X    printf ("login: "); fflush (stdout);
X    if (readline (user, sizeof (user)) < 0) {
X	fprintf (stderr, "user read\n");
X	return;
X    }
X    /* truncate username to 8 characters */
X    user[8] = '\0';
X    pw = getpwnam (user);
X    if (pw == NULL) {
X	fprintf (stderr, "user unknown\n");
X	return;
X    }
X    if (strcmp (pw->pw_shell, UUCICO)) {
X	fprintf (stderr, "Login incorrect.\n");
X	return;
X    }
X    if (pw->pw_passwd && *pw->pw_passwd != '\0') {
X	printf ("Password: "); fflush (stdout);
X	if (readline (passwd, sizeof (passwd)) < 0) {
X	    fprintf (stderr, "passwd read\n");
X	    return;
X	}
X	xpasswd = crypt (passwd, pw->pw_passwd);
X	if (strcmp (xpasswd, pw->pw_passwd)) {
X	    fprintf (stderr, "Login incorrect.\n");
X	    return;
X	}
X    }
X    alarm (0);
X    sprintf (Username, "LOGNAME=%s", user);
X    dologin (pw);
X    setgid (pw->pw_gid);
X    chdir (pw->pw_dir);
X    setuid (pw->pw_uid);
X    execl (UUCICO, "uucico", (char *)0);
X    perror ("uucico server: execl");
X}
X
Xreadline (p, n)
Xregister char *p;
Xregister int n;
X{
X    char c;
X
X    while (n-- > 0) {
X	if (read (0, &c, 1) <=0) 
X	    return (-1);
X	c &= 0177;
X	if (c == '\n' || c == '\r') {
X	    *p = '\0';
X	    return (0);
X	}
X	*p++ = c;
X    }
X    return (-1);
X}
X
X#include <utmp.h>
X#include <fcntl.h>
X
X#define SCPYN(a, b)	strncpy (a, b, sizeof (a));
X
Xstruct utmp utmp;
X
Xdologout ()
X{
X    union wait status;
X    int pid, wtmp;
X
X    while ((pid = wait (&status)) > 0) {
X
X	wtmp = open (WTMP_FILE, O_WRONLY|O_APPEND);
X	if (wtmp >= 0) {
X	    sprintf (utmp.ut_line, "uucp(%.5d)", pid);
X	    SCPYN (utmp.ut_name, "");
X	    utmp.ut_type = DEAD_PROCESS;
X	    utmp.ut_pid = childpid;
X	    (void) time (&utmp.ut_time);
X	    (void) write (wtmp, (char *)&utmp, sizeof (utmp));
X	    (void) close (wtmp);
X	}
X    }
X}
X
Xdologin(pw)
Xstruct passwd *pw;
X{
X    char line[12];
X    int wtmp;
X
X    /* getut() routines will fail on /etc/utmp, due to changing line */
X    wtmp = open (WTMP_FILE, O_WRONLY|O_APPEND);
X    if (wtmp >= 0) {
X	/* hack, but must be unique and no tty line */
X	sprintf (line, "uucp(%.5d)", getpid());
X	SCPYN (utmp.ut_line, line);
X	SCPYN (utmp.ut_name, pw->pw_name);
X	utmp.ut_type = USER_PROCESS;
X	utmp.ut_pid = getpid();
X	time (&utmp.ut_time);
X	(void) write (wtmp, (char *)&utmp, sizeof (utmp));
X	(void) close (wtmp);
X    }
X}
END_OF_uucpd.c
if test 4404 -ne `wc -c <uucpd.c`; then
    echo shar: \"uucpd.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

-- 
Roger Florkowski                                 ~!cs.utexas.edu!taliesin!roger



More information about the Comp.sys.att mailing list