bug fixes & changes from Rick Adams
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Wed, 23 Jan 1985 04:29:00 +0000 (20:29 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Wed, 23 Jan 1985 04:29:00 +0000 (20:29 -0800)
SCCS-vsn: usr.bin/uucp/Makefile 5.7
SCCS-vsn: usr.bin/uucp/DOC/README 5.3
SCCS-vsn: usr.bin/uucp/libuu/anlwrk.c 5.3
SCCS-vsn: usr.bin/uucp/libuu/anyread.c 5.2
SCCS-vsn: usr.bin/uucp/assert.c 5.3
SCCS-vsn: usr.bin/uucp/libuu/cfgets.c 5.2
SCCS-vsn: usr.bin/uucp/libuu/chkpth.c 5.2
SCCS-vsn: usr.bin/uucp/uucico/cico.c 5.5

usr/src/usr.bin/uucp/DOC/README
usr/src/usr.bin/uucp/Makefile
usr/src/usr.bin/uucp/assert.c
usr/src/usr.bin/uucp/libuu/anlwrk.c
usr/src/usr.bin/uucp/libuu/anyread.c
usr/src/usr.bin/uucp/libuu/cfgets.c
usr/src/usr.bin/uucp/libuu/chkpth.c
usr/src/usr.bin/uucp/uucico/cico.c

index 9ea1a18..3a24217 100644 (file)
@@ -1,5 +1,22 @@
 INSTALLATION GUIDE
 INSTALLATION GUIDE
-README 5.2     83/07/19
+README 5.3     85/01/22
+
+This version is based on the "rti uucp" that was on the 4.2BSD tape.
+It contains many additional  features and fixes from Usenet,
+Tom Truscott, Guy Harris, and many others.
+
+A few new subdirectories have been added. Do a "make mkdirs" to make
+sure that you have all of them.
+
+The man pages now describe all the options for the various commands.
+make sure you read them. A complete list of differences is too big to consider.
+
+You should also look through the UUAIDS directory. There are some useful
+programs and hints therein.
+
+Rick Adams
+rick@seismo.ARPA
+January 14, 1985
 
 Tom Truscott, rti!trt,decvax!duke!trt (919)541-6488 Research Triangle Institute
 Bob Gray, gray@berkeley, duke!adiron!bob (315) 336-4989
 
 Tom Truscott, rti!trt,decvax!duke!trt (919)541-6488 Research Triangle Institute
 Bob Gray, gray@berkeley, duke!adiron!bob (315) 336-4989
@@ -35,8 +52,7 @@ uusnap                        Displays spooled files, and pending uuxqts.
 This version runs on all VAXen and PDPs under UNIX-V7 and 4.1bsd, 4.2BSD.
 It also runs on Gould/SEL Concept series machines (e.g. 32/8750), 
 DUAL 68000 unisoft.
 This version runs on all VAXen and PDPs under UNIX-V7 and 4.1bsd, 4.2BSD.
 It also runs on Gould/SEL Concept series machines (e.g. 32/8750), 
 DUAL 68000 unisoft.
-It should not be hard to get it running on BTL system III, IV, and V.
-On such systems, put "#define SYSIII" in uucp.h and pray.
+It also runns on BTL system III, IV, and V.
 
 UUCP installers should read the two papers (by Dave Nowitz)
 in Vol 2B of version 7 manuals and UUAIDS/setup.tblms.
 
 UUCP installers should read the two papers (by Dave Nowitz)
 in Vol 2B of version 7 manuals and UUAIDS/setup.tblms.
@@ -63,7 +79,7 @@ Some steps will vary slightly from system to system.
 
        non-4.2
                a) sites need to install the Berkeley directory reading library.
 
        non-4.2
                a) sites need to install the Berkeley directory reading library.
-                       Try (cd LIBNDIR; make install).
+                       Try (cd libndir; make install).
                        Edit Makefile to have LIBNDIR= -lndir
                        define NDIR in uucp.h.
                b) Check LDFLAGS, OWNER, GROUP, and LIBUUCICO.
                        Edit Makefile to have LIBNDIR= -lndir
                        define NDIR in uucp.h.
                b) Check LDFLAGS, OWNER, GROUP, and LIBUUCICO.
@@ -156,24 +172,9 @@ Some steps will vary slightly from system to system.
        uu.weekly               Renames SYSLOG to SYSLOG.old.
        The above scripts should be run via cron.
 
        uu.weekly               Renames SYSLOG to SYSLOG.old.
        The above scripts should be run via cron.
 
-       uuq
-               Reports number of command ('C.') files queued for each system,
-               number of remote executions ('XQT') pending,
-               and with what systems uucico is currently conversing.
-               (It would also be handy to know the status of each site
-               such as 'decvax: last connection 03:00 Fri Jan 20' and
-               failures such as 'harpo: no answer 07:00 Fri Jan 20'.
-               It would also be handy to have a manual page for this thing.)
-
-       uuusage, uuusage.1, uutbl
-               Summarizes SYSLOG.  Very handy.  (Alan S. Watt).
-               Works best if you use uucp.daily.  Slow if SYSLOG is big.
-
-       uurate
-               More detailed summary of SYSLOG.  Useful for checking
-               throughput.  Modified from program provided by ittvax!swatt.
-               Slow if SYSLOG is big.
-
+       uucpsummary
+               Summarizes LOGFILE and SYSLOG. It's very helpful in telling
+               what is going on and who is calling who.
        uucp.daily
                Daily shell script run at ittvax.  Manages SYSLOG files in
                a convenient form for uuusage.  Not integrated in time
        uucp.daily
                Daily shell script run at ittvax.  Manages SYSLOG files in
                a convenient form for uuusage.  Not integrated in time
index d84fd34..0c9e755 100644 (file)
@@ -1,4 +1,4 @@
-#      Makefile        5.6     84/08/30
+#      Makefile        5.7     85/01/22
 #
 # This version expects the 4.2BSD directory reading routines to
 # located in libc.a.  If they aren't, augment LIBS.  Also, LIBS
 #
 # This version expects the 4.2BSD directory reading routines to
 # located in libc.a.  If they aren't, augment LIBS.  Also, LIBS
@@ -8,34 +8,59 @@
 # Common object files are assembled into a library {uulib.a}
 #
 ALL=   uucp uux uuxqt uucico uulog uuclean uuname uupoll uusnap \
 # Common object files are assembled into a library {uulib.a}
 #
 ALL=   uucp uux uuxqt uucico uulog uuclean uuname uupoll uusnap \
-       uuencode uudecode uusend uucpd
+       uuencode uudecode uusend uucpd uuq
 # Common object files placed in uulib.a
 COMMON=        anlwrk.o anyread.o assert.o cfgets.o chkpth.o \
 # Common object files placed in uulib.a
 COMMON=        anlwrk.o anyread.o assert.o cfgets.o chkpth.o \
-       cpmv.o expfile.o gename.o getargs.o getopt.o getprm.o \
-       getpw.o getpwinfo.o gio.o gnamef.o gnxseq.o gwd.o imsg.o \
-       index.o lastpart.o logent.o mailst.o nio.o pk0.o pk1.o prefix.o \
-       sdmail.o setline.o shio.o subdir.o sysacct.o systat.o ulockf.o \
-       uucpname.o versys.o xqt.o uucpdefs.o
+       cpmv.o expfile.o gename.o getargs.o getprm.o \
+       getpwinfo.o gio.o gnamef.o gnxseq.o gwd.o imsg.o \
+       lastpart.o logent.o mailst.o pk0.o chksum.o pk1.o prefix.o \
+       setline.o shio.o subdir.o sysacct.o systat.o \
+       ulockf.o \
+       uucpname.o versys.o xqt.o uucpdefs.o tio.o fio.o
+
+SRCS=  anlwrk.c anyread.c assert.c cfgets.c chkpth.c chksum.c \
+       cico.c cntrl.c condevs.c conn.c cpmv.c expfile.c \
+       gename.c getargs.c getprm.c getpwinfo.c \
+       gio.c gnamef.c gnsys.c gnxseq.c gwd.c imsg.c \
+       ioctl.c lastpart.c logent.c mailst.c ndir.h \
+       pk.h pk0.c pk1.c pkon.c prefix.c \
+       setline.c shio.c subdir.c sysacct.c systat.c tio.c fio.c\
+       ulockf.c \
+       uuclean.c uucp.c uucp.h uucpdefs.c uucpname.c uudecode.c \
+       uuencode.c uulog.c uuname.c uupoll.c uusend.c uusnap.c \
+       uux.c uuxqt.c \
+       versys.c xqt.c uuq.c
+#These might be useful on non 4.2bsd systems.
+MISC= htonl.c ioctl.c index.c
+
 DESTDIR=
 OWNER= uucp
 GROUP= daemon
 CFLAGS=        -O
 LDFLAGS=
 DESTDIR=
 OWNER= uucp
 GROUP= daemon
 CFLAGS=        -O
 LDFLAGS=
-LIBS=
-LIBDIR=        /usr/lib/uucp
-BIN=   /usr/bin
-PUBDIR=        /usr/spool/uucppublic
-SPOOL= /usr/spool/uucp
-XQTDIR=        /usr/spool/uucp/XTMP
+LIBS= 
+LIBDIR=        ${DESTDIR}/usr/lib/uucp
+BIN=   ${DESTDIR}/usr/bin
+PUBDIR=        ${DESTDIR}/usr/spool/uucppublic
+SPOOL= ${DESTDIR}/usr/spool/uucp
+XQTDIR=        ${SPOOL}/XTMP
+CORRUPT= ${SPOOL}/CORRUPT
+AUDIT= ${SPOOL}/AUDIT
+LCK=   #${SPOOL}/LCK.
+STST=  ${SPOOL}/STST
 # The six subdirs {not counting XTMP}.  The order of the D. files is crucial!
 SUBDIRS=C. D.`uuname -l`X D.`uuname -l` D. X. TM.
 # The six subdirs {not counting XTMP}.  The order of the D. files is crucial!
 SUBDIRS=C. D.`uuname -l`X D.`uuname -l` D. X. TM.
-PKON=  pkon.o
-IOCTL=
 # for make depend
 # for make depend
-UNDEF= -UNDIR -UUNET -USYSIII -UUNAME -UCCWHOAMI -UGETMYHNAME -UDATAKIT
+UNDEF= -UNDIR -UUNET -USYSIII -UUNAME -UCCWHOAMI -UGETMYHNAME -UDATAKIT \
+       -UBSD4_2
 
 all:   ${ALL} 
 
 
 all:   ${ALL} 
 
+print: $(SRCS)
+       vgrind $?
+       vgrind -x index
+       touch print
+
 uucp:  uucp.o uulib.a
        ${CC} -o uucp ${LDFLAGS} uucp.o uulib.a
 
 uucp:  uucp.o uulib.a
        ${CC} -o uucp ${LDFLAGS} uucp.o uulib.a
 
@@ -45,57 +70,51 @@ uux:        uux.o uulib.a
 uuxqt: uuxqt.o uulib.a
        ${CC} -o uuxqt ${LDFLAGS} uuxqt.o uulib.a ${LIBS}
 
 uuxqt: uuxqt.o uulib.a
        ${CC} -o uuxqt ${LDFLAGS} uuxqt.o uulib.a ${LIBS}
 
-uucico:        cico.o cntrl.o conn.o condevs.o gnsys.o ${IOCTL} ${PKON} uulib.a
+uucico:        cico.o cntrl.o conn.o condevs.o gnsys.o uulib.a aculib/aculib.a
        ${CC} -o uucico ${LDFLAGS} cico.o cntrl.o conn.o condevs.o \
        ${CC} -o uucico ${LDFLAGS} cico.o cntrl.o conn.o condevs.o \
