diff options
| author | jtc <jtc@NetBSD.org> | 1994-10-24 22:17:41 +0000 |
|---|---|---|
| committer | jtc <jtc@NetBSD.org> | 1994-10-24 22:17:41 +0000 |
| commit | 83ed75f58e695ed36a677fbb5d37e25e8b03367c (patch) | |
| tree | 34fad65ad1656aa9e530d43fef2ea6cfbf1a68ef /gnu/libexec | |
| parent | db9f432b61abc8b286b9e2cfbb9692ccaeb14ee5 (diff) | |
Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl).
Diffstat (limited to 'gnu/libexec')
178 files changed, 8919 insertions, 1845 deletions
diff --git a/gnu/libexec/uucp/contrib/Makefile.uurt b/gnu/libexec/uucp/contrib/Makefile.uurt index 235fcca889f..e5bc69f795a 100644 --- a/gnu/libexec/uucp/contrib/Makefile.uurt +++ b/gnu/libexec/uucp/contrib/Makefile.uurt @@ -1,30 +1,40 @@ +# $Id: Makefile.uurt,v 1.2 1994/10/24 22:17:41 jtc Exp $ +# Makefile for uurate 1.10 # -# Makefile for uurate 1.0 -# + +# Prefix directory for installation directories. +prefix = /usr/local + +# Directory where the needed .h files are installed (uucp.h ...). +uucpsrcs = ../ # Where uurate is installed -BIN=/usr/local/bin +BIN=$(prefix)/bin +# Where uurate's man is installed +MAN=$(prefix)/man/man1 + +# The directory to look in for Taylor style configuration files +newconfigdir = $(prefix)/conf/uucp # Flags to use when compiling uurate -CFLAGS=-I.. +CC=gcc -O2 +CFLAGS=-I.. -Wall +LDFLAGS=-s -CC=cc SHELL=/bin/sh PROGS=uurate #----------- +MORECFLAGS= -I. -I$(uucpsrcs) -DNEWCONFIGLIB=\"$(newconfigdir)\" all: $(PROGS) +uurate: uurate.c + $(CC) $(CFLAGS) $(MORECFLAGS) $@.c -o $@ $(LDFLAGS) + install: $(PROGS) - @for i in $(PROGS) ; do \ - echo "Install $$i into $(BIN)..." ; \ - cp $$i $(BIN) ; \ - echo "Set ownership and protection..." ; \ - /bin/chmod 0555 $(BIN)/$$i ; \ - /bin/chown bin $(BIN)/$$i ; \ - /bin/chgrp bin $(BIN)/$$i ; \ - done + cp $(PROGS) $(BIN) + cp uurate.man $(MAN)/uurate.1 clean: rm -f $(PROGS) core diff --git a/gnu/libexec/uucp/contrib/README b/gnu/libexec/uucp/contrib/README index c4105ed0386..8e4651a9bbd 100644 --- a/gnu/libexec/uucp/contrib/README +++ b/gnu/libexec/uucp/contrib/README @@ -3,6 +3,11 @@ This is the README file for the Taylor UUCP contrib directory. This directory contains contributed shell scripts and programs that you may find useful. +Not actually included here, but nonetheless useful, is the TUA program +distributed by Lele Gaifax <lele@nautilus.sublink.org>. It can do +various sorts of analysis of any type of UUCP log file. It should be +available from most FTP sites. + xchat.c, xchat.man, README-XCHAT, xc-conf.h-dist, Makefile.xchat: A program by Bob Denny that may be invoked by the ``chat-program'' command for any of the various types of chat scripts. It is @@ -13,9 +18,16 @@ xchat.c, xchat.man, README-XCHAT, xc-conf.h-dist, Makefile.xchat: Dial.Hayes, Hangup.Hayes, Login.LAT, Login.PortSel, Login.VMS: Sample scripts for xchat. +uucomp.shar + A set of programs which automatically compresses outgoing data in + the spool directory. The remote system must cooperate when using + this. It can cut down on phone usage when applicable. + Contributed by Ed Carp. + uurate.c, uurate.man, README-UURATE, Makefile.uurt: A nifty little program by Bob Denny which analyzes the Log and - Stats file and prints various sorts of reports. + Stats file and prints various sorts of reports. This version was + tweaked by Stephan Niemz and Klaus Dahlenburg. uutraf: Another program to produce neat reports from your log files, this @@ -28,9 +40,10 @@ savelog.sh, savelog.man: is originally from smail. It was written by Ronald S. Karr and Landon Curt Noll, and was given to me by Bob Denny. -uureroute: - A perl script reroute all mail queued up for one host to another. - Written by Bill Campbell and contributed by Francois Pinard. +uureroute.perl: + A perl script to reroute all mail queued up for one host to + another. Written by Bill Campbell and contributed by Francois + Pinard. stats.sh: A gawk script by Zacharias Beckman which reads the Stats file and @@ -39,6 +52,29 @@ stats.sh: uuq.sh: A uuq workalike shell script by Zacharias Beckman. +uupoll.shar: + uupoll and autopoll programs contributed by Klaus Dahlenburg. + uupoll can be used to automatically poll all systems, or a list of + systems; autopoll will poll and then retry failed calls. + +uudemon.shar: + An implementation of the HDB uudemon.poll script by Donald Burr. + +uuxconv: + A program by Richard E. Nickle to help convert SPOOLDIR_HDB spool + directories to SPOOLDIR_TAYLOR spool directories (note that it is + not necessary to convert your spool directories at all; the + SPOOLDIR_TAYLOR approach may be slightly more efficient). + +dialHDB.c: + A program by Daniel Hagerty which permits using HDB dialer + programs as chat programs. + +amiga.c: + A wrapper program to run uucico from a cron table under Amiga + SVR4 (apparently a wrapper is required). This was contributed by + Lawrence E. Rosenman. + tstout.c: A program to remove a user from utmp and wtmp, essentially logging them out. I put this together from BSD code. I need it to use diff --git a/gnu/libexec/uucp/contrib/README-UURATE b/gnu/libexec/uucp/contrib/README-UURATE index 2cc361ce26f..0ef637514a5 100644 --- a/gnu/libexec/uucp/contrib/README-UURATE +++ b/gnu/libexec/uucp/contrib/README-UURATE @@ -1,20 +1,21 @@ -uurate V1.2 - Gather and display Taylor UUCP traffic statistics +uurate V1.10 - Gather and display Taylor UUCP traffic statistics -Bob Denny (denny@alisa.com) - Thu Sep 3 19:47:41 1992 +Bob Denny (denny@alisa.com) - Thu Sep 3 19:47:41 1992 (V1.2.1) +Klaus Dahlenburg (kdburg@incoahe.hanse.de) - Tue Sep 28 18:11:34 CET 1993 See the man page for documentation. Installation: ------------ -(1) Copy Makefile.uurt to Makefile. +(1) Copy or sym-link Makefile.uurt to Makefile. -(2) Edit Makefile: set BIN where you want uurate to be installed, and - set CFLAGS to point to the directory containing the UUCP sources - (this is .. by default). +(2) Edit Makefile: set BIN where you want uurate to be installed, + MAN where the man page should go to, and set CFLAGS to point + to the directory containing the UUCP sources (this is .. by + default). Don't forget to set newconfigdir= to point to the + directory where the (Taylor-uucp)config is stored. (3) Type ``make'' to compile the program. (4) Type ``make install'' to install the program. - -(5) Install the man page if you want. I didn't put that into the Makefile. diff --git a/gnu/libexec/uucp/contrib/amiga.c b/gnu/libexec/uucp/contrib/amiga.c new file mode 100644 index 00000000000..d982364cfd5 --- /dev/null +++ b/gnu/libexec/uucp/contrib/amiga.c @@ -0,0 +1,43 @@ +/* Wrapper code for Taylor UUCP on Amiga Unix (SVR4) for cron invoked UUCP */ +/* processes. */ + +/* The problem: Cron is not a "licensed" process. any process that grabs a + controlling terminal needs to be licensed. Taylor UUCP needs controlling + terminals. Taylor UUCP does relinquish the controlling terminal before + fork(), so the "UUCP" license is appropriate. + This simple program does the "right" thing, but *MUST* be SETUID ROOT */ + +/* Written by: Lawrence E. Rosenman <ler@lerami.lerctr.org> */ + +#include <sys/sysm68k.h> +#include <sys/types.h> +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <pwd.h> + +int main(int argc,char *argv[],char *envp) +{ + struct passwd *pw; + char name[256]; + + strcpy(name,"/usr/local/lib/uucp/uucico"); + if (sysm68k(_m68k_LIMUSER,EUA_GET_LIC) == 0 ) { /* are we unlicensed? */ + if (sysm68k(_m68k_LIMUSER,EUA_UUCP) == -1) { /* yes, get a "uucp" license */ + fprintf(stderr,"sysm68k failed, errno=%d\n",errno); /* we didn't? crab it */ + exit(errno); + } + } + + pw = getpwnam("uucp"); /* get the Password Entry for uucp */ + if (pw == NULL) + { + fprintf(stderr,"User ID \"uucp\" doesn't exist.\n"); + exit(1); + } + setgid(pw->pw_gid); /* set gid to uucp */ + setuid(pw->pw_uid); /* set uid to uucp */ + argv[0]=name; /* have PS not lie... */ + execv("/usr/local/lib/uucp/uucico",argv); /* go to the real program */ + exit(errno); +} diff --git a/gnu/libexec/uucp/contrib/dialHDB.c b/gnu/libexec/uucp/contrib/dialHDB.c new file mode 100644 index 00000000000..cb2662134af --- /dev/null +++ b/gnu/libexec/uucp/contrib/dialHDB.c @@ -0,0 +1,187 @@ +/* +# File: dialHDB.c +# Author: Daniel Hagerty , hag@eddie.mit.edu +# Copyright (C) 1993 +# Date: Fri Nov 26 19:22:31 1993 +# Description: Program for using HDB dialers for dialing modems, exiting + with 0 on success, else failure. +# Version: 1.0 +# Revision History: +###### +### 11/26/93 Hag - File creation +###### +### 1/5/94 Hag - Finally got around to finishing this damn thing. +###### +*/ +/* Basic theory behind this program- + dialHDB forks into two processes, a monitor parent, and a child + that does the exec of the dialer. Child pretty much just execs the + dialer program, unless there's an exec problem, in which case the + child sends the parent a SIGUSR1 to indicate failed execution. +*/ + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> + +#define kUsage "Usage:\n\t%s dialerPath device number speed\n\ +%s dialer -h device speed\n" + +#define kExitErrFlag 0x80 /* & in with exit code to determine error */ +#define kErrorMask 0x0f /* Mask to determine error code */ + +/* Error code defines as lifted from an HDB dialer */ +#define RCE_NULL 0 /* general purpose or unknown error code */ +#define RCE_INUSE 1 /* line in use */ +#define RCE_SIG 2 /* signal aborted dialer */ +#define RCE_ARGS 3 /* invalid arguments */ +#define RCE_PHNO 4 /* invalid phone number */ +#define RCE_SPEED 5 /* invalid baud rate -or- bad connect baud */ +#define RCE_OPEN 6 /* can't open line */ +#define RCE_IOCTL 7 /* ioctl error */ +#define RCE_TIMOUT 8 /* timeout */ +#define RCE_NOTONE 9 /* no dial tone */ +#define RCE_BUSY 13 /* phone is busy */ +#define RCE_NOCARR 14 /* no carrier */ +#define RCE_ANSWER 15 /* no answer */ + +/* Structure definition to map error codes to strings */ +typedef struct +{ + int errNum; + char *errString; +} errTable; + +const errTable errors[]= +{ + { RCE_NULL, "Unknown Error" }, + { RCE_INUSE, "Line is being used" }, + { RCE_SIG, "Recieved fatal signal" }, + { RCE_ARGS, "Bad arguments" }, + { RCE_PHNO, "Invalid phone number" }, + { RCE_SPEED, "Invalid baud rate or bad connection" }, + { RCE_OPEN, "Unable to open line" }, + { RCE_IOCTL, "ioctl error" }, + { RCE_TIMOUT, "Timed out" }, + { RCE_NOTONE, "No dialtone" }, + { RCE_BUSY, "Phone number is busy" }, + { RCE_NOCARR, "No carrier" }, + { RCE_ANSWER, "No answer" }, + { 0,NULL} +}; + +/* Function Prototypes */ +int figureStat(int stat); +char *findInTable(int error); +void badExec(void); + +char *dialerName; /* basename of our dialer program */ +char *dialerPath; /* full path of dialer program */ + +main(int argc,char *argv[]) +{ + int parent; /* pid of parent process */ + int child; /* pid of child process */ + int stat; /* exit status of child process */ + char *temp; /* used to get basename of dialer */ + + if(argc!=5) + { + fprintf(stderr,kUsage,argv[0],argv[0]); + exit(1); + } + + dialerPath=argv[1]; + dialerName= (temp=strrchr(argv[1],'/'))!=NULL ? temp+1 : argv[1]; + + parent=getpid(); + + signal(SIGUSR1,badExec); /* set up for possible failed exec */ + + if((child=fork())<0) + { + perror("fork"); + exit(2); + } + if(child>0) /* We're parent, wait for child to exit */ + { + /* Set up to ignore signals so we can report them on stderror */ + signal(SIGHUP,SIG_IGN); + signal(SIGINT,SIG_IGN); + signal(SIGTERM,SIG_IGN); + + wait(&stat); /* wait for child to exit */ + exit(figureStat(stat)); /* figure out our exit code and die */ + } + else /* child process */ + { + close(0); /* close of modem file desc, since HDB */ + close(1); /* doesn't use them */ + dup2(2,1); /* and remap stdout to stderr, just in case */ + if(execvp(argv[1],argv+1)<0) /* exec program with argv shifted by 1 */ + { /* if exec fails, send SIGUSR1 to parent */ + kill(parent,SIGUSR1); + exit(0); + } + } + exit(0); +} + +/* Figure out whether or not dialer ran succesfully, and return +with 0 if it worked, otherwise error */ +int figureStat(int stat) +{ + int exit; + int errFlag; + int error; + + if(WIFSIGNALED(stat)) /* determine if exit was from signal or what */ + { + fprintf(stderr,"Error: Dialer %s recieved signal %d.\n",dialerName, + WTERMSIG(stat)); + return(1); + } + if(WIFSTOPPED(stat)) + { + fprintf(stderr,"Error: Dialer %s recieved signal %d.\n",dialerName, + WSTOPSIG(stat)); + return(1); + } + exit=WEXITSTATUS(stat); + + errFlag=exit&kExitErrFlag; /* Is the error flag set? */ + if(errFlag) + { + char *errString; + + error=exit&kErrorMask; + errString=findInTable(error); /* find it's string, print it on stderr */ + fprintf(stderr,"Error: %s - %s.\n",dialerName,errString); /* and return */ + return(1); + } + return(0); +} + +/* Support routine, look up exit code in error table, and return pointer +to proper string */ +char *findInTable(int error) +{ + int i=0; + + for(i=0;errors[i].errString!=NULL;i++) + { + if(errors[i].errNum==error) + return(errors[i].errString); + } + /* Still here, return the top entry, for unknown error */ + return(errors[0].errString); +} + +/* Called by signal if we recieve SIGUSR 1 */ +void badExec(void) +{ + fprintf(stderr,"Error: %s - Execution problem.\n",dialerPath); + exit(1); +} diff --git a/gnu/libexec/uucp/contrib/uucomp.shar b/gnu/libexec/uucp/contrib/uucomp.shar new file mode 100644 index 00000000000..da131d048c5 --- /dev/null +++ b/gnu/libexec/uucp/contrib/uucomp.shar @@ -0,0 +1,552 @@ +#! /bin/sh +# +# Created by shar, version 0.5 - 04/10/91 +# +# This is a shell archive, meaning: +# 1. Remove everything about the #! /bin/sh line. +# 2. Save the resulting text in a file. +# 3. Execute the file with /bin/sh to create: +# +# length name +# ------ ------------------------------------- +# 128 uucomp-1.1/Compress +# 264 uucomp-1.1/Copyright +# 410 uucomp-1.1/INTERNALS +# 1069 uucomp-1.1/Makefile +# 3528 uucomp-1.1/README +# 632 uucomp-1.1/crmail.c +# 632 uucomp-1.1/crnews.c +# 108 uucomp-1.1/tags +# 3506 uucomp-1.1/uucomp.c +# 383 uucomp-1.1/uucomp.h +# + +if test ! -d uucomp-1.1 ; then + mkdir uucomp-1.1 +fi +# +# Archive number 1 +# This archive created Tue Sep 28 20:21:14 1993 +# + +echo "shar: extracting uucomp-1.1/Compress - (128 characters)" +if test -f 'uucomp-1.1/Compress' ; then + echo shar: will not over-write existing file uucomp-1.1/Compress +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Compress' +Xfor i in $* +Xdo +X if [ -d /usr/spool/uucp/$i ] +X then +X# echo Looking at $i +X cd /usr/spool/uucp/$i +X /usr/bin/uucomp C.* +X fi +Xdone +SHAR_EOF +if test 128 -ne "`wc -c < 'uucomp-1.1/Compress'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/Compress (should have been 128 characters, but was "`wc -c < 'uucomp-1.1/Compress'`" characters) *****" +fi +fi + +touch 0715110393 uucomp-1.1/Compress +chmod 0700 uucomp-1.1/Compress + +echo "shar: extracting uucomp-1.1/Copyright - (264 characters)" +if test -f 'uucomp-1.1/Copyright' ; then + echo shar: will not over-write existing file uucomp-1.1/Copyright +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Copyright' +X +X/* +X * +X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved. +X * +X * Permission is hereby granted for any non-commercial use of this +X * program, as long as this copyright notice remains intact. Commercial +X * users may contact me - I'm easy. +X * +X */ +X +SHAR_EOF +if test 264 -ne "`wc -c < 'uucomp-1.1/Copyright'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/Copyright (should have been 264 characters, but was "`wc -c < 'uucomp-1.1/Copyright'`" characters) *****" +fi +fi + +touch 0715174993 uucomp-1.1/Copyright +chmod 0600 uucomp-1.1/Copyright + +echo "shar: extracting uucomp-1.1/INTERNALS - (410 characters)" +if test -f 'uucomp-1.1/INTERNALS' ; then + echo shar: will not over-write existing file uucomp-1.1/INTERNALS +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/INTERNALS' +XThis is the basic workflow for uucomp: +X +Xfor (every argv) +Xdo +X if not "C." file skip +X if open fail, skip +X read 1 line from C. file +X grab second and 10th field (second is data file name, +X 10th is command name) +X if open fail on second field, skip +X if 10th field isn't "rmail" or "rnews", skip +X execute "gzip -9" on second field +X change "rmail" and "rnews" to "crmail" and "crnews", respectively +X in C. file +Xdone +SHAR_EOF +if test 410 -ne "`wc -c < 'uucomp-1.1/INTERNALS'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/INTERNALS (should have been 410 characters, but was "`wc -c < 'uucomp-1.1/INTERNALS'`" characters) *****" +fi +fi + +touch 0715174693 uucomp-1.1/INTERNALS +chmod 0600 uucomp-1.1/INTERNALS + +echo "shar: extracting uucomp-1.1/Makefile - (1069 characters)" +if test -f 'uucomp-1.1/Makefile' ; then + echo shar: will not over-write existing file uucomp-1.1/Makefile +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/Makefile' +X# +X# Makefile generated with genmake - version 1.1 08/22/92 +X# +X# genmake is Copyright 1991 by Edwin R. Carp +X# +X# GENMAKE -B/usr/bin -tsp [files] +X# +X +XCC = gcc -O6 +XCFLAGS = $(INCLUDE) +XSOURCES = crmail.c crnews.c uucomp.c +XOBJECTS = crmail.o crnews.o uucomp.o +XPROGRAMS = /usr/bin/crmail /usr/bin/crnews /usr/bin/uucomp +X +Xall: $(PROGRAMS) tags +X +X/usr/bin/crmail: crmail.o +X $(CC) $(CFLAGS) -o crmail crmail.o $(LDFLAGS) -O +X strip crmail +X chmod 755 crmail +X mv crmail /usr/bin +X +X/usr/bin/crnews: crnews.o +X $(CC) $(CFLAGS) -o crnews crnews.o $(LDFLAGS) -O +X strip crnews +X chmod 755 crnews +X mv crnews /usr/bin +X +X/usr/bin/uucomp: uucomp.o +X $(CC) $(CFLAGS) -o uucomp uucomp.o $(LDFLAGS) -O +X strip uucomp +X chmod 755 uucomp +X mv uucomp /usr/bin +X +Xclean: +X /bin/rm -f $(OBJECTS) MAKELOG eddep makedep +X +Xclobber: +X /bin/rm -f $(OBJECTS) $(PROGRAMS) MAKELOG eddep makedep *~ *.bak *.BAK +X /bin/rm -f tags +X +Xhidden: +X echo "make all > MAKELOG 2>&1 &"|/bin/sh +X +Xmakefile: +X genmake -B/usr/bin -tsp $(SOURCES) & +X +Xmakeall: +X genmake -B/usr/bin -tsp *.c & +X +Xtags: $(SOURCES) +X ctags $(SOURCES) > tags +X +SHAR_EOF +if test 1069 -ne "`wc -c < 'uucomp-1.1/Makefile'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/Makefile (should have been 1069 characters, but was "`wc -c < 'uucomp-1.1/Makefile'`" characters) *****" +fi +fi + +touch 0714235093 uucomp-1.1/Makefile +chmod 0600 uucomp-1.1/Makefile + +echo "shar: extracting uucomp-1.1/README - (3528 characters)" +if test -f 'uucomp-1.1/README' ; then + echo shar: will not over-write existing file uucomp-1.1/README +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/README' +XLike most people these days, I'm looking for ways to make my computing +Xenvironment more efficient. This environment consists of a 486, a 386, +Xand a 386SL laptop, all of which run Taylor uucp under Linux. The 386 +Xlaptop gets used a lot, since it goes wherever I go and I answer a lot +Xof news and email every day. Often, I must use other people's facilities +X(phone lines and such) to send out replies and post news if I'm not at home. +XSince it's not fair to the client for them to pay for my zone calls back +Xto my home in Fremont, I place the calls on my phone card. Unfortunately, +XPacBell is very proud of the services they offer, especially in regards +Xto this convenience of automatically charging calls to my house wherever I +Xmay be. Considering that this can be very expensive to do, I searched for +Xa way to cut my phone bill down to something I could afford to pay each +Xmonth without fainting every time I saw the bill. +X +XThe first thing I did was to go out and plunk $195 for a 14.4KB modem. +XThat helped, but C-News is very slow on my laptop, and batching articles +Xis even slower, and email (of course) isn't batched at all. Even with +XMNP5 compression turned on, this doesn't make for a very efficient setup, +Xeven at high speeds. +X +XPlaying around with uucp told me that the line turnaround wasn't that much +Xoverhead, nor was sending the C./X. files (the execute files) - the real +Xoverhead was sending out uncompressed news and especially email, since +XI subscribe to several mailing lists and digests can run quite large. +X +XI looked at uubatch, but the most current version I could find (1.05) was +Xnot compatible with Taylor uucp (and I had no other alternative), so I +Xdecided to write my own. Experiments with "gzip -9" convinced me that +Xthat was the way to go, since gzip gives email and news 60 to 75 percent +Xcompression, which would tend to cut one's phone bill significantly. +X +XYou hold in your mailbox (or news reader) the end result of that effort. +XBear in mind that (1) this is a "first cut" and while it is unlikely that +Xthere are very many bugs, there are certainly places where the programs could +Xbe improved and tuned. Suggestions and comments are welcome! +X +XTo install: +X +X 1. Feed this to shar. +X 2. Look at the Makefile. Make sure that the paths for +X things are set up correctly. +X 3. Look at uucomp.h and make sure that the path and +X options for COMPRESS/UNCOMPRESS are set up properly. +X 3. Type "make". This will make uucomp, crmail, and crnews +X and will place them in /usr/bin. Move Compress into +X /usr/lib/uucp. +X 4. Make an entry in crontab to do +X /usr/lib/uucp/Compress site1 site2 site3... +X occasionally. It is suggested that this be done fairly +X frequently. Alternately, you could set up a login shell +X for selected sites to run uucomp every time that site +X logged in. +X 5. Don't forget to add /usr/bin/crmail and /usr/bin/crnews +X to the list of programs allowed to be executed in your +X Permissions file (if running HDB UUCP), or whatever is +X appropriate for your version of uucp. +X +XEnjoy! Any questions or comments can be sent to erc@apple.com. +X +XNote: This is tuned for Taylor uucp, but would not be particularly +Xdifficult to adapt to other version of uucp. See the file INTERNALS for +Xdetails of how this works. +X +XJuly 15, 1993 +XEd Carp +Xerc@apple.com +X------------------------------------------------------------------------------ +XChanges since 1.0: +X +X Version Date Description +X +X 1.1 08/04/93 Added sanity check in C. file (check that +X 'E' is first char in file, otherwise skip) +SHAR_EOF +if test 3528 -ne "`wc -c < 'uucomp-1.1/README'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/README (should have been 3528 characters, but was "`wc -c < 'uucomp-1.1/README'`" characters) *****" +fi +fi + +touch 0804224993 uucomp-1.1/README +chmod 0600 uucomp-1.1/README + +echo "shar: extracting uucomp-1.1/crmail.c - (632 characters)" +if test -f 'uucomp-1.1/crmail.c' ; then + echo shar: will not over-write existing file uucomp-1.1/crmail.c +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/crmail.c' +X/* +X * crmail - get compressed mail from host, uncompress +X * WARNING: This may be insecure! +X */ +X +X/* +X * +X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved. +X * +X * Permission is hereby granted for any non-commercial use of this +X * program, as long as this copyright notice remains intact. Commercial +X * users may contact me - I'm easy. +X * +X */ +X +X#include <stdio.h> +X#include "uucomp.h" +Xmain (argc, argv) +Xint argc; +Xchar **argv; +X{ +X char cmd[1024]; +X int i; +X +X sprintf (cmd, "%s|%s ", UNCOMPRESS, RMAIL); +X for (i = 1; i < argc; i++) +X { +X strcat (cmd, argv[i]); +X strcat (cmd, " "); +X } +X system (cmd); +X exit (0); +X} +SHAR_EOF +if test 632 -ne "`wc -c < 'uucomp-1.1/crmail.c'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/crmail.c (should have been 632 characters, but was "`wc -c < 'uucomp-1.1/crmail.c'`" characters) *****" +fi +fi + +touch 0715195493 uucomp-1.1/crmail.c +chmod 0600 uucomp-1.1/crmail.c + +echo "shar: extracting uucomp-1.1/crnews.c - (632 characters)" +if test -f 'uucomp-1.1/crnews.c' ; then + echo shar: will not over-write existing file uucomp-1.1/crnews.c +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/crnews.c' +X/* +X * crnews - get compressed news from host, uncompress +X * WARNING: This may be insecure! +X */ +X +X/* +X * +X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved. +X * +X * Permission is hereby granted for any non-commercial use of this +X * program, as long as this copyright notice remains intact. Commercial +X * users may contact me - I'm easy. +X * +X */ +X +X#include <stdio.h> +X#include "uucomp.h" +Xmain (argc, argv) +Xint argc; +Xchar **argv; +X{ +X char cmd[1024]; +X int i; +X +X sprintf (cmd, "%s|%s ", UNCOMPRESS, RNEWS); +X for (i = 1; i < argc; i++) +X { +X strcat (cmd, argv[i]); +X strcat (cmd, " "); +X } +X system (cmd); +X exit (0); +X} +SHAR_EOF +if test 632 -ne "`wc -c < 'uucomp-1.1/crnews.c'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/crnews.c (should have been 632 characters, but was "`wc -c < 'uucomp-1.1/crnews.c'`" characters) *****" +fi +fi + +touch 0715195593 uucomp-1.1/crnews.c +chmod 0600 uucomp-1.1/crnews.c + +echo "shar: extracting uucomp-1.1/tags - (108 characters)" +if test -f 'uucomp-1.1/tags' ; then + echo shar: will not over-write existing file uucomp-1.1/tags +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/tags' +Xmain crmail.c /^main (argc, argv)$/ +Xmain crnews.c /^main (argc, argv)$/ +Xmain uucomp.c /^main (argc, argv)$/ +SHAR_EOF +if test 108 -ne "`wc -c < 'uucomp-1.1/tags'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/tags (should have been 108 characters, but was "`wc -c < 'uucomp-1.1/tags'`" characters) *****" +fi +fi + +touch 0804224993 uucomp-1.1/tags +chmod 0600 uucomp-1.1/tags + +echo "shar: extracting uucomp-1.1/uucomp.c - (3506 characters)" +if test -f 'uucomp-1.1/uucomp.c' ; then + echo shar: will not over-write existing file uucomp-1.1/uucomp.c +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/uucomp.c' +X/* +X * uucomp - compress outgoing news/mail +X * +X * usage: uucomp C.* +X * +X * This works for Taylor uucp (available from prep.ai.mit.edu:/pub/gnu/uucp*), +X * but I don't promise it works for anyone else's uucp package. Basically, this +X * is a quick-n-dirty hack to get compressed mail and news to a uucp site. This +X * becomes important when you're on the other end of a 1200 baud packet radio +X * link, where the throughput can be 60 CPS (or lower). It also tends to hide +X * any nasties that people might want to say to you, since the packets *are* +X * public readable. Yes, I looked at uubatch, but it was too complicated for +X * me to figure out <grin>, and it didn't work with Taylor-uucp. This is almost +X * too simple to work... +X * +X * To use this little guy, do something like this in the .bashrc or .profile +X * or .cshrc of the uucp's login shell: +X * +X * cd /usr/spool/uucp/<wherever the C. and D. files are kept> +X * /usr/bin/uucomp C.* +X * exec /usr/lib/uucp/uucico +X * +X * This program was written by Ed Carp (erc@apple.com). It can be used for any +X * non-commercial purpose. This software is freely redistributable. +X */ +X +X/* +X * +X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved. +X * +X * Permission is hereby granted for any non-commercial use of this +X * program, as long as this copyright notice remains intact. Commercial +X * users may contact me - I'm easy. +X * +X */ +X +X#include <stdio.h> +X#include "uucomp.h" +X#undef NULL +X#define NULL (0) +Xmain (argc, argv) +Xint argc; +Xchar **argv; +X{ +X int i, j, sw, ctr = 0, errflag = 0, mctr = 0, nctr = 0, skipctr = 0; +X char scr[64], rcmd[10], line[1024], lineout[1024]; +X char *strtok (), *ptr, *lineptr, compfile[32]; +X FILE *in; +X +X printf ("uucomp 1.1 08/04/93 ... by erc@apple.com\nscanning %d files.", argc - 1); +X for (i = 1; i < argc; i++) +X { +X if (strncmp (argv[i], "C.", 2) != 0) +X { +X skipctr++; +X continue; +X } +X if ((in = fopen (argv[i], "r+")) == (FILE *) NULL) +X { +X skipctr++; +X continue; +X } +X fgets (line, 1022, in); +X if(*line != 'E') +X { +X skipctr++; +X continue; +X } +X line[strlen (line) - 1] = NULL; +X rewind (in); +X *lineout = NULL; +X lineptr = line; +X sw = errflag = 0; +X printf ("."); +X fflush (stdout); +X for (j = 0;; j++) +X { +X ptr = strtok (lineptr, " "); +X if (ptr == NULL) +X break; +X lineptr = NULL; +X if (j == 1) +X { +X if (access (ptr, 4) == EOF) +X { +X#ifdef DEBUG +X printf ("skip: file '%s' doesn't exist\n", ptr); +X#endif +X errflag = 1; +X break; /* +X * skip it if the data file isn't +X * there yet +X */ +X } +X strcpy (compfile, ptr); +X } +X if (j == 9) +X { +X if (strcmp (ptr, "rmail") != 0 && strcmp (ptr, "rnews") != 0) +X { +X#ifdef DEBUG +X printf ("skip: '%s' wrong command\n", ptr); +X#endif +X errflag = 1; +X break; +X } +X if (strcmp (ptr, "rmail") == 0) +X mctr++; +X if (strcmp (ptr, "rnews") == 0) +X nctr++; +X sw = 1; +X strcat (lineout, "c"); +X } +X strcat (lineout, ptr); +X strcat (lineout, " "); +X } +X if (errflag == 1) +X { +X skipctr++; +X fclose (in); +X continue; +X } +X fprintf (in, "%s\n", lineout); +X fclose (in); +X sprintf (line, +X "%s -fc > /tmp/uucomp.%d < %s;cp /tmp/uucomp.%d %s", +X COMPRESS, getpid (), compfile, getpid (), compfile); +X system (line); +X ctr++; +X } +X sprintf (line, "/tmp/uucomp.%d", getpid ()); +X unlink (line); +X printf ("\n%d skipped, %d compressed (%d mail, %d news).\n", +X skipctr, ctr, mctr, nctr); +X exit (0); +X} +SHAR_EOF +if test 3506 -ne "`wc -c < 'uucomp-1.1/uucomp.c'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/uucomp.c (should have been 3506 characters, but was "`wc -c < 'uucomp-1.1/uucomp.c'`" characters) *****" +fi +fi + +touch 0804224693 uucomp-1.1/uucomp.c +chmod 0600 uucomp-1.1/uucomp.c + +echo "shar: extracting uucomp-1.1/uucomp.h - (383 characters)" +if test -f 'uucomp-1.1/uucomp.h' ; then + echo shar: will not over-write existing file uucomp-1.1/uucomp.h +else +sed 's/^X//' << \SHAR_EOF > 'uucomp-1.1/uucomp.h' +X/* +X * +X * Copyright 1993 by Ed Carp (erc@apple.com) All rights reserved. +X * +X * Permission is hereby granted for any non-commercial use of this +X * program, as long as this copyright notice remains intact. Commercial +X * users may contact me - I'm easy. +X * +X */ +X +X#define COMPRESS "/usr/bin/gzip -9c" +X#define UNCOMPRESS "/usr/bin/gzip -dc" +X#define RMAIL "rmail" +X#define RNEWS "rnews" +SHAR_EOF +if test 383 -ne "`wc -c < 'uucomp-1.1/uucomp.h'`" ; then + echo "shar: ***** error transmitting file uucomp-1.1/uucomp.h (should have been 383 characters, but was "`wc -c < 'uucomp-1.1/uucomp.h'`" characters) *****" +fi +fi + +touch 0715190293 uucomp-1.1/uucomp.h +chmod 0600 uucomp-1.1/uucomp.h +echo End of all shell archives +exit 0 diff --git a/gnu/libexec/uucp/contrib/uudemon.shar b/gnu/libexec/uucp/contrib/uudemon.shar new file mode 100644 index 00000000000..31a8fa60707 --- /dev/null +++ b/gnu/libexec/uucp/contrib/uudemon.shar @@ -0,0 +1,82 @@ +#! /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 shell archive." +# Contents: Poll uudemon.poll +# Wrapped by dburr@sbanet on Fri Jul 23 20:15:18 1993 +PATH=/bin:/usr/bin:/usr/ucb ; export PATH +if test -f 'Poll' -a "${1}" != "-c" ; then + echo shar: Will not clobber existing file \"'Poll'\" +else +echo shar: Extracting \"'Poll'\" \(244 characters\) +sed "s/^X//" >'Poll' <<'END_OF_FILE' +X# HDB-ish poll file +X# +X# Format: <site><tab><hour1> <hour2> ... +X# ONLY ONE TAB BETWEEN FIELDS... more may work, but I have absolutely no +X# idea if it will work at all. +X# +X# comment lines (begin with `#') are ignored. +X +Xdschub 20 21 22 +Xgd 20 21 22 +END_OF_FILE +if test 244 -ne `wc -c <'Poll'`; then + echo shar: \"'Poll'\" unpacked with wrong size! +fi +# end of 'Poll' +fi +if test -f 'uudemon.poll' -a "${1}" != "-c" ; then + echo shar: Will not clobber existing file \"'uudemon.poll'\" +else +echo shar: Extracting \"'uudemon.poll'\" \(941 characters\) +sed "s/^X//" >'uudemon.poll' <<'END_OF_FILE' +X#!/bin/sh +X# +X# This is my impersonation of the HDB uudemon.poll script. +X# Yes, I know, this is very clumsy and clunky... ahh well, I've always +X# been better at C/pascal/etc than Shell programming... :( +X +X# change LIBDIR to where UUCP library/conf. files are +X# change SPOOLDIR to the UUCP spool directory. It must be HDB-ish. +XLIBDIR=/usr/lib/uucp; export LIBDIR +XSPOOLDIR=/usr/spool/uucp; export SPOOLDIR +X +X### no changes needed past here ### +X +XHOUR=`date +%H`; export HOUR +X +Xif [ -f ${LIBDIR}/Poll ]; then +X for SYS in `uuname` +X do +X CHOICES="`grep "^$SYS[ ]" ${LIBDIR}/Poll | awk -F' ' \ +X '{ print $2 }'`" +X DOIT="no" +X for H in $CHOICES +X do +X if [ "$HOUR" = "$H" ]; then +X DOIT="yes" +X fi +X done +X if [ "$DOIT" = "yes" ]; then +X if [ ! -d ${SPOOLDIR}/${SYS} ]; then +X mkdir ${SPOOLDIR}/${SYS} +X fi +X chmod 755 ${SPOOLDIR}/${SYS} +X touch ${SPOOLDIR}/${SYS}/C.${SYS}n0000 +X chmod 644 ${SPOOLDIR}/${SYS}/C.${SYS}n0000 +X fi +X done +Xfi +END_OF_FILE +if test 941 -ne `wc -c <'uudemon.poll'`; then + echo shar: \"'uudemon.poll'\" unpacked with wrong size! +fi +chmod +x 'uudemon.poll' +# end of 'uudemon.poll' +fi +echo shar: End of shell archive. +exit 0 diff --git a/gnu/libexec/uucp/contrib/uupoll.shar b/gnu/libexec/uucp/contrib/uupoll.shar new file mode 100644 index 00000000000..ece8e3d2a2a --- /dev/null +++ b/gnu/libexec/uucp/contrib/uupoll.shar @@ -0,0 +1,2696 @@ +#!/bin/sh +# This is a shell archive (produced by shar 3.49) +# To extract the files from this archive, save it to a file, remove +# everything above the "!/bin/sh" line above, and type "sh file_name". +# +# made 04/17/1994 02:21 UTC by ian@comton.airs.com +# Source directory /disk4/ian +# +# existing files will NOT be overwritten unless -c is specified +# +# This shar contains: +# length mode name +# ------ ---------- ------------------------------------------ +# 2602 -r--r--r-- uupoll/Makefile +# 3636 -r--r--r-- uupoll/README +# 4718 -r--r--r-- uupoll/autopoll.8c +# 44031 -r--r--r-- uupoll/autopoll.c +# 3884 -r--r--r-- uupoll/conf.h +# 4787 -r--r--r-- uupoll/uupoll.8c +# 27587 -r--r--r-- uupoll/uupoll.c +# +# ============= uupoll/Makefile ============== +if test ! -d 'uupoll'; then + echo 'x - creating directory uupoll' + mkdir 'uupoll' +fi +if test -f 'uupoll/Makefile' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/Makefile (File already exists)' +else +echo 'x - extracting uupoll/Makefile (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/Makefile' && +# This is the Makefile for uupoll and autopoll +# borrowed and hacked from Taylor UUCP 1.04 +X +# Prefix directory for installation directories. +prefix = /usr/local +X +# The user name/group that should own the resulting executables. +# Both should run suid. +owner = uucp.daemon +X +# Which mode should the resulting executables have. +emode = 4111 +X +# Where to install autopoll. This definition requires $(prefix)/lib to exist. +lbindir = $(prefix)/lib/uucp +X +# Where are the sources from uucp-Taylor uucp.h, uuconf.h, policy.h. +# the following assumes that our sources are in uucp-1.05/contrib/uupoll +# and the required .h files are in main directory for uucp-1.05 +uucpsrcs = ../../ +X +# Where to install uupoll +bbindir = $(prefix)/bin +X +# Where to install man pages. Section 8 for daemons. +man8dir = $(prefix)/man/man8 +man8ext = .8c +X +# Define programs and flags +CC = gcc +CFLAGS = -O2 +LDFLAGS = -s +LIBS = +X +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 +X +# +# Nothing else to configure +# +X +SHELL = /bin/sh +X +VERSION = 1.00 +X +MORECFLAGS = -I. -I$(uucpsrcs) -Wall +X +PROGRAMS = uupoll autopoll +X +UUPOLLOBJS = uupoll.o +AUTOOBJS = autopoll.o +X +ALLOBJS = uupoll.o autopoll.o +X +all: $(PROGRAMS) +X +install: $(PROGRAMS) +X if test -d $(lbindir); then true; else mkdir $(lbindir); fi +X if test -d $(bbindir); then true; else mkdir $(bbindir); fi +X -if test -f $(lbindir)/autopoll.old; then rm -f $(lbindir)/autopoll; else mv $(lbindir)/autopoll $(lbindir)/autopoll.old; fi +X -if test -f $(bbindir)/uupoll.old; then rm -f $(bbindir)/uupoll; else mv $(bbindir)/uupoll $(bbindir)/uupoll.old; fi +X $(INSTALL_PROGRAM) autopoll $(lbindir)/autopoll +X $(INSTALL_PROGRAM) uupoll $(bbindir)/uupoll +X chown $(owner) $(lbindir)/autopoll $(bbindir)/uupoll +X chmod $(emode) $(lbindir)/autopoll $(bbindir)/uupoll +X $(INSTALL_DATA) uupoll.8c $(man8dir)/uupoll$(man8ext) +X $(INSTALL_DATA) autopoll.8c $(man8dir)/autopoll$(man8ext) +X +uninstall: +X rm -f $(lbindir)/autopoll $(bbindir)/uupoll +X rm -f $(man8dir)/autopoll$(man8ext) $(man8dir)/uupoll$(man8ext) +X -cp $(lbindir)/autopoll.old $(lbindir)/autopoll +X -cp $(bbindir)/uupoll.old $(bbindir)/uupoll +X -chown $(owner) $(lbindir)/autopoll $(bbindir)/uupoll +X -chmod $(emode) $(lbindir)/autopoll $(bbindir)/uupoll +X +uupoll: $(UUPOLLOBJS) +X $(CC) $(LDFLAGS) -o uupoll $(UUPOLLOBJS) $(LIBS) +X +autopoll: $(AUTOOBJS) +X $(CC) $(LDFLAGS) -o autopoll $(AUTOOBJS) $(LIBS) +X +.c.o: +X $(CC) -c $(CFLAGS) $(MORECFLAGS) $< +X +X +clean: +X rm -f $(ALLOBJS) $(PROGRAMS) +X +mostlyclean: clean +X +TAGS: +X etags *.h *.c +X +# Header file dependencies. These are maintained by hand. +X +$(ALLOBJS): conf.h +X +.NOEXPORT: +SHAR_EOF +chmod 0444 uupoll/Makefile || +echo 'restore of uupoll/Makefile failed' +Wc_c="`wc -c < 'uupoll/Makefile'`" +test 2602 -eq "$Wc_c" || + echo 'uupoll/Makefile: original size 2602, current size' "$Wc_c" +fi +# ============= uupoll/README ============== +if test -f 'uupoll/README' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/README (File already exists)' +else +echo 'x - extracting uupoll/README (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/README' && +X +The package consists of the following files: +X +X - autopoll.c +X - autopoll.8c +X - conf.h +X - Makefile +X - README +X - uupoll.c +X - uupoll.8c +X +CAVEAT: +uupoll as well as autopoll are created, tested and run on +a NeXT running NeXTstep 2.1+ only! Autopoll will take the same arguments +as uucico and may well work with them the same way uucico works but it +has only been tested to call uucico with the options: +X +X -s<site> -S<site> -f -r1 -C -D (as well as the long form of these options) +X +so far. All options given to autopoll will be passed verbatim to uucico. +X +DESCRIPTION: +The program uupoll was created to be a full replacement for the vendor +supplied one on a NeXT computer. That uupoll checked any site name against +the "hardwired" L.sys and did end with a "Bus error" if the site could not +be found. There was no source available to modify so it had to be created +from scratch. +The program autopoll has no equivalent an the NeXT. The intentions behind +it was to automate the task of rescheduling any failed call. It may be +started by an entry in the crontab tables in just the same way uucico is +started (it will start uucico): +X +05 5 * * * uucp /usr/local/lib/uucp/autopoll -r1 >>/tmp/poll.log 2>&1 +X +Any messages go to stderr or a file (if compiled with that option); in case +the file could not be opened it will use stdout to tell you just that and quit. +To catch any output one may place the string +X +X >>/tmp/poll.log 2>&1 +X +into the command line as well. Uupoll as well as autopoll will place only +a start message into the logfiles in case they are invoked manually from +the shell. +If the call fails autopoll will reschedule uucico for a later time by means +of an AT job. +The messages given by uupoll and autopoll carry an indicator to inform about +the nature of an error; they are: +X +- (I) informal message; such as ".. started" ".. ended". +- (W) there might be an error but the program decided to go ahead. +X The exit code will be at least 4. +- (E) a severe error was encountered that either aborts the whole run or +X only the task for one site will be aborted. +X The exit code will be at least 8. +- (C) a catastrophic error has been found such as unable to fork. The run +X is aborted. +X The exit code will be at least 16. +The final message will show the exit code the programm has terminated with. +X +For more information see the man pages or look into the source. +X +INSTALLATION: +all files should be placed in one folder. Then examine and change the files +Makefile and conf.h to meet your needs. To compile uupoll some files of +uucp must be available (see Makefile: uucpsrcs) +If not already there change to the directory which contain the files and type: +X +make +X +this should compile UUPOLL and AUTOPOLL. There should only be a warning +that rcsid is defined but not used. +Before actually installing you should test the programs to be working as +desired. +Then check the Makefile for the final placement of the modules and the man +pages. Make sure the ownership and setuid is what you need on your machine +to run the program(s). +Then su to root and type: +X +make install +X +which should install the above programs and the man pages in the appropriate +directories. +Some word on the coding: have mercy! This is my second project in 'C'; any +suggestions that may improve the style/coding are welcome however. +X +In case of any problems that can't be solved feel free to contact the +author at: +X +Klaus Dahlenburg Timezone : GMT + 2 +P.O.Box 1267 email : kdburg@incoahe.hanse.de +D-21249 Tostedt Fax : +49 4287 676 +X Germany Voice : +49 4287 681 +X +Have fun! +SHAR_EOF +chmod 0444 uupoll/README || +echo 'restore of uupoll/README failed' +Wc_c="`wc -c < 'uupoll/README'`" +test 3636 -eq "$Wc_c" || + echo 'uupoll/README: original size 3636, current size' "$Wc_c" +fi +# ============= uupoll/autopoll.8c ============== +if test -f 'uupoll/autopoll.8c' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/autopoll.8c (File already exists)' +else +echo 'x - extracting uupoll/autopoll.8c (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/autopoll.8c' && +.\" +.\" @(#)autopoll.8c 1.4 (incoahe) 5/09/1993 +.\" +.TH AUTOPOLL 8C "May 09, 1993" +.UC 6 +.SH NAME +autopoll \- automatic \s-1UUCP\s+1 file transfer supervisor +.SH SYNOPSIS +.B autopoll +[ +.BI options +] +.SH DESCRIPTION +file transfer requests placed by +.IR uucp (1) +or +.IR uux (1) +are handled by +.IR uucico (8C). +.IR uucico +will be invoked immediately by the above programs unless the \-r +option is given which queues the request for later processing. This +is typically done by entries in the +.IR crontab +table(s) which will invoke +.IR uucico. +.IR uucico +can also be invoked by +.IR uupoll (8C). +All methods have in common that there is no automatic retry by +.IR uucico +itself in case the call failed for some reason. +Either manual +intervention or some sort of scripts must be used to overcome this +limitation. +.PP +.IR Autopoll +can be used to automate up to a certain degree the task of rescheduling +a call. None of the standard programs already mentioned need to be +modified to get this working. Also not recommended (see BUGS section) +.IR uucico +may be an alias to +.IR autopoll +as all arguments passed to +.IR autopoll +will be copied verbatim to +.IR uucico. +In case this is done by link or other means the original +.I uucio +must still be available in a directory outside of the normal search path +otherwise +.I autopoll +can't do what it's intended to do and will form a loop. +.PP +When +.IR autopoll +is called thre will be a check on the \-s, \-S and \-f option to +see whether this +is a specific call or not. Also the \-S and the \-f option must be checked +to determine the type of call: honor any imposed wait for a site or not. +Any call to ourself or to an unknown site will be refused. The known sites +will be obtained by a call to +.IR uuname(1). +All other options will not be checked in any way. Next to this +.IR uucico +is called and the exit code is checked for a `1' which indicates that the call +failed for some reason whatsoever. A `0' exit code will be interpreted as +a success and +.IR autopoll +ends immediate. If the call seems to be unsuccessful a new call is scheduled +for any site whose .Status files have a retry period greater than 0. The +retry will be scheduled by means of placing an +.IR at +job at the time of the failing call plus any wait time given. For those +sites that have been called with either the \-f or \-S option the retry +time will be the time of the failing call plus 120 seconds. +.PP +In case the time calculated from the values found in a \.Status file is +lower than the current time, the current time plus 60 seconds will be taken +as the retry time. +.PP +A site will +.IR not +be automatically called again if one of the following +conditions is met: +.PP +\- +.IR uucico +is terminated by a signal +.PP +\- either fork() or exec() failed +.PP +\- the +.IR at +command failed for any reasons. +.PP +\- if no wait should be honored and the retry time is found to be zero. +(this may indicate a `Wrong time to call' condition. +.PP +There are other circumstances that may lead to not reschedule a call or +not to call +.IR uucico +at all, all of which should be accompanied by (a) self explanatory message(s). +.SH BUGS +\- invalid options will make +.IR uucico +fail. The exit code for this type is the same as for any other failure; this +can reschedule the call over and over again or never. +.PP +\- +.IR autopoll +may not work as expected when called with options other than \-r1, \-s, +\-S or \-f. +.PP +\- a rescheduled call may fail with `wrong time to call' the second time +but will be rescheduled again. The times to call won't be checked by +.IR autopoll +and the .Status file may not indicate this in case the \-c option is given. +.PP +\- in case the ..._DIR points to an invalid file a `Bus error' my pop up +during the `exec' call. +.PP +\- the `chat-timeout' value may have to be increased when using +.IR autopoll. +An indication to do that is that the call fails short after `CONNECT' +has been received with `Time out in chat script'. +.PP +\- the site names given will be checked aginst the output of +.I uuname +without any alias expansion done. +.PP +\- the text strings whithin the \.Status files will not be used to detect +a failing call. +.SH FILES +.nf +/usr/local/lib/uucp UUCP internal utilities +/usr/lib/uucp +/usr/local/bin UUCP internal utilities +/usr/bin +/usr/spool/uucp/.Status/ Status files for each site +/usr/spool/uucp/ UUCP spool area. one of its sub- +X directories will hold the null jobs. +/tmp/poll.log This file is present only if autopoll +X has been compiled to place the messages +X into a file. Otherwise all messages will +X go to stderr. The directory as well as +X the name may be different. +.fi +.SH SEE ALSO +uucp(1C), uux(1C), uucico(8C), uupoll(8C), uuname(1C), sort(1), uniq(1), +at(1) +SHAR_EOF +chmod 0444 uupoll/autopoll.8c || +echo 'restore of uupoll/autopoll.8c failed' +Wc_c="`wc -c < 'uupoll/autopoll.8c'`" +test 4718 -eq "$Wc_c" || + echo 'uupoll/autopoll.8c: original size 4718, current size' "$Wc_c" +fi +# ============= uupoll/autopoll.c ============== +if test -f 'uupoll/autopoll.c' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/autopoll.c (File already exists)' +else +echo 'x - extracting uupoll/autopoll.c (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/autopoll.c' && +/* ---------------------------------------------------------------------------* +X +X Name: autopoll +X +X Author: Klaus Dahlenburg <kdburg@incoahe.hanse.de> +X +X Status: Public domain +X +X Copyright: none; claiming it to be your work will adversly affect +X your image to be a good programmer. +X +X Function: Autopoll may be called just as uucico is called. The difference +X is that autopoll will call uucico and if the return code is +X not zero a check is made on the status files to see which site's +X call failed. Those sites will be called again at that time found +X in the status file plus any imposed wait. The next call will be +X scheduled via an at job which in turn is handled by cron. +X Atrun depends on the scheduling granularity of cron so the +X actual times may be later than planned. +X Autopoll will check the options -f and -s (-S) as well as the name +X of the site passed. All other options will be passed unchecked. +X The -f and -S options will indicate to autopoll that any wait +X to call a site should be ignored; if the call fails the next +X call to those sites will be at the current time plus 120 secs. +X When the time found plus any wait evaluates to a time that +X passed already the next call will be the current time plus 60 +X secs. The name of the site if given must be a valid one and not +X the host itself otherwise it will be ignored. +X +X Call: autopoll [ options ] +X +X all option that apply to uucico may be given and +X will be passed verbatim. See man uucico(8). +X +X Environment: NeXT 2.1+, Taylor UUCP-1.04+ +X +X I/O: stdin: unused. +X stdout: used only when ALOG_DIR is defined and the file +X can't be opened. It will be a single message to tell +X just that and the run is aborted. +X stderr: all messages go here. +X If ALOG_DIR is defined (see conf.h) all messages will +X be appended to a file autopoll.msglog in that +X directory; the file will be created automatically if +X necessary; a redirection is then no longer possible. +X Needs access to .Status files (see Comments later on). +X +X Called Programs: sort, uniq, uucico, uuname, at +X +X Compile: no special options are needed. Compiled with gcc 2.3.3 -O2. +X Compile with the supplied cc might produce erroneous code +X for the check options switch case 's' code: the break inside +X the first if (..) {... break} is ignored. +X +X Comments: - should run setuid UUCP or whatever userid is necessary to +X access (RDONLY) the .Status files and to run the programs +X named under "Called Programs" above. +X - No alias expansion is done on the given names for the +X check against uuname's output.. +X - Invalid arguments will yield in an exit code > 0 as do +X "normal" failures. It may therefore happen that a site +X is called at the intervals with the same invalid arguments. +X - "Wrong time to call" is not handled properly and may +X call the site at the intervals until the time ban is lifted. +X - human action is necessary as we can't distinguish between +X "normal" failures and "errors" such as wrong password, +X number to dial etc. The logs should be checked periodically. +X - if CICO_DIR points to a non existent program the run may +X end with signal 10: Bus Error. +X - is has been observed that uucico will time out with "Dial +X failed" when called via autopoll; setting chat-timeout to +X value of 40 cured that problem. +X - no rescheduling is done in case uucico fails and this +X is not reported in the .Status file, one should check +X the uucico log; this is to the fact that autopoll will +X not scan the uucico log. +*/ +X +X +#if !defined(lint) +static char rcsid[] = "$Id: uupoll.shar,v 1.1 1994/10/24 22:17:53 jtc Exp $"; +#endif /* not lint */ +X +/* $Log: uupoll.shar,v $ +/* Revision 1.1 1994/10/24 22:17:53 jtc +/* Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl). +/* +X * Revision 2.8 1994/04/14 17:22:54 kdburg +X * corrected misspelled AT_OPTION +X * +X * Revision 2.7 1994/04/11 20:15:48 kdburg +X * major rework done; honor now some of the new option taht came with +X * uucp-1.05 +X * +X * Revision 2.6 1994/03/26 17:40:30 kdburg +X * added support for UNAME_DIR; cleanup of some code; adjusted code after +X * obtaining sitenames via popen() +X * +X * Revision 2.5 1993/07/07 16:49:02 kdburg +X * when used interactivly only the start msg is put into the msg-log +X * so far defined (UULOG) +X * +X * Revision 2.4 1993/06/26 16:17:51 kdburg +X * the -S option wasn't propagated to the command passed to the at pgm +X * +X * Revision 2.3 1993/05/25 12:05:01 kdburg +X * added error check on gettimeofday; added comment in the note section; +X * minor changes not affection code +X * +X * Revision 2.2 1993/05/17 20:47:05 kdburg +X * execution of at cmd also ok always said failed... +X * +X * Revision 2.1 1993/05/16 21:49:13 kdburg +X * changed exit() to _exit() in case the exec fails within child +X * +X * Revision 2.0 1993/05/16 14:12:05 kdburg +X * initial revision +X * */ +X +#define CAT 16 +#define SEVERE 8 +#define WARNING 4 +#define OK 0 +/* Boolean types */ +typedef int bool; +#undef TRUE +#undef FALSE +#define TRUE (1) +#define FALSE (0) +X +#include "conf.h" +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <ctype.h> +#include <pwd.h> +#include <unistd.h> +#include <sys/file.h> +#include <sys/time.h> +#include <sys/param.h> +#include <sys/wait.h> +X +#ifdef ALOG_FILE +X static char Msg_Log[] = ALOG_FILE; /* name of msglog filename */ +#endif +X +#ifdef UNAME_DIR +X static char subcmd[] = " | sort | uniq"; /* pipe that follows uuname */ +#else /* ! UNAME_DIR */ +X static char Sort[] = "uuname | sort | uniq"; /* default to obtain site names */ +#endif /*UNAME_DIR */ +X +#ifdef AT_OPTION +X static char at_opt[] = AT_OPTION; +#else +X static char at_opt[] = "-mc"; +#endif /* AT_OPTION */ +X +static char at_cmd[] = "at"; +static char cGrade[] = DEF_GRADE; /* grade as defined in conf.h */ +static char dGrade[] = "A"; /* use this if DEF_GRADE is invalid */ +static char Auto_Dir[] = AUTO_DIR; /* we live here */ +static char Cico_Dir[] = CICO_DIR; /* here lives cico */ +X +struct Sites { +X char name[MAXHOSTNAMELEN+1]; /* name of site as supplied by uuname */ +X char grade[1]; /* as passed or defaulted */ +X bool flag; /* TRUE: call this site only */ +X bool force; /* TRUE: -S or -f option given */ +X int stat_code; +X int stat_retries; +X long stat_lastcall; +X long stat_delay; +X char *stat_errtext; +}; +X struct Common_Stor { +X int maxtab; /* high-water-mark for site tab */ +X int Single_Site_Tab; /* entry into site tab for a site */ +X /* passed via -s or -S option */ +X bool force_any; /* TRUE: -f option without site */ +X bool one_site; /* TRUE: call for a specific site */ +X bool nodetach; /* TRUE: -D or --nodetach found */ +X bool ifwork; /* TRUE: -C or --ifwork found */ +X char *Grade; /* use this as grade for calls */ +X char *Poll_Pgm; /* our name without path */ +X char *called_as; /* but called by this name */ +X int our_pid; /* our process-id */ +X char *Uucico; /* cico's name without path */ +X char This_Site[MAXHOSTNAMELEN+1]; /* our site name */ +X char Single_Site[MAXHOSTNAMELEN+1]; /* name of site found as arg */ +X union wait *W_Stat; +X char *Usort; /* will hold uuname + subcmd */ +X struct passwd *pwd; +X struct timeval tp; +X struct timezone tzp; +X struct Sites Sitetab[SITE_MAX]; +X char mon[3]; +X int day, hh, mm, ss; +X char oname[24]; +X char jname[20]; +X char tstr[20]; +X char ctag[2]; +X char workf[300]; +X char call_args[300]; +X }; +X +/* copied from taylor uucp "uudefs.h" +X * +X **/ +X +/* The tstatus_type enumeration holds the kinds of status information +X we put in the status file. The order of entries here corresponds +X to the order of entries in the azStatus array. */ +enum tstatus_type +{ +X /* Conversation complete. */ +X STATUS_COMPLETE, +X /* Port unavailable. */ +X STATUS_PORT_FAILED, +X /* Dial failed. */ +X STATUS_DIAL_FAILED, +X /* Login failed. */ +X STATUS_LOGIN_FAILED, +X /* Handshake failed. */ +X STATUS_HANDSHAKE_FAILED, +X /* Failed after logging in. */ +X STATUS_FAILED, +X /* Talking to remote system. */ +X STATUS_TALKING, +X /* Wrong time to call. */ +X STATUS_WRONG_TIME, +X /* Number of status values. */ +X STATUS_VALUES +}; +X +/* ----end-- copied from taylor uucp "uudefs.h" */ +X +X +/* define the prototypes +X * */ +X +int set_mlog(FILE **seclog, struct Common_Stor *); +int get_sites(struct Common_Stor *); +int Call_Cico(int argc, char *argv[], struct Common_Stor *); +int get_args(int argc, char *argv[], struct Common_Stor *); +int Housekeeping(int argc, char *argv[], struct Common_Stor *); +int Chk_Status(int argc, char *argv[], +X struct timeval tcc, +X struct timezone tzcc, +X struct Common_Stor *); +int Check_Site(struct Common_Stor *); +int start_at(char *name, struct Common_Stor *); +void *storage(unsigned count, char *errloc, int *Rc, struct Common_Stor *); +X +extern int gethostname(char *name, int namelen); +extern int system(char *cmd); +extern int fork(); +extern int unlink(char *path); +extern void *malloc(size_t byteSize); +extern int execve(char *name, char *argv[], char *envp[]); +extern int execlp(char *name, char *arg0, ...); +extern int chmod(char *path, int mode); +extern int getuid(); +extern int getpid(); +extern int isatty(int); +extern char *ttyname(int); +extern void free(void *ptr); +#ifdef __STRICT_ANSI__ +extern FILE *popen(char *command, char *type); +extern int pclose(FILE *stream); +extern void _exit(int status); +#endif /* __STRICT_ANSI__ */ +#ifdef __STRICT_BSD__ +extern int fprintf(FILE *stream, const char *format, ...); +extern int fclose(FILE *stream); +extern char *strerror(int errnum); +extern int fflush(FILE *stream); +extern void exit(int status); +extern int fscanf(FILE *stream, const char *format, ...); +extern int sscanf(char *s, const char *format, ...); +#endif /* __STRICT_BSD__ */ +X +/* --------------------------------------------------------------------------*/ +/* Main */ +/* --------------------------------------------------------------------------*/ +X +int main(int argc, char *argv[]) +{ +X +X struct Common_Stor *sCom_Sto; +X int Maxrc = OK; /* Max err-code encountered so far */ +X int k = 0; +X +X if ( NULL == (sCom_Sto = malloc(sizeof(struct Common_Stor))) ) { +X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n", +X AUTO_DIR,"Common_Stor",errno,strerror(errno)); +X exit (CAT); +X } +X +X Maxrc = Housekeeping(argc, argv, sCom_Sto); +X +/* If any errors popped up so far they are of such a nature that it is very +X * questionable to continue; so we better bail out in this case. +X */ +X if (Maxrc <= WARNING) { +X if ((sCom_Sto->W_Stat = (union wait *)storage (sizeof(union wait), +X "W_Stat",&Maxrc,sCom_Sto)) != NULL) { +X k = Call_Cico(argc, argv, sCom_Sto); +X Maxrc = Maxrc >= k ? Maxrc:k; +X free(sCom_Sto->W_Stat); +X sCom_Sto->W_Stat = NULL; +X } +X } +X k = gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp); +X fprintf(stderr,"%s: (I) ended with rc = %i on %s\n", +X sCom_Sto->called_as, +X Maxrc,k!=0 ? "time unavailable":ctime(&sCom_Sto->tp.tv_sec)); +X fclose(stderr); +X free(sCom_Sto); +X sCom_Sto = NULL; +X exit (Maxrc); +} +X +/* --------------------------------------------------------------------------*/ +/* Functions */ +/* --------------------------------------------------------------------------*/ +X +/* -------------------------------------------------------------------- +X * housekeeping +X */ +X +int Housekeeping(argc, argv, sCom_Sto) +X int argc; +X char *argv[]; +X struct Common_Stor *sCom_Sto; { +X +X FILE *seclog = NULL; +X int Rc = OK; +X int Rci = OK; /* intermediate rc as returnd by functions */ +X +X sCom_Sto->our_pid = getpid(); +X +/* +X * get our name sans path +X * */ +X +X sCom_Sto->called_as = argv[0] + strlen(*argv); +X for(;sCom_Sto->called_as >= argv[0] && *--sCom_Sto->called_as != '/';) +X ; +X sCom_Sto->called_as++; +X +/* if defined set up the name of the message log file otherwise +X * stderr will be used. Setup the cmd string to obtain all known sitenames +X * which will be sorted in ascending order with duplicates removed +X * */ +X +X Rc = set_mlog(&seclog, sCom_Sto); +X if (Rc > WARNING) +X return (Rc); +X +/* put out the started message including the time and the userid. +X * */ +X +X sCom_Sto->pwd = getpwuid(getuid()); +X +X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) { /* unacceptable error */ +X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X return (Rc >= CAT ? Rc:CAT); +X } +X +X if (seclog != NULL) { +X fprintf(seclog,"\n%s: (I) started by `%s' (%s) on %s", +X sCom_Sto->called_as, +X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name, +X ttyname(0), +X ctime(&sCom_Sto->tp.tv_sec)); +X fclose(seclog); +X } +X fprintf(stderr,"\n%s: (I) started by `%s' on %s", +X sCom_Sto->called_as, +X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name, +X ctime(&sCom_Sto->tp.tv_sec)); +X +/* set up the default grade +X * */ +X +X sCom_Sto->Grade = dGrade; /* set default for now */ +X if (strlen(cGrade) != 1) { +X fprintf(stderr,"%s: (W) grade %s invalid; default `%s' used\n", +X sCom_Sto->called_as,cGrade,sCom_Sto->Grade); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else +X sCom_Sto->Grade = cGrade; /* Ok, take the one from conf.h */ +X +/* get the program to actually call the site. This is normally UUCICO. +X * */ +X +X sCom_Sto->Uucico = Cico_Dir + strlen(Cico_Dir); +X for(;sCom_Sto->Uucico >= Cico_Dir && *--sCom_Sto->Uucico != '/';) +X ; +X sCom_Sto->Uucico++; +X +/* get the path to ourself. +X * */ +X +X sCom_Sto->Poll_Pgm = Auto_Dir + strlen(Auto_Dir); +X for(;sCom_Sto->Poll_Pgm >= Auto_Dir && *--(sCom_Sto->Poll_Pgm) != '/';) +X ; +X sCom_Sto->Poll_Pgm++; +X +/* obtain our sitename +X * */ +X +X if ((gethostname(sCom_Sto->This_Site,MAXHOSTNAMELEN+1)) != 0) { +X fprintf(stderr,"%s: (W) hostname could not be obtained\n", +X sCom_Sto->called_as); +X Rc = (Rc >= WARNING) ? Rc:WARNING; +X } +X +/* obtain all known sitenames +X * */ +X +X Rci = get_sites(sCom_Sto); +X Rc = Rci > Rc ? Rci:Rc; +X +/* check the arguments that we are called with +X * */ +X +X Rci = get_args(argc, argv, sCom_Sto); +X Rc = Rci > Rc ? Rci:Rc; +X +X return (Rc); +} +X +/* -------------------------------------------------------------------- +X * check all relevant arguments that have been passed to us. Those args +X * that may be needed for a recall will be copied to a workfield. +X * */ +X +int get_args(int argc, char *argv[], struct Common_Stor *sCom_Sto) { +X +X int j = 0; +X int Rc = OK; +X int Rci = OK; +X +X strcpy(sCom_Sto->Single_Site,""); +X sCom_Sto->force_any = FALSE; +X sCom_Sto->one_site = FALSE; +X sCom_Sto->nodetach = FALSE; +X +X strcpy(sCom_Sto->call_args,AUTO_DIR); /* specify complete path to us */ +X strcat(sCom_Sto->call_args," "); /* and separate by one space */ +X for (j=1;j<argc;j++) { +X if (strcmp(argv[j],"--nodetach") == 0 || +X strcmp(argv[j],"-D") == 0) { +X sCom_Sto->nodetach = TRUE; +X strcat(sCom_Sto->call_args,"-D "); +X continue; +X } +X if (strcmp(argv[j],"--force") == 0 || +X strcmp(argv[j],"-f") == 0) { +X strcat(sCom_Sto->call_args,"-f "); +X sCom_Sto->force_any = TRUE; +X continue; +X } +X if (strcmp(argv[j],"--ifwork") == 0 || +X strcmp(argv[j],"-C") == 0) { +X sCom_Sto->ifwork = TRUE; +X continue; +X } +X if ( strncmp(argv[j],"-s",2) == 0 || +X strncmp(argv[j],"-S",2) == 0 || +X strcmp(argv[j],"--system") == 0) { +X if (strncmp(argv[j],"-S",2) == 0) +X sCom_Sto->force_any = TRUE; +X +X if (strlen(argv[j]) == 2 || strcmp(argv[j],"--system") == 0) { +X j++; +X if (j>=argc) { +X fprintf(stderr,"%s: (E) System to call is missing\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X else { +X strcpy(sCom_Sto->Single_Site,argv[j]); +X Rci = Check_Site(sCom_Sto); +X if (! Rci) { +X sCom_Sto->one_site = TRUE; /* specific call */ +X strcat(sCom_Sto->call_args,argv[j-1]); +X strcat(sCom_Sto->call_args," "); +X strcat(sCom_Sto->call_args,argv[j]); +X strcat(sCom_Sto->call_args," "); +X } +X } +X Rc = Rci <= Rc ? Rc:Rci; +X } +X else { +X strcpy(sCom_Sto->Single_Site,argv[j]+2); +X Rci = Check_Site(sCom_Sto); +X if (! Rci) { +X sCom_Sto->one_site = TRUE; /* specific call */ +X strcat(sCom_Sto->call_args,argv[j]); +X strcat(sCom_Sto->call_args," "); +X } +X Rc = Rci <= Rc ? Rc:Rci; +X } +X continue; +X } +X strcat(sCom_Sto->call_args,argv[j]); +X strcat(sCom_Sto->call_args," "); +X } /* end copy all arguments */ +X +X if (sCom_Sto->ifwork) { +X if (sCom_Sto->one_site) { +X strcat(sCom_Sto->call_args,"-C "); +X } +X else { +X fprintf(stderr,"%s: (W) no site given, '-C' option is ignored\n", +X sCom_Sto->called_as); +X sCom_Sto->ifwork = FALSE; +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X } +X +X if (! sCom_Sto->nodetach) { +X strcat(sCom_Sto->call_args,"-D "); +X } +X +X return (Rc); +} +X +/* -------------------------------------------------------------------- +X * call uucico or whatever programm is necessary to get connected +X */ +X +/* Start uucico and wait for completion. In case the return code is '0' +X * we're finished; otherwise we'll have to check the status files for any +X * non successful calls (retry time > 0). +X * Any such site will be called again at the current time plus any wait +X * Note: +X * If the '-D' or '--nodetach' option is missing, uucico will +X * detach immediate. The return-code is 0 in this case and therefore +X * we can't check whether the call is successful or not. No recall +X * is scheduled for such an invocation. If we however get control +X * to schedule a recall we silently add the '-D' option. To add +X * the '-D' option in any case may be undesirable for a specific +X * type of run. +X */ +X +int Call_Cico(int argc, char *argv[], struct Common_Stor *sCom_Sto) { +X +X int W_Ret = 0; +X int pid = 0; +X int Rc = OK; +X struct timeval tcc; +X struct timezone tzcc; +X +X if ((gettimeofday(&tcc, &tzcc)) != 0) { /* unacceptable error */ +X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X Rc = Rc >= CAT ? Rc:CAT; +X } +X +X if (Rc > WARNING) { +X return (Rc); +X } +X +X fflush(stderr); +X switch(pid = fork()) { +X case -1: +X fprintf(stderr,"%s: (C) could not fork(). Reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X return (CAT); +X case 0: +X if ((argv[0] = (char *)storage(strlen(sCom_Sto->Uucico)+1,"argv[0]", +X &Rc,sCom_Sto)) == NULL) { +X _exit (CAT); +X } +X strcpy(argv[0],sCom_Sto->Uucico); /* change name to be uucico */ +X execve(Cico_Dir, argv, NULL); +X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico,errno,strerror(errno)); +X _exit (CAT); /* child: bail out */ +X default: +X fprintf(stderr,"%s: (I) starting %s [%d]\n\n", +X sCom_Sto->called_as,sCom_Sto->Uucico,pid); +X fflush(stderr); /* maybe we come behind uucico's output */ +X /* if any; it's a race condition */ +X W_Ret = wait(sCom_Sto->W_Stat); +X if (sCom_Sto->W_Stat->w_termsig == 0) { +X if (sCom_Sto->W_Stat->w_retcode == 0) { +X fprintf(stderr,"%s: (I) %s [%d] ended normally\n", +X sCom_Sto->called_as,sCom_Sto->Uucico,pid); +X return (OK); +X } +X if (sCom_Sto->W_Stat->w_retcode != CAT) { +X fprintf(stderr,"%s: (I) %s's log may contain further information !\n", +X sCom_Sto->called_as,sCom_Sto->Uucico); +X fprintf(stderr,"\n%s: (W) %s [%d] ended with rc = %i\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico,pid, +X sCom_Sto->W_Stat->w_retcode); +X return (Chk_Status(argc, argv, +X tcc, tzcc, sCom_Sto)); +X } +X else +X return (CAT); /* we where unable to exec */ +X } +X else { +X fprintf(stderr,"\n%s: (E) %s [%d] terminated by signal %i\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico, +X pid, +X sCom_Sto->W_Stat->w_termsig); +X return (SEVERE); +X } +X } /* switch (pid = fork()) */ +X return (OK); /* Never reached: silence the compiler */ +} +X +X +/* -------------------------------------------------------------------- +X * check the status after the call has completed and the return code +X * is > zero. The status is checked for all sites found via uuname or +X * for one site only (option -s, -S or --system given on call) +X */ +X +int Chk_Status(int argc, char *argv[], +X struct timeval tcc, +X struct timezone tzcc, +X struct Common_Stor *sCom_Sto) { +X +/* +X * For all sites found in Site_Tab their status files will be checked. +X * The table scan will be bypassed for a call to a specific site. +X * If the call failed the wait period is > 0. We will schedule an at-job +X * to be run at the time found + the delta. In case we find an old entry +X * where the time + delta is lower than the current time we'll advance +X * the current time by 60 secs. and use that value instead. +X * In case we are invoked to call a specific site and either the -f option or +X * the site was given as -S... indicating to disregard any wait, we'll +X * use the time found in the status file increased by 120 secs. +*/ +X +X FILE *infile; +X long secs, retries = 0; +X long add = 0; +X int errind = 0; +X int i = 0; +X int ecnt = 0; +X int recall_cnt = 0; +X char curr_site[MAXHOSTNAMELEN+11] = ""; /* keyword + sitename */ +X bool schedule = TRUE; /* FALSE: no more rescheduling: unspec. + force */ +X int Rc = WARNING; /* uucico got rc = 1 otherwise we were not here */ +X int Rs = 0; /* uucico' reason code from .Status file */ +X +/* +X * Note +X * We have to increase the sum of time and wait by at least one minute. +X * That is because this time denotes the earliest point *after* which +X * we may call again. +X * When a site is called at the wrong time the follwing actions are +X * taken: wait = 0 && ! force --> no further action (indicator: see log) +X * wait = 0 && force --> (W) message generated; no further action +X * wait > 0 && ! force --> normal scheduling at time + wait +X * wait > 0 && force --> normal scheduling at time+120 secs +X * We can't depend on the string "Wrong time to call" because the .Status +X * file may not be updated due to the -c switch. This may lead to a +X * situation where the site will be called over and over again while it's +X * still the wrong time. (No we don't want to go fishing for a message in +X * the uucp LOG!) +X * In case the -s, -S or --system option was given we will only +X * check that site and schedule a recall for it so far the +X * conditions are met. +X * In case the -C or --ifwork switch is given without naming a site a +X * the option is dropped and only an unspecific call is scheduled. +X * */ +X +X if (sCom_Sto->one_site) { +X i = sCom_Sto->Single_Site_Tab; +X if (strncmp(sCom_Sto->Sitetab[i].name, +X sCom_Sto->Single_Site, +X sizeof(sCom_Sto->Single_Site)) != 0) { +X fprintf(stderr,"%s: (C) internal index-error (%d): %s found: %s\n", +X sCom_Sto->called_as, +X i, +X sCom_Sto->Single_Site, +X sCom_Sto->Sitetab[i].name); +X Rc = Rc >= CAT ? Rc:CAT; +X return (Rc); /* break unconditionally */ +X } +X } +X +X for (i = sCom_Sto->Single_Site_Tab; i <= sCom_Sto->maxtab; i++) { +X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name); +X if ((infile=fopen(sCom_Sto->workf,"r")) == NULL) { +X ecnt++; +X fprintf(stderr,"%s: (W) no access to status file for: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= WARNING ? Rc:WARNING; +X if (sCom_Sto->one_site) { +X break; +X } +X else { +X continue; +X } +X } +X +X fscanf(infile,"%d %d %ld %ld",&errind,&retries,&secs,&add); +X fclose(infile); +X +X /* +X * in case the .Status file is not updated and we have a call to +X * a specific site we try to give some clues of what went wrong +X * (we won't succeed in any case!) +X */ +X +X if (sCom_Sto->Sitetab[i].stat_lastcall == secs && sCom_Sto->one_site) { +X +X if (errind == 0 && retries == 0 && add == 0) +X break; +X +X if (errind > 0) { +X if (tcc.tv_sec <= (secs+add) && ! sCom_Sto->Sitetab[i].force) { +X fprintf(stderr,"%s: (W) retry time not reached for site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else { +X fprintf(stderr,"%s: (E) maybe port/site unavailable site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X } +X else { +X if (sCom_Sto->one_site) { +X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X } +X fprintf(stderr,"%s: (W) no recall scheduled for site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X break; /* bail out completely */ +X } +X +X if (sCom_Sto->Sitetab[i].stat_lastcall == secs) { +X if (sCom_Sto->one_site) +X break; +X else +X continue; +X } +X +X Rs = OK; /* if Rs is > WARNING we won't schedule a recall */ +X switch(errind) { +X case STATUS_COMPLETE: +X if (add != 0 || retries != 0) { +X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rs = Rs >= SEVERE ? Rs:SEVERE; +X } +X break; +X case STATUS_PORT_FAILED: +X fprintf(stderr,"%s: (E) port was unavailable site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X break; +X case STATUS_DIAL_FAILED: +X fprintf(stderr,"%s: (E) dail failed for site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X break; +X case STATUS_LOGIN_FAILED: +X fprintf(stderr,"%s: (E) login for site: %s failed\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rs = Rs >= SEVERE ? Rs:SEVERE; +X break; +X case STATUS_HANDSHAKE_FAILED: +X fprintf(stderr,"%s: (E) handshake failed site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X break; +X case STATUS_FAILED: +X fprintf(stderr,"%s: (E) invalid status after login site: %s \n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X break; +X case STATUS_TALKING: +X break; +X case STATUS_WRONG_TIME: +X fprintf(stderr,"%s: (W) it's the wrong time to call site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rs = Rs >= SEVERE ? Rs:SEVERE; +X break; +X default: +X fprintf(stderr,"%s: (E) unknown error for call to site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rs = Rs >= SEVERE ? Rs:SEVERE; +X break; +X } +X Rc = Rs > Rc ? Rs:Rc; +X if (Rs > WARNING) { /* schedule a recall ? */ +X fprintf(stderr,"%s: (W) no recall scheduled for site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X if (sCom_Sto->one_site) +X break; +X else +X continue; +X } +X +X if (add == 0) { +X fprintf(stderr,"%s: (W) no delay found for site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X +X +X if (! schedule) { +X recall_cnt += 1; +X continue; /* scheduling already done: unspec. + force */ +X } +X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) { +X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X fclose(infile); +X Rc = Rc >= CAT ? Rc:CAT; +X break; /* break unconditionally */ +X } +X +X if (sCom_Sto->force_any || sCom_Sto->Sitetab[i].force) { +X add = secs + 120; /* shorten the wait */ +X } +X else { /* ! force */ +X +/* +X * check for an already scheduled recall. For we don't keep +X * a file of already scheduled recalls the only way to recognize +X * this, is to check the current time against that of the .Stats file. +X * In case the current time is >= the .Stats-time + n-secs fuzz value +X * we assume (99.99% correctness) that we have already scheduled a recall +X * for this site. If this assumption is incorrect a call will be +X * scheduled on the next unspecific failing call. This check can't +X * be done for forced call because the .Stats will be updated. +X */ +X if (sCom_Sto->tp.tv_sec >= secs+2) { +X fprintf(stderr,"%s: (W) Retry time not reached for site: %s\n", +X sCom_Sto->called_as, +X sCom_Sto->Sitetab[i].name); +X Rc = Rc >= WARNING ? Rc:WARNING; +X if (sCom_Sto->one_site) +X break; +X else +X continue; +X } +X add += secs + 60; /* if not force then take the full wait */ +X } /* force */ +X +X if (sCom_Sto->tp.tv_sec >= add) { +X add = sCom_Sto->tp.tv_sec + 60; /* time < current time */ +X } +X +X sscanf(ctime(&add),"%*s %s %d %d:%d:%d",sCom_Sto->mon, +X &sCom_Sto->day, +X &sCom_Sto->hh, +X &sCom_Sto->mm, +X &sCom_Sto->ss); +X +X sprintf(sCom_Sto->oname,"/tmp/at.%d.%02d%02d%02d",sCom_Sto->our_pid, +X sCom_Sto->hh, +X sCom_Sto->mm, +X sCom_Sto->ss); +X if (! sCom_Sto->one_site) { +X strcpy(curr_site,"-s"); +X strcat(curr_site,sCom_Sto->Sitetab[i].name); +X } +X +X /* +X * If 'onesite' is FALSE and 'force' is TRUE +X * we will reschedule one unspecific call an let UUCICO decide +X * which site should be called (is there any work?) +X */ +X +X if ( ! sCom_Sto->one_site && sCom_Sto->force_any) { +X recall_cnt += 1; +X schedule = FALSE; +X continue; +X } +X strcat(sCom_Sto->call_args,curr_site); +X Rs = start_at(sCom_Sto->Sitetab[i].name, sCom_Sto); +X Rc = Rs >= Rc ? Rs:Rc; +X unlink(sCom_Sto->oname); +X if (Rc > SEVERE || sCom_Sto->one_site) +X break; +X } /* for (i = Single_Site_Tab; ...) */ +X +X if (ecnt > sCom_Sto->maxtab) { +X fprintf(stderr,"%s: (E) no access to status files; no scheduling done\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X else { +X if (! schedule) { +X if (recall_cnt == 1) { +X strcat(sCom_Sto->call_args,curr_site); +X } +X Rs = start_at("any site", sCom_Sto); +X Rc = Rs >= Rc ? Rs:Rc; +X unlink(sCom_Sto->oname); +X } +X } +X return (Rc); +} +X +X /* +X * +X */ +X +int start_at(char *site, struct Common_Stor *sCom_Sto) { +X +FILE *outfile; +int W_Ret = 0; +int Rc = OK; +int pid = 0; +X +/* +X * if we can't open the workfile to be passed to AT we'll abandon +X * this site and set the rc accordingly +X * */ +X +X if ((outfile=fopen(sCom_Sto->oname,"w")) == NULL) { +X fprintf(stderr,"%s: (E) could not open workfile %s. No scheduling for: %s\n", +X sCom_Sto->called_as, +X sCom_Sto->oname, +X site); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X fclose(outfile); +X unlink(sCom_Sto->oname); +X return (Rc); /* bail out here */ +X } +X sprintf(sCom_Sto->jname,"at.%d.%02d%02d%02d",sCom_Sto->our_pid, +X sCom_Sto->hh, +X sCom_Sto->mm, +X sCom_Sto->ss); +X fprintf(outfile,"%s \n",sCom_Sto->call_args); +X sprintf(sCom_Sto->tstr,"%02d%02d",sCom_Sto->hh, +X sCom_Sto->mm); +X sprintf(sCom_Sto->ctag,"%d",sCom_Sto->day); +X fclose(outfile); +X if ((chmod(sCom_Sto->oname,00644)) != 0) { +X fprintf(stderr,"%s: (W) chmod to %s failed. Reason_code: %i (%s)\n", +X sCom_Sto->called_as, +X sCom_Sto->oname, +X errno, +X strerror(errno)); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X +X switch (pid = fork()) { +X case -1: +X fprintf(stderr,"%s: (C) could not fork(). Reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X return (Rc >= CAT ? Rc:CAT); +X case 0: +X if (*at_opt == '\0') +X execlp(at_cmd, at_cmd, sCom_Sto->tstr, +X sCom_Sto->mon, sCom_Sto->ctag, +X sCom_Sto->oname, 0); +X else +X execlp(at_cmd, at_cmd, at_opt, sCom_Sto->tstr, +X sCom_Sto->mon, sCom_Sto->ctag, +X sCom_Sto->oname, 0); +X +X fprintf(stderr,"%s: (C) could not start AT-cmd. Reason-code: %i (%s)\n", +X sCom_Sto->called_as, +X errno,strerror(errno)); +X _exit (CAT); /* child: bail out */ +X default: +X fprintf(stderr,"%s: (I) at [%d] started. Job name: %s\n", +X sCom_Sto->called_as, +X pid, +X sCom_Sto->jname); +X W_Ret = wait(sCom_Sto->W_Stat); +X if (sCom_Sto->W_Stat->w_termsig == 0) { +X if (sCom_Sto->W_Stat->w_retcode != 0) { +X if (sCom_Sto->W_Stat->w_retcode != CAT) { +X fprintf(stderr,"%s: (E) at-cmd failed for some reason\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X else { +X Rc = Rc >= CAT ? Rc:CAT; +X } +X +X fprintf(stderr,"%s: (I) at [%d] ended with rc = %i\n", +X sCom_Sto->called_as, +X pid, +X sCom_Sto->W_Stat->w_retcode); +X /* bail out in case wait returned > SEVERE */ +X if (Rc > SEVERE) { +X return (Rc); +X } +X } +X else { +X fprintf(stderr,"%s: (I) at-cmd [%d] ended normally\n", +X sCom_Sto->called_as, +X pid); +X } +X } +X else { +X fprintf(stderr,"%s: (E) at [%d] terminated by signal %i\n", +X sCom_Sto->called_as, +X pid, +X sCom_Sto->W_Stat->w_termsig); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X } /* switch (pid = fork()) */ +X return (Rc); +} +/* ----------------------------------------------------------------- +X * check the site passed via -s or -S option to be a valid one and +X * not to be our hostname. +X * */ +X +int Check_Site(struct Common_Stor *sCom_Sto) { +X +X int i,j = 0; +X sCom_Sto->Single_Site_Tab = 0; +X if (strcmp(sCom_Sto->Single_Site,sCom_Sto->This_Site) == 0) { +X fprintf(stderr,"%s: (E) won't call *ourself* %s\n", +X sCom_Sto->called_as,sCom_Sto->Single_Site); +X return(SEVERE); +X } +X for(i=0;i<=sCom_Sto->maxtab;i++) { +X if ((j=strcmp(sCom_Sto->Sitetab[i].name,sCom_Sto->Single_Site)) >= 0) { +X break; +X } +X } +X if (j != 0) { +X fprintf(stderr,"%s: (E) unknown site: %s\n", +X sCom_Sto->called_as,sCom_Sto->Single_Site); +X return(SEVERE); +X } +X sCom_Sto->Single_Site_Tab = i; +X sCom_Sto->Sitetab[i].flag = TRUE; +X if (sCom_Sto->force_any) { +X sCom_Sto->Sitetab[i].force = TRUE; +X sCom_Sto->force_any = FALSE; +X } +X return(OK); +} +X +X /* ------------------------------------------------------------------ +X * storage - get some memory +X */ +X +void *storage(unsigned count, +X char *location, +X int *Rc, +X struct Common_Stor *sCom_Sto) +{ +X void *p; +X +X if( NULL == (p= malloc(count)) ) { +X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n", +X sCom_Sto->called_as,location,errno,strerror(errno)); +X *Rc = *Rc >= CAT ? *Rc:CAT; +X } +X return p; +} +X +/* ------------------------------------------------------------------ +X * if defined open the message log file otherwise all mesages will go +X * to stderr. If UNAME_DIR is defined construct the command to be +X * passed to popen(); if undefined the deafult will be used +X * */ +X +int set_mlog(FILE **seclog, struct Common_Stor *sCom_Sto) { +X +X int Rc = 0; +X +#ifdef ALOG_FILE +X if (!isatty(0)) { +X if ((freopen(Msg_Log,"a",stderr)) == NULL) { +X fprintf(stdout,"%s: (C) Could not open msglog: %s\n", +X sCom_Sto->called_as,Msg_Log); +X return (Rc >= CAT ? Rc:CAT); +X } +X } +X else { +X if ((*seclog = fopen(Msg_Log,"a")) == NULL) { +X fprintf(stderr,"%s: (C) Could not open msglog: %s\n", +X sCom_Sto->called_as,Msg_Log); +X return (Rc >= CAT ? Rc:CAT); +X } +X } +#endif /* ALOG_FILE */ +X +/* set up the pipe together with the complete path to uuname */ +X +#ifdef UNAME_DIR +X if ((sCom_Sto->Usort = (char *)storage (sizeof(UNAME_DIR)+sizeof(subcmd), +X "Sort",&Rc, sCom_Sto)) != NULL) { +X strncpy(sCom_Sto->Usort,UNAME_DIR,strlen(UNAME_DIR)); /* paste in the path */ +X strcat(sCom_Sto->Usort,subcmd); /* chain the pipe to it */ +X } +#else /* ! UNAME_DIR */ +X sCom_Sto->Usort = &Sort; /* set pointer to uuname + sort */ +#endif /* UNAME_DIR */ +X +X return (Rc); +} +X +/* ------------------------------------------------------------------ +X * obtain all active sitenames +X * */ +X +int get_sites(struct Common_Stor *sCom_Sto) { +X +X int i = 0; +X int n; +X int Rc = 0; +X FILE *infile, *statsfile; +X +X if ((infile=popen(sCom_Sto->Usort,"r")) != NULL) { +X while(fgets(sCom_Sto->Sitetab[i].name,MAXHOSTNAMELEN+1,infile)) { +X if (i > SITE_MAX) { /* let'm run so that we can give */ +X i++; /* the user some guidance */ +X continue; /* we'll tell the user later on */ +X } +X n = strlen(sCom_Sto->Sitetab[i].name)-1; /* offset: next to last char */ +X sCom_Sto->Sitetab[i].name[n] = '\0'; /* strip trailing newline */ +X sCom_Sto->Sitetab[i].flag = FALSE; /* TRUE: poll this site only*/ +X sCom_Sto->Sitetab[i].force = FALSE; /* TRUE: force call */ +X strcpy(sCom_Sto->Sitetab[i].grade,sCom_Sto->Grade); +X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name); +X if ((statsfile=fopen(sCom_Sto->workf,"r")) == NULL) { +X fprintf(stderr,"%s: (W) no access to status file for: %s\n", +X sCom_Sto->called_as,sCom_Sto->Sitetab[i].name); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else { +X fscanf(statsfile,"%d %d %ld %ld %s", +X &sCom_Sto->Sitetab[i].stat_code, +X &sCom_Sto->Sitetab[i].stat_retries, +X &sCom_Sto->Sitetab[i].stat_lastcall, +X &sCom_Sto->Sitetab[i].stat_delay, +X sCom_Sto->workf); +X +X fclose(statsfile); +X if ((sCom_Sto->Sitetab[i].stat_errtext = +X (char *)storage (sizeof(sCom_Sto->workf), +X "stat_errtext",&Rc, sCom_Sto)) == NULL) { +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else +X strcpy(sCom_Sto->Sitetab[i].stat_errtext,sCom_Sto->workf); +X } +X sCom_Sto->maxtab = i++; /* set high-water-mark */ +X } +X if (ferror(infile) != 0) { +X fprintf(stderr,"%s: (E) fgets() for sitenames failed reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X pclose(infile); +X +X /* +X * check for an empty table (strange but possible) +X */ +X +X if (sCom_Sto->maxtab == 0) { +X fprintf(stderr,"%s: (E) could not obtain sitenames.\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X else { +X +X /* in case the internal table overflows we'll now give notice and tell +X * the user by which amount the table has to be increased to hold all +X * site-names +X */ +X +X if (i > SITE_MAX) { +X fprintf(stderr,"%s: (E) number of sites > internal tab\n", +X sCom_Sto->called_as); +X fprintf(stderr,"%s: (E) increase SITE_MAX to >= %d and recompile\n", +X sCom_Sto->called_as,i); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X } /* sCom_Sto->maxtab == 0 */ +X +X } +X else /* infile == NULL */ +X { +X fprintf(stderr,"%s: (E) could not sort sitenames. Reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X +X } /* if ((infile=popen(sCom_Sto->Usort,"r")) ... */ +X +X return (Rc); +} +SHAR_EOF +chmod 0444 uupoll/autopoll.c || +echo 'restore of uupoll/autopoll.c failed' +Wc_c="`wc -c < 'uupoll/autopoll.c'`" +test 44031 -eq "$Wc_c" || + echo 'uupoll/autopoll.c: original size 44031, current size' "$Wc_c" +fi +# ============= uupoll/conf.h ============== +if test -f 'uupoll/conf.h' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/conf.h (File already exists)' +else +echo 'x - extracting uupoll/conf.h (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/conf.h' && +#ifndef CONF +X #define CONF +X +/* $Id: uupoll.shar,v 1.1 1994/10/24 22:17:53 jtc Exp $ */ +/* $Log: uupoll.shar,v $ +/* Revision 1.1 1994/10/24 22:17:53 jtc +/* Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl). +/* +X * Revision 1.9 1994/04/14 17:24:58 kdburg +X * added comment to the AT_OPTION +X * +X * Revision 1.8 1994/03/26 17:41:06 kdburg +X * the location of uuname can now be specified. This was added due to +X * the fact that cron (NeXT 3.2 and +) now obeys the path that was active +X * during boot (either /.path or set within /etc/rc) so autopoll/uupoll +X * always got the wrong uuname when called direct fron cron. This is +X * not true when called via a script that does a 'su - user -c ...' +X * +X * Revision 1.7 1993/06/26 16:21:47 kdburg +X * default location for logfiles changed +X * +X * Revision 1.6 1993/05/14 22:32:05 kdburg +X * change to HAVE_SPOOLDIR_TAYLOR +X * +X * Revision 1.5 1993/05/09 13:16:53 kdburg +X * make have-autopoll the default +X * +X * Revision 1.4 1993/05/08 23:17:34 kdburg +X * cleanup and to reflect changes made to autopoll/uupoll +X * +X * Revision 1.3 1993/04/29 10:46:34 kdburg +X * added def for STATUS_DIR +X * +X * Revision 1.2 1993/04/27 15:31:47 kdburg +X * rearranged the defs; changed LOG_DIR to ALOG_DIR in case uupoll +X * will have one too; we need then eventually 2 different dirs. +X * +X * Revision 1.1 1993/04/26 21:20:12 kdburg +X * Initial revision +X * */ +X +/* --------- combined config file for uupoll and autopoll */ +/* --------- change the following defines to meet your needs */ +X +/* define the default grade to be inserted into the pollfile name */ +#define DEF_GRADE "A" +X +/* Define the complete path to the uuname program. +X * If undefined we'll use just the name 'uuname' to call it +X * */ +#define UNAME_DIR "/usr/local/bin/uuname" +X +/* define the path to the directory which does contain uucico */ +#define CICO_DIR "/usr/local/lib/uucp/uucico" +X +/* define the path to the directory which holds all the uucp files. +X * We'll place the poll file in one of it's subdirectories +X * */ +#define SPOOL_DIR "/usr/spool/uucp" +X +/* at least one of the follwing must be defined To use the second or +X * third set of definitions, change the ``#if 1'' to ``#if 0'' +X * and change the appropriate ``#if 0'' to ``#if 1''. +X * */ +#if 0 +#define HAVE_SPOOLDIR_BSD +#endif +#if 0 +#define HAVE_SPOOLDIR_HDB +#endif +#if 1 +#define HAVE_SPOOLDIR_TAYLOR +#endif +X +/* define the maximum number of sites in your config or L.sys */ +#define SITE_MAX 100 +X +/* define the path to the directory which is to contain the +X * message log created by uupoll and the file name itself. +X * change the ``#if 1'' to ``#if 0'' to have the messages on stderr +X * */ +#if 1 +#define ULOG_FILE "/Logfiles/poll.log" +#endif +X +/* change if to 0 if you don't have autopoll installed. */ +#if 1 +#define AUTO_POLL +#endif +X +/* The following defs are irrelevant if you don't have autopoll */ +X +/* define the options to be given to the at cmd (-s -c -m). The default +X * is shown (use csh and send mail after execution) if AT_OPTION is +X * undefined +X * */ +#define AT_OPTION "-mc" +X +/* Define the complete path to the autopoll program. +X * This will assure that we get the one we want +X * The path must be the same as given in Makefile (lbindir) +X * */ +#define AUTO_DIR "/usr/local/lib/uucp/autopoll" +X +/* define the path to the directory which is to contain the +X * message log created by autopoll and the file name itself. +X * change the ``#if 1'' to ``#if 0'' to have the messages on stderr +X * */ +#if 1 +#define ALOG_FILE "/Logfiles/poll.log" +#endif +X +/* define the full path to the directory which holds the status files +X * The name should be given *except* the sitename. A trailing `/' if any +X * must be given. +X * Example: /usr/spool/uucp/.Status/sys.sitename +X * then specify STATUS_DIR as +X * "/usr/spool/uucp/.Status/sys." +X * */ +#define STATUS_DIR "/usr/spool/uucp/.Status/" +#endif +SHAR_EOF +chmod 0444 uupoll/conf.h || +echo 'restore of uupoll/conf.h failed' +Wc_c="`wc -c < 'uupoll/conf.h'`" +test 3884 -eq "$Wc_c" || + echo 'uupoll/conf.h: original size 3884, current size' "$Wc_c" +fi +# ============= uupoll/uupoll.8c ============== +if test -f 'uupoll/uupoll.8c' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/uupoll.8c (File already exists)' +else +echo 'x - extracting uupoll/uupoll.8c (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/uupoll.8c' && +.\" Copyright (c) 1986 Regents of the University of California. +.\" All rights reserved. The Berkeley software License Agreement +.\" specifies the terms and conditions for redistribution. +.\" +.\" @(#)uupoll.8c 6.1 (Berkeley) 4/24/86 +.\" @(#)uupoll.8c 1.11 (incoahe) 5/09/1993 +.\" +.TH UUPOLL 8C "Mai 09, 1993" +.UC 6 +.SH NAME +uupoll \- poll a remote \s-1UUCP\s+1 site +.SH SYNOPSIS +.B uupoll +[ +.BI \-g grade +] [ +.B \-n +] [ +.B \-x +] +.I system ... ... +.SH SUMMARY +This version of +.IR uupoll +can be used to fully replace the vendor supplied +.IR uupoll +that comes with the NeXTStep OS. The original version (up to 3.1) had a +X bug in that +X an unknown site given as argument would yield in a `Bus error' condition. +Using any other type of UUCP like Taylor-UUCP with the option of having +a different file structure as well as a different L.sys will therefore +make it necessary to do maintenance to the (unused) L.sys as well to keep +.IR uupoll +going. This one has been programmed from scratch due to the fact that no +source code was available. Some enhancements have been incorporated into +this version: +.PP +\- the default grade may now be compiled different from `A'. +.PP +\- the options may now be given in any order and the \-g option may be given +more than once. Any option will be used immediately when encountered and +will stay in effect unless reset; this does not apply to the \-x and \-n +option which can't be reset. The processing of options is guaranteed to be +from left to right so that some grouping may be achieved (see below). +.PP +\- +.IR uupoll +may be used to call any program instead of +.IR uucico +namely +.IR autopoll +to ease the task of rescheduling a failed call. +.SH DESCRIPTION +.I Uupoll +is used to force a poll of a remote system. It queues a null job for the +remote system, unless the \-x option has been given, and then invokes +either +.IR uucico (8C) +or +.IR autopoll (8C) +or any other program depending on how +.IR uupoll +is customized. If used in conjunction with +.IR autopoll +the latter will then invoke +.IR uucico. +.SH OPTIONS +The following options are available: +.TP 8 +.BI \-g grade +Only send jobs of grade +.I grade +or higher on this call. The +.I grade +stays in effect until it is changed by a different \-g option. +.TP 8 +.B \-n +Queue the null job, but do not invoke the program that actually calls +the named site(s). +The \-n option once given will apply to all sites following to the +.IR right +of it. +.TP 8 +.B \-x +Do not place a null job for all following sites. This option must be given +before the \-n option. The \-n option will nullify this. Any grade in effect +will not be honored because +.I uucico (Taylor) +does not carry the \-g option at the moment. +.PP +.I Uupoll +is usually run by +.IR cron (5) +or by a user who wants to hurry a job along. A typical entry in +.I crontab +could be: +.PP +.nf +X 0 0,8,16 * * * uucp /usr/bin/uupoll ihnp4 +X 0 4,12,20 * * * uucp /usr/bin/uupoll ucbvax +.fi +This will poll +.B ihnp4 +at midnight, 0800, and 1600, and +.B ucbvax +at 0400, noon, and 2000. +.PP +If the local machine is already running +.I uucico +every +hour and has a limited number of outgoing modems, a better approach +might be: +.PP +.nf +X 0 0,8,16 * * * uucp /usr/bin/uupoll -n ihnp4 +X 0 4,12,20 * * * uucp /usr/bin/uupoll -n ucbvax +X 5 * * * * uucp /usr/lib/uucp/uucico -r1 -D -C +.fi +This will queue null jobs for the remote sites at the top of the hour; they +will be processed by +.I uucico +when it runs five minutes later (the -C option apply to Taylor +uucp-1.05 only, the -D option applies to Talor uucp-1.04 and up) +.SH EXTENDED options +An example of the options and how they interact is given below. The working +order while processing the options is left to right: +.nf +X uupoll -gC site1 -gB site2 -x site3 -n -gA site4 site5 +.fi +.PP +this poll will: +.PP +- call immediate site1 with grade C or higher and will place a null job +.PP +- call immediate site2 with grade B or higher and will place a null job +.PP +- call immediate site3 with grade B or higher without placing a null job +.PP +- just placing a null job for site4 and site5 with grade A or higher. These +sites will be called at the next regular schedule. +.SH BUGS +When more than one site is given on the command line and no \-n option is +given there will be an immediate invocation of +.IR uucico +or +.IR autopoll +for +.IR all +sites given. That may lead to a `No port available' condition. +.SH FILES +.ta \w'/usr/spool/uucp/ 'u +.nf +/etc/uucp/ UUCP internal files/utilities +/usr/spool/uucp/ Spool directory +/tmp/poll.log This file is present only if uupoll has been +X compiled to place the messages into a file. +X Otherwise all messages will go to stderr. +X The directory as well as the name may be +X different. The name may be defined at compile time. +.fi +.SH SEE ALSO +uucp(1C), uux(1C), uucico(8C), autopoll(8C) +SHAR_EOF +chmod 0444 uupoll/uupoll.8c || +echo 'restore of uupoll/uupoll.8c failed' +Wc_c="`wc -c < 'uupoll/uupoll.8c'`" +test 4787 -eq "$Wc_c" || + echo 'uupoll/uupoll.8c: original size 4787, current size' "$Wc_c" +fi +# ============= uupoll/uupoll.c ============== +if test -f 'uupoll/uupoll.c' -a X"$1" != X"-c"; then + echo 'x - skipping uupoll/uupoll.c (File already exists)' +else +echo 'x - extracting uupoll/uupoll.c (Text)' +sed 's/^X//' << 'SHAR_EOF' > 'uupoll/uupoll.c' && +/* ---------------------------------------------------------------------------* +X +X Name: uupoll +X +X Author: Klaus Dahlenburg <kdburg@incoahe.hanse.de> +X +X Status: Public domain +X +X Copyright: none +X +X Funktion: The main intention behind this program was to get a full +X replacement of the uupoll supplied by NeXT when using an +X UUCP or a file structure that is different from that hardwired +X config in NeXT's uupoll. The lack of source made it impossible +X to modify the supplied uupoll. +X +X Call: uupoll [-n] [-x] [-g[A | 0-9,A-Z,a-z]] site ... +X +X -n just place a poll file but do not call uucico; +X This option can be given only once. +X -x meaningful only for sites not affected by the -n +X option. It prevents the creation of a poll file; +X the default is to place one. In case the poll fails +X there will be no attempt to poll those sites on +X the next general (unspecific) poll. If using +X autopoll the site will be called at the next + 1 +X run of autopoll. +X -g any grade may be given to meet the criteria for +X a successful poll. The default being specified +X in conf.h (A). +X This option may be given individually for each +X site to call. +X site the name of the site to be called. As many sites +X as necessary may be specified separated by at least +X one blank. +X Note: any site will be called with the options currently in +X effect. The working order is left to right. Example: +X uupoll -gQ site1 site2 -gZ site3 -n site4 +X site1 and site2 will be called immediate with grade Q +X site3 will be called immediate with grade Z. Site4 will +X have a poll file created with grade Z. +X +X Environment: NeXT 2.1 +X +X Called Programs: sort, uniq, uucico (or autopoll), uuname +X +X Compile: no special options are needed +X +X Comments: - should run setuid UUCP or whatever userid is necessary to +X write to the spool directory with the proper ownership of +X the files and to run uucico. +X - No alias expansion is done on the given names. +*/ +X +#if !defined(lint) +static char rcsid[] = "$Id: uupoll.shar,v 1.1 1994/10/24 22:17:53 jtc Exp $"; +#endif /* not lint */ +X +/* $Log: uupoll.shar,v $ +/* Revision 1.1 1994/10/24 22:17:53 jtc +/* Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl). +/* +X * Revision 2.7 1994/04/14 17:22:04 kdburg +X * major rework done +X * +X * Revision 2.6 1994/03/26 17:38:41 kdburg +X * added support for UNAME_DIR; cleanup of some code; adjusted code after +X * obtaining sitenames via popen() +X * +X * Revision 2.5 1994/03/24 19:01:24 kdburg +X * some minor changes; some calls had their rc not checked +X * +X * Revision 2.4 1993/07/08 07:56:26 kdburg +X * befor invoking autopoll stdin is now closed to avoid blocking of +X * terminal +X * +X * Revision 2.3 1993/07/05 19:43:00 kdburg +X * when used interactivly only the start msg is put into the msg-log +X * so far defined (UULOG) +X * +X * Revision 2.2 1993/05/20 18:50:52 kdburg +X * no execute permission to the poll-pgm (uucico/autopoll) was not +X * reflected in the log; when to start message was not given when -x +X * option was present +X * +X * Revision 2.1 1993/05/16 21:48:15 kdburg +X * changed exit() to _exit() in case the exec fails within child +X * +X * Revision 2.0 1993/05/16 14:11:04 kdburg +X * initial revision +X * */ +X +#define CAT 16 +#define SEVERE 8 +#define WARNING 4 +#define OK 0 +#define P_MODE 00647 /* file-mode for poll-file */ +/* Boolean types */ +typedef int bool; +#undef TRUE +#undef FALSE +#define TRUE (1) +#define FALSE (0) +X +#include "conf.h" +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <ctype.h> +#include <sys/file.h> +#include <sys/param.h> +#include <pwd.h> +#include <sys/time.h> +X +#define X_OK 1 /* access: executable ? */ +X +#ifdef ALOG_FILE +X static char Msg_Log[] = ALOG_FILE; /* name of msglog filename */ +#endif +X +#ifdef UNAME_DIR +X static char subcmd[] = " | sort | uniq"; /* pipe that follows uuname */ +#else /* ! UNAME_DIR */ +X static char Sort[] = "uuname | sort | uniq"; /* default to obtain site names */ +#endif /*UNAME_DIR */ +X +static char cGrade[] = DEF_GRADE; /* grade as defined in conf.h */ +static char dGrade[] = "A"; /* use this if DEF_GRADE is invalid */ +#ifdef AUTO_POLL +X static char Auto_Dir[] = AUTO_DIR; /* autopoll lives here */ +#else +X static char Cico_Dir[] = CICO_DIR; /* and here lives cico */ +#endif /* AUTO_POLL */ +X +struct Sites { +X char name[MAXHOSTNAMELEN+1]; /* name of site as supplied by uuname */ +X char grade[1]; /* as passed or defaulted */ +X bool flag; /* TRUE this site should be polled */ +X int asap; /* 1 without -n; 2 with -x option */ +}; +X struct Common_Stor { +X int maxtab; /* high-water-mark for site tab */ +X char *Grade; /* use this as grade for calls */ +X char *Poll_Pgm; /* our name without path */ +X char *called_as; /* but called by this name */ +X int our_pid; /* our process-id */ +X char *Uucico; /* cico's name without path */ +X char This_Site[MAXHOSTNAMELEN+1]; /* our site name */ +X char System[MAXHOSTNAMELEN+1]; /* intermediate to hold sitename */ +X char *Usort; /* will hold uuname + subcmd */ +X struct passwd *pwd; +X struct timeval tp; +X struct timezone tzp; +X struct Sites Sitetab[SITE_MAX]; +X char workf[300]; +X }; +X +/* define the prototypes +X * */ +X +int set_mlog(FILE **seclog, struct Common_Stor *); +int get_sites(struct Common_Stor *); +int Check_Args(int argc, char *argv[], struct Common_Stor *); +int Housekeeping(int argc, char *argv[], struct Common_Stor *); +int Call_Site(struct Common_Stor *); +void *storage(unsigned count, char *errloc, int *Rc, struct Common_Stor *); +X +extern int getpid(); +extern void free(void *ptr); +extern int access(char *path, int mode); +extern int gethostname(char *name, int namelen); +extern int system(char *cmd); +extern int fork(); +extern int execlp(char *name, char *arg0, ...); +extern void *malloc(size_t byteSize); +extern int getuid(); +extern int isatty(int); +extern char *ttyname(int); +extern int open(char *path, int flags, int mode); +extern int close(int fd); +#ifdef __STRICT_ANSI__ +extern FILE *popen(char *command, char *type); +extern int pclose(FILE *stream); +extern void _exit(int status); +#endif /* __STRICT_ANSI__ */ +#ifdef __STRICT_BSD__ +extern int fprintf(FILE *stream, const char *format, ...); +extern int fclose(FILE *stream); +extern char *strerror(int errnum); +extern int fflush(FILE *stream); +extern void exit(int status); +#endif /* __STRICT_BSD__ */ +X +/* --------------------------------------------------------------------------*/ +/* Main */ +/* --------------------------------------------------------------------------*/ +X +int main(int argc, char *argv[]) +{ +X +X struct Common_Stor *sCom_Sto; +X int Maxrc = OK; /* Max err-code encountered so far */ +X int k = 0; +X +X if ( NULL == (sCom_Sto = malloc(sizeof(struct Common_Stor))) ) { +X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n", +X argv[0],"Common_Stor",errno,strerror(errno)); +X exit (CAT); +X } +X +X Maxrc = Housekeeping(argc, argv, sCom_Sto); +X +/* If any errors popped up so far they are of such a nature that it is very +X * questionable to continue; so we better bail out in this case. +X */ +X if (Maxrc <= WARNING) { +X k = Call_Site(sCom_Sto); +X Maxrc = Maxrc >= k ? Maxrc:k; +X } +X k = gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp); +X fprintf(stderr,"%s: (I) ended with rc = %i on %s\n", +X sCom_Sto->called_as, +X Maxrc,k!=0 ? "time unavailable":ctime(&sCom_Sto->tp.tv_sec)); +X fclose(stderr); +X free(sCom_Sto); +X sCom_Sto = NULL; +X exit (Maxrc); +} +X +/* --------------------------------------------------------------------------*/ +/* Functions */ +/* --------------------------------------------------------------------------*/ +X +/* -------------------------------------------------------------------- +X * housekeeping +X */ +X +int Housekeeping(argc, argv, sCom_Sto) +X int argc; +X char *argv[]; +X struct Common_Stor *sCom_Sto; { +X +X FILE *seclog = NULL; +X int Rc = OK; +X int Rci = OK; /* intermediate rc as returnd by functions */ +X +X sCom_Sto->our_pid = getpid(); +X +/* +X * get our name sans path +X * */ +X +X sCom_Sto->called_as = argv[0] + strlen(*argv); +X for(;sCom_Sto->called_as >= argv[0] && *--sCom_Sto->called_as != '/';) +X ; +X sCom_Sto->called_as++; +X +/* if defined set up the name of the message log file otherwise +X * stderr will be used. Setup the cmd string to obtain all known sitenames +X * which will be sorted in ascending order with duplicates removed +X * */ +X +X Rc = set_mlog(&seclog, sCom_Sto); +X if (Rc > WARNING) +X return (Rc); +X +/* put out the started message including the time and the userid. +X * */ +X +X sCom_Sto->pwd = getpwuid(getuid()); +X +X if ((gettimeofday(&sCom_Sto->tp, &sCom_Sto->tzp)) != 0) { /* unacceptable error */ +X fprintf(stderr,"%s: (C) gettimeofday() failed. Reason: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X return (Rc >= CAT ? Rc:CAT); +X } +X +X if (seclog != NULL) { +X fprintf(seclog,"\n%s: (I) started by `%s' (%s) on %s", +X sCom_Sto->called_as, +X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name, +X ttyname(0), +X ctime(&sCom_Sto->tp.tv_sec)); +X fclose(seclog); +X } +X fprintf(stderr,"\n%s: (I) started by `%s' on %s", +X sCom_Sto->called_as, +X (sCom_Sto->pwd==NULL) ? "???":sCom_Sto->pwd->pw_name, +X ctime(&sCom_Sto->tp.tv_sec)); +X +/* set up the default grade +X * */ +X +X sCom_Sto->Grade = dGrade; /* set default for now */ +X if (strlen(cGrade) != 1) { +X fprintf(stderr,"%s: (W) grade %s invalid; default `%s' used\n", +X sCom_Sto->called_as,cGrade,sCom_Sto->Grade); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else +X sCom_Sto->Grade = cGrade; /* Ok, take the one from conf.h */ +X +/* get the program to actually call the site. This is either UUCICO +X * or AUTOPOLL or something completely different. +X * */ +X +#ifdef AUTO_POLL +X sCom_Sto->Uucico = Auto_Dir + strlen(Auto_Dir); +X for(;sCom_Sto->Uucico >= Auto_Dir && *--sCom_Sto->Uucico != '/';) +X ; +X sCom_Sto->Uucico++; +#else /* ! AUTO_POLL */ +X sCom_Sto->Uucico = Cico_Dir + strlen(Cico_Dir); +X for(;sCom_Sto->Uucico >= Cico_Dir && *--sCom_Sto->Uucico != '/';) +X ; +X sCom_Sto->Uucico++; +#endif /* AUTO_POLL */ +X +/* get the path to ourself. +X * */ +X +X sCom_Sto->Poll_Pgm = argv[0] + strlen(argv[0]); +X for(;sCom_Sto->Poll_Pgm >= argv[0] && *--(sCom_Sto->Poll_Pgm) != '/';) +X ; +X sCom_Sto->Poll_Pgm++; +X +/* obtain our sitename +X * */ +X +X if ((gethostname(sCom_Sto->This_Site,MAXHOSTNAMELEN+1)) != 0) { +X fprintf(stderr,"%s: (W) hostname could not be obtained\n", +X sCom_Sto->called_as); +X Rc = (Rc >= WARNING) ? Rc:WARNING; +X } +X +/* obtain all known sitenames +X * */ +X +X Rci = get_sites(sCom_Sto); +X Rc = Rci > Rc ? Rci:Rc; +X +/* check the arguments that we are called with +X * */ +X +X Rci = Check_Args(argc, argv, sCom_Sto); +X Rc = Rci > Rc ? Rci:Rc; +X +X return (Rc); +} +X +/* -------------------------------------------------------------------- +X * check all relevant arguments that have been passed to us. Those args +X * that may be needed for a recall will be copied to a workfield. +X * */ +X +int Check_Args(int argc, char *argv[], struct Common_Stor *sCom_Sto) { +X int i,s,k,n = 0; +X int Rc = OK; +X int One_Site = 0; /* TRUE: found at least one valid site to call */ +X int poll_file = 1; /* FALSE: after -x option given */ +X int def_flag = 0; /* TRUE: when option -n was encountered */ +X +X /* --------------------------------------------------------------*/ +X /* check the arguments passed to us */ +X /* */ +X /* These are: -n -> place a POLL file but do not start uucico */ +X /* -x -> do not place a poll file (immed. poll only) */ +X /* -g? -> specify a grade with the POLL file. The ? */ +X /* may be: 0-9, A-Z, a-z */ +X /* (validity not checked!) */ +X /* site name of the site to call. There many be as */ +X /* many as necessary separated by at least one */ +X /* blank */ +X /* Note: all options will stay in effect as long as they are'nt */ +X /* changed by a new setting. The options -n and -x can't */ +X /* be negated once given; that means place all sites */ +X /* that should be immediately polled to the left of the */ +X /* -n option; the same applies to the -x option which must */ +X /* be left of the -n option to come into effect! */ +X /* The working order is left to right! */ +X /* --------------------------------------------------------------*/ +X +X for (i = 1, s = 0; i < argc; i++) { +X k = strlen(argv[i]); +X switch (*argv[i]) { +X +X /* ----> handle the options */ +X +X case '-': +X n = 1; +X switch (*(argv[i]+n)) { +X case 'n': +X if (k > 2) { +X fprintf(stderr,"%s: (E) invalid specification %s\n", +X sCom_Sto->called_as,argv[i]); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X def_flag = 1; +X break; +X case 'x': +X if (k > 2) { +X fprintf(stderr,"%s: (E) invalid specification %s\n", +X sCom_Sto->called_as,argv[i]); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X if (def_flag) { +X fprintf(stderr,"%s: (W) -x after -n has no effect\n", +X sCom_Sto->called_as); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X else { +X poll_file = 0; +X } +X break; +X case 'g': +X if (k > 3) { +X fprintf(stderr,"%s: (E) invalid specification %s\n", +X sCom_Sto->called_as,argv[i]); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X if (*(argv[i]+n+1) == '\0') { +X fprintf(stderr,"%s: (E) missing grade\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X if (isalnum(*(argv[i]+n+1)) == 0) { +X fprintf(stderr,"%s: (E) invalid grade %s\n", +X sCom_Sto->called_as,argv[i]); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X break; +X } +X strcpy(sCom_Sto->Grade,(argv[i]+n+1)); +X break; +X default: +X fprintf(stderr,"%s: (W) missing/unknown option `-%s' ignored\n", +X sCom_Sto->called_as,argv[i]+n); +X Rc = Rc >= WARNING ? Rc:WARNING; +X break; +X } /* end of switch (*(argv[i]+n)) */ +X break; +X +X /* ----> handle the sitenames */ +X +X default: +X if (strcmp(argv[i],sCom_Sto->This_Site) == 0) { +X fprintf(stderr,"%s: (W) ignoring to call *ourself* %s\n", +X sCom_Sto->called_as,argv[i]); +X Rc = Rc >= WARNING ? Rc:WARNING; +X break; +X } +X strcpy(sCom_Sto->System,argv[i]); +X for(s=0;s<=sCom_Sto->maxtab;s++) { +X if ((n=strcmp(sCom_Sto->Sitetab[s].name,sCom_Sto->System)) >= 0) { +X break; +X } +X } +X if (n != 0) { +X fprintf(stderr,"%s: (W) unknown site (ignored): %s\n", +X sCom_Sto->called_as,sCom_Sto->System); +X Rc = Rc >= WARNING ? Rc:WARNING; +X break; +X } +X +X /* ----> if there was no error we arrive here to save the data */ +X +X strcpy(sCom_Sto->Sitetab[s].grade,sCom_Sto->Grade); +X One_Site = sCom_Sto->Sitetab[s].flag = 1; /* poll this site */ +X if (def_flag) +X sCom_Sto->Sitetab[s].asap = 0; /* poll on next schedule */ +X else { +X sCom_Sto->Sitetab[s].asap = 1; /* poll immediately */ +X if (! poll_file) +X sCom_Sto->Sitetab[s].asap++; /* and do not place a poll file */ +X } +X s++; +X break; +X } /* end of switch (*argv[i]) */ +X } /* end of for(...) */ +X +/* now let's check what we've gotten so far. If no valid data has been */ +/* entered we will indicate that to prevent further processing */ +X +X if (! One_Site) { +X fprintf(stderr,"%s: (E) found no site to call\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X +return (Rc); +} +X +int Call_Site(struct Common_Stor *sCom_Sto) { +X +/* For all sites that carry the -n flag we will place */ +/* a poll file into the appropriate directory. For all others there will */ +/* be an immediate call to uucico (or autopoll) */ +/* Those sites that have been named on the command have the corresponding */ +/* flag byte set to one. */ +X +X int fdpoll; /* fildes for the poll file */ +X int mode = P_MODE; /* mode for poll file */ +X int i = 0; +X int Rc = OK; +X int pid = 0; /* process-id after fork() */ +X +X for(i=0;(i<=sCom_Sto->maxtab);i++) { +X if (sCom_Sto->Sitetab[i].flag == 0) /* should we trigger this one ? */ +X continue; /* nope */ +X +/* processing done for delayed polls only */ +X +X if (sCom_Sto->Sitetab[i].asap <= 1) { /* do not place a poll file */ +X /* for sites that will be polled */ +X /* immediate and carry the -x option */ +#ifdef HAVE_SPOOLDIR_TAYLOR +X sprintf(sCom_Sto->workf,"%s/%s/C./C.%sPOLL", +X SPOOL_DIR, +X sCom_Sto->Sitetab[i].name, +X sCom_Sto->Sitetab[i].grade); +#endif +#ifdef HAVE_SPOOLDIR_HDB +X sprintf(sCom_Sto->workf,"%s/%s/C.%s%sPOLL", +X SPOOL_DIR, +X sCom_Sto->Sitetab[i].name, +X sCom_Sto->Sitetab[i].name, +X sCom_Sto->Sitetab[i].grade); +#endif +#ifdef HAVE_SPOOLDIR_BSD +X sprintf(sCom_Sto->workf,"%s/C./C.%s%sPOLL", +X SPOOL_DIR, +X sCom_Sto->Sitetab[i].name, +X sCom_Sto->Sitetab[i].grade); +#endif +X +X fflush(stderr); +X if ((fdpoll=open(sCom_Sto->workf,O_CREAT,mode)) <= 0) { +X fprintf(stderr,"%s: (E) couldn't place poll file for system: %s. Reason: %s\n", +X sCom_Sto->called_as, +X sCom_Sto->Sitetab[i].name, +X strerror(errno)); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X else { +X if (close(fdpoll) != 0) { +X fprintf(stderr,"%s: (W) close failed for poll file; system: %s. Reason: %s\n", +X sCom_Sto->called_as, +X sCom_Sto->Sitetab[i].name, +X strerror(errno)); +X Rc = Rc >= WARNING ? Rc:WARNING; +X } +X } +X } +X +/* the following processing is done for immediate polls only +X * there is no wait for the completion of the called program that actually +X * calls the site +X * */ +X +X fflush(stderr); +X if (Rc <= WARNING) { +X fprintf(stderr,"%s: (I) site %s will be called %s\n", +X sCom_Sto->called_as, +X sCom_Sto->Sitetab[i].name, +X sCom_Sto->Sitetab[i].asap == 0 ? +X "upon next poll":"immediately"); +X if (sCom_Sto->Sitetab[i].asap >= 1) +X { +#ifdef AUTO_DIR +X if ( access(Auto_Dir,X_OK) != 0) /* do we have xecute permission ? */ +#else /* ! AUTO_DIR */ +X if ( access(Cico_Dir,X_OK) != 0) /* do we have xecute permission ? */ +#endif /* AUTO_DIR */ +X { +X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico, +X errno,strerror(errno)); +X return (Rc >= CAT ? Rc:CAT); /* abandon the run */ +X } +X switch (pid = fork()) +X { +X case -1: +X fprintf(stderr,"%s: (C) could not fork() Reason-code: %i (%s)\n", +X sCom_Sto->called_as, +X errno,strerror(errno)); +X return (Rc >= CAT ? Rc:CAT); +X case 0: +X if (isatty(0)) +X close(0); /* don't block the terminal by autopoll */ +#ifdef AUTO_DIR +X execlp(Auto_Dir, +#else /* ! AUTO_DIR */ +X execlp(Cico_Dir, +#endif /*AUTO_DIR */ +X sCom_Sto->Uucico, +X "-D", "-r1", "-s", +X sCom_Sto->Sitetab[i].name,0); +X fprintf(stderr,"%s: (C) could not start %s. Reason-code: %i (%s)\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico, +X errno,strerror(errno)); +X _exit (CAT); /* child: bail out */ +X default: +X fflush(stderr); +X fprintf(stderr,"%s: (I) %s [%d] started; site: %s\n", +X sCom_Sto->called_as, +X sCom_Sto->Uucico, +X pid, +X sCom_Sto->Sitetab[i].name); +X } /* switch (pid = fork()) */ +X } /* if (Sitetab ...) */ +X } /* if (Rc ...) */ +X } /* for(i=0;(i<= ...)) */ +X return (Rc); +} +X +X /* ------------------------------------------------------------------ +X * storage - get some memory +X */ +X +void *storage(unsigned count, +X char *location, +X int *Rc, +X struct Common_Stor *sCom_Sto) +{ +X void *p; +X +X if( NULL == (p= malloc(count)) ) { +X fprintf(stderr,"%s: (C) malloc failed (%s). Reason: %i (%s)\n", +X sCom_Sto->called_as,location,errno,strerror(errno)); +X *Rc = *Rc >= CAT ? *Rc:CAT; +X } +X return p; +} +X +/* ------------------------------------------------------------------ +X * if defined open the message log file otherwise all mesages will go +X * to stderr. If UNAME_DIR is defined construct the command to be +X * passed to popen(); if undefined the default will be used +X * */ +X +int set_mlog(FILE **seclog, struct Common_Stor *sCom_Sto) { +X +X int Rc = 0; +X +#ifdef ALOG_FILE +X if (!isatty(0)) { +X if ((freopen(Msg_Log,"a",stderr)) == NULL) { +X fprintf(stdout,"%s: (C) Could not open msglog: %s\n", +X sCom_Sto->called_as,Msg_Log); +X return (Rc >= CAT ? Rc:CAT); +X } +X } +X else { +X if ((*seclog = fopen(Msg_Log,"a")) == NULL) { +X fprintf(stderr,"%s: (C) Could not open msglog: %s\n", +X sCom_Sto->called_as,Msg_Log); +X return (Rc >= CAT ? Rc:CAT); +X } +X } +#endif /* ALOG_FILE */ +X +/* set up the pipe together with the complete path to uuname */ +X +#ifdef UNAME_DIR +X if ((sCom_Sto->Usort = (char *)storage (sizeof(UNAME_DIR)+sizeof(subcmd), +X "Sort",&Rc, sCom_Sto)) != NULL) { +X strncpy(sCom_Sto->Usort,UNAME_DIR,strlen(UNAME_DIR)); /* paste in the path */ +X strcat(sCom_Sto->Usort,subcmd); /* chain the pipe to it */ +X } +#else /* ! UNAME_DIR */ +X sCom_Sto->Usort = &Sort; /* set pointer to uuname + sort */ +#endif /* UNAME_DIR */ +X +X return (Rc); +} +X +/* ------------------------------------------------------------------ +X * obtain all active sitenames +X * */ +X +int get_sites(struct Common_Stor *sCom_Sto) { +X +X int i = 0; +X int n; +X int Rc = 0; +X FILE *infile; +X +X if ((infile=popen(sCom_Sto->Usort,"r")) != NULL) { +X while(fgets(sCom_Sto->Sitetab[i].name,MAXHOSTNAMELEN+1,infile)) { +X if (i > SITE_MAX) { /* let'm run so that we can give */ +X i++; /* the user some guidance */ +X continue; /* we'll tell the user later on */ +X } +X n = strlen(sCom_Sto->Sitetab[i].name)-1; /* offset: next to last char */ +X sCom_Sto->Sitetab[i].name[n] = '\0'; /* strip trailing newline */ +X sCom_Sto->Sitetab[i].flag = FALSE; /* TRUE: poll this site */ +X sCom_Sto->Sitetab[i].asap = FALSE; /* TRUE: immediate poll */ +X strcpy(sCom_Sto->Sitetab[i].grade,sCom_Sto->Grade); +X sprintf(sCom_Sto->workf,"%s%s",STATUS_DIR,sCom_Sto->Sitetab[i].name); +X sCom_Sto->maxtab = i++; /* set high-water-mark */ +X } +X if (ferror(infile) != 0) { +X fprintf(stderr,"%s: (E) fgets() for sitenames failed reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X pclose(infile); +X +X /* +X * check for an empty table (strange but possible) +X */ +X +X if (sCom_Sto->maxtab == 0) { +X fprintf(stderr,"%s: (E) could not obtain sitenames.\n", +X sCom_Sto->called_as); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X else { +X +X /* in case the internal table overflows we'll now give notice and tell +X * the user by which amount the table has to be increased to hold all +X * site-names +X */ +X +X if (i > SITE_MAX) { +X fprintf(stderr,"%s: (E) number of sites > internal tab\n", +X sCom_Sto->called_as); +X fprintf(stderr,"%s: (E) increase SITE_MAX to >= %d and recompile\n", +X sCom_Sto->called_as,i); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X } +X } /* sCom_Sto->maxtab == 0 */ +X +X } +X else /* infile == NULL */ +X { +X fprintf(stderr,"%s: (E) could not sort sitenames. Reason-code: %i (%s)\n", +X sCom_Sto->called_as,errno,strerror(errno)); +X Rc = Rc >= SEVERE ? Rc:SEVERE; +X +X } /* if ((infile=popen(sCom_Sto->Usort,"r")) ... */ +X +X return (Rc); +} +SHAR_EOF +chmod 0444 uupoll/uupoll.c || +echo 'restore of uupoll/uupoll.c failed' +Wc_c="`wc -c < 'uupoll/uupoll.c'`" +test 27587 -eq "$Wc_c" || + echo 'uupoll/uupoll.c: original size 27587, current size' "$Wc_c" +fi +exit 0 diff --git a/gnu/libexec/uucp/contrib/uurate.c b/gnu/libexec/uucp/contrib/uurate.c index ceab41c53bf..129b8e7dfb2 100644 --- a/gnu/libexec/uucp/contrib/uurate.c +++ b/gnu/libexec/uucp/contrib/uurate.c @@ -5,16 +5,16 @@ * and outputs various statistical data to standard out. * * Author: - * Bob Denny (denny@alisa.com) - * Fri Feb 7 13:38:36 1992 + * Bob Denny (denny@alisa.com) + * Fri Feb 7 13:38:36 1992 * * Original author: - * Mark Pizzolato mark@infopiz.UUCP + * Mark Pizzolato mark@infopiz.UUCP * * Edits: - * Bob Denny - Fri Feb 7 15:04:54 1992 - * Heavy rework for Taylor UUCP. This was the (very old) uurate from - * DECUS UUCP, which had a single logfile for activity and stats. + * Bob Denny - Fri Feb 7 15:04:54 1992 + * Heavy rework for Taylor UUCP. This was the (very old) uurate from + * DECUS UUCP, which had a single logfile for activity and stats. * Personally, I would have done things differently, with tables * and case statements, but in the interest of time, I preserved * Mark Pizzolato's techniques and style. @@ -23,41 +23,165 @@ * Changes to report format suggested by Francois Pinard and others. * Add summary report, format from uutraf.pl (perl script), again * thanks to Francois. Integrate and checkout with 1.03 of Taylor UUCP. + * + * Stephan Niemz <stephan@sunlab.ka.sub.org> - Fri Apr 9 1993 + * - Print totals in summary report, + * - show all commands in execution report, + * - count incoming calls correctly, + * - suppress empty tables, + * - don't divide by zero in efficiency report, + * - limit the efficiency to 100% (could be more with the i-protocol), + * - suppress some zeros to improve readability, + * - check for failure of calloc, + * - -h option changed to -s for consistency with all other uucp commands + * (but -h was left in for comptibility). + * + * Scott Boyd <scott@futures.com> - Thu Aug 26 13:21:34 PDT 1993 + * - Changed hosts linked-list insertion routine so that hosts + * are always listed in alphabetical order on reports. + * + * Klaus Dahlenburg <kdburg@incoahe.hanse.de> - Fri Jun 18 1993 (1.2.2) + * - redesigned the printed layout (sticked to those 80 column tubes). + * - 'Retry time not ...' and ' ERROR: All matching ports ...' will now be + * counted as calls and will raise the failed-call counter. + * - times now shown as hh:mm:ss; the fields may hold up to 999 hrs + * (a month equals 744 hrs at max). Printing will be as follows: + * + * hrs > 0 hh:mm:ss + * min > 0 mm:ss + * sec > 0 ss + * leading zeroes are suppressed. + * + * - the bytes xfered will be given in thousands only (we're counting + * so 1K is 1000 bytes!). Sums up to 9,999,999.9 thousand can be shown. + * - dropped the fractions of a byte in columns: bytes/second (avg cps). + * - File statistic changed to display in/out in one row instead of 2 + * separate reports. + * - eliminated the goto in command report and tightened the code; also + * the 'goto usage' has been replaced by a call to void usage() with no + * return (exit 1). + * - a totaling is done for all reports now; the total values are held + * within the structure; after finishing read there will be an alloc + * for a site named 'Total' so that the totals line will be printed + * more or less automatically. + * - option -t implemented: that is every possible report will be given. + * - the start and end date/time of the input files are printed; can be + * dropped by the -q option at run time. + * - it is now possible to use Log/Stats files from V2_LOGGING configs. + * They must however not be mixed together (with each other). + * - the Log/Stats files are taken from config which is passed via + * Makefile at compile time. Variable to set is: newconfigdir. If the + * default config can't be read the default values are used + * (the config is optional!). + * Note: keyword/filename must be on the same line (no continuation). + * - -I option implemented to run with a different config file. In case + * the file can't be opened the run is aborted! + * - -q option implemented to run without environment report (default is + * FALSE: print the report). + * - -p option added to print protocol statistics: one for the packets + * and one for the errors encountered + * - reapplied patch by Scott Boyd <scott@futures.com> that I did not + * get knowledge of */ +/* $Log: uurate.c,v $ +/* Revision 1.2 1994/10/24 22:17:57 jtc +/* Upgraded to Taylor UUCP 1.05 (Thanks to John Kohl). +/* + * Revision 1.15 1994/04/07 21:47:11 kdburg + * printed 'no data avail' while there was data; layout chnaged + * (cosmetic only) + * + * Revision 1.14 1994/04/07 21:16:32 kdburg + * the layout of the protocol-used line within the LOGFILE changed + * from 1.04 to 1.05; both formats may be used together; output + * changed for packet report (columns adjusted) + * + * Revision 1.13 1994/04/04 10:04:35 kdburg + * cosmetic change to the packet-report (separator lines) + * + * Revision 1.12 1994/03/30 19:52:04 kdburg + * incorporated patch by Scott Boyd which was missing from this version + * of uurate.c. Left the comment in cronological order. + * + * Revision 1.11 1994/03/28 18:53:22 kdburg + * config not checked properly for 'logfile/statsfile' overwrites, bail-out + * possible; wrong file name written to log for statsfile when found + * + * Revision 1.10 1993/09/28 16:46:51 kdburg + * transmission failures denoted by: failed after ... in stats file + * have not been counted at all. + * + * Revision 1.9 1993/08/17 23:38:36 kdburg + * sometimes a line(site) was missing from the protocol stats due + * to a missing +; added option -d and -v reassing option -h to print + * the help; a zero was returned instead of a null-pointer by + * prot_sum + * + * Revision 1.8 1993/07/03 06:58:55 kdburg + * empty input not handled properly; assigned some buffer to input; msg + * not displayed when no protocol data was available + * + * Revision 1.7 1993/06/27 10:31:53 kdburg + * rindex was replaced by strchr must be strrchr + * + * Revision 1.6 1993/06/26 06:59:18 kdburg + * switch hdr_done not reset at beginning of protocol report + * + * Revision 1.5 1993/06/25 22:22:30 kdburg + * changed rindex to strchr; if there is no NEWCONFIG defined take + * appropriate action + * + * Revision 1.4 1993/06/25 20:04:07 kdburg + * added comment about -p option; inserted proto for rindex + * + * Revision 1.3 1993/06/25 19:31:14 kdburg + * major rework done; added protocol reports (normal/errors) + * + * Revision 1.2 1993/06/21 19:53:54 kdburg + * init + * */ -char version[] = "@(#) Taylor UUCP Log File Summary Filter, Version 1.2"; - -#include <ctype.h> /* Character Classification */ -#include <string.h> +char version[] = "@(#) Taylor UUCP Log File Summary Filter, Version 1.2.2"; +static char rcsid[] = "$Id: uurate.c,v 1.2 1994/10/24 22:17:57 jtc Exp $"; +#include <ctype.h> /* Character Classification */ #include <math.h> - #include "uucp.h" +/* uucp.h includes string.h or strings.h, no include here. */ #define _DEBUG_ 0 - + /* * Direction of Calling and Data Transmission */ -#define IN 0 /* Inbound */ -#define OUT 1 /* Outbound */ + +#define IN 0 /* Inbound */ +#define OUT 1 /* Outbound */ + +/* + * define some limits + */ +#define MAXCOLS 8 /* report has this # of columns incl. 'name' */ +#define MAXREP 6 /* number of reports available */ +#define MAXFNAME 64 /* max input file name length incl. path*/ +#define MAXDNAME 8 /* max display (Hostname) name length */ /* * Data structures used to collect information */ struct File_Stats { - int files; /* Files Transferred */ - unsigned long bytes; /* Data Size Transferred*/ - double time; /* Transmission Time */ + int files; /* Files Transferred */ + unsigned long bytes; /* Data Size Transferred*/ + double time; /* Transmission Time */ }; struct Phone_Call { - int calls; /* Call Count */ - int succs; /* Successful calls */ - double connect_time; /* Connect Time Spent */ - struct File_Stats flow[2]; /* Rcvd & Sent Data */ + int calls; /* Call Count */ + int succs; /* Successful calls */ + double connect_time; /* Connect Time Spent */ + struct File_Stats flow[2]; /* Rcvd & Sent Data */ }; struct Execution_Command @@ -67,591 +191,1664 @@ struct Execution_Command int count; }; +struct Protocol_Summary + { + struct Protocol_Summary *next; + char type[3]; + long int pr_cnt; + long int pr_psent; + long int pr_present; + long int pr_preceived; + long int pr_eheader; + long int pr_echksum; + long int pr_eorder; + long int pr_ereject; + long int pr_pwinmin; + long int pr_pwinmax; + long int pr_psizemin; + long int pr_psizemax; + }; + struct Host_entry { struct Host_entry *next; char Hostname[32]; - struct Execution_Command *cmds; /* Local Activities */ - struct Phone_Call call[2]; /* In & Out Activities */ + struct Execution_Command *cmds; /* Local Activities */ + struct Phone_Call call[2]; /* In & Out Activities */ + struct Protocol_Summary *proto; }; + struct Host_entry *hosts = NULL; + struct Host_entry *tot = NULL; + struct Host_entry *cur = NULL; + struct Execution_Command *cmd, *t_cmds = NULL; + struct Protocol_Summary *prot, *t_prot, *s_prot, *ss_prot = NULL; /* * Stuff for getopt() */ -extern int optind; /* GETOPT : Option Index */ -extern char *optarg; /* GETOPT : Option Value */ -extern void *calloc(); - -static void fmtime(); -static void fmbytes(); +extern int optind; /* GETOPT : Option Index */ +extern char *optarg; /* GETOPT : Option Value */ +#if ! HAVE_STDLIB_H + extern pointer *calloc(); +#endif /* HAVE_STDLIB_H */ /* * Default files to read. Taken from Taylor compile-time configuration. - * Must look like an argvec, hence the dummy argv[0]. + * def_logs must look like an argvec, hence the dummy argv[0]. + * Maybe later modified by scanning the config */ -static char *(def_logs[3]) = { "", LOGFILE, STATFILE }; + +static char *def_logs[3] = { NULL, NULL, NULL}; +char *I_conf = NULL; /* points to config lib given by -I option */ +char *D_conf = NULL; /* points to config lib from makefile */ +char *Tlog = NULL; /* points to Log-file */ +char *Tstat = NULL; /* points to Stats-file */ +char Pgm_name[64]; /* our pgm-name */ +char logline[BUFSIZ+1]; /* input area */ +char noConf[] = "- not defined -"; +char buff[16*BUFSIZ]; +char sbuff[2*BUFSIZ]; /* - * Misc. strings for reports + * Boolean switches for various decisions */ -static char *(file_hdr[2]) = { "\nReceived file statistics:\n", - "\nSent file statistics\n" }; - + + int p_done = FALSE; /* TRUE: start date/time of file printed */ + int hdr_done = FALSE; /* TRUE: report header printed */ + int show_files = FALSE; /* TRUE: -f option given */ + int show_calls = FALSE; /* TRUE: -c option given */ + int show_commands = FALSE; /* TRUE: -x option given */ + int show_efficiency = FALSE; /* TRUE: -e option given */ + int show_all = FALSE; /* TRUE: -t option given */ + int show_proto = FALSE; /* TRUE: -p option given */ + int use_stdin = FALSE; /* TRUE: -i option given */ + int be_quiet = FALSE; /* TRUE: -q option given */ + int have_files[2]; /* TRUE: [IN] or [OUT] files found */ + int have_calls = FALSE; /* TRUE: in/out calls found */ + int have_commands = FALSE; /* TRUE: found uuxqt records */ + int have_proto = FALSE; /* TRUE: protocol data found */ + int no_records = TRUE; /* FALSE: got one record from file */ + +/* + * protos + */ + +static pointer *getmem(unsigned n); +static void inc_cmd(struct Execution_Command **, char *name); +static void fmtime(double sec, char *buf); +static void fmbytes(unsigned long n, char *buf); +static void usage(); +static int chk_config(char *conf, int n, int type); +static void hdrprt(char c, int bot); +struct Protocol_Summary *prot_sum(struct Protocol_Summary **, char *, int); + /* * BEGIN EXECUTION */ -main(argc, argv) -int argc; -char *argv[]; + +int main(argc, argv) + int argc; + char *argv[]; { - char c; - char *p, *s; - struct Host_entry *hosts = NULL; - struct Host_entry *cur = NULL; - struct Host_entry *e; - struct Execution_Command *cmd; - struct Execution_Command *ec; - char Hostname[64]; FILE *Log = NULL; - char logline[1024]; + int c; + char *p, *s, *stt, *flq = NULL; + char Hostname[MAXHOSTNAMELEN]; /* def taken from <sys/param.h> */ + char Filename[15]; /* filename to be printed */ + char in_date[14]; /* holds the date info of record read*/ + char in_time[14]; /* holds the time info of record read */ + char dt_info[31]; /* holds the date info from the last record read */ char *logmsg; - int sent; - int called; - int show_files = 0; /* I prefer boolean, but... */ - int show_calls = 0; - int show_commands = 0; - int show_efficiency = 0; - int show_summary = 0; - int have_files = 0; - int have_calls = 0; - int have_commands = 0; - int use_stdin = 0; - Hostname[0] = '\0'; + int sent, called = IN; + int report = 0; /* if <= 0 give msg that no report was avail. */ + int junk; + + /* -------------------------------------------------------------------- + * P r o l o g + * -------------------------------------------------------------------- + */ + + Hostname[0] = '\0'; + have_files[IN]= have_files[OUT]= FALSE; + setvbuf(stdout,sbuff,_IOFBF,sizeof(sbuff)); + + /* + * get how we've been called isolate the name from the path + */ + if ((stt = strrchr(argv[0],'/')) != NULL) + strcpy(Pgm_name,++stt); + else + strcpy(Pgm_name,argv[0]); + def_logs[0] = Pgm_name; + /* * I wish the compiler had the #error directive! */ -#if !HAVE_TAYLOR_LOGGING - fprintf(stderr, "uurate cannot be used with your configuration of\n"); - fprintf(stderr, "Taylor UUCP. To use uurate you must be using the\n"); - fprintf(stderr, "TAYLOR_LOGGING configuration.\n"); + +#if !HAVE_TAYLOR_LOGGING && !HAVE_V2_LOGGING + fprintf(stderr,"\a%s: (E) %s\n",Pgm_name,"Your config of Taylor UUCP is not yet supported."); + fprintf(stderr,"%s: (E) %s\n",Pgm_name,"Current support is for V2 or TAYLOR logging only."); + puts(" Run aborted due to errors\n") exit(1); #endif /* - * Process the command line arguments + * get some mem to store the default config name (def's are in + * policy.h ) */ - while((c = getopt(argc, argv, "h:cfexai")) != EOF) - { - switch(c) - { - case 'h': - strcpy(Hostname, optarg); - break; - case 'c': - show_calls = 1; - break; - case 'f': - show_files = 1; - break; - case 'x': - show_commands = 1; - break; - case 'e': - show_efficiency = 1; - break; - case 'a': - show_calls = show_files = show_commands = show_efficiency = 1; - break; - case 'i': - use_stdin = 1; - break; - default : - goto usage; - } - } + if (sizeof(NEWCONFIGLIB) > 1) /* defined at compile time */ + { + D_conf = (char *)getmem((sizeof(NEWCONFIGLIB) + sizeof("/config"))); + strcpy(D_conf,NEWCONFIGLIB); /* passed by makefile */ + strcat(D_conf,"/config"); + } + Tlog = (char *)getmem(sizeof(LOGFILE)); + Tstat = (char *)getmem(sizeof(STATFILE)); + Tlog = LOGFILE; + Tstat = STATFILE; + /* - * If no report switches given, show summary report. + * Process the command line arguments */ - if (show_calls == 0 && show_files == 0 - && show_efficiency == 0 && show_commands == 0) - show_summary = 1; - + + while((c = getopt(argc, argv, "I:s:cfdexaitphv")) != EOF) + { + switch(c) + { + case 'h': + (void) usage(); + case 's': + strcpy(Hostname, optarg); + break; + case 'c': + show_calls = TRUE; + ++report; + break; + case 'd': + printf("%s: (I) config-file default: %s\n",Pgm_name,D_conf); + exit (0); + break; + case 'f': + show_files = TRUE; + ++report; + break; + case 'x': + show_commands = TRUE; + ++report; + break; + case 'e': + show_efficiency = TRUE; + ++report; + break; + case 'a': + show_calls = show_files = show_commands = show_efficiency = TRUE; + report = 4; + break; + case 'i': + use_stdin = TRUE; + break; + case 't': + show_all = TRUE; + report = MAXREP; + break; + case 'p': + show_proto = TRUE; + ++report; + break; + case 'I': + I_conf = (char *)getmem(sizeof(optarg)); + I_conf = optarg; + break; + case 'q': + be_quiet = TRUE; + break; + case 'v': + printf("%s\n",rcsid); + exit (0); + default : + (void) usage(); + } + } + if (report == 0) /* no options given */ + ++report; /* at least summary can be printed */ + if (! be_quiet) + hdrprt('i',0); /* print header for environment info */ + /* * Adjust argv and argc to account for the args processed above. */ + argc -= (optind - 1); argv += (optind - 1); /* - * If further args present, Assume rest are logfiles for us to process, - * otherwise, take input from Log and Stat files provided in the - * compilation environment of Taylor UUCP. If -i was given, Log already - * points to stdin and no file args are accepted. + * If further args present, Assume rest are logfiles for us to process + * which should be given in pairs (log plus stat) otherwise the results may + * not come out as expected! If no further args are present take input from + * Log and Stat files provided in the compilation environment of Taylor UUCP. + * If -i was given, Log already points to stdin and no file args are accepted. + */ + + if (use_stdin) /* If -i, read from stdin */ + { + if (argc != 1) /* No file arguments allowed */ + { + fprintf(stderr,"\a%s: (E) %s\n",Pgm_name, + "it's not posssible to give file args with '-i'"); + (void) usage(); + } + else + { + argc = 2; + Log = stdin; + if (! be_quiet) + puts(" Input from stdin; no other files will be used\n"); + } + } + else + { + if (argc != 1) /* file arguments are present */ + { + if (! be_quiet) + puts(" No defaults used; will use passed file arguments\n"); + } + else /* Read from current logs */ + { + def_logs[1] = Tlog; /* prime the */ + def_logs[2] = Tstat; /* file names */ + if (! be_quiet) + printf(" Config for this run: "); + + if (I_conf != NULL) + { + junk = 0; + if (! be_quiet) + printf("%s\n",I_conf); + if (0 != (chk_config(I_conf,be_quiet,junk))) + return (8); + } + else + { + if (D_conf != NULL) + { + junk = 1; /* indicate default (compiled) config */ + if (! be_quiet) + printf("%s\n",D_conf); + chk_config(D_conf,be_quiet,junk); + } + else + if (! be_quiet) + printf("%s\n",noConf); + } + def_logs[1] = Tlog; /* final setting of */ + def_logs[2] = Tstat; /* file names */ + argv = def_logs; /* Bash argvec to log/stat files */ + argc = sizeof(def_logs) / sizeof(def_logs[0]); + } + } + + /* -------------------------------------------------------------------- + * MAIN LOGFILE PROCESSING LOOP + * -------------------------------------------------------------------- */ - if(argc == 1) /* No file arguments */ + + if (!use_stdin) + { + if (argc < 3 && ! be_quiet) + { + puts(" (W) there is only one input file!"); + puts(" (W) some reports may not be printed"); + } + if (! be_quiet) + hdrprt('d',0); /* give subheaderline */ + } + + while (argc > 1) + { + if (!use_stdin && (Log = fopen(argv[1], "r")) == NULL) { - if (use_stdin) /* If -i, read from stdin */ - { - argc = 2; - Log = stdin; - } - else /* Read from current logs */ - { - argc = 3; /* Bash argvec to default log/stat files */ - argv = &def_logs[0]; - } + perror(argv[1]); + exit (8); } - else if (use_stdin) /* File args with -i is an error */ + setvbuf(Log,buff,_IOFBF,sizeof(buff)); + if ((flq = strrchr(argv[1], '/')) == NULL) + strncpy(Filename,argv[1],sizeof(Filename)-1); + else + strncpy(Filename,++flq,sizeof(Filename)-1); + + strcpy(in_date," n/a"); + strcpy(in_time," n/a"); + p_done = FALSE; /* no info printed yet */ + no_records = TRUE; /* not read any record yet */ + + /* + * Read each line of the logfile and collect information + */ + + while (fgets(logline, sizeof(logline), Log)) { - fprintf(stderr, "uurate (error): file args given with '-i'\n"); - goto usage; + /* + * The host name of the other end of the connection is + * always the second field of the log line, whether we + * are reading a Log file or a Stats file. Set 'p' to + * point to the second field, null-terminated. Skip + * the line if something is funny. V2 and Taylor ar identical + * up to this part. Put out the start/end date of the files read; + */ + + if (NULL == (p = strchr(logline, ' '))) + continue; + no_records = FALSE; /* got one (usable) record at least */ + ++p; + + if (NULL != (stt = strchr(p, '('))) + { + if (! p_done && ! use_stdin && ! be_quiet) + { + +#if HAVE_TAYLOR_LOGGING + sscanf(++stt,"%s%*c%[^.]",in_date,in_time); +#endif /* HAVE_TAYLOR_LOGGING */ + +#if HAVE_V2_LOGGING + sscanf(++stt,"%[^-]%*c%[1234567890:]",in_date,in_time); +#endif /* HAVE_V2_LOGGING */ + + printf(" %-14s %10s %8s",Filename, in_date, in_time); + strcpy(in_date," n/a"); /* reset to default */ + strcpy(in_time," n/a"); + p_done = TRUE; + } + else + { + if (! use_stdin && ! be_quiet) /* save for last time stamp prt. */ + strncpy(dt_info,++stt,sizeof(dt_info)-1); + } + } + + if (NULL != (s = strchr(p, ' '))) + *s = '\0'; + for (s = p; *s; ++s) + if (isupper(*s)) + *s = tolower(*s); + + /* + * Skip this line if we got -s <host> and + * this line does not contain that host name. + * Don't skip the `incoming call' line with the system name `-'. + */ + + if (Hostname[0] != '\0') + if ( (p[0] != '-' || p[1] != '\0') && 0 != strcmp(p, Hostname) ) + continue; + + /* + * We are within a call block now. If this line is a file + * transfer record, determine the direction. If not then + * skip the line if it is not interesting. + */ + + if ((s = strchr(++s, ')')) == NULL) + continue; + +#if ! HAVE_TAYLOR_LOGGING +#if HAVE_V2_LOGGING + if ((strncmp(s,") (",3)) == 0) /* are we in stats file ?) */ + if ((s = strchr(++s, ')')) == NULL) + continue; /* yes but strange layout */ +#endif /* HAVE_V2_LOGGING */ +#endif /* ! HAVE_TAYLOR_LOGGING */ + + logmsg = s + 2; /* Message is 2 characters after ')' */ + if ((0 != strncmp(logmsg, "Call complete", 13)) && + (0 != strncmp(logmsg, "Calling system", 14)) && + (0 != strncmp(logmsg, "Incoming call", 13)) && + (0 != strncmp(logmsg, "Handshake successful", 20)) && + (0 != strncmp(logmsg, "Retry time not", 14)) && + (0 != strncmp(logmsg, "ERROR: All matching ports", 25)) && + (0 != strncmp(logmsg, "Executing", 9)) && + (0 != strncmp(logmsg, "Protocol ", 9)) && + (0 != strncmp(logmsg, "sent ", 5)) && + (0 != strncmp(logmsg, "received ", 9)) && + (0 != strncmp(logmsg, "failed after ", 13)) && + (0 != strncmp(logmsg, "Errors: ", 8))) + continue; + + /* + * Find the Host_entry for this host, or create a new + * one and link it on to the list. + */ + + if ((cur == NULL) || (0 != strcmp(p, cur->Hostname))) + { + struct Host_entry *e, *last; + + for (e= cur= hosts; cur != NULL ; e= cur, cur= cur->next) + if (0 == strcmp(cur->Hostname, p)) + break; + if (cur == NULL) + { + cur= (struct Host_entry *)getmem(sizeof(*hosts)); + strcpy(cur->Hostname, p); + if (hosts == NULL) + e= hosts= cur; + else { + e = hosts; + last = NULL; + while (e != NULL) { + if (strcmp(e->Hostname, cur->Hostname) <= 0) { + if (e->next == NULL) { + e->next = cur; + break; + } + last = e; + e = e->next; + } + else { + cur->next = e; + if (last == NULL) + hosts = cur; + else + last->next = cur; + break; + } + } /* while (e != NULL) */ + } /* hosts == NULL */ + } /* cur == NULL */ + } + + /* + * OK, if this is a uuxqt record, find the Execution_Command + * structure for the command being executed, or create a new + * one. Then count an execution of this command. + * (Log file only) + */ + + if (0 == strncmp(logmsg, "Executing", 9)) + { + if (NULL == (p = strchr(logmsg, '('))) + continue; + if ((s = strpbrk(++p, " )")) == NULL) + continue; + *s = '\0'; + inc_cmd(&cur->cmds, p); + inc_cmd(&t_cmds, p); + have_commands = TRUE; + continue; + } + + /* + * Count start of outgoing call. + */ + + if ((0 == strncmp(logmsg, "Calling system", 14)) || + (0 == strncmp(logmsg, "Retry time not", 14)) || + (0 == strncmp(logmsg, "ERROR: All matching ports", 25))) + { + called = OUT; + cur->call[OUT].calls++; + have_calls = TRUE; + s_prot = NULL; /* destroy pointer to protocol */ + continue; + } + + /* + * Count start of incoming call. + */ + + if (0 == strncmp(logmsg, "Incoming call", 13)) + { + called = IN; + s_prot = NULL; /* destroy pointer to protocol */ + continue; + } + + /* + * On an incoming call, get system name from the second line. + * Get protocol type and size/window too + */ + + if (0 == strncmp(logmsg, "Handshake successful", 20)) + { + if ( called==IN ) + cur->call[IN].calls++; + have_calls = TRUE; + s_prot = NULL; /* destroy pointer to protocol */ + if (NULL == (p = strchr(logmsg, '('))) + continue; + if (0 == strncmp(p, "(protocol ", 10)) + { + if (NULL == (p = strchr(p, '\''))) + continue; + ss_prot = prot_sum(&cur->proto, ++p, 1); + s_prot = prot_sum(&t_prot, p, 1); + continue; + } + } + + /* + * check protocol type and get stats + * + */ + + if (0 == strncmp(logmsg, "Protocol ", 9)) + { + s_prot = NULL; /* destroy pointer to protocol */ + if (NULL == (p = strchr(logmsg, '\''))) + continue; + ss_prot = prot_sum(&cur->proto, ++p, 2); + s_prot = prot_sum(&t_prot, p, 2); + continue; + } + + /* + * check protocol errors. Unfortunately the line does not contain + * the used protocol, so if any previous line did contain that + * information and we did process that line we will save the pointer + * to that particular segment into s_prot. If this pointer is not set + * the error info is lost for we don't know where to store. + * + */ + + if ((0 == strncmp(logmsg, "Errors: header", 14)) && s_prot != NULL) + { + int i1,i2,i3,i4 = 0; + sscanf(logmsg,"%*s %*s %d%*c%*s %d%*c%*s %d%*c%*s %*s%*c %d",&i1,&i2,&i3,&i4); + ss_prot->pr_eheader += i1; + ss_prot->pr_echksum += i2; + ss_prot->pr_eorder += i3; + ss_prot->pr_ereject += i4; + s_prot->pr_eheader += i1; + s_prot->pr_echksum += i2; + s_prot->pr_eorder += i3; + s_prot->pr_ereject += i4; + s_prot = NULL; + continue; + } + + /* + * Handle end of call. Pick up the connect time. + * position is on the closing paren of date/time info + * i.e: ) text.... + */ + + if (0 == strncmp(logmsg, "Call complete", 13)) + { + cur->call[called].succs++; + s_prot = NULL; /* destroy pointer to protocol */ + if (NULL == (s = strchr(logmsg, '('))) + continue; + cur->call[called].connect_time += atof(s+1); + continue; + } + + /* + * We are definitely in a Stats file now. + * If we reached here, this must have been a file transfer + * record. Count it in the field corresponding to the + * direction of the transfer. Count bytes transferred and + * the time to transfer as well. + * Position within the record is at the word 'received' or 'sent' + * depending on the direction. + */ + + sent = IN; /* give it an initial value */ + if (0 == strncmp(logmsg, "failed after ",13)) + logmsg += 13; /* the transmission failed for any reason */ + /* so advance pointer */ + if (0 == strncmp(logmsg, "sent", 4)) + sent = OUT; + else if (0 == strncmp(logmsg, "received", 8)) + sent = IN; + have_files[sent] = TRUE; + cur->call[called].flow[sent].files++; + if (NULL == (s = strchr(logmsg, ' '))) /* point past keyword */ + continue; /* nothing follows */ + /* we should be at the bytes column now*/ +#if HAVE_TAYLOR_LOGGING + cur->call[called].flow[sent].bytes += atol(++s); +#endif /* HAVE_TAYLOR_LOGGING */ +#if HAVE_V2_LOGGING + if (NULL == (s = strpbrk(s, "0123456789"))) /* point to # bytes */ + continue; + cur->call[called].flow[sent].bytes += atol(s); +#endif /* HAVE_V2_LOGGING */ + if (NULL == (s = strchr(s, ' '))) /* point past # of bytes */ + continue; + if (NULL == (s = strpbrk(s, "0123456789"))) /* point to # of seconds */ + continue; + cur->call[called].flow[sent].time += atof(s); + + } /* end of while (fgets(logline...)) */ + + if (stt != NULL && ! use_stdin && ! be_quiet && ! no_records) + { + +#if HAVE_TAYLOR_LOGGING + sscanf(dt_info,"%s%*c%[^.]",in_date,in_time); +#endif /* HAVE_TAYLOR_LOGGING */ + +#if HAVE_V2_LOGGING + sscanf(dt_info,"%[^-]%*c%[1234567890:]",in_date,in_time); +#endif /* HAVE_V2_LOGGING */ + + printf(" %10s %8s\n",in_date, in_time); + p_done = FALSE; } + if (Log != stdin) + { + if (0 != ferror(Log)) + { + if (! be_quiet) + printf(" %-14s data is incomplete; read error"," "); + else + fprintf(stderr,"%s (W) data is incomplete; read error on %s\n", + Pgm_name,argv[1]); + } + else + { + if (! be_quiet && no_records) + printf(" %-14s %10s\n",Filename, " is empty "); + } + } + fclose(Log); -#if _DEBUG_ - printf("\n"); -#endif + argc--; + argv++; + } /* end of while (for (argv ....) */ /* - * MAIN LOGFILE PROCESSING LOOP + * do we have *any* data ? */ - while (argc > 1) - { - if (!use_stdin && (Log = fopen(argv[1], "r")) == NULL) - { - perror(argv[1]); - return; - } + if (cur == NULL) + { + puts("\n(I) Sorry! No data is available for any requested report\n"); + exit(0); + } -#if _DEBUG_ - printf("Reading %s...\n", (use_stdin ? "stdin" : argv[1])); -#endif - - /* - * Read each line of the logfile and collect information - */ - while (fgets(logline, sizeof(logline), Log)) - { - /* - * The host name of the other end of the connection is - * always the second field of the log line, whether we - * are reading a Log file or a Stats file. Set 'p' to - * point to the second field, null-terminated. Skip - * the line if something is funny. - */ - if (NULL == (p = strchr(logline, ' '))) - continue; - ++p; - if (NULL != (s = strchr(p, ' '))) - *s = '\0'; - for (s = p; *s; ++s) - if (isupper(*s)) - *s = tolower(*s); - /* - * Skip this line if we got -h <host> and - * this line does not contain that host name. - */ - if (Hostname[0] != '\0') - if (0 != strcmp(p, Hostname)) - continue; - /* - * We are within a call block now. If this line is a file - * transfer record, determine the direction. If not then - * skip the line if it is not interesting. - */ - if ((s = strchr(++s, ')')) == NULL) - continue; - logmsg = s + 2; /* Message is 2 characters after ')' */ - if (0 == strncmp(logmsg, "sent", 4)) - sent = OUT; - else - if (0 == strncmp(logmsg, "received", 8)) - sent = IN; - else - if ((0 != strncmp(logmsg, "Call complete", 13)) && - (0 != strncmp(logmsg, "Calling system", 14)) && - (0 != strncmp(logmsg, "Incoming call", 13)) && - (0 != strncmp(logmsg, "Executing", 9))) - continue; - /* - * Find the Host_entry for this host, or create a new - * one and link it on to the list. - */ - if ((cur == NULL) || (0 != strcmp(p, cur->Hostname))) - { - for (cur = hosts; cur != NULL ; cur = cur->next) - if (0 == strcmp(cur->Hostname, p)) - break; - if (cur == NULL) - { - cur = (struct Host_entry *)calloc(1, sizeof(*hosts)); - strcpy(cur->Hostname, p); - if (hosts == NULL) - hosts = cur; - else - { - for (e = hosts; e->next != NULL; e = e->next); - e->next = cur; - } - } - } - /* - * OK, if this is a uuxqt record, find the Execution_Command - * structure for the command being executed, or create a new - * one. Then count an execution of this command. - */ - if (0 == strncmp(logmsg, "Executing", 9)) - { - if (NULL == (p = strchr(logmsg, '('))) - continue; - if ((s = strpbrk(++p, " )")) == NULL) - continue; - *s = '\0'; - for (cmd = cur->cmds; cmd != NULL; cmd = cmd->next) - if (0 == strcmp(cmd->Commandname, p)) - break; - if (cmd == NULL) - { - cmd = (struct Execution_Command *)calloc(1, sizeof(*cmd)); - strcpy(cmd->Commandname, p); - if (cur->cmds == NULL) - cur->cmds = cmd; - else - { - for (ec = cur->cmds; ec->next != NULL; ec = ec->next); - ec->next = cmd; - } - } - ++cmd->count; - have_commands = 1; - continue; - } - /* - * Count start of outgoing call. - */ - if (0 == strncmp(logmsg, "Calling system", 14)) - { - called = OUT; - cur->call[called].calls += 1; - have_calls = 1; - continue; - } - /* - * Count start of incoming call. - */ - if (0 == strncmp(logmsg, "Incoming call", 13)) - { - called = IN; - cur->call[called].calls += 1; - have_calls = 1; - continue; - } - /* - * Handle end of call. Pick up the connect time. - */ - if (0 == strncmp(logmsg, "Call complete", 13)) - { - cur->call[called].succs += 1; - if (NULL == (s = strchr(logmsg, '('))) - continue; - cur->call[called].connect_time += atof(s+1); - continue; - } - /* - * If we reached here, this must have been a file transfer - * record. Count it in the field corresponding to the - * direction of the transfer. Count bytes transferred and - * the time to transfer as well. - */ - have_files = 1; - cur->call[called].flow[sent].files += 1; - if (NULL == (s = strchr(logmsg, ' '))) - continue; - cur->call[called].flow[sent].bytes += atol(++s); - if (NULL == (s = strchr(s, ' '))) - continue; - if (NULL == (s = strpbrk(s, "0123456789"))) - continue; - cur->call[called].flow[sent].time += atof(s); - } - argc -= 1; - argv += 1; - if(Log != stdin) - fclose(Log); - } - /* - * *********** - * * REPORTS * - * *********** + * truncate hostname, alloc the structure holding the totals and + * collect the totals data */ + for (cur = hosts; cur != NULL;cur = cur->next) + { + cur->Hostname[MAXDNAME] = '\0'; + if (cur->next == NULL) /* last so will have to alloc totals */ + { + cur->next = (struct Host_entry *)getmem(sizeof(*hosts)); + strcpy(cur->next->Hostname,"Totals"); + tot = cur->next; + for (cur = hosts; cur != NULL; cur = cur->next) + { + if (cur->next != NULL) /* don't count totals to totals */ + { + tot->call[IN].flow[IN].bytes += cur->call[IN].flow[IN].bytes; + tot->call[OUT].flow[IN].bytes += cur->call[OUT].flow[IN].bytes; + tot->call[IN].flow[OUT].bytes += cur->call[IN].flow[OUT].bytes; + tot->call[OUT].flow[OUT].bytes += cur->call[OUT].flow[OUT].bytes; + tot->call[IN].flow[IN].time += cur->call[IN].flow[IN].time; + tot->call[OUT].flow[IN].time += cur->call[OUT].flow[IN].time; + tot->call[IN].flow[OUT].time += cur->call[IN].flow[OUT].time; + tot->call[OUT].flow[OUT].time += cur->call[OUT].flow[OUT].time; + tot->call[IN].flow[IN].files += cur->call[IN].flow[IN].files; + tot->call[OUT].flow[IN].files += cur->call[OUT].flow[IN].files; + tot->call[IN].flow[OUT].files += cur->call[IN].flow[OUT].files; + tot->call[OUT].flow[OUT].files += cur->call[OUT].flow[OUT].files; + tot->call[OUT].succs += cur->call[OUT].succs; + tot->call[OUT].calls += cur->call[OUT].calls; + tot->call[OUT].connect_time += cur->call[OUT].connect_time; + tot->call[IN].succs += cur->call[IN].succs; + tot->call[IN].calls += cur->call[IN].calls; + tot->call[IN].connect_time += cur->call[IN].connect_time; + } + } + break; /* totals is last in Host_Entry */ + } + } + /* - * Truncate the Hostnames to 8 characters at most. + * *********** + * * REPORTS * + * *********** */ - for (cur = hosts; cur != NULL; cur = cur->next) - cur->Hostname[8] = '\0'; #if _DEBUG_ - printf("\n"); + putchar('\n'); #endif - /* - * Summary report + /* ------------------------------------------------------------------ + * + * Summary report only when no other report except option -t is given * * I know, this code could be tightened (rbd)... + * ------------------------------------------------------------------ */ - if(show_summary) - { - char t1[32], t2[32], t3[32], t4[32], t5[32]; - long ib, ob, b, rf, sf; - long t_ib=0, t_ob=0, t_b=0, t_rf=0, t_sf=0; - double it, ot, ir, or; - double t_it=0.0, t_ot=0.0; - int nhosts = 0; - - printf("\n\ - Remote ------- Bytes -------- --- Time ---- -- Avg CPS -- -- Files --\n"); - printf("\ - Host Rcvd Sent Total Rcvd Sent Rcvd Sent Rcvd Sent\n"); - printf("\ --------- ------- ------- ------- ------ ------ ------ ------ ----- -----\n"); - for (cur = hosts; cur != NULL; cur = cur->next) - { - ib = (cur->call[IN].flow[IN].bytes + - cur->call[OUT].flow[IN].bytes); - fmbytes(ib, t1); - t_ib += ib; - - ob = (cur->call[IN].flow[OUT].bytes + - cur->call[OUT].flow[OUT].bytes); - fmbytes(ob, t2); - t_ob += ob; - - b = ib + ob; - fmbytes(b, t3); - t_b += b; - - it = cur->call[IN].flow[IN].time + - cur->call[OUT].flow[IN].time; - fmtime(it, t4); - t_it += it; - - ot = cur->call[IN].flow[OUT].time + - cur->call[OUT].flow[OUT].time; - fmtime(ot, t5); - t_ot += ot; - - rf = cur->call[IN].flow[IN].files + - cur->call[OUT].flow[IN].files; - t_rf += rf; - - sf = cur->call[IN].flow[OUT].files + - cur->call[OUT].flow[OUT].files; - t_sf += sf; - - ir = (it == 0.0) ? 0.0 : (ib / it); - or = (ot == 0.0) ? 0.0 : (ob / ot); - - printf("%-8s %7s %7s %7s %6s %6s %6.1f %6.1f %5d %5d\n", - cur->Hostname, - t1, t2, t3, t4, t5, - ir, or, rf, sf); - } - - if(nhosts > 1) - { - fmbytes(t_ib, t1); - fmbytes(t_ob, t2); - fmbytes(t_b, t3); - fmtime(t_it, t4); - fmtime(t_ot, t5); - ir = (t_it == 0.0) ? 0.0 : (t_ib / t_it); - or = (t_ot == 0.0) ? 0.0 : (t_ob / t_ot); - - printf("\ --------- ------- ------- ------- ------ ------ ------ ------ ----- -----\n"); - printf("\ -Totals %7s %7s %7s %6s %6s %6.1f %6.1f %5d %5d\n", - t1, t2, t3, t4, t5, - ir, or, t_rf, t_sf); - } - } - - /* - * Call statistics report + if ( !(show_calls || show_files || + show_efficiency || show_commands || show_proto) || show_all) + { + if (have_calls || have_files[IN] || have_files[OUT]) + { + char t1[32], t2[32], t3[32], t4[32], t5[32]; + long ib, ob, b, rf, sf; + double it, ot, ir, or; + + hdr_done = FALSE; + for (cur = hosts; cur != NULL; cur = cur->next) + { + ib = (cur->call[IN].flow[IN].bytes + + cur->call[OUT].flow[IN].bytes); + fmbytes(ib, t1); + + ob = (cur->call[IN].flow[OUT].bytes + + cur->call[OUT].flow[OUT].bytes); + fmbytes(ob, t2); + + /* Don't print null-lines. */ + if (( b= ib+ob ) == 0 ) + continue; + /* Don't print the header twice. */ + if (! hdr_done) + { + hdrprt('s',0); /* print the header line(s) */ + hdr_done = TRUE; + } + + fmbytes(b, t3); + + it = cur->call[IN].flow[IN].time + + cur->call[OUT].flow[IN].time; + fmtime(it, t4); + + ot = cur->call[IN].flow[OUT].time + + cur->call[OUT].flow[OUT].time; + fmtime(ot, t5); + + rf = cur->call[IN].flow[IN].files + + cur->call[OUT].flow[IN].files; + + sf = cur->call[IN].flow[OUT].files + + cur->call[OUT].flow[OUT].files; + + ir = (it == 0.0) ? 0.0 : (ib / it); + or = (ot == 0.0) ? 0.0 : (ob / ot); + + if (cur->next == NULL) /* totals line reached ? */ + hdrprt('s',1); /* print the separator line */ + + printf("%-8s %4d %4d %9s %9s %9s %9s %9s %5.0f %5.0f\n", + cur->Hostname, rf, sf, + t1, t2, t3, t4, t5, + ir, or); + } + if (! hdr_done) + { + puts("\n(I) No data found to print Compact summary report"); + } + } + else + { + puts("\n(I) No data available for Compact summary report"); + --report; + } + } + + /* ------------------------------------------------------------------ + * Protocol statistics report + * ------------------------------------------------------------------ */ - if(show_calls && have_calls) - { - char t1[32], t2[32]; - - printf("\nCall statistics:\n"); - printf("\ - sysname callto failto totime callfm failfm fmtime\n"); - printf("\ - -------- ------ ------ -------- ------ ------ --------\n"); - for (cur = hosts; cur != NULL; cur = cur->next) - { - fmtime(cur->call[OUT].connect_time, t1); - fmtime(cur->call[IN].connect_time, t2), - printf(" %-8s %6d %6d %8s %6d %6d %8s\n", - cur->Hostname, - cur->call[OUT].calls, - cur->call[OUT].calls - cur->call[OUT].succs, - t1, - cur->call[IN].calls, - cur->call[IN].calls - cur->call[IN].succs, - t2); - } - } - /* - * File statistics report + if (show_proto || show_all) + { + if (have_proto) + { + /* --------------------- */ + /* protocol packet report */ + /* --------------------- */ + + char *type = NULL; + hdr_done = FALSE; + for (cur = hosts; cur != NULL; cur = cur->next) + { + type = cur->Hostname; + if (cur->next == NULL) + { + if (hdr_done) + puts("-------------------------------------------------------------------"); + cur->proto = t_prot; + } + for (prot = cur->proto; prot != NULL; prot = prot->next) + { + if (! hdr_done) + { + hdrprt('p',0); /* print the header line(s) */ + hdr_done = TRUE; + } + printf("%-8s %3s %4d %4d %5d %4d %10d %7d %10d\n", + type == NULL ? " ":cur->Hostname, + prot->type, + prot->pr_psizemin, + prot->pr_psizemax, + prot->pr_pwinmin, + prot->pr_pwinmax, + prot->pr_psent, + prot->pr_present, + prot->pr_preceived); + type = NULL; + } + } + if (! hdr_done) + puts("\n(I) No data found to print Protocol packet report"); + + /* --------------------- */ + /* protocol error report */ + /* --------------------- */ + + type = NULL; + hdr_done = FALSE; + if (t_prot != NULL) + { + for (cur = hosts; cur != NULL; cur = cur->next) + { + type = cur->Hostname; + if (cur->next == NULL) + { + if (hdr_done) + puts("--------------------------------------------------------------"); + cur->proto = t_prot; + } + + for (prot = cur->proto; prot != NULL; prot = prot->next) + { + if ((prot->pr_eheader + prot->pr_echksum + + prot->pr_eorder + prot->pr_ereject) != 0) + { + if (! hdr_done) + { + hdrprt('p',1); /* print the header line(s) */ + hdr_done = TRUE; + } + printf("%-8s %3s %11d %11d %11d %11d\n", + type == NULL ? " ":cur->Hostname, + prot->type, + prot->pr_eheader, + prot->pr_echksum, + prot->pr_eorder, + prot->pr_ereject); + type = NULL; + } + } + } + } + if (! hdr_done) + puts("\n(I) No data found to print Protocol error report"); + } + else + { + puts("\n(I) No data available for Protocol reports"); + --report; + } + } + + /* ------------------------------------------------------------------ + * Call statistics report + * ------------------------------------------------------------------ */ - if(show_files && have_files) - { - char t1[32], t2[32]; - - for (sent = IN; sent <= OUT; ++sent) - { - printf(file_hdr[sent]); - printf(" sysname files bytes xfr time byte/s\n"); - printf(" -------- ------ -------- -------- ------\n"); - for (cur = hosts; cur != NULL; cur = cur->next) - { - double rate; - double time; - - time = cur->call[IN].flow[sent].time + - cur->call[OUT].flow[sent].time; - if (time == 0.0) - continue; - rate = (cur->call[IN].flow[sent].bytes + - cur->call[OUT].flow[sent].bytes) / time; - fmbytes((cur->call[IN].flow[sent].bytes + - cur->call[OUT].flow[sent].bytes), t1); - fmtime((cur->call[IN].flow[sent].time + - cur->call[OUT].flow[sent].time), t2); - printf(" %-8s %6d %8s %8s %6.1f\n", - cur->Hostname, - cur->call[IN].flow[sent].files + - cur->call[OUT].flow[sent].files, - t1, t2, rate); - } - } - } - /* - * Efficiency report + if (show_calls || show_all) + { + if (have_calls) + { + char t1[32], t2[32]; + + hdr_done = FALSE; + for (cur = hosts; cur != NULL; cur = cur->next) + { + if (cur->next == NULL) + { + if (hdr_done) + hdrprt('c',1); /* print the separator line */ + } + else + { + /* Don't print null-lines on deatail lines */ + if ( cur->call[OUT].calls + cur->call[IN].calls == 0 ) + continue; + + /* Don't print the header twice. */ + if (! hdr_done) + { + hdrprt('c',0); /* print the header line(s) */ + hdr_done = TRUE; + } + } + if ( cur->call[OUT].calls > 0 || cur->next == NULL) + { + fmtime(cur->call[OUT].connect_time, t1); + printf( " %-8s %7d %7d %7d %9s", + cur->Hostname, + cur->call[OUT].succs, + cur->call[OUT].calls - cur->call[OUT].succs, + cur->call[OUT].calls, + t1 ); + } + else + { + printf( " %-42s", cur->Hostname ); + } + if ( cur->call[IN].calls > 0 || cur->next == NULL ) + { + fmtime(cur->call[IN].connect_time, t2); + printf( " %7d %7d %7d %9s", + cur->call[IN].succs, + cur->call[IN].calls - cur->call[IN].succs, + cur->call[IN].calls, + t2 ); + } + putchar('\n'); + } + if (! hdr_done) + { + puts("\n(I) No data found to print Call statistics report"); + } + } + else + { + puts("\n(I) No data available for Call statistics report"); + --report; + } + } + + /* ------------------------------------------------------------------ + * File statistics report + * ------------------------------------------------------------------ */ - if (show_efficiency && have_files) + + if (show_files || show_all) + { + if (have_files[IN] || have_files[OUT]) + { + char t1[32], t2[32]; + double rate = 0, time = 0; + int b = 0; + int lineOut = 0; + + hdr_done = FALSE; + for (cur = hosts; cur != NULL; cur = cur->next) + { + lineOut = 0; + for (sent= IN; sent <= OUT; ++sent) + { + b = cur->call[IN].flow[sent].bytes + + cur->call[OUT].flow[sent].bytes; + time = cur->call[IN].flow[sent].time + + cur->call[OUT].flow[sent].time; + + /* Don't print null-lines on detail lines. */ + if ( (b != 0 && time != 0.0) || cur->next == NULL) + { + /* Don't print the header twice. */ + if (! hdr_done) + { + hdrprt('f',0); /* print the header line(s) */ + hdr_done = TRUE; + } + fmbytes(b, t1); + rate = (cur->call[IN].flow[sent].bytes + + cur->call[OUT].flow[sent].bytes) / time; + fmtime((cur->call[IN].flow[sent].time + + cur->call[OUT].flow[sent].time), t2); + + if (lineOut == 0) /* first half not printed yet ? */ + { + if (cur->next == NULL) /* totals line ? */ + hdrprt('f',1); /* print the separator line */ + printf(" %-8s", cur->Hostname); + if (sent == OUT) /* can't happen whith totals line */ + printf("%34s", " "); + } + + printf(" %5d %11s %9s %5.0f", + cur->call[IN].flow[sent].files + + cur->call[OUT].flow[sent].files, + t1, t2, rate); + lineOut = 1; + } + } /* end: for (sent ... ) */ + if (lineOut) + printf("\n"); + } /* end: for (cur= ... ) */ + if (! hdr_done) + { + puts("\n(I) No data found to print File statistics report"); + } + } + else + { + puts("\n(I) No data available for File statistics report"); + --report; + } + } + + /* ------------------------------------------------------------------ + * Efficiency report + * ------------------------------------------------------------------ + */ + + if (show_efficiency || show_all) + { + if (have_files[IN] || have_files[OUT]) + { + char t1[32], t2[32], t3[32]; + double total, flow; + + hdr_done = FALSE; + for (cur = hosts; cur != NULL; cur = cur->next) + { + /* Don't print null-lines. */ + if ( 0 == cur->call[IN].flow[IN].files + + cur->call[IN].flow[OUT].files + + cur->call[OUT].flow[IN].files + + cur->call[OUT].flow[OUT].files || + 0.0 == (total= cur->call[IN].connect_time + + cur->call[OUT].connect_time)) + { + continue; + } + + if (! hdr_done) + { + hdrprt('e',0); /* print the header line(s) */ + hdr_done = TRUE; + } + + flow = cur->call[IN].flow[IN].time + + cur->call[IN].flow[OUT].time + + cur->call[OUT].flow[IN].time + + cur->call[OUT].flow[OUT].time; + fmtime(total, t1); + fmtime(flow, t2); + fmtime(total-flow, t3); + + if (cur->next == NULL) + hdrprt('e',1); /* print the separator line */ + + printf(" %-8s %10s %10s %10s %7.2f\n", + cur->Hostname, t1, t2, t3, + flow >= total ? 100.0: flow*100.0/total); + } /* end: for (cur= .. */ + if (! hdr_done) + { + puts("\n(I) No data found to print Efficiency report"); + } + } + else + { + puts("\n(I) No data available for Efficiency report"); + --report; + } + } + + /* ------------------------------------------------------------------ + * Command execution report + * ------------------------------------------------------------------ + */ + + if (show_commands || show_all) + { + if (have_commands) + { + int ncmds, i, match; + + /* + * layout the header line. The column's header is the command name + */ + + hdr_done = FALSE; + for (ncmds= 0, cmd= t_cmds; + cmd != NULL && ncmds <= MAXCOLS-1; + ncmds++, cmd= cmd->next) + { + if (! hdr_done) + { + puts("\nCommand executions:"); + puts("-------------------"); + puts(" Name of "); + fputs(" site ", stdout); + hdr_done = TRUE; + } + printf(" %7s", cmd->Commandname); + } + if (! hdr_done) + { + puts("\n(I) No data found to print Command execution report"); + } + else + { + fputs("\n --------", stdout); + for (i= 0; i<ncmds; i++) + fputs(" ------", stdout); + putchar('\n'); + + /* + * print out the number of executions for each host/command + */ + + for (cur= hosts; cur != NULL; cur= cur->next) + { + if (cur->next == NULL) + break; + + /* Don't print null-lines. */ + + if (cur->cmds == NULL) + continue; + + printf(" %-8s", cur->Hostname); + for (cmd= t_cmds; cmd != NULL; cmd= cmd->next) + { + struct Execution_Command *ec; + match = FALSE; + for(ec= cur->cmds; ec != NULL; ec= ec->next) + { + if ( 0 == strcmp(cmd->Commandname, ec->Commandname) ) + { + printf(" %7d", ec->count); + match = TRUE; + break; + } + } + if (! match) + printf("%8s"," "); /* blank out column */ + } + putchar('\n'); + } + + /* + * print the totals line + */ + + fputs(" --------", stdout); + for (i= 0; i<ncmds; i++) + fputs("--------", stdout); + printf("\n %-8s", cur->Hostname); + for (cmd= t_cmds; cmd != NULL; cmd= cmd->next) + { + printf(" %7d", cmd->count); + } + putchar('\n'); + } + } + else + { + puts("\n(I) No data available for Command execution report"); + --report; + } + } + if (report <= 0 ) /* any reports ? */ + { + puts("\n(I) Sorry! No data is available for any requested report\n"); + exit(1); + } + + puts("\n(I) End of reports\n"); + exit (0); +} /* end of main */ + + /* ------------------------------------------------------------------ + * * Functions * + * ------------------------------------------------------------------ + */ + + /* ------------------------------------------------------------------ + * display the help + * ------------------------------------------------------------------ + */ + +void usage() +{ + fprintf(stderr,"Usage uurate [-acdefhiptvx] [-s hostname] [-I config file] [logfile(s) ... logfile(s)]\n"); + fprintf(stderr,"where:\t-a\tPrint reports c,e,f,x\n"); + fprintf(stderr,"\t-c\tReport call statistics\n"); + fprintf(stderr,"\t-d\tPrint the name of the default config file\n"); + fprintf(stderr,"\t-e\tReport efficiency statistics\n"); + fprintf(stderr,"\t-f\tReport file transfer statistics\n"); + fprintf(stderr,"\t-h\tPrint this help\n"); + fprintf(stderr,"\t-i\tRead log info from standard input\n"); + fprintf(stderr,"\t-p\tReport protocol statistics\n"); + fprintf(stderr,"\t-t\tAll available reports plus compact summary report\n"); + fprintf(stderr,"\t-v\tPrint version number\n"); + fprintf(stderr,"\t-x\tReport command execution statistics\n"); + fprintf(stderr,"\t-s host\tReport activities involving HOST only\n"); + fprintf(stderr,"\t-I config Use config instead of standard config file\n"); + fprintf(stderr,"If no report options given, a compact summary report is printed.\n"); + fprintf(stderr,"log files should be given as pairs that is Log/Stats ... .\n"); + fprintf(stderr,"If neither -i nor logfiles given, those names found in config will be used\n"); + + exit (1); +} + + /* ------------------------------------------------------------------ + * getmem - get some memory + * ------------------------------------------------------------------ + */ + +static pointer *getmem(n) + unsigned n; +{ + pointer *p; + + if( NULL== (p= calloc(1, n)) ) { - char t1[32], t2[32], t3[32]; - double total, flow; - - printf("\nEfficiency:\n"); - printf(" sysname conntime flowtime ovhdtime eff. %%\n"); - printf(" -------- -------- -------- -------- ------\n"); - for (cur = hosts; cur != NULL; cur = cur->next) - { - total = cur->call[IN].connect_time + cur->call[OUT].connect_time; - flow = cur->call[IN].flow[IN].time + cur->call[IN].flow[OUT].time + - cur->call[OUT].flow[IN].time + cur->call[OUT].flow[OUT].time; - fmtime(total, t1); - fmtime(flow, t2); - fmtime((total-flow), t3); - printf(" %-8s %8s %8s %8s %5.1f%%\n", - cur->Hostname, t1, t2, t3, ((flow / total) * 100.0)); - } + fprintf(stderr,"\a%s (C) %s\n",Pgm_name, "out of memory\n"); + exit (8); } + return p; +} + + /* ------------------------------------------------------------------ + * inc_cmd - increment command count + * ------------------------------------------------------------------ + */ + +static void inc_cmd(cmds, name) + struct Execution_Command **cmds; + char *name; +{ + int cnt = 0; + struct Execution_Command *cmd, *ec; + + for (ec = cmd = *cmds; cmd != NULL; ec= cmd, cmd= cmd->next, cnt++) + if ( (0 == strcmp(cmd->Commandname, name)) || + (0 == strcmp(cmd->Commandname, "Misc.")) ) + break; + if (cmd == NULL) + { + cmd= (struct Execution_Command *)getmem(sizeof(*cmd)); + if (cnt <= MAXCOLS-1) /* first col prints site name therefore < max-1 */ + { + strcpy(cmd->Commandname, name); + if (*cmds == NULL) + ec = *cmds = cmd; + else + ec->next= cmd; + } + else + { + strcpy(ec->Commandname, "Misc."); /* reached high-water-mark */ + cmd = ec; /* backtrack */ + } + } + cmd->count++; +} + + + /* ------------------------------------------------------------------ + * prot_sum - collect protocol data + * ------------------------------------------------------------------ + */ + + struct Protocol_Summary * + prot_sum(proto, ptype, ind) + struct Protocol_Summary **proto; + char *ptype; + int ind; +{ + int cnt = 0; + int i1, i2, i3 = 0; + struct Protocol_Summary *cur, *first; + for (first = cur = *proto; cur != NULL; first= cur, cur= cur->next, cnt++) + { + if ( (0 == strncmp(cur->type, ptype,strlen(cur->type)))) + break; + } + if (cur == NULL) + { + cur= (struct Protocol_Summary *)getmem(sizeof(*cur)); + sscanf(ptype,"%[^\' ]3",cur->type); + if (*proto == NULL) + first = *proto = cur; + else + first->next= cur; + } + if (NULL == (ptype = strchr(ptype, ' '))) + return (NULL); + cur->pr_cnt++; + have_proto = TRUE; + ++ptype; + switch(ind) + { + case 1: /* used protocol line */ /* - * Command execution report - */ - if (show_commands & have_commands) - { - printf("\nCommand executions:\n"); - printf(" sysname rmail rnews other\n"); - printf(" -------- ------ ------ ------\n"); - for (cur = hosts; cur != NULL; cur = cur->next) - { - int rmail, rnews, other; - - if (cur->cmds == NULL) - continue; - rmail = rnews = other = 0; - for (cmd = cur->cmds; cmd != NULL; cmd = cmd->next) - { - if (strcmp(cmd->Commandname, "rmail") == 0) - rmail += cmd->count; - else if (strcmp(cmd->Commandname, "rnews") == 0) - rnews += cmd->count; - else - other += cmd->count; - } - printf(" %-8s %6d %6d %6d\n", cur->Hostname, - rmail, rnews, other); - } - } - return; - - usage: - fprintf(stderr, - "Usage uurate [-cfexai] [-h hostname] [logfile ... logfile]\n"); - fprintf(stderr,"where:\t-c\tReport call statistics\n"); - fprintf(stderr, "\t-f\tReport file transfer statistics\n"); - fprintf(stderr, "\t-e\tReport efficiency statistics\n"); - fprintf(stderr, "\t-x\tReport command execution statistics\n"); - fprintf(stderr, "\t-a\tAll of the above reports\n"); - fprintf(stderr, "\t-h host\tReport activities involving ONLY host\n"); - fprintf(stderr, "\t-i\tRead log info from standard input\n"); - fprintf(stderr, - "If no report options given, a compact summary report is given.\n"); - fprintf(stderr, - "If neither -i nor logfiles given, defaults to reading from\n"); - fprintf(stderr, "%s and %s\n\n", LOGFILE, STATFILE); + * uucp-1.04 format: .... packet size ssss window ww) + * uucp-1.05 format: .... remote packet/window ssss/ww local ssss/ww) + * (the remote packet/window will be used!) + */ + + i1 = i2 = 0; /* reset */ + + if (NULL == (strchr(ptype, '/'))) + sscanf(ptype,"%*s %*s %d %*s %d",&i1,&i2); + else + sscanf(ptype,"%*s %*s %d/%d",&i1,&i2); + + if (i1 > cur->pr_psizemax) + cur->pr_psizemax = i1; + if (i1 < cur->pr_psizemin || cur->pr_psizemin == 0) + cur->pr_psizemin = i1; + + if (i2 > cur->pr_pwinmax) + cur->pr_pwinmax = i2; + if (i2 < cur->pr_pwinmin || cur->pr_pwinmin == 0) + cur->pr_pwinmin = i2; + break; + case 2: /* protocol statistics line */ + i1 = i2 = i3 = 0; /* reset */ + sscanf(ptype,"%*s %*s %d%*c %*s %d%*c %*s %d",&i1,&i2,&i3); + cur->pr_psent += i1; + cur->pr_present += i2; + cur->pr_preceived += i3; + break; + default: + break; + } + return (cur); } + /* ------------------------------------------------------------------ + * fmtime() - Format time in hours & minutes & seconds; + * ------------------------------------------------------------------ + */ -/* - * fmtime() - Format time in hours & minutes; - */ static void fmtime(dsec, buf) - double dsec; - char *buf; + double dsec; + char *buf; { long hrs, min, lsec; - lsec = dsec; - hrs = lsec / 3600L; - min = (lsec - (hrs * 3600L)) / 60L; + if( dsec <= 0 ) + { + strcpy(buf, "0" ); + return; + } + lsec = fmod(dsec+0.5, 60L); /* round to the next full second */ + hrs = dsec / 3600L; + min = ((long)dsec / 60L) % 60L; + if (hrs == 0) + if (min == 0) + sprintf(buf,"%6s%2ld"," ",lsec); + else + sprintf(buf,"%3s%2ld:%02ld"," ",min,lsec); + else + sprintf(buf,"%2ld:%02ld:%02ld",hrs,min,lsec); - sprintf(buf, "%02ld:%02ld", hrs, min); } -/* - * fmbytes - Format size in bytes - */ + /* ------------------------------------------------------------------ + * fmbytes - Format size in bytes + * ------------------------------------------------------------------ + */ + static void fmbytes(n, buf) - unsigned long n; - char *buf; + unsigned long n; + char *buf; { - char t; - double s = n; + if ( n == 0 ) + { + strcpy( buf, "0.0" ); + return; + } + sprintf(buf, "%.1f", (double)n / 1000.0); /* Display in Kilobytes */ +} - if(s >= 10239897.6) /* More than 9999.9K ? */ - { - s = (double)n / 1048576.0; /* Yes, display in Megabytes */ - t = 'M'; - } - else - { - s = (double)n / 1024.0; /* Display in Kilobytes */ - t = 'K'; - } - sprintf(buf, "%.1f%c", s, t); + /* ------------------------------------------------------------------ + * chk_config - Read the config file + * check on keywords: logfile and statfile. When found override + * the corresponding default + * ------------------------------------------------------------------ + */ + +int chk_config(char *T_conf,int be_quiet, int type) +{ + FILE *Conf; + char keywrd[9]; + char name[MAXPATHLEN+1]; + char *pos1, *pos2; + int i = 0; + int logf = FALSE; + int statf = FALSE; + + if ((Conf = fopen(T_conf, "r")) == NULL) + { + if (! be_quiet) + { + puts(" Could not open config"); + if (type == 0) + { + puts(" The run will be aborted\n"); + return (8); + } + } + else + { + fprintf(stderr,"%s (E) %s %s \n",Pgm_name, + "could not open config:", + T_conf); + if (type != 0) + fprintf(stderr,"%s (W) defaults used for all files\n", + Pgm_name); + else + { + fprintf(stderr,"%s (C) ended due to errors\n", + Pgm_name); + return (8); + } + } + } + else + { + while (fgets(logline, sizeof(logline), Conf)) + { + if (logline[0] == '#') + continue; + sscanf(logline,"%8s %s",keywrd,name); + if (0 == strncmp(keywrd,"logfile",7)) + { + pos1 = pos2 = name; + for (i=0;(i<=MAXPATHLEN && *pos1 != '\0');pos1++,pos2++,i++) + { + if (*pos1 == '#') /* name immed followed by comment */ + break; + if (*pos1 == '\\') /* quoted comment (filename has #) */ + { + ++pos1; /* skip escape char */ + if (*pos1 != '#') /* continuation ? */ + { + puts(" Config error:"); + puts(" Found filename continuation; bailing out\n"); + exit (8); + } + } + *pos2 = *pos1; /* move char */ + } + *pos2 = '\0'; /* terminate string */ + Tlog = (char *)getmem(strlen(name)+1); + strcpy(Tlog,name); + if (! be_quiet) + printf(" logfile used: %s\n",Tlog); + logf = TRUE; + if (statf) /* statsfile still to come ? */ + break; /* no finished */ + continue; + } + + if (0 == strncmp(keywrd,"statfile",8)) + { + pos1 = pos2 = name; + for (i=0;(i<=MAXPATHLEN && *pos1 != '\0');pos1++,pos2++,i++) + { + if (*pos1 == '#') /* name immed followed by comment */ + break; + if (*pos1 == '\\') /* quoted comment (filename has #) */ + { + ++pos1; /* skip escape char */ + if (*pos1 != '#') /* continuation ? */ + { + puts(" Config error:"); + puts(" Found filename continuation; bailing out\n"); + exit (8); + } + } + *pos2 = *pos1; /* move char */ + } + *pos2 = '\0'; /* terminate string */ + Tstat = (char *)getmem(strlen(name)+1); + strcpy(Tstat,name); + if (! be_quiet) + printf(" statfile used: %s\n",Tstat); + statf = TRUE; + if (logf) /* logfile still to come ? */ + break; /* no finished */ + continue; + } + } + fclose(Conf); + } + + if (! be_quiet) + { + if (! logf) + puts(" logfile used: - default -"); + if (! statf) + puts(" statfile used: - default -"); + } + +return 0; } + + /* ------------------------------------------------------------------ + * hdrprt - Print Header/Trailer lines (constant data) + * ------------------------------------------------------------------ + */ + +static void hdrprt(char head, int bot) +{ + switch(head) + { + case('s'): /* standard summary report */ + if (bot == 0) + { + puts("\nCompact summary:"); + puts("----------------"); + puts("\ +Name of + Files + +------- Bytes/1000 --------+ +------ Time -----+ + Avg CPS +\n\ +site in out inbound outbound total inbound outbound in out\n\ +-------- ---- ---- --------- --------- --------- --------- --------- ----- -----"); + } + else + puts("\ +--------------------------------------------------------------------------------"); + break; + + + case('f'): /* file statistic report */ + if (bot == 0) + { + puts("\nFile statistics:"); + puts("----------------"); + puts(" Name of +----------- Inbound -----------+ +---------- Outbound -----------+"); + puts(" site files Bytes/1000 xfr time B/sec files Bytes/1000 xfr time B/sec"); + puts(" -------- ----- ----------- --------- ----- ----- ----------- --------- -----"); + } + else + puts("\ + ----------------------------------------------------------------------------"); + break; + + + case('c'): /* calls statistic report */ + if (bot == 0) + { + puts("\nCall statistics:"); + puts("----------------"); + puts(" Name of +------- Outbound Calls -------+ +-------- Inbound Calls ------+"); + puts(" site succ. failed total time succ. failed total time"); + puts(" -------- ------ ------ ------ --------- ------ ------ ------ ---------"); + } + else + puts("\ + ----------------------------------------------------------------------------"); + break; + + + case('e'): /* efficiency statistic report */ + if (bot == 0) + { + puts("\nEfficiency:"); + puts("-----------"); + puts(" Name of +------ Times inbound/outbound -------+"); + puts(" site connected xfr time overhead eff. %"); + puts(" -------- --------- --------- --------- ------"); + } + else + puts(" -------------------------------------------------"); + break; + + case('i'): /* Environment information */ + if (bot == 0) + { + puts("\nEnvironment Information:"); + puts("------------------------"); + printf(" Default config: %s\n",D_conf == NULL ? + noConf:D_conf); + printf(" Default logfile: %s\n",Tlog); + printf(" Default statfile: %s\n\n",Tstat); + } + break; + + case('d'): /* Date/time coverage */ + if (bot == 0) + { + puts("\n Date coverage of input files:"); + puts(" Name of +----- Start -----+ +------ End ------+"); + puts(" file date time date time"); + puts(" -------- ---------- -------- ---------- --------"); + } + break; + + case('p'): /* Protocol stats */ + if (bot == 0) + { + puts("\nProtocol packet report:"); + puts("-----------------------"); + puts(" +------- protocol -----+ +--------- Packets ----------+"); + puts("Name of packet window "); + puts("site typ min max min max sent resent received"); + puts("-------- --- ---- ---- ---- ---- ----------- ------- ----------"); + } + else + { + puts("\nProtocol error report:"); + puts("----------------------"); + puts("Name of +----------------- Error Types --------------------+"); + puts("site typ header checksum order rem-reject"); + puts("-------- --- ----------- ---------- ----------- ----------"); + } + break; + + default: + if (bot == 0) + { + puts("\nNo header for this report defined:"); + } + else + puts(" "); + break; + } +} diff --git a/gnu/libexec/uucp/contrib/uurate.man b/gnu/libexec/uucp/contrib/uurate.man index 9f33ef30386..344c7ad5243 100644 --- a/gnu/libexec/uucp/contrib/uurate.man +++ b/gnu/libexec/uucp/contrib/uurate.man @@ -1,10 +1,13 @@ +''' $Id: uurate.man,v 1.2 1994/10/24 22:17:59 jtc Exp $ .TH uurate 1 .SH NAME uurate \- Report Taylor UUCP statistics .SH SYNOPSIS -.BR uurate " [ " "\-cfexai" " ] [ " "\-h " +.BR uurate " [ " "\-acdefhipqtvx" " ] [ " "\-s " .I host -.RI " ] [ " "logfile..." " ] " +.RI " ] [ " "\-I " +.I config +.RI " ][ " "logfile..." " ] " .PP or simply, .PP @@ -12,20 +15,20 @@ or simply, .PP for a traffic summary report. .SH DESCRIPTION -The +The .I uurate -command provides tabular summary reports on the operation of the +command provides tabular summary reports on the operation of the Taylor UUCP system. Data is taken from the currently active log -files, standard input, or from a list of log files given on the -command line. Output is in the form of tabular reports summarizing +files, standard input, or from a list of log files given on the +command line. Output is in the form of tabular reports summarizing call, file transfer, and command execution .RI "(" "uuxqt" ")" activity. .PP -The log files given to +The log and stats files given to .I uurate -must be in the ``Taylor'' format. Also, note that call and file -transfer activities are logged in separate files, nominally called +must be in the ``Taylor'' or ``V2'' format. Also, note that call and file +transfer activities are logged in separate files, nominally called .I Log and .I Stats, @@ -33,43 +36,49 @@ respectively. For reports to be meaningful, the .I Log and .I Stats -files should be given to +files should be given to .I uurate together, and cover the same time period. .PP If neither the .B \-i -option nor any +or +.B \-I +option nor any .I logfile -options are given, +options are given, .I uurate defaults to taking its input from the current Taylor .I Log and .I Stats -files, as defined at compilation time. +files. The names are either as defined at compilation time, in case +there is no config file, or taken from the arguments of the keywords +.I logfile +and +.I statfile +when encountered in the config file. This is the normal mode of operation. .PP The reporting options described below can be used to select -the set of reports desired. If no options are given, the -.B call -and -.B file -reports are displayed. If there is no relevant data for a particular -report or host, that report or host will be supressed. +the set of reports desired. If no options are given, a summary +report is displayed. If there is no relevant data for a particular +report or host, that report or host will be suppressed. .SH OPTIONS -The following options may be given to +The following options may be given to .I uurate: .TP 5 +.B \-a +All reports. Identical to +.B \-cfexp. +.TP 5 .B \-c Report on call statistics. Requires data from a .I Log file. .TP 5 -.B \-f -Report on file transfer statistics. Requires data from a -.I Stats -file. +.B \-d +will print the default config file to be used. .TP 5 .B \-e Report on efficiency (total connect time versus time spent transferring @@ -79,6 +88,32 @@ and a .I Stats file, and they must span the same time period. .TP 5 +.B \-f +Report on file transfer statistics. Requires data from a +.I Stats +file. +.TP 5 +.B \-h +will print a short help information. +.TP 5 +.B \-i +tells uurate to read any logfile information from standard input. +.TP 5 +.B \-p +report on protocol errors and packets sent/received +.TP 5 +.B \-q +do not print the Environment information, +.TP 5 +.B \-t +All reports. Identical to +.B \-cfexp. +plus the +.B Compact summary. +.TP 5 +.B \-v +will print the version id string +.TP 5 .B \-x Report on remote execution requests (e.g., .IR rmail ")." @@ -86,19 +121,20 @@ Requires data from a .I Log file. .TP 5 -.B \-a -All reports. Identical to -.B \-cfex. -.TP 5 -.BI "\-h " "host" +.BI "\-s " "host" Restrict report output to .I host. +.TP 5 +.BI "\-I " "config file" +an alternate config file may be passed by this option. .SH "DESCRIPTION OF REPORTS" There are four reports available: the call, file transfer, efficiency, and remote execution reports. Each may be selected by a command line -option. All reports may be selected via the option -.B \-a. -If no report selection options are given, +option. All reports may be selected via the options +.B \-a +or +.B \-t. +If no report selection options are given, .I uurate displays a compact traffic summary report (see below). .SS "Summary report" @@ -109,109 +145,136 @@ displays a traffic summary report. This is particularly useful in daily jobs which report on errors and the like. Traffic statistics for each active system is reported on a single line. If more than one system was active, a 'totals' line is included at the end of the report. +.SS "Protocol packet report" +The protocol report gives statistics on min/max packet and window sizes +used during transmission. Further on data is collected for packets +transferred. The data is collected for each host/protocol type. +The fields are described below: +.PP +.br +.nf +.in +.3i +.ta 1.0i +.BR "site " "UUCP node name of neighbor host system," +.BR "typ " "Type of protocol used" +.BR "Min " "minimum packet/window size" +.BR "Max " "maximum packet/window size" +.BR "sent " "packets sent" +.BR "resent " "packets resent" +.BR "received " "packets received" +.in -.3 +.SS "Protocol error report" +The protocol report gives statistics on packet errors +during transmission. The data is collected for each host/protocol type. +The fields are described below: +.PP +.br +.nf +.in +.3i +.ta 1.5i +.BR "site " "UUCP node name of neighbor host system," +.BR "typ " "Type of protocol used" +.BR "header " "number of errors in header" +.BR "checksum " "number of checksum errors" +.BR "order " "number of order errors" +.BR "resent " "number packets resent" +.BR "rem-reject " "packets that the remote site rejected" +.in -.3 .SS "Call report" -The call report gives statistics on inbound and outbound calls for +The call report gives statistics on inbound and outbound calls for each active host system. The fields are described below: +.PP .br .nf -.in +.5i +.in +.3i .ta 1.0i -.BR "sysname " "UUCP node name of neighbor host system" -.BR "callto " "Outbound calls attempted to that system" -.BR "failto " "Failed outbound calls to that system" -.BR "totime " "Connect time (sec.) on outbound calls" -.BR "callfm " "Inbound calls attempted by that system" -.BR "failfm " "Failed inbound calls from that system" -.BR "fmtime " "Connect time (sec.) on inbound calls" -.in -.5 +.BR "site " "UUCP node name of neighbor host system," +.BR "succ. " "Successful calls attempted to/by that system," +.BR "failed " "Failed calls to/by that system," +.BR "total " "Total calls to/by that system," +.BR "time " "Collected connect time (hh:mm:ss) for all calls," +.in -.3 .SS "File transfer reports" -The file transfer reports give statistics on inbound and +The file transfer reports give statistics on inbound and outbound file transfers (regardless of which end initiated the transfer) for each active host system. There are two reports, one for files sent to the remote system and one for files received from the remote system. The fields in each report are described below: +.PP .br .nf -.in +.5i +.in +.3i .ta 1.0i -.BR "sysname " "UUCP node name of neighbor host system" -.BR "files " "Number of files transferred" -.BR "bytes " "Total size (bytes) of files transferred" -.BR "seconds " "Total time (sec.) to transfer files" -.BR "byte/sec " "Average transfer rate (bytes/sec)" -.in -.5 +.BR "site " "UUCP node name of neighbor host system" +.BR "files " "Number of files transferred" +.BR "Bytes/1000 " "Total size of files transferred given in thousands" +.BR "xfr time " "Total time (hh:mm:ss) spent on transfer the files," +.BR "B/sec " "Average transfer rate (bytes/sec)." +.in -.3 .SS "Efficiency report" The efficiency report describes the utilization of the links to each active remote system, giving the ratio of total connect time -to the time spent actually transferring files. +to the time spent actually transferring files. The fields are described below: +.PP .br .nf -.in +.5i +.in +.3i .ta 1.0i -.BR "sysname " "UUCP node name of neighbor host system" -.BR "conntime " "Total connect time for that system" -.BR "flowtime " "Total file transfer time for that system" -.BR "ovhdtime " "Connect time not used to transfer files" -.BR "effcy (%) " "Ratio of connect time to transfer time" -.in -.5 -.SS "Remote execution report" +.BR "site " "UUCP node name of neighbor host system" +.BR "connected " "Total connect time for that system (turn-around)" +.BR "xfr time " "Total file transfer time for that system" +.BR "overhead " "Connect time not used to transfer files," +.BR "eff. % " "Ratio of connect time to transfer time (xfer*100/conn)" +.in -.3 +.SS "Command executions report" The remote execution report describes remotely -requested command executions from each active host system. -Executions of +requested command executions from each active host system, like .I rmail and -.I rnews -are the most common, and are detailed separately. The fields -are described below: +.IR rnews "." +Up to eight command names are displayed. If there are more, the +rest will be put together in an `Misc.' column. +The fields are described below: +.PP .br .nf -.in +.5i +.in +.3i .ta 1.0i -.BR "sysname " "UUCP node name of neighbor host system" -.BR "rmail " "Number of rmail requests from that system" -.BR "rnews " "Number of rnews requests from that system" -.BR "other " "Number of other requests from that system" -.in -.5i +.BR "site " "UUCP node name of neighbor host system," +.BR "(command) " "Number of requests of this command," +.BR "Misc. " "Number of other requests, if more than eight." +.in -.3i .SS FILES The file names below may be changed at compilation time or by the configuration file, so these are only approximations. .br .nf -.in +.5in -.ta 2.0i -.IR "/usr/spool/uucp/Log " "Taylor format call/execution log" -.IR "/usr/spool/uucp/Stats " "Taylor format file transfer log" +.in +.3in +.ta 2.2i +.IR "/usr/spool/uucp/Log " "V2/Taylor format call/execution log," +.IR "/usr/spool/uucp/Stats " "V2/Taylor format file transfer log." .SS "SEE ALSO" .IR uucico "(8)" .SS BUGS -Does not understand older (V2, BNU) logging formats. Anyone care to -volunteer to add this? I don't use the stuff myself. +Does not understand other than V2/TAYLOR logging formats. Anyone care to +volunteer to add the not mentioned? .PP -The entries that Taylor UUCP makes in the log file for incoming calls -don't have a host name. This confuses -.I uurate -into thinking that the calls came in for system "-". This may require -a change to Taylor logging. +Scanning the arguments of logfile and statfile keywords +in config should handle lines continued with the backslash as well. .PP -Should check the configuration file to locate the currently active -.I Log -and -.I Stats -files when using them for default inputs. Instead, it uses the -compile-time settings only. -.PP -Should report packet protocol error statistics by host and -protocol type. +The +.B failfm +field in the call statistics table is always zero, unless +something really serious happens, e.g. uucico got SIGQUIT or +the whole system crashed. .SS AUTHOR -Robert B. Denny (denny@alisa.com) +Robert B. Denny (denny@alisa.com). .br Loosely based on the DECUS UUCP program .I uurate by Mark Pizzolato. - - - - - - +.br +Modified by Stephan Niemz (stephan@sunlab.ka.sub.org). +.br +Modified by Klaus Dahlenburg (kdburg@incoahe.hanse.de). diff --git a/gnu/libexec/uucp/contrib/uureroute b/gnu/libexec/uucp/contrib/uureroute index 3eeb654e1e2..e69de29bb2d 100644 --- a/gnu/libexec/uucp/contrib/uureroute +++ b/gnu/libexec/uucp/contrib/uureroute @@ -1,91 +0,0 @@ -#!/usr/local/bin/perl -eval ' exec /usr/local/bin/perl $0 "$@" ' - if $running_under_some_shell; - -# From a script by <Bill.Campbell@celestial.com> -# Newsgroups: comp.sources.misc -# Subject: v28i073: uureroute - Reroute HDB queued mail, Part01/01 -# Date: 26 Feb 92 02:28:37 GMT -# -# This is a Honey DanBer specific routine written in perl to reroute all -# mail queued up for a specific host. It needs to be run as "root" since -# uucp will not allow itself to remove others requests. -# -# Revision *** 92/21/09: Francois Pinard <pinard@iro.umontreal.ca> -# 1. adapted for Taylor UUCP -# -# Revision 1.3 91/10/08 09:01:21 src -# 1. Rewritten in perl -# 2. Add -v option for debugging. -# -# Revision 1.2 91/10/07 23:57:42 root -# 1. Fix mail program path. -# 2. Truncate directory name to 7 characters - -($progname = $0) =~ s!.*/!!; # save this very early - -$USAGE = " -# Reroute uucp mail -# -# Usage: $progname [-v] host [host...] -# -# Options Argument Description -# -v Verbose (doesn't execute /bin/sh) -# -"; - -$UUSTAT = "/usr/local/bin/uustat"; -$SHELL = "/bin/sh"; -$SMAIL = "/bin/smail"; - -sub usage -{ - die join ("\n", @_) . "\n$USAGE\n"; -} - -do "getopts.pl"; - -&usage ("Invalid Option") unless do Getopts ("vV"); - -$verbose = ($opt_v ? '-v' : ()); -$suffix = ($verbose ? '' : $$); - -&usage ("No system specified") if $#ARGV < 0; - -if (!$verbose) -{ - open (SHELL, "| $SHELL"); - select SHELL; -} - -while ($system = shift) -{ - $sysprefix = substr ($system, 0, 7); - $directory = "/usr/spool/uucp/$sysprefix"; - open (UUSTAT, "$UUSTAT -s $system -c rmail |"); - print "set -ex\n"; - while (<UUSTAT>) - { - ($jobid, ) = split; - ($cfile) = substr ($jobid, length ($jobid) - 5); - $cfilename = "$directory/C./C.$cfile"; - open (CFILE, $cfilename) || die "Cannot open $cfilename\n"; - $_ = <CFILE>; - close CFILE; - if (/^E D\.(....) [^ ]+ [^ ]+ -CR D\.\1 0666 [^ ]+ 0 rmail (.*)/) - { - $datafile = "$directory/D./D.$1"; - $address = $2; - } - else - { - print STDERR; - die "Cannot parse previous line from $cfilename\n"; - } - print "$SMAIL -R $system!$address < $datafile && $UUSTAT -k $jobid\n"; - } - close UUSTAT; -} -close SHELL unless $verbose; - -exit 0; diff --git a/gnu/libexec/uucp/contrib/uureroute.perl b/gnu/libexec/uucp/contrib/uureroute.perl new file mode 100644 index 00000000000..3eeb654e1e2 --- /dev/null +++ b/gnu/libexec/uucp/contrib/uureroute.perl @@ -0,0 +1,91 @@ +#!/usr/local/bin/perl +eval ' exec /usr/local/bin/perl $0 "$@" ' + if $running_under_some_shell; + +# From a script by <Bill.Campbell@celestial.com> +# Newsgroups: comp.sources.misc +# Subject: v28i073: uureroute - Reroute HDB queued mail, Part01/01 +# Date: 26 Feb 92 02:28:37 GMT +# +# This is a Honey DanBer specific routine written in perl to reroute all +# mail queued up for a specific host. It needs to be run as "root" since +# uucp will not allow itself to remove others requests. +# +# Revision *** 92/21/09: Francois Pinard <pinard@iro.umontreal.ca> +# 1. adapted for Taylor UUCP +# +# Revision 1.3 91/10/08 09:01:21 src +# 1. Rewritten in perl +# 2. Add -v option for debugging. +# +# Revision 1.2 91/10/07 23:57:42 root +# 1. Fix mail program path. +# 2. Truncate directory name to 7 characters + +($progname = $0) =~ s!.*/!!; # save this very early + +$USAGE = " +# Reroute uucp mail +# +# Usage: $progname [-v] host [host...] +# +# Options Argument Description +# -v Verbose (doesn't execute /bin/sh) +# +"; + +$UUSTAT = "/usr/local/bin/uustat"; +$SHELL = "/bin/sh"; +$SMAIL = "/bin/smail"; + +sub usage +{ + die join ("\n", @_) . "\n$USAGE\n"; +} + +do "getopts.pl"; + +&usage ("Invalid Option") unless do Getopts ("vV"); + +$verbose = ($opt_v ? '-v' : ()); +$suffix = ($verbose ? '' : $$); + +&usage ("No system specified") if $#ARGV < 0; + +if (!$verbose) +{ + open (SHELL, "| $SHELL"); + select SHELL; +} + +while ($system = shift) +{ + $sysprefix = substr ($system, 0, 7); + $directory = "/usr/spool/uucp/$sysprefix"; + open (UUSTAT, "$UUSTAT -s $system -c rmail |"); + print "set -ex\n"; + while (<UUSTAT>) + { + ($jobid, ) = split; + ($cfile) = substr ($jobid, length ($jobid) - 5); + $cfilename = "$directory/C./C.$cfile"; + open (CFILE, $cfilename) || die "Cannot open $cfilename\n"; + $_ = <CFILE>; + close CFILE; + if (/^E D\.(....) [^ ]+ [^ ]+ -CR D\.\1 0666 [^ ]+ 0 rmail (.*)/) + { + $datafile = "$directory/D./D.$1"; + $address = $2; + } + else + { + print STDERR; + die "Cannot parse previous line from $cfilename\n"; + } + print "$SMAIL -R $system!$address < $datafile && $UUSTAT -k $jobid\n"; + } + close UUSTAT; +} +close SHELL unless $verbose; + +exit 0; diff --git a/gnu/libexec/uucp/contrib/uutraf b/gnu/libexec/uucp/contrib/uutraf index 8b56d0f6b4f..9625ea5206c 100644 --- a/gnu/libexec/uucp/contrib/uutraf +++ b/gnu/libexec/uucp/contrib/uutraf @@ -1,11 +1,11 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # uutraf.pl -- UUCP Traffic Analyzer -# SCCS Status : @(#)@ uutraf 1.7 +# SCCS Status : @(#)@ uutraf 1.8 # Author : Johan Vromans # Created On : *** # Last Modified By: Johan Vromans -# Last Modified On: Wed Feb 26 08:52:56 1992 -# Update Count : 4 +# Last Modified On: Mon Aug 30 15:02:22 1993 +# Update Count : 6 # Status : OK # Requires: : Perl V4 or later @@ -52,7 +52,7 @@ if ( $ARGV[0] =~ /^-/ ) { } if ( $uucp_type eq "taylor" || $uucp_type eq "gnu" ) { - @ARGV = ("/usr/spool/uucp/Stats") unless $#ARGV >= 0; + @ARGV = ("/usr/local/spool/uucp/Stats") unless $#ARGV >= 0; $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/ .]+)\\) " . "(sent|received) (\\d+) bytes in (\\d+)\\.(\\d+) seconds"; $uucp_type = 0; @@ -73,16 +73,17 @@ elsif ( $uucp_type eq "bsd" || $uucp_type eq "v7" ) { $recv = "received"; } else { - die ("Unknown UUCP type: $uucp_type\n"); + die ("FATAL: Unknown UUCP type: $uucp_type\n"); } $garbage = 0; while ( <> ) { unless ( /$pat/o ) { - print STDERR "Possible garbage: $_"; + print STDERR "$_"; + next if /failed/; if ( $garbage++ > 10 ) { - die ("Too much garbage; wrong UUCP type?\n"); + die ("FATAL: Too much garbage; wrong UUCP type?\n"); } next; } @@ -90,10 +91,10 @@ while ( <> ) { # gather timestamps $last_date = $2; $first_date = $last_date unless defined $first_date; - + # initialize new hosts unless ( defined $hosts{$1} ) { - $hosts{$1} = $files_in{$1} = $files_out{$1} = + $hosts{$1} = $files_in{$1} = $files_out{$1} = $bytes_in{$1} = $bytes_out{$1} = $secs_in{$1} = $secs_out{$1} = 0; } @@ -162,9 +163,9 @@ foreach $host (@hosts) { sub print_line { reset "Z"; # reset print fields - local ($Zhost, - $Zi_bytes, $Zo_bytes, - $Zi_secs, $Zo_secs, + local ($Zhost, + $Zi_bytes, $Zo_bytes, + $Zi_secs, $Zo_secs, $Zi_count, $Zo_count) = @_; $Ti_bytes += $Zi_bytes; $To_bytes += $Zo_bytes; @@ -186,7 +187,7 @@ sub print_line { sub print_dashes { $Zhost = $Zi_bytes = $Zo_bytes = $Zt_bytes = - $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count = + $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count = "------------"; write; # easy, isn't it? @@ -196,6 +197,12 @@ sub print_dashes { sub gethostname { $ENV{"SHELL"} = "/bin/sh"; + $try = `hostname 2>/dev/null`; + chop $try; + return $+ if $try =~ /^[-.\w]+$/; + $try = `uname -n 2>/dev/null`; + chop $try; + return $+ if $try =~ /^[-.\w]+$/; $try = `uuname -l 2>/dev/null`; chop $try; return $+ if $try =~ /^[-.\w]+$/; diff --git a/gnu/libexec/uucp/contrib/uuxconv b/gnu/libexec/uucp/contrib/uuxconv new file mode 100644 index 00000000000..843f9e000fa --- /dev/null +++ b/gnu/libexec/uucp/contrib/uuxconv @@ -0,0 +1,50 @@ +#!/bin/sh +# +# uuxconv +# +# After converting to Taylor from SVR4.03 UUCP, I still had a lot of +# jobs queued up to go out. +# +# This script is a one-shot to mass-requeue a site's spool. +# +# It doesn't go and do your whole spool, nor even all grades. +# you need to go into each grade directory for each site and +# execute this. +# +# i.e.: You have a site named 'foo' +# cd /var/spool/uucp/foo/Z +# uuxconv foo +# +# it does delete the 'D' & 'X' after requeing them, but doesn't remove +# the 'C' files. +# +# I foolishly went and ran this script on all my queued jobs, without +# adding the improvements to recursively go through the entire UUCP spool, +# so now I'm out of files to test with. I don't want to add the code +# to do that since I can't test it, and this worked. +# +# I hereby give this (trivial :-)) program to the GNU Project/FSF +# and Ian Taylor in it's entirety, so that it can be placed in +# the contrib directory of taylor-uucp, and save others the pain +# of rewriting it. +# +# Richard Nickle (rick@trystro.uucp, rnickle@gnu.ai.mit.edu) +# May 27, 1993 +# +if [ $# -eq 0 ] +then + echo "Usage: $0 sitename" + exit 1 +fi +exit 0 +site=$1 +tsite=`echo $site | cut -c1-5` +find . -name "D.$tsite*" -print | +while read file +do + control=`egrep "^C" $file | cut -c3-` + input=`egrep "^I" $file | cut -c3-` + (uux - -r -z $site!$control < $input) && (rm $file $input) + echo "$site!$control < $input" +done +exit 0 diff --git a/gnu/libexec/uucp/contrib/xchat.c b/gnu/libexec/uucp/contrib/xchat.c index cfb4d359662..b44549e53ed 100644 --- a/gnu/libexec/uucp/contrib/xchat.c +++ b/gnu/libexec/uucp/contrib/xchat.c @@ -9,6 +9,9 @@ * Bob Denny (denny@alisa.com) * Based on code in DECUS UUCP (for VAX/VMS) * + * Small modification by: + * Daniel Hagerty (hag@eddie.mit.edu) + * * History: * Version 1.0 shipped with Taylor 1.03. No configuration info inside. * @@ -18,6 +21,12 @@ * for timed reads. Use Taylor UUCP "conf.h" file to set * configuration for this program. Add defaulting of script * and log file paths. + * + * Daniel Hagerty - Mon Nov 22 18:17:38 1993 + * V1.2 - Added a new opcode to xchat. "expectstr" is a cross between + * sendstr and expect, looking for a parameter supplied string. + * Useful where a prompt could change for different dial in + * lines and such. * * Bugs: * Does not support BSD terminal I/O. Anyone care to add it? @@ -130,7 +139,8 @@ struct script_opdef { #define SC_PEVN 39 /* Set port for 7-bit, even parity */ #define SC_PODD 40 /* Set port for 7-bit, odd parity */ #define SC_HUPS 41 /* Change state on HUP signal */ -#define SC_END 42 /* end of array */ +#define SC_XPST 42 /* Expect a param string */ +#define SC_END 43 /* end of array */ /* values for prmtype, prm2type */ @@ -186,6 +196,7 @@ static struct script_opdef sc_opdef[] = {"sendstr", SC_SNDP, SC_INT, SC_NONE}, {"ifstr", SC_IF1P, SC_INT, SC_NWST}, {"ifnstr", SC_IF0P, SC_INT, SC_NWST}, + {"expectstr", SC_XPST, SC_INT, SC_NWST}, {"table end", SC_END, SC_NONE, SC_NONE} }; @@ -1029,6 +1040,7 @@ int do_script(begin) case SC_TIMO: /* these are "expects", don't bother */ case SC_XPCT: /* with them yet, other than noting that */ case SC_CARR: /* they exist */ + case SC_XPST: expcnt++; break; } @@ -1132,7 +1144,24 @@ int do_script(begin) } } } - + /* New opcode added by hag@eddie.mit.edu for expecting a + parameter supplied string */ + case SC_XPST: + if(curscr->intprm >paramc-1) + { + sprintf(tempstr,"expectstr - param#%d",curscr->intprm); + logit(tempstr, " not present"); + return(FAIL); + } + prmlen=xlat_str(tempstr,paramv[curscr->intprm]); + if((expin >= prmlen) && + (strncmp(tempstr,&expbuf[expin-prmlen], + prmlen) == SAME)) + { + charlog(tempstr,prmlen,DB_LGI, "Matched"); + goto _chgstate; + } + break; /* * SIGNAL HANDLERS */ diff --git a/gnu/libexec/uucp/contrib/xchat.man b/gnu/libexec/uucp/contrib/xchat.man index c980e202fcb..55537be9072 100644 --- a/gnu/libexec/uucp/contrib/xchat.man +++ b/gnu/libexec/uucp/contrib/xchat.man @@ -380,6 +380,18 @@ is received from standard input (usually the serial port). Case is significant, but high-order bits are not checked. .TP 2.0i +.BI "expectstr " "ns int" +Change to state +.I ns +if the string specified in parameter +.I int +is received from standard input (usually the serial port). +.I int +must be in the range 0 to 7. +Case is significant, but high-order bits are not +checked. +Useful where a prompt can change in different dial-in lines. +.TP 2.0i .BI "ifcarr " ns Change to state .I ns @@ -604,6 +616,8 @@ seconds). uucico(8) for Taylor UUCP, and documentation for Taylor UUCP. .SH AUTHOR Robert B. Denny (denny@alisa.com) +.SH CONTRIBUTORS +Daniel Hagerty (hag@eddie.mit.edu) .SH HISTORY This program is an adaptation of the dial/login script processing code that is a part of DECUS UUCP for VAX/VMS, written by Jamie diff --git a/gnu/libexec/uucp/cu/cu.1 b/gnu/libexec/uucp/cu/cu.1 index 56409a00427..118cff5fc4c 100644 --- a/gnu/libexec/uucp/cu/cu.1 +++ b/gnu/libexec/uucp/cu/cu.1 @@ -1,5 +1,5 @@ -''' $Id: cu.1,v 1.1 1993/08/04 19:31:53 jtc Exp $ -.TH cu 1 "Taylor UUCP 1.04" +''' $Id: cu.1,v 1.2 1994/10/24 22:18:11 jtc Exp $ +.TH cu 1 "Taylor UUCP 1.05" .SH NAME cu \- Call up another system .SH SYNOPSIS @@ -22,8 +22,12 @@ Otherwise, if the argument begins with a digit, it is taken to be a phone number to call. Otherwise, it is taken to be the name of a system to call. The .B \-z +or +.B \-\-system option may be used to name a system beginning with a digit, and the .B \-c +or +.B \-\-phone option may be used to name a phone number that does not begin with a digit. @@ -31,9 +35,9 @@ digit. locates a port to use in the UUCP configuration files. If a simple system name is given, it will select a port appropriate for that system. The -.B \-p, \-l +.B \-p, \-\-port, \-l, \-\-line, \-s and -.B \-s +.B \-\-speed options may be used to control the port selection. When a connection is made to the remote system, @@ -208,53 +212,55 @@ default is true. The following options may be given to .I cu. .TP 5 -.B \-e +.B \-e, \-\-parity=even Use even parity. .TP 5 -.B \-o -Use odd parity. If both +.B \-o, \-\-parity=odd +Use odd parity. +.TP 5 +.B \-\-parity=none +Use no parity. No parity is also used if both .B \-e and .B \-o -are used, no parity is used. Otherwise the default parity of the line -is used. +are given. .TP 5 -.B \-h +.B \-h, \-\-halfduplex Echo characters locally (half-duplex mode). .TP 5 -.B \-z system +.B \-z system, \-\-system system The system to call. .TP 5 -.B \-c phone-number +.B \-c phone-number, \-\-phone phone-number The phone number to call. .TP 5 -.B \-p port +.B \-p port, \-\-port port Name the port to use. .TP 5 .B \-a port Equivalent to -.B \-p port. +.B \-\-port port. .TP 5 -.B \-l line +.B \-l line, \-\-line line Name the line to use by giving a device name. This may be used to dial out on ports that are not listed in the UUCP configuration files. Write access to the device is required. .TP 5 -.B \-s speed +.B \-s speed, \-\-speed speed The speed (baud rate) to use. .TP 5 .B \-# Where # is a number, equivalent to -.B \-s #. +.B \-\-speed #. .TP 5 -.B \-n +.B \-n, \-\-prompt Prompt for the phone number to use. .TP 5 .B \-d Enter debugging mode. Equivalent to -.B \-x all. +.B \-debug all. .TP 5 -.B \-x type +.B \-x type, \-\-debug type Turn on particular debugging types. The following types are recognized: abnormal, chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing. Only abnormal, chat, @@ -262,20 +268,26 @@ handshake, port, config, incoming and outgoing are meaningful for .I cu. Multiple types may be given, separated by commas, and the -.B \-x +.B \-\-debug option may appear multiple times. A number may also be given, which will turn on that many types from the foregoing list; for example, -.B \-x 2 +.B \-\-debug 2 is equivalent to -.B \-x abnormal,chat. -.B \-x all +.B \-\-debug abnormal,chat. +.B \-\-debug all may be used to turn on all debugging options. .TP 5 -.B \-I file +.B \-I file, \-\-config file Set configuration file to use. This option may not be available, depending upon how .I cu was compiled. +.TP 5 +.B \-v, \-\-version +Report version information and exit. +.TP 5 +.B \-\-help +Print a help message and exit. .SH BUGS This program does not work very well. .SH FILES @@ -284,3 +296,6 @@ approximation. .br /usr/lib/uucp/config - Configuration file. +.SH AUTHOR +Ian Lance Taylor +<ian@airs.com> diff --git a/gnu/libexec/uucp/cu/cu.c b/gnu/libexec/uucp/cu/cu.c index 72d60a62ecc..aaea4e9bcb8 100644 --- a/gnu/libexec/uucp/cu/cu.c +++ b/gnu/libexec/uucp/cu/cu.c @@ -1,7 +1,7 @@ /* cu.c Call up a remote system. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char cu_rcsid[] = "$Id: cu.c,v 1.1 1993/08/04 19:31:54 jtc Exp $"; +const char cu_rcsid[] = "$Id: cu.c,v 1.2 1994/10/24 22:18:13 jtc Exp $"; #endif #include "cu.h" @@ -66,7 +66,7 @@ boolean fCuvar_binary = FALSE; /* A prefix string to use before sending a binary character from a file; this is only used if fCuvar_binary is TRUE. The default is - ^Z. */ + ^V. */ const char *zCuvar_binary_prefix = "\026"; /* Whether to check for echoes of characters sent when sending a file. @@ -126,9 +126,6 @@ static const struct uuconf_cmdtab asCuvars[] = { NULL, 0, NULL, NULL} }; -/* The program name. */ -char abProgram[] = "cu"; - /* The string printed at the initial connect. */ #if ANSI_C #define ZCONNMSG "\aConnected." @@ -175,6 +172,9 @@ static boolean fCulocalecho; /* Whether we need to call fsysdep_cu_finish. */ static boolean fCustarted; +/* Whether ZCONNMSG has been printed yet. */ +static boolean fCuconnprinted = FALSE; + /* A structure used to pass information to icuport_lock. */ struct sconninfo { @@ -187,6 +187,7 @@ struct sconninfo /* Local functions. */ static void ucuusage P((void)); +static void ucuhelp P((void)); static void ucuabort P((void)); static void uculog_start P((void)); static void uculog_end P((void)); @@ -209,7 +210,24 @@ static boolean fcusend_buf P((struct sconnection *qconn, const char *zbuf, do { if (! fsysdep_terminal_puts (zline)) ucuabort (); } while (0) /* Long getopt options. */ -static const struct option asCulongopts[] = { { NULL, 0, NULL, 0 } }; +static const struct option asCulongopts[] = +{ + { "phone", required_argument, NULL, 'c' }, + { "parity", required_argument, NULL, 2 }, + { "halfduplex", no_argument, NULL, 'h' }, + { "prompt", no_argument, NULL, 'n' }, + { "line", required_argument, NULL, 'l' }, + { "port", required_argument, NULL, 'p' }, + { "speed", required_argument, NULL, 's' }, + { "baud", required_argument, NULL, 's' }, + { "mapcr", no_argument, NULL, 't' }, + { "system", required_argument, NULL, 'z' }, + { "config", required_argument, NULL, 'I' }, + { "debug", required_argument, NULL, 'x' }, + { "version", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, 1 }, + { NULL, 0, NULL, 0 } +}; int main (argc, argv) @@ -252,6 +270,8 @@ main (argc, argv) struct uuconf_dialer *qdialer; char bcmd; + zProgram = argv[0]; + /* We want to accept -# as a speed. It's easiest to look through the arguments, replace -# with -s#, and let getopt handle it. */ for (i = 1; i < argc; i++) @@ -271,7 +291,7 @@ main (argc, argv) } } - while ((iopt = getopt_long (argc, argv, "a:c:dehnI:l:op:s:tx:z:", + while ((iopt = getopt_long (argc, argv, "a:c:dehnI:l:op:s:tvx:z:", asCulongopts, (int *) NULL)) != EOF) { switch (iopt) @@ -347,13 +367,47 @@ main (argc, argv) #endif break; + case 'v': + /* Print version and exit. */ + fprintf + (stderr, + "%s: Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", + zProgram, VERSION); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + + case 2: + /* --parity. */ + if (strncmp (optarg, "even", strlen (optarg)) == 0) + feven = TRUE; + else if (strncmp (optarg, "odd", strlen (optarg)) == 0) + fodd = TRUE; + else if (strncmp (optarg, "none", strlen (optarg)) == 0) + { + feven = TRUE; + fodd = TRUE; + } + else + { + fprintf (stderr, "%s: --parity requires even, odd or none\n", + zProgram); + ucuusage (); + } + break; + + case 1: + /* --help. */ + ucuhelp (); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + case 0: /* Long option found and flag set. */ break; default: ucuusage (); - break; + /*NOTREACHED*/ } } @@ -366,7 +420,10 @@ main (argc, argv) if (optind != argc - 1 || zsystem != NULL || zphone != NULL) - ucuusage (); + { + fprintf (stderr, "%s: too many arguments\n", zProgram); + ucuusage (); + } if (strcmp (argv[optind], "dir") != 0) { if (isdigit (BUCHAR (argv[optind][0]))) @@ -382,7 +439,11 @@ main (argc, argv) && zport == NULL && zline == NULL && ibaud == 0L) - ucuusage (); + { + fprintf (stderr, "%s: must specify system, line, port or speed\n", + zProgram); + ucuusage (); + } if (fprompt) { @@ -395,7 +456,7 @@ main (argc, argv) if (getline (&zphone, &cphone, stdin) <= 0 || *zphone == '\0') { - fprintf (stderr, "%s: No phone number entered\n", abProgram); + fprintf (stderr, "%s: no phone number entered\n", zProgram); exit (EXIT_FAILURE); } } @@ -523,16 +584,20 @@ main (argc, argv) sport.uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL; sport.uuconf_u.uuconf_sdirect.uuconf_ibaud = ibaud; - if (! fsysdep_port_access (&sport)) - ulog (LOG_FATAL, "%s: Permission denied", zline); - - if (! fconn_init (&sport, &sconn)) + if (! fconn_init (&sport, &sconn, UUCONF_PORTTYPE_UNKNOWN)) ucuabort (); if (! fconn_lock (&sconn, FALSE)) ulog (LOG_FATAL, "%s: Line in use", zline); qCuconn = &sconn; + + /* Check user access after locking the port, because on + some systems shared lines affect the ownership and + permissions. In such a case ``Line in use'' is more + clear than ``Permission denied.'' */ + if (! fsysdep_port_access (&sport)) + ulog (LOG_FATAL, "%s: Permission denied", zline); } ihighbaud = 0L; } @@ -544,7 +609,8 @@ main (argc, argv) continue; if (qsys->uuconf_qport != NULL) { - if (fconn_init (qsys->uuconf_qport, &sconn)) + if (fconn_init (qsys->uuconf_qport, &sconn, + UUCONF_PORTTYPE_UNKNOWN)) { if (fconn_lock (&sconn, FALSE)) { @@ -648,7 +714,8 @@ main (argc, argv) || qsys == NULL) ucuabort (); - if (qsys->uuconf_qalternate == NULL) + qsys = qsys->uuconf_qalternate; + if (qsys == NULL) ulog (LOG_FATAL, "%s: No remaining alternates", zsystem); fCuclose_conn = FALSE; @@ -693,6 +760,7 @@ main (argc, argv) only comes out when a special command is received from the terminal. */ printf ("%s\n", ZCONNMSG); + fCuconnprinted = TRUE; if (! fsysdep_terminal_raw (fCulocalecho)) ucuabort (); @@ -719,7 +787,8 @@ main (argc, argv) (void) fconn_unlock (&sconn); uconn_free (&sconn); - printf ("\n%s\n", ZDISMSG); + if (fCuconnprinted) + printf ("\n%s\n", ZDISMSG); ulog_close (); @@ -734,41 +803,56 @@ main (argc, argv) static void ucuusage () { + fprintf (stderr, "Usage: %s [options] [system or phone-number]\n", + zProgram); + fprintf (stderr, "Use %s --help for help\n", zProgram); + exit (EXIT_FAILURE); +} + +/* Print a help message. */ + +static void +ucuhelp () +{ fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", + "Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", VERSION); fprintf (stderr, - "Usage: cu [options] [system or phone-number]\n"); + "Usage: %s [options] [system or phone-number]\n", zProgram); fprintf (stderr, - " -a port, -p port: Use named port\n"); + " -a,-p,--port port: Use named port\n"); fprintf (stderr, - " -l line: Use named device (e.g. tty0)\n"); + " -l,--line line: Use named device (e.g. tty0)\n"); fprintf (stderr, - " -s speed, -#: Use given speed\n"); + " -s,--speed,--baud speed, -#: Use given speed\n"); fprintf (stderr, - " -c phone: Phone number to call\n"); + " -c,--phone phone: Phone number to call\n"); fprintf (stderr, - " -z system: System to call\n"); + " -z,--system system: System to call\n"); fprintf (stderr, " -e: Set even parity\n"); fprintf (stderr, " -o: Set odd parity\n"); fprintf (stderr, - " -h: Echo locally\n"); + " --parity={odd,even}: Set parity\n"); + fprintf (stderr, + " -h,--halfduplex: Echo locally\n"); fprintf (stderr, - " -t: Map carriage return to carriage return/linefeed\n"); + " -t,--mapcr: Map carriage return to carriage return/linefeed\n"); fprintf (stderr, - " -n: Prompt for phone number\n"); + " -n,--prompt: Prompt for phone number\n"); fprintf (stderr, " -d: Set maximum debugging level\n"); fprintf (stderr, - " -x debug: Set debugging type\n"); + " -x,--debug debug: Set debugging type\n"); #if HAVE_TAYLOR_CONFIG fprintf (stderr, - " -I file: Set configuration file to use\n"); + " -I,--config file: Set configuration file to use\n"); #endif /* HAVE_TAYLOR_CONFIG */ - - exit (EXIT_FAILURE); + fprintf (stderr, + " -v,--version: Print version and exit\n"); + fprintf (stderr, + " --help: Print help and exit\n"); } /* This function is called when a fatal error occurs. */ @@ -805,7 +889,8 @@ ucuabort () ulog_close (); - printf ("\n%s\n", ZDISMSG); + if (fCuconnprinted) + printf ("\n%s\n", ZDISMSG); usysdep_exit (FALSE); } @@ -866,7 +951,7 @@ icuport_lock (qport, pinfo) q->fmatched = TRUE; - if (! fconn_init (qport, q->qconn)) + if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN)) return UUCONF_NOT_FOUND; else if (! fconn_lock (q->qconn, FALSE)) { diff --git a/gnu/libexec/uucp/libunix/MANIFEST b/gnu/libexec/uucp/libunix/MANIFEST index d64e7992204..c57f466fc98 100644 --- a/gnu/libexec/uucp/libunix/MANIFEST +++ b/gnu/libexec/uucp/libunix/MANIFEST @@ -8,8 +8,9 @@ basnam.c bytfre.c chmod.c cohtty.c -cwd.c +corrup.c cusub.c +cwd.c detach.c dirent.c dup2.c @@ -40,7 +41,9 @@ move.c opensr.c pause.c picksb.c +pipe.c portnm.c +priv.c proctm.c recep.c remove.c diff --git a/gnu/libexec/uucp/libunix/Makefile b/gnu/libexec/uucp/libunix/Makefile index 16fad592afb..5878c8d397f 100644 --- a/gnu/libexec/uucp/libunix/Makefile +++ b/gnu/libexec/uucp/libunix/Makefile @@ -1,5 +1,5 @@ # This subdirectory contains Unix specific support functions. -# $Id: Makefile,v 1.3 1993/10/28 05:00:07 cgd Exp $ +# $Id: Makefile,v 1.4 1994/10/24 22:18:21 jtc Exp $ LIB= unix SRCS= access.c addbas.c app3.c app4.c basnam.c bytfre.c cwd.c \ @@ -10,7 +10,8 @@ SRCS= access.c addbas.c app3.c app4.c basnam.c bytfre.c cwd.c \ proctm.c recep.c run.c seq.c serial.c signal.c sindir.c size.c \ sleep.c spawn.c splcmd.c splnam.c spool.c srmdir.c statsb.c \ status.c time.c tmpfil.c trunc.c uacces.c ufopen.c ultspl.c \ - unknwn.c uuto.c walk.c wldcrd.c work.c xqtfil.c xqtsub.c ftw.c + unknwn.c uuto.c walk.c wldcrd.c work.c xqtfil.c xqtsub.c \ + ftw.c corrup.c pipe.c priv.c CFLAGS+= -I$(.CURDIR)/../common_sources \ -DOWNER=\"$(owner)\" -DSBINDIR=\"$(sbindir)\" diff --git a/gnu/libexec/uucp/libunix/app3.c b/gnu/libexec/uucp/libunix/app3.c index 5c0b5893851..f3c3555a363 100644 --- a/gnu/libexec/uucp/libunix/app3.c +++ b/gnu/libexec/uucp/libunix/app3.c @@ -19,7 +19,10 @@ zsappend3 (zdir1, zdir2, zfile) cdir2 = strlen (zdir2); cfile = strlen (zfile); zret = zbufalc (cdir1 + cdir2 + cfile + 3); - memcpy (zret, zdir1, cdir1); + if (cdir1 == 1 && *zdir1 == '/') + cdir1 = 0; + else + memcpy (zret, zdir1, cdir1); memcpy (zret + cdir1 + 1, zdir2, cdir2); memcpy (zret + cdir1 + cdir2 + 2, zfile, cfile); zret[cdir1] = '/'; diff --git a/gnu/libexec/uucp/libunix/app4.c b/gnu/libexec/uucp/libunix/app4.c index a3b3787f68f..d3a243fd728 100644 --- a/gnu/libexec/uucp/libunix/app4.c +++ b/gnu/libexec/uucp/libunix/app4.c @@ -21,7 +21,10 @@ zsappend4 (zdir1, zdir2, zdir3, zfile) cdir3 = strlen (zdir3); cfile = strlen (zfile); zret = zbufalc (cdir1 + cdir2 + cdir3 + cfile + 4); - memcpy (zret, zdir1, cdir1); + if (cdir1 == 1 && *zdir1 == '/') + cdir1 = 0; + else + memcpy (zret, zdir1, cdir1); memcpy (zret + cdir1 + 1, zdir2, cdir2); memcpy (zret + cdir1 + cdir2 + 2, zdir3, cdir3); memcpy (zret + cdir1 + cdir2 + cdir3 + 3, zfile, cfile); diff --git a/gnu/libexec/uucp/libunix/cohtty.c b/gnu/libexec/uucp/libunix/cohtty.c index a7aec1cae33..5a52df91e57 100644 --- a/gnu/libexec/uucp/libunix/cohtty.c +++ b/gnu/libexec/uucp/libunix/cohtty.c @@ -37,6 +37,19 @@ * reset the serial device to see if the device needs to be re-enabled. */ +/* May 10, 1993: This function will always return true for the following + * reasons: + * 1) lock files have already been dealt with + * 2) if someone else already has the port open, uucico should fail anyways + * 3) Coherent's disable command return can return '0' or '1', but will + * succeed in any event. + * 4) It doesn't matter if there is a ttys entry for the port in question. + * /etc/ttys generally only lists devices that MAY be enabled for logins. + * If a device will never be used for logins, then there may not be a + * ttys entry, in which case, disable won't be called anyways. + * ---bob@mwc.com + */ + boolean fscoherent_disable_tty (zdevice, pzenable) const char *zdevice; @@ -130,14 +143,14 @@ char enable_device[16]; /* this will hold our device name + strlen (enable_device)); sprintf(*pzenable,"/dev/%s", enable_device); /* ulog(LOG_NORMAL,"Enable string is {%s}",*pzenable); */ - return(x==0? TRUE : FALSE); /* disable either failed - or succeded */ + return TRUE; }else{ - return FALSE; /* device in tty entry not enabled */ + /* device not enabled */ + return TRUE; } } } - return FALSE; /* no ttys entry found */ + return TRUE; /* no ttys entry found */ } /* The following is COHERENT 4.0 specific. It is used to test for any diff --git a/gnu/libexec/uucp/libunix/corrup.c b/gnu/libexec/uucp/libunix/corrup.c new file mode 100644 index 00000000000..87f19e66889 --- /dev/null +++ b/gnu/libexec/uucp/libunix/corrup.c @@ -0,0 +1,33 @@ +/* corrup.c + Save a file in the .Corrupt directory. */ + +#include "uucp.h" + +#include "sysdep.h" +#include "uudefs.h" +#include "system.h" + +char * +zsysdep_save_corrupt_file (zfile) + const char *zfile; +{ + const char *zslash; + char *zto; + + zslash = strrchr (zfile, '/'); + if (zslash == NULL) + zslash = zfile; + else + ++zslash; + + zto = zsappend3 (zSspooldir, CORRUPTDIR, zslash); + + if (! fsysdep_move_file (zfile, zto, TRUE, FALSE, FALSE, + (const char *) NULL)) + { + ubuffree (zto); + return NULL; + } + + return zto; +} diff --git a/gnu/libexec/uucp/libunix/cusub.c b/gnu/libexec/uucp/libunix/cusub.c index 4cee888d716..8b24d88e15c 100644 --- a/gnu/libexec/uucp/libunix/cusub.c +++ b/gnu/libexec/uucp/libunix/cusub.c @@ -1,7 +1,7 @@ /* cusub.c System dependent routines for cu. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char cusub_rcsid[] = "$Id: cusub.c,v 1.1 1993/08/04 19:32:09 jtc Exp $"; +const char cusub_rcsid[] = "$Id: cusub.c,v 1.2 1994/10/24 22:18:29 jtc Exp $"; #endif #include "uudefs.h" @@ -37,8 +37,40 @@ const char cusub_rcsid[] = "$Id: cusub.c,v 1.1 1993/08/04 19:32:09 jtc Exp $"; #include "conn.h" #include "prot.h" +#if HAVE_FCNTL_H +#include <fcntl.h> +#else +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#endif +#endif + +/* Get definitions for both O_NONBLOCK and O_NDELAY. */ +#ifndef O_NDELAY +#ifdef FNDELAY +#define O_NDELAY FNDELAY +#else /* ! defined (FNDELAY) */ +#define O_NDELAY 0 +#endif /* ! defined (FNDELAY) */ +#endif /* ! defined (O_NDELAY) */ + +#ifndef O_NONBLOCK +#ifdef FNBLOCK +#define O_NONBLOCK FNBLOCK +#else /* ! defined (FNBLOCK) */ +#define O_NONBLOCK 0 +#endif /* ! defined (FNBLOCK) */ +#endif /* ! defined (O_NONBLOCK) */ + #include <errno.h> +/* 4.2 systems don't define SIGUSR2. This should work for them. On + systems which are missing SIGUSR1, or SIGURG, you must find two + signals which you can safely use. */ +#ifndef SIGUSR2 +#define SIGUSR2 SIGURG +#endif + /* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */ #ifndef EAGAIN #ifndef EWOULDBLOCK @@ -69,6 +101,7 @@ static char bStstp; static const char *zsport_line P((const struct uuconf_port *qport)); static void uscu_child P((struct sconnection *qconn, int opipe)); +static RETSIGTYPE uscu_child_handler P((int isig)); static RETSIGTYPE uscu_alarm P((int isig)); static int cscu_escape P((char *pbcmd, const char *zlocalname)); static RETSIGTYPE uscu_alarm_kill P((int isig)); @@ -97,6 +130,7 @@ zsport_line (qport) break; case UUCONF_PORTTYPE_TCP: case UUCONF_PORTTYPE_TLI: + case UUCONF_PORTTYPE_PIPE: return NULL; } @@ -556,7 +590,9 @@ uscu_child (qconn, opipe) CATCH_PROTECT int cwrite; CATCH_PROTECT char abbuf[1024]; - /* It would be nice if we could just use fsserial_read, but that + fgot = FALSE; + + /* It would be nice if we could just use fsysdep_conn_read, but that will log signals that we don't want logged. There should be a generic way to extract the file descriptor from the port. */ if (qconn->qport == NULL) @@ -571,8 +607,12 @@ uscu_child (qconn, opipe) oport = -1; break; #endif + case UUCONF_PORTTYPE_PIPE: + /* A read of 0 on a pipe always means EOF (see below). */ + fgot = TRUE; + /* Fall through. */ case UUCONF_PORTTYPE_STDIN: - oport = 0; + oport = ((struct ssysdep_conn *) qconn->psysdep)->ord; break; case UUCONF_PORTTYPE_MODEM: case UUCONF_PORTTYPE_DIRECT: @@ -583,6 +623,10 @@ uscu_child (qconn, opipe) } } + /* Force the descriptor into blocking mode. */ + (void) fcntl (oport, F_SETFL, + fcntl (oport, F_GETFL, 0) &~ (O_NDELAY | O_NONBLOCK)); + usset_signal (SIGUSR1, uscu_child_handler, TRUE, (boolean *) NULL); usset_signal (SIGUSR2, uscu_child_handler, TRUE, (boolean *) NULL); usset_signal (SIGINT, SIG_IGN, TRUE, (boolean *) NULL); @@ -591,7 +635,6 @@ uscu_child (qconn, opipe) usset_signal (SIGTERM, uscu_child_handler, TRUE, (boolean *) NULL); fstopped = FALSE; - fgot = FALSE; iSchild_sig = 0; cwrite = 0; @@ -792,7 +835,7 @@ fsysdep_terminal_raw (flocalecho) sSterm_new.c_lflag &=~ (ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHONL); else sSterm_new.c_lflag &=~ (ICANON | ISIG); - sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL); + sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY); sSterm_new.c_oflag &=~ (OPOST); sSterm_new.c_cc[VMIN] = 1; sSterm_new.c_cc[VTIME] = 0; @@ -808,7 +851,7 @@ fsysdep_terminal_raw (flocalecho) (ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHOK | ECHONL); else sSterm_new.c_lflag &=~ (ICANON | IEXTEN | ISIG); - sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL); + sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF); sSterm_new.c_oflag &=~ (OPOST); sSterm_new.c_cc[VMIN] = 1; sSterm_new.c_cc[VTIME] = 0; @@ -1094,8 +1137,9 @@ fsysdep_shell (qconn, zcmd, tcmd) oread = owrite = -1; break; case UUCONF_PORTTYPE_STDIN: - oread = 0; - owrite = 1; + case UUCONF_PORTTYPE_PIPE: + oread = ((struct ssysdep_conn *) qconn->psysdep)->ord; + owrite = ((struct ssysdep_conn *) qconn->psysdep)->owr; break; case UUCONF_PORTTYPE_MODEM: case UUCONF_PORTTYPE_DIRECT: diff --git a/gnu/libexec/uucp/libunix/cwd.c b/gnu/libexec/uucp/libunix/cwd.c index 433025db6c3..71d05d11f54 100644 --- a/gnu/libexec/uucp/libunix/cwd.c +++ b/gnu/libexec/uucp/libunix/cwd.c @@ -24,14 +24,17 @@ fsysdep_needs_cwd (zfile) consistent with other UUCP packages. */ char * -zsysdep_local_file_cwd (zfile, zpubdir) +zsysdep_local_file_cwd (zfile, zpubdir, pfbadname) const char *zfile; const char *zpubdir; + boolean *pfbadname; { + if (pfbadname != NULL) + *pfbadname = FALSE; if (*zfile == '/') return zbufcpy (zfile); else if (*zfile == '~') - return zsysdep_local_file (zfile, zpubdir); + return zsysdep_local_file (zfile, zpubdir, pfbadname); else return zsysdep_add_cwd (zfile); } diff --git a/gnu/libexec/uucp/libunix/detach.c b/gnu/libexec/uucp/libunix/detach.c index 41e1969b5ef..9b505af499c 100644 --- a/gnu/libexec/uucp/libunix/detach.c +++ b/gnu/libexec/uucp/libunix/detach.c @@ -1,7 +1,7 @@ /* detach.c Detach from the controlling terminal. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -54,6 +54,11 @@ #define O_WRONLY 1 #define O_RDWR 2 #endif + +#if HAVE_BROKEN_SETSID +#undef HAVE_SETSID +#define HAVE_SETSID 0 +#endif /* Detach from the controlling terminal. This is called by uucico if it is calling out to another system, so that it can receive SIGHUP @@ -64,14 +69,9 @@ void usysdep_detach () { -#if ! HAVE_BSD_PGRP || ! HAVE_TIOCNOTTY - pid_t igrp; - /* First make sure we are not a process group leader. If we have - TIOCNOTTY, this doesn't matter, since TIOCNOTTY sets our process - group to 0 anyhow. */ - + /* Make sure we are not a process group leader. */ #if HAVE_BSD_PGRP igrp = getpgrp (0); #else @@ -100,22 +100,25 @@ usysdep_detach () while (getppid () != 1) sleep (1); - ulog_id (getpid ()); + ipid = getpid (); + ulog_id (ipid); /* Restore SIGHUP catcher if it wasn't being ignored. */ if (! fignored) usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL); - } -#endif /* ! HAVE_BSD_PGRP || ! HAVE_TIOCNOTTY */ + DEBUG_MESSAGE2 (DEBUG_PORT, "Forked; old PID %ld, new pid %ld", + (long) igrp, (long) ipid); + } -#if HAVE_TIOCNOTTY - /* Lose the original controlling terminal. If standard input has - been reopened to /dev/null, this will do no harm. If another - port has been opened to become the controlling terminal, it - should have been detached when it was closed. */ +#if ! HAVE_SETSID && HAVE_TIOCNOTTY + /* Lose the original controlling terminal as well as our process + group. If standard input has been reopened to /dev/null, this + will do no harm. If another port has been opened to become the + controlling terminal, it should have been detached when it was + closed. */ (void) ioctl (0, TIOCNOTTY, (char *) NULL); -#endif +#endif /* ! HAVE_SETSID && HAVE_TIOCNOTTY */ /* Close stdin, stdout and stderr and reopen them on /dev/null, to make sure we have no connection at all to the terminal. */ @@ -127,58 +130,38 @@ usysdep_detach () || open ((char *) "/dev/null", O_WRONLY) != 2) ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno)); -#if HAVE_BSD_PGRP - - /* Make sure our process group ID is set to 0. On BSD TIOCNOTTY - should already have set it 0, so this will do no harm. On System - V we presumably did not execute the TIOCNOTTY call, but the - System V setpgrp will detach the controlling terminal anyhow. - This lets us use the same code on both BSD and System V, provided - it compiles correctly, which life easier for the configure - script. We don't output an error if we got EPERM because some - BSD variants don't permit this usage of setpgrp (which means they - don't provide any way to pick up a new controlling terminal). */ - - if (setpgrp (0, 0) < 0) - { - if (errno != EPERM) - ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); - } - -#else /* ! HAVE_BSD_PGRP */ - #if HAVE_SETSID /* Under POSIX the setsid call creates a new session for which we are the process group leader. It also detaches us from our - controlling terminal. I'm using the BSD setpgrp call first - because they should be equivalent for my purposes, but it turns - out that on Ultrix 4.0 setsid prevents us from ever acquiring - another controlling terminal (it does not change our process - group, and Ultrix 4.0 prevents us from setting our process group - to 0). */ - (void) setsid (); + controlling terminal. */ + if (setsid () < 0) + ulog (LOG_ERROR, "setsid: %s", strerror (errno)); #else /* ! HAVE_SETSID */ -#if HAVE_SETPGRP - - /* Now we assume we have the System V setpgrp, which takes no - arguments, and we couldn't compile the HAVE_BSD_PGRP code above - because there was a prototype somewhere in scope. On System V - setpgrp makes us the leader of a new process group and also - detaches the controlling terminal. */ +#if ! HAVE_SETPGRP + #error Cannot detach from controlling terminal +#endif + /* If we don't have setsid, we must use setpgrp. On an old System V + system setpgrp will make us the leader of a new process group and + detach the controlling terminal. On an old BSD system the call + setpgrp (0, 0) will set our process group to 0 so that we can + acquire a new controlling terminal (TIOCNOTTY may or may not have + already done that anyhow). */ +#if HAVE_BSD_PGRP + if (setpgrp (0, 0) < 0) +#else if (setpgrp () < 0) - ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); - -#else /* ! HAVE_SETPGRP */ - - #error Must detach from controlling terminal +#endif + { + /* Some systems seem to give EPERM errors inappropriately. */ + if (errno != EPERM) + ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); + } -#endif /* HAVE_SETPGRP */ #endif /* ! HAVE_SETSID */ -#endif /* ! HAVE_BSD_PGRP */ /* At this point we have completely detached from our controlling terminal. The next terminal device we open will probably become diff --git a/gnu/libexec/uucp/libunix/dirent.c b/gnu/libexec/uucp/libunix/dirent.c index 83db496cabb..c7e467ec1b1 100644 --- a/gnu/libexec/uucp/libunix/dirent.c +++ b/gnu/libexec/uucp/libunix/dirent.c @@ -21,7 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/dup2.c b/gnu/libexec/uucp/libunix/dup2.c index 6a7359fe92e..d1454205125 100644 --- a/gnu/libexec/uucp/libunix/dup2.c +++ b/gnu/libexec/uucp/libunix/dup2.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/epopen.c b/gnu/libexec/uucp/libunix/epopen.c index dec1b3999d6..8c1f5cd0d85 100644 --- a/gnu/libexec/uucp/libunix/epopen.c +++ b/gnu/libexec/uucp/libunix/epopen.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -56,7 +56,7 @@ espopen (pazargs, frd, pipid) } aidescs[2] = SPAWN_NULL; - ipid = ixsspawn (pazargs, aidescs, FALSE, FALSE, + ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, (const char *) NULL, FALSE, TRUE, (const char *) NULL, (const char *) NULL, (const char *) NULL); diff --git a/gnu/libexec/uucp/libunix/filnam.c b/gnu/libexec/uucp/libunix/filnam.c index 62054767b89..0b234c06dcc 100644 --- a/gnu/libexec/uucp/libunix/filnam.c +++ b/gnu/libexec/uucp/libunix/filnam.c @@ -1,7 +1,7 @@ /* filnam.c Get names to use for UUCP files. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -62,7 +62,7 @@ extern off_t lseek (); #endif #define ZCHARS \ - "0123456789ABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* Local functions. */ diff --git a/gnu/libexec/uucp/libunix/fsusg.c b/gnu/libexec/uucp/libunix/fsusg.c index 370c16a2ef5..697ab1e0134 100644 --- a/gnu/libexec/uucp/libunix/fsusg.c +++ b/gnu/libexec/uucp/libunix/fsusg.c @@ -1,5 +1,5 @@ /* fsusage.c -- return space usage of mounted filesystems - Copyright (C) 1991, 1992 Free Software Foundation, Inc. + Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,11 +19,10 @@ for use with Taylor UUCP. */ #include "uucp.h" +#include "uudefs.h" #include "sysdep.h" #include "fsusg.h" -int statfs (); - #if STAT_STATFS2_BSIZE #ifndef _IBMR2 /* 4.3BSD, SunOS 4, HP-UX, AIX PS/2. */ #include <sys/vfs.h> @@ -53,16 +52,19 @@ int statfs (); #endif #endif -#ifdef _AIX -#ifdef _I386 /* AIX PS/2. */ +#if STAT_DUSTAT /* AIX PS/2. */ #include <sys/stat.h> #include <sys/dustat.h> #endif -#endif #if STAT_STATVFS /* SVR4. */ #include <sys/statvfs.h> -int statvfs (); +#endif + +#if STAT_DISK_SPACE /* QNX. */ +#include <sys/disk.h> +#include <fcntl.h> +#include <errno.h> #endif #define STAT_NONE 0 @@ -72,7 +74,9 @@ int statvfs (); #if ! STAT_STATFS2_FSIZE #if ! STAT_STATFS2_FS_DATA #if ! STAT_STATFS4 +#if ! STAT_DUSTAT #if ! STAT_USTAT +#if ! STAT_DISK_SPACE #undef STAT_NONE #define STAT_NONE 1 #endif @@ -81,9 +85,13 @@ int statvfs (); #endif #endif #endif +#endif +#endif #if ! STAT_NONE +static long adjust_blocks P((long blocks, int fromsize, int tosize)); + /* Return the number of TOSIZE-byte blocks used by BLOCKS FROMSIZE-byte blocks, rounding up. */ @@ -122,7 +130,7 @@ get_fs_usage (path, disk, fsp) if (statfs (path, &fsd) != 1) return -1; -#define convert_blocks(b) adjust_blocks ((b), 1024, 512) +#define convert_blocks(b) adjust_blocks ((long) (b), 1024, 512) fsp->fsu_blocks = convert_blocks (fsd.fd_req.btot); fsp->fsu_bfree = convert_blocks (fsd.fd_req.bfree); fsp->fsu_bavail = convert_blocks (fsd.fd_req.bfreen); @@ -130,7 +138,7 @@ get_fs_usage (path, disk, fsp) fsp->fsu_ffree = fsd.fd_req.gfree; #endif -#if STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */ +#if STAT_STATFS2_BSIZE || STAT_DUSTAT /* 4.3BSD, SunOS 4, HP-UX, AIX. */ struct statfs fsd; if (statfs (path, &fsd) < 0) @@ -170,23 +178,94 @@ get_fs_usage (path, disk, fsp) adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) #endif +#if STAT_DISK_SPACE /* QNX. */ + int o; + int iret; + long cfree_blocks, ctotal_blocks; + char *zpath; + char *zslash; + + zpath = zbufcpy (path); + while ((o = open (zpath, O_RDONLY, 0)) == -1 + && errno == ENOENT) + { + /* The named file doesn't exist, so we can't open it. Try the + directory containing it. */ + if ((strcmp ("/", zpath) == 0) + || (strcmp (zpath, ".") == 0) + || (strcmp (zpath, "") == 0) + /* QNX peculiarity: "//2" means root on node 2 */ + || ((strncmp (zpath, "//", 2) == 0) + && (strchr (zpath + 2, '/') == NULL))) + { + /* We can't shorten this! */ + break; + } + + /* Shorten the pathname by one component and try again. */ + zslash = strrchr (zpath, '/'); + if (zslash == NULL) + { + /* Try the current directory. We can open directories. */ + zpath[0] = '.'; + zpath[1] = '\0'; + } + else if (zslash == zpath) + { + /* Try the root directory. */ + zpath[0] = '/'; + zpath[1] = '\0'; + } + else + { + /* Chop off last path component. */ + zslash[0] = '\0'; + } + } + if (o == -1) + { + ulog (LOG_ERROR, "get_fs_usage: open (%s) failed: %s", zpath, + strerror (errno)); + ubuffree (zpath); + return -1; + } + ubuffree (zpath); + + iret = disk_space (o, &cfree_blocks, &ctotal_blocks); + (void) close (o); + if (iret == -1) + { + ulog (LOG_ERROR, "get_fs_usage: disk_space failed: %s", + strerror (errno)); + return -1; + } + + fsp->fsu_blocks = ctotal_blocks; + fsp->fsu_bfree = cfree_blocks; + fsp->fsu_bavail = cfree_blocks; + + /* QNX has no limit on the number of inodes. Most inodes are stored + directly in the directory entry. */ + fsp->fsu_files = -1; + fsp->fsu_ffree = -1; +#endif /* STAT_DISK_SPACE */ + #if STAT_USTAT - { - struct stat sstat; - struct ustat s; + struct stat sstat; + struct ustat s; - if (stat (path, &sstat) < 0 - || ustat (sstat.st_dev, &s) < 0) - return -1; - fsp->fsu_blocks = -1; - fsp->fsu_bfree = f_tfree; - fsp->fsu_bavail = f_tfree; - fsp->fsu_files = -1; - fsp->fsu_ffree = -1; - } + if (stat (path, &sstat) < 0 + || ustat (sstat.st_dev, &s) < 0) + return -1; + fsp->fsu_blocks = -1; + fsp->fsu_bfree = s.f_tfree; + fsp->fsu_bavail = s.f_tfree; + fsp->fsu_files = -1; + fsp->fsu_ffree = -1; #endif #if ! STAT_STATFS2_FS_DATA /* ! Ultrix */ +#if ! STAT_DISK_SPACE #if ! STAT_USTAT #if ! STAT_NONE fsp->fsu_blocks = convert_blocks (fsd.f_blocks); @@ -197,12 +276,12 @@ get_fs_usage (path, disk, fsp) #endif #endif #endif +#endif return 0; } -#ifdef _AIX -#ifdef _I386 +#if STAT_DUSTAT /* AIX PS/2 does not supply statfs. */ int @@ -228,5 +307,4 @@ statfs (path, fsb) fsb->f_fsid.val[1] = fsd.du_pckno; return 0; } -#endif -#endif /* _AIX && _I386 */ +#endif /* STAT_DUSTAT */ diff --git a/gnu/libexec/uucp/libunix/ftw.c b/gnu/libexec/uucp/libunix/ftw.c index c3372b53ca4..c7af06e04f0 100644 --- a/gnu/libexec/uucp/libunix/ftw.c +++ b/gnu/libexec/uucp/libunix/ftw.c @@ -17,7 +17,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -Modified by Ian Lanc Taylor for Taylor UUCP, June 1992. */ +Modified by Ian Lance Taylor for Taylor UUCP, June 1992, and October 1993. */ #include "uucp.h" @@ -63,7 +63,7 @@ ftw_dir (dirs, level, descriptors, dir, len, func) int descriptors; char *dir; size_t len; - int (*func) P((const char *file, const struct stat *status, int flag)); + int (*func) P((const char *file, struct stat *status, int flag)); { int got; struct dirent *entry; @@ -177,7 +177,7 @@ ftw_dir (dirs, level, descriptors, dir, len, func) int ftw (dir, func, descriptors) const char *dir; - int (*func) P((const char *file, const struct stat *status, int flag)); + int (*func) P((const char *file, struct stat *status, int flag)); int descriptors; { DIR **dirs; @@ -234,7 +234,11 @@ ftw (dir, func, descriptors) if (flag == FTW_D) { if (ret == 0) - ret = ftw_dir (dirs, 0, descriptors, buf, len, func); + { + if (len == 1 && *buf == '/') + len = 0; + ret = ftw_dir (dirs, 0, descriptors, buf, len, func); + } if (dirs[0] != NULL) { int save; diff --git a/gnu/libexec/uucp/libunix/indir.c b/gnu/libexec/uucp/libunix/indir.c index 2484ec23f85..de1df702cc5 100644 --- a/gnu/libexec/uucp/libunix/indir.c +++ b/gnu/libexec/uucp/libunix/indir.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/init.c b/gnu/libexec/uucp/libunix/init.c index d4a13776281..95822db1168 100644 --- a/gnu/libexec/uucp/libunix/init.c +++ b/gnu/libexec/uucp/libunix/init.c @@ -1,7 +1,7 @@ /* init.c Initialize the system dependent routines. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -153,35 +153,39 @@ usysdep_initialize (puuconf,iflags) pointer puuconf; int iflags; { - int cdescs; - int o; int iuuconf; char *z; struct passwd *q; ulog_id (getpid ()); - /* Close everything but stdin, stdout and stderr. */ + if ((iflags & INIT_NOCLOSE) == 0) + { + int cdescs; + int o; + + /* Close everything but stdin, stdout and stderr. */ #if HAVE_GETDTABLESIZE - cdescs = getdtablesize (); + cdescs = getdtablesize (); #else #if HAVE_SYSCONF - cdescs = sysconf (_SC_OPEN_MAX); + cdescs = sysconf (_SC_OPEN_MAX); #else #ifdef OPEN_MAX - cdescs = OPEN_MAX; + cdescs = OPEN_MAX; #else #ifdef NOFILE - cdescs = NOFILE; + cdescs = NOFILE; #else - cdescs = 20; + cdescs = 20; #endif /* ! defined (NOFILE) */ #endif /* ! defined (OPEN_MAX) */ #endif /* ! HAVE_SYSCONF */ #endif /* ! HAVE_GETDTABLESIZE */ - for (o = 3; o < cdescs; o++) - (void) close (o); + for (o = 3; o < cdescs; o++) + (void) close (o); + } /* Make sure stdin, stdout and stderr are open. */ if (fcntl (0, F_GETFD, 0) < 0 diff --git a/gnu/libexec/uucp/libunix/iswait.c b/gnu/libexec/uucp/libunix/iswait.c index d2610aa1f8b..aa855151c92 100644 --- a/gnu/libexec/uucp/libunix/iswait.c +++ b/gnu/libexec/uucp/libunix/iswait.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/jobid.c b/gnu/libexec/uucp/libunix/jobid.c index 7f22f1d37d7..c8b21cbcf21 100644 --- a/gnu/libexec/uucp/libunix/jobid.c +++ b/gnu/libexec/uucp/libunix/jobid.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/lcksys.c b/gnu/libexec/uucp/libunix/lcksys.c index 4ece16afe7b..c1b0efaa3b9 100644 --- a/gnu/libexec/uucp/libunix/lcksys.c +++ b/gnu/libexec/uucp/libunix/lcksys.c @@ -8,20 +8,32 @@ #include "sysdep.h" #include "system.h" +/* Get the name of a system lock file. */ + +static char *zssys_lock_name P((const struct uuconf_system *qsys, char *z)); + +#define LOCKNAMELEN (sizeof "LCK..12345678") + +static char * +zssys_lock_name (qsys, z) + const struct uuconf_system *qsys; + char *z; +{ + strcpy (z, "LCK.."); + strncpy (z + sizeof "LCK.." - 1, qsys->uuconf_zname, 8); + z[sizeof "LCK.." - 1 + 8] = '\0'; + return z; +} + /* Lock a remote system. */ boolean fsysdep_lock_system (qsys) const struct uuconf_system *qsys; { - char *z; - boolean fret; - - z = zbufalc (strlen (qsys->uuconf_zname) + sizeof "LCK.."); - sprintf (z, "LCK..%.8s", qsys->uuconf_zname); - fret = fsdo_lock (z, FALSE, (boolean *) NULL); - ubuffree (z); - return fret; + char ab[LOCKNAMELEN]; + + return fsdo_lock (zssys_lock_name (qsys, ab), FALSE, (boolean *) NULL); } /* Unlock a remote system. */ @@ -30,12 +42,7 @@ boolean fsysdep_unlock_system (qsys) const struct uuconf_system *qsys; { - char *z; - boolean fret; - - z = zbufalc (strlen (qsys->uuconf_zname) + sizeof "LCK.."); - sprintf (z, "LCK..%.8s", qsys->uuconf_zname); - fret = fsdo_unlock (z, FALSE); - ubuffree (z); - return fret; + char ab[LOCKNAMELEN]; + + return fsdo_unlock (zssys_lock_name (qsys, ab), FALSE); } diff --git a/gnu/libexec/uucp/libunix/locfil.c b/gnu/libexec/uucp/libunix/locfil.c index 0e05af9bcee..1c4db66520a 100644 --- a/gnu/libexec/uucp/libunix/locfil.c +++ b/gnu/libexec/uucp/libunix/locfil.c @@ -1,7 +1,7 @@ /* locfil.c Expand a file name on the local system. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -41,12 +41,16 @@ extern struct passwd *getpwnam (); and moving any other type of file into the public directory. */ char * -zsysdep_local_file (zfile, zpubdir) +zsysdep_local_file (zfile, zpubdir, pfbadname) const char *zfile; const char *zpubdir; + boolean *pfbadname; { const char *zdir; + if (pfbadname != NULL) + *pfbadname = FALSE; + if (*zfile == '/') return zbufcpy (zfile); @@ -79,6 +83,8 @@ zsysdep_local_file (zfile, zpubdir) { ulog (LOG_ERROR, "User %s not found", zcopy); ubuffree (zcopy); + if (pfbadname != NULL) + *pfbadname = TRUE; return NULL; } ubuffree (zcopy); diff --git a/gnu/libexec/uucp/libunix/lock.c b/gnu/libexec/uucp/libunix/lock.c index c43e31dfd00..d476bed7170 100644 --- a/gnu/libexec/uucp/libunix/lock.c +++ b/gnu/libexec/uucp/libunix/lock.c @@ -1,7 +1,7 @@ /* lock.c Lock and unlock a file name. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/04 19:32:33 jtc Exp $"; +const char lock_rcsid[] = "$Id: lock.c,v 1.2 1994/10/24 22:18:59 jtc Exp $"; #endif #include "uudefs.h" @@ -43,6 +43,19 @@ const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/04 19:32:33 jtc Exp $"; #endif #endif +#if TM_IN_SYS_TIME +#include <sys/time.h> +#else +#include <time.h> +#endif + +#if HAVE_QNX_LOCKFILES +#include <sys/kernel.h> +#include <sys/psinfo.h> +#include <sys/seginfo.h> +#include <sys/vc.h> +#endif + #ifndef O_RDONLY #define O_RDONLY 0 #define O_WRONLY 1 @@ -56,6 +69,15 @@ const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/04 19:32:33 jtc Exp $"; #ifndef SEEK_SET #define SEEK_SET 0 #endif + +#ifndef localtime +extern struct tm *localtime (); +#endif + +#if HAVE_QNX_LOCKFILES +static boolean fsqnx_stale P((unsigned long ipid, unsigned long inme, + unsigned long inid, boolean *pferr)); +#endif /* Lock something. If the fspooldir argument is TRUE, the argument is a file name relative to the spool directory; otherwise the argument @@ -73,13 +95,19 @@ fsdo_lock (zlock, fspooldir, pferr) size_t cslash; pid_t ime; char *ztempfile; - char abtempfile[sizeof "TMP1234567890"]; + char abtempfile[sizeof "TMP12345678901234567890"]; int o; +#if HAVE_QNX_LOCKFILES + nid_t inme; + char ab[23]; + char *zend; +#else #if HAVE_V2_LOCKFILES int i; #else char ab[12]; #endif +#endif int cwrote; const char *zerr; boolean fret; @@ -99,6 +127,9 @@ fsdo_lock (zlock, fspooldir, pferr) } ime = getpid (); +#if HAVE_QNX_LOCKFILES + inme = getnid (); +#endif /* We do the actual lock by creating a file and then linking it to the final file name we want. This avoids race conditions due to @@ -114,7 +145,12 @@ fsdo_lock (zlock, fspooldir, pferr) else cslash = zslash - zpath + 1; +#if HAVE_QNX_LOCKFILES + sprintf (abtempfile, "TMP%010lx%010lx", (unsigned long) ime, + (unsigned long) inme); +#else sprintf (abtempfile, "TMP%010lx", (unsigned long) ime); +#endif ztempfile = zbufalc (cslash + sizeof abtempfile); memcpy (ztempfile, zpath, cslash); memcpy (ztempfile + cslash, abtempfile, sizeof abtempfile); @@ -141,13 +177,18 @@ fsdo_lock (zlock, fspooldir, pferr) } } +#if HAVE_QNX_LOCKFILES + sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inid); + cwrote = write (o, ab, strlen (ab)); +#else #if HAVE_V2_LOCKFILES - i = ime; + i = (int) ime; cwrote = write (o, &i, sizeof i); #else - sprintf (ab, "%10d\n", (int) ime); + sprintf (ab, "%10ld\n", (long) ime); cwrote = write (o, ab, strlen (ab)); #endif +#endif zerr = NULL; if (cwrote < 0) @@ -177,8 +218,13 @@ fsdo_lock (zlock, fspooldir, pferr) while (link (ztempfile, zpath) != 0) { int cgot; - int ipid; + pid_t ipid; boolean freadonly; + struct stat st; + char abtime[sizeof "1991-12-31 12:00:00"]; +#if HAVE_QNX_LOCKFILES + nid_t inid; +#endif fret = FALSE; @@ -228,11 +274,17 @@ fsdo_lock (zlock, fspooldir, pferr) break; } +#if HAVE_QNX_LOCKFILES + ab[cgot] = '\0'; + ipid = (pid_t) strtol (ab, &zend, 10); + inid = (nid_t) strtol (zend, (char **) NULL, 10); +#else #if HAVE_V2_LOCKFILES - ipid = i; + ipid = (pid_t) i; #else ab[cgot] = '\0'; - ipid = strtol (ab, (char **) NULL, 10); + ipid = (pid_t) strtol (ab, (char **) NULL, 10); +#endif #endif /* On NFS, the link might have actually succeeded even though we @@ -247,18 +299,49 @@ fsdo_lock (zlock, fspooldir, pferr) going to worry about this possibility. */ if (ipid == ime) { - fret = TRUE; - break; +#if HAVE_QNX_LOCKFILES + if (inid == inme) +#endif + { + fret = TRUE; + break; + } } +#if HAVE_QNX_LOCKFILES + if (! fsqnx_stale ((unsigned long) ipid, (unsigned long) inme, + (unsigned long) inid, pferr)) + break; +#else /* If the process still exists, we will get EPERM rather than ESRCH. We then return FALSE to indicate that we cannot make the lock. */ if (kill (ipid, 0) == 0 || errno == EPERM) break; +#endif - ulog (LOG_ERROR, "Found stale lock %s held by process %d", - zpath, ipid); + if (fstat (o, &st) < 0) + strcpy (abtime, "unknown"); + else + { + time_t itm; + struct tm *q; + + itm = (time_t) st.st_mtime; + q = localtime (&itm); + sprintf (abtime, "%04d-%02d-%02d %02d:%02d:%02d", + q->tm_year + 1900, q->tm_mon + 1, q->tm_mday, q->tm_hour, + q->tm_min, q->tm_sec); + } + +#if HAVE_QNX_LOCKFILES + ulog (LOG_ERROR, + "Stale lock %s held by process %ld on node %ld created %s", + zpath, (long) ipid, (long) inid, abtime); +#else + ulog (LOG_ERROR, "Stale lock %s held by process %ld created %s", + zpath, (long) ipid, abtime); +#endif /* This is a stale lock, created by a process that no longer exists. @@ -317,6 +400,7 @@ fsdo_lock (zlock, fspooldir, pferr) (void) close (o); o = -1; (void) remove (zpath); + fret = TRUE; continue; } @@ -326,13 +410,18 @@ fsdo_lock (zlock, fspooldir, pferr) break; } +#if HAVE_QNX_LOCKFILES + sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inid); + cwrote = write (o, ab, strlen (ab)); +#else #if HAVE_V2_LOCKFILES - i = ime; + i = (int) ime; cwrote = write (o, &i, sizeof i); #else - sprintf (ab, "%10d\n", (int) ime); + sprintf (ab, "%10ld\n", (long) ime); cwrote = write (o, ab, strlen (ab)); #endif +#endif if (cwrote < 0) { @@ -360,52 +449,63 @@ fsdo_lock (zlock, fspooldir, pferr) break; } +#if HAVE_QNX_LOCKFILES + ab[cgot] = '\0'; + ipid = (pid_t) strtol (ab, &zend, 10); + inid = (nid_t) strtol (zend, (char **) NULL, 10); +#else #if HAVE_V2_LOCKFILES - ipid = i; + ipid = (pid_t) i; #else ab[cgot] = '\0'; - ipid = strtol (ab, (char **) NULL, 10); + ipid = (pid_t) strtol (ab, (char **) NULL, 10); +#endif #endif if (ipid == ime) { - struct stat sfile, sdescriptor; - - /* It looks like we have the lock. Do the final stat - check. */ - if (stat ((char *) zpath, &sfile) < 0) - { - if (errno != ENOENT) - { - zerr = "stat"; - break; - } - /* Loop around and try again. */ - } - else +#if HAVE_QNX_LOCKFILES + if (inid == inme) +#endif { - if (fstat (o, &sdescriptor) < 0) + struct stat sfile, sdescriptor; + + /* It looks like we have the lock. Do the final stat + check. */ + if (stat ((char *) zpath, &sfile) < 0) { - zerr = "fstat"; - break; + if (errno != ENOENT) + { + zerr = "stat"; + break; + } + /* Loop around and try again. */ } - - if (sfile.st_ino == sdescriptor.st_ino - && sfile.st_dev == sdescriptor.st_dev) + else { - /* Close the file before assuming we've succeeded to - pick up any trailing errors. */ - if (close (o) < 0) + if (fstat (o, &sdescriptor) < 0) { - zerr = "close"; + zerr = "fstat"; break; } - o = -1; - - /* We have the lock. */ - fret = TRUE; - break; + if (sfile.st_ino == sdescriptor.st_ino + && sfile.st_dev == sdescriptor.st_dev) + { + /* Close the file before assuming we've + succeeded to pick up any trailing errors. */ + if (close (o) < 0) + { + zerr = "close"; + break; + } + + o = -1; + + /* We have the lock. */ + fret = TRUE; + break; + } } } } @@ -475,3 +575,90 @@ fsdo_unlock (zlock, fspooldir) return FALSE; } } + +#if HAVE_QNX_LOCKFILES + +/* Return TRUE if the lock is stale. */ + +static boolean +fsqnx_stale (ipid, inme, inid, pferr) + unsigned long ipid; + unsigned long inme; + unsigned long inid; + boolean *pferr; +{ + /* A virtual process ID. This virtual process ID, which will exist + on the local node, will represent the process ID of the process + manager process (Proc) on the remote node. */ + pid_t ivid; + /* The return value of the qnx_psinfo function. This is either a + process ID which might or might not be the same as the process + being looked for, or -1 to indicate no process found. */ + pid_t ifound_pid; + /* This holds the actual result of qnx_psinfo. We will ignore + almost all the fields since we're just checking for existence. */ + struct _psinfo spsdata; + + /* Establish connection with a remote process manager if necessary. */ + if (inid != inme) + { + ivid = qnx_vc_attach (inid /* remote node ID */, + PROC_PID /* pid of process manager */, + 1000 /* initial buffer size */, + 0 /* flags */); + if (ivid < 0) + { + ulog (LOG_ERROR, "qnx_vc_attach (%lu, PROC_PID): %s", + inid, strerror (errno)); + if (pferr != NULL) + *pferr = TRUE; + return FALSE; + } + } + else + { + /* Use the local pid of the local process manager. */ + ivid = PROC_PID; + } + + /* Request the process information. */ + ifound_pid = qnx_psinfo (ivid /* process manager handling request */, + ipid /* get info on this process */, + &spsdata /* put info in this struct */, + 0 /* unused */, + (struct _seginfo *) NULL /* unused */); + + /* Deallocate the virtual connection before continuing. */ + { + int isaved_errno = errno; + if (qnx_vc_detach (ivid) < 0) + ulog (LOG_ERROR, "qnx_vd_detach (%ld): %s", (long) ivid, + strerror (errno)); + errno = isaved_errno; + } + + /* If the returned pid matches then the process still holds the lock. */ + if ((ifound_pid == ipid) && (spsdata.pid == ipid)) + return FALSE; + + /* If the returned pid is positive and doesn't match, then the + process doesn't exist and the lock is stale. Continue. */ + + /* If the returned pid is negative (-1) and errno is EINVAL (or ESRCH + in older versions of QNX), then the process doesn't exist and the + lock is stale. Continue. */ + + /* Check for impossible errors. */ + if ((ifound_pid < 0) && (errno != ESRCH) && (errno != EINVAL)) + { + ulog (LOG_ERROR, "qnx_psinfo (%ld, %ld): %s", (long) ivid, + (long) ipid, strerror (errno)); + /* Since we don't know what the hell this means, and we don't + want our system to freeze, we treat this case as a stale + lock. Continue on. */ + } + + return TRUE; +} + +#endif /* HAVE_QNX_LOCKFILES */ diff --git a/gnu/libexec/uucp/libunix/loctim.c b/gnu/libexec/uucp/libunix/loctim.c index da5f32e2d27..7f1f87aa671 100644 --- a/gnu/libexec/uucp/libunix/loctim.c +++ b/gnu/libexec/uucp/libunix/loctim.c @@ -3,7 +3,9 @@ #include "uucp.h" -#if HAVE_TIME_H +#if TM_IN_SYS_TIME +#include <sys/time.h> +#else #include <time.h> #endif diff --git a/gnu/libexec/uucp/libunix/mail.c b/gnu/libexec/uucp/libunix/mail.c index 74c1aa95adc..e1fbaa92afe 100644 --- a/gnu/libexec/uucp/libunix/mail.c +++ b/gnu/libexec/uucp/libunix/mail.c @@ -1,7 +1,7 @@ /* mail.c Send mail to a user. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -48,17 +48,47 @@ fsysdep_mail (zto, zsubject, cstrs, paz) int cstrs; const char **paz; { - const char *az[3]; + char **pazargs; + char *zcopy, *ztok; + size_t cargs, iarg; FILE *e; pid_t ipid; time_t itime; int i; - az[0] = MAIL_PROGRAM; - az[1] = zto; - az[2] = NULL; + /* Parse MAIL_PROGRAM into an array of arguments. */ + zcopy = zbufcpy (MAIL_PROGRAM); + + cargs = 0; + for (ztok = strtok (zcopy, " \t"); + ztok != NULL; + ztok = strtok ((char *) NULL, " \t")) + ++cargs; + + pazargs = (char **) xmalloc ((cargs + 4) * sizeof (char *)); + + memcpy (zcopy, MAIL_PROGRAM, sizeof MAIL_PROGRAM); + for (ztok = strtok (zcopy, " \t"), iarg = 0; + ztok != NULL; + ztok = strtok ((char *) NULL, " \t"), ++iarg) + pazargs[iarg] = ztok; + +#if ! MAIL_PROGRAM_SUBJECT_BODY + pazargs[iarg++] = (char *) "-s"; + pazargs[iarg++] = (char *) zsubject; +#endif + +#if ! MAIL_PROGRAM_TO_BODY + pazargs[iarg++] = (char *) zto; +#endif + + pazargs[iarg] = NULL; + + e = espopen ((const char **) pazargs, FALSE, &ipid); + + ubuffree (zcopy); + xfree ((pointer) pazargs); - e = espopen (az, FALSE, &ipid); if (e == NULL) { ulog (LOG_ERROR, "espopen (%s): %s", MAIL_PROGRAM, @@ -66,10 +96,16 @@ fsysdep_mail (zto, zsubject, cstrs, paz) return FALSE; } - fprintf (e, "Subject: %s\n", zsubject); +#if MAIL_PROGRAM_TO_BODY fprintf (e, "To: %s\n", zto); +#endif +#if MAIL_PROGRAM_SUBJECT_BODY + fprintf (e, "Subject: %s\n", zsubject); +#endif +#if MAIL_PROGRAM_TO_BODY || MAIL_PROGRAM_SUBJECT_BODY fprintf (e, "\n"); +#endif (void) time (&itime); /* Remember that ctime includes a \n, so this skips a line. */ diff --git a/gnu/libexec/uucp/libunix/mkdir.c b/gnu/libexec/uucp/libunix/mkdir.c index f59ad5dfd6e..2546cbff1e4 100644 --- a/gnu/libexec/uucp/libunix/mkdir.c +++ b/gnu/libexec/uucp/libunix/mkdir.c @@ -38,7 +38,7 @@ mkdir (zdir, imode) aidescs[1] = SPAWN_NULL; aidescs[2] = SPAWN_NULL; - ipid = ixsspawn (azargs, aidescs, FALSE, FALSE, (const char *) NULL, + ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL, TRUE, FALSE, (const char *) NULL, (const char *) NULL, (const char *) NULL); diff --git a/gnu/libexec/uucp/libunix/mkdirs.c b/gnu/libexec/uucp/libunix/mkdirs.c index a4e0b67bb8c..129488c8d95 100644 --- a/gnu/libexec/uucp/libunix/mkdirs.c +++ b/gnu/libexec/uucp/libunix/mkdirs.c @@ -29,15 +29,14 @@ fsysdep_make_dirs (zfile, fpublic) if (*z == '/' && z != zcopy) { *z = '\0'; - if (! fsysdep_directory (zcopy)) + if (mkdir (zcopy, imode) != 0 + && errno != EEXIST + && (errno != EACCES || ! fsysdep_directory (zcopy))) { - if (mkdir (zcopy, imode) != 0) - { - ulog (LOG_ERROR, "mkdir (%s): %s", zcopy, - strerror (errno)); - ubuffree (zcopy); - return FALSE; - } + ulog (LOG_ERROR, "mkdir (%s): %s", zcopy, + strerror (errno)); + ubuffree (zcopy); + return FALSE; } *z = '/'; } diff --git a/gnu/libexec/uucp/libunix/move.c b/gnu/libexec/uucp/libunix/move.c index ccfe6d4d728..3345bbfa04d 100644 --- a/gnu/libexec/uucp/libunix/move.c +++ b/gnu/libexec/uucp/libunix/move.c @@ -1,7 +1,7 @@ /* move.c Move a file. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -77,14 +77,12 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) if (stat (zcopy, &s) != 0) { ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno)); - (void) remove (zorig); ubuffree (zcopy); return FALSE; } if (! fsuser_access (&s, W_OK, zuser)) { ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - (void) remove (zorig); ubuffree (zcopy); return FALSE; } @@ -107,10 +105,7 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) if (fmkdirs && errno == ENOENT) { if (! fsysdep_make_dirs (zto, fpublic)) - { - (void) remove (zorig); - return FALSE; - } + return FALSE; if (rename (zorig, zto) == 0) return TRUE; } @@ -127,7 +122,6 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) { ulog (LOG_ERROR, "rename (%s, %s): %s", zorig, zto, strerror (errno)); - (void) remove (zorig); return FALSE; } @@ -135,7 +129,6 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) if (stat ((char *) zorig, &s) < 0) { ulog (LOG_ERROR, "stat (%s): %s", zorig, strerror (errno)); - (void) remove (zorig); return FALSE; } @@ -148,26 +141,19 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) if (fmkdirs && errno == ENOENT) { if (! fsysdep_make_dirs (zto, fpublic)) - { - (void) remove (zorig); - return FALSE; - } + return FALSE; o = creat ((char *) zto, s.st_mode); } if (o < 0) { ulog (LOG_ERROR, "creat (%s): %s", zto, strerror (errno)); - (void) remove (zorig); return FALSE; } } (void) close (o); if (! fcopy_file (zorig, zto, fpublic, fmkdirs)) - { - (void) remove (zorig); - return FALSE; - } + return FALSE; if (remove (zorig) != 0) ulog (LOG_ERROR, "remove (%s): %s", zorig, strerror (errno)); diff --git a/gnu/libexec/uucp/libunix/opensr.c b/gnu/libexec/uucp/libunix/opensr.c index 3a8ca7a8b8a..15cd5cd1360 100644 --- a/gnu/libexec/uucp/libunix/opensr.c +++ b/gnu/libexec/uucp/libunix/opensr.c @@ -1,7 +1,7 @@ /* opensr.c Open files for sending and receiving. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -131,16 +131,18 @@ esysdep_open_send (qsys, zfile, fcheck, zuser) } /* Get a temporary file name to receive into. We use the ztemp - argument to pick the file name, so that we relocate the file if the + argument to pick the file name, so that we restart the file if the transmission is aborted. */ char * -zsysdep_receive_temp (qsys, zto, ztemp) +zsysdep_receive_temp (qsys, zto, ztemp, frestart) const struct uuconf_system *qsys; const char *zto; const char *ztemp; + boolean frestart; { - if (ztemp != NULL + if (frestart + && ztemp != NULL && *ztemp == 'D' && strcmp (ztemp, "D.0") != 0) return zsappend3 (".Temp", qsys->uuconf_zname, ztemp); @@ -148,6 +150,10 @@ zsysdep_receive_temp (qsys, zto, ztemp) return zstemp_file (qsys); } +/* The number of seconds in one week. We must cast to long for this + to be calculated correctly on a machine with 16 bit ints. */ +#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60) + /* Open a temporary file to receive into. This should, perhaps, check that we have write permission on the receiving directory, but it doesn't. */ @@ -168,8 +174,10 @@ esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart) that case, we may have already received some portion of this file. */ o = -1; - *pcrestart = -1; - if (ztemp != NULL + if (pcrestart != NULL) + *pcrestart = -1; + if (pcrestart != NULL + && ztemp != NULL && *ztemp == 'D' && strcmp (ztemp, "D.0") != 0) { @@ -185,7 +193,7 @@ esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart) restarted, and they know about this issue, they can touch it to bring it up to date. */ if (fstat (o, &s) < 0 - || s.st_mtime + 7 * 24 * 60 * 60 < time ((time_t *) NULL)) + || s.st_mtime + SECS_PER_WEEK < time ((time_t *) NULL)) { (void) close (o); o = -1; diff --git a/gnu/libexec/uucp/libunix/pause.c b/gnu/libexec/uucp/libunix/pause.c index e774e0897bf..8155db32726 100644 --- a/gnu/libexec/uucp/libunix/pause.c +++ b/gnu/libexec/uucp/libunix/pause.c @@ -29,7 +29,9 @@ #endif #if HAVE_SELECT +#if HAVE_SYS_TIME_H #include <sys/time.h> +#endif #if HAVE_SYS_SELECT_H #include <sys/select.h> #endif @@ -53,7 +55,7 @@ struct pollfd #endif /* HAVE_POLL */ #if HAVE_TIME_H -#if HAVE_SYS_TIME_AND_TIME_H || ! USE_SELECT_TIMER +#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME #include <time.h> #endif #endif @@ -87,10 +89,10 @@ usysdep_pause () s.tv_sec = 0; s.tv_usec = 500 * (long) 1000; select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s); -#endif /* USE_SELECT_TIMER */ +#endif /* HAVE_SELECT */ #if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP -#if ! USE_SELECT_TIMER && ! HAVE_POLL +#if ! HAVE_SELECT && ! HAVE_POLL sleep (1); -#endif /* ! USE_SELECT_TIMER && ! HAVE_POLL */ +#endif /* ! HAVE_SELECT && ! HAVE_POLL */ #endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */ } diff --git a/gnu/libexec/uucp/libunix/picksb.c b/gnu/libexec/uucp/libunix/picksb.c index 3fe5c6f585f..7acfc719aa9 100644 --- a/gnu/libexec/uucp/libunix/picksb.c +++ b/gnu/libexec/uucp/libunix/picksb.c @@ -1,7 +1,7 @@ /* picksb.c System dependent routines for uupick. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char picksb_rcsid[] = "$Id: picksb.c,v 1.1 1993/08/04 19:32:42 jtc Exp $"; +const char picksb_rcsid[] = "$Id: picksb.c,v 1.2 1994/10/24 22:19:12 jtc Exp $"; #endif #include "uudefs.h" @@ -203,18 +203,22 @@ fsysdep_uupick_free (zsystem, zpubdir) /* Expand a local file name for uupick. */ char * -zsysdep_uupick_local_file (zfile) +zsysdep_uupick_local_file (zfile, pfbadname) const char *zfile; + boolean *pfbadname; { struct passwd *q; + if (pfbadname != NULL) + *pfbadname = FALSE; + /* If this does not start with a simple ~, pass it to zsysdep_local_file_cwd; as it happens, zsysdep_local_file_cwd only uses the zpubdir argument if the file starts with a simple ~, so it doesn't really matter what we pass for zpubdir. */ if (zfile[0] != '~' || (zfile[1] != '/' && zfile[1] != '\0')) - return zsysdep_local_file_cwd (zfile, (const char *) NULL); + return zsysdep_local_file_cwd (zfile, (const char *) NULL, pfbadname); q = getpwuid (getuid ()); if (q == NULL) diff --git a/gnu/libexec/uucp/libunix/pipe.c b/gnu/libexec/uucp/libunix/pipe.c new file mode 100644 index 00000000000..05e03bbafec --- /dev/null +++ b/gnu/libexec/uucp/libunix/pipe.c @@ -0,0 +1,294 @@ +/* pipe.c + The pipe port communication routines for Unix. + Contributed by Marc Boucher <marc@CAM.ORG>. + + Copyright (C) 1993 Ian Lance Taylor + + This file is part of the Taylor UUCP package. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author of the program may be contacted at ian@airs.com or + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. + */ + +#include "uucp.h" + +#if USE_RCS_ID +const char pipe_rcsid[] = "$Id: pipe.c,v 1.1 1994/10/24 22:19:14 jtc Exp $"; +#endif + +#include "uudefs.h" +#include "uuconf.h" +#include "system.h" +#include "conn.h" +#include "sysdep.h" + +#include <errno.h> + +#if HAVE_FCNTL_H +#include <fcntl.h> +#else +#if HAVE_SYS_FILE_H +#include <sys/file.h> +#endif +#endif + +/* Local functions. */ + +static void uspipe_free P((struct sconnection *qconn)); +static boolean fspipe_open P((struct sconnection *qconn, long ibaud, + boolean fwait)); +static boolean fspipe_close P((struct sconnection *qconn, + pointer puuconf, + struct uuconf_dialer *qdialer, + boolean fsuccess)); +static boolean fspipe_dial P((struct sconnection *qconn, pointer puuconf, + const struct uuconf_system *qsys, + const char *zphone, + struct uuconf_dialer *qdialer, + enum tdialerfound *ptdialer)); + +/* The command table for standard input ports. */ + +static const struct sconncmds spipecmds = +{ + uspipe_free, + NULL, /* pflock */ + NULL, /* pfunlock */ + fspipe_open, + fspipe_close, + fspipe_dial, + fsdouble_read, + fsdouble_write, + fsysdep_conn_io, + NULL, /* pfbreak */ + NULL, /* pfset */ + NULL, /* pfcarrier */ + fsdouble_chat, + NULL /* pibaud */ +}; + +/* Initialize a pipe connection. */ + +boolean +fsysdep_pipe_init (qconn) + struct sconnection *qconn; +{ + struct ssysdep_conn *q; + + q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn)); + q->o = -1; + q->ord = -1; + q->owr = -1; + q->zdevice = NULL; + q->iflags = -1; + q->iwr_flags = -1; + q->fterminal = FALSE; + q->ftli = FALSE; + q->ibaud = 0; + q->ipid = -1; + qconn->psysdep = (pointer) q; + qconn->qcmds = &spipecmds; + return TRUE; +} + +static void +uspipe_free (qconn) + struct sconnection *qconn; +{ + xfree (qconn->psysdep); +} + +/* Open a pipe port. */ + +/*ARGSUSED*/ +static boolean +fspipe_open (qconn, ibaud, fwait) + struct sconnection *qconn; + long ibaud; + boolean fwait; +{ + /* We don't do incoming waits on pipes. */ + if (fwait) + return FALSE; + + return TRUE; +} + +/* Close a pipe port. */ + +/*ARGSUSED*/ +static boolean +fspipe_close (qconn, puuconf, qdialer, fsuccess) + struct sconnection *qconn; + pointer puuconf; + struct uuconf_dialer *qdialer; + boolean fsuccess; +{ + struct ssysdep_conn *qsysdep; + boolean fret; + + qsysdep = (struct ssysdep_conn *) qconn->psysdep; + fret = TRUE; + + /* Close our sides of the pipe. */ + if (qsysdep->ord >= 0 && close (qsysdep->ord) < 0) + { + ulog (LOG_ERROR, "fspipe_close: close read fd: %s", strerror (errno)); + fret = FALSE; + } + if (qsysdep->owr != qsysdep->ord + && qsysdep->owr >= 0 + && close (qsysdep->owr) < 0) + { + ulog (LOG_ERROR, "fspipe_close: close write fd: %s", strerror (errno)); + fret = FALSE; + } + qsysdep->ord = -1; + qsysdep->owr = -1; + + /* Kill dangling child process. */ + if (qsysdep->ipid >= 0) + { + if (kill (qsysdep->ipid, SIGHUP) == 0) + usysdep_sleep (2); +#ifdef SIGPIPE + if (kill (qsysdep->ipid, SIGPIPE) == 0) + usysdep_sleep (2); +#endif + if (kill (qsysdep->ipid, SIGKILL) < 0 && errno == EPERM) + { + ulog (LOG_ERROR, "fspipe_close: Cannot kill child pid %lu: %s", + (unsigned long) qsysdep->ipid, strerror (errno)); + fret = FALSE; + } + else + (void) ixswait ((unsigned long) qsysdep->ipid, (const char *) NULL); + } + qsysdep->ipid = -1; + return fret; +} + +/* Dial out on a pipe port, so to speak: launch connection program + under us. The code alternates q->o between q->ord and q->owr as + appropriate. It is always q->ord before any call to fsblock. */ + +/*ARGSUSED*/ +static boolean +fspipe_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer) + struct sconnection *qconn; + pointer puuconf; + const struct uuconf_system *qsys; + const char *zphone; + struct uuconf_dialer *qdialer; + enum tdialerfound *ptdialer; +{ + struct ssysdep_conn *q; + int aidescs[3]; + const char **pzprog; + + q = (struct ssysdep_conn *) qconn->psysdep; + + *ptdialer = DIALERFOUND_FALSE; + + pzprog = (const char **) qconn->qport->uuconf_u.uuconf_spipe.uuconf_pzcmd; + + if (pzprog == NULL) + { + ulog (LOG_ERROR, "No command for pipe connection"); + return FALSE; + } + + aidescs[0] = SPAWN_WRITE_PIPE; + aidescs[1] = SPAWN_READ_PIPE; + aidescs[2] = SPAWN_NULL; + + /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the + responsibility of security on the connection program. */ + q->ipid = ixsspawn (pzprog, aidescs, TRUE, TRUE, (const char *) NULL, + FALSE, TRUE, (const char *) NULL, + (const char *) NULL, (const char *) NULL); + if (q->ipid < 0) + { + ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno)); + return FALSE; + } + + q->owr = aidescs[0]; + q->ord = aidescs[1]; + q->o = q->ord; + + q->iflags = fcntl (q->ord, F_GETFL, 0); + q->iwr_flags = fcntl (q->owr, F_GETFL, 0); + if (q->iflags < 0 || q->iwr_flags < 0) + { + ulog (LOG_ERROR, "fspipe_dial: fcntl: %s", strerror (errno)); + (void) fspipe_close (qconn, puuconf, qdialer, FALSE); + return FALSE; + } + + return TRUE; +} + +#if 0 + +/* Marc Boucher's contributed code used an alarm to avoid waiting too + long when closing the pipe. However, I believe that it is not + possible for the kernel to sleep when closing a pipe; it is only + possible when closing a device. Therefore, I have removed the + code, but am preserving it in case I am wrong. To reenable it, the + two calls to close in fspipe_close should be changed to call + fspipe_alarmclose. */ + +static RETSIGTYPE +usalarm (isig) + int isig; +{ +#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET + (void) signal (isig, usalarm); +#endif + +#if HAVE_RESTARTABLE_SYSCALLS + longjmp (sSjmp_buf, 1); +#endif +} + +static int +fspipe_alarmclose (fd) + int fd; +{ + int iret = -1; + int ierrno = 0; + + if (fsysdep_catch ()) + { + usysdep_start_catch (); + usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); + (void) alarm (30); + + iret = close (fd); + ierrno = errno; + } + + usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); + (void) alarm (0); + usysdep_end_catch (); + + errno = ierrno; + return iret; +} + +#endif /* 0 */ diff --git a/gnu/libexec/uucp/libunix/priv.c b/gnu/libexec/uucp/libunix/priv.c new file mode 100644 index 00000000000..207bd3dbbb9 --- /dev/null +++ b/gnu/libexec/uucp/libunix/priv.c @@ -0,0 +1,24 @@ +/* priv.c + See if a user is privileged. */ + +#include "uucp.h" + +#include "sysdep.h" +#include "system.h" + +/* See whether the user is privileged (for example, only privileged + users are permitted to kill arbitrary jobs with uustat). This is + true only for root and uucp. We check for uucp by seeing if the + real user ID and the effective user ID are the same; this works + because we should be suid to uucp, so our effective user ID will + always be uucp while our real user ID will be whoever ran the + program. */ + +boolean +fsysdep_privileged () +{ + uid_t iuid; + + iuid = getuid (); + return iuid == 0 || iuid == geteuid (); +} diff --git a/gnu/libexec/uucp/libunix/proctm.c b/gnu/libexec/uucp/libunix/proctm.c index 55cf96f0c97..b9b6eb9e4af 100644 --- a/gnu/libexec/uucp/libunix/proctm.c +++ b/gnu/libexec/uucp/libunix/proctm.c @@ -1,7 +1,7 @@ /* proctm.c Get the time spent in the process. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -48,7 +48,7 @@ #define HAVE_FTIME 0 #endif -#if HAVE_TIME_H && (HAVE_SYS_TIME_AND_TIME_H || ! HAVE_GETTIMEOFDAY) +#if HAVE_TIME_H && (TIME_WITH_SYS_TIME || ! HAVE_GETTIMEOFDAY) #include <time.h> #endif diff --git a/gnu/libexec/uucp/libunix/recep.c b/gnu/libexec/uucp/libunix/recep.c index 84a211a7a94..152fd0d0ba1 100644 --- a/gnu/libexec/uucp/libunix/recep.c +++ b/gnu/libexec/uucp/libunix/recep.c @@ -1,7 +1,7 @@ /* recep.c See whether a file has already been received. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -103,7 +103,7 @@ fsysdep_remember_reception (qsys, zto, ztemp) { if (errno == ENOENT) { - if (fsysdep_make_dirs (zfile, TRUE)) + if (fsysdep_make_dirs (zfile, FALSE)) { ubuffree (zfile); return FALSE; @@ -133,6 +133,10 @@ fsysdep_remember_reception (qsys, zto, ztemp) return TRUE; } +/* The number of seconds in one week. We must cast to long for this + to be calculated correctly on a machine with 16 bit ints. */ +#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60) + /* See if we have already received a file. Note that don't delete the marker file here, because we need to know that the sending system has received our denial first. This function returns TRUE if the @@ -161,7 +165,7 @@ fsysdep_already_received (qsys, zto, ztemp) } /* Ignore the file (return FALSE) if it is over one week old. */ - fret = s.st_mtime + 7 * 24 * 60 * 60 >= time ((time_t *) NULL); + fret = s.st_mtime + SECS_PER_WEEK >= time ((time_t *) NULL); if (fret) DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, "fsysdep_already_received: Found %s", diff --git a/gnu/libexec/uucp/libunix/run.c b/gnu/libexec/uucp/libunix/run.c index e2191962837..af9b078d3bd 100644 --- a/gnu/libexec/uucp/libunix/run.c +++ b/gnu/libexec/uucp/libunix/run.c @@ -1,7 +1,7 @@ /* run.c Run a program. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -31,13 +31,11 @@ #include <errno.h> -/* Start up a new program and end the current one. We don't have to - worry about SIGHUP because the current process is either not a - process group leader (uucp, uux) or it does not have a controlling - terminal (uucico). */ +/* Start up a new program. */ boolean -fsysdep_run (zprogram, zarg1, zarg2) +fsysdep_run (ffork, zprogram, zarg1, zarg2) + boolean ffork; const char *zprogram; const char *zarg1; const char *zarg2; @@ -47,6 +45,40 @@ fsysdep_run (zprogram, zarg1, zarg2) int aidescs[3]; pid_t ipid; + /* If we are supposed to fork, fork and then spawn so that we don't + have to worry about zombie processes. */ + if (ffork) + { + ipid = ixsfork (); + if (ipid < 0) + { + ulog (LOG_ERROR, "fork: %s", strerror (errno)); + return FALSE; + } + + if (ipid != 0) + { + /* This is the parent. Wait for the child we just forked to + exit (below) and return. */ + (void) ixswait ((unsigned long) ipid, (const char *) NULL); + + /* Force the log files to be reopened in case the child just + output any error messages and stdio doesn't handle + appending correctly. */ + ulog_close (); + + return TRUE; + } + + /* This is the child. Detach from the terminal to avoid any + unexpected SIGHUP signals. At this point we are definitely + not a process group leader, so usysdep_detach will not fork + again. */ + usysdep_detach (); + + /* Now spawn the program and then exit. */ + } + zlib = zbufalc (sizeof SBINDIR + sizeof "/" + strlen (zprogram)); sprintf (zlib, "%s/%s", SBINDIR, zprogram); @@ -65,11 +97,17 @@ fsysdep_run (zprogram, zarg1, zarg2) FALSE, TRUE, (const char *) NULL, (const char *) NULL, (const char *) NULL); ubuffree (zlib); + if (ipid < 0) { ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno)); + if (ffork) + _exit (EXIT_FAILURE); return FALSE; } + if (ffork) + _exit (EXIT_SUCCESS); + return TRUE; } diff --git a/gnu/libexec/uucp/libunix/seq.c b/gnu/libexec/uucp/libunix/seq.c index 2e01233022a..5188510b612 100644 --- a/gnu/libexec/uucp/libunix/seq.c +++ b/gnu/libexec/uucp/libunix/seq.c @@ -1,7 +1,7 @@ /* seq.c Get and increment the conversation sequence number for a system. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c index 2b02cd5aaa5..a6230e72ef0 100644 --- a/gnu/libexec/uucp/libunix/serial.c +++ b/gnu/libexec/uucp/libunix/serial.c @@ -1,7 +1,7 @@ /* serial.c The serial port communication routines for Unix. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char serial_rcsid[] = "$Id: serial.c,v 1.1 1993/08/04 19:32:52 jtc Exp $"; +const char serial_rcsid[] = "$Id: serial.c,v 1.2 1994/10/24 22:19:24 jtc Exp $"; #endif #include "uudefs.h" @@ -78,19 +78,21 @@ const char serial_rcsid[] = "$Id: serial.c,v 1.1 1993/08/04 19:32:52 jtc Exp $"; #define FD_CLOEXEC 1 #endif -#if HAVE_SYS_IOCTL_H +#if HAVE_SYS_IOCTL_H || HAVE_TXADDCD #include <sys/ioctl.h> #endif #if HAVE_BSD_TTY +#if HAVE_SYS_TIME_H #include <sys/time.h> +#endif #if HAVE_SYS_SELECT_H #include <sys/select.h> #endif #endif #if HAVE_TIME_H -#if HAVE_SYS_TIME_AND_TIME_H || ! HAVE_BSD_TTY +#if ! HAVE_SYS_TIME_H || ! HAVE_BSD_TTY || TIME_WITH_SYS_TIME #include <time.h> #endif #endif @@ -117,6 +119,10 @@ const char serial_rcsid[] = "$Id: serial.c,v 1.1 1993/08/04 19:32:52 jtc Exp $"; #endif /* ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS */ #endif /* HAVE_SVR4_LOCKFILES */ +#if HAVE_DEV_INFO +#include <sys/dev.h> +#endif + /* Get definitions for both O_NONBLOCK and O_NDELAY. */ #ifndef O_NDELAY #ifdef FNDELAY @@ -180,28 +186,46 @@ extern int t_nerr; /* Determine bits to clear for the various terminal control fields for HAVE_SYSV_TERMIO and HAVE_POSIX_TERMIOS. */ + +/* These fields are defined on some systems, and I am told that it + does not hurt to clear them, and it sometimes helps. */ +#ifndef IMAXBEL +#define IMAXBEL 0 +#endif + +#ifndef PENDIN +#define PENDIN 0 +#endif + #if HAVE_SYSV_TERMIO #define ICLEAR_IFLAG (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK \ | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC \ - | IXON | IXANY | IXOFF) + | IXON | IXANY | IXOFF | IMAXBEL) #define ICLEAR_OFLAG (OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET \ | OFILL | OFDEL | NLDLY | CRDLY | TABDLY | BSDLY \ | VTDLY | FFDLY) -#define ICLEAR_CFLAG (CBAUD | CLOCAL | CSIZE | PARENB | PARODD) +#define ICLEAR_CFLAG (CBAUD | CSIZE | PARENB | PARODD) #define ISET_CFLAG (CS8 | CREAD | HUPCL) #define ICLEAR_LFLAG (ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK \ - | ECHONL | NOFLSH) + | ECHONL | NOFLSH | PENDIN) #endif #if HAVE_POSIX_TERMIOS #define ICLEAR_IFLAG (BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR \ | INLCR | INPCK | ISTRIP | IXOFF | IXON \ - | PARMRK) + | PARMRK | IMAXBEL) #define ICLEAR_OFLAG (OPOST) -#define ICLEAR_CFLAG (CLOCAL | CSIZE | PARENB | PARODD) +#define ICLEAR_CFLAG (CSIZE | PARENB | PARODD) #define ISET_CFLAG (CS8 | CREAD | HUPCL) #define ICLEAR_LFLAG (ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN \ - | ISIG | NOFLSH | TOSTOP) + | ISIG | NOFLSH | TOSTOP | PENDIN) #endif + +enum tclocal_setting +{ + SET_CLOCAL, + CLEAR_CLOCAL, + IGNORE_CLOCAL +}; /* Local functions. */ @@ -216,7 +240,7 @@ static boolean fsserial_lock P((struct sconnection *qconn, boolean fin)); static boolean fsserial_unlock P((struct sconnection *qconn)); static boolean fsserial_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); + boolean fwait, enum tclocal_setting tlocal)); static boolean fsstdin_open P((struct sconnection *qconn, long ibaud, boolean fwait)); static boolean fsmodem_open P((struct sconnection *qconn, long ibaud, @@ -237,13 +261,6 @@ static boolean fsdirect_close P((struct sconnection *qconn, pointer puuconf, struct uuconf_dialer *qdialer, boolean fsuccess)); -static boolean fsserial_reset P((struct sconnection *qconn)); -static boolean fsstdin_reset P((struct sconnection *qconn)); -static boolean fsstdin_read P((struct sconnection *qconn, - char *zbuf, size_t *pclen, size_t cmin, - int ctimeout, boolean freport)); -static boolean fsstdin_write P((struct sconnection *qconn, - const char *zwrite, size_t cwrite)); static boolean fsserial_break P((struct sconnection *qconn)); static boolean fsstdin_break P((struct sconnection *qconn)); static boolean fsserial_set P((struct sconnection *qconn, @@ -256,9 +273,9 @@ static boolean fsstdin_set P((struct sconnection *qconn, enum txonxoffsetting txonxoff)); static boolean fsmodem_carrier P((struct sconnection *qconn, boolean fcarrier)); +static boolean fsserial_hardflow P((struct sconnection *qconn, + boolean fhardflow)); static boolean fsrun_chat P((int oread, int owrite, char **pzprog)); -static boolean fsstdin_chat P((struct sconnection *qconn, - char **pzprog)); static long isserial_baud P((struct sconnection *qconn)); /* The command table for standard input ports. */ @@ -270,15 +287,14 @@ static const struct sconncmds sstdincmds = NULL, /* pfunlock */ fsstdin_open, fsstdin_close, - fsstdin_reset, NULL, /* pfdial */ - fsstdin_read, - fsstdin_write, + fsdouble_read, + fsdouble_write, fsysdep_conn_io, fsstdin_break, fsstdin_set, NULL, /* pfcarrier */ - fsstdin_chat, + fsdouble_chat, isserial_baud }; @@ -291,7 +307,6 @@ static const struct sconncmds smodemcmds = fsserial_unlock, fsmodem_open, fsmodem_close, - fsserial_reset, fmodem_dial, fsysdep_conn_read, fsysdep_conn_write, @@ -312,7 +327,6 @@ static const struct sconncmds sdirectcmds = fsserial_unlock, fsdirect_open, fsdirect_close, - fsserial_reset, NULL, /* pfdial */ fsysdep_conn_read, fsysdep_conn_write, @@ -489,6 +503,8 @@ fsserial_init (qconn, qcmds, zdevice) q->zdevice[sizeof "/dev/" + clen - 1] = '\0'; } q->o = -1; + q->ord = -1; + q->owr = -1; q->ftli = FALSE; qconn->psysdep = (pointer) q; qconn->qcmds = qcmds; @@ -538,6 +554,12 @@ usserial_free (qconn) qconn->psysdep = NULL; } +#if HAVE_SEQUENT_LOCKFILES +#define LCK_TEMPLATE "LCK..tty" +#else +#define LCK_TEMPLATE "LCK.." +#endif + /* This routine is used for both locking and unlocking. It is the only routine which knows how to translate a device name into the name of a lock file. If it can't figure out a name, it does @@ -561,6 +583,39 @@ fsserial_lockfile (flok, qconn) zalc = NULL; if (z == NULL) { +#if HAVE_QNX_LOCKFILES + { + nid_t idevice_nid; + char abdevice_nid[13]; /* length of long, a period, and a NUL */ + size_t cdevice_nid; + const char *zbase; + size_t clen; + + /* If the node ID is explicitly specified as part of the + pathname to the device, use that. Otherwise, presume the + device is local to the current node. */ + if (qsysdep->zdevice[0] == '/' && qsysdep->zdevice[1] == '/') + idevice_nid = (nid_t) strtol (qsysdep->zdevice + 2, + (char **) NULL, 10); + else + idevice_nid = getnid (); + + sprintf (abdevice_nid, "%ld.", (long) idevice_nid); + cdevice_nid = strlen (abdevice_nid); + + zbase = strrchr (qsysdep->zdevice, '/') + 1; + clen = strlen (zbase); + + zalc = zbufalc (sizeof LCK_TEMPLATE + cdevice_nid + clen); + + memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1); + memcpy (zalc + sizeof LCK_TEMPLATE - 1, abdevice_nid, cdevice_nid); + memcpy (zalc + sizeof LCK_TEMPLATE - 1 + cdevice_nid, + zbase, clen + 1); + + z = zalc; + } +#else /* ! HAVE_QNX_LOCKFILES */ #if ! HAVE_SVR4_LOCKFILES { const char *zbase; @@ -568,22 +623,21 @@ fsserial_lockfile (flok, qconn) zbase = strrchr (qsysdep->zdevice, '/') + 1; clen = strlen (zbase); - zalc = zbufalc (sizeof "LCK.." + clen); - memcpy (zalc, "LCK..", sizeof "LCK.." - 1); - memcpy (zalc + sizeof "LCK.." - 1, zbase, clen + 1); + zalc = zbufalc (sizeof LCK_TEMPLATE + clen); + memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1); + memcpy (zalc + sizeof LCK_TEMPLATE - 1, zbase, clen + 1); #if HAVE_SCO_LOCKFILES { char *zl; - for (zl = zalc + sizeof "LCK.." - 1; *zl != '\0'; zl++) + for (zl = zalc + sizeof LCK_TEMPLATE - 1; *zl != '\0'; zl++) if (isupper (*zl)) *zl = tolower (*zl); } #endif z = zalc; } -#else /* ! HAVE_SVR4_LOCKFILES */ -#if HAVE_SVR4_LOCKFILES +#else /* HAVE_SVR4_LOCKFILES */ { struct stat s; @@ -598,10 +652,8 @@ fsserial_lockfile (flok, qconn) major (s.st_rdev), minor (s.st_rdev)); z = zalc; } -#else /* ! HAVE_SVR4_LOCKFILES */ - z = strrchr (qsysdep->zdevice, '/') + 1; -#endif /* ! HAVE_SVR4_LOCKFILES */ -#endif /* ! HAVE_SVR4_LOCKFILES */ +#endif /* HAVE_SVR4_LOCKFILES */ +#endif /* ! HAVE_QNX_LOCKFILES */ } if (flok) @@ -614,13 +666,15 @@ fsserial_lockfile (flok, qconn) { if (flok) { - if (lockttyexist (z)) + if (lockttyexist (z + sizeof LCK_TEMPLATE - 1)) { - ulog (LOG_NORMAL, "%s: port already locked"); + ulog (LOG_NORMAL, "%s: port already locked", + z + sizeof LCK_TEMPLATE - 1); fret = FALSE; } else - fret = fscoherent_disable_tty (z, &qsysdep->zenable); + fret = fscoherent_disable_tty (z + sizeof LCK_TEMPLATE - 1, + &qsysdep->zenable); } else { @@ -679,7 +733,7 @@ fsserial_lock (qconn, fin) if (! fsserial_lockfile (TRUE, qconn)) return FALSE; -#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL +#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL || HAVE_DEV_INFO /* Open the line and try to mark it in use. */ { struct ssysdep_conn *qsysdep; @@ -730,6 +784,38 @@ fsserial_lock (qconn, fin) } #endif +#if HAVE_DEV_INFO + /* QNX programs "lock" a serial port by simply opening it and + checking if some other program also has the port open. If the + count of openers is greater than one, the program presumes the + port is "locked" and backs off. This isn't really "locking" of + course, but it pretty much seems to work. This can result in + dropping incoming connections if an outgoing connection is + started at exactly the same time. It would probably be better + to stop using the lock files at all for this case, but that + would involve more complex changes to the code, and I'm afraid + I would break something. -- Joe Wells <jbw@cs.bu.edu> */ + { + struct _dev_info_entry sdevinfo; + + if (dev_info (qsysdep->o, &sdevinfo) == -1) + { + ulog (LOG_ERROR, "dev_info: %s", strerror (errno)); + sdevinfo.open_count = 2; /* force presumption of "locked" */ + } + if (sdevinfo.open_count != 1) + { +#ifdef TIOCNOTTY + (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL); +#endif /* TIOCNOTTY */ + (void) close (qsysdep->o); + qsysdep->o = -1; + (void) fsserial_lockfile (FALSE, qconn); + return FALSE; + } + } +#endif /* HAVE_DEV_INFO */ + if (fcntl (qsysdep->o, F_SETFD, fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0) { @@ -742,11 +828,6 @@ fsserial_lock (qconn, fin) (void) fsserial_lockfile (FALSE, qconn); return FALSE; } - -#ifdef TIOCSCTTY - /* On BSD 4.4, make it our controlling terminal. */ - (void) ioctl (qsysdep->o, TIOCSCTTY, 0); -#endif } #endif /* HAVE_TIOCSINUSE || HAVE_TIOCEXCL */ @@ -786,8 +867,7 @@ fsserial_unlock (qconn) return fret; } -/* Open a serial line. This sets the terminal settings. We begin in - seven bit mode and let the protocol change if necessary. */ +/* A table to map baud rates into index numbers. */ #if HAVE_POSIX_TERMIOS typedef speed_t baud_code; @@ -848,11 +928,18 @@ static struct sbaud_table static int cSmin; #endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ +/* Open a serial line. This sets the terminal settings. We begin in + seven bit mode and let the protocol change if necessary. If fwait + is FALSE we open the terminal in non-blocking mode. If flocal is + TRUE we set CLOCAL on the terminal when using termio[s]; this is + supposedly required on some versions of BSD/386. */ + static boolean -fsserial_open (qconn, ibaud, fwait) +fsserial_open (qconn, ibaud, fwait, tlocal) struct sconnection *qconn; long ibaud; boolean fwait; + enum tclocal_setting tlocal; { struct ssysdep_conn *q; baud_code ib; @@ -860,7 +947,19 @@ fsserial_open (qconn, ibaud, fwait) q = (struct ssysdep_conn *) qconn->psysdep; if (q->zdevice != NULL) - ulog_device (strrchr (q->zdevice, '/') + 1); + { +#if LOG_DEVICE_PREFIX + ulog_device (q->zdevice); +#else + const char *z; + + if (strncmp (q->zdevice, "/dev/", sizeof "/dev/" - 1) == 0) + z = q->zdevice + sizeof "/dev/" - 1; + else + z = q->zdevice; + ulog_device (z); +#endif + } else { const char *zport; @@ -925,11 +1024,6 @@ fsserial_open (qconn, ibaud, fwait) ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); return FALSE; } - -#ifdef TIOCSCTTY - /* On BSD 4.4, make it our controlling terminal. */ - (void) ioctl (q->o, TIOCSCTTY, 0); -#endif } /* Get the port flags, and make sure the ports are blocking. */ @@ -940,7 +1034,7 @@ fsserial_open (qconn, ibaud, fwait) ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); return FALSE; } - q->istdout_flags = -1; + q->iwr_flags = -1; if (! fgetterminfo (q->o, &q->sorig)) { @@ -1020,11 +1114,11 @@ fsserial_open (qconn, ibaud, fwait) q->snew.c_iflag &=~ ICLEAR_IFLAG; q->snew.c_oflag &=~ ICLEAR_OFLAG; q->snew.c_cflag &=~ ICLEAR_CFLAG; - q->snew.c_cflag |= (ib | ISET_CFLAG); + q->snew.c_cflag |= ib | ISET_CFLAG; q->snew.c_lflag &=~ ICLEAR_LFLAG; cSmin = 1; q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 0; + q->snew.c_cc[VTIME] = 1; #ifdef TCFLSH /* Flush pending input. */ @@ -1045,7 +1139,7 @@ fsserial_open (qconn, ibaud, fwait) q->snew.c_lflag &=~ ICLEAR_LFLAG; cSmin = 1; q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 0; + q->snew.c_cc[VTIME] = 1; (void) cfsetospeed (&q->snew, ib); (void) cfsetispeed (&q->snew, ib); @@ -1055,12 +1149,31 @@ fsserial_open (qconn, ibaud, fwait) #endif /* HAVE_POSIX_TERMIOS */ +#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS + switch (tlocal) + { + case SET_CLOCAL: + q->snew.c_cflag |= CLOCAL; + break; + case CLEAR_CLOCAL: + q->snew.c_cflag &=~ CLOCAL; + break; + case IGNORE_CLOCAL: + break; + } +#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ + if (! fsetterminfo (q->o, &q->snew)) { ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno)); return FALSE; } +#ifdef TIOCSCTTY + /* On BSD 4.4, make it our controlling terminal. */ + (void) ioctl (q->o, TIOCSCTTY, 0); +#endif + if (ibaud != 0) q->ibaud = ibaud; else @@ -1084,8 +1197,9 @@ fsserial_open (qconn, ibaud, fwait) return TRUE; } -/* Open a standard input port. The code alternates q->o between 0 and - 1 as appropriate. It is always 0 before any call to fsblock. */ +/* Open a standard input port. The code alternates q->o between + q->ord and q->owr as appropriate. It is always q->ord before any + call to fsblock. */ static boolean fsstdin_open (qconn, ibaud, fwait) @@ -1096,11 +1210,14 @@ fsstdin_open (qconn, ibaud, fwait) struct ssysdep_conn *q; q = (struct ssysdep_conn *) qconn->psysdep; - q->o = 0; - if (! fsserial_open (qconn, ibaud, fwait)) + q->ord = 0; + q->owr = 1; + + q->o = q->ord; + if (! fsserial_open (qconn, ibaud, fwait, IGNORE_CLOCAL)) return FALSE; - q->istdout_flags = fcntl (1, F_GETFL, 0); - if (q->istdout_flags < 0) + q->iwr_flags = fcntl (q->owr, F_GETFL, 0); + if (q->iwr_flags < 0) { ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); return FALSE; @@ -1116,9 +1233,26 @@ fsmodem_open (qconn, ibaud, fwait) long ibaud; boolean fwait; { + struct uuconf_modem_port *qm; + + qm = &qconn->qport->uuconf_u.uuconf_smodem; if (ibaud == (long) 0) - ibaud = qconn->qport->uuconf_u.uuconf_smodem.uuconf_ibaud; - return fsserial_open (qconn, ibaud, fwait); + ibaud = qm->uuconf_ibaud; + + if (! fsserial_open (qconn, ibaud, fwait, + fwait ? CLEAR_CLOCAL : SET_CLOCAL)) + return FALSE; + + /* If we are waiting for carrier, then turn on hardware flow + control. We don't turn on hardware flow control when dialing + out, because some modems don't assert the necessary signals until + they see carrier. Instead, we turn on hardware flow control in + fsmodem_carrier. */ + if (fwait + && ! fsserial_hardflow (qconn, qm->uuconf_fhardflow)) + return FALSE; + + return TRUE; } /* Open a direct port. */ @@ -1129,9 +1263,18 @@ fsdirect_open (qconn, ibaud, fwait) long ibaud; boolean fwait; { + struct uuconf_direct_port *qd; + + qd = &qconn->qport->uuconf_u.uuconf_sdirect; if (ibaud == (long) 0) - ibaud = qconn->qport->uuconf_u.uuconf_sdirect.uuconf_ibaud; - return fsserial_open (qconn, ibaud, fwait); + ibaud = qd->uuconf_ibaud; + if (! fsserial_open (qconn, ibaud, fwait, + qd->uuconf_fcarrier ? CLEAR_CLOCAL : SET_CLOCAL)) + return FALSE; + + /* Always turn on hardware flow control for a direct port when it is + opened. There is no other sensible time to turn it on. */ + return fsserial_hardflow (qconn, qd->uuconf_fhardflow); } /* Change the blocking status of the port. We keep track of the @@ -1174,14 +1317,14 @@ fsblock (qs, fblock) qs->iflags = iwant; - if (qs->istdout_flags >= 0) + if (qs->iwr_flags >= 0 && qs->ord != qs->owr) { if (fblock) - iwant = qs->istdout_flags &~ (O_NDELAY | O_NONBLOCK); + iwant = qs->iwr_flags &~ (O_NDELAY | O_NONBLOCK); else - iwant = qs->istdout_flags | iSunblock; + iwant = qs->iwr_flags | iSunblock; - if (fcntl (1, F_SETFL, iwant) < 0) + if (fcntl (qs->owr, F_SETFL, iwant) < 0) { /* We don't bother to fix up iSunblock here, since we succeeded above. */ @@ -1189,7 +1332,7 @@ fsblock (qs, fblock) return FALSE; } - qs->istdout_flags = iwant; + qs->iwr_flags = iwant; } return TRUE; @@ -1260,9 +1403,9 @@ fsstdin_close (qconn, puuconf, qdialer, fsuccess) struct ssysdep_conn *qsysdep; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - (void) close (1); + (void) close (qsysdep->owr); (void) close (2); - qsysdep->o = 0; + qsysdep->o = qsysdep->ord; return fsserial_close (qsysdep); } @@ -1428,68 +1571,6 @@ fsdirect_close (qconn, puuconf, qdialer, fsuccess) return fsserial_close ((struct ssysdep_conn *) qconn->psysdep); } -/* Reset a serial port by hanging up. */ - -static boolean -fsserial_reset (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *q; - sterminal sbaud; - - q = (struct ssysdep_conn *) qconn->psysdep; - - if (! q->fterminal) - return TRUE; - - sbaud = q->snew; - -#if HAVE_BSD_TTY - sbaud.stty.sg_ispeed = B0; - sbaud.stty.sg_ospeed = B0; -#endif -#if HAVE_SYSV_TERMIO - sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0; -#endif -#if HAVE_POSIX_TERMIOS - if (cfsetospeed (&sbaud, B0) < 0) - { - ulog (LOG_ERROR, "Can't set baud rate: %s", strerror (errno)); - return FALSE; - } -#endif - - if (! fsetterminfodrain (q->o, &sbaud)) - { - ulog (LOG_ERROR, "Can't hangup terminal: %s", strerror (errno)); - return FALSE; - } - - /* Give the terminal a chance to settle. */ - sleep (2); - - if (! fsetterminfo (q->o, &q->snew)) - { - ulog (LOG_ERROR, "Can't reopen terminal: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Reset a standard input port. */ - -static boolean -fsstdin_reset (qconn) - struct sconnection *qconn; -{ - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = 0; - return fsserial_reset (qconn); -} - /* Begin dialing out on a modem port. This opens the dialer device if there is one. */ @@ -1522,7 +1603,27 @@ fsysdep_modem_begin_dial (qconn, qdial) sleep (2); (void) ioctl (qsysdep->o, TIOCSDTR, 0); #else /* ! defined (TIOCCDTR) */ - (void) fconn_reset (qconn); + if (qsysdep->fterminal) + { + sterminal sbaud; + + sbaud = qsysdep->snew; + +#if HAVE_BSD_TTY + sbaud.stty.sg_ispeed = B0; + sbaud.stty.sg_ospeed = B0; +#endif +#if HAVE_SYSV_TERMIO + sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0; +#endif +#if HAVE_POSIX_TERMIOS + (void) cfsetospeed (&sbaud, B0); +#endif + + (void) fsetterminfodrain (qsysdep->o, &sbaud); + sleep (2); + (void) fsetterminfo (qsysdep->o, &qsysdep->snew); + } #endif /* ! defined (TIOCCDTR) */ if (qdial->uuconf_fdtr_toggle_wait) @@ -1584,15 +1685,17 @@ fsmodem_carrier (qconn, fcarrier) boolean fcarrier; { register struct ssysdep_conn *q; + struct uuconf_modem_port *qm; q = (struct ssysdep_conn *) qconn->psysdep; if (! q->fterminal) return TRUE; + qm = &qconn->qport->uuconf_u.uuconf_smodem; if (fcarrier) { - if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_fcarrier) + if (qm->uuconf_fcarrier) { #ifdef TIOCCAR /* Tell the modem to pay attention to carrier. */ @@ -1605,18 +1708,18 @@ fsmodem_carrier (qconn, fcarrier) #if HAVE_BSD_TTY #ifdef LNOMDM - /* IS68K Unix uses a local LNOMDM bit. */ - { - int iparam; - - iparam = LNOMDM; - if (ioctl (q->o, TIOCLBIC, &iparam) < 0) + /* IS68K Unix uses a local LNOMDM bit. */ { - ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s", - strerror (errno)); - return FALSE; + int iparam; + + iparam = LNOMDM; + if (ioctl (q->o, TIOCLBIC, &iparam) < 0) + { + ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s", + strerror (errno)); + return FALSE; + } } - } #endif /* LNOMDM */ #endif /* HAVE_BSD_TTY */ @@ -1630,9 +1733,20 @@ fsmodem_carrier (qconn, fcarrier) } #endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ } + + /* Turn on hardware flow control after turning on carrier. We + don't do it until now because some modems don't assert the + right signals until they see carrier. */ + if (! fsserial_hardflow (qconn, qm->uuconf_fhardflow)) + return FALSE; } else { + /* Turn off any hardware flow control before turning off + carrier. */ + if (! fsserial_hardflow (qconn, FALSE)) + return FALSE; + #ifdef TIOCNCAR /* Tell the modem to ignore carrier. */ if (ioctl (q->o, TIOCNCAR, 0) < 0) @@ -1700,6 +1814,104 @@ fsmodem_carrier (qconn, fcarrier) return TRUE; } +/* Tell the port to use hardware flow control. There is no standard + mechanism for controlling this. This implementation supports + CRTSCTS on SunOS, RTS/CTSFLOW on 386(ish) unix, CTSCD on the 3b1, + and TXADDCD/TXDELCD on AIX. If you know how to do it on other + systems, please implement it and send me the patches. */ + +static boolean +fsserial_hardflow (qconn, fhardflow) + struct sconnection *qconn; + boolean fhardflow; +{ + register struct ssysdep_conn *q; + + q = (struct ssysdep_conn *) qconn->psysdep; + + if (! q->fterminal) + return TRUE; + + /* Don't do anything if we don't know what to do. */ +#if HAVE_BSD_TTY +#define HAVE_HARDFLOW 0 +#endif +#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS +#if ! HAVE_TXADDCD +#ifndef CRTSFL +#ifndef CRTSCTS +#ifndef CTSCD +#define HAVE_HARDFLOW 0 +#endif +#endif +#endif +#endif +#endif + +#ifndef HAVE_HARDFLOW +#define HAVE_HARDFLOW 1 +#endif + +#if HAVE_HARDFLOW + if (fhardflow) + { +#if HAVE_TXADDCD + /* The return value does not reliably indicate whether this + actually succeeded. */ + (void) ioctl (q->o, TXADDCD, "rts"); +#else /* ! HAVE_TXADDCD */ +#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS +#ifdef CRTSFL + q->snew.c_cflag |= CRTSFL; + q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW); +#endif /* defined (CRTSFL) */ +#ifdef CRTSCTS + q->snew.c_cflag |= CRTSCTS; +#endif /* defined (CRTSCTS) */ +#ifdef CTSCD + q->snew.c_cflag |= CTSCD; +#endif /* defined (CTSCD) */ +#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ + if (! fsetterminfo (q->o, &q->snew)) + { + ulog (LOG_ERROR, "Can't enable hardware flow control: %s", + strerror (errno)); + return FALSE; + } +#endif /* ! HAVE_TXADDCD */ + } + else + { +#if HAVE_TXADDCD + /* The return value does not reliably indicate whether this + actually succeeded. */ + (void) ioctl (q->o, TXDELCD, "rts"); +#else /* ! HAVE_TXADDCD */ +#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS +#ifdef CRTSFL + q->snew.c_cflag &=~ CRTSFL; + q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW); +#endif /* defined (CRTSFL) */ +#ifdef CRTSCTS + q->snew.c_cflag &=~ CRTSCTS; +#endif /* defined (CRTSCTS) */ +#ifdef CTSCD + q->snew.c_cflag &=~ CTSCD; +#endif /* defined (CTSCD) */ +#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ + if (! fsetterminfo (q->o, &q->snew)) + { + ulog (LOG_ERROR, "Can't disable hardware flow control: %s", + strerror (errno)); + return FALSE; + } +#endif /* ! HAVE_TXADDCD */ + } +#endif /* HAVE_HARDFLOW */ + + return TRUE; +} + /* Finish dialing out on a modem by closing any dialer device and waiting for carrier. */ @@ -1781,7 +1993,50 @@ fsysdep_modem_end_dial (qconn, qdial) return FALSE; } -#endif /* TIOCWONLINE */ +#else /* ! defined (TIOCWONLINE) */ + + /* Try to open the port again without using O_NDELAY. In + principle, the open should delay until carrier is available. + This may not work on some systems, so we just ignore any + errors. */ + { + int onew; + + onew = open (q->zdevice, O_RDWR); + if (onew >= 0) + { + boolean fbad; + int iflags; + + fbad = FALSE; + + if (fcntl (onew, F_SETFD, + fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0) + fbad = TRUE; + + if (! fbad) + { + iflags = fcntl (onew, F_GETFL, 0); + if (iflags < 0 + || ! fsetterminfo (onew, &q->snew)) + fbad = TRUE; + } + + if (fbad) + (void) close (onew); + else + { + (void) close (q->o); + q->o = onew; + q->iflags = iflags; +#if HAVE_TIOCSINUSE + (void) ioctl (onew, TIOCSINUSE, 0); +#endif + } + } + } + +#endif /* ! defined (TIOCWONLINE) */ } return TRUE; @@ -1841,6 +2096,7 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) boolean fret; register struct ssysdep_conn * const q = (struct ssysdep_conn *) qconn->psysdep; + int cwouldblock; cwant = *pclen; *pclen = 0; @@ -1879,6 +2135,7 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) fret = FALSE; + cwouldblock = 0; while (TRUE) { int cgot; @@ -1995,10 +2252,26 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) (normally we would have received SIGHUP, but we can't count on that). We turn off the signals before calling ulog to reduce problems with interrupted system calls. */ - if (cgot <= 0) + if (cgot > 0) + cwouldblock = 0; + else { if (cgot < 0 && errno == EINTR) cgot = 0; + else if (cgot < 0 + && (errno == EAGAIN || errno == EWOULDBLOCK) + && cwouldblock < 2) + { + /* Incomprehensibly, on some systems the read will + return EWOULDBLOCK even though the descriptor has + been set to blocking mode. We permit the read call + to do this twice in a row, and then error out. We + don't want to permit an arbitrary number of + EWOULDBLOCK errors, since that could hang us up + indefinitely. */ + ++cwouldblock; + cgot = 0; + } else { int ierr; @@ -2114,10 +2387,10 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport) return fret; } -/* Read from a stdin port. */ +/* Read from a port with separate read/write file descriptors. */ -static boolean -fsstdin_read (qconn, zbuf, pclen, cmin, ctimeout, freport) +boolean +fsdouble_read (qconn, zbuf, pclen, cmin, ctimeout, freport) struct sconnection *qconn; char *zbuf; size_t *pclen; @@ -2128,7 +2401,7 @@ fsstdin_read (qconn, zbuf, pclen, cmin, ctimeout, freport) struct ssysdep_conn *qsysdep; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = 0; + qsysdep->o = qsysdep->ord; return fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport); } @@ -2166,7 +2439,7 @@ fsysdep_conn_write (qconn, zwrite, cwrite) #if HAVE_TLI if (q->ftli) { - cdid = t_snd (q->o, zwrite, cwrite, 0); + cdid = t_snd (q->o, (char *) zwrite, cwrite, 0); if (cdid < 0 && t_errno != TSYSERR) { ulog (LOG_ERROR, "t_snd: %s", @@ -2225,10 +2498,10 @@ fsysdep_conn_write (qconn, zwrite, cwrite) return TRUE; } -/* Write to a stdin port. */ +/* Write to a port with separate read/write file descriptors. */ -static boolean -fsstdin_write (qconn, zwrite, cwrite) +boolean +fsdouble_write (qconn, zwrite, cwrite) struct sconnection *qconn; const char *zwrite; size_t cwrite; @@ -2236,10 +2509,10 @@ fsstdin_write (qconn, zwrite, cwrite) struct ssysdep_conn *qsysdep; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = 0; + qsysdep->o = qsysdep->ord; if (! fsblock (qsysdep, TRUE)) return FALSE; - qsysdep->o = 1; + qsysdep->o = qsysdep->owr; return fsysdep_conn_write (qconn, zwrite, cwrite); } @@ -2303,8 +2576,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) /* If we are running on standard input, we switch the file descriptors by hand. */ - if (q->istdout_flags >= 0) - q->o = 0; + if (q->ord >= 0) + q->o = q->ord; /* Do an unblocked read. */ if (! fsblock (q, FALSE)) @@ -2378,8 +2651,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) cdo = SINGLE_WRITE; #endif - if (q->istdout_flags >= 0) - q->o = 1; + if (q->owr >= 0) + q->o = q->owr; /* Loop until we get something besides EINTR. */ while (TRUE) @@ -2391,7 +2664,7 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) #if HAVE_TLI if (q->ftli) { - cdid = t_snd (q->o, zwrite, cdo, 0); + cdid = t_snd (q->o, (char *) zwrite, cdo, 0); if (cdid < 0) { if (t_errno == TFLOW) @@ -2446,8 +2719,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) { /* We didn't write any data. Do a blocking write. */ - if (q->istdout_flags >= 0) - q->o = 0; + if (q->ord >= 0) + q->o = q->ord; if (! fsblock (q, TRUE)) return FALSE; @@ -2457,11 +2730,11 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) cdo = SINGLE_WRITE; DEBUG_MESSAGE1 (DEBUG_PORT, - "fsysdep_conn_io: Blocking write of %lud", + "fsysdep_conn_io: Blocking write of %lu", (unsigned long) cdo); - if (q->istdout_flags >= 0) - q->o = 1; + if (q->owr >= 0) + q->o = q->owr; /* Loop until we get something besides EINTR. */ while (TRUE) @@ -2473,7 +2746,7 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread) #if HAVE_TLI if (q->ftli) { - cdid = t_snd (q->o, zwrite, cdo, 0); + cdid = t_snd (q->o, (char *) zwrite, cdo, 0); if (cdid < 0 && t_errno != TSYSERR) { ulog (LOG_ERROR, "t_snd: %s", @@ -2562,7 +2835,7 @@ fsstdin_break (qconn) struct ssysdep_conn *qsysdep; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = 1; + qsysdep->o = qsysdep->owr; return fsserial_break (qconn); } @@ -2791,6 +3064,22 @@ fsserial_set (qconn, tparity, tstrip, txonxoff) } #endif /* HAVE_POSIX_TERMIOS */ #endif /* defined (CRTSCTS) */ +#ifdef CRTSFL + if ((q->snew.c_cflag & CRTSFL) != 0) + { + iset = IXON; + iclear = IXOFF; + /* SCO says we cant have CRTSFL **and** RTSFLOW/CTSFLOW */ +#ifdef RTSFLOW + iclear |= RTSFLOW; +#endif +#ifdef CTSFLOW + iclear |= CTSFLOW; +#endif + fdo = TRUE; + break; + } +#endif /* defined(CRTSFL) */ iset = IXON | IXOFF; iclear = 0; fdo = TRUE; @@ -2876,7 +3165,7 @@ fsstdin_set (qconn, tparity, tstrip, txonxoff) struct ssysdep_conn *qsysdep; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - qsysdep->o = 0; + qsysdep->o = qsysdep->ord; return fsserial_set (qconn, tparity, tstrip, txonxoff); } @@ -2940,15 +3229,22 @@ fsrun_chat (oread, owrite, pzprog) return ixswait ((unsigned long) ipid, "Chat program") == 0; } -/* Run a chat program on a stdin port. */ +/* Run a chat program on a port using separate read/write file + descriptors. */ -/*ARGSUSED*/ -static boolean -fsstdin_chat (qconn, pzprog) +boolean +fsdouble_chat (qconn, pzprog) struct sconnection *qconn; char **pzprog; { - return fsrun_chat (0, 1, pzprog); + struct ssysdep_conn *qsysdep; + boolean fret; + + qsysdep = (struct ssysdep_conn *) qconn->psysdep; + fret = fsrun_chat (qsysdep->ord, qsysdep->owr, pzprog); + if (qsysdep->fterminal) + (void) fgetterminfo (qsysdep->ord, &qsysdep->snew); + return fret; } /* Run a chat program on any general type of connection. */ @@ -2959,9 +3255,13 @@ fsysdep_conn_chat (qconn, pzprog) char **pzprog; { struct ssysdep_conn *qsysdep; + boolean fret; qsysdep = (struct ssysdep_conn *) qconn->psysdep; - return fsrun_chat (qsysdep->o, qsysdep->o, pzprog); + fret = fsrun_chat (qsysdep->o, qsysdep->o, pzprog); + if (qsysdep->fterminal) + (void) fgetterminfo (qsysdep->o, &qsysdep->snew); + return fret; } /* Return baud rate of a serial port. */ diff --git a/gnu/libexec/uucp/libunix/signal.c b/gnu/libexec/uucp/libunix/signal.c index 33e24a72457..75016c30e11 100644 --- a/gnu/libexec/uucp/libunix/signal.c +++ b/gnu/libexec/uucp/libunix/signal.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/sindir.c b/gnu/libexec/uucp/libunix/sindir.c index d9875081891..7c9da50045f 100644 --- a/gnu/libexec/uucp/libunix/sindir.c +++ b/gnu/libexec/uucp/libunix/sindir.c @@ -18,7 +18,10 @@ zsysdep_in_dir (zdir, zfile) cdir = strlen (zdir); cfile = strlen (zfile); zret = zbufalc (cdir + cfile + 2); - memcpy (zret, zdir, cdir); + if (cdir == 1 && *zdir == '/') + cdir = 0; + else + memcpy (zret, zdir, cdir); memcpy (zret + cdir + 1, zfile, cfile); zret[cdir] = '/'; zret[cdir + cfile + 1] = '\0'; diff --git a/gnu/libexec/uucp/libunix/sleep.c b/gnu/libexec/uucp/libunix/sleep.c index b232f9674ff..910c9292e19 100644 --- a/gnu/libexec/uucp/libunix/sleep.c +++ b/gnu/libexec/uucp/libunix/sleep.c @@ -10,5 +10,17 @@ void usysdep_sleep (c) int c; { +#if HAVE_NAPMS || HAVE_NAP || HAVE_USLEEP || HAVE_SELECT || HAVE_POLL + int i; + + /* In this case, usysdep_pause is accurate. */ + for (i = 2 * c; i > 0; i--) + usysdep_pause (); +#else + /* On some system sleep (1) may not sleep at all. Avoid this sort + of problem by always doing at least sleep (2). */ + if (c < 2) + c = 2; (void) sleep (c); +#endif } diff --git a/gnu/libexec/uucp/libunix/spawn.c b/gnu/libexec/uucp/libunix/spawn.c index 7ab080d1a9c..67b915fc66a 100644 --- a/gnu/libexec/uucp/libunix/spawn.c +++ b/gnu/libexec/uucp/libunix/spawn.c @@ -1,7 +1,7 @@ /* spawn.c Spawn a program securely. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -102,6 +102,9 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, char *azenv[9]; char **pazenv; boolean ferr; +#if HAVE_FULLDUPLEX_PIPES + boolean ffullduplex; +#endif int ierr = 0; int onull; int aichild_descs[3]; @@ -196,6 +199,11 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, cpar_close = 0; cchild_close = 0; +#if HAVE_FULLDUPLEX_PIPES + ffullduplex = (aidescs[0] == SPAWN_WRITE_PIPE + && aidescs[1] == SPAWN_READ_PIPE); +#endif + for (i = 0; i < 3; i++) { if (aidescs[i] == SPAWN_NULL) @@ -224,6 +232,16 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, { int aipipe[2]; +#if HAVE_FULLDUPLEX_PIPES + if (ffullduplex && i == 1) + { + /* Just use the fullduplex pipe. */ + aidescs[i] = aidescs[0]; + aichild_descs[i] = aichild_descs[0]; + continue; + } +#endif + if (pipe (aipipe) < 0) { ierr = errno; @@ -249,8 +267,10 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, ++cpar_close; ++cchild_close; - if (fcntl (aidescs[i], F_SETFD, - fcntl (aidescs[i], F_GETFD, 0) | FD_CLOEXEC) < 0) + if (fcntl (aipipe[0], F_SETFD, + fcntl (aipipe[0], F_GETFD, 0) | FD_CLOEXEC) < 0 + || fcntl (aipipe[1], F_SETFD, + fcntl (aipipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0) { ierr = errno; ferr = TRUE; @@ -332,9 +352,21 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, if (! fkeepuid) { + /* Return to the uid of the invoking user. */ (void) setuid (getuid ()); (void) setgid (getgid ()); } + else + { + /* Try to force the UUCP uid to be both real and effective user + ID, in order to present a consistent environment regardless + of the invoking user. This won't work on System V based + systems, but it will do no harm. It would be possible to use + a setuid root program to force the UID setting, but I don't + think the efficiency loss is worth it. */ + (void) setuid (geteuid ()); + (void) setgid (getegid ()); + } if (zchdir != NULL) (void) chdir (zchdir); @@ -352,11 +384,24 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, #endif } +#ifdef isc386 +#ifdef _POSIX_SOURCE + /* ISC has a remarkably stupid notion of environments. If a program + is compiled in the POSIX environment, it sets a process state. + If you then exec a program which expects the USG environment, the + process state is not reset, so the execed program fails. The + __setostype call is required to change back to the USG + environment. This ought to be a switch in policy.h, but it seems + too trivial, so I will leave this code here and wait for it to + break in some fashion in the next version of ISC. */ + __setostype (0); +#endif +#endif + (void) execve ((char *) zcmd, (char **) pazargs, pazenv); /* The exec failed. If permitted, try using /bin/sh to execute a shell script. */ - if (errno == ENOEXEC && fshell) { char *zto; diff --git a/gnu/libexec/uucp/libunix/splcmd.c b/gnu/libexec/uucp/libunix/splcmd.c index 9f6616a36dd..77406611996 100644 --- a/gnu/libexec/uucp/libunix/splcmd.c +++ b/gnu/libexec/uucp/libunix/splcmd.c @@ -1,7 +1,7 @@ /* splcmd.c Spool a command. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -44,10 +44,12 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) int ccmds; const struct scmd *pascmds; { - char *z; + char abtempfile[sizeof "TMP1234567890"]; + char *ztemp; FILE *e; int i; const struct scmd *q; + char *z; char *zjobid; #if DEBUG > 0 @@ -55,14 +57,17 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) ulog (LOG_FATAL, "Bad grade %d", bgrade); #endif - z = zscmd_file (qsys, bgrade); - if (z == NULL) + /* Write the commands into a temporary file and then rename it to + avoid a race with uucico reading the file. */ + sprintf (abtempfile, "TMP%010lx", (unsigned long) getpid ()); + ztemp = zsfind_file (abtempfile, qsys->uuconf_zname, bgrade); + if (ztemp == NULL) return NULL; - e = esysdep_fopen (z, FALSE, FALSE, TRUE); + e = esysdep_fopen (ztemp, FALSE, FALSE, TRUE); if (e == NULL) { - ubuffree (z); + ubuffree (ztemp); return NULL; } @@ -93,8 +98,8 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) "zsysdep_spool_commands: Unrecognized type %d", q->bcmd); (void) fclose (e); - (void) remove (z); - ubuffree (z); + (void) remove (ztemp); + ubuffree (ztemp); return NULL; } } @@ -102,11 +107,30 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) if (fclose (e) != 0) { ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (z); + (void) remove (ztemp); + ubuffree (ztemp); + return NULL; + } + + z = zscmd_file (qsys, bgrade); + if (z == NULL) + { + (void) remove (ztemp); + ubuffree (ztemp); + return NULL; + } + + if (! fsysdep_move_file (ztemp, z, FALSE, FALSE, FALSE, + (const char *) NULL)) + { + (void) remove (ztemp); + ubuffree (ztemp); ubuffree (z); return NULL; } + ubuffree (ztemp); + zjobid = zsfile_to_jobid (qsys, z, bgrade); if (zjobid == NULL) (void) remove (z); diff --git a/gnu/libexec/uucp/libunix/spool.c b/gnu/libexec/uucp/libunix/spool.c index f28229fe4e1..987f8e5a138 100644 --- a/gnu/libexec/uucp/libunix/spool.c +++ b/gnu/libexec/uucp/libunix/spool.c @@ -1,7 +1,7 @@ /* spool.c Find a file in the spool directory. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char spool_rcsid[] = "$Id: spool.c,v 1.1 1993/08/04 19:33:02 jtc Exp $"; +const char spool_rcsid[] = "$Id: spool.c,v 1.2 1994/10/24 22:19:37 jtc Exp $"; #endif #include "uudefs.h" @@ -194,7 +194,12 @@ zsfind_file (zsimple, zsystem, bgrade) const char *zsystem; int bgrade; { - if (! fspool_file (zsimple)) + /* zsysdep_spool_commands calls this with TMPXXX which we must treat + as a C. file. */ + if ((zsimple[0] != 'T' + || zsimple[1] != 'M' + || zsimple[2] != 'P') + && ! fspool_file (zsimple)) { ulog (LOG_ERROR, "Unrecognized file name %s", zsimple); return NULL; @@ -203,7 +208,9 @@ zsfind_file (zsimple, zsystem, bgrade) #if ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR if (*zsimple == 'X') { - size_t clen; + static char *zbuf; + static size_t cbuf; + size_t clen, cwant; /* Files beginning with X. are execute files. It is important for security reasons that we know the system which created @@ -216,22 +223,19 @@ zsfind_file (zsimple, zsystem, bgrade) too short, but hopefully no problem will occur since any System V systems will be using HDB or SVR4 or TAYLOR. */ clen = strlen (zsimple); - if (clen <= 7 || strncmp (zsimple + 2, zsystem, clen - 7) != 0) + if (clen < 5) { - static char *zbuf; - static size_t cbuf; - size_t cwant; - - cwant = strlen (zsystem) + 8; - if (cwant > cbuf) - { - zbuf = (char *) xrealloc ((pointer) zbuf, cwant); - cbuf = cwant; - } - sprintf (zbuf, "X.%s%s", zsystem, - clen < 5 ? zsimple : zsimple + clen - 5); - zsimple = zbuf; + ulog (LOG_ERROR, "Bad file name (too short) %s", zsimple); + return NULL; } + cwant = strlen (zsystem) + 8; + if (cwant > cbuf) + { + zbuf = (char *) xrealloc ((pointer) zbuf, cwant); + cbuf = cwant; + } + sprintf (zbuf, "X.%s%s", zsystem, zsimple + clen - 5); + zsimple = zbuf; } #endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR */ @@ -264,6 +268,7 @@ zsfind_file (zsimple, zsystem, bgrade) switch (*zsimple) { case 'C': + case 'T': #if SPOOLDIR_BSD42 || SPOOLDIR_BSD43 return zsysdep_in_dir ("C.", zsimple); #endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */ diff --git a/gnu/libexec/uucp/libunix/srmdir.c b/gnu/libexec/uucp/libunix/srmdir.c index 28487ef3097..6110b003fc2 100644 --- a/gnu/libexec/uucp/libunix/srmdir.c +++ b/gnu/libexec/uucp/libunix/srmdir.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -35,7 +35,7 @@ #include <ftw.h> #endif -static int isremove_dir P((const char *, const struct stat *, int)); +static int isremove_dir P((const char *, struct stat *, int)); /* Keep a list of directories to be removed. */ @@ -90,7 +90,7 @@ fsysdep_rmdir (zdir) static int isremove_dir (zfile, qstat, iflag) const char *zfile; - const struct stat *qstat; + struct stat *qstat; int iflag; { if (iflag == FTW_D || iflag == FTW_DNR) diff --git a/gnu/libexec/uucp/libunix/statsb.c b/gnu/libexec/uucp/libunix/statsb.c index 79a14c0e64c..0181960139a 100644 --- a/gnu/libexec/uucp/libunix/statsb.c +++ b/gnu/libexec/uucp/libunix/statsb.c @@ -1,7 +1,7 @@ /* statsb.c System dependent routines for uustat. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char statsb_rcsid[] = "$Id: statsb.c,v 1.1 1993/08/04 19:33:06 jtc Exp $"; +const char statsb_rcsid[] = "$Id: statsb.c,v 1.2 1994/10/24 22:19:40 jtc Exp $"; #endif #include "uudefs.h" @@ -73,32 +73,16 @@ const char statsb_rcsid[] = "$Id: statsb.c,v 1.1 1993/08/04 19:33:06 jtc Exp $"; /* Local functions. */ -static int ussettime P((const char *z, time_t inow)); +static int issettime P((const char *z, time_t inow)); static boolean fskill_or_rejuv P((pointer puuconf, const char *zid, boolean fkill)); -/* See whether the user is permitted to kill arbitrary jobs. This is - true only for root and uucp. We check for uucp by seeing if the - real user ID and the effective user ID are the same; this works - because we should be suid to uucp, so our effective user ID will - always be uucp while our real user ID will be whoever ran the - program. */ - -boolean -fsysdep_privileged () -{ - uid_t iuid; - - iuid = getuid (); - return iuid == 0 || iuid == geteuid (); -} - /* Set file access time to the present. On many systems this could be done by passing NULL to utime, but on some that doesn't work. This routine is not time critical, so we never rely on NULL. */ static int -ussettime(z, inow) +issettime(z, inow) const char *z; time_t inow; { @@ -238,7 +222,7 @@ fskill_or_rejuv (puuconf, zid, fkill) if (fkill) isys = remove (ztemp); else - isys = ussettime (ztemp, inow); + isys = issettime (ztemp, inow); if (isys != 0 && errno != ENOENT) { @@ -261,7 +245,7 @@ fskill_or_rejuv (puuconf, zid, fkill) if (fkill) isys = remove (zfile); else - isys = ussettime (zfile, inow); + isys = issettime (zfile, inow); if (isys != 0 && errno != ENOENT) { @@ -313,6 +297,21 @@ ixsysdep_file_time (zfile) return (long) s.st_mtime; } + +/* Set the time of a file to the current time. */ + +boolean +fsysdep_touch_file (zfile) + const char *zfile; +{ + if (issettime (zfile, time ((time_t *) NULL)) != 0) + { + ulog (LOG_ERROR, "utime (%s): %s", zfile, strerror (errno)); + return FALSE; + } + + return TRUE; +} /* Start getting the status files. */ @@ -399,7 +398,10 @@ fsysdep_lock_status () DIR *qdir; struct dirent *qentry; int calc; - int *pai; + pid_t *pai; +#if HAVE_QNX_LOCKFILES + nid_t *painid; +#endif int cgot; int aidescs[3]; char *zcopy, *ztok; @@ -420,18 +422,28 @@ fsysdep_lock_status () calc = 0; pai = NULL; cgot = 0; +#if HAVE_QNX_LOCKFILES + painid = NULL; +#endif while ((qentry = readdir (qdir)) != NULL) { char *zname; int o; +#if HAVE_QNX_LOCKFILES + nid_t inid; + char ab[23]; + char *zend; +#else #if HAVE_V2_LOCKFILES int i; #else char ab[12]; #endif +#endif int cread; int ierr; - int ipid; + pid_t ipid; + int icheck; if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0) continue; @@ -464,22 +476,45 @@ fsysdep_lock_status () ubuffree (zname); +#if HAVE_QNX_LOCKFILES + ab[cread] = '\0'; + ipid = (pid_t) strtol (ab, &zend, 10); + inid = (nid_t) strtol (zend, (char **) NULL, 10); +#else #if HAVE_V2_LOCKFILES - ipid = i; + ipid = (pid_t) i; #else ab[cread] = '\0'; - ipid = strtol (ab, (char **) NULL, 10); + ipid = (pid_t) strtol (ab, (char **) NULL, 10); +#endif #endif - printf ("%s: %d\n", qentry->d_name, ipid); +#if HAVE_QNX_LOCKFILES + printf ("%s: %ld %ld\n", qentry->d_name, (long) inid, (long) ipid); +#else + printf ("%s: %ld\n", qentry->d_name, (long) ipid); +#endif + + for (icheck = 0; icheck < cgot; icheck++) + if (pai[icheck] == ipid) + break; + if (icheck < cgot) + continue; if (cgot >= calc) { calc += 10; - pai = (int *) xrealloc ((pointer) pai, calc * sizeof (int)); + pai = (pid_t *) xrealloc ((pointer) pai, calc * sizeof (pid_t)); +#if HAVE_QNX_LOCKFILES + painid = (nid_t *) xrealloc ((pointer) painid, + calc * sizeof (nid_t)); +#endif } pai[cgot] = ipid; +#if HAVE_QNX_LOCKFILES + painid[cgot] = inid; +#endif ++cgot; } @@ -513,16 +548,40 @@ fsysdep_lock_status () { int i; char *zlast, *zset; +#if HAVE_QNX_LOCKFILES + char *zpenultimate, *zsetnid; +#endif /* HAVE_QNX_LOCKFILES */ zlast = pazargs[cargs - 1]; zset = zbufalc (strlen (zlast) + 20); + +#if HAVE_QNX_LOCKFILES + /* We assume in this case that PS_PROGRAM ends with " -n -p". + Thus, the last argument is "-p" and the second-to-last + (penultimate) argument is "-n". We modify them to read "-n###" + and "-p###" where "###" is the node ID and the process ID, + respectively. This seems like quite a roundabout way of doing + things. Why don't we just leave the " -n -p" part out of + PS_PROGRAM and construct the "-n###" and "-p###" arguments here + from scratch? Because that would not fit as well with how the + code works for the other systems and would require larger + changes. */ + zpenultimate = pazargs[cargs - 2]; + zsetnid = zbufalc (strlen (zpenultimate) + 20); +#endif + for (i = 0; i < cgot; i++) { pid_t ipid; - sprintf (zset, "%s%d", zlast, pai[i]); + sprintf (zset, "%s%ld", zlast, (long) pai[i]); pazargs[cargs - 1] = zset; +#if HAVE_QNX_LOCKFILES + sprintf (zsetnid, "%s%ld", zpenultimate, (long) painid[i]); + pazargs[cargs - 2] = zsetnid; +#endif + ipid = ixsspawn ((const char **) pazargs, aidescs, FALSE, FALSE, (const char *) NULL, FALSE, TRUE, (const char *) NULL, (const char *) NULL, @@ -533,6 +592,9 @@ fsysdep_lock_status () (void) ixswait ((unsigned long) ipid, PS_PROGRAM); } ubuffree (zset); +#if HAVE_QNX_LOCKFILES + ubuffree (zsetnid); +#endif } #else { @@ -546,7 +608,7 @@ fsysdep_lock_status () { char ab[20]; - sprintf (ab, "%d", pai[i]); + sprintf (ab, "%ld", (long) pai[i]); strcat (zlast, ab); if (i + 1 < cgot) strcat (zlast, ","); @@ -563,7 +625,7 @@ fsysdep_lock_status () (void) ixswait ((unsigned long) ipid, PS_PROGRAM); ubuffree (zlast); } -#endif +#endif ubuffree (zcopy); xfree ((pointer) pazargs); diff --git a/gnu/libexec/uucp/libunix/status.c b/gnu/libexec/uucp/libunix/status.c index f403068a709..a967085e08f 100644 --- a/gnu/libexec/uucp/libunix/status.c +++ b/gnu/libexec/uucp/libunix/status.c @@ -1,7 +1,7 @@ /* status.c Routines to get and set the status for a system. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -41,7 +41,7 @@ static const int aiMapstatus[] = { - 0, 13, 7, 6, 4, 20, 3, 2 + 0, 13, 7, 6, 20, 4, 3, 2 }; #define CMAPENTRIES (sizeof (aiMapstatus) / sizeof (aiMapstatus[0])) diff --git a/gnu/libexec/uucp/libunix/strerr.c b/gnu/libexec/uucp/libunix/strerr.c index d2a6c2128d0..8e7480f1ec5 100644 --- a/gnu/libexec/uucp/libunix/strerr.c +++ b/gnu/libexec/uucp/libunix/strerr.c @@ -12,6 +12,8 @@ extern int sys_nerr; extern char *sys_errlist[]; #endif +#undef strerror + char * strerror (ierr) int ierr; diff --git a/gnu/libexec/uucp/libunix/tmpfil.c b/gnu/libexec/uucp/libunix/tmpfil.c index 2dac0024388..b10e8096df4 100644 --- a/gnu/libexec/uucp/libunix/tmpfil.c +++ b/gnu/libexec/uucp/libunix/tmpfil.c @@ -1,7 +1,7 @@ /* tmpfil.c Get a temporary file name. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,11 +20,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" +#include "uudefs.h" #include "uuconf.h" #include "system.h" #include "sysdep.h" diff --git a/gnu/libexec/uucp/libunix/uacces.c b/gnu/libexec/uucp/libunix/uacces.c index c92c78eae35..d99ead36674 100644 --- a/gnu/libexec/uucp/libunix/uacces.c +++ b/gnu/libexec/uucp/libunix/uacces.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/ufopen.c b/gnu/libexec/uucp/libunix/ufopen.c index 5a7b6f22b0d..76ee1d1394d 100644 --- a/gnu/libexec/uucp/libunix/ufopen.c +++ b/gnu/libexec/uucp/libunix/ufopen.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libunix/walk.c b/gnu/libexec/uucp/libunix/walk.c index ab96123127d..85b94dae8a9 100644 --- a/gnu/libexec/uucp/libunix/walk.c +++ b/gnu/libexec/uucp/libunix/walk.c @@ -11,8 +11,7 @@ #include <ftw.h> #endif -static int iswalk_dir P((const char *zname, const struct stat *qstat, - int iflag)); +static int iswalk_dir P((const char *zname, struct stat *qstat, int iflag)); /* Walk a directory tree. */ @@ -41,7 +40,7 @@ usysdep_walk_tree (zdir, pufn, pinfo) static int iswalk_dir (zname, qstat, iflag) const char *zname; - const struct stat *qstat; + struct stat *qstat; int iflag; { char *zcopy; diff --git a/gnu/libexec/uucp/libunix/wldcrd.c b/gnu/libexec/uucp/libunix/wldcrd.c index cfbd15eb848..13faa29b9c4 100644 --- a/gnu/libexec/uucp/libunix/wldcrd.c +++ b/gnu/libexec/uucp/libunix/wldcrd.c @@ -1,7 +1,7 @@ /* wldcrd.c Expand wildcards. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -113,9 +113,10 @@ fsysdep_wildcard_start (zfile) azargs[2] = zcmd; azargs[3] = NULL; + e = espopen (azargs, TRUE, &ipid); + ubuffree (zcmd); - e = espopen (azargs, TRUE, &ipid); if (e == NULL) { ulog (LOG_ERROR, "espopen: %s", strerror (errno)); diff --git a/gnu/libexec/uucp/libunix/work.c b/gnu/libexec/uucp/libunix/work.c index 3d055c282ed..0dc53579e3f 100644 --- a/gnu/libexec/uucp/libunix/work.c +++ b/gnu/libexec/uucp/libunix/work.c @@ -1,7 +1,7 @@ /* work.c Routines to read command files. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char work_rcsid[] = "$Id: work.c,v 1.1 1993/08/04 19:33:20 jtc Exp $"; +const char work_rcsid[] = "$Id: work.c,v 1.2 1994/10/24 22:19:54 jtc Exp $"; #endif #include "uudefs.h" @@ -55,10 +55,25 @@ static int iswork_cmp P((constpointer pkey, constpointer pdatum)); /* These functions can support multiple actions going on at once. This allows the UUCP package to send and receive multiple files at - the same time. This is a very flexible feature, but I'm not sure - it will actually be used all that much. + the same time. */ - The ssfile structure holds a command file name and all the lines +/* To avoid wasting a lot of time scanning the spool directory, which + might cause the remote system to time out, we limit each scan to + pick up at most a certain number of files. */ +#define COMMANDS_PER_SCAN (200) + +/* The ssfilename structure holds the name of a work file, as well as + its grade. */ + +struct ssfilename +{ + char *zfile; + char bgrade; + /* Some compiler may need this, and it won't normally hurt. */ + char bdummy; +}; + +/* The ssfile structure holds a command file name and all the lines read in from that command file. The union within the ssline structure initially holds a line from the file and then holds a pointer back to the ssfile structure; a pointer to this union is @@ -77,6 +92,9 @@ struct ssline struct ssfile { char *zfile; + char bgrade; + /* bdummy is needed for some buggy compilers. */ + char bdummy; int clines; int cdid; struct ssline aslines[CFILELINES]; @@ -84,7 +102,7 @@ struct ssfile /* Static variables for the work scan. */ -static char **azSwork_files; +static struct ssfilename *asSwork_files; static size_t cSwork_files; static size_t iSwork_file; static struct ssfile *qSwork_file; @@ -182,10 +200,10 @@ iswork_cmp (pkey, pdatum) constpointer pkey; constpointer pdatum; { - const char * const *pzkey = (const char * const *) pkey; - const char * const *pzdatum = (const char * const *) pdatum; + const struct ssfilename *qkey = (const struct ssfilename *) pkey; + const struct ssfilename *qdatum = (const struct ssfilename *) pdatum; - return strcmp (*pzkey, *pzdatum); + return strcmp (qkey->zfile, qdatum->zfile); } /* See whether there is any work to do for a particular system. */ @@ -309,7 +327,8 @@ fsysdep_get_work_init (qsys, bgrade) (bad) qsort implementations are very slow when given a sorted array, which causes particularly bad effects here. */ if (chad > 0) - qsort ((pointer) azSwork_files, chad, sizeof (char *), iswork_cmp); + qsort ((pointer) asSwork_files, chad, sizeof (struct ssfilename), + iswork_cmp); #if SPOOLDIR_SVR4 qgdir = qdir; @@ -342,6 +361,7 @@ fsysdep_get_work_init (qsys, bgrade) { char bfilegrade; char *zname; + struct ssfilename slook; #if ! SPOOLDIR_SVR4 zname = zbufcpy (qentry->d_name); @@ -350,13 +370,14 @@ fsysdep_get_work_init (qsys, bgrade) bfilegrade = qgentry->d_name[0]; #endif + slook.zfile = zname; if (! fswork_file (qsys->uuconf_zname, qentry->d_name, &bfilegrade) || UUCONF_GRADE_CMP (bgrade, bfilegrade) < 0 - || (azSwork_files != NULL - && bsearch ((pointer) &zname, - (pointer) azSwork_files, - chad, sizeof (char *), + || (asSwork_files != NULL + && bsearch ((pointer) &slook, + (pointer) asSwork_files, + chad, sizeof (struct ssfilename), iswork_cmp) != NULL)) ubuffree (zname); else @@ -368,18 +389,24 @@ fsysdep_get_work_init (qsys, bgrade) if (cSwork_files >= callocated) { callocated += CWORKFILES; - azSwork_files = - (char **) xrealloc ((pointer) azSwork_files, - callocated * sizeof (char *)); + asSwork_files = + ((struct ssfilename *) + xrealloc ((pointer) asSwork_files, + (callocated * sizeof (struct ssfilename)))); } - azSwork_files[cSwork_files] = zname; + asSwork_files[cSwork_files].zfile = zname; + asSwork_files[cSwork_files].bgrade = bfilegrade; ++cSwork_files; + if (cSwork_files - chad > COMMANDS_PER_SCAN) + break; } } #if SPOOLDIR_SVR4 closedir (qdir); + if (cSwork_files - chad > COMMANDS_PER_SCAN) + break; } qdir = qgdir; #endif @@ -389,10 +416,10 @@ fsysdep_get_work_init (qsys, bgrade) /* Sorting the files alphabetically will get the grades in the right order, since all the file prefixes are the same. */ - - if (cSwork_files > chad) - qsort ((pointer) (azSwork_files + chad), cSwork_files - chad, - sizeof (char *), iswork_cmp); + if (cSwork_files > iSwork_file) + qsort ((pointer) (asSwork_files + iSwork_file), + cSwork_files - iSwork_file, + sizeof (struct ssfilename), iswork_cmp); return TRUE; } @@ -417,7 +444,7 @@ fsysdep_get_work (qsys, bgrade, qcmd) if (qSwork_file != NULL && qSwork_file->cdid >= qSwork_file->clines) qSwork_file = NULL; - if (azSwork_files == NULL) + if (asSwork_files == NULL) { qcmd->bcmd = 'H'; return TRUE; @@ -437,6 +464,7 @@ fsysdep_get_work (qsys, bgrade, qcmd) char *zline; size_t cline; char *zname; + char bfilegrade; /* Read all the lines of a command file into memory. */ do @@ -464,7 +492,8 @@ fsysdep_get_work (qsys, bgrade, qcmd) return FALSE; } - zname = zsysdep_in_dir (zdir, azSwork_files[iSwork_file]); + zname = zsysdep_in_dir (zdir, asSwork_files[iSwork_file].zfile); + bfilegrade = asSwork_files[iSwork_file].bgrade; ++iSwork_file; @@ -521,6 +550,7 @@ fsysdep_get_work (qsys, bgrade, qcmd) } qfile->zfile = zname; + qfile->bgrade = bfilegrade; qfile->clines = iline; qfile->cdid = 0; qSwork_file = qfile; @@ -554,6 +584,7 @@ fsysdep_get_work (qsys, bgrade, qcmd) qSwork_file->aslines[iline].zline = NULL; continue; } + qcmd->bgrade = qSwork_file->bgrade; qSwork_file->aslines[iline].qfile = qSwork_file; qcmd->pseq = (pointer) (&qSwork_file->aslines[iline]); @@ -652,14 +683,14 @@ void usysdep_get_work_free (qsys) const struct uuconf_system *qsys; { - if (azSwork_files != NULL) + if (asSwork_files != NULL) { size_t i; for (i = 0; i < cSwork_files; i++) - ubuffree ((pointer) azSwork_files[i]); - xfree ((pointer) azSwork_files); - azSwork_files = NULL; + ubuffree ((pointer) asSwork_files[i].zfile); + xfree ((pointer) asSwork_files); + asSwork_files = NULL; cSwork_files = 0; iSwork_file = 0; } @@ -710,6 +741,7 @@ zsysdep_save_temp_file (pseq) if (! fsysdep_move_file (qline->ztemp, zto, TRUE, FALSE, FALSE, (const char *) NULL)) { + /* Leave the file where it was, not that is much help. */ ubuffree (zto); return "Could not move file to preservation directory"; } @@ -743,7 +775,7 @@ zsysdep_jobid (qsys, pseq) this is a remote file; returning -1 will cause zsfind_file to do the right thing. */ -char +int bsgrade (pseq) pointer pseq; { diff --git a/gnu/libexec/uucp/libunix/xqtfil.c b/gnu/libexec/uucp/libunix/xqtfil.c index 2cdcc185a00..cd632661392 100644 --- a/gnu/libexec/uucp/libunix/xqtfil.c +++ b/gnu/libexec/uucp/libunix/xqtfil.c @@ -1,7 +1,7 @@ /* xqtfil.c Routines to read execute files. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char xqtfil_rcsid[] = "$Id: xqtfil.c,v 1.1 1993/08/04 19:33:21 jtc Exp $"; +const char xqtfil_rcsid[] = "$Id: xqtfil.c,v 1.2 1994/10/24 22:19:55 jtc Exp $"; #endif #include "uudefs.h" @@ -144,9 +144,8 @@ zsysdep_get_xqt (pzsystem, pferr) return NULL; } - /* No system name may start with a dot (this is enforced by - tisystem in sysinf.c). This allows us to quickly skip - impossible directories. */ + /* No system name may start with a dot This allows us to + quickly skip impossible directories. */ if (qtop->d_name[0] == '.') continue; diff --git a/gnu/libexec/uucp/libunix/xqtsub.c b/gnu/libexec/uucp/libunix/xqtsub.c index 53e290a0d14..497a5a3bc96 100644 --- a/gnu/libexec/uucp/libunix/xqtsub.c +++ b/gnu/libexec/uucp/libunix/xqtsub.c @@ -1,7 +1,7 @@ /* xqtsub.c System dependent functions used only by uuxqt. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char xqtsub_rcsid[] = "$Id: xqtsub.c,v 1.1 1993/08/04 19:33:22 jtc Exp $"; +const char xqtsub_rcsid[] = "$Id: xqtsub.c,v 1.2 1994/10/24 22:19:57 jtc Exp $"; #endif #include "uudefs.h" @@ -89,6 +89,7 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr) boolean *pferr; { char **pz; + struct stat s; *pferr = FALSE; @@ -110,7 +111,16 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr) /* If we already have an absolute path, we can get out immediately. */ if (**pz == '/') - return zbufcpy (*pz); + { + /* Quick error check. */ + if (stat (*pz, &s) != 0) + { + ulog (LOG_ERROR, "%s: %s", *pz, strerror (errno)); + *pferr = TRUE; + return NULL; + } + return zbufcpy (*pz); + } break; } } @@ -124,14 +134,12 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr) for (pz = pzpath; *pz != NULL; pz++) { char *zname; - struct stat s; zname = zsysdep_in_dir (*pz, zcmd); if (stat (zname, &s) == 0) return zname; } - *pferr = FALSE; return NULL; } @@ -159,7 +167,8 @@ zsysdep_xqt_local_file (qsys, zfile) memcpy (zret, zfile + 1, clen); return zret; } - return zsysdep_local_file (zfile, qsys->uuconf_zpubdir); + return zsysdep_local_file (zfile, qsys->uuconf_zpubdir, + (boolean *) NULL); } #if ! ALLOW_FILENAME_ARGUMENTS @@ -177,9 +186,12 @@ fsysdep_xqt_check_file (qsys, zfile) { size_t clen; + /* Disallow exact "..", prefix "../", suffix "/..", internal "/../", + and restricted absolute paths. */ clen = strlen (zfile); - if ((clen == sizeof "../" - 1 - && strcmp (zfile, "../") == 0) + if ((clen == sizeof ".." - 1 + && strcmp (zfile, "..") == 0) + || strncmp (zfile, "../", sizeof "../" - 1) == 0 || (clen >= sizeof "/.." - 1 && strcmp (zfile + clen - (sizeof "/.." - 1), "/..") == 0) || strstr (zfile, "/../") != NULL @@ -358,7 +370,7 @@ fsysdep_execute (qsys, zuser, pazargs, zfullcmd, zinput, zoutput, /* Pass zchdir as zxqtdir, fnosigs as TRUE, fshell as TRUE if we aren't already using the shell. */ - ipid = ixsspawn (pazargs, aidescs, FALSE, FALSE, zxqtdir, TRUE, + ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, zxqtdir, TRUE, ! fshell, zpath, qsys->uuconf_zname, zuser); ierr = errno; diff --git a/gnu/libexec/uucp/libuuconf/MANIFEST b/gnu/libexec/uucp/libuuconf/MANIFEST index 8d1eb364663..98787b59489 100644 --- a/gnu/libexec/uucp/libuuconf/MANIFEST +++ b/gnu/libexec/uucp/libuuconf/MANIFEST @@ -61,6 +61,7 @@ rdlocs.c rdperm.c reliab.c remunk.c +runuxq.c sinfo.c snams.c split.c diff --git a/gnu/libexec/uucp/libuuconf/Makefile b/gnu/libexec/uucp/libuuconf/Makefile index be2fd9b9091..d264b084110 100644 --- a/gnu/libexec/uucp/libuuconf/Makefile +++ b/gnu/libexec/uucp/libuuconf/Makefile @@ -1,5 +1,5 @@ # This is the Makefile for the Taylor UUCP uuconf library -# $Id: Makefile,v 1.3 1993/10/28 05:00:19 cgd Exp $ +# $Id: Makefile,v 1.4 1994/10/24 22:20:16 jtc Exp $ LIB= uuconf SRCS= addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \ @@ -13,7 +13,7 @@ SRCS= addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \ snams.c split.c spool.c stafil.c syssub.c tcalou.c tdial.c \ tdialc.c tdnams.c tgcmp.c thread.c time.c tinit.c tlocnm.c \ tport.c tportc.c tsinfo.c tsnams.c tsys.c tval.c ugtlin.c \ - unk.c val.c vinit.c vport.c vsinfo.c vsnams.c vsys.c + unk.c val.c vinit.c vport.c vsinfo.c vsnams.c vsys.c runuxq.c CFLAGS+= -I$(.CURDIR)/../common_sources \ -DNEWCONFIGLIB=\"$(newconfigdir)\"\ -DOLDCONFIGLIB=\"$(oldconfigdir)\" diff --git a/gnu/libexec/uucp/libuuconf/README b/gnu/libexec/uucp/libuuconf/README index 64a5eecf03a..b9a2156c86d 100644 --- a/gnu/libexec/uucp/libuuconf/README +++ b/gnu/libexec/uucp/libuuconf/README @@ -1,8 +1,8 @@ This is the README file for the beta release of the uuconf library. It was written by Ian Lance Taylor. I can be reached at ian@airs.com, -or, equivalently, uunet!airs!ian, or c/o Infinity Development Systems, -P.O. Box 520, Waltham MA, 02254. +or, equivalently, uunet!cygint!airs!ian, or c/o Cygnus Support, 4th +Floor, Building 200, 1 Kendall Square, Cambridge MA, 02139, USA. This package is covered by the Gnu Library General Public License. See the file COPYING.LIB for details. If you would like to do diff --git a/gnu/libexec/uucp/libuuconf/addblk.c b/gnu/libexec/uucp/libuuconf/addblk.c index 6244dad875e..e499782b276 100644 --- a/gnu/libexec/uucp/libuuconf/addblk.c +++ b/gnu/libexec/uucp/libuuconf/addblk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_addblk_rcsid[] = "$Id: addblk.c,v 1.1 1993/08/04 19:33:31 jtc Exp $"; +const char _uuconf_addblk_rcsid[] = "$Id: addblk.c,v 1.2 1994/10/24 22:20:22 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/addstr.c b/gnu/libexec/uucp/libuuconf/addstr.c index 8498d502c9c..36e0e03dc2d 100644 --- a/gnu/libexec/uucp/libuuconf/addstr.c +++ b/gnu/libexec/uucp/libuuconf/addstr.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_addstr_rcsid[] = "$Id: addstr.c,v 1.1 1993/08/04 19:33:32 jtc Exp $"; +const char _uuconf_addstr_rcsid[] = "$Id: addstr.c,v 1.2 1994/10/24 22:20:25 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/allblk.c b/gnu/libexec/uucp/libuuconf/allblk.c index b3dd7e0a762..61168780d4c 100644 --- a/gnu/libexec/uucp/libuuconf/allblk.c +++ b/gnu/libexec/uucp/libuuconf/allblk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_allblk_rcsid[] = "$Id: allblk.c,v 1.1 1993/08/04 19:33:33 jtc Exp $"; +const char _uuconf_allblk_rcsid[] = "$Id: allblk.c,v 1.2 1994/10/24 22:20:27 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/alloc.c b/gnu/libexec/uucp/libuuconf/alloc.c index 2808c62088f..d89d331829c 100644 --- a/gnu/libexec/uucp/libuuconf/alloc.c +++ b/gnu/libexec/uucp/libuuconf/alloc.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_alloc_rcsid[] = "$Id: alloc.c,v 1.1 1993/08/04 19:33:34 jtc Exp $"; +const char _uuconf_alloc_rcsid[] = "$Id: alloc.c,v 1.2 1994/10/24 22:20:30 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/alloc.h b/gnu/libexec/uucp/libuuconf/alloc.h index c5c9cad8e32..d6949ab5005 100644 --- a/gnu/libexec/uucp/libuuconf/alloc.h +++ b/gnu/libexec/uucp/libuuconf/alloc.h @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ /* This header file is private to the uuconf memory allocation diff --git a/gnu/libexec/uucp/libuuconf/base.c b/gnu/libexec/uucp/libuuconf/base.c index c40f660523a..31f3afa42e3 100644 --- a/gnu/libexec/uucp/libuuconf/base.c +++ b/gnu/libexec/uucp/libuuconf/base.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_base_rcsid[] = "$Id: base.c,v 1.1 1993/08/04 19:33:38 jtc Exp $"; +const char _uuconf_base_rcsid[] = "$Id: base.c,v 1.2 1994/10/24 22:20:36 jtc Exp $"; #endif /* This turns a cmdtab_offset table into a uuconf_cmdtab table. Each diff --git a/gnu/libexec/uucp/libuuconf/bool.c b/gnu/libexec/uucp/libuuconf/bool.c index c1bbde13269..2562f8f8b23 100644 --- a/gnu/libexec/uucp/libuuconf/bool.c +++ b/gnu/libexec/uucp/libuuconf/bool.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_bool_rcsid[] = "$Id: bool.c,v 1.1 1993/08/04 19:33:40 jtc Exp $"; +const char _uuconf_bool_rcsid[] = "$Id: bool.c,v 1.2 1994/10/24 22:20:39 jtc Exp $"; #endif /* Parse a boolean string into a variable. This is called by diff --git a/gnu/libexec/uucp/libuuconf/callin.c b/gnu/libexec/uucp/libuuconf/callin.c index 4df26ddfddd..fed5f38becf 100644 --- a/gnu/libexec/uucp/libuuconf/callin.c +++ b/gnu/libexec/uucp/libuuconf/callin.c @@ -1,7 +1,7 @@ /* callin.c Check a login name and password against the UUCP password file. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,35 +20,46 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_callin_rcsid[] = "$Id: callin.c,v 1.1 1993/08/04 19:33:42 jtc Exp $"; +const char _uuconf_callin_rcsid[] = "$Id: callin.c,v 1.2 1994/10/24 22:20:42 jtc Exp $"; #endif #include <errno.h> -static int iplogin P((pointer pglobal, int argc, char **argv, +static int ipcheck P((pointer pglobal, int argc, char **argv, pointer pvar, pointer pinfo)); + +struct sinfo +{ + int (*pcmpfn) P((int, pointer, const char *)); + pointer pinfo; + boolean ffound; + boolean fmatched; +}; /* Check a login name and password against the UUCP password file. This looks at the Taylor UUCP password file, but will work even if - uuconf_taylor_init was not called. */ + uuconf_taylor_init was not called. It accepts either spaces or + colons as field delimiters. */ int -uuconf_callin (pglobal, zlogin, zpassword) +uuconf_callin (pglobal, pcmpfn, pinfo) pointer pglobal; - const char *zlogin; - const char *zpassword; + int (*pcmpfn) P((int, pointer, const char *)); + pointer pinfo; { struct sglobal *qglobal = (struct sglobal *) pglobal; int iret; char **pz; - struct uuconf_cmdtab as[2]; - char *zfilepass; + struct uuconf_cmdtab as[1]; + struct sinfo s; + char *zline; + size_t cline; /* If we have no password file names, fill in the default name. */ if (qglobal->qprocess->pzpwdfiles == NULL) @@ -66,14 +77,15 @@ uuconf_callin (pglobal, zlogin, zpassword) return iret; } - as[0].uuconf_zcmd = zlogin; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 2; - as[0].uuconf_pvar = (pointer) &zfilepass; - as[0].uuconf_pifn = iplogin; + as[0].uuconf_zcmd = NULL; - as[1].uuconf_zcmd = NULL; + s.pcmpfn = pcmpfn; + s.pinfo = pinfo; + s.ffound = FALSE; + s.fmatched = FALSE; - zfilepass = NULL; + zline = NULL; + cline = 0; iret = UUCONF_SUCCESS; @@ -91,52 +103,82 @@ uuconf_callin (pglobal, zlogin, zpassword) break; } - iret = uuconf_cmd_file (pglobal, e, as, (pointer) NULL, - (uuconf_cmdtabfn) NULL, - UUCONF_CMDTABFLAG_CASE, (pointer) NULL); + qglobal->ilineno = 0; + + iret = UUCONF_SUCCESS; + + while (getline (&zline, &cline, e) > 0) + { + char *zcolon; + + ++qglobal->ilineno; + + /* Turn the first two colon characters into spaces. This is + a hack to make Unix style passwd files work. */ + zcolon = strchr (zline, ':'); + if (zcolon != NULL) + { + *zcolon = ' '; + zcolon = strchr (zcolon, ':'); + if (zcolon != NULL) + *zcolon = ' '; + } + iret = uuconf_cmd_line (pglobal, zline, as, (pointer) &s, + ipcheck, 0, (pointer) NULL); + if ((iret & UUCONF_CMDTABRET_EXIT) != 0) + { + iret &=~ UUCONF_CMDTABRET_EXIT; + if (iret != UUCONF_SUCCESS) + iret |= UUCONF_ERROR_LINENO; + break; + } + + iret = UUCONF_SUCCESS; + } + (void) fclose (e); - if (iret != UUCONF_SUCCESS || zfilepass != NULL) + if (iret != UUCONF_SUCCESS || s.ffound) break; } + if (zline != NULL) + free ((pointer) zline); + if (iret != UUCONF_SUCCESS) { qglobal->zfilename = *pz; iret |= UUCONF_ERROR_FILENAME; } - else if (zfilepass == NULL - || strcmp (zfilepass, zpassword) != 0) + else if (! s.ffound || ! s.fmatched) iret = UUCONF_NOT_FOUND; - if (zfilepass != NULL) - free ((pointer) zfilepass); - return iret; } -/* This is called if it is the name we are looking for. The pvar - argument points to zfilepass, and we set it to the password. */ +/* This is called on each line of the file. It checks to see if the + login name from the file is the one we are looking for. If it is, + it sets ffound, and then sets fmatched according to whether the + password matches or not. */ static int -iplogin (pglobal, argc, argv, pvar, pinfo) +ipcheck (pglobal, argc, argv, pvar, pinfo) pointer pglobal; int argc; char **argv; pointer pvar; pointer pinfo; { - struct sglobal *qglobal = (struct sglobal *) pglobal; - char **pzpass = (char **) pvar; + struct sinfo *q = (struct sinfo *) pinfo; - *pzpass = strdup (argv[1]); - if (*pzpass == NULL) - { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); - } + if (argc != 2) + return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; + + if (! (*q->pcmpfn) (0, q->pinfo, argv[0])) + return UUCONF_CMDTABRET_CONTINUE; + + q->ffound = TRUE; + q->fmatched = (*q->pcmpfn) (1, q->pinfo, argv[1]) != 0; return UUCONF_CMDTABRET_EXIT; } diff --git a/gnu/libexec/uucp/libuuconf/calout.c b/gnu/libexec/uucp/libuuconf/calout.c index 957833ebc31..db8ef4b18e1 100644 --- a/gnu/libexec/uucp/libuuconf/calout.c +++ b/gnu/libexec/uucp/libuuconf/calout.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_calout_rcsid[] = "$Id: calout.c,v 1.1 1993/08/04 19:33:45 jtc Exp $"; +const char _uuconf_calout_rcsid[] = "$Id: calout.c,v 1.2 1994/10/24 22:20:44 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/chatc.c b/gnu/libexec/uucp/libuuconf/chatc.c index f29481b59a9..a310fee8f61 100644 --- a/gnu/libexec/uucp/libuuconf/chatc.c +++ b/gnu/libexec/uucp/libuuconf/chatc.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_chatc_rcsid[] = "$Id: chatc.c,v 1.1 1993/08/04 19:33:48 jtc Exp $"; +const char _uuconf_chatc_rcsid[] = "$Id: chatc.c,v 1.2 1994/10/24 22:20:47 jtc Exp $"; #endif #include <ctype.h> diff --git a/gnu/libexec/uucp/libuuconf/cmdarg.c b/gnu/libexec/uucp/libuuconf/cmdarg.c index 2020ea91a9f..cc6accdc807 100644 --- a/gnu/libexec/uucp/libuuconf/cmdarg.c +++ b/gnu/libexec/uucp/libuuconf/cmdarg.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_cmdarg_rcsid[] = "$Id: cmdarg.c,v 1.1 1993/08/04 19:33:50 jtc Exp $"; +const char _uuconf_cmdarg_rcsid[] = "$Id: cmdarg.c,v 1.2 1994/10/24 22:20:49 jtc Exp $"; #endif #include <ctype.h> diff --git a/gnu/libexec/uucp/libuuconf/cmdfil.c b/gnu/libexec/uucp/libuuconf/cmdfil.c index 333a4bf3764..14a994f0279 100644 --- a/gnu/libexec/uucp/libuuconf/cmdfil.c +++ b/gnu/libexec/uucp/libuuconf/cmdfil.c @@ -1,7 +1,7 @@ /* cmdfil.c Read and parse commands from a file. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_cmdfil_rcsid[] = "$Id: cmdfil.c,v 1.1 1993/08/04 19:33:51 jtc Exp $"; +const char _uuconf_cmdfil_rcsid[] = "$Id: cmdfil.c,v 1.2 1994/10/24 22:20:53 jtc Exp $"; #endif #include <errno.h> @@ -99,5 +99,8 @@ uuconf_cmd_file (pglobal, e, qtab, pinfo, pfiunknown, iflags, pblock) iret = UUCONF_SUCCESS; } + if (zline != NULL) + free ((pointer) zline); + return iret; } diff --git a/gnu/libexec/uucp/libuuconf/cmdlin.c b/gnu/libexec/uucp/libuuconf/cmdlin.c index 63e95646731..0850010f1ac 100644 --- a/gnu/libexec/uucp/libuuconf/cmdlin.c +++ b/gnu/libexec/uucp/libuuconf/cmdlin.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_cmdlin_rcsid[] = "$Id: cmdlin.c,v 1.1 1993/08/04 19:33:52 jtc Exp $"; +const char _uuconf_cmdlin_rcsid[] = "$Id: cmdlin.c,v 1.2 1994/10/24 22:20:56 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/debfil.c b/gnu/libexec/uucp/libuuconf/debfil.c index 3be5381e5df..80b7444307d 100644 --- a/gnu/libexec/uucp/libuuconf/debfil.c +++ b/gnu/libexec/uucp/libuuconf/debfil.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_debfil_rcsid[] = "$Id: debfil.c,v 1.1 1993/08/04 19:33:53 jtc Exp $"; +const char _uuconf_debfil_rcsid[] = "$Id: debfil.c,v 1.2 1994/10/24 22:20:58 jtc Exp $"; #endif /* Get the name of the UUCP debugging file. */ diff --git a/gnu/libexec/uucp/libuuconf/deblev.c b/gnu/libexec/uucp/libuuconf/deblev.c index 40cf763b100..53e87ea7e0c 100644 --- a/gnu/libexec/uucp/libuuconf/deblev.c +++ b/gnu/libexec/uucp/libuuconf/deblev.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_deblev_rcsid[] = "$Id: deblev.c,v 1.1 1993/08/04 19:33:54 jtc Exp $"; +const char _uuconf_deblev_rcsid[] = "$Id: deblev.c,v 1.2 1994/10/24 22:21:00 jtc Exp $"; #endif /* Get the UUCP debugging level. */ diff --git a/gnu/libexec/uucp/libuuconf/diacod.c b/gnu/libexec/uucp/libuuconf/diacod.c index 823239d953b..36837945b04 100644 --- a/gnu/libexec/uucp/libuuconf/diacod.c +++ b/gnu/libexec/uucp/libuuconf/diacod.c @@ -1,7 +1,7 @@ /* diacod.c Translate a dialcode. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_diacod_rcsid[] = "$Id: diacod.c,v 1.1 1993/08/04 19:33:55 jtc Exp $"; +const char _uuconf_diacod_rcsid[] = "$Id: diacod.c,v 1.2 1994/10/24 22:21:03 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/dial.c b/gnu/libexec/uucp/libuuconf/dial.c index efdef538c32..98cb93219cc 100644 --- a/gnu/libexec/uucp/libuuconf/dial.c +++ b/gnu/libexec/uucp/libuuconf/dial.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_dial_rcsid[] = "$Id: dial.c,v 1.1 1993/08/04 19:33:57 jtc Exp $"; +const char _uuconf_dial_rcsid[] = "$Id: dial.c,v 1.2 1994/10/24 22:21:06 jtc Exp $"; #endif /* Find a dialer by name. */ diff --git a/gnu/libexec/uucp/libuuconf/diasub.c b/gnu/libexec/uucp/libuuconf/diasub.c index 7979d0ebd21..af99a69051b 100644 --- a/gnu/libexec/uucp/libuuconf/diasub.c +++ b/gnu/libexec/uucp/libuuconf/diasub.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_diasub_rcsid[] = "$Id: diasub.c,v 1.1 1993/08/04 19:33:58 jtc Exp $"; +const char _uuconf_diasub_rcsid[] = "$Id: diasub.c,v 1.2 1994/10/24 22:21:09 jtc Exp $"; #endif /* Clear the information in a dialer. */ diff --git a/gnu/libexec/uucp/libuuconf/dnams.c b/gnu/libexec/uucp/libuuconf/dnams.c index 6a10ada811a..48ab776d523 100644 --- a/gnu/libexec/uucp/libuuconf/dnams.c +++ b/gnu/libexec/uucp/libuuconf/dnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_dnams_rcsid[] = "$Id: dnams.c,v 1.1 1993/08/04 19:33:59 jtc Exp $"; +const char _uuconf_dnams_rcsid[] = "$Id: dnams.c,v 1.2 1994/10/24 22:21:15 jtc Exp $"; #endif /* Get all known dialer names. */ diff --git a/gnu/libexec/uucp/libuuconf/errno.c b/gnu/libexec/uucp/libuuconf/errno.c index d1def82ca3c..61ca6075b8d 100644 --- a/gnu/libexec/uucp/libuuconf/errno.c +++ b/gnu/libexec/uucp/libuuconf/errno.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_errno_rcsid[] = "$Id: errno.c,v 1.1 1993/08/04 19:34:01 jtc Exp $"; +const char _uuconf_errno_rcsid[] = "$Id: errno.c,v 1.2 1994/10/24 22:21:26 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/errstr.c b/gnu/libexec/uucp/libuuconf/errstr.c index 2bed403f258..ecbf6156815 100644 --- a/gnu/libexec/uucp/libuuconf/errstr.c +++ b/gnu/libexec/uucp/libuuconf/errstr.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_errstr_rcsid[] = "$Id: errstr.c,v 1.1 1993/08/04 19:34:02 jtc Exp $"; +const char _uuconf_errstr_rcsid[] = "$Id: errstr.c,v 1.2 1994/10/24 22:21:32 jtc Exp $"; #endif static char *zeprint_num P((char *zbuf, size_t cbuf, int ival)); diff --git a/gnu/libexec/uucp/libuuconf/filnam.c b/gnu/libexec/uucp/libuuconf/filnam.c index ab1b76a51d2..f1c7253ffa8 100644 --- a/gnu/libexec/uucp/libuuconf/filnam.c +++ b/gnu/libexec/uucp/libuuconf/filnam.c @@ -20,18 +20,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_filnam_rcsid[] = "$Id: filnam.c,v 1.1 1993/08/04 19:34:03 jtc Exp $"; +const char _uuconf_filnam_rcsid[] = "$Id: filnam.c,v 1.2 1994/10/24 22:21:37 jtc Exp $"; #endif /* Return the saved file name. */ -const char * +UUCONF_CONST char * uuconf_error_filename (pglobal) pointer pglobal; { diff --git a/gnu/libexec/uucp/libuuconf/freblk.c b/gnu/libexec/uucp/libuuconf/freblk.c index cb27d115c05..6e66c5c0dab 100644 --- a/gnu/libexec/uucp/libuuconf/freblk.c +++ b/gnu/libexec/uucp/libuuconf/freblk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_freblk_rcsid[] = "$Id: freblk.c,v 1.1 1993/08/04 19:34:05 jtc Exp $"; +const char _uuconf_freblk_rcsid[] = "$Id: freblk.c,v 1.2 1994/10/24 22:21:42 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/fredia.c b/gnu/libexec/uucp/libuuconf/fredia.c index 60b00b7cf88..d2fad1df9de 100644 --- a/gnu/libexec/uucp/libuuconf/fredia.c +++ b/gnu/libexec/uucp/libuuconf/fredia.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_fredia_rcsid[] = "$Id: fredia.c,v 1.1 1993/08/04 19:34:08 jtc Exp $"; +const char _uuconf_fredia_rcsid[] = "$Id: fredia.c,v 1.2 1994/10/24 22:21:47 jtc Exp $"; #endif /* Free the memory allocated for a dialer. */ diff --git a/gnu/libexec/uucp/libuuconf/free.c b/gnu/libexec/uucp/libuuconf/free.c index 91916f1d3ca..e1774784896 100644 --- a/gnu/libexec/uucp/libuuconf/free.c +++ b/gnu/libexec/uucp/libuuconf/free.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_free_rcsid[] = "$Id: free.c,v 1.1 1993/08/04 19:34:10 jtc Exp $"; +const char _uuconf_free_rcsid[] = "$Id: free.c,v 1.2 1994/10/24 22:21:53 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/freprt.c b/gnu/libexec/uucp/libuuconf/freprt.c index 2906b9dc836..7a13d12f9a4 100644 --- a/gnu/libexec/uucp/libuuconf/freprt.c +++ b/gnu/libexec/uucp/libuuconf/freprt.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_freprt_rcsid[] = "$Id: freprt.c,v 1.1 1993/08/04 19:34:12 jtc Exp $"; +const char _uuconf_freprt_rcsid[] = "$Id: freprt.c,v 1.2 1994/10/24 22:21:59 jtc Exp $"; #endif /* Free the memory allocated for a port. */ diff --git a/gnu/libexec/uucp/libuuconf/fresys.c b/gnu/libexec/uucp/libuuconf/fresys.c index a73f4c1bc8c..26a57e033a4 100644 --- a/gnu/libexec/uucp/libuuconf/fresys.c +++ b/gnu/libexec/uucp/libuuconf/fresys.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_fresys_rcsid[] = "$Id: fresys.c,v 1.1 1993/08/04 19:34:13 jtc Exp $"; +const char _uuconf_fresys_rcsid[] = "$Id: fresys.c,v 1.2 1994/10/24 22:22:04 jtc Exp $"; #endif /* Free the memory allocated for a system. */ diff --git a/gnu/libexec/uucp/libuuconf/grdcmp.c b/gnu/libexec/uucp/libuuconf/grdcmp.c index 8b02ff9963a..a84e1d5e4a9 100644 --- a/gnu/libexec/uucp/libuuconf/grdcmp.c +++ b/gnu/libexec/uucp/libuuconf/grdcmp.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_grdcmp_rcsid[] = "$Id: grdcmp.c,v 1.1 1993/08/04 19:34:14 jtc Exp $"; +const char _uuconf_grdcmp_rcsid[] = "$Id: grdcmp.c,v 1.2 1994/10/24 22:22:08 jtc Exp $"; #endif #include <ctype.h> diff --git a/gnu/libexec/uucp/libuuconf/hdial.c b/gnu/libexec/uucp/libuuconf/hdial.c index 666cc7f62ee..d1ecac91f5c 100644 --- a/gnu/libexec/uucp/libuuconf/hdial.c +++ b/gnu/libexec/uucp/libuuconf/hdial.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hdial_rcsid[] = "$Id: hdial.c,v 1.1 1993/08/04 19:34:15 jtc Exp $"; +const char _uuconf_hdial_rcsid[] = "$Id: hdial.c,v 1.2 1994/10/24 22:22:11 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/hdnams.c b/gnu/libexec/uucp/libuuconf/hdnams.c index 0806059214e..ef14baeb4cb 100644 --- a/gnu/libexec/uucp/libuuconf/hdnams.c +++ b/gnu/libexec/uucp/libuuconf/hdnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hdnams_rcsid[] = "$Id: hdnams.c,v 1.1 1993/08/04 19:34:16 jtc Exp $"; +const char _uuconf_hdnams_rcsid[] = "$Id: hdnams.c,v 1.2 1994/10/24 22:22:16 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/hinit.c b/gnu/libexec/uucp/libuuconf/hinit.c index 2b1c1cc6fa3..192d9cfc446 100644 --- a/gnu/libexec/uucp/libuuconf/hinit.c +++ b/gnu/libexec/uucp/libuuconf/hinit.c @@ -1,7 +1,7 @@ /* hinit.c Initialize for reading HDB configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1994 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hinit_rcsid[] = "$Id: hinit.c,v 1.1 1993/08/04 19:34:17 jtc Exp $"; +const char _uuconf_hinit_rcsid[] = "$Id: hinit.c,v 1.2 1994/10/24 22:22:23 jtc Exp $"; #endif #include <errno.h> @@ -125,7 +125,7 @@ uuconf_hdb_init (ppglobal, zprogram) --cchars; if (zline[cchars] == '\n') zline[cchars] = '\0'; - if (isspace (BUCHAR (zline[0])) || zline[0] == '#') + if (zline[0] == '#') continue; ctypes = _uuconf_istrsplit (zline, '\0', &pzargs, &cargs); diff --git a/gnu/libexec/uucp/libuuconf/hlocnm.c b/gnu/libexec/uucp/libuuconf/hlocnm.c index 9af4d7e7a51..288ab109368 100644 --- a/gnu/libexec/uucp/libuuconf/hlocnm.c +++ b/gnu/libexec/uucp/libuuconf/hlocnm.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hlocnm_rcsid[] = "$Id: hlocnm.c,v 1.1 1993/08/04 19:34:18 jtc Exp $"; +const char _uuconf_hlocnm_rcsid[] = "$Id: hlocnm.c,v 1.2 1994/10/24 22:22:28 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/hport.c b/gnu/libexec/uucp/libuuconf/hport.c index 690de91fc24..18a5b027f66 100644 --- a/gnu/libexec/uucp/libuuconf/hport.c +++ b/gnu/libexec/uucp/libuuconf/hport.c @@ -1,7 +1,7 @@ /* hport.c Find a port in the HDB configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hport_rcsid[] = "$Id: hport.c,v 1.1 1993/08/04 19:34:20 jtc Exp $"; +const char _uuconf_hport_rcsid[] = "$Id: hport.c,v 1.2 1994/10/24 22:22:38 jtc Exp $"; #endif #include <errno.h> @@ -85,6 +85,7 @@ uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) char *z, *zprotos, *zport; long ilow, ihigh; pointer pblock; + char ***ppzdialer; ++qglobal->ilineno; @@ -202,6 +203,9 @@ uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT; qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1]; qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow; + qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; + qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; + ppzdialer = NULL; } else if (strcmp (pzsplit[0], "TCP") == 0) { @@ -213,43 +217,23 @@ uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX | UUCONF_RELIABLE_SPECIFIED); qport->uuconf_u.uuconf_stcp.uuconf_zport = pzsplit[1]; + ppzdialer = &qport->uuconf_u.uuconf_stcp.uuconf_pzdialer; } else if (ctoks >= 5 && (strcmp (pzsplit[4], "TLI") == 0 || strcmp (pzsplit[4], "TLIS") == 0)) { - size_t c; - char **pzd; - qport->uuconf_ttype = UUCONF_PORTTYPE_TLI; qport->uuconf_u.uuconf_stli.uuconf_zdevice = pzsplit[1]; qport->uuconf_u.uuconf_stli.uuconf_fstream = strcmp (pzsplit[4], "TLIS") == 0; qport->uuconf_u.uuconf_stli.uuconf_pzpush = NULL; - pblock = uuconf_malloc_block (); - if (pblock == NULL) - { - qglobal->ierrno = errno; - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - c = (ctoks - 4) * sizeof (char *); - pzd = (char **) uuconf_malloc (pblock, c + sizeof (char *)); - if (pzd == NULL) - { - qglobal->ierrno = errno; - uuconf_free_block (pblock); - iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; - break; - } - memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c); - pzd[ctoks - 4] = NULL; - qport->uuconf_u.uuconf_stli.uuconf_pzdialer = pzd; qport->uuconf_u.uuconf_stli.uuconf_zservaddr = NULL; qport->uuconf_ireliable = (UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX | UUCONF_RELIABLE_SPECIFIED); + ppzdialer = &qport->uuconf_u.uuconf_stli.uuconf_pzdialer; } else { @@ -273,8 +257,15 @@ uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh; } qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; + qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; + qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; + ppzdialer = &qport->uuconf_u.uuconf_smodem.uuconf_pzdialer; + } + + if (ppzdialer != NULL) + { if (ctoks < 5) - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL; + *ppzdialer = NULL; else { size_t c; @@ -299,9 +290,8 @@ uuconf_hdb_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) memcpy ((pointer) pzd, (pointer) (pzsplit + 4), c); pzd[ctoks - 4] = NULL; - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = pzd; + *ppzdialer = pzd; } - qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; } if (pifn != NULL) diff --git a/gnu/libexec/uucp/libuuconf/hrmunk.c b/gnu/libexec/uucp/libuuconf/hrmunk.c index e7516f7e784..d2790f3b178 100644 --- a/gnu/libexec/uucp/libuuconf/hrmunk.c +++ b/gnu/libexec/uucp/libuuconf/hrmunk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hrmunk_rcsid[] = "$Id: hrmunk.c,v 1.1 1993/08/04 19:34:22 jtc Exp $"; +const char _uuconf_hrmunk_rcsid[] = "$Id: hrmunk.c,v 1.2 1994/10/24 22:22:45 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/hsinfo.c b/gnu/libexec/uucp/libuuconf/hsinfo.c index 83129a3e706..f99239e6b1a 100644 --- a/gnu/libexec/uucp/libuuconf/hsinfo.c +++ b/gnu/libexec/uucp/libuuconf/hsinfo.c @@ -1,7 +1,7 @@ /* hsinfo.c Get information about a system from the HDB configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hsinfo_rcsid[] = "$Id: hsinfo.c,v 1.1 1993/08/04 19:34:24 jtc Exp $"; +const char _uuconf_hsinfo_rcsid[] = "$Id: hsinfo.c,v 1.2 1994/10/24 22:22:52 jtc Exp $"; #endif #include <errno.h> @@ -112,6 +112,8 @@ _uuconf_ihdb_system_internal (qglobal, zsystem, qsys) FILE *e; int cchars; + qglobal->ilineno = 0; + e = fopen (*pz, "r"); if (e == NULL) { @@ -122,8 +124,6 @@ _uuconf_ihdb_system_internal (qglobal, zsystem, qsys) break; } - qglobal->ilineno = 0; - while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) { int ctoks, ctimes, i; @@ -258,6 +258,11 @@ _uuconf_ihdb_system_internal (qglobal, zsystem, qsys) pblock); if (iret != UUCONF_SUCCESS) break; + + /* Treat any time/grade setting as both a timegrade and + a call-timegrade. */ + if (bgrade != UUCONF_GRADE_LOW) + qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade; } if (iret != UUCONF_SUCCESS) @@ -355,7 +360,7 @@ _uuconf_ihdb_system_internal (qglobal, zsystem, qsys) if (iret != UUCONF_SUCCESS) { qglobal->zfilename = *pz; - return iret | UUCONF_ERROR_FILENAME; + return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO; } if (pblock == NULL) diff --git a/gnu/libexec/uucp/libuuconf/hsnams.c b/gnu/libexec/uucp/libuuconf/hsnams.c index de003a3ec5e..128f754ad17 100644 --- a/gnu/libexec/uucp/libuuconf/hsnams.c +++ b/gnu/libexec/uucp/libuuconf/hsnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hsnams_rcsid[] = "$Id: hsnams.c,v 1.1 1993/08/04 19:34:26 jtc Exp $"; +const char _uuconf_hsnams_rcsid[] = "$Id: hsnams.c,v 1.2 1994/10/24 22:23:00 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/hsys.c b/gnu/libexec/uucp/libuuconf/hsys.c index 676c20ff0e3..b5dbd793384 100644 --- a/gnu/libexec/uucp/libuuconf/hsys.c +++ b/gnu/libexec/uucp/libuuconf/hsys.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hsys_rcsid[] = "$Id: hsys.c,v 1.1 1993/08/04 19:34:29 jtc Exp $"; +const char _uuconf_hsys_rcsid[] = "$Id: hsys.c,v 1.2 1994/10/24 22:23:06 jtc Exp $"; #endif /* Get system information from the HDB configuration files. This is a diff --git a/gnu/libexec/uucp/libuuconf/hunk.c b/gnu/libexec/uucp/libuuconf/hunk.c index 8e997d0b710..dfeb1c63a5c 100644 --- a/gnu/libexec/uucp/libuuconf/hunk.c +++ b/gnu/libexec/uucp/libuuconf/hunk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_hunk_rcsid[] = "$Id: hunk.c,v 1.1 1993/08/04 19:34:31 jtc Exp $"; +const char _uuconf_hunk_rcsid[] = "$Id: hunk.c,v 1.2 1994/10/24 22:23:13 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/iniglb.c b/gnu/libexec/uucp/libuuconf/iniglb.c index 2422656efc4..1c582c513e2 100644 --- a/gnu/libexec/uucp/libuuconf/iniglb.c +++ b/gnu/libexec/uucp/libuuconf/iniglb.c @@ -1,7 +1,7 @@ /* iniglb.c Initialize the global information structure. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1994 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_iniglb_rcsid[] = "$Id: iniglb.c,v 1.1 1993/08/04 19:34:33 jtc Exp $"; +const char _uuconf_iniglb_rcsid[] = "$Id: iniglb.c,v 1.2 1994/10/24 22:23:16 jtc Exp $"; #endif #include <errno.h> @@ -84,6 +84,7 @@ _uuconf_iinit_global (pqglobal) qprocess->zdebugfile = DEBUGFILE; qprocess->zdebug = ""; qprocess->cmaxuuxqts = 0; + qprocess->zrunuuxqt = NULL; qprocess->fv2 = TRUE; qprocess->fhdb = TRUE; qprocess->pzdialcodefiles = NULL; diff --git a/gnu/libexec/uucp/libuuconf/init.c b/gnu/libexec/uucp/libuuconf/init.c index ef252a78245..bb7a51b8914 100644 --- a/gnu/libexec/uucp/libuuconf/init.c +++ b/gnu/libexec/uucp/libuuconf/init.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_init_rcsid[] = "$Id: init.c,v 1.1 1993/08/04 19:34:35 jtc Exp $"; +const char _uuconf_init_rcsid[] = "$Id: init.c,v 1.2 1994/10/24 22:23:18 jtc Exp $"; #endif /* Initialize the UUCP configuration file reading routines. This is diff --git a/gnu/libexec/uucp/libuuconf/int.c b/gnu/libexec/uucp/libuuconf/int.c index b0047ee6c09..05385aea8fe 100644 --- a/gnu/libexec/uucp/libuuconf/int.c +++ b/gnu/libexec/uucp/libuuconf/int.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_int_rcsid[] = "$Id: int.c,v 1.1 1993/08/04 19:34:37 jtc Exp $"; +const char _uuconf_int_rcsid[] = "$Id: int.c,v 1.2 1994/10/24 22:23:22 jtc Exp $"; #endif /* Parse a string into a variable. This is called by uuconf_cmd_args, diff --git a/gnu/libexec/uucp/libuuconf/lckdir.c b/gnu/libexec/uucp/libuuconf/lckdir.c index 52d1a9fc733..671241531c9 100644 --- a/gnu/libexec/uucp/libuuconf/lckdir.c +++ b/gnu/libexec/uucp/libuuconf/lckdir.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_lckdir_rcsid[] = "$Id: lckdir.c,v 1.1 1993/08/04 19:34:39 jtc Exp $"; +const char _uuconf_lckdir_rcsid[] = "$Id: lckdir.c,v 1.2 1994/10/24 22:23:24 jtc Exp $"; #endif /* Get the name of the UUCP lock directory. */ diff --git a/gnu/libexec/uucp/libuuconf/lineno.c b/gnu/libexec/uucp/libuuconf/lineno.c index 77839f6ede4..2e67f88b8d9 100644 --- a/gnu/libexec/uucp/libuuconf/lineno.c +++ b/gnu/libexec/uucp/libuuconf/lineno.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_lineno_rcsid[] = "$Id: lineno.c,v 1.1 1993/08/04 19:34:41 jtc Exp $"; +const char _uuconf_lineno_rcsid[] = "$Id: lineno.c,v 1.2 1994/10/24 22:23:26 jtc Exp $"; #endif /* Return the saved line number. */ diff --git a/gnu/libexec/uucp/libuuconf/llocnm.c b/gnu/libexec/uucp/libuuconf/llocnm.c index 272d6237e97..0736a4a5c8f 100644 --- a/gnu/libexec/uucp/libuuconf/llocnm.c +++ b/gnu/libexec/uucp/libuuconf/llocnm.c @@ -1,7 +1,7 @@ /* llocnm.c Get the local name to use, given a login name. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_llocnm_rcsid[] = "$Id: llocnm.c,v 1.1 1993/08/04 19:34:43 jtc Exp $"; +const char _uuconf_llocnm_rcsid[] = "$Id: llocnm.c,v 1.2 1994/10/24 22:23:30 jtc Exp $"; #endif #include <errno.h> @@ -49,9 +49,12 @@ uuconf_login_localname (pglobal, zlogin, pzname) #endif #if HAVE_HDB_CONFIG - iret = uuconf_hdb_login_localname (pglobal, zlogin, pzname); - if (iret != UUCONF_NOT_FOUND) - return iret; + if (qglobal->qprocess->fhdb) + { + iret = uuconf_hdb_login_localname (pglobal, zlogin, pzname); + if (iret != UUCONF_NOT_FOUND) + return iret; + } #endif if (qglobal->qprocess->zlocalname != NULL) diff --git a/gnu/libexec/uucp/libuuconf/local.c b/gnu/libexec/uucp/libuuconf/local.c index 33adda40b0c..43c8ddf9df0 100644 --- a/gnu/libexec/uucp/libuuconf/local.c +++ b/gnu/libexec/uucp/libuuconf/local.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_local_rcsid[] = "$Id: local.c,v 1.1 1993/08/04 19:34:45 jtc Exp $"; +const char _uuconf_local_rcsid[] = "$Id: local.c,v 1.2 1994/10/24 22:23:35 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/locnm.c b/gnu/libexec/uucp/libuuconf/locnm.c index 1bc165b73f9..37693b86cfa 100644 --- a/gnu/libexec/uucp/libuuconf/locnm.c +++ b/gnu/libexec/uucp/libuuconf/locnm.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_locnm_rcsid[] = "$Id: locnm.c,v 1.1 1993/08/04 19:34:47 jtc Exp $"; +const char _uuconf_locnm_rcsid[] = "$Id: locnm.c,v 1.2 1994/10/24 22:23:37 jtc Exp $"; #endif /* Get the local node name. */ diff --git a/gnu/libexec/uucp/libuuconf/logfil.c b/gnu/libexec/uucp/libuuconf/logfil.c index 6d76764faa9..1a2c499fadd 100644 --- a/gnu/libexec/uucp/libuuconf/logfil.c +++ b/gnu/libexec/uucp/libuuconf/logfil.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_logfil_rcsid[] = "$Id: logfil.c,v 1.1 1993/08/04 19:34:48 jtc Exp $"; +const char _uuconf_logfil_rcsid[] = "$Id: logfil.c,v 1.2 1994/10/24 22:23:39 jtc Exp $"; #endif /* Get the name of the UUCP log file. */ diff --git a/gnu/libexec/uucp/libuuconf/maxuxq.c b/gnu/libexec/uucp/libuuconf/maxuxq.c index 8b5e9e7064b..ee97b8f7934 100644 --- a/gnu/libexec/uucp/libuuconf/maxuxq.c +++ b/gnu/libexec/uucp/libuuconf/maxuxq.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_maxuxq_rcsid[] = "$Id: maxuxq.c,v 1.1 1993/08/04 19:34:49 jtc Exp $"; +const char _uuconf_maxuxq_rcsid[] = "$Id: maxuxq.c,v 1.2 1994/10/24 22:23:41 jtc Exp $"; #endif /* Get the maximum number of simultaneous uuxqt executions. When diff --git a/gnu/libexec/uucp/libuuconf/mrgblk.c b/gnu/libexec/uucp/libuuconf/mrgblk.c index 4b2ea1c5744..2e796eb60e6 100644 --- a/gnu/libexec/uucp/libuuconf/mrgblk.c +++ b/gnu/libexec/uucp/libuuconf/mrgblk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_mrgblk_rcsid[] = "$Id: mrgblk.c,v 1.1 1993/08/04 19:34:50 jtc Exp $"; +const char _uuconf_mrgblk_rcsid[] = "$Id: mrgblk.c,v 1.2 1994/10/24 22:23:45 jtc Exp $"; #endif #include "alloc.h" diff --git a/gnu/libexec/uucp/libuuconf/paramc.c b/gnu/libexec/uucp/libuuconf/paramc.c index bcc9a0be7b2..0dd482ce233 100644 --- a/gnu/libexec/uucp/libuuconf/paramc.c +++ b/gnu/libexec/uucp/libuuconf/paramc.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_paramc_rcsid[] = "$Id: paramc.c,v 1.1 1993/08/04 19:34:51 jtc Exp $"; +const char _uuconf_paramc_rcsid[] = "$Id: paramc.c,v 1.2 1994/10/24 22:23:50 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/port.c b/gnu/libexec/uucp/libuuconf/port.c index 586c2269442..1d22ed8cee8 100644 --- a/gnu/libexec/uucp/libuuconf/port.c +++ b/gnu/libexec/uucp/libuuconf/port.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_port_rcsid[] = "$Id: port.c,v 1.1 1993/08/04 19:34:52 jtc Exp $"; +const char _uuconf_port_rcsid[] = "$Id: port.c,v 1.2 1994/10/24 22:23:55 jtc Exp $"; #endif /* Find a port by name, baud rate, and special purpose function. */ diff --git a/gnu/libexec/uucp/libuuconf/prtsub.c b/gnu/libexec/uucp/libuuconf/prtsub.c index 682f38e6873..3d874c0d931 100644 --- a/gnu/libexec/uucp/libuuconf/prtsub.c +++ b/gnu/libexec/uucp/libuuconf/prtsub.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_prtsub_rcsid[] = "$Id: prtsub.c,v 1.1 1993/08/04 19:34:53 jtc Exp $"; +const char _uuconf_prtsub_rcsid[] = "$Id: prtsub.c,v 1.2 1994/10/24 22:23:59 jtc Exp $"; #endif /* Clear the information in a port. This can only clear the type diff --git a/gnu/libexec/uucp/libuuconf/pubdir.c b/gnu/libexec/uucp/libuuconf/pubdir.c index 0c4714d466f..dffaa749828 100644 --- a/gnu/libexec/uucp/libuuconf/pubdir.c +++ b/gnu/libexec/uucp/libuuconf/pubdir.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_pubdir_rcsid[] = "$Id: pubdir.c,v 1.1 1993/08/04 19:34:54 jtc Exp $"; +const char _uuconf_pubdir_rcsid[] = "$Id: pubdir.c,v 1.2 1994/10/24 22:24:02 jtc Exp $"; #endif /* Get the name of the UUCP public directory. */ diff --git a/gnu/libexec/uucp/libuuconf/rdlocs.c b/gnu/libexec/uucp/libuuconf/rdlocs.c index ba8365fd7bf..e94203e1063 100644 --- a/gnu/libexec/uucp/libuuconf/rdlocs.c +++ b/gnu/libexec/uucp/libuuconf/rdlocs.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_rdlocs_rcsid[] = "$Id: rdlocs.c,v 1.1 1993/08/04 19:34:55 jtc Exp $"; +const char _uuconf_rdlocs_rcsid[] = "$Id: rdlocs.c,v 1.2 1994/10/24 22:24:06 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/rdperm.c b/gnu/libexec/uucp/libuuconf/rdperm.c index dd481c1a8e5..e0f8f687dff 100644 --- a/gnu/libexec/uucp/libuuconf/rdperm.c +++ b/gnu/libexec/uucp/libuuconf/rdperm.c @@ -1,7 +1,7 @@ /* rdperm.c Read the HDB Permissions file. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_rdperm_rcsid[] = "$Id: rdperm.c,v 1.1 1993/08/04 19:34:57 jtc Exp $"; +const char _uuconf_rdperm_rcsid[] = "$Id: rdperm.c,v 1.2 1994/10/24 22:24:11 jtc Exp $"; #endif #include <errno.h> @@ -165,7 +165,7 @@ _uuconf_ihread_permissions (qglobal) --cchars; if (zline[cchars] == '\n') zline[cchars] = '\0'; - if (isspace (BUCHAR (zline[0])) || zline[0] == '#') + if (zline[0] == '#') continue; centries = _uuconf_istrsplit (zline, '\0', &pzsplit, &csplit); @@ -427,19 +427,25 @@ ihadd_norw (qglobal, ppz, pzno) char *znew; int iret; - csize = strlen (*pz) + 1; - znew = (char *) uuconf_malloc (qglobal->pblock, csize + 1); - if (znew == NULL) + /* Ignore an attempt to say NOREAD or NOWRITE with an empty + string, since it will be interpreted as an attempt to deny + everything. */ + if (**pz != '\0') { - qglobal->ierrno = errno; - return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; + csize = strlen (*pz) + 1; + znew = (char *) uuconf_malloc (qglobal->pblock, csize + 1); + if (znew == NULL) + { + qglobal->ierrno = errno; + return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; + } + znew[0] = '!'; + memcpy ((pointer) (znew + 1), (pointer) *pz, csize); + iret = _uuconf_iadd_string (qglobal, znew, FALSE, FALSE, ppz, + qglobal->pblock); + if (iret != UUCONF_SUCCESS) + return iret; } - znew[0] = '!'; - memcpy ((pointer) (znew + 1), (pointer) *pz, csize); - iret = _uuconf_iadd_string (qglobal, znew, FALSE, FALSE, ppz, - qglobal->pblock); - if (iret != UUCONF_SUCCESS) - return iret; } return UUCONF_SUCCESS; diff --git a/gnu/libexec/uucp/libuuconf/reliab.c b/gnu/libexec/uucp/libuuconf/reliab.c index 13517d49f34..e1cdd00405c 100644 --- a/gnu/libexec/uucp/libuuconf/reliab.c +++ b/gnu/libexec/uucp/libuuconf/reliab.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_reliab_rcsid[] = "$Id: reliab.c,v 1.1 1993/08/04 19:34:58 jtc Exp $"; +const char _uuconf_reliab_rcsid[] = "$Id: reliab.c,v 1.2 1994/10/24 22:24:17 jtc Exp $"; #endif /* Handle the "seven-bit" command for a port or a dialer. The pvar diff --git a/gnu/libexec/uucp/libuuconf/remunk.c b/gnu/libexec/uucp/libuuconf/remunk.c index 85297b0212f..f9b38fecc84 100644 --- a/gnu/libexec/uucp/libuuconf/remunk.c +++ b/gnu/libexec/uucp/libuuconf/remunk.c @@ -1,7 +1,7 @@ /* remunk.c Get the name of the remote.unknown shell script. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_remunk_rcsid[] = "$Id: remunk.c,v 1.1 1993/08/04 19:34:59 jtc Exp $"; +const char _uuconf_remunk_rcsid[] = "$Id: remunk.c,v 1.2 1994/10/24 22:24:19 jtc Exp $"; #endif /* Get the name of the remote.unknown shell script. */ @@ -37,9 +37,18 @@ uuconf_remote_unknown (pglobal, pzname) pointer pglobal; char **pzname; { -#if HAVE_TAYLOR_CONFIG || ! HAVE_HDB_CONFIG +#if ! HAVE_HDB_CONFIG return UUCONF_NOT_FOUND; #else +#if HAVE_TAYLOR_CONFIG + struct sglobal *qglobal = (struct sglobal *) pglobal; + + /* If ``unknown'' commands were used in the config file, then ignore + any remote.unknown script. */ + if (qglobal->qprocess->qunknown != NULL) + return UUCONF_NOT_FOUND; +#endif /* HAVE_TAYLOR_CONFIG */ + return uuconf_hdb_remote_unknown (pglobal, pzname); -#endif +#endif /* HAVE_HDB_CONFIG */ } diff --git a/gnu/libexec/uucp/libuuconf/runuxq.c b/gnu/libexec/uucp/libuuconf/runuxq.c new file mode 100644 index 00000000000..9663f56c88f --- /dev/null +++ b/gnu/libexec/uucp/libuuconf/runuxq.c @@ -0,0 +1,77 @@ +/* maxuxq.c + Return how often to spawn a uuxqt process. + + Copyright (C) 1994 Ian Lance Taylor + + This file is part of the Taylor UUCP uuconf library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author of the program may be contacted at ian@airs.com or + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. + */ + +#include "uucnfi.h" + +#if USE_RCS_ID +const char _uuconf_runuxq_rcsid[] = "$Id: runuxq.c,v 1.1 1994/10/24 22:24:23 jtc Exp $"; +#endif + +/* Return how often to spawn a uuxqt process. This is either a + positive number representing the number of execution files to be + received between spawns, or a special code. When using + TAYLOR_CONFIG, this is from the ``run-uuxqt'' command in config + (the default is UUCONF_RUNUUXQT_ONCE, for compatibility). + Otherwise, we return UUCONF_RUNUUXQT_PERCALL for HDB_CONFIG and 10 + for V2_CONFIG, to emulate traditional HDB and V2 emulations. */ + +int +uuconf_runuuxqt (pglobal, pirunuuxqt) + pointer pglobal; + int *pirunuuxqt; +{ +#if HAVE_TAYLOR_CONFIG + { + struct sglobal *qglobal = (struct sglobal *) pglobal; + const char *zrun; + + zrun = qglobal->qprocess->zrunuuxqt; + if (zrun == NULL + || strcasecmp (zrun, "once") == 0) + *pirunuuxqt = UUCONF_RUNUUXQT_ONCE; + else if (strcasecmp (zrun, "never") == 0) + *pirunuuxqt = UUCONF_RUNUUXQT_NEVER; + else if (strcasecmp (zrun, "percall") == 0) + *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL; + else + { + char *zend; + + *pirunuuxqt = strtol ((char *) qglobal->qprocess->zrunuuxqt, + &zend, 10); + if (*zend != '\0' || *pirunuuxqt <= 0) + *pirunuuxqt = UUCONF_RUNUUXQT_ONCE; + } + } +#else /* ! HAVE_TAYLOR_CONFIG */ +#if HAVE_HDB_CONFIG + *pirunuuxqt = UUCONF_RUNUUXQT_PERCALL; +#else /* ! HAVE_HDB_CONFIG */ + *pirunuuxqt = 10; +#endif /* ! HAVE_HDB_CONFIG */ +#endif /* ! HAVE_TAYLOR_CONFIG */ + + return UUCONF_SUCCESS; +} diff --git a/gnu/libexec/uucp/libuuconf/sinfo.c b/gnu/libexec/uucp/libuuconf/sinfo.c index f73851f84ab..2d7d93f8e01 100644 --- a/gnu/libexec/uucp/libuuconf/sinfo.c +++ b/gnu/libexec/uucp/libuuconf/sinfo.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_sinfo_rcsid[] = "$Id: sinfo.c,v 1.1 1993/08/04 19:35:00 jtc Exp $"; +const char _uuconf_sinfo_rcsid[] = "$Id: sinfo.c,v 1.2 1994/10/24 22:24:27 jtc Exp $"; #endif /* Get information about a particular system. We combine the diff --git a/gnu/libexec/uucp/libuuconf/snams.c b/gnu/libexec/uucp/libuuconf/snams.c index d239b10e083..bf40398d04b 100644 --- a/gnu/libexec/uucp/libuuconf/snams.c +++ b/gnu/libexec/uucp/libuuconf/snams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_snams_rcsid[] = "$Id: snams.c,v 1.1 1993/08/04 19:35:01 jtc Exp $"; +const char _uuconf_snams_rcsid[] = "$Id: snams.c,v 1.2 1994/10/24 22:24:31 jtc Exp $"; #endif /* Get all known system names. */ diff --git a/gnu/libexec/uucp/libuuconf/split.c b/gnu/libexec/uucp/libuuconf/split.c index 76cc5e8d360..be03cabdd65 100644 --- a/gnu/libexec/uucp/libuuconf/split.c +++ b/gnu/libexec/uucp/libuuconf/split.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_split_rcsid[] = "$Id: split.c,v 1.1 1993/08/04 19:35:02 jtc Exp $"; +const char _uuconf_split_rcsid[] = "$Id: split.c,v 1.2 1994/10/24 22:24:33 jtc Exp $"; #endif #include <ctype.h> diff --git a/gnu/libexec/uucp/libuuconf/spool.c b/gnu/libexec/uucp/libuuconf/spool.c index e9c13f072cb..bb9a768290f 100644 --- a/gnu/libexec/uucp/libuuconf/spool.c +++ b/gnu/libexec/uucp/libuuconf/spool.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_spool_rcsid[] = "$Id: spool.c,v 1.1 1993/08/04 19:35:03 jtc Exp $"; +const char _uuconf_spool_rcsid[] = "$Id: spool.c,v 1.2 1994/10/24 22:24:36 jtc Exp $"; #endif /* Get the name of the UUCP spool directory. */ diff --git a/gnu/libexec/uucp/libuuconf/stafil.c b/gnu/libexec/uucp/libuuconf/stafil.c index bcea0bffd6c..0fb7ad165b1 100644 --- a/gnu/libexec/uucp/libuuconf/stafil.c +++ b/gnu/libexec/uucp/libuuconf/stafil.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_stafil_rcsid[] = "$Id: stafil.c,v 1.1 1993/08/04 19:35:04 jtc Exp $"; +const char _uuconf_stafil_rcsid[] = "$Id: stafil.c,v 1.2 1994/10/24 22:24:39 jtc Exp $"; #endif /* Get the name of the UUCP statistics file. */ diff --git a/gnu/libexec/uucp/libuuconf/syshdr.h b/gnu/libexec/uucp/libuuconf/syshdr.h index 8ff18a6ca49..b5a759fd1a6 100644 --- a/gnu/libexec/uucp/libuuconf/syshdr.h +++ b/gnu/libexec/uucp/libuuconf/syshdr.h @@ -1,7 +1,7 @@ /* syshdr.unx -*- C -*- Unix system header for the uuconf library. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ /* The root directory (used when setting local-send and local-receive @@ -82,6 +82,40 @@ extern char *sys_errlist[]; #endif /* ! HAVE_STRERROR */ +/* This macro is used to make a filename found in a configuration file + into an absolute path. The zdir argument is the directory to put it + in. The zset argument is set to the new string. The fallocated + argument is set to TRUE if the new string was allocated. */ +#define MAKE_ABSOLUTE(zset, fallocated, zfile, zdir, pblock) \ + do \ + { \ + if (*(zfile) == '/') \ + { \ + (zset) = (zfile); \ + (fallocated) = FALSE; \ + } \ + else \ + { \ + size_t abs_cdir, abs_cfile; \ + char *abs_zret; \ +\ + abs_cdir = strlen (zdir); \ + abs_cfile = strlen (zfile); \ + abs_zret = (char *) uuconf_malloc ((pblock), \ + abs_cdir + abs_cfile + 2); \ + (zset) = abs_zret; \ + (fallocated) = TRUE; \ + if (abs_zret != NULL) \ + { \ + memcpy ((pointer) abs_zret, (pointer) (zdir), abs_cdir); \ + abs_zret[abs_cdir] = '/'; \ + memcpy ((pointer) (abs_zret + abs_cdir + 1), \ + (pointer) (zfile), abs_cfile + 1); \ + } \ + } \ + } \ + while (0) + /* We want to be able to mark the Taylor UUCP system files as close on exec. */ #if HAVE_FCNTL_H diff --git a/gnu/libexec/uucp/libuuconf/syssub.c b/gnu/libexec/uucp/libuuconf/syssub.c index f9b52c13fed..3823209c375 100644 --- a/gnu/libexec/uucp/libuuconf/syssub.c +++ b/gnu/libexec/uucp/libuuconf/syssub.c @@ -1,7 +1,7 @@ /* syssub.c System information subroutines. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_syssub_rcsid[] = "$Id: syssub.c,v 1.1 1993/08/04 19:35:06 jtc Exp $"; +const char _uuconf_syssub_rcsid[] = "$Id: syssub.c,v 1.2 1994/10/24 22:24:45 jtc Exp $"; #endif #include <errno.h> @@ -231,6 +231,71 @@ _uuconf_isystem_default (qglobal, qset, qdefault, faddalternates) if (qalt->uuconf_qproto_params == (struct uuconf_proto_param *) &_uuconf_unset) qalt->uuconf_qproto_params = qdefault->uuconf_qproto_params; + else if (qdefault->uuconf_qproto_params != NULL) + { + int cnew, ca; + struct uuconf_proto_param *qd, *qa; + + /* Merge in the default protocol parameters, so that a + system with 'g' protocol parameters won't lose the + default 'i' protocol parameters. */ + ca = 0; + cnew = 0; + for (qd = qdefault->uuconf_qproto_params; + qd->uuconf_bproto != '\0'; + qd++) + { + int c; + + c = 0; + for (qa = qalt->uuconf_qproto_params; + (qa->uuconf_bproto != '\0' + && qa->uuconf_bproto != qd->uuconf_bproto); + qa++) + ++c; + if (qa->uuconf_bproto == '\0') + { + ++cnew; + ca = c; + } + } + + if (cnew > 0) + { + struct uuconf_proto_param *qnew; + + qnew = ((struct uuconf_proto_param *) + uuconf_malloc (qset->uuconf_palloc, + ((ca + cnew + 1) + * sizeof (struct uuconf_proto_param)))); + if (qnew == NULL) + { + qglobal->ierrno = errno; + return UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO; + } + memcpy ((pointer) qnew, (pointer) qalt->uuconf_qproto_params, + ca * sizeof (struct uuconf_proto_param)); + cnew = 0; + for (qd = qdefault->uuconf_qproto_params; + qd->uuconf_bproto != '\0'; + qd++) + { + for (qa = qalt->uuconf_qproto_params; + (qa->uuconf_bproto != '\0' + && qa->uuconf_bproto != qd->uuconf_bproto); + qa++) + ; + if (qa->uuconf_bproto == '\0') + { + qnew[ca + cnew] = *qd; + ++cnew; + } + } + qnew[ca + cnew].uuconf_bproto = '\0'; + uuconf_free (qset->uuconf_palloc, qalt->uuconf_qproto_params); + qalt->uuconf_qproto_params = qnew; + } + } if (qdefault->uuconf_qalternate != NULL) qdefault = qdefault->uuconf_qalternate; diff --git a/gnu/libexec/uucp/libuuconf/tcalou.c b/gnu/libexec/uucp/libuuconf/tcalou.c index 8eb627eb334..1e45d238462 100644 --- a/gnu/libexec/uucp/libuuconf/tcalou.c +++ b/gnu/libexec/uucp/libuuconf/tcalou.c @@ -1,7 +1,7 @@ /* tcalou.c Find callout login name and password from Taylor UUCP configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tcalou_rcsid[] = "$Id: tcalou.c,v 1.1 1993/08/04 19:35:07 jtc Exp $"; +const char _uuconf_tcalou_rcsid[] = "$Id: tcalou.c,v 1.2 1994/10/24 22:24:48 jtc Exp $"; #endif #include <errno.h> @@ -99,7 +99,7 @@ uuconf_taylor_callout (pglobal, qsys, pzlog, pzpass) } as[0].uuconf_zcmd = qsys->uuconf_zname; - as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 3; + as[0].uuconf_itype = UUCONF_CMDTABTYPE_FN | 0; if (*pzlog == NULL) as[0].uuconf_pvar = (pointer) pzlog; else @@ -168,6 +168,9 @@ icsys (pglobal, argc, argv, pvar, pinfo) char **pzlog = (char **) pvar; char **pzpass = (char **) pinfo; + if (argc < 2 || argc > 3) + return UUCONF_SYNTAX_ERROR | UUCONF_CMDTABRET_EXIT; + if (pzlog != NULL) { *pzlog = strdup (argv[1]); @@ -182,7 +185,10 @@ icsys (pglobal, argc, argv, pvar, pinfo) if (pzpass != NULL) { - *pzpass = strdup (argv[2]); + if (argc < 3) + *pzpass = strdup (""); + else + *pzpass = strdup (argv[2]); if (*pzpass == NULL) { qglobal->ierrno = errno; diff --git a/gnu/libexec/uucp/libuuconf/tdial.c b/gnu/libexec/uucp/libuuconf/tdial.c index f13c92998ab..5f0feba6f43 100644 --- a/gnu/libexec/uucp/libuuconf/tdial.c +++ b/gnu/libexec/uucp/libuuconf/tdial.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tdial_rcsid[] = "$Id: tdial.c,v 1.1 1993/08/04 19:35:08 jtc Exp $"; +const char _uuconf_tdial_rcsid[] = "$Id: tdial.c,v 1.2 1994/10/24 22:24:53 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/tdialc.c b/gnu/libexec/uucp/libuuconf/tdialc.c index e70090f3bb0..a02ea3e1710 100644 --- a/gnu/libexec/uucp/libuuconf/tdialc.c +++ b/gnu/libexec/uucp/libuuconf/tdialc.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tdialc_rcsid[] = "$Id: tdialc.c,v 1.1 1993/08/04 19:35:09 jtc Exp $"; +const char _uuconf_tdialc_rcsid[] = "$Id: tdialc.c,v 1.2 1994/10/24 22:24:55 jtc Exp $"; #endif static int idchat P((pointer pglobal, int argc, char **argv, pointer pvar, diff --git a/gnu/libexec/uucp/libuuconf/tdnams.c b/gnu/libexec/uucp/libuuconf/tdnams.c index d9e4b0d7e38..69b63485dcd 100644 --- a/gnu/libexec/uucp/libuuconf/tdnams.c +++ b/gnu/libexec/uucp/libuuconf/tdnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tdnams_rcsid[] = "$Id: tdnams.c,v 1.1 1993/08/04 19:35:10 jtc Exp $"; +const char _uuconf_tdnams_rcsid[] = "$Id: tdnams.c,v 1.2 1994/10/24 22:24:57 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/tgcmp.c b/gnu/libexec/uucp/libuuconf/tgcmp.c index 9bc8de2b5f4..2264af3a3b4 100644 --- a/gnu/libexec/uucp/libuuconf/tgcmp.c +++ b/gnu/libexec/uucp/libuuconf/tgcmp.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tgcmp_rcsid[] = "$Id: tgcmp.c,v 1.1 1993/08/04 19:35:11 jtc Exp $"; +const char _uuconf_tgcmp_rcsid[] = "$Id: tgcmp.c,v 1.2 1994/10/24 22:24:59 jtc Exp $"; #endif /* A comparison function to pass to _uuconf_itime_parse. This diff --git a/gnu/libexec/uucp/libuuconf/thread.c b/gnu/libexec/uucp/libuuconf/thread.c index 92f100bba20..08a20d09dee 100644 --- a/gnu/libexec/uucp/libuuconf/thread.c +++ b/gnu/libexec/uucp/libuuconf/thread.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_thread_rcsid[] = "$Id: thread.c,v 1.1 1993/08/04 19:35:11 jtc Exp $"; +const char _uuconf_thread_rcsid[] = "$Id: thread.c,v 1.2 1994/10/24 22:25:03 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/time.c b/gnu/libexec/uucp/libuuconf/time.c index 6f316828a38..4db53548cee 100644 --- a/gnu/libexec/uucp/libuuconf/time.c +++ b/gnu/libexec/uucp/libuuconf/time.c @@ -1,7 +1,7 @@ /* time.c Parse a time string into a uuconf_timespan structure. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_time_rcsid[] = "$Id: time.c,v 1.1 1993/08/04 19:35:12 jtc Exp $"; +const char _uuconf_time_rcsid[] = "$Id: time.c,v 1.2 1994/10/24 22:25:07 jtc Exp $"; #endif #include <ctype.h> @@ -61,6 +61,7 @@ static const struct { "fr", 5, 5 }, { "sa", 6, 6 }, { "never", -1, -2 }, + { "none", -1, -2 }, { NULL, 0, 0 } }; @@ -106,7 +107,7 @@ _uuconf_itime_parse (qglobal, ztime, ival, cretry, picmp, pqspan, pblock) { if ((bfirst == (*pz)[0] || (isupper (BUCHAR ((*pz)[0])) - && bfirst == tolower (BUCHAR ((*pz)[0])))) + && (int) bfirst == (int) tolower (BUCHAR ((*pz)[0])))) && strcasecmp (ztime, *pz) == 0) zfound = pz[1]; pz += 2; diff --git a/gnu/libexec/uucp/libuuconf/tinit.c b/gnu/libexec/uucp/libuuconf/tinit.c index 829fd12285e..d82b9e6998b 100644 --- a/gnu/libexec/uucp/libuuconf/tinit.c +++ b/gnu/libexec/uucp/libuuconf/tinit.c @@ -1,7 +1,7 @@ /* tinit.c Initialize for reading Taylor UUCP configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tinit_rcsid[] = "$Id: tinit.c,v 1.1 1993/08/04 19:35:14 jtc Exp $"; +const char _uuconf_tinit_rcsid[] = "$Id: tinit.c,v 1.2 1994/10/24 22:25:12 jtc Exp $"; #endif #include <errno.h> @@ -35,8 +35,10 @@ const char _uuconf_tinit_rcsid[] = "$Id: tinit.c,v 1.1 1993/08/04 19:35:14 jtc E static int itset_default P((struct sglobal *qglobal, char ***ppzvar, const char *zfile)); -static int itadd P((pointer pglobal, int argc, char **argv, pointer pvar, - pointer pinfo)); +static int itdebug P((pointer pglobal, int argc, char **argv, pointer pvar, + pointer pinfo)); +static int itaddfile P((pointer pglobal, int argc, char **argv, pointer pvar, + pointer pinfo)); static int itunknown P((pointer pglobal, int argc, char **argv, pointer pvar, pointer pinfo)); static int itprogram P((pointer pglobal, int argc, char **argv, pointer pvar, @@ -62,22 +64,24 @@ static const struct cmdtab_offset asCmds[] = offsetof (struct sprocess, zstatsfile), NULL }, { "debugfile", UUCONF_CMDTABTYPE_STRING, offsetof (struct sprocess, zdebugfile), NULL }, - { "debug", UUCONF_CMDTABTYPE_STRING, - offsetof (struct sprocess, zdebug), NULL }, + { "debug", UUCONF_CMDTABTYPE_FN | 0, + offsetof (struct sprocess, zdebug), itdebug }, { "max-uuxqts", UUCONF_CMDTABTYPE_INT, offsetof (struct sprocess, cmaxuuxqts), NULL }, + { "run-uuxqt", UUCONF_CMDTABTYPE_STRING, + offsetof (struct sprocess, zrunuuxqt), NULL }, { "sysfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzsysfiles), itadd }, + offsetof (struct sprocess, pzsysfiles), itaddfile }, { "portfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzportfiles), itadd }, + offsetof (struct sprocess, pzportfiles), itaddfile }, { "dialfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzdialfiles), itadd }, + offsetof (struct sprocess, pzdialfiles), itaddfile }, { "dialcodefile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzdialcodefiles), itadd }, + offsetof (struct sprocess, pzdialcodefiles), itaddfile }, { "callfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzcallfiles), itadd }, + offsetof (struct sprocess, pzcallfiles), itaddfile }, { "passwdfile", UUCONF_CMDTABTYPE_FN | 0, - offsetof (struct sprocess, pzpwdfiles), itadd }, + offsetof (struct sprocess, pzpwdfiles), itaddfile }, { "unknown", UUCONF_CMDTABTYPE_FN, offsetof (struct sprocess, qunknown), itunknown }, { "v2-files", UUCONF_CMDTABTYPE_BOOLEAN, @@ -227,11 +231,29 @@ uuconf_taylor_init (ppglobal, zprogram, zname) return UUCONF_SUCCESS; } -/* Add new strings to a variable. */ +/* Local interface to the _uuconf_idebug_cmd function, which handles + the "debug" command. */ + +static int +itdebug (pglobal, argc, argv, pvar, pinfo) + pointer pglobal; + int argc; + char **argv; + pointer pvar; + pointer pinfo; +{ + struct sglobal *qglobal = (struct sglobal *) pglobal; + char **pzdebug = (char **) pvar; + + return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, + qglobal->pblock); +} + +/* Add new filenames to a list of files. */ /*ARGSUSED*/ static int -itadd (pglobal, argc, argv, pvar, pinfo) +itaddfile (pglobal, argc, argv, pvar, pinfo) pointer pglobal; int argc; char **argv; @@ -254,7 +276,19 @@ itadd (pglobal, argc, argv, pvar, pinfo) { for (i = 1; i < argc; i++) { - iret = _uuconf_iadd_string (qglobal, argv[i], TRUE, FALSE, ppz, + char *z; + boolean fallocated; + + MAKE_ABSOLUTE (z, fallocated, argv[i], NEWCONFIGLIB, + qglobal->pblock); + if (z == NULL) + { + qglobal->ierrno = errno; + return (UUCONF_MALLOC_FAILED + | UUCONF_ERROR_ERRNO + | UUCONF_CMDTABRET_EXIT); + } + iret = _uuconf_iadd_string (qglobal, z, ! fallocated, FALSE, ppz, qglobal->pblock); if (iret != UUCONF_SUCCESS) return iret; @@ -368,3 +402,60 @@ itset_default (qglobal, ppzvar, zfile) return _uuconf_iadd_string (qglobal, zadd, FALSE, FALSE, ppzvar, qglobal->pblock); } + +/* Handle the "debug" command which is documented to take multiple + arguments. This is also called by the ``debug'' command in a sys + file. It returns a CMDTABRET code. This should probably be in its + own file, but the only other place it is called is from tsinfo.c, + and any user of tsinfo.c it sure to link in this file as well. */ + +int +_uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, pblock) + struct sglobal *qglobal; + char **pzdebug; + int argc; + char **argv; + pointer pblock; +{ + if (argc == 1) + { + *pzdebug = NULL; + return UUCONF_CMDTABRET_CONTINUE; + } + else if (argc == 2) + { + *pzdebug = argv[1]; + return UUCONF_CMDTABRET_KEEP; + } + else + { + size_t cdebug; + int i; + char *zdebug; + + cdebug = 0; + for (i = 1; i < argc; i++) + cdebug += strlen (argv[i]) + 1; + zdebug = (char *) uuconf_malloc (pblock, cdebug); + if (zdebug == NULL) + { + qglobal->ierrno = errno; + return (UUCONF_MALLOC_FAILED + | UUCONF_ERROR_ERRNO + | UUCONF_CMDTABRET_EXIT); + } + cdebug = 0; + for (i = 1; i < argc; i++) + { + size_t clen; + + clen = strlen (argv[i]); + memcpy (zdebug + cdebug, argv[i], clen); + zdebug[cdebug + clen] = ' '; + cdebug += clen + 1; + } + zdebug[cdebug - 1] = '\0'; + *pzdebug = zdebug; + return UUCONF_CMDTABRET_CONTINUE; + } +} diff --git a/gnu/libexec/uucp/libuuconf/tlocnm.c b/gnu/libexec/uucp/libuuconf/tlocnm.c index bf09446e8f6..afb0ce382e5 100644 --- a/gnu/libexec/uucp/libuuconf/tlocnm.c +++ b/gnu/libexec/uucp/libuuconf/tlocnm.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tlocnm_rcsid[] = "$Id: tlocnm.c,v 1.1 1993/08/04 19:35:14 jtc Exp $"; +const char _uuconf_tlocnm_rcsid[] = "$Id: tlocnm.c,v 1.2 1994/10/24 22:25:15 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/tport.c b/gnu/libexec/uucp/libuuconf/tport.c index 0a94a81c112..c310c1a028a 100644 --- a/gnu/libexec/uucp/libuuconf/tport.c +++ b/gnu/libexec/uucp/libuuconf/tport.c @@ -1,7 +1,7 @@ /* tport.c Find a port in the Taylor UUCP configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tport_rcsid[] = "$Id: tport.c,v 1.1 1993/08/04 19:35:15 jtc Exp $"; +const char _uuconf_tport_rcsid[] = "$Id: tport.c,v 1.2 1994/10/24 22:25:19 jtc Exp $"; #endif #include <errno.h> @@ -290,6 +290,10 @@ ipunknown (pglobal, argc, argv, pvar, pinfo) { struct sglobal *qglobal = (struct sglobal *) pglobal; struct uuconf_port *qport = (struct uuconf_port *) pinfo; + int iret; - return _uuconf_iport_cmd (qglobal, argc, argv, qport); + iret = _uuconf_iport_cmd (qglobal, argc, argv, qport); + if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS) + iret |= UUCONF_CMDTABRET_EXIT; + return iret; } diff --git a/gnu/libexec/uucp/libuuconf/tportc.c b/gnu/libexec/uucp/libuuconf/tportc.c index 7b796eacb09..312a0b70836 100644 --- a/gnu/libexec/uucp/libuuconf/tportc.c +++ b/gnu/libexec/uucp/libuuconf/tportc.c @@ -1,7 +1,7 @@ /* tportc.c Handle a Taylor UUCP port command. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tportc_rcsid[] = "$Id: tportc.c,v 1.1 1993/08/04 19:35:16 jtc Exp $"; +const char _uuconf_tportc_rcsid[] = "$Id: tportc.c,v 1.2 1994/10/24 22:25:24 jtc Exp $"; #endif #include <errno.h> @@ -50,7 +50,8 @@ static const char * const azPtype_names[] = "modem", "direct", "tcp", - "tli" + "tli", + "pipe" }; #define CPORT_TYPES (sizeof azPtype_names / sizeof azPtype_names[0]) @@ -104,6 +105,9 @@ static const struct cmdtab_offset asPmodem_cmds[] = { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fcarrier), NULL }, + { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN, + offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_fhardflow), + NULL }, { "dial-device", UUCONF_CMDTABTYPE_STRING, offsetof (struct uuconf_port, uuconf_u.uuconf_smodem.uuconf_zdial_device), @@ -130,6 +134,12 @@ static const struct cmdtab_offset asPdirect_cmds[] = { "speed", UUCONF_CMDTABTYPE_LONG, offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_ibaud), NULL }, + { "carrier", UUCONF_CMDTABTYPE_BOOLEAN, + offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fcarrier), + NULL }, + { "hardflow", UUCONF_CMDTABTYPE_BOOLEAN, + offsetof (struct uuconf_port, uuconf_u.uuconf_sdirect.uuconf_fhardflow), + NULL }, { NULL, 0, 0, NULL } }; @@ -141,6 +151,9 @@ static const struct cmdtab_offset asPtcp_cmds[] = { "service", UUCONF_CMDTABTYPE_STRING, offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_zport), NULL }, + { "dialer-sequence", UUCONF_CMDTABTYPE_FULLSTRING, + offsetof (struct uuconf_port, uuconf_u.uuconf_stcp.uuconf_pzdialer), + NULL }, { NULL, 0, 0, NULL } }; @@ -169,11 +182,22 @@ static const struct cmdtab_offset asPtli_cmds[] = #define CTLI_CMDS (sizeof asPtli_cmds / sizeof asPtli_cmds[0]) +/* The pipe port command table. */ +static const struct cmdtab_offset asPpipe_cmds[] = +{ + { "command", UUCONF_CMDTABTYPE_FULLSTRING, + offsetof (struct uuconf_port, uuconf_u.uuconf_spipe.uuconf_pzcmd), + NULL }, + { NULL, 0, 0, NULL} +}; + +#define CPIPE_CMDS (sizeof asPpipe_cmds / sizeof asPpipe_cmds[0]) + #undef max #define max(i1, i2) ((i1) > (i2) ? (i1) : (i2)) #define CCMDS \ max (max (max (CPORT_CMDS, CSTDIN_CMDS), CMODEM_CMDS), \ - max (max (CDIRECT_CMDS, CTCP_CMDS), CTLI_CMDS)) + max (max (CDIRECT_CMDS, CTCP_CMDS), max (CTLI_CMDS, CPIPE_CMDS))) /* Handle a command passed to a port from a Taylor UUCP configuration file. This can be called when reading either the port file or the @@ -243,15 +267,19 @@ _uuconf_iport_cmd (qglobal, argc, argv, qport) qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud = 0L; qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = 0L; qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; + qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL; qport->uuconf_u.uuconf_smodem.uuconf_qdialer = NULL; break; case UUCONF_PORTTYPE_DIRECT: qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = NULL; qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = -1; + qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; + qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; break; case UUCONF_PORTTYPE_TCP: qport->uuconf_u.uuconf_stcp.uuconf_zport = (char *) "uucp"; + qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL; qport->uuconf_ireliable = (UUCONF_RELIABLE_SPECIFIED | UUCONF_RELIABLE_ENDTOEND | UUCONF_RELIABLE_RELIABLE @@ -270,6 +298,9 @@ _uuconf_iport_cmd (qglobal, argc, argv, qport) | UUCONF_RELIABLE_EIGHT | UUCONF_RELIABLE_FULLDUPLEX); break; + case UUCONF_PORTTYPE_PIPE: + qport->uuconf_u.uuconf_spipe.uuconf_pzcmd = NULL; + break; } if (fgottype) @@ -310,6 +341,10 @@ _uuconf_iport_cmd (qglobal, argc, argv, qport) qcmds = asPtli_cmds; ccmds = CTLI_CMDS; break; + case UUCONF_PORTTYPE_PIPE: + qcmds = asPpipe_cmds; + ccmds = CPIPE_CMDS; + break; default: return UUCONF_SYNTAX_ERROR; } @@ -410,23 +445,28 @@ ipdialer (pglobal, argc, argv, pvar, pinfo) _uuconf_uclear_dialer (qnew); - clen = strlen (qport->uuconf_zname); - qnew->uuconf_zname = (char *) uuconf_malloc (qport->uuconf_palloc, - (clen - + sizeof " dialer")); - if (qnew->uuconf_zname == NULL) + if (qport->uuconf_zname == NULL) + qnew->uuconf_zname = (char *) "default port file dialer"; + else { - qglobal->ierrno = errno; - return (UUCONF_MALLOC_FAILED - | UUCONF_ERROR_ERRNO - | UUCONF_CMDTABRET_EXIT); + clen = strlen (qport->uuconf_zname); + qnew->uuconf_zname = + (char *) uuconf_malloc (qport->uuconf_palloc, + clen + sizeof " dialer"); + if (qnew->uuconf_zname == NULL) + { + qglobal->ierrno = errno; + return (UUCONF_MALLOC_FAILED + | UUCONF_ERROR_ERRNO + | UUCONF_CMDTABRET_EXIT); + } + + memcpy ((pointer) qnew->uuconf_zname, + (pointer) qport->uuconf_zname, clen); + memcpy ((pointer) (qnew->uuconf_zname + clen), + (pointer) " dialer", sizeof " dialer"); } - memcpy ((pointer) qnew->uuconf_zname, - (pointer) qport->uuconf_zname, clen); - memcpy ((pointer) (qnew->uuconf_zname + clen), (pointer) " dialer", - sizeof " dialer"); - qnew->uuconf_palloc = qport->uuconf_palloc; qmodem->uuconf_qdialer = qnew; diff --git a/gnu/libexec/uucp/libuuconf/tsinfo.c b/gnu/libexec/uucp/libuuconf/tsinfo.c index 5e31ca2c2d3..ed31eb2d36a 100644 --- a/gnu/libexec/uucp/libuuconf/tsinfo.c +++ b/gnu/libexec/uucp/libuuconf/tsinfo.c @@ -1,7 +1,7 @@ /* tsinfo.c Get information about a system from the Taylor UUCP configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tsinfo_rcsid[] = "$Id: tsinfo.c,v 1.1 1993/08/04 19:35:18 jtc Exp $"; +const char _uuconf_tsinfo_rcsid[] = "$Id: tsinfo.c,v 1.2 1994/10/24 22:25:31 jtc Exp $"; #endif #include <errno.h> @@ -54,6 +54,7 @@ CMDTABFN (iisize); CMDTABFN (iibaud_range); CMDTABFN (iiport); CMDTABFN (iichat); +CMDTABFN (iidebug); CMDTABFN (iicalled_login); CMDTABFN (iiproto_param); CMDTABFN (iirequest); @@ -136,8 +137,8 @@ static const struct cmdtab_offset asIcmds[] = offsetof (struct uuconf_system, uuconf_qproto_params), iiproto_param }, { "called-chat", UUCONF_CMDTABTYPE_PREFIX | 0, offsetof (struct uuconf_system, uuconf_scalled_chat), iichat }, - { "debug", UUCONF_CMDTABTYPE_STRING, - offsetof (struct uuconf_system, uuconf_zdebug), NULL }, + { "debug", UUCONF_CMDTABTYPE_FN | 0, + offsetof (struct uuconf_system, uuconf_zdebug), iidebug }, { "max-remote-debug", UUCONF_CMDTABTYPE_STRING, offsetof (struct uuconf_system, uuconf_zmax_remote_debug), NULL }, { "send-request", UUCONF_CMDTABTYPE_BOOLEAN, @@ -708,6 +709,25 @@ iichat (pglobal, argc, argv, pvar, pinfo) return iret; } +/* Local interface to the _uuconf_idebug_cmd function, which handles + the "debug" command. */ + +static int +iidebug (pglobal, argc, argv, pvar, pinfo) + pointer pglobal; + int argc; + char **argv; + pointer pvar; + pointer pinfo; +{ + struct sglobal *qglobal = (struct sglobal *) pglobal; + struct sinfo *qinfo = (struct sinfo *) pinfo; + char **pzdebug = (char **) pvar; + + return _uuconf_idebug_cmd (qglobal, pzdebug, argc, argv, + qinfo->qsys->uuconf_palloc); +} + /* Handle the "called-login" command. This only needs to be in a function because there can be additional arguments listing the remote systems which are permitted to use this login name. The diff --git a/gnu/libexec/uucp/libuuconf/tsnams.c b/gnu/libexec/uucp/libuuconf/tsnams.c index c0f96e53f61..1e90363bfcb 100644 --- a/gnu/libexec/uucp/libuuconf/tsnams.c +++ b/gnu/libexec/uucp/libuuconf/tsnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tsnams_rcsid[] = "$Id: tsnams.c,v 1.1 1993/08/04 19:35:19 jtc Exp $"; +const char _uuconf_tsnams_rcsid[] = "$Id: tsnams.c,v 1.2 1994/10/24 22:25:38 jtc Exp $"; #endif /* Get all the system names from the Taylor UUCP configuration files. diff --git a/gnu/libexec/uucp/libuuconf/tsys.c b/gnu/libexec/uucp/libuuconf/tsys.c index 6a1f6621092..5a68a34d461 100644 --- a/gnu/libexec/uucp/libuuconf/tsys.c +++ b/gnu/libexec/uucp/libuuconf/tsys.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tsys_rcsid[] = "$Id: tsys.c,v 1.1 1993/08/04 19:35:20 jtc Exp $"; +const char _uuconf_tsys_rcsid[] = "$Id: tsys.c,v 1.2 1994/10/24 22:25:42 jtc Exp $"; #endif /* Get system information from the Taylor UUCP configuration files. diff --git a/gnu/libexec/uucp/libuuconf/tval.c b/gnu/libexec/uucp/libuuconf/tval.c index be8769612dd..d75fc7280d6 100644 --- a/gnu/libexec/uucp/libuuconf/tval.c +++ b/gnu/libexec/uucp/libuuconf/tval.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_tval_rcsid[] = "$Id: tval.c,v 1.1 1993/08/04 19:35:21 jtc Exp $"; +const char _uuconf_tval_rcsid[] = "$Id: tval.c,v 1.2 1994/10/24 22:25:46 jtc Exp $"; #endif /* Validate a login name for a system using Taylor UUCP configuration diff --git a/gnu/libexec/uucp/libuuconf/ugtlin.c b/gnu/libexec/uucp/libuuconf/ugtlin.c index 88ca3507384..029df41d362 100644 --- a/gnu/libexec/uucp/libuuconf/ugtlin.c +++ b/gnu/libexec/uucp/libuuconf/ugtlin.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_ugtlin_rcsid[] = "$Id: ugtlin.c,v 1.1 1993/08/04 19:35:22 jtc Exp $"; +const char _uuconf_ugtlin_rcsid[] = "$Id: ugtlin.c,v 1.2 1994/10/24 22:25:51 jtc Exp $"; #endif /* Read a line from a file with backslash continuations. This updates diff --git a/gnu/libexec/uucp/libuuconf/unk.c b/gnu/libexec/uucp/libuuconf/unk.c index 565dd270f25..6be15304efd 100644 --- a/gnu/libexec/uucp/libuuconf/unk.c +++ b/gnu/libexec/uucp/libuuconf/unk.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_unk_rcsid[] = "$Id: unk.c,v 1.1 1993/08/04 19:35:22 jtc Exp $"; +const char _uuconf_unk_rcsid[] = "$Id: unk.c,v 1.2 1994/10/24 22:25:54 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/uucnfi.h b/gnu/libexec/uucp/libuuconf/uucnfi.h index 9ce6a62dc76..98122794f10 100644 --- a/gnu/libexec/uucp/libuuconf/uucnfi.h +++ b/gnu/libexec/uucp/libuuconf/uucnfi.h @@ -1,7 +1,7 @@ /* uucnfi.h Internal header file for the uuconf package. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ /* This is the internal header file for the uuconf package. It should @@ -80,6 +80,8 @@ struct sprocess const char *zdebug; /* The maximum number of simultaneously executing uuxqts. */ int cmaxuuxqts; + /* How often to spawn a uuxqt process. */ + const char *zrunuuxqt; /* Whether we are reading the V2 configuration files. */ boolean fv2; /* Whether we are reading the HDB configuration files. */ @@ -334,6 +336,12 @@ extern int _uuconf_itime_parse P((struct sglobal *qglobal, char *ztime, /* A grade comparison function to pass to _uuconf_itime_parse. */ extern int _uuconf_itime_grade_cmp P((long, long)); +/* Parse a debugging string. */ + +extern int _uuconf_idebug_cmd P((struct sglobal *qglobal, + char **pzdebug, int argc, + char **argv, pointer pblock)); + /* Add a string to a NULL terminated list of strings. */ extern int _uuconf_iadd_string P((struct sglobal *qglobal, char *zadd, boolean fcopy, diff --git a/gnu/libexec/uucp/libuuconf/val.c b/gnu/libexec/uucp/libuuconf/val.c index a4eb30fb67b..32be21874a1 100644 --- a/gnu/libexec/uucp/libuuconf/val.c +++ b/gnu/libexec/uucp/libuuconf/val.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_val_rcsid[] = "$Id: val.c,v 1.1 1993/08/04 19:35:25 jtc Exp $"; +const char _uuconf_val_rcsid[] = "$Id: val.c,v 1.2 1994/10/24 22:26:02 jtc Exp $"; #endif /* Validate a login name for a system. */ diff --git a/gnu/libexec/uucp/libuuconf/vinit.c b/gnu/libexec/uucp/libuuconf/vinit.c index 20ff5bcb1b7..da3184be33f 100644 --- a/gnu/libexec/uucp/libuuconf/vinit.c +++ b/gnu/libexec/uucp/libuuconf/vinit.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_vinit_rcsid[] = "$Id: vinit.c,v 1.1 1993/08/04 19:35:25 jtc Exp $"; +const char _uuconf_vinit_rcsid[] = "$Id: vinit.c,v 1.2 1994/10/24 22:26:06 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/vport.c b/gnu/libexec/uucp/libuuconf/vport.c index b9382a38614..7539ec40976 100644 --- a/gnu/libexec/uucp/libuuconf/vport.c +++ b/gnu/libexec/uucp/libuuconf/vport.c @@ -1,7 +1,7 @@ /* vport.c Find a port in the V2 configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_vport_rcsid[] = "$Id: vport.c,v 1.1 1993/08/04 19:35:27 jtc Exp $"; +const char _uuconf_vport_rcsid[] = "$Id: vport.c,v 1.2 1994/10/24 22:26:11 jtc Exp $"; #endif #include <errno.h> @@ -140,6 +140,8 @@ uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) qport->uuconf_ttype = UUCONF_PORTTYPE_DIRECT; qport->uuconf_u.uuconf_sdirect.uuconf_zdevice = pzsplit[1]; qport->uuconf_u.uuconf_sdirect.uuconf_ibaud = ilow; + qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier = FALSE; + qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow = TRUE; } else { @@ -162,6 +164,7 @@ uuconf_v2_find_port (pglobal, zname, ibaud, ihighbaud, pifn, pinfo, qport) qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud = ihigh; } qport->uuconf_u.uuconf_smodem.uuconf_fcarrier = TRUE; + qport->uuconf_u.uuconf_smodem.uuconf_fhardflow = TRUE; if (ctoks < 5) qport->uuconf_u.uuconf_smodem.uuconf_pzdialer = NULL; else diff --git a/gnu/libexec/uucp/libuuconf/vsinfo.c b/gnu/libexec/uucp/libuuconf/vsinfo.c index c528ce35012..69a4707d9d7 100644 --- a/gnu/libexec/uucp/libuuconf/vsinfo.c +++ b/gnu/libexec/uucp/libuuconf/vsinfo.c @@ -1,7 +1,7 @@ /* vsinfo.c Get information about a system from the V2 configuration files. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP uuconf library. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_vsinfo_rcsid[] = "$Id: vsinfo.c,v 1.1 1993/08/04 19:35:28 jtc Exp $"; +const char _uuconf_vsinfo_rcsid[] = "$Id: vsinfo.c,v 1.2 1994/10/24 22:26:14 jtc Exp $"; #endif #include <errno.h> @@ -77,7 +77,7 @@ _uuconf_iv2_system_internal (qglobal, zsystem, qsys) qglobal->ilineno = 0; - while ((cchars = getline (&zline, &cline, e)) > 0) + while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0) { int ctoks, ctimes, i; struct uuconf_system *qset; @@ -174,7 +174,7 @@ _uuconf_iv2_system_internal (qglobal, zsystem, qsys) here. */ zretry = strchr (pzsplit[1], ';'); if (zretry == NULL) - cretry = 0; + cretry = 55; else { *zretry = '\0'; @@ -212,6 +212,11 @@ _uuconf_iv2_system_internal (qglobal, zsystem, qsys) pblock); if (iret != UUCONF_SUCCESS) break; + + /* Treat any time/grade setting as both a timegrade and a + call-timegrade. */ + if (bgrade != UUCONF_GRADE_LOW) + qset->uuconf_qcalltimegrade = qset->uuconf_qtimegrade; } if (iret != UUCONF_SUCCESS) @@ -259,6 +264,7 @@ _uuconf_iv2_system_internal (qglobal, zsystem, qsys) else qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_zport = pzsplit[3]; + qset->uuconf_qport->uuconf_u.uuconf_stcp.uuconf_pzdialer = NULL; } if (ctoks < 4) diff --git a/gnu/libexec/uucp/libuuconf/vsnams.c b/gnu/libexec/uucp/libuuconf/vsnams.c index 0bf04b581d8..701bbe87d25 100644 --- a/gnu/libexec/uucp/libuuconf/vsnams.c +++ b/gnu/libexec/uucp/libuuconf/vsnams.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_vsnams_rcsid[] = "$Id: vsnams.c,v 1.1 1993/08/04 19:35:29 jtc Exp $"; +const char _uuconf_vsnams_rcsid[] = "$Id: vsnams.c,v 1.2 1994/10/24 22:26:17 jtc Exp $"; #endif #include <errno.h> diff --git a/gnu/libexec/uucp/libuuconf/vsys.c b/gnu/libexec/uucp/libuuconf/vsys.c index c0280cce3f1..4ee8df4dfc1 100644 --- a/gnu/libexec/uucp/libuuconf/vsys.c +++ b/gnu/libexec/uucp/libuuconf/vsys.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucnfi.h" #if USE_RCS_ID -const char _uuconf_vsys_rcsid[] = "$Id: vsys.c,v 1.1 1993/08/04 19:35:30 jtc Exp $"; +const char _uuconf_vsys_rcsid[] = "$Id: vsys.c,v 1.2 1994/10/24 22:26:23 jtc Exp $"; #endif /* Get system information from the V2 configuration files. This is a diff --git a/gnu/libexec/uucp/libuucp/MANIFEST b/gnu/libexec/uucp/libuucp/MANIFEST index 093924858ea..4fe9c3b318e 100644 --- a/gnu/libexec/uucp/libuucp/MANIFEST +++ b/gnu/libexec/uucp/libuucp/MANIFEST @@ -22,6 +22,7 @@ strncs.c strrch.c strstr.c strtol.c +strtou.c xfree.c xmall.c xreall.c diff --git a/gnu/libexec/uucp/libuucp/buffer.c b/gnu/libexec/uucp/libuucp/buffer.c index c44fa451394..8ddb2219cf4 100644 --- a/gnu/libexec/uucp/libuucp/buffer.c +++ b/gnu/libexec/uucp/libuucp/buffer.c @@ -1,7 +1,7 @@ /* buffer.c Manipulate buffers used to hold strings. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of Taylor UUCP. @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -97,13 +97,31 @@ void ubuffree (z) char *z; { - size_t ioff; struct sbuf *q; + /* The type of ioff should be size_t, but making it int avoids a bug + in some versions of the HP/UX compiler, and will always work. */ + int ioff; if (z == NULL) return; ioff = offsetof (struct sbuf, u); q = (struct sbuf *) (pointer) (z - ioff); + +#ifdef DEBUG_BUFFER + { + struct sbuf *qlook; + + for (qlook = qBlist; qlook != NULL; qlook = qlook->qnext) + { + if (qlook == q) + { + ulog (LOG_ERROR, "ubuffree: Attempt to free buffer twice"); + abort (); + } + } + } +#endif + q->qnext = qBlist; qBlist = q; } diff --git a/gnu/libexec/uucp/libuucp/debug.c b/gnu/libexec/uucp/libuucp/debug.c index 86f784154ab..16c1b54891a 100644 --- a/gnu/libexec/uucp/libuucp/debug.c +++ b/gnu/libexec/uucp/libuucp/debug.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" @@ -29,6 +29,8 @@ #include "uudefs.h" +#if DEBUG > 1 + /* The debugging level. */ int iDebug; @@ -63,9 +65,9 @@ idebug_parse (z) iret = 0; - for (ztok = strtok (zcopy, ","); + for (ztok = strtok (zcopy, ", \t"); ztok != NULL; - ztok = strtok ((char *) NULL, ",")) + ztok = strtok ((char *) NULL, ", \t")) { if (strcasecmp (ztok, "all") == 0) { @@ -91,6 +93,8 @@ idebug_parse (z) return iret; } +#endif /* DEBUG > 1 */ + /* A debugging routine used when displaying buffers. */ size_t diff --git a/gnu/libexec/uucp/libuucp/getlin.c b/gnu/libexec/uucp/libuucp/getlin.c index 1c204e74ee3..983da7d1875 100644 --- a/gnu/libexec/uucp/libuucp/getlin.c +++ b/gnu/libexec/uucp/libuucp/getlin.c @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" diff --git a/gnu/libexec/uucp/libuucp/parse.c b/gnu/libexec/uucp/libuucp/parse.c index 6b928a4eed4..40bc6353b15 100644 --- a/gnu/libexec/uucp/libuucp/parse.c +++ b/gnu/libexec/uucp/libuucp/parse.c @@ -1,7 +1,7 @@ /* parse.c Parse a UUCP command string. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char parse_rcsid[] = "$Id: parse.c,v 1.1 1993/08/04 19:35:49 jtc Exp $"; +const char parse_rcsid[] = "$Id: parse.c,v 1.2 1994/10/24 22:26:45 jtc Exp $"; #endif #include "uudefs.h" @@ -59,6 +59,7 @@ fparse_cmd (zcmd, qcmd) && qcmd->bcmd != 'P') return FALSE; + qcmd->bgrade = '\0'; qcmd->pseq = NULL; qcmd->zfrom = NULL; qcmd->zto = NULL; @@ -164,10 +165,21 @@ fparse_cmd (zcmd, qcmd) z = strtok ((char *) NULL, " \t\n"); if (z == NULL) return FALSE; - qcmd->imode = (int) strtol (z, &zend, 8); + qcmd->imode = (int) strtol (z, &zend, 0); if (*zend != '\0') return FALSE; + /* As a magic special case, if the mode came out as the decimal + values 666 or 777, assume that they actually meant the octal + values. Most systems use a leading zero, but a few do not. + Since both 666 and 777 are greater than the largest legal mode + value, which is 0777 == 511, this hack does not restrict any + legal values. */ + if (qcmd->imode == 666) + qcmd->imode = 0666; + else if (qcmd->imode == 777) + qcmd->imode = 0777; + z = strtok ((char *) NULL, " \t\n"); if (qcmd->bcmd == 'E' && z == NULL) return FALSE; diff --git a/gnu/libexec/uucp/libuucp/status.c b/gnu/libexec/uucp/libuucp/status.c index bee5f83dd08..65e854ebdca 100644 --- a/gnu/libexec/uucp/libuucp/status.c +++ b/gnu/libexec/uucp/libuucp/status.c @@ -7,6 +7,22 @@ /* Status strings. These must match enum tstatus_type. */ +#if USE_TRADITIONAL_STATUS + +const char *azStatus[] = +{ + "SUCCESSFUL", + "DEVICE FAILED", + "DIAL FAILED", + "LOGIN FAILED", + "STARTUP FAILED", + "CONVERSATION FAILED", + "TALKING", + "WRONG TIME TO CALL" +}; + +#else + const char *azStatus[] = { "Conversation complete", @@ -18,3 +34,5 @@ const char *azStatus[] = "Talking", "Wrong time to call" }; + +#endif diff --git a/gnu/libexec/uucp/libuucp/strtou.c b/gnu/libexec/uucp/libuucp/strtou.c new file mode 100644 index 00000000000..cd22506da30 --- /dev/null +++ b/gnu/libexec/uucp/libuucp/strtou.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#define UNSIGNED 1 + +#include "lib/strtol.c" diff --git a/gnu/libexec/uucp/uuchk/uuchk.c b/gnu/libexec/uucp/uuchk/uuchk.c index 41021defb80..413d8a24f88 100644 --- a/gnu/libexec/uucp/uuchk/uuchk.c +++ b/gnu/libexec/uucp/uuchk/uuchk.c @@ -1,7 +1,7 @@ /* uuchk.c Display what we think the permissions of systems are. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char uuchk_rcsid[] = "$Id: uuchk.c,v 1.1 1993/08/04 19:36:14 jtc Exp $"; +const char uuchk_rcsid[] = "$Id: uuchk.c,v 1.2 1994/10/24 22:26:59 jtc Exp $"; #endif #include "getopt.h" @@ -36,6 +36,7 @@ const char uuchk_rcsid[] = "$Id: uuchk.c,v 1.1 1993/08/04 19:36:14 jtc Exp $"; /* Local functions. */ static void ukusage P((void)); +static void ukhelp P((void)); static void ukshow P((const struct uuconf_system *qsys, pointer puuconf)); static int ikshow_port P((struct uuconf_port *qport, pointer pinfo)); @@ -44,6 +45,7 @@ static void ukshow_chat P((const struct uuconf_chat *qchat, const char *zhdr)); static void ukshow_size P((struct uuconf_timespan *q, boolean fcall, boolean flocal)); +static void ukshow_reliable P ((int i, const char *zhdr)); static void ukshow_proto_params P((struct uuconf_proto_param *pas, int cindent)); static void ukshow_time P((const struct uuconf_timespan *)); @@ -62,8 +64,18 @@ struct sinfo boolean fgot; }; +/* Program name. */ +static const char *zKprogram; + /* Long getopt options. */ -static const struct option asKlongopts[] = { { NULL, 0, NULL, 0 } }; +static const struct option asKlongopts[] = +{ + { "config", required_argument, NULL, 'I' }, + { "debug", required_argument, NULL, 'x' }, + { "version", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, 1 }, + { NULL, 0, NULL, 0 } +}; int main (argc, argv) @@ -77,7 +89,9 @@ main (argc, argv) pointer puuconf; char **pzsystems; - while ((iopt = getopt_long (argc, argv, "I:x:", asKlongopts, + zKprogram = argv[0]; + + while ((iopt = getopt_long (argc, argv, "I:vx:", asKlongopts, (int *) NULL)) != EOF) { switch (iopt) @@ -92,18 +106,34 @@ main (argc, argv) information for this program. */ break; + case 'v': + /* Print version and exit. */ + printf ("%s: Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", + zKprogram, VERSION); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + + case 1: + /* --help. */ + ukhelp (); + exit (EXIT_SUCCESS); + /*NOTREACHED*/ + case 0: /* Long option found and flag set. */ break; default: ukusage (); - break; + /*NOTREACHED*/ } } if (optind != argc) - ukusage (); + { + fprintf (stderr, "%s: too many arguments", zKprogram); + ukusage (); + } iret = uuconf_init (&puuconf, (const char *) NULL, zconfig); if (iret != UUCONF_SUCCESS) @@ -113,6 +143,12 @@ main (argc, argv) if (iret != UUCONF_SUCCESS) ukuuconf_error (puuconf, iret); + if (*pzsystems == NULL) + { + fprintf (stderr, "%s: no systems found\n", zKprogram); + exit (EXIT_FAILURE); + } + while (*pzsystems != NULL) { struct uuconf_system ssys; @@ -136,18 +172,26 @@ main (argc, argv) /* Print a usage message and die. */ -static void -ukusage () +static void ukusage () { - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - VERSION); - fprintf (stderr, - "Usage: uuchk [-I file]\n"); - fprintf (stderr, - " -I file: Set configuration file to use\n"); + fprintf (stderr, "Usage: %s [{-I,--config} file]\n", zKprogram); + fprintf (stderr, "Use %s --help for help\n", zKprogram); exit (EXIT_FAILURE); } + +/* Print a help message. */ + +static void +ukhelp () +{ + printf ("Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n", + VERSION); + printf ("Usage: %s [{-I,--config} file] [-v] [--version] [--help]\n", + zKprogram); + printf (" -I,--config file: Set configuration file to use\n"); + printf (" -v,--version: Print version and exit\n"); + printf (" --help: Print help and exit\n"); +} /* Dump out the information for a system. */ @@ -310,6 +354,8 @@ ukshow (qsys, puuconf) iret = uuconf_callout (puuconf, qsys, &zlogin, &zpass); if (iret == UUCONF_NOT_FOUND) printf (" Can not determine login name or password\n"); + else if (UUCONF_ERROR_VALUE (iret) == UUCONF_FOPEN_FAILED) + printf (" Can not read call out file\n"); else if (iret != UUCONF_SUCCESS) ukuuconf_error (puuconf, iret); else @@ -401,7 +447,7 @@ ukshow (qsys, puuconf) if (fcalled) { ukshow_size (qsys->uuconf_qcalled_local_size, FALSE, TRUE); - ukshow_size (qsys->uuconf_qcalled_remote_size, FALSE, TRUE); + ukshow_size (qsys->uuconf_qcalled_remote_size, FALSE, FALSE); } if (fcall) @@ -498,7 +544,9 @@ ikshow_port (qport, pinfo) struct sinfo *qi = (struct sinfo *) pinfo; char **pz; struct uuconf_modem_port *qmodem; + struct uuconf_tcp_port *qtcp; struct uuconf_tli_port *qtli; + struct uuconf_pipe_port *qpipe; qi->fgot = TRUE; @@ -513,13 +561,21 @@ ikshow_port (qport, pinfo) if (qport->uuconf_u.uuconf_sdirect.uuconf_zdevice != NULL) printf (" Device %s\n", qport->uuconf_u.uuconf_sdirect.uuconf_zdevice); + else + printf (" Using port name as device name\n"); printf (" Speed %ld\n", qport->uuconf_u.uuconf_sdirect.uuconf_ibaud); + printf (" Carrier %savailable\n", + qport->uuconf_u.uuconf_sdirect.uuconf_fcarrier ? "" : "not "); + printf (" Hardware flow control %savailable\n", + qport->uuconf_u.uuconf_sdirect.uuconf_fhardflow ? "" : "not "); break; case UUCONF_PORTTYPE_MODEM: qmodem = &qport->uuconf_u.uuconf_smodem; printf (" Port type modem\n"); if (qmodem->uuconf_zdevice != NULL) printf (" Device %s\n", qmodem->uuconf_zdevice); + else + printf (" Using port name as device name\n"); if (qmodem->uuconf_zdial_device != NULL) printf (" Dial device %s\n", qmodem->uuconf_zdial_device); printf (" Speed %ld\n", qmodem->uuconf_ibaud); @@ -528,6 +584,8 @@ ikshow_port (qport, pinfo) qmodem->uuconf_ihighbaud); printf (" Carrier %savailable\n", qmodem->uuconf_fcarrier ? "" : "not "); + printf (" Hardware flow control %savailable\n", + qmodem->uuconf_fhardflow ? "" : "not "); if (qmodem->uuconf_qdialer != NULL) { printf (" Specially defined dialer\n"); @@ -589,9 +647,17 @@ ikshow_port (qport, pinfo) printf (" *** No dialer information\n"); break; case UUCONF_PORTTYPE_TCP: + qtcp = &qport->uuconf_u.uuconf_stcp; printf (" Port type tcp\n"); - printf (" TCP service %s\n", - qport->uuconf_u.uuconf_stcp.uuconf_zport); + printf (" TCP service %s\n", qtcp->uuconf_zport); + if (qtcp->uuconf_pzdialer != NULL + && qtcp->uuconf_pzdialer[0] != NULL) + { + printf (" Dialer sequence"); + for (pz = qtcp->uuconf_pzdialer; *pz != NULL; pz++) + printf (" %s", *pz); + printf ("\n"); + } break; case UUCONF_PORTTYPE_TLI: qtli = &qport->uuconf_u.uuconf_stli; @@ -599,6 +665,8 @@ ikshow_port (qport, pinfo) qtli->uuconf_fstream ? "S" : ""); if (qtli->uuconf_zdevice != NULL) printf (" Device %s\n", qtli->uuconf_zdevice); + else + printf (" Using port name as device name\n"); if (qtli->uuconf_pzpush != NULL) { printf (" Push"); @@ -617,6 +685,17 @@ ikshow_port (qport, pinfo) if (qtli->uuconf_zservaddr != NULL) printf (" Server address %s\n", qtli->uuconf_zservaddr); break; + case UUCONF_PORTTYPE_PIPE: + qpipe = &qport->uuconf_u.uuconf_spipe; + printf (" Port type pipe\n"); + if (qpipe->uuconf_pzcmd != NULL) + { + printf (" Command"); + for (pz = qpipe->uuconf_pzcmd; *pz != NULL; pz++) + printf (" %s", *pz); + printf ("\n"); + } + break; default: fprintf (stderr, " CAN'T HAPPEN\n"); break; @@ -628,6 +707,9 @@ ikshow_port (qport, pinfo) if (qport->uuconf_zlockname != NULL) printf (" Will use lockname %s\n", qport->uuconf_zlockname); + if ((qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) + ukshow_reliable (qport->uuconf_ireliable, " "); + if (qport->uuconf_qproto_params != NULL) ukshow_proto_params (qport->uuconf_qproto_params, 3); @@ -656,6 +738,8 @@ ukshow_dialer (q) } ukshow_chat (&q->uuconf_scomplete, " When complete chat"); ukshow_chat (&q->uuconf_sabort, " When aborting chat"); + if ((q->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) + ukshow_reliable (q->uuconf_ireliable, " "); if (q->uuconf_qproto_params != NULL) ukshow_proto_params (q->uuconf_qproto_params, 4); } @@ -744,6 +828,29 @@ ukshow_size (qspan, fcall, flocal) printf (" (At other times may send files of any size)\n"); } +/* Show reliability information. */ + +static void +ukshow_reliable (i, zhdr) + int i; + const char *zhdr; +{ + printf ("%sCharacteristics:", zhdr); + if ((i & UUCONF_RELIABLE_EIGHT) != 0) + printf (" eight-bit-clean"); + else + printf (" not-eight-bit-clean"); + if ((i & UUCONF_RELIABLE_RELIABLE) != 0) + printf (" reliable"); + if ((i & UUCONF_RELIABLE_ENDTOEND) != 0) + printf (" end-to-end"); + if ((i & UUCONF_RELIABLE_FULLDUPLEX) != 0) + printf (" fullduplex"); + else + printf (" halfduplex"); + printf ("\n"); +} + /* Show protocol parameters. */ static void @@ -849,8 +956,8 @@ ukuuconf_error (puuconf, iret) (void) uuconf_error_string (puuconf, iret, ab, sizeof ab); if ((iret & UUCONF_ERROR_FILENAME) == 0) - fprintf (stderr, "uuchk: %s\n", ab); + fprintf (stderr, "%s: %s\n", zKprogram, ab); else - fprintf (stderr, "uuchk:%s\n", ab); + fprintf (stderr, "%s:%s\n", zKprogram, ab); exit (EXIT_FAILURE); } diff --git a/gnu/libexec/uucp/uucico/Makefile b/gnu/libexec/uucp/uucico/Makefile index e4c58aa7af7..89e1ddf74f8 100644 --- a/gnu/libexec/uucp/uucico/Makefile +++ b/gnu/libexec/uucp/uucico/Makefile @@ -1,5 +1,5 @@ # Makefile for uucico -# $Id: Makefile,v 1.2 1993/08/05 16:15:06 jtc Exp $ +# $Id: Makefile,v 1.3 1994/10/24 22:27:09 jtc Exp $ BINDIR= $(sbindir) BINOWN= $(owner) @@ -12,6 +12,7 @@ SRCS= uucico.c trans.c send.c rec.c xcmd.c prot.c protg.c protf.c \ LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) CFLAGS+= -I$(.CURDIR)/../common_sources\ + -DOWNER=\"$(owner)\" \ -DVERSION=\"$(VERSION)\" MAN8= uucico.0 diff --git a/gnu/libexec/uucp/uucico/prote.c b/gnu/libexec/uucp/uucico/prote.c index 2d2e77e1d8e..d55f43d7e62 100644 --- a/gnu/libexec/uucp/uucico/prote.c +++ b/gnu/libexec/uucp/uucico/prote.c @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char prote_rcsid[] = "$Id: prote.c,v 1.1 1993/08/04 19:36:18 jtc Exp $"; +const char prote_rcsid[] = "$Id: prote.c,v 1.2 1994/10/24 22:27:14 jtc Exp $"; #endif #include "uudefs.h" diff --git a/gnu/libexec/uucp/uucico/protf.c b/gnu/libexec/uucp/uucico/protf.c index 3cdacef25ee..29a3a0dc6f0 100644 --- a/gnu/libexec/uucp/uucico/protf.c +++ b/gnu/libexec/uucp/uucico/protf.c @@ -1,7 +1,7 @@ /* protf.c The 'f' protocol. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char protf_rcsid[] = "$Id: protf.c,v 1.1 1993/08/04 19:36:19 jtc Exp $"; +const char protf_rcsid[] = "$Id: protf.c,v 1.2 1994/10/24 22:27:18 jtc Exp $"; #endif #include <ctype.h> @@ -340,6 +340,10 @@ ffprocess_data (qdaemon, pfexit, pcneed) { for (i = iPrecstart; i < CRECBUFLEN && i != iPrecend; i++) { + /* Some systems seem to send characters with parity, so + strip the parity bit. */ + abPrecbuf[i] &= 0x7f; + if (abPrecbuf[i] == '\r') { int istart; @@ -395,7 +399,9 @@ ffprocess_data (qdaemon, pfexit, pcneed) { int b; - b = *zfrom++ & 0xff; + /* Some systems seem to send characters with parity, so + strip the parity bit. */ + b = *zfrom++ & 0x7f; if (b < 040 || b > 0176) { ulog (LOG_ERROR, "Illegal byte %d", b); diff --git a/gnu/libexec/uucp/uucico/protg.c b/gnu/libexec/uucp/uucico/protg.c index e9eaeb04906..3073351125a 100644 --- a/gnu/libexec/uucp/uucico/protg.c +++ b/gnu/libexec/uucp/uucico/protg.c @@ -1,7 +1,7 @@ /* protg.c The 'g' protocol. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char protg_rcsid[] = "$Id: protg.c,v 1.1 1993/08/04 19:36:20 jtc Exp $"; +const char protg_rcsid[] = "$Id: protg.c,v 1.2 1994/10/24 22:27:29 jtc Exp $"; #endif #include <ctype.h> @@ -346,6 +346,12 @@ static long cGbad_order; received). */ static long cGremote_rejects; +/* Number of duplicate RR packets treated as RJ packets. Some UUCP + packages appear to never send RJ packets, but only RR packets. If + no RJ has been seen, fgprocess_data treats a duplicate RR as an RJ + and increments this variable. */ +static long cGremote_duprrs; + /* The error level. This is the total number of errors as adjusted by cGerror_decay. */ static long cGerror_level; @@ -419,6 +425,7 @@ fgstart (qdaemon, pzlog) cGbad_checksum = 0; cGbad_order = 0; cGremote_rejects = 0; + cGremote_duprrs = 0; cGerror_level = 0; cGexpect_bad_order = 0; @@ -440,6 +447,13 @@ fgstart (qdaemon, pzlog) iseg = 1; } + if (iGrequest_winsize <= 0 || iGrequest_winsize > 7) + { + ulog (LOG_ERROR, "Illegal window size %d for '%c' protocol", + iGrequest_winsize, qdaemon->qproto->bname); + iGrequest_winsize = IWINDOW; + } + fgota = FALSE; fgotb = FALSE; for (i = 0; i < cGstartup_retries; i++) @@ -503,10 +517,14 @@ fgstart (qdaemon, pzlog) if (! fginit_sendbuffers (TRUE)) return FALSE; - *pzlog = zbufalc (sizeof "protocol '' packet size window " + 50); - sprintf (*pzlog, "protocol '%c' packet size %d window %d", + *pzlog = + zbufalc (sizeof "protocol '' sending packet/window / receiving /" + + 64); + sprintf (*pzlog, + "protocol '%c' sending packet/window %d/%d receiving %d/%d", qdaemon->qproto->bname, (int) iGremote_packsize, - (int) iGremote_winsize); + (int) iGremote_winsize, (int) iGrequest_packsize, + (int) iGrequest_winsize); return TRUE; } @@ -528,6 +546,22 @@ fbiggstart (qdaemon, pzlog) fGshort_packets = FALSE; return fgstart (qdaemon, pzlog); } + +/* The 'v' protocol is identical to the 'g' protocol, except that the + packet size defaults to 512 bytes. Rather than really get it + right, we automatically switch from the usual default of 64 to 512. + This won't work correctly if somebody does protocol-parameter v + packet-size 64. */ + +boolean +fvstart (qdaemon, pzlog) + struct sdaemon *qdaemon; + char **pzlog; +{ + if (iGrequest_packsize == IPACKSIZE) + iGrequest_packsize = 1024; + return fgstart (qdaemon, pzlog); +} /* Exchange initialization messages with the other system. @@ -671,10 +705,12 @@ fgshutdown (qdaemon) if (cGbad_hdr != 0 || cGbad_checksum != 0 || cGbad_order != 0 - || cGremote_rejects != 0) + || cGremote_rejects != 0 + || cGremote_duprrs != 0) ulog (LOG_NORMAL, "Errors: header %ld, checksum %ld, order %ld, remote rejects %ld", - cGbad_hdr, cGbad_checksum, cGbad_order, cGremote_rejects); + cGbad_hdr, cGbad_checksum, cGbad_order, + cGremote_duprrs + cGremote_rejects); /* Reset all the parameters to their default values, so that the protocol parameters used for this connection do not affect the @@ -739,7 +775,8 @@ fgsendcmd (qdaemon, z, ilocal, iremote) } memcpy (zpacket, z, clen); - bzero (zpacket + clen, csize - clen); + if (csize > clen) + bzero (zpacket + clen, csize - clen); fagain = FALSE; if (! fgsenddata (qdaemon, zpacket, csize, 0, 0, (long) 0)) @@ -894,7 +931,8 @@ fgsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) --zdata; zdata[0] = (char) cshort; zdata[-1] = '\0'; - bzero (zdata + cdata + 1, cshort - 1); + if (cshort > 1) + bzero (zdata + cdata + 1, cshort - 1); } else { @@ -1568,12 +1606,15 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound) /* Annoyingly, some UUCP packages appear to send an RR packet rather than an RJ packet when they want a packet to be - resent. If we get a duplicate RR, we treat it as an RJ. */ + resent. If we get a duplicate RR and we've never seen an RJ, + we treat the RR as an RJ. */ fduprr = FALSE; - if (CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL + if (cGremote_rejects == 0 + && CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL && CONTROL_XXX (ab[IFRAME_CONTROL]) == RR && iGremote_ack == CONTROL_YYY (ab[IFRAME_CONTROL]) - && INEXTSEQ (iGremote_ack) != iGsendseq) + && INEXTSEQ (iGremote_ack) != iGsendseq + && iGretransmit_seq != -1) { DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, "fgprocess_data: Treating duplicate RR as RJ"); @@ -1581,11 +1622,12 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound) } /* Update the received sequence number from the yyy field of a - data packet or an RR control packet. If we've been delaying - sending packets until we received an ack, this may send out - some packets. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL - || CONTROL_XXX (ab[IFRAME_CONTROL]) == RR) + data packet (if it is the one we are expecting) or an RR + control packet. If we've been delaying sending packets until + we received an ack, this may send out some packets. */ + if ((CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL + && CONTROL_XXX (ab[IFRAME_CONTROL]) == INEXTSEQ (iGrecseq)) + || (CONTROL_XXX (ab[IFRAME_CONTROL]) == RR && ! fduprr)) { if (! fggot_ack (qdaemon, CONTROL_YYY (ab[IFRAME_CONTROL]))) return FALSE; @@ -1773,7 +1815,10 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound) iGsendseq, iGretransmit_seq); ++cGresent_packets; - ++cGremote_rejects; + if (fduprr) + ++cGremote_duprrs; + else + ++cGremote_rejects; ++cGerror_level; if (! fgcheck_errors (qdaemon)) return FALSE; diff --git a/gnu/libexec/uucp/uucico/proti.c b/gnu/libexec/uucp/uucico/proti.c index 606b2bd94f3..8a5ac7d10ec 100644 --- a/gnu/libexec/uucp/uucico/proti.c +++ b/gnu/libexec/uucp/uucico/proti.c @@ -1,7 +1,7 @@ /* proti.c The 'i' protocol. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1993 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -20,13 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author of the program may be contacted at ian@airs.com or - c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254. + c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. */ #include "uucp.h" #if USE_RCS_ID -const char proti_rcsid[] = "$Id: proti.c,v 1.1 1993/08/04 19:36:22 jtc Exp $"; +const char proti_rcsid[] = "$Id: proti.c,v 1.2 1994/10/24 22:27:38 jtc Exp $"; #endif #include <ctype.h> @@ -153,7 +153,10 @@ const char proti_rcsid[] = "$Id: proti.c,v 1.1 1993/08/04 19:36:22 jtc Exp $"; #define IMAXSEQ 32 /* Get the next sequence number given a sequence number. */ -#define INEXTSEQ(i) ((i + 1) & (IMAXSEQ - 1)) +#define INEXTSEQ(i) (((i) + 1) & (IMAXSEQ - 1)) + +/* Get the previous sequence number given a sequence number. */ +#define IPREVSEQ(i) (((i) + IMAXSEQ - 1) & (IMAXSEQ - 1)) /* Compute i1 - i2 in sequence space (i.e., the number of packets from i2 to i1). */ @@ -216,17 +219,14 @@ static int iIremote_packsize; static int iIalc_packsize; /* Forced remote packet size, used if non-zero (protocol parameter - ``remote-packet-size''). */ + ``remote-packet-size''). There is no forced remote window size + because the ACK strategy requires that both sides agree on the + window size. */ static int iIforced_remote_packsize = 0; -/* Remote window size (set from SYNC packet or from - iIforced_remote_winsize). */ +/* Remote window size (set from SYNC packet). */ static int iIremote_winsize; -/* Forced remote window size, used if non-zero (protocol parameter - ``remote-window''). */ -static int iIforced_remote_winsize = 0; - /* Timeout to use when sending the SYNC packet (protocol parameter ``sync-timeout''). */ int cIsync_timeout = CSYNC_TIMEOUT; @@ -251,6 +251,11 @@ static int cIerrors = CERRORS; the error level by one (protocol parameter ``error-decay''). */ static int cIerror_decay = CERROR_DECAY; +/* The number of packets we should wait to receive before sending an + ACK; this is set by default to half the window size we have + requested (protocol parameter ``ack-frequency''). */ +static int cIack_frequency = 0; + /* The set of characters to avoid (protocol parameter ``avoid''). This is actually part of the 'j' protocol; it is defined in this file because the 'i' and 'j' protocols use the same protocol @@ -334,8 +339,6 @@ struct uuconf_cmdtab asIproto_params[] = { "window", UUCONF_CMDTABTYPE_INT, (pointer) &iIrequest_winsize, NULL }, { "remote-packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iIforced_remote_packsize, NULL }, - { "remote-window", UUCONF_CMDTABTYPE_INT, - (pointer) &iIforced_remote_winsize, NULL }, { "sync-timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_timeout, NULL }, { "sync-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_retries, @@ -344,6 +347,7 @@ struct uuconf_cmdtab asIproto_params[] = { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cIretries, NULL }, { "errors", UUCONF_CMDTABTYPE_INT, (pointer) &cIerrors, NULL }, { "error-decay", UUCONF_CMDTABTYPE_INT, (pointer) &cIerror_decay, NULL }, + { "ack-frequency", UUCONF_CMDTABTYPE_INT, (pointer) &cIack_frequency, NULL }, /* The ``avoid'' protocol parameter is part of the 'j' protocol, but it is convenient for the 'i' and 'j' protocols to share the same protocol parameter table. */ @@ -398,7 +402,7 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) boolean (*pfreceive) P((struct sconnection *qconn, size_t cneed, size_t *pcrec, int ctimeout, boolean freport)); { - char ab[CHDRLEN + 3 + CCKSUMLEN]; + char ab[CHDRLEN + 4 + CCKSUMLEN]; unsigned long icksum; int ctries; int csyncs; @@ -414,10 +418,6 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) else iIremote_packsize = iIforced_remote_packsize; iIalc_packsize = 0; - if (iIforced_remote_winsize <= 0 || iIforced_remote_winsize >= IMAXSEQ) - iIforced_remote_winsize = 0; - else - iIremote_winsize = iIforced_remote_winsize; iIsendseq = 1; iIrecseq = 0; @@ -435,16 +435,41 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) cIbad_cksum = 0; cIremote_rejects = 0; + if (iIrequest_packsize < 0 || iIrequest_packsize > imaxpacksize) + { + ulog (LOG_ERROR, "Illegal protocol '%c' packet size; using %d", + qdaemon->qproto->bname, imaxpacksize); + iIrequest_packsize = imaxpacksize; + } + + /* The maximum permissible window size is 16. Otherwise the + protocol can get confused because a duplicated packet may arrive + out of order. If the window size is large in such a case, the + duplicate packet may be treated as a packet in the upcoming + window, causing the protocol to assume that all intermediate + packets have been lost, leading to immense confusion. */ + if (iIrequest_winsize < 0 || iIrequest_winsize > IMAXSEQ / 2) + { + ulog (LOG_ERROR, "Illegal protocol '%c' window size; using %d", + qdaemon->qproto->bname, IREQUEST_WINSIZE); + iIrequest_winsize = IREQUEST_WINSIZE; + } + + /* The default for the ACK frequency is half the window size. */ + if (cIack_frequency <= 0 || cIack_frequency >= iIrequest_winsize) + cIack_frequency = iIrequest_winsize / 2; + ab[IHDR_INTRO] = IINTRO; ab[IHDR_LOCAL] = ab[IHDR_REMOTE] = IHDRWIN_SET (0, 0); - ab[IHDR_CONTENTS1] = IHDRCON_SET1 (SYNC, qdaemon->fcaller, 3); - ab[IHDR_CONTENTS2] = IHDRCON_SET2 (SYNC, qdaemon->fcaller, 3); + ab[IHDR_CONTENTS1] = IHDRCON_SET1 (SYNC, qdaemon->fcaller, 4); + ab[IHDR_CONTENTS2] = IHDRCON_SET2 (SYNC, qdaemon->fcaller, 4); ab[IHDR_CHECK] = IHDRCHECK_VAL (ab); ab[CHDRLEN + 0] = (iIrequest_packsize >> 8) & 0xff; ab[CHDRLEN + 1] = iIrequest_packsize & 0xff; ab[CHDRLEN + 2] = iIrequest_winsize; - icksum = icrc (ab + CHDRLEN, 3, ICRCINIT); - UCKSUM_SET (ab + CHDRLEN + 3, icksum); + ab[CHDRLEN + 3] = qdaemon->cchans; + icksum = icrc (ab + CHDRLEN, 4, ICRCINIT); + UCKSUM_SET (ab + CHDRLEN + 4, icksum); /* The static cIsyncs is incremented each time a SYNC packet is received. */ @@ -455,11 +480,11 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) { boolean ftimedout; - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fistart: Sending SYNC packsize %d winsize %d", - iIrequest_packsize, iIrequest_winsize); + DEBUG_MESSAGE3 (DEBUG_PROTO, + "fistart: Sending SYNC packsize %d winsize %d channels %d", + iIrequest_packsize, iIrequest_winsize, qdaemon->cchans); - if (! (*pfIsend) (qdaemon->qconn, ab, CHDRLEN + 3 + CCKSUMLEN, + if (! (*pfIsend) (qdaemon->qconn, ab, CHDRLEN + 4 + CCKSUMLEN, TRUE)) return FALSE; @@ -509,11 +534,15 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) if (iseq >= IMAXSEQ) { - *pzlog = zbufalc (sizeof "protocol 'i' packet size %d window %d" - + 50); - sprintf (*pzlog, "protocol '%c' packet size %d window %d", - qdaemon->qproto->bname, iIremote_packsize, - iIremote_winsize); + *pzlog = + zbufalc (sizeof "protocol '' sending packet/window / receiving /" + + 64); + sprintf (*pzlog, + "protocol '%c' sending packet/window %d/%d receiving %d/%d", + qdaemon->qproto->bname, (int) iIremote_packsize, + (int) iIremote_winsize, (int) iIrequest_packsize, + (int) iIrequest_winsize); + iIalc_packsize = iIremote_packsize; return TRUE; @@ -575,13 +604,13 @@ fishutdown (qdaemon) iIrequest_packsize = IREQUEST_PACKSIZE; iIrequest_winsize = IREQUEST_WINSIZE; iIforced_remote_packsize = 0; - iIforced_remote_winsize = 0; cIsync_timeout = CSYNC_TIMEOUT; cIsync_retries = CSYNC_RETRIES; cItimeout = CTIMEOUT; cIretries = CRETRIES; cIerrors = CERRORS; cIerror_decay = CERROR_DECAY; + cIack_frequency = 0; zJavoid_parameter = ZAVOID; return TRUE; @@ -835,8 +864,9 @@ fisenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) iIlocal_ack = iIrecseq; zhdr[IHDR_CHECK] = IHDRCHECK_VAL (zhdr); - DEBUG_MESSAGE2 (DEBUG_PROTO, "fisenddata: Sending packet %d (%d bytes)", - iIsendseq, (int) cdata); + DEBUG_MESSAGE4 (DEBUG_PROTO, + "fisenddata: Sending packet %d size %d local %d remote %d", + iIsendseq, (int) cdata, ilocal, iremote); iIsendseq = INEXTSEQ (iIsendseq); ++cIsent_packets; @@ -977,6 +1007,8 @@ ficheck_errors (qdaemon) char absync[CHDRLEN + 3 + CCKSUMLEN]; unsigned long icksum; + /* Don't bother sending the number of channels in this + packet. */ iIrequest_packsize /= 2; absync[IHDR_INTRO] = IINTRO; absync[IHDR_LOCAL] = IHDRWIN_SET (0, 0); @@ -1127,9 +1159,9 @@ fiprocess_data (qdaemon, pfexit, pffound, pcneed) if (iIrequest_winsize > 0 && CSEQDIFF (iseq, iIlocal_ack) > iIrequest_winsize) { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Out of order packet %d", - iseq); + DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, + "fiprocess_data: Out of order packet %d (ack %d)", + iseq, iIlocal_ack); ++cIbad_order; if (! ficheck_errors (qdaemon)) @@ -1253,7 +1285,27 @@ fiprocess_data (qdaemon, pfexit, pffound, pcneed) if (iseq != -1) { - afInaked[iseq] = FALSE; + /* If we already sent a NAK for this packet, and we have not + seen the previous packet, then forget that we sent a NAK + for this and any preceding packets. This is to handle + the following sequence: + receive packet 0 + packets 1 and 2 lost + receive packet 3 + send NAK 1 + send NAK 2 + packet 1 lost + receive packet 2 + At this point we want to send NAK 1. */ + if (afInaked[iseq] + && azIrecbuffers[IPREVSEQ (iseq)] == NULL) + { + for (i = INEXTSEQ (iIrecseq); + i != iseq; + i = INEXTSEQ (i)) + afInaked[i] = FALSE; + afInaked[iseq] = FALSE; + } /* If we haven't handled all previous packets, we must save off this packet and deal with it later. */ @@ -1263,16 +1315,16 @@ fiprocess_data (qdaemon, pfexit, pffound, pcneed) || (iIrequest_winsize > 0 && CSEQDIFF (iseq, iIrecseq) > iIrequest_winsize)) { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Ignoring out of order packet %d", - iseq); + DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, + "fiprocess_data: Ignoring out of order packet %d (recseq %d)", + iseq, iIrecseq); continue; } else { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Saving unexpected packet %d", - iseq); + DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, + "fiprocess_data: Saving unexpected packet %d (recseq %d)", + iseq, iIrecseq); if (azIrecbuffers[iseq] == NULL) { @@ -1352,7 +1404,7 @@ fiprocess_data (qdaemon, pfexit, pffound, pcneed) However, it can happen if we receive a burst of short packets, such as a set of command acknowledgements. */ if (iIrequest_winsize > 0 - && CSEQDIFF (iIrecseq, iIlocal_ack) >= iIrequest_winsize / 2) + && CSEQDIFF (iIrecseq, iIlocal_ack) >= cIack_frequency) { char aback[CHDRLEN]; @@ -1401,9 +1453,11 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit) boolean fret; iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]); - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fiprocess_packet: Got DATA packet %d size %d", - iseq, cfirst + csecond); + DEBUG_MESSAGE4 (DEBUG_PROTO, + "fiprocess_packet: Got DATA packet %d size %d local %d remote %d", + iseq, cfirst + csecond, + IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]), + IHDRWIN_GETCHAN (zhdr[IHDR_LOCAL])); fret = fgot_data (qdaemon, zfirst, (size_t) cfirst, zsecond, (size_t) csecond, IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]), @@ -1417,7 +1471,7 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit) case SYNC: { - int ipack, iwin; + int ipack, iwin, cchans; /* We accept a SYNC packet to adjust the packet and window sizes at any time. */ @@ -1436,16 +1490,31 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit) else iwin = zsecond[2 - cfirst]; - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fiprocess_packet: Got SYNC packsize %d winsize %d", - ipack, iwin); + /* The fourth byte in a SYNC packet is the number of channels + to use. This is optional. Switching the number of + channels in the middle of a conversation may cause + problems. */ + if (cfirst + csecond <= 3) + cchans = 0; + else + { + if (cfirst > 3) + cchans = zfirst[3]; + else + cchans = zsecond[3 - cfirst]; + if (cchans > 0 && cchans < 8) + qdaemon->cchans = cchans; + } + + DEBUG_MESSAGE3 (DEBUG_PROTO, + "fiprocess_packet: Got SYNC packsize %d winsize %d channels %d", + ipack, iwin, cchans); if (iIforced_remote_packsize == 0 && (iIalc_packsize == 0 || ipack <= iIalc_packsize)) iIremote_packsize = ipack; - if (iIforced_remote_winsize == 0) - iIremote_winsize = iwin; + iIremote_winsize = iwin; /* We increment a static variable to tell the initialization code that a SYNC was received, and we set *pfexit to TRUE @@ -1477,44 +1546,68 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit) iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]); - /* The timeout code will send a NAK for the packet the remote - side wants. So we may see a NAK here for the packet we are - about to send. */ - if (iseq == iIsendseq - || (iIremote_winsize > 0 - && (CSEQDIFF (iseq, iIremote_ack) > iIremote_winsize - || CSEQDIFF (iIsendseq, iseq) > iIremote_winsize))) + /* If the remote side times out while waiting for a packet, it + will send a NAK for the next packet it wants to see. If we + have not sent that packet yet, and we have no + unacknowledged data, it implies that the remote side has a + window full of data to send, which implies that our ACK has + been lost. Therefore, we send an ACK. */ + if (iseq == iIsendseq && + INEXTSEQ (iIremote_ack) == iIsendseq) { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_packet: Ignoring out of order NAK %d", - iseq); - return TRUE; - } + char aback[CHDRLEN]; + + aback[IHDR_INTRO] = IINTRO; + aback[IHDR_LOCAL] = IHDRWIN_SET (0, 0); + aback[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0); + iIlocal_ack = iIrecseq; + aback[IHDR_CONTENTS1] = IHDRCON_SET1 (ACK, qdaemon->fcaller, 0); + aback[IHDR_CONTENTS2] = IHDRCON_SET2 (ACK, qdaemon->fcaller, 0); + aback[IHDR_CHECK] = IHDRCHECK_VAL (aback); - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_packet: Got NAK %d; resending packet", - iseq); + DEBUG_MESSAGE1 (DEBUG_PROTO, "fiprocess_packet: Sending ACK %d", + iIrecseq); - /* Update the received sequence number. */ - zsend = azIsendbuffers[iseq] + CHDROFFSET; - if (IHDRWIN_GETSEQ (zsend[IHDR_REMOTE]) != iIrecseq) + return (*pfIsend) (qdaemon->qconn, aback, CHDRLEN, TRUE); + } + else { - int iremote; + if (iseq == iIsendseq + || (iIremote_winsize > 0 + && (CSEQDIFF (iseq, iIremote_ack) > iIremote_winsize + || CSEQDIFF (iIsendseq, iseq) > iIremote_winsize))) + { + DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, + "fiprocess_packet: Ignoring out of order NAK %d (sendseq %d)", + iseq, iIsendseq); + return TRUE; + } - iremote = IHDRWIN_GETCHAN (zsend[IHDR_REMOTE]); - zsend[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote); - zsend[IHDR_CHECK] = IHDRCHECK_VAL (zsend); - iIlocal_ack = iIrecseq; - } + DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, + "fiprocess_packet: Got NAK %d; resending packet", + iseq); + + /* Update the received sequence number. */ + zsend = azIsendbuffers[iseq] + CHDROFFSET; + if (IHDRWIN_GETSEQ (zsend[IHDR_REMOTE]) != iIrecseq) + { + int iremote; + + iremote = IHDRWIN_GETCHAN (zsend[IHDR_REMOTE]); + zsend[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote); + zsend[IHDR_CHECK] = IHDRCHECK_VAL (zsend); + iIlocal_ack = iIrecseq; + } - ++cIresent_packets; + ++cIresent_packets; - clen = CHDRCON_GETBYTES (zsend[IHDR_CONTENTS1], - zsend[IHDR_CONTENTS2]); + clen = CHDRCON_GETBYTES (zsend[IHDR_CONTENTS1], + zsend[IHDR_CONTENTS2]); - return (*pfIsend) (qdaemon->qconn, zsend, - CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0), - TRUE); + return (*pfIsend) (qdaemon->qconn, zsend, + CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0), + TRUE); + } } case SPOS: |