-               gnsys.o ${IOCTL} ${PKON} uulib.a ${LIBS}
+               gnsys.o uulib.a aculib/aculib.a ${LIBS}
 
 uulog: uulog.o uulib.a
        ${CC} -o uulog ${LDFLAGS} uulog.o uulib.a
 
 uuclean: uuclean.o uulib.a
 
 uulog: uulog.o uulib.a
        ${CC} -o uulog ${LDFLAGS} uulog.o uulib.a
 
 uuclean: uuclean.o uulib.a
-       ${CC} -o uuclean ${LDFLAGS} uuclean.o uulib.a
+       ${CC} -o uuclean ${LDFLAGS} uuclean.o uulib.a ${LIBS}
 
 uuname:        uuname.o uulib.a
        ${CC} -o uuname ${LDFLAGS} uuname.o uulib.a
 
 uuname:        uuname.o uulib.a
        ${CC} -o uuname ${LDFLAGS} uuname.o uulib.a
+
 uupoll:        uupoll.o uulib.a
        ${CC} -o uupoll ${LDFLAGS} uupoll.o uulib.a
 
 uupoll:        uupoll.o uulib.a
        ${CC} -o uupoll ${LDFLAGS} uupoll.o uulib.a
 
-uusnap:        uusnap.o uulib.a
-       ${CC} -o uusnap ${LDFLAGS} uusnap.o uulib.a ${LIBS}
+uusnap:        uusnap.o
+       ${CC} -o uusnap ${LDFLAGS} uusnap.o ${LIBS}
 
 
-uuencode: uuencode.o uulib.a
-       ${CC} -o uuencode ${LDFLAGS} uuencode.o uulib.a
+uuencode: uuencode.o
+       ${CC} -o uuencode ${LDFLAGS} uuencode.o
 
 
-uudecode: uudecode.o uulib.a
-       ${CC} -o uudecode ${LDFLAGS} uudecode.o uulib.a
+uudecode: uudecode.o
+       ${CC} -o uudecode ${LDFLAGS} uudecode.o
 
 
-uusend: uusend.o uulib.a
-       ${CC} -o uusend ${LDFLAGS} uusend.o uulib.a
+uusend: uusend.o
+       ${CC} -o uusend ${LDFLAGS} uusend.o
 
 
-uucpd: uucpd.o
+uucpd: uucpd.o uucp.h
        ${CC} -o uucpd ${LDFLAGS} uucpd.o
 
        ${CC} -o uucpd ${LDFLAGS} uucpd.o
 
+uuq: uuq.o uulib.a
+       ${CC} -o uuq ${LDFLAGS} uuq.o uulib.a
+
 # Note: mode 700 on ${LIBDIR} would be safer.
 # Also,  L.sys etc should be 600.
 # Note: mode 700 on ${LIBDIR} would be safer.
 # Also,  L.sys etc should be 600.
+
 mkdirs:
 mkdirs:
-       -mkdir ${DESTDIR}/${LIBDIR}
-       chmod 755 ${DESTDIR}/${LIBDIR}
-       chown ${OWNER} ${DESTDIR}/${LIBDIR}
-       chgrp ${GROUP} ${DESTDIR}/${LIBDIR}
-       -mkdir ${DESTDIR}/${SPOOL}
-       chmod 755 ${DESTDIR}/${SPOOL}
-       chown ${OWNER} ${DESTDIR}/${SPOOL}
-       chgrp ${GROUP} ${DESTDIR}/${SPOOL}
-       -mkdir ${DESTDIR}/${PUBDIR}
-       chmod 777 ${DESTDIR}/${PUBDIR}
-       chown ${OWNER} ${DESTDIR}/${PUBDIR}
-       chgrp ${GROUP} ${DESTDIR}/${PUBDIR}
-       -mkdir ${DESTDIR}/${XQTDIR}
-       chmod 755 ${DESTDIR}/${XQTDIR}
-       chown ${OWNER} ${DESTDIR}/${XQTDIR}
-       chgrp ${GROUP} ${DESTDIR}/${XQTDIR}
-       cd ${DESTDIR}/${SPOOL}; for i in ${SUBDIRS}; do \
+       -for i in ${LIBDIR} ${SPOOL} ${PUBDIR} ${XQTDIR} ${CORRUPT} \
+               ${AUDIT} ${LCK} ${STST} ; do \
+               rm -f $$i ; mkdir $$i ; \
+               chmod 755 $$i; chown ${OWNER} $$i; chgrp ${GROUP} $$i ; \
+       done
+       chmod 777 ${PUBDIR} ${LCK}
+       -cd ${SPOOL}; for i in ${SUBDIRS} ; do \
                mkdir $$i; \
                chown ${OWNER} $$i; chgrp ${GROUP} $$i; chmod 755 $$i; \
        done
                mkdir $$i; \
                chown ${OWNER} $$i; chgrp ${GROUP} $$i; chmod 755 $$i; \
        done
@@ -107,39 +126,30 @@ uulib.a: ${COMMON}
        ar cr $@ `lorder ${COMMON} | tsort`
        ranlib $@
 
        ar cr $@ `lorder ${COMMON} | tsort`
        ranlib $@
 
-install: all
-       chown ${OWNER} ${DESTDIR}/${LIBDIR}
-       chgrp ${GROUP} ${DESTDIR}/${LIBDIR}
-       chmod 755 ${DESTDIR}/${LIBDIR}
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} uucp ${DESTDIR}/${BIN}/uucp
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} uux ${DESTDIR}/${BIN}/uux
-       : chmod u+t ${BIN}/uux; : this helps PDPs
-       install -s -m 6110 -o ${OWNER} -g ${GROUP} \
-               uuxqt ${DESTDIR}/${LIBDIR}/uuxqt
-       : chmod u+t ${LIBDIR}/uuxqt; : this helps PDPs
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uucico ${DESTDIR}/${LIBDIR}/uucico
-       : chmod u+t ${LIBDIR}/uucico; : this helps PDPs if uucico is pure
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} uulog ${DESTDIR}/${BIN}/uulog
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uuclean ${DESTDIR}/${LIBDIR}/uuclean
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uuname ${DESTDIR}/${BIN}/uuname
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uupoll ${DESTDIR}/${BIN}/uupoll
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uusnap ${DESTDIR}/${BIN}/uusnap
-       install -s uuencode ${DESTDIR}/${BIN}/uuencode
-       install -s uudecode ${DESTDIR}/${BIN}/uudecode
-       install -s -m 6111 -o ${OWNER} -g ${GROUP} \
-               uusend ${DESTDIR}/${BIN}/uusend
-       install -s -m 100 -o ${OWNER} -g ${GROUP} \
-               uucpd ${DESTDIR}/${LIBDIR}/uucpd
-       rm -f ${DESTDIR}/${BIN}/ruusend
-       ln ${DESTDIR}/${BIN}/uusend ${DESTDIR}/${BIN}/ruusend
+aculib/aculib.a:
+       cd aculib; make
+
+install:
+       chown ${OWNER} ${LIBDIR}
+       chgrp ${GROUP} ${LIBDIR}
+       chmod 755 ${LIBDIR}
+       for i in uucico uuclean; do \
+               install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${LIBDIR} ;\
+       done
+       for i in uucp uux uulog uuname uusnap uupoll uuq uusend; do \
+               install -s -m 6111 -o ${OWNER} -g ${GROUP} $$i ${BIN} ;\
+       done
+       rm -f ${BIN}/ruusend
+       ln ${BIN}/uusend ${BIN}/ruusend
+       install -s -m 6110 -o ${OWNER} -g ${GROUP} uuxqt ${LIBDIR}
+       install -s -m 700 -o root uucpd /etc/uucpd
+       @echo Dont forget to fork off /etc/uucpd in /etc/rc.local
+       install -s uuencode ${BIN}
+       install -s uudecode ${BIN}
 
 clean:
        rm -f *.o ${ALL} uulib.a
 
 clean:
        rm -f *.o ${ALL} uulib.a
+       cd aculib; make clean
 
 depend:
        for i in *.c; do \
 
 depend:
        for i in *.c; do \
@@ -164,202 +174,110 @@ depend:
 # DEPENDENCIES MUST END AT END OF FILE
 anlwrk.o: anlwrk.c
 anlwrk.o: uucp.h
 # DEPENDENCIES MUST END AT END OF FILE
 anlwrk.o: anlwrk.c
 anlwrk.o: uucp.h
-anlwrk.o: /usr/include/sys/types.h
-anlwrk.o: /usr/include/sys/stat.h
-anlwrk.o: /usr/include/sys/dir.h
+anlwrk.o: uust.h
 anyread.o: anyread.c
 anyread.o: uucp.h
 anyread.o: anyread.c
 anyread.o: uucp.h
-anyread.o: /usr/include/sys/types.h
-anyread.o: /usr/include/sys/stat.h
 assert.o: assert.c
 assert.o: uucp.h
 assert.o: assert.c
 assert.o: uucp.h
-assert.o: /usr/include/sys/time.h
-assert.o: /usr/include/sys/types.h
-assert.o: /usr/include/errno.h
 cfgets.o: cfgets.c
 cfgets.o: cfgets.c
-cfgets.o: /usr/include/stdio.h
 chkpth.o: chkpth.c
 chkpth.o: uucp.h
 chkpth.o: chkpth.c
 chkpth.o: uucp.h
-chkpth.o: /usr/include/sys/types.h
-chkpth.o: /usr/include/sys/stat.h
+chksum.o: chksum.c
 cico.o: cico.c
 cico.o: uucp.h
 cico.o: cico.c
 cico.o: uucp.h
-cico.o: /usr/include/signal.h
-cico.o: /usr/include/setjmp.h
-cico.o: /usr/include/sys/types.h
-cico.o: /usr/include/sgtty.h
+cico.o: uust.h
+cico.o: uusub.h
 cntrl.o: cntrl.c
 cntrl.o: uucp.h
 cntrl.o: cntrl.c
 cntrl.o: uucp.h
-cntrl.o: /usr/include/sys/types.h
-cntrl.o: /usr/include/sys/stat.h
+cntrl.o: uust.h
 condevs.o: condevs.c
 condevs.o: condevs.c
-condevs.o: /usr/include/sys/types.h
-condevs.o: /usr/include/errno.h
-condevs.o: /usr/include/setjmp.h
-condevs.o: /usr/include/signal.h
-condevs.o: /usr/include/sgtty.h
 condevs.o: uucp.h
 condevs.o: uucp.h
-condevs.o: /usr/include/sys/time.h
-condevs.o: /usr/include/sys/timeb.h
 conn.o: conn.c
 conn.o: uucp.h
 conn.o: conn.c
 conn.o: uucp.h
-conn.o: /usr/include/signal.h
-conn.o: /usr/include/setjmp.h
-conn.o: /usr/include/ctype.h
-conn.o: /usr/include/sys/types.h
-conn.o: /usr/include/sys/time.h
-conn.o: /usr/include/errno.h
-conn.o: /usr/include/sgtty.h
 cpmv.o: cpmv.c
 cpmv.o: uucp.h
 cpmv.o: cpmv.c
 cpmv.o: uucp.h
-cpmv.o: /usr/include/sys/types.h
-cpmv.o: /usr/include/sys/stat.h
 expfile.o: expfile.c
 expfile.o: uucp.h
 expfile.o: expfile.c
 expfile.o: uucp.h
-expfile.o: /usr/include/sys/types.h
-expfile.o: /usr/include/sys/stat.h
+fio.o: fio.c
+fio.o: uucp.h
 gename.o: gename.c
 gename.o: uucp.h
 getargs.o: getargs.c
 gename.o: gename.c
 gename.o: uucp.h
 getargs.o: getargs.c
-getargs.o: /usr/include/stdio.h
 getopt.o: getopt.c
 getopt.o: getopt.c
-getopt.o: /usr/include/stdio.h
 getprm.o: getprm.c
 getprm.o: getprm.c
-getprm.o: /usr/include/stdio.h
-getpw.o: getpw.c
-getpw.o: /usr/include/stdio.h
 getpwinfo.o: getpwinfo.c
 getpwinfo.o: uucp.h
 getpwinfo.o: getpwinfo.c
 getpwinfo.o: uucp.h
-getpwinfo.o: /usr/include/pwd.h
 gio.o: gio.c
 gio.o: gio.c
-gio.o: pk.p
-gio.o: /usr/include/sys/types.h
 gio.o: pk.h
 gio.o: pk.h
-gio.o: /usr/include/setjmp.h
 gio.o: uucp.h
 gnamef.o: gnamef.c
 gnamef.o: uucp.h
 gio.o: uucp.h
 gnamef.o: gnamef.c
 gnamef.o: uucp.h
-gnamef.o: /usr/include/sys/types.h
-gnamef.o: /usr/include/sys/dir.h
 gnsys.o: gnsys.c
 gnsys.o: uucp.h
 gnsys.o: gnsys.c
 gnsys.o: uucp.h
-gnsys.o: /usr/include/sys/types.h
-gnsys.o: /usr/include/sys/dir.h
 gnxseq.o: gnxseq.c
 gnxseq.o: uucp.h
 gnxseq.o: gnxseq.c
 gnxseq.o: uucp.h
-gnxseq.o: /usr/include/sys/types.h
-gnxseq.o: /usr/include/sys/time.h
 gwd.o: gwd.c
 gwd.o: uucp.h
 gwd.o: gwd.c
 gwd.o: uucp.h
-gwd.o: /usr/include/signal.h
 imsg.o: imsg.c
 imsg.o: uucp.h
 imsg.o: imsg.c
 imsg.o: uucp.h
-index.o: index.c
-index.o: /usr/include/stdio.h
 ioctl.o: ioctl.c
 ioctl.o: uucp.h
 ioctl.o: ioctl.c
 ioctl.o: uucp.h
-ioctl.o: /usr/include/sgtty.h
 lastpart.o: lastpart.c
 logent.o: logent.c
 logent.o: uucp.h
 lastpart.o: lastpart.c
 logent.o: logent.c
 logent.o: uucp.h
-logent.o: /usr/include/sys/types.h
-logent.o: /usr/include/sys/time.h
-logent.o: /usr/include/sgtty.h
 mailst.o: mailst.c
 mailst.o: uucp.h
 mailst.o: mailst.c
 mailst.o: uucp.h
-nio.o: nio.c
-nio.o: /usr/include/sys/param.h
-nio.o: uucp.h
 pk0.o: pk0.c
 pk0.o: pk0.c
-pk0.o: /usr/include/stdio.h
-pk0.o: pk.p
-pk0.o: /usr/include/sys/param.h
 pk0.o: pk.h
 pk0.o: pk.h
-pk0.o: /usr/include/sys/buf.h
 pk1.o: pk1.c
 pk1.o: pk1.c
-pk1.o: /usr/include/stdio.h
-pk1.o: pk.p
-pk1.o: /usr/include/sys/param.h
 pk1.o: pk.h
 pk1.o: pk.h
-pk1.o: /usr/include/sys/buf.h
-pk1.o: /usr/include/setjmp.h
-pk1.o: /usr/include/signal.h
-pkon.o: pkon.c
+pk1.o: uucp.h
 prefix.o: prefix.c
 prefix.o: prefix.c
-sdmail.o: sdmail.c
-sdmail.o: uucp.h
-sdmail.o: /usr/include/pwd.h
 setline.o: setline.c
 setline.o: uucp.h
 shio.o: shio.c
 shio.o: uucp.h
 setline.o: setline.c
 setline.o: uucp.h
 shio.o: shio.c
 shio.o: uucp.h
-shio.o: /usr/include/signal.h
 subdir.o: subdir.c
 subdir.o: uucp.h
 sysacct.o: sysacct.c
 subdir.o: subdir.c
 subdir.o: uucp.h
 sysacct.o: sysacct.c
-sysacct.o: /usr/include/sys/types.h
 systat.o: systat.c
 systat.o: uucp.h
 systat.o: systat.c
 systat.o: uucp.h
-systat.o: /usr/include/sys/types.h
+tio.o: tio.c
+tio.o: uucp.h
 ulockf.o: ulockf.c
 ulockf.o: uucp.h
 ulockf.o: ulockf.c
 ulockf.o: uucp.h
-ulockf.o: /usr/include/sys/types.h
-ulockf.o: /usr/include/sys/stat.h
 uuclean.o: uuclean.c
 uuclean.o: uucp.h
 uuclean.o: uuclean.c
 uuclean.o: uucp.h
-uuclean.o: /usr/include/signal.h
-uuclean.o: /usr/include/pwd.h
-uuclean.o: /usr/include/sys/types.h
-uuclean.o: /usr/include/sys/stat.h
-uuclean.o: /usr/include/sys/dir.h
 uucp.o: uucp.c
 uucp.o: uucp.h
 uucp.o: uucp.c
 uucp.o: uucp.h
-uucp.o: /usr/include/sys/types.h
-uucp.o: /usr/include/sys/stat.h
+uucp.o: uust.h
+uucpd.o: uucpd.c
+uucpd.o: uucp.h
 uucpdefs.o: uucpdefs.c
 uucpdefs.o: uucp.h
 uucpname.o: uucpname.c
 uucpname.o: uucp.h
 uucpdefs.o: uucpdefs.c
 uucpdefs.o: uucp.h
 uucpname.o: uucpname.c
 uucpname.o: uucp.h
-uucpname.o: /usr/include/sys/types.h
-uucpname.o: /usr/include/sys/stat.h
 uudecode.o: uudecode.c
 uudecode.o: uudecode.c
-uudecode.o: /usr/include/stdio.h
-uudecode.o: /usr/include/pwd.h
-uudecode.o: /usr/include/sys/types.h
-uudecode.o: /usr/include/sys/stat.h
 uuencode.o: uuencode.c
 uuencode.o: uuencode.c
-uuencode.o: /usr/include/stdio.h
-uuencode.o: /usr/include/sys/types.h
-uuencode.o: /usr/include/sys/stat.h
 uulog.o: uulog.c
 uulog.o: uucp.h
 uuname.o: uuname.c
 uuname.o: uucp.h
 uulog.o: uulog.c
 uulog.o: uucp.h
 uuname.o: uuname.c
 uuname.o: uucp.h
-uuname.o: /usr/include/signal.h
 uupoll.o: uupoll.c
 uupoll.o: uucp.h
 uupoll.o: uupoll.c
 uupoll.o: uucp.h
+uuq.o: uuq.c
+uuq.o: uucp.h
 uusend.o: uusend.c
 uusend.o: uusend.c
-uusend.o: /usr/include/stdio.h
-uusend.o: /usr/include/pwd.h
-uusend.o: /usr/include/sys/types.h
-uusend.o: /usr/include/sys/stat.h
 uusnap.o: uusnap.c
 uusnap.o: uucp.h
 uusnap.o: uusnap.c
 uusnap.o: uucp.h
-uusnap.o: /usr/include/sys/types.h
-uusnap.o: /usr/include/sys/stat.h
-uusnap.o: /usr/include/sys/dir.h
 uux.o: uux.c
 uux.o: uucp.h
 uuxqt.o: uuxqt.c
 uuxqt.o: uucp.h
 uux.o: uux.c
 uux.o: uucp.h
 uuxqt.o: uuxqt.c
 uuxqt.o: uucp.h
-uuxqt.o: /usr/include/sys/types.h
-uuxqt.o: /usr/include/sys/stat.h
-uuxqt.o: /usr/include/sys/dir.h
 versys.o: versys.c
 versys.o: uucp.h
 xqt.o: xqt.c
 xqt.o: uucp.h
 versys.o: versys.c
 versys.o: uucp.h
 xqt.o: xqt.c
 xqt.o: uucp.h
-xqt.o: /usr/include/signal.h
 # DEPENDENCIES MUST END AT END OF FILE
 # IF YOU PUT STUFF HERE IT WILL GO AWAY
 # see make depend above
 # DEPENDENCIES MUST END AT END OF FILE
 # IF YOU PUT STUFF HERE IT WILL GO AWAY
 # see make depend above
index bfa9577..d29ab46 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)assert.c   5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)assert.c   5.3 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #endif
 
 #include "uucp.h"
index 5804aaa..53d6dd2 100644 (file)
@@ -1,10 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)anlwrk.c   5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)anlwrk.c   5.3 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #endif
 
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include "uust.h"
 #ifdef NDIR
 #include "ndir.h"
 #else
 #ifdef NDIR
 #include "ndir.h"
 #else
@@ -50,15 +51,11 @@ static char sccsid[] = "@(#)anlwrk.c        5.2 (Berkeley) %G%";
  */
 
 
  */
 
 
-#define LLEN 20
-#define MAXRQST 250
 #define TLIMIT (5*60L)
 #define NITEMS(X)      (sizeof (X) / sizeof ((X)[0]))
 
 #define TLIMIT (5*60L)
 #define NITEMS(X)      (sizeof (X) / sizeof ((X)[0]))
 
-/* These are all used only locally
- */
-static int Nfiles = 0;
-static char Filent[LLEN][NAMESIZE];
+int Nfiles = 0;
+char Filent[LLEN][NAMESIZE];
 
 /*******
  *     anlwrk(file, wvec)      create a vector of command arguments
 
 /*******
  *     anlwrk(file, wvec)      create a vector of command arguments
@@ -77,22 +74,23 @@ register char *file, **wvec;
        static char str[MAXRQST];
        static FILE *fp = NULL;
 
        static char str[MAXRQST];
        static FILE *fp = NULL;
 
-       /* If called with a null string, force a shutdown
+       /*
+        * If called with a null string, force a shutdown
         * of the current work file.
         * of the current work file.
-        * John Levine, ima.247, related change in cntl.c
         */
        if (file[0] == '\0') {
                if (fp != NULL)
                        fclose (fp);
                fp = NULL;
         */
        if (file[0] == '\0') {
                if (fp != NULL)
                        fclose (fp);
                fp = NULL;
-               return(0);
+               return 0;
        }
        if (fp == NULL) {
                fp = fopen(subfile(file), "r");
                if (fp == NULL) {
        }
        if (fp == NULL) {
                fp = fopen(subfile(file), "r");
                if (fp == NULL) {
-                       unlink(subfile(file));  /* Try to zap the thing. rti!trt */
-                       return(0);
+                       unlink(subfile(file));
+                       return 0;
                }
                }
+               Usrf = 0;
        }
 
        /* This is what deletes the current work file when EOF
        }
 
        /* This is what deletes the current work file when EOF
@@ -104,11 +102,14 @@ register char *file, **wvec;
        if (fgets(str, MAXRQST, fp) == NULL) {
                fclose(fp);
                unlink(subfile(file));
        if (fgets(str, MAXRQST, fp) == NULL) {
                fclose(fp);
                unlink(subfile(file));
+               USRF(USR_COMP);
+               US_RRS(file, Usrf);
+               Usrf = 0;
                file[0] = '\0';
                fp = NULL;
                file[0] = '\0';
                fp = NULL;
-               return(0);
+               return 0;
        }
        }
-       return(getargs(str, wvec));
+       return getargs(str, wvec, 20);
 }
 
 
 }
 
 
@@ -134,12 +135,16 @@ register char *dir, *pre;
 {
        static DIR  *dirp = NULL;
        register nfound;
 {
        static DIR  *dirp = NULL;
        register nfound;
-       char filename[NAMESIZE];        /* @@@ NB: this needs new dir stuff */
+       char filename[NAMESIZE];
        int plen = strlen (pre);
        int plen = strlen (pre);
+       int flen;
+       extern char MaxGrade;
 
        if (dirp == NULL) {
 
        if (dirp == NULL) {
-               if ((dirp = opendir(subdir(dir,pre[0]), "r")) == NULL)
-                       return(0);
+               if ((dirp = opendir(subdir(dir,pre[0]))) == NULL) {
+                       DEBUG(1,"opendir(%s) FAILS\n",subdir(dir,pre[0]));
+                       return 0;
+               }
        }
        else
                rewinddir(dirp);
        }
        else
                rewinddir(dirp);
@@ -152,15 +157,21 @@ register char *dir, *pre;
                 * Special case: prefix "X." does not do this check
                 * so uuxqt can use bldflst.
                 */
                 * Special case: prefix "X." does not do this check
                 * so uuxqt can use bldflst.
                 */
-               if (!prefix(pre, filename)
-                || (plen != 2 && strlen(filename)-plen != 5))
+               flen = strlen(filename);
+               if (!prefix(pre, filename) || (plen != 2 && flen-plen != 5)) {
+                       DEBUG(99,"bldflst rejects %s\n",filename);
                        continue;
                        continue;
+               }
+               if (filename[flen-5] > MaxGrade ) {
+                       DEBUG(8,"bldflst rejects %s, grade too low\n",filename);
+                       continue;
+               }
                nfound++;
                if (*reqst == 'c')
                nfound++;
                if (*reqst == 'c')
-                       return (1);
+                       return 1;
                entflst(filename);
        }
                entflst(filename);
        }
-       return (nfound? 1: 0);
+       return  nfound? 1: 0;
 }
 
 /***
 }
 
 /***
@@ -175,30 +186,24 @@ register char *dir, *pre;
 /* LOCAL only */
 int
 entflst(file)
 /* LOCAL only */
 int
 entflst(file)
-char *file;
+register char *file;
 {
        register int i;
 {
        register int i;
-       register char *p;
 
 
-       /* If there is room in the table, just add it. */
-       if (Nfiles < LLEN) {
-               strcpy(Filent[Nfiles++], file);
-               return;
+       /* locate position for the new file and make room for it */
+       for (i = Nfiles; i > 0; i--) {
+               if (pcompar(file, Filent[i-1]) >= 0)
+                       break;
+               if (i <LLEN)
+                       strcpy(Filent[i], Filent[i-1]);
        }
 
        }
 
-       /* Find lowest priority file in table  */
-       p = Filent[0];
-       for (i = 1; i < Nfiles; i++)
-               if (pcompar(Filent[i], p) < 0)
-                       p = Filent[i];
-
-       /*
-        * If new candidate is of higher priority
-        * that the lowest priority file in the table,
-        * replace the table entry.
-        */
-       if (pcompar(p, file) < 0)
-               strcpy(p, file);
+       /* add new file (if there is room), and increase Nfiles if need be */
+       if (i < LLEN) {
+               strcpy(Filent[i], file);
+               if (Nfiles < LLEN)
+                       Nfiles++;
+       }
 }
 
 /*
 }
 
 /*
@@ -223,15 +228,15 @@ register char *p1, *p2;
        p2 += strlen(p2)-5;
        /* check 'grade' */
        if (rc = *p2++ - *p1++)
        p2 += strlen(p2)-5;
        /* check 'grade' */
        if (rc = *p2++ - *p1++)
-               return(rc);
+               return rc;
        /* check for  sequence wrap-around */
        if (rc = *p2++ - *p1++)
                if (rc < -10 || rc > 10)
        /* check for  sequence wrap-around */
        if (rc = *p2++ - *p1++)
                if (rc < -10 || rc > 10)
-                       return(-rc);
+                       return -rc;
                else
                else
-                       return(rc);
+                       return rc;
        /* check remaining digits */
        /* check remaining digits */
-       return(strcmp(p2, p1));
+       return strcmp(p2, p1);
 }
 
 /***
 }
 
 /***
@@ -249,23 +254,14 @@ register char *p1, *p2;
 gtwrkf(dir, file)
 char *file, *dir;
 {
 gtwrkf(dir, file)
 char *file, *dir;
 {
-       register char *p;
-       register int i;
-
-       if (Nfiles == 0)
-               return(0);
-       /* Find highest priority file in table */
-       p = Filent[0];
-       for (i = 1; i < Nfiles; i++) 
-               if (pcompar(Filent[i], p) > 0)
-                       p = Filent[i];
-       sprintf(file, "%s/%s", dir, p);
-       strcpy(p, Filent[--Nfiles]);
-       return(1);
+       if (Nfiles <= 0)
+               return 0;
+       sprintf(file, "%s/%s", dir, Filent[--Nfiles]);
+       return 1;
 }
 
 /***
 }
 
 /***
- *     gtwvec(file, dir, wkpre, wrkvec)        get work vector 
+ *     gtwvec(file, dir, wkpre, wrkvec)        get work vector
  *     char *file, *dir, *wkpre, **wrkvec;
  *
  *     return codes:
  *     char *file, *dir, *wkpre, **wrkvec;
  *
  *     return codes:
@@ -281,12 +277,12 @@ register char *file;
 {
        register int nargs, n;
 
 {
        register int nargs, n;
 
-       n = 0;          /* Break possible infinite loop.  rti!trt */
+       n = 0;
        while ((nargs = anlwrk(file, wrkvec)) == 0) {
                if (++n > 3 || !iswrk(file, "get", dir, wkpre))
        while ((nargs = anlwrk(file, wrkvec)) == 0) {
                if (++n > 3 || !iswrk(file, "get", dir, wkpre))
-                       return(0);
+                       return 0;
        }
        }
-       return(nargs);
+       return nargs;
 }
 
 /***
 }
 
 /***
@@ -338,8 +334,10 @@ register char *file, *reqst, *dir, *pre;
         */
        for (;;) {
                ret = 0;
         */
        for (;;) {
                ret = 0;
-               if (Nfiles == 0 || newspool((time_t)TLIMIT))
+               if (Nfiles == 0 || newspool((time_t)TLIMIT)) {
                        ret = bldflst (reqst, dir, pre);
                        ret = bldflst (reqst, dir, pre);
+                       DEBUG(99,"bldflst returns %d\n",ret);
+               }
 
                /* If they only wanted to check, return
                 * boolean list not empty.  NB: the list
 
                /* If they only wanted to check, return
                 * boolean list not empty.  NB: the list
@@ -347,13 +345,13 @@ register char *file, *reqst, *dir, *pre;
                 * a new system name is mentioned.
                 */
                if (*reqst == 'c')
                 * a new system name is mentioned.
                 */
                if (*reqst == 'c')
-                       return (ret);
+                       return ret;
 
                if (Nfiles == 0)
 
                if (Nfiles == 0)
-                       return(0);
+                       return 0;
 
                if (gtwrkf(dir, file))
 
                if (gtwrkf(dir, file))
-                       return (1);
+                       return 1;
        }
 }
 
        }
 }
 
@@ -383,5 +381,5 @@ time_t      limit;
                lastmod = mod.st_mtime;
        }
        lastcheck = check;
                lastmod = mod.st_mtime;
        }
        lastcheck = check;
-       return (ret);
+       return ret;
 }
 }
index 8a60ce1..8afbf83 100644 (file)
@@ -1,26 +1,24 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)anyread.c  5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)anyread.c  5.2 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #endif
 
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
-
-/*******
+/*
  *     anyread         check if anybody can read
  *     anyread         check if anybody can read
- *     return 0 ok: FAIL not ok
+ *     return SUCCESS ok: FAIL not ok
  */
  */
-
 anyread(file)
 char *file;
 {
        struct stat s;
 
 anyread(file)
 char *file;
 {
        struct stat s;
 
-       if (stat(subfile(file), &s) != 0)
+       if (stat(subfile(file), &s) < 0)
                /* for security check a non existant file is readable */
                /* for security check a non existant file is readable */
-               return(0);
+               return SUCCESS;
        if (!(s.st_mode & ANYREAD))
        if (!(s.st_mode & ANYREAD))
-               return(FAIL);
-       return(0);
+               return FAIL;
+       return SUCCESS;
 }
 }
index e161ccc..94851ac 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cfgets.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)cfgets.c   5.2 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -13,7 +13,7 @@ static char sccsid[] = "@(#)cfgets.c  5.1 (Berkeley) %G%";
 #define EOS            '\0'
 
 char *
 #define EOS            '\0'
 
 char *
-cfgets (buf, siz, fil)
+cfgets(buf, siz, fil)
 register char *buf;
 int siz;
 FILE *fil;
 register char *buf;
 int siz;
 FILE *fil;
@@ -22,15 +22,15 @@ FILE *fil;
        register i, c, len;
        char *fgets();
 
        register i, c, len;
        char *fgets();
 
-       for (i=0,s=buf; i = (fgets (s, siz-i, fil) != NULL); i = s - buf) {
+       for (i=0,s=buf; i = (fgets(s, siz-i, fil) != NULL); i = s - buf) {
 
                /* get last character of line */
 
                /* get last character of line */
-               c = s[len = (strlen (s) - 1)];
+               c = s[len = (strlen(s) - 1)];
 
                /* skip comments; make sure end of comment line seen */
                if (*s == COMMENT) {
                        while (c != EOLN && c != EOF)
 
                /* skip comments; make sure end of comment line seen */
                if (*s == COMMENT) {
                        while (c != EOLN && c != EOF)
-                               c = fgetc (fil);
+                               c = getc(fil);
                        *s = EOS;
                }
 
                        *s = EOS;
                }
 
@@ -44,7 +44,7 @@ FILE *fil;
                }
        }
        
                }
        }
        
-       return (i ? buf : NULL);
+       return i ? buf : NULL;
 }
 
 #ifdef TEST
 }
 
 #ifdef TEST
@@ -52,7 +52,7 @@ main()
 {
        char buf[512];
 
 {
        char buf[512];
 
-       while (cfgets (buf, sizeof buf, stdin))
-               fputs (buf, stdout);
+       while (cfgets(buf, sizeof buf, stdin))
+               fputs(buf, stdout);
 }
 #endif TEST
 }
 #endif TEST
index b222284..38a051e 100644 (file)
@@ -1,19 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)chkpth.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)chkpth.c   5.2 (Berkeley) %G%";
 #endif
 
 #endif
 
-/*
- * Doug Kingston, 30 July 82 to fix handling of the "userpath" structures.
- * (brl-bmd) 
- * rti!trt: the code here is bizarre.  There must be a zillion holes.
- * chkpth should not be called for implied Spool requests .
- * But explicit requests (foo!/usr/spoo/uucp/*) should use chkpth.
- */
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
 #include "uucp.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
-
 struct userpath {
        char *us_lname;
        char *us_mname;
 struct userpath {
        char *us_lname;
        char *us_mname;
@@ -25,7 +17,6 @@ struct userpath *Uhead = NULL;
 struct userpath *Mchdef = NULL, *Logdef = NULL;
 int Uptfirst = 1;
 
 struct userpath *Mchdef = NULL, *Logdef = NULL;
 int Uptfirst = 1;
 
-
 /*******
  *     chkpth(logname, mchname, path)
  *     char *path, *logname, *mchname;
 /*******
  *     chkpth(logname, mchname, path)
  *     char *path, *logname, *mchname;
@@ -47,11 +38,11 @@ char *path, *logname, *mchname;
 
        /* Allow only rooted pathnames.  Security wish.  rti!trt */
        if (*path != '/')
 
        /* Allow only rooted pathnames.  Security wish.  rti!trt */
        if (*path != '/')
-               return(FAIL);
+               return FAIL;
 
        if (Uptfirst) {
                rdpth();
 
        if (Uptfirst) {
                rdpth();
-               ASSERT(Uhead != NULL, "INIT USERFILE, No entrys!", "", 0);
+               ASSERT(Uhead != NULL, "INIT USERFILE, No entrys!", CNULL, 0);
                Uptfirst = 0;
        }
        for (u = Uhead; u != NULL; ) {
                Uptfirst = 0;
        }
        for (u = Uhead; u != NULL; ) {
@@ -67,24 +58,22 @@ char *path, *logname, *mchname;
                else
                        u = Logdef;
                if (u == NULL)
                else
                        u = Logdef;
                if (u == NULL)
-                       return(FAIL);
+                       return FAIL;
        }
        }
-       /* found user name */
-       p = u->us_path;
 
        /*  check for /../ in path name  */
        for (s = path; *s != '\0'; s++) {
                if (prefix("/../",s))
 
        /*  check for /../ in path name  */
        for (s = path; *s != '\0'; s++) {
                if (prefix("/../",s))
-                       return(FAIL);
+                       return FAIL;
        }
 
        /* Check for access permission */
        for (p = u->us_path; *p != NULL; p++)
                if (prefix(*p, path))
        }
 
        /* Check for access permission */
        for (p = u->us_path; *p != NULL; p++)
                if (prefix(*p, path))
-                       return(0);
+                       return SUCCESS;
 
        /* path name not valid */
 
        /* path name not valid */
-       return(FAIL);
+       return FAIL;
 }
 
 
 }
 
 
@@ -94,10 +83,6 @@ char *path, *logname, *mchname;
  *     rdpth  -  this routine will read the USERFILE and
  *     construct the userpath structure pointed to by (u);
  *
  *     rdpth  -  this routine will read the USERFILE and
  *     construct the userpath structure pointed to by (u);
  *
- *     return codes:  0  |  FAIL
- *
- * 5/3/81 - changed to enforce the uucp-wide convention that system
- *         names be 7 chars or less in length
  */
 
 rdpth()
  */
 
 rdpth()
@@ -115,7 +100,8 @@ rdpth()
        while (cfgets(buf, sizeof(buf), uf) != NULL) {
                int nargs, i;
 
        while (cfgets(buf, sizeof(buf), uf) != NULL) {
                int nargs, i;
 
-               if ((u = (struct userpath *)malloc(sizeof (struct userpath))) == NULL) {
+               u = (struct userpath *)malloc(sizeof (struct userpath));
+               if (u == NULL) {
                        DEBUG (1, "*** Userpath malloc failed\n", 0);
                        fclose (uf);
                        return;
                        DEBUG (1, "*** Userpath malloc failed\n", 0);
                        fclose (uf);
                        return;
@@ -129,7 +115,7 @@ rdpth()
                }
 
                strcpy(pc, buf);
                }
 
                strcpy(pc, buf);
-               nargs = getargs(pc, pbuf);
+               nargs = getargs(pc, pbuf, 50);
                u->us_lname = pbuf[0];
                pc = index(u->us_lname, ',');
                if (pc != NULL)
                u->us_lname = pbuf[0];
                pc = index(u->us_lname, ',');
                if (pc != NULL)
@@ -141,11 +127,7 @@ rdpth()
                        u->us_mname[7] = '\0';
                if (*u->us_lname == '\0' && Logdef == NULL)
                        Logdef = u;
                        u->us_mname[7] = '\0';
                if (*u->us_lname == '\0' && Logdef == NULL)
                        Logdef = u;
-               /* rti!trt: commented following else so
-                * chkpth("","",file) works okay.
-                * I don't understand this, though.
-                */
-               /*else*/ if (*u->us_mname == '\0' && Mchdef == NULL)
+               if (*u->us_mname == '\0' && Mchdef == NULL)
                        Mchdef = u;
                i = 1;
                if (strcmp(pbuf[1], "c") == SAME) {
                        Mchdef = u;
                i = 1;
                if (strcmp(pbuf[1], "c") == SAME) {
@@ -154,13 +136,14 @@ rdpth()
                }
                else
                        u->us_callback = 0;
                }
                else
                        u->us_callback = 0;
-               if ((cp = u->us_path =
-                 (char **)calloc((unsigned)(nargs-i+1), sizeof(char *))) == NULL) {
+               cp = (char **)calloc((unsigned)(nargs-i+1), sizeof(char *));
+               if (cp == NULL) {
                        /*  can not allocate space */
                        DEBUG (1, "Userpath calloc 2 failed!\n", 0);
                        fclose(uf);
                        return;
                }
                        /*  can not allocate space */
                        DEBUG (1, "Userpath calloc 2 failed!\n", 0);
                        fclose(uf);
                        return;
                }
+               u->us_path = cp;
 
                while (i < nargs)
                        *cp++ = pbuf[i++];
 
                while (i < nargs)
                        *cp++ = pbuf[i++];
@@ -189,19 +172,19 @@ register char *name;
 
        if (Uptfirst) {
                rdpth();
 
        if (Uptfirst) {
                rdpth();
-               ASSERT(Uhead != NULL, "INIT USERFILE, No Users!", "", 0);
+               ASSERT(Uhead != NULL, "INIT USERFILE, No Users!", CNULL, 0);
                Uptfirst = 0;
        }
 
        for (u = Uhead; u != NULL; ) {
                if (strcmp(u->us_lname, name) == SAME)
                        /* found user name */
                Uptfirst = 0;
        }
 
        for (u = Uhead; u != NULL; ) {
                if (strcmp(u->us_lname, name) == SAME)
                        /* found user name */
-                       return(u->us_callback);
+                       return u->us_callback;
                u = u->unext;
        }
 
        /* userid not found */
                u = u->unext;
        }
 
        /* userid not found */
-       return(0);
+       return 0;
 }
 
 
 }
 
 
@@ -214,7 +197,7 @@ register char *name;
  *     directories up to the last part of the
  *     filename (if they do not exist).
  *
  *     directories up to the last part of the
  *     filename (if they do not exist).
  *
- *     return 0 | FAIL
+ *     return SUCCESS | FAIL
  */
 
 chkperm(file, mopt)
  */
 
 chkperm(file, mopt)
@@ -226,40 +209,35 @@ char *file, *mopt;
        extern char *lastpart();
 
        if (stat(subfile(file), &s) == 0) {
        extern char *lastpart();
 
        if (stat(subfile(file), &s) == 0) {
-               /* Forbid scribbling on a not-generally-writable file */
-               /* rti!trt */
                if ((s.st_mode & ANYWRITE) == 0)
                if ((s.st_mode & ANYWRITE) == 0)
-                       return(FAIL);
-               return(0);
+                       return FAIL;
+               return SUCCESS;
        }
 
        strcpy(dir, file);
        *lastpart(dir) = '\0';
        if ((ret = stat(subfile(dir), &s)) == -1
          && mopt == NULL)
        }
 
        strcpy(dir, file);
        *lastpart(dir) = '\0';
        if ((ret = stat(subfile(dir), &s)) == -1
          && mopt == NULL)
-               return(FAIL);
+               return FAIL;
 
        if (ret != -1) {
                if ((s.st_mode & ANYWRITE) == 0)
 
        if (ret != -1) {
                if ((s.st_mode & ANYWRITE) == 0)
-                       return(FAIL);
+                       return FAIL;
                else
                else
-                       return(0);
+                       return SUCCESS;
        }
 
        /*  make directories  */
        }
 
        /*  make directories  */
-       return(mkdirs(file));
+       return mkdirs(file);
 }
 
 /*
  * Check for sufficient privilege to request debugging.
 }
 
 /*
  * Check for sufficient privilege to request debugging.
- * Suggested by seismo!stewart, John Stewart.
  */
  */
-chkdebug(uid)
-int uid;
+chkdebug()
 {
 {
-       if (uid > PRIV_UIDS) {
-               fprintf(stderr, "Sorry, uid must be <= %d for debugging\n",
-                       PRIV_UIDS);
+       if (access(SYSFILE, 04) < 0) {
+               fprintf(stderr, "Sorry, you must be able to read L.sys for debugging\n");
                cleanup(1);
                exit(1);        /* Just in case */
        }
                cleanup(1);
                exit(1);        /* Just in case */
        }
index bcad3bb..c7036b3 100644 (file)
@@ -1,50 +1,66 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cico.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)cico.c     5.5 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/types.h>
 #endif
 
 #include "uucp.h"
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/types.h>
-#ifdef SYSIII
+#ifdef USG
 #include <termio.h>
 #endif
 #include <termio.h>
 #endif
-#ifndef        SYSIII
+#ifndef        USG
 #include <sgtty.h>
 #endif
 #include <sgtty.h>
 #endif
-
-
-#ifdef UNET
-#include <UNET/unetio.h>
-#include <UNET/tcp.h>
-static struct uiocstate ust;
-#endif
+#ifdef BSDTCP
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#endif BSDTCP
+#include <sys/stat.h>
+#include "uust.h"
+#include "uusub.h"
 
 jmp_buf Sjbuf;
 
 jmp_buf Sjbuf;
-       /*  call fail text  */
+jmp_buf Pipebuf;
+
+/*  call fail text  */
 char *Stattext[] = {
        "",
        "BAD SYSTEM",
 char *Stattext[] = {
        "",
        "BAD SYSTEM",
-       "WRONG TIME",
+       "WRONG TIME TO CALL",
        "SYSTEM LOCKED",
        "NO DEVICE",
        "DIAL FAILED",
        "LOGIN FAILED",
        "BAD SEQUENCE"
        "SYSTEM LOCKED",
        "NO DEVICE",
        "DIAL FAILED",
        "LOGIN FAILED",
        "BAD SEQUENCE"
-       };
+};
 
 
-int Role = 0;
-       /*  call fail codes  */
-int Stattype[] = {0, 0, 0, 0,
-       SS_NODEVICE, SS_FAIL, SS_FAIL, SS_BADSEQ
-       };
+/*  call fail codes  */
+int Stattype[] = {
+       0,
+       0,
+       SS_WRONGTIME,
+       0,
+       SS_NODEVICE,
+       SS_FAIL,
+       SS_FAIL,
+       SS_BADSEQ
+};
 
 
 int Errorrate = 0;
 
 
 int Errorrate = 0;
-#ifdef SYSIII
+int ReverseRole = 0;
+int StdErrIsTty = 0;
+int Role = SLAVE;
+int onesys = 0;
+extern int LocalOnly;
+extern char MaxGrade;
+
+#ifdef USG
 struct termio Savettyb;
 #endif
 struct termio Savettyb;
 #endif
-#ifndef        SYSIII
+#ifndef        USG
 struct sgttyb Savettyb;
 #endif
 
 struct sgttyb Savettyb;
 #endif
 
@@ -58,32 +74,20 @@ register char *argv[];
 {
        register int ret;
        int seq;
 {
        register int ret;
        int seq;
-       int onesys = 0;
        char wkpre[NAMESIZE], file[NAMESIZE];
        char wkpre[NAMESIZE], file[NAMESIZE];
-       char msg[BUFSIZ], *q;
+       char msg[MAXFULLNAME], *q, **alias;
        register char *p;
        extern onintr(), timeout(), setdebug();
        register char *p;
        extern onintr(), timeout(), setdebug();
-       extern intrEXIT();
        extern char *pskip();
        char rflags[30];
        char *ttyn;
        extern char *pskip();
        char rflags[30];
        char *ttyn;
-       int orig_uid = getuid();
+#if defined(VMS) && defined(BSDTCP)
+       u_long Hostnumber = 0;
+#endif VMS && BSDTCP
 
        strcpy(Progname, "uucico");
        uucpname(Myname);
 
 
        strcpy(Progname, "uucico");
        uucpname(Myname);
 
-       /* Try to run as uucp -- rti!trt */
-       setgid(getegid());
-       setuid(geteuid());
-
-       signal(SIGILL, intrEXIT);
-       signal(SIGTRAP, intrEXIT);
-       signal(SIGIOT, intrEXIT);
-       signal(SIGEMT, intrEXIT);
-       signal(SIGFPE, intrEXIT);
-       signal(SIGBUS, intrEXIT);
-       signal(SIGSEGV, intrEXIT);
-       signal(SIGSYS, intrEXIT);
        signal(SIGINT, onintr);
        signal(SIGHUP, onintr);
        signal(SIGQUIT, onintr);
        signal(SIGINT, onintr);
        signal(SIGHUP, onintr);
        signal(SIGQUIT, onintr);
@@ -92,8 +96,11 @@ register char *argv[];
        signal(SIGFPE, setdebug);
        ret = guinfo(getuid(), User, msg);
        strcpy(Loginuser, User);
        signal(SIGFPE, setdebug);
        ret = guinfo(getuid(), User, msg);
        strcpy(Loginuser, User);
-       ASSERT(ret == 0, "BAD UID ", "", ret);
+       ASSERT(ret == 0, "BAD UID", CNULL, ret);
 
 
+#ifdef BSD4_2
+       setlinebuf(stderr);
+#endif
        rflags[0] = '\0';
        umask(WFMASK);
        strcpy(Rmtname, Myname);
        rflags[0] = '\0';
        umask(WFMASK);
        strcpy(Rmtname, Myname);
@@ -103,111 +110,148 @@ register char *argv[];
                case 'd':
                        Spool = &argv[1][2];
                        break;
                case 'd':
                        Spool = &argv[1][2];
                        break;
-#ifdef TCPNET
-               case 'v':
-                       Unet = 1;
-                       break;
-#endif TCPNET
-
-#ifdef PROTODEBUG
-               case 'E':
-                       Errorrate = atoi(&argv[1][2]);
-                       if (Errorrate <= 0)
-                               Errorrate = 100;
-                       break;
                case 'g':
                case 'g':
-                       Pkdrvon = 1;
-                       break;
-               case 'G':
-                       Pkdrvon = 1;
-                       strcat(rflags, " -g ");
+                       MaxGrade = argv[1][2];
                        break;
                        break;
-#endif
                case 'r':
                        Role = atoi(&argv[1][2]);
                        break;
                case 'r':
                        Role = atoi(&argv[1][2]);
                        break;
+               case 'R':
+                       ReverseRole++;
+                       Role = MASTER;
+                       break;
                case 's':
                        sprintf(Rmtname, "%.7s", &argv[1][2]);
                        if (Rmtname[0] != '\0')
                                onesys = 1;
                        break;
                case 'x':
                case 's':
                        sprintf(Rmtname, "%.7s", &argv[1][2]);
                        if (Rmtname[0] != '\0')
                                onesys = 1;
                        break;
                case 'x':
-                       chkdebug(orig_uid);
+                       chkdebug();
                        Debug = atoi(&argv[1][2]);
                        if (Debug <= 0)
                                Debug = 1;
                        strcat(rflags, argv[1]);
                        logent("ENABLED", "DEBUG");
                        break;
                        Debug = atoi(&argv[1][2]);
                        if (Debug <= 0)
                                Debug = 1;
                        strcat(rflags, argv[1]);
                        logent("ENABLED", "DEBUG");
                        break;
+               case 'L':       /* local calls only */
+                       LocalOnly++;
+                       break;
+#if defined(VMS) && defined(BSDTCP)
+               case 'h':
+                       Hostnumber = inet_addr(&argv[1][2]);
+                       break;
+#endif VMS && BSDTCP
                default:
                default:
-                       printf("unknown flag %s\n", argv[1]);
+                       printf("unknown flag %s (ignored)\n", argv[1]);
                        break;
                }
                --argc;  argv++;
        }
 
                        break;
                }
                --argc;  argv++;
        }
 
-       subchdir(Spool);
-       strcpy(Wrkdir, Spool);
+       while (argc > 1) {
+               printf("unknown argument %s (ignored)\n", argv[1]);
+               --argc; argv++;
+       }
 
 
-#ifdef UNET
-/*
- * Determine if we are on UNET
- */
-       ret = ioctl(0, UIOCSTATE, &ust);
-       if (ret == 0) {
-               Unet = 1;
-               DEBUG(4, "UNET connection -- ioctl-s disabled\n", "");
+       /* Try to run as uucp -- rti!trt */
+       setgid(getegid());
+       setuid(geteuid());
+#ifdef TIOCNOTTY
+       /*
+        * detach uucico from controlling terminal
+        * to defend against rlogind sending us a SIGKILL (!!!)
+        */
+       if (Role == MASTER && (ret = open("/dev/tty", 2)) >= 0) {
+               ioctl(ret, TIOCNOTTY, STBNULL);
+               close(ret);
        }
        }
-#endif
+#endif TIOCNOTTY
+#ifdef BSD4_2
+       if (getpgrp(0) == 0) { /*We have no controlling terminal */
+               setpgrp(0, getpid());
+       }
+#endif BSD4_2
+
+       ret = subchdir(Spool);
+       ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
+       strcpy(Wrkdir, Spool);
+
        if (Role == SLAVE) {
        if (Role == SLAVE) {
+               /* check for /etc/nologin */
+               ultouch();      /* sets nologinflag as a side effect */
+               if (nologinflag) {
+                       logent(NOLOGIN, "UUCICO SHUTDOWN");
+                       if (Debug)
+                               logent("DEBUGGING", "continuing anyway");
+                       else
+                               cleanup(1);
+               }
+#ifdef TCPIP
+               /*
+                * Determine if we are on TCPIP
+                */
+               if (isatty(0) ==  0) {
+                       IsTcpIp = 1;
+                       DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
+               }
+#endif TCPIP
                /* initial handshake */
                onesys = 1;
                /* initial handshake */
                onesys = 1;
-               if (!Unet) {
-#ifdef SYSIII
+               if (!IsTcpIp) {
+#ifdef USG
                        ret = ioctl(0, TCGETA, &Savettyb);
                        Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7;
                        Savettyb.c_oflag |= OPOST;
                        Savettyb.c_lflag |= (ISIG|ICANON|ECHO);
                        ret = ioctl(0, TCGETA, &Savettyb);
                        Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7;
                        Savettyb.c_oflag |= OPOST;
                        Savettyb.c_lflag |= (ISIG|ICANON|ECHO);
-#endif
-#ifndef        SYSIII
+#else !USG
                        ret = ioctl(0, TIOCGETP, &Savettyb);
                        Savettyb.sg_flags |= ECHO;
                        Savettyb.sg_flags &= ~RAW;
                        ret = ioctl(0, TIOCGETP, &Savettyb);
                        Savettyb.sg_flags |= ECHO;
                        Savettyb.sg_flags &= ~RAW;
-#endif
+#endif !USG
                }
                Ifn = 0;
                Ofn = 1;
                fixmode(Ifn);
                }
                Ifn = 0;
                Ofn = 1;
                fixmode(Ifn);
-               fclose(stderr);
-               fopen(RMTDEBUG, "w");
-               omsg('S', "here", Ofn);
+               sprintf(file,"%s/%d", RMTDEBUG, getpid());
+#ifdef VMS
+               /* hold the version number down */
+               unlink(file);
+#endif
+               freopen(file, "w", stderr);
+#ifdef BSD4_2
+               setlinebuf(stderr);
+#else  !BSD4_2
+               setbuf(stderr, NULL);
+#endif !BSD4_2
+               sprintf(msg, "here=%s", Myname);
+               omsg('S', msg, Ofn);
                signal(SIGALRM, timeout);
                alarm(MAXMSGTIME);
                if (setjmp(Sjbuf)) {
                        /* timed out */
                signal(SIGALRM, timeout);
                alarm(MAXMSGTIME);
                if (setjmp(Sjbuf)) {
                        /* timed out */
-                       if (!Unet) {
-#ifdef SYSIII
+                       if (!IsTcpIp) {
+#ifdef USG
                                ret = ioctl(0, TCSETA, &Savettyb);
 #endif
                                ret = ioctl(0, TCSETA, &Savettyb);
 #endif
-#ifndef        SYSIII
+#ifndef        USG
                                ret = ioctl(0, TIOCSETP, &Savettyb);
 #endif
                        }
                                ret = ioctl(0, TIOCSETP, &Savettyb);
 #endif
                        }
-                       exit(0);
+                       cleanup(0);
                }
                for (;;) {
                        ret = imsg(msg, Ifn);
                        if (ret != 0) {
                                alarm(0);
                }
                for (;;) {
                        ret = imsg(msg, Ifn);
                        if (ret != 0) {
                                alarm(0);
-                               if (!Unet) {
-#ifdef SYSIII
+                               if (!IsTcpIp) {
+#ifdef USG
                                        ret = ioctl(0, TCSETA, &Savettyb);
 #endif
                                        ret = ioctl(0, TCSETA, &Savettyb);
 #endif
-#ifndef        SYSIII
+#ifndef        USG
                                        ret = ioctl(0, TIOCSETP, &Savettyb);
 #endif
                                }
                                        ret = ioctl(0, TIOCSETP, &Savettyb);
 #endif
                                }
-                               exit(0);
+                               cleanup(0);
                        }
                        if (msg[0] == 'S')
                                break;
                        }
                        if (msg[0] == 'S')
                                break;
@@ -216,7 +260,81 @@ register char *argv[];
                q = &msg[1];
                p = pskip(q);
                sprintf(Rmtname, "%.7s", q);
                q = &msg[1];
                p = pskip(q);
                sprintf(Rmtname, "%.7s", q);
+               sprintf(wkpre,"%s/%s", RMTDEBUG, Rmtname);
+               unlink(wkpre);
+               if (link(file, wkpre) == 0)
+                       unlink(file);
                DEBUG(4, "sys-%s\n", Rmtname);
                DEBUG(4, "sys-%s\n", Rmtname);
+#ifdef BSDTCP
+               /* we must make sure they are really who they say they
+                * are. We compare the hostnumber with the number in the hosts
+                * table for the site they claim to be.
+                */
+               if (IsTcpIp) {
+                       struct hostent *hp;
+                       char *cpnt, *inet_ntoa();
+                       int fromlen;
+                       struct sockaddr_in from;
+
+#ifndef        VMS
+                       fromlen = sizeof(from);
+                       if (getpeername(0, &from, &fromlen) < 0) {
+                               logent(Rmtname, "NOT A TCP CONNECTION");
+                               omsg('R', "NOT TCP", Ofn);
+                               cleanup(0);
+                       }
+#else  VMS
+                       from.sin_addr.s_addr = Hostnumber;
+                       from.sin_family = AF_INET;
+#endif VMS
+                       hp = gethostbyaddr(&from.sin_addr,
+                               sizeof (struct in_addr), from.sin_family);
+                       if (hp == 0) {
+                               /* security break or just old host table? */
+                               logent(Rmtname, "UNKNOWN IP-HOST Name =");
+                               cpnt = inet_ntoa(from.sin_addr),
+                               logent(cpnt, "UNKNOWN IP-HOST Number =");
+                               sprintf(wkpre, "%s/%s isn't in my host table",
+                                       Rmtname, cpnt);
+                               omsg('R' ,wkpre ,Ofn);
+                               cleanup(0);
+                       }
+                       if (Debug>99)
+                               logent(Rmtname,"Request from IP-Host name =");
+                       /* The following is to determine if the name given us by
+                        * the Remote uucico matches any of the names(aliases)
+                        * given its network number (remote machine) in our
+                        * host table.
+                        */
+                       if (strncmp(q, hp->h_name, 7) == 0) {
+                               if (Debug > 99)
+                                       logent(q,"Found in host Tables");
+                       } else { /* Scan The host aliases */
+                               for(alias=hp->h_aliases; *alias!=0 &&
+                                   strncmp(q, *alias, 7) != 0; ++alias)
+                                       ;
+                               if (strncmp(q, *alias, 7) != 0) {
+                                       logent(q, "FORGED HOSTNAME");
+                                       logent(inet_ntoa(from.sin_addr), "ORIGINATED AT");
+                                       omsg('R',"You're not who you claim to be");
+                                       cleanup(0);
+                               }
+#ifdef DEBUG
+                               if (Debug> 99)
+                                       logent(q,"Found in host Tables");
+#endif
+                       }
+               }
+#endif BSDTCP
+
+#ifdef NOSTRANGERS
+               /* If we don't know them, we won't talk to them... */
+               if (versys(Rmtname)) {
+                       logent(Rmtname, "UNKNOWN HOST");
+                       omsg('R', "You are unknown to me", Ofn);
+                       cleanup(0);
+               }
+#endif NOSTRANGERS
                if (mlock(Rmtname)) {
                        omsg('R', "LCK", Ofn);
                        cleanup(0);
                if (mlock(Rmtname)) {
                        omsg('R', "LCK", Ofn);
                        cleanup(0);
@@ -227,7 +345,7 @@ register char *argv[];
                        omsg('R', "CB", Ofn);
                        logent("CALLBACK", "REQUIRED");
                        /*  set up for call back  */
                        omsg('R', "CB", Ofn);
                        logent("CALLBACK", "REQUIRED");
                        /*  set up for call back  */
-                       systat(Rmtname, SS_CALLBACK, "CALL BACK");
+                       systat(Rmtname, SS_CALLBACK, "CALLING BACK");
                        gename(CMDPRE, Rmtname, 'C', file);
                        close(creat(subfile(file), 0666));
                        xuucico(Rmtname);
                        gename(CMDPRE, Rmtname, 'C', file);
                        close(creat(subfile(file), 0666));
                        xuucico(Rmtname);
@@ -237,9 +355,6 @@ register char *argv[];
                while (*p == '-') {
                        q = pskip(p);
                        switch(*(++p)) {
                while (*p == '-') {
                        q = pskip(p);
                        switch(*(++p)) {
-                       case 'g':
-                               Pkdrvon = 1;
-                               break;
                        case 'x':
                                Debug = atoi(++p);
                                if (Debug <= 0)
                        case 'x':
                                Debug = atoi(++p);
                                if (Debug <= 0)
@@ -258,41 +373,79 @@ register char *argv[];
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
+#ifdef GNXSEQ
                if ((ret = gnxseq(Rmtname)) == seq) {
                        omsg('R', "OK", Ofn);
                        cmtseq();
                if ((ret = gnxseq(Rmtname)) == seq) {
                        omsg('R', "OK", Ofn);
                        cmtseq();
-               }
+               } else {
+#else !GNXSEQ
+               if (seq == 0)
+                       omsg('R', "OK", Ofn);
                else {
                else {
+#endif !GNXSEQ
                        systat(Rmtname, Stattype[7], Stattext[7]);
                        systat(Rmtname, Stattype[7], Stattext[7]);
-                       logent("BAD SEQ", "HANDSHAKE FAILED");
+                       logent("BAD SEQ", "HANDSHAKE FAIL");
+#ifdef GNXSEQ
                        ulkseq();
                        ulkseq();
+#endif GNXSEQ
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
                ttyn = ttyname(Ifn);
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
                ttyn = ttyname(Ifn);
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
+       } else { /* Role == MASTER */
+               struct stat stbuf;
+               if (isatty(fileno(stderr)) || (fstat(fileno(stderr),&stbuf) == 0
+                   && stbuf.st_mode&S_IFREG) )
+                       StdErrIsTty =  1;
+               setdebug(0);
        }
        }
+
 loop:
 loop:
+       if(setjmp(Pipebuf)) {   /* come here on SIGPIPE */
+               clsacu();
+               close(Ofn);
+               close(Ifn);
+               Ifn = Ofn = -1;
+               rmlock(CNULL);
+               sleep(3);
+       }
        if (!onesys) {
        if (!onesys) {
+               struct stat sbuf;
+
+               if (!StdErrIsTty) {
+                       sprintf(file, "%s/%s", RMTDEBUG, Rmtname);
+                       if (stat(file, &sbuf) == 0 && sbuf.st_size == 0)
+                               unlink(file);
+               }
                ret = gnsys(Rmtname, Spool, CMDPRE);
                ret = gnsys(Rmtname, Spool, CMDPRE);
+               setdebug(0);
                if (ret == FAIL)
                        cleanup(100);
                if (ret == 0)
                        cleanup(0);
                if (ret == FAIL)
                        cleanup(100);
                if (ret == 0)
                        cleanup(0);
-       }
-       else if (Role == MASTER && callok(Rmtname) != 0) {
+       } else if (Role == MASTER && callok(Rmtname) != 0) {
                logent("SYSTEM STATUS", "CAN NOT CALL");
                cleanup(0);
        }
 
        sprintf(wkpre, "%c.%.7s", CMDPRE, Rmtname);
 
                logent("SYSTEM STATUS", "CAN NOT CALL");
                cleanup(0);
        }
 
        sprintf(wkpre, "%c.%.7s", CMDPRE, Rmtname);
 
+       signal(SIGINT, SIG_IGN);
+       signal(SIGQUIT, SIG_IGN);
        if (Role == MASTER) {
        if (Role == MASTER) {
+               /* check for /etc/nologin */
+               ultouch();      /* sets nologinflag as a side effect */
+               if (nologinflag) {
+                       logent(NOLOGIN, "UUCICO SHUTDOWN");
+                       if (Debug)
+                               logent("DEBUGGING", "continuing anyway");
+                       else
+                               cleanup(1);
+               }
                /*  master part */
                /*  master part */
-               signal(SIGINT, SIG_IGN);
                signal(SIGHUP, SIG_IGN);
                signal(SIGHUP, SIG_IGN);
-               signal(SIGQUIT, SIG_IGN);
                if (!iswrk(file, "chk", Spool, wkpre) && !onesys) {
                        logent(Rmtname, "NO WORK");
                        goto next;
                if (!iswrk(file, "chk", Spool, wkpre) && !onesys) {
                        logent(Rmtname, "NO WORK");
                        goto next;
@@ -309,19 +462,35 @@ loop:
                sprintf(msg, "call to %s ", Rmtname);
                if (mlock(Rmtname) != 0) {
                        logent(msg, "LOCKED");
                sprintf(msg, "call to %s ", Rmtname);
                if (mlock(Rmtname) != 0) {
                        logent(msg, "LOCKED");
+                       US_SST(us_s_lock);
                        goto next;
                }
                Ofn = Ifn = conn(Rmtname);
                if (Ofn < 0) {
                        goto next;
                }
                Ofn = Ifn = conn(Rmtname);
                if (Ofn < 0) {
-                       logent(msg, "FAILED");
-                       systat(Rmtname, Stattype[-Ofn],
-                               Stattext[-Ofn]);
+                       if (Ofn != CF_TIME)
+                               logent(msg, _FAILED);
+                       /* avoid excessive 'wrong time' info */
+                       if (Stattype[-Ofn] != SS_WRONGTIME || argv[0][0] != 'U'){
+                               systat(Rmtname, Stattype[-Ofn], Stattext[-Ofn]);
+                               US_SST(-Ofn);
+                               UB_SST(-Ofn);
+                       }
                        goto next;
                        goto next;
-               }
-               else {
+               } else {
                        logent(msg, "SUCCEEDED");
                        logent(msg, "SUCCEEDED");
+                       US_SST(us_s_cok);
+                       UB_SST(ub_ok);
+               }
+#ifdef TCPIP
+               /*
+                * Determine if we are on TCPIP
+                */
+               if (isatty(Ifn) ==  0) {
+                       IsTcpIp = 1;
+                       DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
                }
                }
-       
+#endif
+
                if (setjmp(Sjbuf))
                        goto next;
                signal(SIGALRM, timeout);
                if (setjmp(Sjbuf))
                        goto next;
                signal(SIGALRM, timeout);
@@ -330,24 +499,30 @@ loop:
                        ret = imsg(msg, Ifn);
                        if (ret != 0) {
                                alarm(0);
                        ret = imsg(msg, Ifn);
                        if (ret != 0) {
                                alarm(0);
-                               logent("imsg 1", "FAILED");
-                               goto next;
+                               logent("imsg 1", _FAILED);
+                               goto Failure;
                        }
                        if (msg[0] == 'S')
                                break;
                }
                alarm(MAXMSGTIME);
                        }
                        if (msg[0] == 'S')
                                break;
                }
                alarm(MAXMSGTIME);
+#ifdef GNXSEQ
                seq = gnxseq(Rmtname);
                seq = gnxseq(Rmtname);
+#else !GNXSEQ
+               seq = 0;
+#endif !GNXSEQ
                sprintf(msg, "%.7s -Q%d %s", Myname, seq, rflags);
                omsg('S', msg, Ofn);
                for (;;) {
                        ret = imsg(msg, Ifn);
                        DEBUG(4, "msg-%s\n", msg);
                sprintf(msg, "%.7s -Q%d %s", Myname, seq, rflags);
                omsg('S', msg, Ofn);
                for (;;) {
                        ret = imsg(msg, Ifn);
                        DEBUG(4, "msg-%s\n", msg);
-                       if (ret != 0) {
+                       if (ret != SUCCESS) {
                                alarm(0);
                                alarm(0);
+#ifdef GNXSEQ
                                ulkseq();
                                ulkseq();
-                               logent("imsg 2", "FAILED");
-                               goto next;
+#endif GNXSEQ
+                               logent("imsg 2", _FAILED);
+                               goto Failure;
                        }
                        if (msg[0] == 'R')
                                break;
                        }
                        if (msg[0] == 'R')
                                break;
@@ -355,19 +530,30 @@ loop:
                alarm(0);
                if (msg[1] == 'B') {
                        /* bad sequence */
                alarm(0);
                if (msg[1] == 'B') {
                        /* bad sequence */
-                       logent("BAD SEQ", "HANDSHAKE FAILED");
-                       systat(Rmtname, Stattype[7], Stattext[7]);
+                       logent("BAD SEQ", "HANDSHAKE FAIL");
+                       US_SST(us_s_hand);
+                       systat(Rmtname, SS_BADSEQ, Stattext[SS_BADSEQ]);
+#ifdef GNXSEQ
                        ulkseq();
                        ulkseq();
+#endif GNXSEQ
                        goto next;
                }
                if (strcmp(&msg[1], "OK") != SAME)  {
                        goto next;
                }
                if (strcmp(&msg[1], "OK") != SAME)  {
-                       logent(&msg[1], "HANDSHAKE FAILED");
+                       logent(&msg[1], "HANDSHAKE FAIL");
+                       US_SST(us_s_hand);
+#ifdef GNXSEQ
                        ulkseq();
                        ulkseq();
+#endif GNXSEQ
+                       systat(Rmtname, SS_INPROGRESS,
+                               strcmp(&msg[1], "CB") == SAME?
+                               "AWAITING CALLBACK": "HANDSHAKE FAIL");
                        goto next;
                }
                        goto next;
                }
+#ifdef GNXSEQ
                cmtseq();
                cmtseq();
+#endif GNXSEQ
        }
        }
-       DEBUG(1, " Rmtname %s, ", Rmtname);
+       DEBUG(1, "Rmtname %s, ", Rmtname);
        DEBUG(1, "Role %s,  ", Role ? "MASTER" : "SLAVE");
        DEBUG(1, "Ifn - %d, ", Ifn);
        DEBUG(1, "Loginuser - %s\n", Loginuser);
        DEBUG(1, "Role %s,  ", Role ? "MASTER" : "SLAVE");
        DEBUG(1, "Ifn - %d, ", Ifn);
        DEBUG(1, "Loginuser - %s\n", Loginuser);
@@ -378,30 +564,31 @@ loop:
        ret = startup(Role);
        alarm(0);
        if (ret != SUCCESS) {
        ret = startup(Role);
        alarm(0);
        if (ret != SUCCESS) {
+               logent("startup", _FAILED);
 Failure:
 Failure:
-               logent("startup", "FAILED");
-               systat(Rmtname, SS_FAIL, "STARTUP");
+               US_SST(us_s_start);
+               systat(Rmtname, SS_FAIL, "STARTUP FAILED");
                goto next;
                goto next;
-       }
-       else {
+       } else {
                logent("startup", "OK");
                logent("startup", "OK");
+               US_SST(us_s_gress);
                systat(Rmtname, SS_INPROGRESS, "TALKING");
                ret = cntrl(Role, wkpre);
                DEBUG(1, "cntrl - %d\n", ret);
                signal(SIGINT, SIG_IGN);
                signal(SIGHUP, SIG_IGN);
                signal(SIGALRM, timeout);
                systat(Rmtname, SS_INPROGRESS, "TALKING");
                ret = cntrl(Role, wkpre);
                DEBUG(1, "cntrl - %d\n", ret);
                signal(SIGINT, SIG_IGN);
                signal(SIGHUP, SIG_IGN);
                signal(SIGALRM, timeout);
-               if (ret == 0) {
+               if (ret == SUCCESS) {
                        logent("conversation complete", "OK");
                        logent("conversation complete", "OK");
+                       US_SST(us_s_ok);
                        rmstat(Rmtname);
 
                        rmstat(Rmtname);
 
-               }
-               else {
-                       logent("conversation complete", "FAILED");
-                       systat(Rmtname, SS_FAIL, "CONVERSATION");
+               } else {
+                       logent("conversation complete", _FAILED);
+                       US_SST(us_s_cf);
+                       systat(Rmtname, SS_FAIL, "CONVERSATION FAILED");
                }
                alarm(MAXMSGTIME);
                }
                alarm(MAXMSGTIME);
-               omsg('O', "OOOOO", Ofn);
                DEBUG(4, "send OO %d,", ret);
                if (!setjmp(Sjbuf)) {
                        for (;;) {
                DEBUG(4, "send OO %d,", ret);
                if (!setjmp(Sjbuf)) {
                        for (;;) {
@@ -414,7 +601,8 @@ Failure:
                        }
                }
                alarm(0);
                        }
                }
                alarm(0);
-               clsacu();       /* rti!trt: is this needed? */
+               clsacu();
+               rmlock(CNULL);
        }
 next:
        if (!onesys) {
        }
 next:
        if (!onesys) {
@@ -423,7 +611,7 @@ next:
        cleanup(0);
 }
 
        cleanup(0);
 }
 
-#ifndef        SYSIII
+#ifndef        USG
 struct sgttyb Hupvec;
 #endif
 
 struct sgttyb Hupvec;
 #endif
 
@@ -437,6 +625,8 @@ register int code;
 {
        register int ret;
        register char *ttyn;
 {
        register int ret;
        register char *ttyn;
+       char bfr[BUFSIZ];
+       struct stat sbuf;
 
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
 
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
@@ -444,13 +634,11 @@ register int code;
        clsacu();
        logcls();
        if (Role == SLAVE) {
        clsacu();
        logcls();
        if (Role == SLAVE) {
-               if (!Unet) {
-#ifdef SYSIII
+               if (!IsTcpIp) {
+#ifdef USG
                        Savettyb.c_cflag |= HUPCL;
                        ret = ioctl(0, TCSETA, &Savettyb);
                        Savettyb.c_cflag |= HUPCL;
                        ret = ioctl(0, TCSETA, &Savettyb);
-#endif
-#ifndef        SYSIII
-                       /* rti!trt:  use more robust hang up sequence */
+#else !USG
                        ret = ioctl(0, TIOCHPCL, STBNULL);
                        ret = ioctl(0, TIOCGETP, &Hupvec);
                        Hupvec.sg_ispeed = B0;
                        ret = ioctl(0, TIOCHPCL, STBNULL);
                        ret = ioctl(0, TIOCGETP, &Hupvec);
                        Hupvec.sg_ispeed = B0;
@@ -458,7 +646,9 @@ register int code;
                        ret = ioctl(0, TIOCSETP, &Hupvec);
                        sleep(2);
                        ret = ioctl(0, TIOCSETP, &Savettyb);
                        ret = ioctl(0, TIOCSETP, &Hupvec);
                        sleep(2);
                        ret = ioctl(0, TIOCSETP, &Savettyb);
-#endif
+                       /* make *sure* exclusive access is off */
+                       ret = ioctl(0, TIOCNXCL, STBNULL);
+#endif !USG
                        DEBUG(4, "ret ioctl - %d\n", ret);
                }
                ttyn = ttyname(Ifn);
                        DEBUG(4, "ret ioctl - %d\n", ret);
                }
                ttyn = ttyname(Ifn);
@@ -471,9 +661,15 @@ register int code;
                close(Ifn);
                close(Ofn);
        }
                close(Ifn);
                close(Ofn);
        }
-       DEBUG(1, "exit code %d\n", code);
        if (code == 0)
                xuuxqt();
        if (code == 0)
                xuuxqt();
+       else
+               DEBUG(1, "exit code %d\n", code);
+       sprintf(bfr, "%s/%s", RMTDEBUG, Rmtname);
+       if (stat(bfr, &sbuf) == 0 && sbuf.st_size == 0)
+               unlink(bfr);
+       sprintf(bfr, "%s/%d", RMTDEBUG, getpid());
+       unlink(bfr);
        exit(code);
 }
 
        exit(code);
 }
 
@@ -488,34 +684,40 @@ register int inter;
        signal(inter, SIG_IGN);
        sprintf(str, "SIGNAL %d", inter);
        logent(str, "CAUGHT");
        signal(inter, SIG_IGN);
        sprintf(str, "SIGNAL %d", inter);
        logent(str, "CAUGHT");
-       systat(Rmtname, SS_FAIL, str);
+       US_SST(us_s_intr);
+       if (*Rmtname && strcmp(Rmtname, Myname))
+               systat(Rmtname, SS_FAIL, str);
+       if (inter == SIGPIPE && !onesys)
+               longjmp(Pipebuf, 1);
        cleanup(inter);
 }
 
        cleanup(inter);
 }
 
-/* changed to single version of intrEXIT.  Is this okay? rti!trt */
-intrEXIT(signo)
-int signo;
-{
-#ifdef SIGIO
-       /* if using 4.2 signal mechanism, must unblock all signal handlers */
-       sigsetmask(0);
-#endif
-       signal(signo, SIG_DFL);
-       setgid(getgid());
-       setuid(getuid());
-       abort();
-}
 /*
  * Catch a special signal
  * (SIGFPE, ugh), and toggle debugging between 0 and 30.
  * Handy for looking in on long running uucicos.
  */
 /*
  * Catch a special signal
  * (SIGFPE, ugh), and toggle debugging between 0 and 30.
  * Handy for looking in on long running uucicos.
  */
-setdebug()
+setdebug(code)
+int code;
 {
 {
-       if (Debug < 30)
-               Debug = 30;
-       else
-               Debug = 0;
+       char buf[BUFSIZ];
+
+       if (!StdErrIsTty) {
+               sprintf(buf,"%s/%s", RMTDEBUG, Rmtname);
+               unlink(buf);
+               freopen(buf, "w", stderr);
+#ifdef BSD4_2
+               setlinebuf(stderr);
+#else  !BSD4_2
+               setbuf(stderr, NULL);
+#endif !BSD4_2
+       }
+       if (code) {
+               if (Debug == 0)
+                       Debug = 30;
+               else
+                       Debug = 0;
+       }
 }
 
 
 }
 
 
@@ -528,18 +730,18 @@ setdebug()
 fixmode(tty)
 register int tty;
 {
 fixmode(tty)
 register int tty;
 {
-#ifdef SYSIII
+#ifdef USG
        struct termio ttbuf;
 #endif
        struct termio ttbuf;
 #endif
-#ifndef        SYSIII
+#ifndef        USG
        struct sgttyb ttbuf;
 #endif
        register int ret;
 
        struct sgttyb ttbuf;
 #endif
        register int ret;
 
-       if (Unet)
+       if (IsTcpIp)
                return;
                return;
-#ifdef SYSIII
-       ioctl(tty, TCGETA, &ttbuf);
+#ifdef USG
+       ret = ioctl(tty, TCGETA, &ttbuf);
        ttbuf.c_iflag = ttbuf.c_oflag = ttbuf.c_lflag = (ushort)0;
        ttbuf.c_cflag &= (CBAUD);
        ttbuf.c_cflag |= (CS8|CREAD);
        ttbuf.c_iflag = ttbuf.c_oflag = ttbuf.c_lflag = (ushort)0;
        ttbuf.c_cflag &= (CBAUD);
        ttbuf.c_cflag |= (CS8|CREAD);
@@ -547,14 +749,14 @@ register int tty;
        ttbuf.c_cc[VTIME] = 1;
        ret = ioctl(tty, TCSETA, &ttbuf);
 #endif
        ttbuf.c_cc[VTIME] = 1;
        ret = ioctl(tty, TCSETA, &ttbuf);
 #endif
-#ifndef        SYSIII
+#ifndef        USG
        ioctl(tty, TIOCGETP, &ttbuf);
        ttbuf.sg_flags = (ANYP | RAW);
        ret = ioctl(tty, TIOCSETP, &ttbuf);
 #endif
        ioctl(tty, TIOCGETP, &ttbuf);
        ttbuf.sg_flags = (ANYP | RAW);
        ret = ioctl(tty, TIOCSETP, &ttbuf);
 #endif
-       ASSERT(ret >= 0, "STTY FAILED", "", ret);
-#ifndef        SYSIII
-       ioctl(tty, TIOCEXCL, STBNULL);
+/*     ASSERT(ret >= 0, "STTY FAILED", CNULL, ret); */
+#ifndef        USG
+       ret = ioctl(tty, TIOCEXCL, STBNULL);
 #endif
 }
 
 #endif
 }
 
@@ -566,7 +768,10 @@ register int tty;
 timeout()
 {
        logent(Rmtname, "TIMEOUT");
 timeout()
 {
        logent(Rmtname, "TIMEOUT");
-       systat(Rmtname, SS_FAIL, "TIMEOUT");
+       if (*Rmtname && strcmp(Rmtname, Myname)) {
+               US_SST(us_s_tmot);
+               systat(Rmtname, SS_FAIL, "TIMEOUT");
+       }
        longjmp(Sjbuf, 1);
 }
 
        longjmp(Sjbuf, 1);
 }
 
@@ -574,8 +779,9 @@ static char *
 pskip(p)
 register char *p;
 {
 pskip(p)
 register char *p;
 {
-       while( *p && *p != ' ' )
+       while(*p && *p != ' ')
                ++p;
                ++p;
-       if( *p ) *p++ = 0;
-       return(p);
+       if(*p)
+               *p++ = 0;
+       return p;
 }
 }