diff options
author | kris <kris@FreeBSD.org> | 2001-10-01 06:22:53 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2001-10-01 06:22:53 +0000 |
commit | ebde71313f25e6c00554d63efdb7e13e7ec8da0f (patch) | |
tree | cf5a73cdbdc325eb67758fae618b870f0530f779 | |
parent | 5a5b9f79f48be499ceca11f3d54c0525935b9ac1 (diff) | |
download | FreeBSD-src-ebde71313f25e6c00554d63efdb7e13e7ec8da0f.zip FreeBSD-src-ebde71313f25e6c00554d63efdb7e13e7ec8da0f.tar.gz |
Phase I of UUCP migration to ports. This leaves behind a minimal build
environment for cu, which is still useful.
176 files changed, 13 insertions, 67381 deletions
diff --git a/gnu/libexec/uucp/ChangeLog b/gnu/libexec/uucp/ChangeLog deleted file mode 100644 index 9f948fb..0000000 --- a/gnu/libexec/uucp/ChangeLog +++ /dev/null @@ -1,5070 +0,0 @@ -Sun Aug 20 15:12:36 1995 Ian Lance Taylor <ian@airs.com> - - * Released version 1.06.1. - - * uux.c (main): Make sure that the grade is between '0' and '9', - or 'a' and 'z', or 'A' and 'Z', in case isalnum accepts other - characters. - * uucp.c (main): Likewise. - -Sat Aug 19 23:15:21 1995 Ian Lance Taylor <ian@airs.com> - - * configure.in: Check for seteuid. - * configure: Rebuild. - * config.h.in (HAVE_SETEUID): Define. - * unix/uid.c: If HAVE_SETEUID is defined, use seteuid rather than - setuid. - * policy.h: Change HAVE_BROKEN_SETREUID comment to mention that it - does not work on 4.4BSD-Lite and NetBSD. - - * Andrey A. Chernov: uuconf.h (UUCONF_GRADE_LEGAL): Use BUCHAR. - -Wed Aug 16 21:23:39 1995 Ian Lance Taylor <ian@airs.com> - - * uucico.c (flogin_prompt): Add pzsystem parameter, and pass it to - faccept_call. Change all callers. - - * trans.c (qtransalc): Clear zlog field. - - * Makefile.in (VERSION): Change to 1.06.1. - -Thu Aug 10 22:42:53 1995 Ian Lance Taylor <ian@airs.com> - - * Released version 1.06. - - * uuconf/tsinfo.c (_uuconf_itaylor_system_internal): Don't set - uuconf_fcall merely because uuconf_qtimegrade is not set. Check - values against _uuconf_unset, not NULL. - - * trans.c (fgot_data): Only log when data comes in if fsendfile is - FALSE. - -Wed Aug 9 20:52:29 1995 Ian Lance Taylor <ian@airs.com> - - * Makefile.in (VERSION): Change to 1.06. - -Tue Aug 1 20:13:36 1995 Ian Lance Taylor <ian@airs.com> - - * uuconf/tsinfo.c (_uuconf_itaylor_system_internal): Set the fcall - field for the first alternate if it has some way of selecting a - port. - - * Ard van Breemen: unix/serial.c (fsserial_hardflow): Add support - for NCR Tower using IRTS. - - * policy.h (FSYNC_ON_CLOSE): Define. - * system.h (fsysdep_sync): Declare. - * uucp.h (fstdiosync): Define, twice. - * unix/sync.c: New file. - * copy.c (fcopy_open_file): Call fsysdep_sync. - * cu.c (icutake): Likewise. - * rec.c (frec_file_end): Likewise. - (frec_file_end): Call fstdiosync. - * uucp.c (uccopy): Likewise. - * uux.c (main): Likewise. - (uxadd_send_file): Likewise. - * unix/splcmd.c (zsysdep_spool_commands): Likewise. - * unix/Makefile.in (OBJS): Add sync.o. - (sync.o): New target. - - * Peter Wemm: unix/filnam.c (fscmd_seq): Increase the delay each - time an attempt to lock LCK..SEQ fails. - - * Peter Wemm: uustat.c (fsnotify): Escape a leading "From " when - including standard input in a mail message. - -Mon Jul 31 22:45:23 1995 Ian Lance Taylor <ian@airs.com> - - * unix/serial.c (fsserial_lockfile): In the HAVE_SVR4_LOCKFILES - case, increase the space allocated to print the major and minor - numbers. - -Sun Jul 30 22:30:51 1995 Ian Lance Taylor <ian@airs.com> - - * trans.c (fgot_data): Log a message as soon as anything comes in, - not just for file data. - - * prote.c (feprocess_data): Handle a zero length file. - -Wed Jul 19 00:14:46 1995 Ian Lance Taylor <ian@airs.com> - - * unix/xqtfil.c (fSone_dir): New static variable. - (fsysdep_get_xqt_init): Add zsystem argument. - (zsysdep_get_xqt): Likewise. - (usysdep_get_xqt_free): Likewise. - * system.h (fsysdep_get_xqt_init): Update declaration. - (zsysdep_get_xqt): Likewise. - (usysdep_get_xqt_free): Likewise. - * uuxqt.c (main): Pass zdosys for system to get_xqt routines. - * uustat.c (fsexecutions): Pass NULL for system to get_xqt - routines. - (fsquery): Likewise. - - * uux.c (main): If we are not starting uucico, and we queued a - local execution, start uuxqt. - -Tue Jul 18 22:33:08 1995 Ian Lance Taylor <ian@airs.com> - - * uuxqt.c (REMOVE_QINPUT): Define. - (uqdo_xqt_file): Set REMOVE_QINPUT if zQinput is in the spool - directory. - (isave_files): If REMOVE_QINPUT is set, save the input file. - (uqcleanup): If REMOVE_QINPUT and REMOVE_NEEDED are set, remove - the input file. - -Mon Jul 17 20:59:20 1995 Ian Lance Taylor <ian@airs.com> - - * uuchk.c (ukshow): Add missing \n. - -Sun Jul 16 12:02:03 1995 Ian Lance Taylor <ian@airs.com> - - * Makefile.in (TEXI2HTML): Define. - (doc-dist): Depend upon uucp.html; put HTML files in documentation - distribution. - (html, uucp.html): New targets. - -Mon Jul 10 20:24:48 1995 Ian Lance Taylor <ian@airs.com> - - * unix/lcksys.c: Rewrite to not truncate the system name in the - lock file name, unless HAVE_LONG_FILE_NAMES is 0. - -Sat Jul 8 13:41:26 1995 Ian Lance Taylor <ian@airs.com> - - * Andrey A. Chernov: cu.c (ucuhelp): Mention -E. - (fcudo_cmd): Use BUCHAR rather than casting to unsigned int. - (icuunrecogvar): Likewise. - (uculist_vars): Likewise. - (icuunrecogfn): Likewise. - * lib/getopt.c (_getopt_internal): Likewise. - - * Andrey A. Chernov: Makefile.in (infodir): Changed commented out - setting from share/doc to share/info. - - * Godfrey van der Linden: unix/serial.c (fsysdep_conn_io): Base - select or alarm timeout on connection speed. - - * configure.in: Move AC_PREFIX_PROGRAM before AC_PROG_CC. - * configure: Rebuild. - - * policy.h (HAVE_BROKEN_SETLKW): Add new define. - * unix/filnam.c (USE_POSIX_LOCKS): Don't set if HAVE_BROKEN_SETLKW - is set. - (fscmd_seq): If the F_SETLKW call returns EINVAL, revert to using - lock files. - - * unix/spawn.c (ixsspawn): If setreuid is available, use it, - rather than setuid, to set the real user ID to the effective user - ID. - - * Thomas Mechtersheimer: uuchk.c (main): Correct typo (iret for - iint). - - * Bob Thrush: unix/serial.c (fsserial_hardflow): Correct typo - (c_cflags for c_cflag). - - * configure.in: Check for sys/statvfs.h. Check for memset, - memcmp, and memcpy with the correct argument types (apparently - some systems require this). - * config.h.in (HAVE_SYS_STATVFS_H): Define. - * configure: Rebuild. - -Mon Jul 3 00:26:50 1995 Ian Lance Taylor <ian@airs.com> - - * Released version beta 1.06. - -Sun Jul 2 10:39:40 1995 Ian Lance Taylor <ian@airs.com> - - * configure.in: Add AC_OUTPUT code to touch stamp-h when - rebuilding config.h. - * Makefile.in (stamp-h): Remove ``echo > stamp-h''. - - * Makefile.in (dist): Fix for srcdir != objdir. - * unix/Makefile.in (dist): Likewise. - * uuconf/Makefile.in (dist): Likewise. - * lib/Makefile.in (dist): Likewise. - -Sat Jul 1 13:42:35 1995 Ian Lance Taylor <ian@airs.com> - - * configure.in: Check for termios.h. - * config.h.in (HAVE_TERMIOS_H): Mention. - * policy.h: Set HAVE_POSIX_TERMIOS if HAVE_TERMIOS_H. - -Fri Jun 30 09:24:13 1995 Ian Lance Taylor <ian@airs.com> - - * uux.c (zXxqt_name): Remove. - (fXxqtlocal): New static variable; replaces local fxqtlocal. - (sXxqtsys): New static variable; replaces local sxqtsys. - (zXxqtloc): New static variable; replaces local zxqtloc. - (bXgrade): New static variable; replaces local bgrade. - (abXxqt_tname): New static variable; replaces local abxqt_tname. - (abXxqt_xname): New static variable; replaces local abxqt_xname. - (main): Use new static variables instead of locals. Don't set - zXxqt_name. - (uxadd_xqt_line): Get file name here before opening file. - (uxadd_send_file): Remove parameters qxqtsys, zxqtloc, and bgrade. - Change all callers. - - * unix/filnam.c (usput62): New static function. - (zscmd_file): When SPOOLDIR_TAYLOR, use a different algorithm - which does not read the sequence file. - * unix/splcmd.c (zsysdep_spool_commands): Return value of - zscmd_file might already exist; handle that case. - * unix/jobid.c (zsfile_to_jobid): Change jobid format when - SPOOLDIR_TAYLOR, since sequence number is now much longer. - (zsjobid_to_file): Corresponding change. - * unix/work.c (fswork_file): When SPOOLDIR_TAYLOR, don't require - the the file name to be 7 characters long. - (bsgrade): Change algorithm used when SPOOLDIR_TAYLOR. - - * uustat.c (fsworkfile_show): Correct kill prompt to put program - name at start of line. Add trailing space after question mark. - (fsexecutions): Likewise. - - * unix/work.c (fsysdep_get_work): Don't call fsysdep_get_work_init - if no more jobs are found. - -Thu Jun 29 15:27:31 1995 Ian Lance Taylor <ian@airs.com> - - * fsusg.c: Update with changes from fileutils 3.12. - * configure.in: Update filesystem space tests to fileutils 3.12. - * config.h.in: Corresponding changes. - - * unix/filnam.c (fscmd_seq): If F_SETLKW fails with ENOMEM, - ENOSPC, or ENOLCK, sleep and try again. - - * Makefile.in (MORECFLAGS): Remove unused SBINDIR definition. - * unix/Makefile.in (run.o): Add dependency on Makefile and - ../Makefile, so that it is rebuilt if sbindir changes. - * uuconf/Makefile.in (callin.o): Add dependency on Makefile and - ../Makefile, so that it is rebuilt if NEWCONFIGLIB or OLDCONFIGLIB - change. - (hinit.o, hrmunk.o, maxuxq.o, rdperm.o, tinit.o): Likewise. - (vinit.o): Likewise. - - * cu.c (main, ucuhelp): Update copyright. - * tstuu.c (main): Likewise. - * uuchk.c (main, ukhelp): Likewise. - * uucico.c (main, uhelp): Likewise. - * uuconv.c (main, uvhelp): Likewise. - * uucp.c (main, uchelp): Likewise. - * uulog.c (main, ulhelp): Likewise. - * uuname.c (main, unhelp): Likewise. - * uupick.c (main, uphelp): Likewise. - * uustat.c (main, ushelp): Likewise. - * uux.c (main, uxhelp): Likewise. - * uuxqt.c (main, uqhelp): Likewise. - - * Makefile.in (VERSION): Update to beta1.06. - -Wed Jun 28 10:36:35 1995 Ian Lance Taylor <ian@airs.com> - - * trans.c (struct scharge, sTsend, sTreceive): Remove. - (qTtiming_rec, iTrecsecs, iTrecmicros): New static variables. - (fqueue_receive): If adding something to an empty receive queue, - update iTrecsecs and iTrecmicros. - (utransfree): Remove references to sTsend and sTreceive. If - freeing qTtiming_rec, clear it. - (ftcharge): Remove. Remove all calls to it. - (fttime): New static function. - (uclear_queue): Clear qTtiming_rec. - (floop): Add timing code to replace ftcharge. - (fgot_data): Likewise. - (ftadd_cmd): Set s.bcmd to 'H' for a hangup request, for better - debugging information. - (ufailed): Remove setting of iTchecktime and calls to ftcharge. - - * uuconf.h (UUCONF_STRIP_LOGIN): Define. - (UUCONF_STRIP_PROTO): Define. - (uuconf_strip): Declare. - * uuconf/strip.c: New file, definining uuconf_strip. - * uuconf/Makefile.in (OBJS): Add strip.o. - * uuconf/uucnfi.h (struct sprocess): Add new fields fstrip_login - and fstrip_proto. - * uuconf/iniglb.c (_uuconf_iinit_global): Initialize new fields. - * uuconf/tinit.c (asCmds): Add "strip-login" and "strip-proto". - * uucico.c (fdo_call): Check whether protocol commands should be - stripped, and pass information to zget_uucp_cmd. - (faccept_call): Likewise. - (flogin_prompt): Check whether login commands should be stripped, - and pass information to zget_typed_line. - (zget_uucp_cmd): Add fstrip argument, and use it to control - whether incoming characters are stripped. - (zget_typed_line): Likewise. - * uuchk.c (main): Report uuconf_strip information. - -Mon Jun 26 17:57:14 1995 Ian Lance Taylor <ian@airs.com> - - * uuchk.c (main): Report global configuration information. - - * uux.c (main): If an attempt is made to execute an empty command, - just create a poll file instead. - - * uupick.c (main): Mention 'd' as a possible command. - -Wed Jun 21 16:16:13 1995 Ian Lance Taylor <ian@airs.com> - - * unix/filnam.c (fscmd_seq): If available, use POSIX style locking - for the sequence file. Use IPRIVATE_FILE_MODE when creating the - sequene file. - - * copy.c (fcopy_file): Add fsignals argument, and pass it to - fcopy_open_file. Update all callers. - (fcopy_open_file): Add fsignals argument; if TRUE, check for - signals while copying the file. Update all callers. - * uudefs.h (fcopy_file, fcopy_open_file): Update prototypes. - -Thu Jun 15 20:34:00 1995 Ian Lance Taylor <ian@airs.com> - - * Rob Janssen: getopt.h: Don't fail if P is not defined because - this file got included by something other than uucp.h. - -Tue Jun 6 13:17:14 1995 Ian Lance Taylor <ian@airs.com> - - * log.c (ulog): Always open the log file even if zmsg is NULL. - * unix/detach.c (usysdep_detach): Call ulog with NULL before - closing stderr. - - * log.c (ulog): Print file name correctly under HDB_LOGGING if an - error occurs. - - * Andrey A. Chernov: uucp.h: Use off_t rather than long when - casting arguments to lseek. - - * proti.c (IMAXPACKSIZE): Subtract one. - (fijstart): Correct iIforced_remote_packsize check. - - * unix/filnam.c (zsfile_name): Only use remote system name in - local filename for SPOOLDIR_SVR4, not for SPOOLDIR_HDB. - - * Peter da Silva: cu.c (asCulongopts): Add "escape". - (main): Handle -E/--escape. - * cu.1: Document -E/--escape. - * unix/cusub.c (fsysdep_cu): Don't treat \0 as an escape - character. - - * Takatoshi Ikeda: log.c (ustats): Base 'M' vs. 'S' in HDB_LOGGING - on fcaller, not on fmaster. - (zldate_and_time): In HDB_LOGGING, don't zero fill the hour. - * uudefs.h (ustats): Change argument name in prototype. - * send.c (fsend_await_confirm): Pass fcaller rather than fmaster - to ustats. - * rec.c (frec_file_end): Likewise. - * trans.c (ufailed): Likewise. - - * unix/tcp.c: Include <arpa/inet.h>. - (ftcp_dial): If gethostbyname fails, try inet_addr. - - * Jim Brownfield: unix/detach.c (usysdep_detach): Call TIOCNOTTY - on /dev/tty, not on file descriptor 0. - - * uuchk.c (ukshow): If the system will never be called, say so - explicitly. - - * unix/pause.c (usysdep_pause): When using poll, clear the sdummy - structure before passing it down. - - * unix/bytfre.c (csysdep_bytes_free): Check for overflow. - - * C.A. Lademann: cu.c (asCulongopts): Add "nostop". - (main): Handle --nostop. - (ucuhelp): Mention --nostop. - * cu.1: Document --nostop. - - * Dean Edmonds: cu.c (fcuset_var): Copy string before calling - uuconf_cmd_args, and handle UUCONF_CMDTABRET_KEEP correctly. - - * Jorge Cwik: Add support for 'y' protocol. - * proty.c: New file, written by Jorge Cwik. - * prot.h: Declare 'y' protocol functions. - * uucico.c (asProtocols): Add entry for 'y' protocol. - * Makefile.in (UUOBJS): Add proty.o. - (ALLOBJS): Add proty.o. - (proty.o): New target. - -Mon Jun 5 12:05:22 1995 Ian Lance Taylor <ian@airs.com> - - * cu.c (main): Don't clobber user specified ibaud when a specific - system is being called. - - * unix/serial.c (fsysdep_stdin_init): chmod /dev/tty to 0600 to - prevent other users from writing to it. - - * uux.c (main): If the argument is quoted by parentheses, don't - break it at shell separator characters. - - * protg.c (fgprocess_data): Don't treat a duplicate RR as an RJ if - we are retransmitting packets. Corrects change of May 15, 1993. - - * unix/lock.c (fsdo_lock): Log an error message if the LOCKFILES - define appears to not match the contents of the lock file. - -Sun Jun 4 14:25:43 1995 Ian Lance Taylor <ian@airs.com> - - * Makefile.in (uucp.info): Use explicit $(srcdir) rather than $<. - (uucp.dvi): Likewise. - (uucp.ps): Use uucp.dvi rather than $<. - - * Scott Guthridge: cu.c (icutake): Skip \r characters unless - fCuvar_binary is set. - - * unix/status.c (fsysdep_get_status): Ignore double quotes around - description string in status file. - (fsysdep_set_status): If SPOOLDIR_SVR4, put double quotes around - description string. - - * uustat.c (fsxqt_file_read): Change second argument from file - name to open file. - (fsworkfile_show): Make sure execution file can be opened before - displaying information in execution file format. - (fsexecutions): Open file before passing it to fsxqt_file_read. - - * uucp.h (ffileioerror): Rename from ffilereaderror. - * cu.c (icuput): Corresponding change. - * trans.c (floop): Likewise. - (fgot_data): Use ffileioerror to decide whether to print message - using errno. - - * uuconv.c (uvwrite_taylor_port): Fix handling of dialer-sequence - for a modem port to actually print ``dialer-sequence''. - - * uuconf/hsinfo.c (_uuconf_ihdb_system_internal): Treat a syntax - error in the time field as equivalent to ``never''. - * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Likewise. - - * uuchk.c (ukshow): Print max-retries information. - - * Don Phillips: Add support for new called-timegrade command. - * uuconf.h (struct uuconf_system): Add uuconf_qcalledtimegrade - field. - * uuconf/tsinfo.c (asIcmds): Add "called-timegrade". - * uuconf/syssub.c (SYSTEM_TIMESPANS): Add uuconf_qcalledtimegrade. - * trans.c (fqueue): Check uuconf_qcalledtimegrade. - * uuchk.c (ukshow): Print called-timegrade and success-wait - information. - * uuconv.c (uvwrite_taylor_system): Handled called-timegrade. - - * unix/xqtsub.c (fsysdep_lock_uuxqt_dir): Accept EISDIR. - - * Damon: unix/mkdirs.c (fsysdep_make_dirs): Accept EROFS. - -Sat May 27 09:55:38 1995 Ian Lance Taylor <ian@airs.com> - - * unix/detach.c (usysdep_detach): Mention routine name in - debugging message. - - * tstuu.c (main): Exit with an error message if not compiled with - HAVE_TAYLOR_CONFIG. - - * Jim Avera: Makefile.in (install-info): Get the info files from - the source directory if they aren't in the object directory. - - * uuchk.c (main): Accept -s to only print information for a - specific system. - (asKlongopts): Add --system as a synonym for -s. - (ukusage): Mention -s. - (ukhelp): Likewise. - - * Makefile.in (uuconf/libuuconf.a): Depend upon config.h. - (unix/libunix.a, lib/libuucp.a): Likewise. - - * Matthias Urlichs and Olaf Kirch: If an execution fails, save the - files. - * sysh.unx (FAILEDDIR): Define. - * system.h (zsysdep_save_failed_file): Declare. - * uuxqt.c (uqdo_xqt_file): Call isave_files if an execution fails. - Move the execution files out of the execution directory on any - failure, not just a temporary one. - (isave_files): New function; pass all the execution files to - zsysdep_save_failed_file, and send mail to OWNER. - * unix/failed.c: New file. - * unix/Makefile.in (OBJS): Add failed.o. - (failed.o): New target. - - * Johannes Stille: Remove various race conditions, as follows: - * rec.c (flocal_rec_send_request): Don't free qtrans if pfsendcmd - fails. - (fremote_send_reply): Likewise. - (fremote_send_fail_send): Move pfsendcmd call to the end of the - routine, after everything else has been done. - (frec_file_send_confirm): Likewise. - * send.c (struct ssendinfo): Add new fields fnever and zconfirm. - (flocal_send_fail): Remove first argument; change all callers. - (usfree_send): Free new zconfirm field. - (flocal_send_file_init): Initialize new zconfirm field. - (fremote_rec_file_init): Likewise. - (flocal_send_request): Free qtrans explicitly, rather than - expecting flocal_send_fail to do it. - (flocal_send_request): Don't free qtrans if pfsendcmd fails. - (flocal_send_await_reply): Use new fnever field rather than - overloading fsent. - (flocal_send_cancelled): Likewise. - (flocal_send_await_reply): Set fcmd field to TRUE. - (fremote_rec_reply): Set fcmd field to TRUE. Set qtrans->zlog - before calling pfsendcmd. Don't free qtrans if pfsendcmd fails. - (fremote_rec_fail_send): Move pfsendcmd call to the end of the - routine, after everything else has been done. - (fsend_file_end): If zconfirm is set, call fsend_await_confirm. - Don't bother to set fcmd here. - (fsend_await_confirm): If fsent is not set, just save command in - zconfirm and return. - (fsend_exec_file_init): Free and clear new zconfirm field. - * xcmd.c (flocal_xcmd_request): Don't free qtrans if pfsendcmd - fails. - - * unix/pause.c: Prefer any of the other choices to nap, since the - meaning of nap argument varies from system to system, and the user - may not set HAVE_HUNDREDTHS_NAP correctly. - - * unix/cusub.c (fsysdep_shell): When starting up an interactive - shell, use the environment variable SHELL rather than /bin/sh. - -Fri May 26 00:03:46 1995 Ian Lance Taylor <ian@airs.com> - - * Chip Salzenberg: uulog.c (main): Set cluser, not clsys, when - using HAVE_HDB_LOGGING. - - * Robert Joop: uuconf/callin.c (uuconf_callin): Improve handling - of Unix style passwd files. - - * uupick.c (main): Don't fail if we can't get system information, - since uupick is not setuid. - - * Stephen Harris: uudefs.h (struct sstatus): Add new field - zstring. - * unix/status.c (fsysdep_get_status): Set zstring field. - * uustat.c (fsquery_show): Print and free zstring field, if set, - rather than indexing off type. - (fsmachines): Likewise. - * uucico.c (fcall): Free sstat.zstring. - - * proti.c (cIwindow_timeout): New static variable. - (fijstart): Initialize cIwindow_timeout based on the window size - and connection speed. Increment both timeouts in callee. - (fishutdown): Initialize cIwindow_timeout. - (fiwindow_wait): Use cIwindow_timeout rather than cItimeout. - - * unix/serial.c (fsysdep_conn_io): Try using select before doing a - blocking write, and use an alarm if we fall back to the blocking - write, to try to avoid deadlock when both systems fill the pipe. - - * Trever Miller: unix/lock.c (fsdo_lock): Fix use of inid where - inme was intended, in HAVE_QNX_LOCKFILES code. - - * unix/lock.c (fsdo_lock): Treat an empty lock file as stale. - -Thu May 25 11:46:32 1995 Ian Lance Taylor <ian@airs.com> - - * Kenji Rikitake: unix/serial.c (fsserial_hardflow): Handle - CRTS_IFLOW as used on BSDI. - - * Gerriet M. Denkmann: uuconf/vsnams.c (uuconf_v2_system_names): - Accept continuation lines in L.sys. - * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Skip comment - lines in L.cmds. Ignore everything after comma in L.cmds lines. - - * Gerriet M. Denkmann: unix/ftw.c (ftw_dir): Initialize newlev to - avoid warning. - - * Paul Pryor: unix/tli.c (ftli_open): Swap real and effective user - ID's when running as a server, so that root can bind privileged - ports. - - * unix/tcp.c (ftcp_open): Call fsuser_perms and fsuucp_perms - rather than having the same code inline. - - * sysh.unx (fsuser_perms, fsuucp_perms): Declare. - * unix/ufopen.c (fsuser_perms, fsuucp_perms): Move into uid.c. - * unix/uid.c: New file. - * unix/Makefile.in (OBJS): Add uid.o. - (uid.o): New target. - - * unix/tcp.c: Move tcp.c into unix subdirectory. - * unix/tli.c: Likewise for tli.c. - * Makefile.in (UUOBJS, CUOBJS, ALLOBJS): Remove tcp.o and tli.o. - (tcp.o, tli.o): Remove. - * unix/Makefile.in (OBJS): Add tcp.o and tli.o. - (tcp.o, tli.o): New targets. - - * Paul Pryor: configure.in: Check for -lnsl_s before -lnsl. - - * Makefile.in (prefix): Use @prefix@, not /usr/local. - (exec_prefix): New variable, set to @exec_prefix@. - (sbindir, bindir): Use $(exec_prefix) rather than $(prefix). - (CPPFLAGS): New variable, set to @CPPFLAGS@. - (@SET_MAKE@): New macro used by autoconf 2. - (MORECFLAGS): Put -I. before -I$(srcdir). - (MDEFINES): Pass down CPPFLAGS. - (.c.o): Use CPPFLAGS. - (uuconv.o): Likewise. - (distclean): Remove stamp-h, config.log and config.cache. - (maintainer-clean): New synonym for realclean. - (configure, config.h, stamp-h, Makefile, config.status): Rewrite - as suggested by autoconf 2.3. - (.PHONY): Add maintainer-clean. - * lib/Makefile.in (CPPFLAGS): New variable, set to @CPPFLAGS@. - (MORECFLAGS): Put `-I..' before `-I$(srcdir)/..'. - (maintainer-clean): New synonym for realclean. - (.c.o): Use CPPFLAGS. - (Makefile): Just rebuild this Makefile, not the others. - (.PHONY): Add maintainer-clean. - * unix/Makefile.in (CPPFLAGS): New variable, set to @CPPFLAGS@. - (prefix): Removed. - (sbindir): Use @exec_prefix@ rather than $(prefix). - (MORECFLAGS): Put `-I..' before `-I$(srcdir)/..'. - (maintainer-clean): New synonym for realclean. - (.c.o): Use CPPFLAGS. - (Makefile): Just rebuild this Makefile, not the others. - (.PHONY): Add maintainer-clean. - * uuconf/Makefile.in (prefix): Set to @prefix@, not /usr/local. - (CPPFLAGS): New variable, set to @CPPFLAGS@. - (MORECFLAGS): Put `-I.' before `-I$(srcdir)' and `-I..' before - `-I$(srcdir)/..'. - (maintainer-clean): New synonym for realclean. - (.c.o): Use CPPFLAGS. - (Makefile): Just rebuild this Makefile, not the others. - (.PHONY): Add maintainer-clean. - - * configure.in: Extensive changes for autoconf 2.3. - * configure: Regenerate using autoconf 2.3. - * install-sh: New file. - -Mon May 22 22:18:59 1995 Ian Lance Taylor <ian@airs.com> - - * Mister Flash: chat.c (fcsend): Don't get forget to add 10 in \x. - -Tue Jan 17 22:49:05 1995 Ian Lance Taylor <ian@airs.com> - - * unix/mkdirs.c (fsysdep_make_dirs): Don't get confused by a - double slash. - -Wed Aug 10 09:25:10 1994 Ian Lance Taylor (ian@airs.com) - - * uuconf/hport.c (uuconf_hdb_find_port): Set iret to - UUCONF_SUCCESS when a port is found. - -Tue Aug 2 08:57:05 1994 Ian Lance Taylor (ian@airs.com) - - * trans.c (ftadd_cmd): Report a 'P' (poll) command as garbled. - -Wed Jul 20 21:53:03 1994 Ian Lance Taylor (ian@airs.com) - - * rec.c (flocal_rec_file_init): Set name of local system after - calling uuconf_system_local. - * uustat.c (fsexecutions): Likewise. - -Sat Jul 16 16:54:12 1994 Ian Lance Taylor (ian@airs.com) - - * log.c (ulog): Use strerror in message about being unable to open - the log file. - -Wed Jul 13 00:44:33 1994 Ian Lance Taylor (ian@airs.com) - - * rec.c (fremote_send_reply): Set qinfo->freplied before sending - the command. - -Sun Jul 10 23:25:23 1994 Ian Lance Taylor (ian@airs.com) - - * Tin Le: lib/debug.c (udebug_buffer): Only compile if DEBUG > 1. - -Mon Jun 27 21:06:29 1994 Ian Lance Taylor (ian@airs.com) - - * uuconf.h (UUCONF_CMDTABFLAG_NOCOMMENTS): Define. - * uuconf/cmdlin.c (uuconf_cmd_line): Handle NOCOMMENTS. - * uuxqt.c (uqdo_xqt_file): Pass NOCOMMENTS to uuconf_cmd_file. - -Thu May 19 22:50:37 1994 Ian Lance Taylor (ian@airs.com) - - * Ollivier Robert: unix/mkdirs.c: Permit EISDIR. - -Wed May 18 23:15:36 1994 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fcall): Reset sDaemon fields each time through the - loop, not just once. - -Thu May 5 23:15:11 1994 Ian Lance Taylor (ian@airs.com) - - * Released version 1.05. - - * Makefile.in (doc-dist): Put uucp.ps in uucp-doc-$(VERSION). - -Sun May 1 23:41:49 1994 Ian Lance Taylor (ian@airs.com) - - * uuchk.c (ikshow_port): Show reliability information. - (ukshow_dialer): Likewise. - (ukshow_reliable): New function. - -Sat Apr 16 22:28:10 1994 Ian Lance Taylor (ian@airs.com) - - * Andrew A. Chernov: uucico.c (main): Pass 'z' to getopt. - (uhelp): Mention -z aka --try-next. - - * log.c (ustats): Report failed transfers when HAVE_HDB_LOGGING. - -Wed Apr 13 23:07:20 1994 Ian Lance Taylor (ian@airs.com) - - * prot.c (fsend_data): If no room in receive buffer, just write - the data out, don't call fconn_io. - -Tue Apr 12 21:55:32 1994 Ian Lance Taylor (ian@airs.com) - - * Spider Boardman: unix/serial.c (fsysdep_modem_end_dial): Set - terminal characteristics of reopened port. - -Sun Apr 10 18:05:34 1994 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_fail): Always call fsysdep_did_work. - (flocal_send_await_reply): Don't call flocal_send_fail if we are - going to call fsend_exec_file_init. Only call - fsend_exec_file_init if fnever is TRUE. Pass fnever to - flocal_send_cancelled using the qinfo->fsent flag. - (flocal_send_cancelled): Only call fsend_exec_file_init if - qinfo->fsent is TRUE. - - * unix/statsb.c (fsysdep_lock_status): If HAVE_QNX_LOCKFILES, - initialize painid to NULL. - -Tue Apr 5 23:09:00 1994 Ian Lance Taylor (ian@airs.com) - - * Released version gamma 1.05. - - * Makefile.in (VERSION): Changed to gamma1.05. - - * uucico.c (fcall): Return TRUE if -C was used and no call was - made because there was no work. - -Mon Apr 4 20:29:30 1994 Ian Lance Taylor (ian@airs.com) - - * Chris Lewis: unix/serial.c: Include <sys/ioctl.h> if - HAVE_TXADDCD. Check for HAVE_TXADDCD rather than ifdef TXADDCD or - TXDELCD. - - * configure.in: Check for TXADDCD in <sys/ioctl.h>. - * config.h.in (HAVE_TXADDCD): New configuration macro. - -Sun Apr 3 14:05:30 1994 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_request): Queue stransfer structure up - before sending any command or data, because sending data may cause - data to be received for this stransfer, and we must be prepared to - handle it correctly. - (fremote_rec_reply): Likewise. - * rec.c (flocal_rec_send_request, fremote_send_reply): Likewise. - (fremote_send_fail_send): Likewise. - * xcmd.c (flocal_xcmd_request): Likewise. - - * Chris Lewis: unix/serial.c (fsserial_hardflow): Add support for - AIX TXADDCD and 3b1 CTSCD. - -Sat Apr 2 00:04:30 1994 Ian Lance Taylor (ian@airs.com) - - * policy.h (USE_TRADITIONAL_STATUS): Permit this to be defined. - * lib/status.c: Control initialization of azStatus based on - USE_TRADITIONAL_STATUS rather than SPOOLDIR_HDB || SPOOLDIR_SVR4. - -Fri Apr 1 23:52:09 1994 Ian Lance Taylor (ian@airs.com) - - * log.c (ulog): When using HAVE_HDB_LOGGING, force the program - name to lower case when using it as a file name. - - * send.c (flocal_send_await_reply): Correct code to really not - decrement number of channels to one. - * rec.c (flocal_rec_await_reply): Likewise. - -Wed Mar 30 22:57:30 1994 Ian Lance Taylor (ian@airs.com) - - * lib/buffer.c (ubuffree): Change ioff from size_t to int to avoid - HP/UX compiler bug. - - * configure.in: Make sure that <utime.h> defines struct utimbuf - before assuming that it is present. - -Tue Mar 29 23:00:15 1994 Ian Lance Taylor (ian@airs.com) - - * uuconf/filnam.c: Use UUCONF_CONST, not const, to match - declaration in uuconf.h. - -Mon Mar 28 20:06:00 1994 Ian Lance Taylor (ian@airs.com) - - * Andrew A. Chernov: policy.h: For several macros, add commented - out values appropriate for some free BSD distributions. - * Makefile.in: Likewise. - - * uucico.c (icallin_cmp): Use pointer, not void *. - * uuconf/callin.c (struct sinfo, uuconf_callin): Likewise. - - * Chris Lewis: uuconv.c (fvperm_string_cmp, fvperm_array_cmp): AIX - 3.2.5 cc can't handle conditional expressions in if conditions. - -Sun Mar 27 15:04:27 1994 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_fail): Don't assume that qtrans is not NULL. - - * Jeff Ross, Stephen J. Walick: Makefile.in (uusched): Substitute - for @SBINDIR@, not @BINDIR@. - - * configure.in: Make sure that <dirent.h> defines struct dirent - before assuming that it is present. - - * Benoit Grange: unix/detach.c (usysdep_detach): Correct type of - HAVE_BSD_SETPGRP for HAVE_BSD_PGRP. - -Sat Mar 26 12:59:36 1994 Ian Lance Taylor (ian@airs.com) - - * Andrew A. Chernov: uucico.c (asLongopts): Add --try-next as - synonym for -z. - (main): If -z, call fcall with ftrynext as TRUE. - (fcall): Add ftrynext argument. If ftrynext is TRUE, try the next - alternate if a call fails. - -Fri Mar 25 22:37:51 1994 Ian Lance Taylor (ian@airs.com) - - * lib/parse.c (fparse_cmd): If we get a decimal 666 or 777 for the - mode, turn it into an octal 0666 or 0777. - - * send.c (flocal_send_fail): Accept qdaemon argument rather than - qsys. Changed all callers. If we are going to send an execution - file, don't call fsysdep_did_work. - - * protg.c (fgstart): Say ``sending'' and ``receiving'' instead of - ``remote'' and ``local'' in log message. - * proti.c (fijstart): Likewise. - -Thu Mar 24 22:40:49 1994 Ian Lance Taylor (ian@airs.com) - - * Gert Doering: uuchk.c (ikshow_port): Don't use qtli for a TCP - port. - - * Makefile.in (uusched, uuto): Fix typo in sed command. - - * unix/mail.c (fsysdep_mail): Add casts to avoid warnings. - * uuconf/runuxq.c (uuconf_runuuxqt): Likewise. - - * Emmanuel Mogenet: unix/pipe.c (fspipe_dial): Make consistently - static. - - * unix/serial.c (fsserial_open): Only strip /dev/ from the start - of a device name, rather than dropping everything before the last - slash. - - * sysh.unx (ftw): Change stat argument to not be const pointer. - * unix/ftw.c (ftw_dir, ftw): Change stat argument to func argument - to not be const pointer. - * unix/srmdir.c (isremove_dir): Change stat argument to not be - const pointer. - * unix/walk.c (iswalk_dir): Likewise. - -Wed Mar 23 20:02:26 1994 Ian Lance Taylor (ian@airs.com) - - * conn.c (fconn_break): Remove incorrect indirection of function - pointer. - - * unix/mkdirs.c (fsysdep_make_dirs): Some systems can return - EACCES, not EEXIST, when a directory exists. - - * configure.in: Fix STAT_STATFS2_FSIZE test. - * configure: Regenerated. - -Tue Mar 22 01:32:21 1994 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main): Skip a leading dash in argv[0] which is - probably the result of being invoked by the Unix login program. - - * configure.in: Check for sys/time.h. - * config.h.in (HAVE_SYS_TIME_H): Define. - - * unix/serial.c (fsysdep_modem_begin_dial): Correct type of q for - qsysdep. - - * uux.c (main): Check for zXnames being NULL. - -Sat Mar 19 14:07:31 1994 Ian Lance Taylor (ian@airs.com) - - * Released version beta 1.05. - - * Makefile.in (uucp.info): Use -o argument to force info files to - be created in objdir. - (doc-dist): Get README-DOC from $(srcdir). - - * lib/debug.c (iDebug, azDebug_names, idebug_parse): Only compile - if DEBUG > 1. - -Mon Feb 14 22:46:49 1994 Ian Lance Taylor (ian@airs.com) - - * lib/strtou.c: New file, for strtoul. - * lib/MANIFEST: List strtou.c. - * configure.in: Check for strtoul, add strtou.o to LIBOBJS if not - there. - * config.h.in (HAVE_STRTOUL): Define. - * uucp.h (strtoul): Declare. - -Mon Jan 31 20:17:30 1994 Ian Lance Taylor (ian@airs.com) - - * Makefile.in, lib/Makefile.in, unix/Makefile.in, - uuconf/Makefile.in: Use $(CFLAGS) after all other flags. - -Sun Jan 30 14:34:51 1994 Ian Lance Taylor (ian@airs.com) - - * Makefile.in (clean, distclean, dist, doc-dist): Remove .tar.gz - file, not .tar.Z one. - (dist, doc-dist): Use gzip --best, not compress. - - * Makefile.in (VERSION): Set to beta1.05. - - * cu.c, uuchk.c, uucico.c, uuconv.c, uucp.c, uulog.c, uuname.c, - uupick.c, uustat.c, uux.c, uuxqt.c: Updated copyright date. - - * conn.c (fconn_init): Added third argument: type of standard - input port. - * conn.h (fconn_init): Updated declaration. - * uucico.c (asLongopts): Added --stdin, synonym for -i. - (main): Accept -i TLI to set standard input to be of type TLI. - Pass appropriate additional argument to fconn_init. - (uhelp): Updated. - (fconn_call, iuport_lock): Changed all calls to fconn_init. - * cu.c: Changed all calls to fconn_init. - * prot.c, protj.c: Include uuconf.h before conn.h. - * Makefile.in (prot.o, protj.o): Updated. - - * unix/serial.c (fsysdep_conn_read): Permit up to two EWOULDBLOCK - error returns from read before quitting. - -Sat Jan 22 16:48:41 1994 Ian Lance Taylor (ian@airs.com) - - * uuconf/hinit.c: Don't treat lines with leading whitespace as - comments in Sysfiles. - - * log.c: Don't require ANSI C to use vfprintf, just require - stdarg.h and prototypes. Required for Alpha cc support. - - * configure.in: Check for prototype support. Check for stdarg.h. - When looking for socket and t_open check for "-lsocket -lnsl" - after plain "-lnsl". - * config.h.in (HAVE_PROTOTYPES, HAVE_STDARG_H): New macros. - * uucp.h: Demand that an ANSI C compiler support prototypes. If - HAVE_PROTOTYPES is 1 for Classic C, defined P(x) to be x. - - * configure: Upgraded to autoconf 1.7. - - * protg.c (fgstart): Ensure that window size is reasonable. - - * protg.c (fvstart): Change default packet size from 512 to 1024. - - * trans.h (struct sdaemon): Added zconfig, irunuuxqt, and - cxfiles_received fields. - (fspawn_uuxqt): Declare. - * uucico.c (fcall, flogin_prompt, faccept_call): Added zconfig and - fuuxqt arguments; changed all callers. - (main): Use fspawn_uuxqt to invoke uuxqt, and only do it if - uuconf_runuuxqt returns UUCONF_RUNUUXQT_ONCE. - (fcall, faccept_call): Initialize new struct sdaemon fields. - Spawn uuxqt if uuconf_runuuxqt returned UUCONF_RUNUUXQT_PERCALL or - if it returned a positive number and execution files have arrived - since the last time uuxqt was spawned. - (fspawn_uuxqt): New function. - * rec.c (frec_file_end): Spawn uuxqt if enough execution files - have been received. - - * uuconf.h (UUCONF_RUNUUXQT_NEVER, UUCONF_RUNUUXQT_ONCE, - UUCONF_RUNUUXQT_PERCALL): New #define constants. - (uuconf_runuuxqt): Declare. - * uuconf/runuxq.c: New file. - * uuconf/uucnfi.h (struct sprocess); Added zrunuuxqt field. - * uuconf/tinit.c (asCmds): Added "run-uuxqt". - * uuconf/iniglb.c (_uuconf_iinit_global): Initialize zrunuuxqt - field. - * uuconf/MANIFEST, uuconf/Makefile.in: Handle runuxq.c. - - * system.h (fsysdep_run): Added ffork argument. - * unix/run.c (fsysdep_run): Added ffork argument. - * uucico.c (main), uux.c (main), uucp.c (main): Changed calls to - fsysdep_run to pass ffork argument as FALSE. - -Fri Jan 14 19:40:20 1994 Ian Lance Taylor (ian@airs.com) - - * Chip Salzenberg: unix/splcmd.c (zsysdep_spool_commands): More - fitting value for size of abtempfile. - -Mon Jan 10 22:46:52 1994 Ian Lance Taylor (ian@airs.com) - - * unix/recep.c (fsysdep_remember_reception): Create directory with - mode of 0755, not 0777. - -Mon Jan 3 20:34:35 1994 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgprocess_data): Don't believe the ACK of an out of - order packet. - - * uucico.c (asProtocols): Added 'v'. - * prot.h (fvstart): Declare. - * protg.c (fvstart): New function. - -Sun Jan 2 15:34:12 1994 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main), uucp.c (main), uux.c (main): Pass -I argument - to invoked program. - - * uustat.c (JOB_REJUVENATE): Define. - (asLongopts): Add "rejuvenate-all". - (main, ususage): Handle -R. - (fsworkfile_show, fsexecutions): Handle JOB_REJUVENATE. - * system.h (fsysdep_touch_file): Declare. - * unix/statsb.c (issettime): Rename from ussettime. - (fsysdep_touch_file): Create. - - * Jim Avera: system.h: (INIT_NOCLOSE): Define. - * unix/init.c (usysdep_initialize): If INIT_NOCLOSE is set, don't - close all open descriptors. - - * Allen Delaney: tli.c: Don't declare t_alloc if we have - <tiuser.h>, since it can cause conflicts. - - * configure.in: Call AC_CONST. - * config.h.in: Added #undef const for configure to comment out. - * uucp.h: Don't undefine const here. - - * Spider Boardman: uucico.c (main): Correct error message. - uux.c (main), uucp.c (main): Call uucico with -C option. - - * tstuu.c (uprepare_test): Don't put the obsolete pty command into - the port file. - - * spawn.c (ixsspawn): Set close-on-exec flag for both ends of - new pipe. - - * Andrew A. Chernov: unix/serial.c (ICLEAR_IFLAG): Clear IMAXBEL - if it is defined. - (ICLEAR_LFLAG): Clear PENDIN if it is defined. - - * send.c (flocal_send_file_init): If stat fails, discard the - command and save the temporary file. - (flocal_send_fail): Cleaned up zsysdep_save_temp_file call. - -Thu Dec 23 00:55:22 1993 Ian Lance Taylor (ian@airs.com) - - * Martin Tomes: spawn.c (ixsspawn): On ISC, call __setostype - before execve. - -Wed Dec 22 00:06:25 1993 Ian Lance Taylor (ian@airs.com) - - * uuconf/tport.c (ipunknown): Set UUCONF_CMDTABRET_EXIT if an - error is found. - - * uucico.c (asLongopts): Add --login as a synonym for -u. - (main): Permit a privileged user to use -u to set the login name - rather than always using zsysdep_login_name (). - (flogin_prompt): Accept login name as an argument. If non-null, - use it rather than prompting for one. - (uhelp): Document new --login option. - * uucico.8: Document new --login option. - * unix/priv.c: New file, containing fsysdep_privileged. - * unix/statsb.c (fsysdep_privileged): Moved to priv.c. - * unix/MANIFEST, unix/Makefile.in: Support new priv.c file. - - * uuchk.c (ikshow_port): Print a note when using the port name as - a device name. - -Tue Dec 21 00:01:40 1993 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fcall): Ignore status file times in the future when - deciding whether a retry is permitted. - - * detach.c (usysdep_detach): If it forks, output a debugging - message with the old and new process IDs. - - * Scott Ballantyne: unix/spawn.c (ixsspawn): If fkeepuid is TRUE, - try to set the real user and group ID to the effective user and - group ID. This will not work on System V derived systems, but - should do no harm. - * unix/xqtsub.c (fsysdep_execute): Pass fkeepuid as TRUE to - ixsspawn. - * unix/epopen.c (espopen): Likewise. - - * uucico.c (faccept_call): Use correct default for - max-remote-debug. - - * uuconf/tportc.c (ipdialer): Don't core dump if the port name is - NULL, as it is for the default port. - - * unix/xqtsub.c (fsysdep_xqt_check_file): Do not permit the name - ``..'', or strings starting with ``../''. - - * proti.c (fijstart): Send a fourth byte in the SYNC packet with - the number of channels. - (fiprocess_packet): If a SYNC packet has a fourth byte, use it to - set the number of channels. - - * rec.c (flocal_rec_await_reply): Handle RN9 (no channels - available on remote). - * send.c (flocal_send_await_reply): Handle SN9 (no channels - available on remote). - - * trans.h (struct sdaemon): Added cchans field. - * uucico.c (fcall, fdo_call, faccept_call): Initialize cchans. - * trans.c (utchanalc, fcheck_queue, floop): Use qdaemon->cchans, - not qdaemon->qproto->cchans. - * send.c (flocal_send_request, flocal_send_await_reply): Likewise. - * rec.c (fremote_send_fail): Likewise. - -Sun Dec 19 19:44:31 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (cIack_frequency): New static variable. - (asIproto_params): New protocol parameter ack-frequency. - (fijstart): If cIack_frequency is not set, set it to half the - window size. - (fishutdown): Clear cIack_frequency. - (fiprocess_data): Use cIack_frequency to determine when to send an - acknowledgement, rather than always sending one at half the window - size. - - * uuconf/cmdfil.c (uuconf_cmd_file): Free zline. - - * uuconf/callin.c (uuconf_callin): Treat colon as a field - delimiter, for Unix /etc/passwd support. - - * unix/xqtsub.c (zsysdep_find_command): If file named with - absolute path does not exist, give a reasonable error message. - - * uuconf/rdperm.c (ihadd_norw): Ignore use of empty string with - NOREAD or NOWRITE, rather than denying everything. - - * Chip Salzenberg: uulog.c (main): Set zluser correctly under - HAVE_HDB_LOGGING. - - * Chip Salzenberg: protz.c (izrecv_hdr): Use %lx, not %x. - -Sun Dec 12 19:24:35 1993 Ian Lance Taylor (ian@airs.com) - - * uucp.c (uccopy): Null terminate name of forwarding system. - -Mon Nov 22 21:12:41 1993 Ian Lance Taylor (ian@airs.com) - - * unix/tmpfil.c: Include "uudefs.h". - * unix/Makefile.in: Changed accordingly. - - * log.c (zstpcpy): New function. - (ulog): Output to log file with a single call to fprintf. - - * uucp.c (uccopy): Clarified "not permitted to send" error. - - * log.c (ulog): If debugging is on, output all log messages to - debugging file. - - * uucico.c (fdo_call): Changed "Bad initialization string" error - message. - - * unix/lock.c (fsdo_lock): Print date a stale lock was last - modified. - - * uucico.c (uaccept_call_cleanup): Call ulog_system (NULL). - -Sun Nov 21 17:04:27 1993 Ian Lance Taylor (ian@airs.com) - - * Joe Wells: policy.h: Added new parameter LOG_DEVICE_PREFIX. - * unix/serial.c (fsserial_open): Use it. - - * Makefile.in: Always use CFLAGS as well as LDFLAGS when linking. - - * Joe Wells: policy.h: Added new parameter QNX_LOG_NODE_ID. - * log.c (ulog): Log the QNX node ID if QNX_LOG_NODE_ID is set. - - * Joe Wells: unix/serial.c: Support QNX dev_info function for - serial port locking. - - * Joe Wells: unix/fsusg.c: Support QNX disk_space function. - * unix/Makefile.in: fsusg.o now depends upon uudefs.h. - - * Joe Wells: policy.h: Changed PS_PROGRAM default for __QNX__. - Added HAVE_QNX_LOCKFILES. Rearranged LOCKFILE defines to permit - some default selections. - * sysh.unx: Removed LOCKFILES sanity check. - * unix/lock.c (fsdo_lock, fsqnx_stale), unix/serial.c - (fsserial_lockfile), unix/statsb.c (fsysdep_lock_status): Added - support for HAVE_QNX_LOCKFILES. - - * configure.in, config.h.in, policy.h: Moved MAIL_PROGRAM to - policy.h. Added MAIL_PROGRAM_TO_BODY and - MAIL_PROGRAM_SUBJECT_BODY. - * unix/mail.c: Updated accordingly. - - * uucico.c (main): Don't make -p imply -e. - (uhelp): Modified accordingly. - * uucico.8: Modified accordingly. - -Mon Nov 1 21:34:36 1993 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main): Call fconn_close and fconn_open rather than - calling fconn_reset. - * conn.h (struct sconncmds): Removed pfreset field. - (fconn_reset): Removed declaration. - * conn.c (fconn_reset): Removed. - * tcp.c (ftcp_reset): Removed. - (ftcp_open): Save pid in ssysdep_conn information. - (ftcp_close): If pid has changed, return FALSE. - * tli.c (ftli_reset): Removed. - (ftli_open): Save pid in ssysdep_conn information. - (ftli_close): If pid has changed, return FALSE. - * unix/pipe.c (fspipe_close): Replaced with fspipe_reset body. - (fspipe_reset): Removed. - (fspipe_dial): Call fspipe_close, not fspipe_reset. - * unix/serial.c (fsserial_reset, fsstdin_reset): Removed. - (fsysdep_modem_begin_dial): Hangup terminal here, rather than - calling fconn_reset. - - * send.c (fremote_rec_reply): If we want to request hangup, send - an M after the mode. - * rec.c (flocal_rec_await_reply): If there an M after the mode, - the remote is requesting a hangup. - -Sun Oct 31 23:43:40 1993 Ian Lance Taylor (ian@airs.com) - - * uux.c (zXnames): New static variable to hold list of file names - being sent. - (uxadd_name): Function to add a new name. - (main, uxadd_send_file): Call uxadd_name. - (main): Include zXnames in log message. - -Mon Oct 18 00:23:27 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (fijstart): Ensure that packet size and window size are - reasonable; restrict window size to 16. - - * proti.c (iIforced_remote_winsize): Removed, along with all - references. - (asIproto_params): Removed "remote-window". - -Sun Oct 17 22:15:14 1993 Ian Lance Taylor (ian@airs.com) - - * Mark Delany: protg.c (cGremote_duprrs): New static variable. - (fgstart): Initialize it. - (fgshutdown): Count rejects as cGremote_duprrs + cGremote_rejects. - (fgprocess_data): If cGremote_rejects is non-zero, don't treat - duplicate RR as reject. Count duplicate RR's in cGremote_duprrs, - not cGremote_rejects. - - * Mark Delany: unix/serial.c (fsdouble_chat, fsysdep_conn_chat): - After running a chat program, reread the terminal characteristics. - -Wed Oct 13 20:46:46 1993 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call): Fix typo. - -Thu Oct 7 22:28:45 1993 Ian Lance Taylor (ian@airs.com) - - * unix/app3.c (zsappend3), unix/app4.c (zsappend4), unix/ftw.c - (ftw), unix/sindir.c (zsysdep_in_dir): Don't duplicate '/' - character for root directory. - - * send.c (flocal_send_await_reply): If an SN comes in while the - file is being sent, seek to the end rather than setting fsendfile - to FALSE. - (flocal_send_cancelled): Don't send an empty packet. - * trans.c (utransfree): Set e field to EFILECLOSED when debugging. - (floop): Check for file send cancelled at top of loop, not middle. - - * uucp.h (ffileseekend): Define. - -Wed Oct 6 00:51:08 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (fisenddata, fiprocess_packet): Report channel numbers - in debugging messages. - -Tue Oct 5 00:00:33 1993 Ian Lance Taylor (ian@airs.com) - - * unix/statsb.c (fsysdep_lock_status): Only report the status of a - particular job once, no matter how many lock files it has. - - * uustat.c (fsnotify): Added itime argument. Changed all callers. - Report time job was queued in mail message. - - * unix/cusub.c (fsysdep_terminal_raw): For TERMIO and TERMIOS, - clear IXON, IXOFF and IXANY (TERMIO only) in c_iflag. - - * Lele Gaifax: log.c (ustats): Report device name. - - * log.c (ulog): Use zsysdep_base_name of zProgram. - - * uuxqt.c (main): Accept local system name and unknown system - names for -s argument. zsysdep_get_xqt may return an alias. - -Wed Sep 29 00:13:39 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (fiprocess_packet): If sending an ACK for a NAK, don't - also send a packet. - - * unix/serial.c (fsysdep_modem_end_dial): If TIOCWONLINE is not - defined, reopen the port to wait for carrier. - - * policy.h: Use __ultrix__ as well as ultrix in check for - HAVE_STRIP_BUG. - -Tue Sep 28 22:25:05 1993 Ian Lance Taylor (ian@airs.com) - - * Marcel Waldvogel: uuchk.c (ukshow): Don't die if the call out - file can not be opened. - -Sun Sep 19 00:16:01 1993 Ian Lance Taylor (ian@airs.com) - - * Jason Molenda: policy.h (HAVE_SEQUENT_LOCKFILES): New - configuration parameter. - * sysh.unx, unix/serial.c: Implement it. - - * uulog.c (main): Ignore any errors when trying to canonicalize - the system name. - - * Marcel Waldvogel: uucico.c (faccept_call): If the calling system - is already locked, and we are using sequence numbers for it, - increment the local sequence number to keep in synch. - - * unix/sleep.c (usysdep_sleep): If usysdep_pause is accurate, use - it. Otherwise call sleep, but always for at least two seconds. - * chat.c (fcsend): Call usysdep_sleep with 1, not 2. - - * unix/pause.c: Correct USE_SELECT_TIMER to HAVE_SELECT. - - * unix/serial.c (fsmodem_open): Only turn on hardware flow control - for an incoming connection. - (fsmodem_carrier): Turn on hardware flow control after turning on - carrier. Turn off hardware flow control before turning off - carrier. - - * uuxqt.c (uqdo_xqt_file): Use known system name, not system name - from execution file, unless the former is a prefix of the latter. - -Sat Sep 18 16:53:41 1993 Ian Lance Taylor (ian@airs.com) - - * policy.h: Add HAVE_ENCRYPTED_PASSWORDS configuration parameter. - * callin.c: Change interface to use a passed in comparison - function. - * uuconf.h: Change declaration of uuconf_callin. - * uucico.c (flogin_prompt): Change call to uuconf_callin. - (icallin_cmp): New function. Handle HAVE_ENCRYPTED_PASSWORDS. - - * Hans-Dieter Doll: chat.c (fchat): Permit \W at the end of an - expect string to specify a timeout. - - * util.c (zremove_local_sys): New function. - * uudefs.h: Declare zremove_local_sys. - * uucp.c (main): Read local system information. Ignore local - system name in front of arguments. - * uux.c (main): Ignore local system name in front of arguments. - - * configure.in: Call AC_HAVE_POUNDBANG, AC_STAT_MACROS_BROKEN, - AC_TIME_WITH_SYS_TIME, AC_STRUCT_TM. Call AC_SUBST(POUNDBANG). - Remove HAVE_SYS_TIME_AND_TIME_H check. Rework disk space - configuration to actually check for the functions. Check for - function dev_info. Don't confuse HAVE_FTW_H and HAVE_FTW (from - Joe Wells). - * config.h.in (STAT_MACROS_BROKEN, TM_IN_SYS_TIME, STAT_DUSTAT, - STAT_DISK_SPACE, HAVE_DEV_INFO): New macros set by configure. - (TIME_WITH_SYS_TIME): Renamed from HAVE_SYS_TIME_AND_TIME_H. - * Makefile.in (POUNDBANG): Set to @POUNDBANG@. - (uusched, uuto): If POUNDBANG = no, turn #!/bin/sh into :. - (config.status): Use config.status --recheck. - (configure): Chdir to $(srcdir) before running autoconf. - * sysh.unx: If STAT_MACROS_BROKEN, undefine S_ISDIR. - * log.c, time.c, uustat.c, unix/loctim.c: If TM_IN_SYS_TIME, - include <sys/time.h>, not <time.h>. - * tstuu.c, unix/pause.c, unix/proctm.c, unix/serial.c: Rename - HAVE_SYS_TIME_AND_TIME_H to TIME_WITH_SYS_TIME. - * fsusg.c: Check STAT_DUSTAT, not _AIX and _I386. - - * config.h.in: Renamed from conf.h.in. - * MANIFEST, configure.in, Makefile.in, lib/Makefile.in, - unix/Makefile.in, uuconf/Makefile.in, uucp.h: conf.h renamed to - config.h. - -Fri Sep 17 00:36:16 1993 Ian Lance Taylor (ian@airs.com) - - * Joe Wells: policy.h: If __QNX__, default to HAVE_POSIX_TERMIOS. - - * Joe Wells: Makefile.in (FORCE): Add dummy command to work around - QNX make bug. - - * Makefile.in, lib/Makefile.in, unix/Makefile.in, - uuconf/Makefile.in: Add .PHONY declaration for appropriate - commands. - - * Joe Wells: Makefile.in (install): Create $(man1dir) and - $(man8dir) if necessary. - (install-info): Create $(infodir) if necessary. - - * Joe Wells: sysh.unx (bsgrade): Declare as returning int rather - than char, since it can return a negative number. - * unix/work.c (bsgrade): Define as returning int. - - * Joe Wells: unix/lock.c (fsdo_lock), unix/statsb.c - (fsysdep_lock_status): Use pid_t rather than int for variables - that hold pid's. Cast to long when using printf. - - * Joe Wells: uucico.c (fcall): Fix test for 24 hour check when too - many retries. - - * Joe Wells: uucico.c (fcall), unix/opensr.c - (esysdep_open_receive), unix/recep.c (fsysdep_already received): - Cast values in multiplication to determine seconds per day or per - week to long, because result is larger than 16 bits. - - * Joe Wells: uuconv.c: Add return 0 after exit to avoid warnings. - -Thu Sep 16 23:53:58 1993 Ian Lance Taylor (ian@airs.com) - - * Joe Wells: configure.in: Set AR from environment, defaulting to - ar, and substitute it in Makefiles. - * Makefile.in: Set AR to @AR@. Pass it down in MDEFINES. - * lib/Makefile.in, unix/Makefile.in, uuconf/Makefile.in: Set AR to - @AR@. Use $(AR) instead of ar. Use rc instead of qc (POSIX.2 - does not define q). - -Wed Sep 15 00:47:33 1993 Ian Lance Taylor (ian@airs.com) - - * uuconf/callin.c (uuconf_callin): Take an additional argument: a - function to call to transform the login name and password. This - is a hack to avoid requiring escape sequence handling in uuconf. - * uucico.c (flogin_prompt): Pass cescape to uuconf_callin. This - is an incompatible change. - * uuconf.h (uuconf_callin): Update declaration. - * tstuu.c (uprepare_test): Use \s in password in Call1 and Pass2. - - * chat.c (fcsend, fcprogram): Expand escape sequences in callout - login names and passwords. This is an incompatible change. - - * Joe Wells: uustat.c (fsnotify): Add missing break statement. - - * Mark Eichin: tstuu.c (main): Add some sleeps in the children to - make the tests more robust on Linux. - - * uulog.c (ulhelp): Clean up general usage message: don't show -F - for HDB_LOGGING, don't show -x for non HDB_LOGGING. Remove - mention of numeric debugging levels. - * uustat.c (ushelp): Remove mention of numeric debugging levels. - - * unix/serial.c (ICLEAR_CFLAG): Removed CLOCAL. - (enum tclocal_setting): New enum. - (fsserial_lock): Don't call TIOCSCTTY. - (fsserial_open): Changed flocal argument to tlocal. Use it to - determine initial CLOCAL setting for TERMIO and TERMIOS. Don't - call TIOCSCTTY until after setting the terminal state. - (fsstdin_open): Call fsserial_open with IGNORE_CLOCAL. - (fsmodem_open): Call fsserial_open with SET_CLOCAL if calling out, - CLEAR_CLOCAL if waiting for an incoming call. - (fsdirect_open): Call with SET_CLOCAL or CLEAR_CLOCAL depending - upon fcarrier setting. - * uuconf.h (struct uuconf_direct_port): Added fcarrier field. - * uuconf/tportc.c (asPdirect_cmds): Added ``carrier'' command. - (_uuconf_iport_cmd): Initialize direct fcarrier field to FALSE. - * uuconf/hport.c (uuconf_hdb_find_port), uuconf/vport.c - (uuconf_v2_find_port): Set direct fcarrier field to FALSE. - * uuchk.c (ikshow_port): Print direct port carrier field. - * uuconv.c (uvwrite_taylor_port): Likewise. - - * uustat.c (main, fsquery, fsquery_systems, fsquery_show): Support - -o, -y, -s and -S in conjunction with -q. - -Tue Sep 14 00:51:50 1993 Ian Lance Taylor (ian@airs.com) - - * log.c (ulog): If we can't open the log file, print an error on - stderr. - - * configure.in, conf.h.in: Adjusted for autoconf 1.5. - -Sun Sep 12 15:52:29 1993 Ian Lance Taylor (ian@airs.com) - - * unix/serial.c (fsserial_open): Add flocal argument. Changed all - callers. Pass it as TRUE when dialing out on a modem. This is - supposedly required on 386bsd. - - * conn.c (fconn_dial_sequence): New function. - (fmodem_dial): Use fconn_dial_sequence. Call fsysdep_modem_begin - only once, before entire sequence, and fsysdep_modem_end only - once, after entire sequence. Don't call fcdo_dial. - (fcdo_dial): Removed. - * conn.h: Declare fconn_dial_sequence. - * uucico.c (fconn_call): Don't free dialer if fconn_dial fails. - * uuconf.h (struct uuconf_tcp_port): Add pzdialer field. - * tcp.c (ftcp_dial): Pass new pzdialer field to - fconn_dial_sequence. - * tli.c (ftli_dial): Pass pzdialer to fconn_dial_sequence. - * uuconf/hport.c (uuconf_hdb_find_port): Add trailing dialer - sequence to pzdialer field for TCP port. - * uuconf/tportc.c (asPtcp): Add ``dialer-sequence'' command. - (_uuconf_iport_cmd): Initialize pzdialer for TCP port. - * uuconf/vsinfo.c (_uuconf_iv2_system_internal): Initialize - pzdialer for TCP port. - * uuchk.c (ikshow_port): Print TCP pzdialer field. - * uuconv.c (uvwrite_taylor_port, ivwrite_hdb_port): Output TCP - pzdialer field. - -Sat Sep 11 16:30:17 1993 Ian Lance Taylor (ian@airs.com) - - * uulog.c, uuname.c (main): Pass INIT_NOCHDIR to - usysdep_initialize. - - * uucp.1, uustat.1, uux.1, uuxqt.8: Remove uses of nonportable .EX - and .EE macros. - - * uuxqt.c (asQcmds, iqout, iqfile, iqrequestor, iquser): Remove - restrictions on number of arguments to commands in execution file, - since is there is such a range of buggy UUCP implementations out - there. - - * sysh.unx (CORRUPTDIR): Define. - * unix/corrup.c: New file for new zsysdep_save_corrupt_file - function to save a file in CORRUPTDIR. - * unix/Makefile.in, unix/MANIFEST: Add corrup. - * system.h: Add declaration of zsysdep_save_corrupt_file. - * uuxqt.c (uqdo_xqt_file): If execution file has a syntax error, - save it using zsysdep_save_corrupt_file and notify OWNER. - - * uuconf/hsinfo.c (_uuconf_ihdb_system_internal), vsinfo.c - (_uuconf_iv2_system_internal): Treat a specified time/grade as - both a timegrade and a call-timegrade. - - * rec.c (frec_file_end): If the received file can not be moved to - the final location, and there is enough disk space, keep the file, - mentioned the saved name in the error message, and send mail to - OWNER about it. If the hand created execution file can not be - moved, delete it. - * unix/move.c (fsysdep_move_file): Don't delete the original file - if the move fails. - * unix/splcmd.c (zsysdep_spool_commands): Remove the temporary - file if the move fails. - -Wed Sep 1 23:29:30 1993 Ian Lance Taylor (ian@airs.com) - - * uuconf/tinit.c (itdebug, _uuconf_idebug_cmd): New functions. - (asCmds): Call itdebug for "debug", to accept spaces between - options as well as commas. - * uuconf/tsinfo.c (iidebug): New function. - (asIcmds): Call iidebug for "debug". - * uuconf/uucnfi.h: Added prototype for _uuconf_idebug_cmd. - -Tue Aug 31 00:09:33 1993 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_file_init): Don't set flocal if job was - requested by a remote user. - (flocal_send_fail, flocal_send_open_file): Don't save temporary - file in .Preserve if job was requested by a remote user. - - * unix/wldcrd.c (fsysdep_wildcard_start): Don't free zcmd until - after calling espopen. - - * lib/buffer.c (ubuffree): Added debugging code controlled by - DEBUG_BUFFER macro. - -Sun Aug 29 13:33:21 1993 Ian Lance Taylor (ian@airs.com) - - * uuconf/tcalou.c: Permit empty password in call file. - - * unix/work.c (COMMANDS_PER_SCAN): New macro. - (fsysdep_get_work_init): Get at most COMMANDS_PER_SCAN new command - files, to avoid timeouts while reading a large directory. - - * rec.c (fremote_send_file_init): Initialize crestart. - - * uux.c (main): Changed special handling of single "-" argument to - call getopt multiple times. - - * D.J. James: protg.c (fgsendcmd, fgsenddata), prott.c - (ftsendcmd): Avoid passing 0 to bzero to avoid SunOS bug. - - * protf.c (ffprocess_data): Some systems seem to send characters - with parity, so strip the parity bit from incoming bytes. - - * Kenji Rikitake: uucp.h: Changed order of header files to avoid - gcc stddef.h vs. sys/stdtypes.h problem on SunOS 4.1. - - * Alexander Lehmann: configure.in: Correct misspelling of - HAVE_GETWD. - - * John Hood: unix/filnam.c (ZCHARS): Get the alphabet right. - - * Gabor Kiss: tcp.c (ftcp_dial): Use all gethostbyname info before - calling getservbyname. - -Thu Aug 26 23:15:33 1993 Ian Lance Taylor (ian@airs.com) - - * uux.c, uuxqt.c: Added long options. - - * uucp.c: Added v to getopt_long argument, print help and version - info to stderr. - - * unix/splcmd.c (zsysdep_spool_commands): Create command file via - temporary file, so that the command file is created atomically. - * unix/spool.c (zscmd_file): Accept files starting with "TMP". - -Sun Jul 25 14:50:41 1993 Ian Lance Taylor (ian@airs.com) - - * uupick.c, uustat.c: Added long options. - -Mon Jul 19 22:06:19 1993 Ian Lance Taylor (ian@airs.com) - - * uucico.c, uuconv.c, uucp.c, uulog.c, uuname.c: Added long - options. - * uucico.c (main, fcall): Made -c option not print the ``No work'' - log message. - * uuname.c (main): Call ulog_uuconf rather than unuuconf_error. - -Sun Jul 11 14:29:39 1993 Ian Lance Taylor (ian@airs.com) - - * cu.c, uuchk.c: Added long options. - - * uudefs.h, log.c (zProgram): Renamed from abProgram. - * cu.c, uucico.c, uucp.c, uulog.c, uuname.c, uupick.c, uustat.c, - uux.c, uuxqt.c (main): Initialize zProgram from argv[0]. - - * Bob Hemedinger: unix/cohtty.c (fscoherent_disable_tty): Almost - always return TRUE. - * unix/serial.c (fsserial_lockfile): Skip "LCK.." in string passed - to lockttyexist and fscoherent_disable_tty. - * uucico.c (main): If __COHERENT__ is defined, change the meaning - of -c for backward compatibility with old Coherent UUCP. - - * David Nugent: uucico.c (main): Added -C option to only call - system named by -s or -S if there is work. - - * uuconf/syssub.c (_uuconf_isystem_default): Merge in default - protocol parameters so that setting parameters for one protocol - does not lose the default settings for other protocols. - - * unix/lcksys.c (zssys_lock_name): New function. - (fsysdep_lock_system, fsysdep_unlock_system): Use it. - - * John Plate: uuchk.c (ukshow): Call ukshow_size with the right - arguments in the called remote case. - - * uuconf/remunk.c (uuconf_remote_unknown): use the remote.unknown - shell script if HDB_CONFIG and no ``unknown'' commands appeared in - the config file. - - * Jim Brownfield: uuconf/vsinfo.c (_uuconf_iv2_system_internal): - Accept continuation lines in L.sys. - - * Marc Evans: unix/serial.c (fsysdep_conn_write, fsysdep_conn_io): - Add casts to t_snd calls to avoid warnings. - - * Julian Stacey: uuchk.c (main): If no information found, say so. - - * Ju"rgen Fluk: uulog.c (main): Better error messages for HDB. - - * uucico.c (zget_typed_line): If last string ended in \r, ignore - leading \n. - - * Mark E. Mallett: uuconf/time.c (asTdays): Add "none". - - * uuconf/hsinfo.c (_uuconf_ihdb_system_internal): Report line - numbers for syntax errors. - -Sat Jul 10 10:28:03 1993 Ian Lance Taylor (ian@airs.com) - - Initial hardware flow control support from Peter Wemm: - * uuconf.h (struct uuconf_modem_port, struct uuconf_direct_port): - New field uuconf_fhardflow in each structure. - * unix/serial.c (fsserial_hardflow): New routine. Initially - supports SunOS and SCO Unix. - (fsmodem_open, fsdirect_open): Turn on hardware flow control if - supported by the port. - (fsserial_set): If CRTFSL is set, don't send XON/XOFF characters. - * uuconf/hport.c (uuconf_hdb_find_port), uuconf/tportc.c - (_uuconf_iport_cmd), uuconf/vport.c (uuconf_v2_find_port): - Initialize uuconf_fhardflow field to TRUE. - * uuconf/tportc.c (struct asPmodem_cmds, struct asPdirect_cmds): - Added "hardflow" command. - * uuchk.c (ikshow_port): Report whether hardware flow control is - available. - * uuconv.c (uvwrite_taylor_port): Write out hardware flow control - information. - - * Peter Wemm: protg.c (fgstart), proti.c (fijstart): Report local - packet and window size as well as remote. - * rec.c (fremote_send_file_init), send.c (flocal_send_open_file, - fremote_rec_reply): Report number of bytes being sent or received, - and restart point if any. - - * Peter Wemm: trans.h (struct sdaemon): New fields csent and - creceived. - * uucico.c (fcall, faccept_call): Initialize csent and creceived. - (fdo_call, faccept_call): Report on number of file bytes - transferred and bytes per second. - * rec.c (frec_file_end): Record number of bytes received. - * send.c (fsend_wait_confirm): Record numbers of bytes sent. - * trans.c (ufailed): Record number of bytes sent or received. - - * Peter Wemm: uusched.in, uuto.in: Use #!/bin/sh rather than :. - Use exec when invoking program. - - * uulog.c (main): Don't die if we can't canonicalize the -s - argument. - - * unix/cusub.c (uscu_child): Force the descriptor into blocking - mode. - - Port type pipe support contributed by Marc Boucher: - * unix/pipe.c: New file. Support routines for pipes. - * unix/MANIFEST, unix/Makefile.in: Adjusted for new file pipe.c. - * uuconf.h (enum uuconf_porttype): Added UUCONF_PORTTYPE_PIPE. - (struct uuconf_pipe_port): New structure. - (struct uuconf_port): Added uuconf_pipe_port to union. - * sysh.unx (struct ssysdep_conn): Add fields ord, owr and ipid, - rename istdout_flags to iwr_flags. - (fsdouble_{read, write, chat}): New prototypes. - * conn.h: Prototype for fsysdep_pipe_init. - * unix/serial.c: Renamed fsstdin_{read, write, chat} to - fsdouble_{read, write, chat}. Made them non-static. Changed them - to use ord and owr fields rather than 0 and 1. - (fsserial_init, fsstdin_open): Initialize ord and owr fields. - (fsstdin_close, fsblock, fsstdin_reset, fsysdep_conn_io, - fsstdin_break, fsstdin_set): Use ord and owr fields rather than 0 - and 1. - * uuconf/tportc.c (asPtype_names): Added "pipe". - (asPpipe_cmds, CPIPE_CMDS): New array of pipe commands. - (CCMDS, _uuconf_iport_cmd): Adjusted accordingly. - * tcp.c (fsysdep_tcp_init), tli.c (fsysdep_tli_init): Initialize - new ord and owr fields. - * conn.c (fconn_init): Call fsysdep_pipe_init for - UUCONF_PORTTYPE_PIPE. - * unix/cusub.c (zsport_line, uscu_child, fsysdep_shell): Handle - UUCONF_PORTTYPE_PIPE. - * uuchk.c (ikshow_port): Report on port type pipe. - * uuconv.c (uvwrite_taylor_port): Write out port type pipe. - - * Marc Boucher: cu.c: (main, ucuabort): Use new variable - fCuconnprinted to avoid printing ZDISMSG if ZCONNMSG has not been - printed. - (main): Call fsysdep_port_access only after we have locked the - port, to get a better error message on systems with shared lines. - - * Marc Boucher: policy.h (HAVE_FULLDUPLEX_PIPES): New macro. - * unix/spawn.c (ixspawn): Use it. - - * Marc Boucher: uucico.c (uusage): Added lines for -c and -D. - - * uuconf/time.c (_uuconf_itime_parse): Add casts to avoid a - compiler warning. - - * uustat.c (fsworkfile_show): Don't report non-existent send - files. - - * lib/parse.c (fparse_cmd): Accept any base for the mode argument, - rather than always using 8. Depend upon the leading zero to - indicate base 8. Accomodates UFGATE 1.03. - -Wed Jun 30 00:27:27 1993 Ian Lance Taylor (ian@airs.com) - - * uudefs.h (struct scmd): Changed bdummy field to bgrade. - * trans.c (fqueue_send): Sort sends by whether they are a command - and then by grade. - * unix/work.c (asSwork_files): Renamed from azSwork_files, made - array of struct ssfilename rather than char *. - (struct ssfile): Added bgrade field. - (iswork_cmp, fsysdep_get_work_init, usysdep_get_work_freed): - Changed accordingly. - (fsysdep_get_work): Set qcmd->bgrade. - * uucp.c (uccopy), uux.c (main, uxadd_send_file), uuxqt.c - (uqdo_xqt_file), xcmd.c (fremote_xcmd_init), lib/parse.c - (fparse_cmd): Initialize bgrade field of scmd structure. - -Sun Jun 27 23:21:33 1993 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_await_reply, flocal_send_cancelled): If the - first D. file being sent for a faked E command fails, send the - second one anyhow. - -Sun Jun 6 23:07:33 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (fiprocess_data): If we get a packet we sent a NAK for, - forget that sent NAKs for all preceding packets. - (fiprocess_packet): If we get a NAK for the packet we are about to - send, and all our packets have been acknowledged, send an ACK. - -Thu Jun 3 20:54:55 1993 Ian Lance Taylor (ian@airs.com) - - * prot.h (struct sprotocol): Added frestart field. - * uucico.c (asProtocols): Initialize frestart field. - * system.h, unix/opensr.c (zsysdep_receive_temp): Added frestart - argument to zsysdep_receive_temp. - * rec.c (flocal_rec_send_request, fremote_send_file_init, - frec_file_end): Pass frestart argument to zsysdep_receive_temp. - * unix/opensr.c (esysdep_open_receive): Permit pcrestart argument - to be NULL. - * rec.c (flocal_rec_await_reply, fremote_send_file_init): Pass - pcrestart argument to esysdep_open_receive as NULL if file - tranfers can not be restarted. - - * lib/status.c (azStatus): Uwe Doering: If SPOOLDIR_HDB or - SPOOLDIR_SVR4, use the same strings they use. - * unix/status.c (aiMapstatus): Uwe Doering: Swap 4 and 20. - - * unix/serial.c (fsserial_open): Uwe Doering: Set VTIME to 1. - - * uucico.c (faccept_call, uaccept_call_cleanup): Uwe Doering: Free - and unlock evertyhing after any return from faccept_call. - (main): Don't need to unlock after faccept_call here any more. - - * proti.c (fiprocess_data): Added additional debugging - information. - -Sat May 15 13:55:21 1993 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgprocess_data): Don't treat a duplicate RR as an RJ if - we are retransmitting packets. If we are treating a duplicate RR - as an RJ, don't also treat it as an acknowledgement. - - * unix/serial.c (fsysdep_conn_io): Typo in debugging message. - -Tue May 4 00:03:32 1993 Ian Lance Taylor (ian@airs.com) - - * uux.c (main): Andreas Raab: Move aboptions out of local block - since a pointer to it escapes the scope. - - * unix/mkdirs.c: W Christopher Martin: Just try to make the - directories, and ignore EEXIST errors, rather than first checking - whether the directory exists. - - * send.c (flocal_send_request): Chip Salzenberg: Double check that - the file still exists before sending the S command. - - * uucico.c (zget_uucp_cmd, zget_typed_line), trans.c (fgot_data): - Matthew Geier: Avoid doing memcpy (z, NULL, 0). - -Mon May 3 22:52:46 1993 Ian Lance Taylor (ian@airs.com) - - * system.h, unix/locfil.c, unix/cwd.c, unix/picksb.c: Johan - Vromans: Added pfbadname argument to zsysdep_local_file, - zsysdep_local_file_cwd, zsysdep_uupick_local_file. - * Changed all callers. - * send.c (fremote_rec_file_init), rec.c (fremote_send_file_init): - If remote system gives bad name, return an error rather than - aborting the connection. - * uuxqt.c (uqdo_xqt_file): If bad file name, abort execution - rather than try again later. - * uupick.c (main): If bad file name, permit new command rather - than exiting. - - * lib/debug.c: Stephan Niemz: Accept whitespace separated - debugging types. - - * unix/detach.c: Always use setsid if it is available. - -Sun May 2 13:23:33 1993 Ian Lance Taylor (ian@airs.com) - - * unix/spool.c (zsfind_file): Fix handling of execution file - names for systems to work with any possible execution file name. - - * send.c (flocal_send_open_file): Subtract starting position from - number of bytes passed to pffile. - - * uuconf/rdperm.c: Syd Weinstein: Don't skip lines in Permissions - with leading whitespace. - - * uuconf/vsinfo.c: Gero Kuhlmann: Set default retry time - correctly. - - * unix/lock.c (fsdo_lock): Andrew Vignaux: Handle readonly lock - files correctly. - - * send.c (flocal_send_fail, flocal_send_await_reply): James Van - Artsdalen: Clarify error messages relating to execution files. - - * log.c (ustats): Avoid overflow in bytes/sec calculation. - -Sat May 1 17:40:14 1993 Ian Lance Taylor (ian@airs.com) - - * trans.c (ftadd_cmd): Don't treat junk at end of command as a - size if the remote system doesn't support sizes. - - * uucico.c (faccept_call): Turn on the protocol before reading the - queue, in case there are lots of command files. - - * unix/cusub.c: Julian Stacey: If SIGUSR2 is not defined, use - SIGURG instead. - - * uuconf/syshdr.unx (MAKE_ABSOLUTE): New macro. - * uuconf/tinit.c (itaddfile): Renamed from itadd. Use - MAKE_ABSOLUTE to force absolute pathnames to configuration files. - - * conn.c (fconn_close): Steve M. Robbins: Ignore any SIGHUP - received after closing the connection. - - * cu.c (main): Frank Conrad: When an alternate fails, move on to - the next one. - - * uucico.c (faccept_call): Alexei K. Yushin: Supposedly some - UUCP's send UgG rather than just Ug. - - * unix/serial.c (fsserial_lockfile): Bob Hemedinger: Fix error - message in HAVE_COHERENT_LOCKFILES case. - - * unix/mkdir.c: Andy Fyfe: Pass fkeepuid as TRUE to ixsspawn. - - * unix/strerr.c: Undefine strerror in case there is a macro - definition which configure did not pick up. - - * configure.in: Andy Fyfe: AT&T 3b1 has sys/mount.h but not - statfs. - - * uudir.c: Andy Fyfe: Include uucp.h. - - * unix/fsusg.c: Andy Fyfe: Typos in (untested) STAT_USTAT case. - - * unix/filnam.c: Eric Lee Green: Avoid generating filenames that - only differ in case, to make life easier for bad filesystems. - - * uuconf/llocnm.c: Brian J. Murrell: Don't read HDB files if - ``hdb-files no'' given. - -Sat Mar 20 16:10:20 1993 Ian Lance Taylor (ian@airs.com) - - * uudefs.h (eSendfile, eRecfile): Deleted obsolete declarations. - -Sat Feb 13 15:57:30 1993 Ian Lance Taylor (ian@airs.com) - - * Released version 1.04. - - * unix/detach.c: Andrew A. Chernov: Don't check return of setsid. - -Sun Jan 31 01:45:56 1993 Ian Lance Taylor (ian@airs.com) - - * cu.c (main): Pass "cu" to uuconf_init. - - * protz.c (fzprocess): Restore ZPAD char before calling getinsync. - -Sat Jan 30 22:19:26 1993 Ian Lance Taylor (ian@airs.com) - - * Makefile.in (doc-dist): New target. - -Wed Jan 27 22:55:26 1993 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgstart): Set iGremote_segsize when using - remote-packet-size. - -Tue Jan 26 01:01:34 1993 Ian Lance Taylor (ian@airs.com) - - * proti.c (fiprocess_data): always send an ACK after receiving - half a window, rather than sometimes resending a packet. Half a - window of short packets can arrive very quickly. - - * tstuu.c (main, cread, fsend): rewrote communication routines to - avoid deadlock. - -Sun Jan 24 01:02:47 1993 Ian Lance Taylor (ian@airs.com) - - * trans.c (ufailed): don't report statistics if no bytes - transferred. - - * Makefile.in (install): simplified somewhat. - (dist): distribute the sample directory. - -Sat Jan 23 19:47:12 1993 Ian Lance Taylor (ian@airs.com) - - * configure.in, conf.h.in, tli.c: Karl Swarz: check for and use - <sys/tli.h>. - -Fri Jan 22 00:09:37 1993 Ian Lance Taylor (ian@airs.com) - - * send.c (flocal_send_request): Alan Judge: don't send C in option - string when faking an E command as an S command. - -Thu Jan 21 00:09:31 1993 Ian Lance Taylor (ian@airs.com) - - * uux.c (main): don't use E command if forwarding. - -Wed Jan 20 00:22:38 1993 Ian Lance Taylor (ian@airs.com) - - * send.c (fsend_exec_file_init), rec.c (frec_file_end), uux.c - (main): Chip Salzenberg: always put the C line last in an - execution file, to support Fredmail. - -Tue Jan 19 00:09:43 1993 Ian Lance Taylor (ian@airs.com) - - * trans.h, trans.c (ftcharge, floop, fgot_data): rewrote timing - code. - - * trans.h, trans.c, send.c, rec.c, xcmd.c, protf.c, protz.c - (fqueue_local, fqueue_remote, fqueue_send, fqueue_receive): added - boolean return value and qdaemon argument. - -Mon Jan 18 00:01:46 1993 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call, faccept_call): Ted Lindgreen, Chip - Salzenberg: wait for remote hangup string before hanging up. - - * proti.c (fiprocess_data, fiprocess_packet): stop scanning input - buffer after a CLOSE packet. - -Sat Jan 16 22:44:28 1993 Ian Lance Taylor (ian@airs.com) - - * system.h, uucico.c (main), uuxqt.c (main), unix/init.c: Ted - Lindgreen: eliminated INIT_DAEMON. - - * log.c (ulog): don't log SIGINT if fLog_sighup is FALSE. - - * unix/move.c (fsysdep_move_file), unix/xqtsub.c - (fsysdep_move_uuxqt_files): the system call rename seems to fail - on some systems for arbitrary reasons, so always try to copy the - file by hand, not just if we get EXDEV. - - * policy.h, unix/pause.c: Gregory Gulik: added HAVE_HUNDREDTHS_NAP - configuration parameter. - -Wed Jan 6 21:06:45 1993 Ian Lance Taylor (ian@airs.com) - - * unix/serial.c (fsserial_lockfile): create HDB lock files when - using HAVE_COHERENT_LOCKING. - unix/cohtty.c (fscoherent_disable_tty): consistently return FALSE - on error. - - * unix/cusub.c (fsysdep_terminal_raw): Andrew A. Chernov: if - POSIX_TERMIOS, turn of IEXTEN flag. - -Sat Jan 2 23:19:27 1993 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgprocess_data): treat a duplicate RR as an RJ. - -Fri Jan 1 11:17:30 1993 Ian Lance Taylor (ian@airs.com) - - * policy.h, unix/proctm.c: Steven S. Dick: use sysconf - (_SC_CLK_TCK) for TIMES_TICK if possible. - - * uuconf/diacod.c: Gregory Gulik: accept an empty dialcode string. - - * system.h, uucico.c (main), uucp.c (main), uux.c (main), - unix/run.c: Karsten Thygesen: removed ffork argument from - fsysdep_run. - -Wed Dec 30 00:21:55 1992 Ian Lance Taylor (ian@airs.com) - - * unix/link.c: Andrey G Blochintsev: don't fail just because - destination directories do not exist. - - * send.c (flocal_send_open_file): Scott Ballantyne: record file - name when logging send of execution command. - - * protz.c: Chip Salzenberg: reformatted to 80 columns. - -Tue Dec 29 23:50:52 1992 Ian Lance Taylor (ian@airs.com) - - * uuconv.c (uvwrite_time): scott@geom.umn.edu: handle midnight - more correctly. - -Fri Dec 18 00:49:16 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uucp.c (uccopy), uux.c (main), cu.c (icuput, icutake), - unix/ufopen.c (esysdep_user_fopen): Doug Evans: open files used - for %put and %take using esysdep_user_fopen, rather than with - privileges of uucp. Added frd and fbinary arguments to - esysdep_user_fopen. - -Thu Dec 17 00:04:53 1992 Ian Lance Taylor (ian@airs.com) - - * unix/picksb.c (zsysdep_uupick): Peter Wemm: allocation error. - - * uupick.c (main): Peter Wemm: pass INIT_GETCWD to - usysdep_initialize; really quit if 'q' is typed. - - * uulog.c (main): Peter Wemm: always canonicalize system name, not - just if using HDB_LOGGING. - - * uudefs.h, log.c (ustats), trans.c (ufailed), send.c - (fsend_await_confirm), rec.c (frec_file_end): Peter Wemm: added - fmaster argument to ustats, used only in HDB_LOGGING. - -Wed Dec 16 23:35:51 1992 Ian Lance Taylor (ian@airs.com) - - * uustat.c (main): Marc Unangst: forgot to call strtol for -y. - - * policy.h, sysh.unx: Brian J. Murrell: yet another configuration - parameter: HAVE_BROKEN_SETREUID. - -Tue Dec 15 00:13:04 1992 Ian Lance Taylor (ian@airs.com) - - * uuconv.c (uvwrite_taylor_system): mnichols@pacesetter.com: use - command-path rather than path. - - * trans.c (floop): Marc Unangst: don't clear frequested_hangup if - we didn't manage to hang up. - - * uucp.h, rec.c (fremote_send_file_init): Oleg Girko: patches to - make code compile if USE_STDIO is 0. - - * unix/proctm.c: Tim Peiffer: reverse sense of TIMES_TICK check in - hopes of avoiding ISC preprocessor bug. - - * unix/fsusg.h, unix/fsusg.c, unix/bytfre.c, system.h, conf.h.in, - configure.in, unix/Makefile.in, unix/MANIFEST: use new disk space - checking routines from GNU fileutils 3.4. - * unix/opensr.c (zsysdep_receive_temp): don't check free space - here any more. - * policy.h, trans.h, trans.c, rec.c, uucico.c, uudefs.h: Chip - Salzenberg: check amount of remaining space on disk every - FREE_SPACE_DELTA bytes, and abort the file transfer if disk space - gets too low. - -Wed Dec 2 00:24:12 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, unix/serial.c (fsserial_set): Frank Conrad: added - HAVE_PARITY_BUG parameter for the Sony NEWS. - -Mon Nov 30 00:06:59 1992 Ian Lance Taylor (ian@airs.com) - - * lib/spool.c (fspool_file): Andrew Chernov: accept any - alphanumeric character in the name, because it could be a grade - from another system. - -Sun Nov 29 22:36:47 1992 Ian Lance Taylor (ian@airs.com) - - * lib/buffer.c (ubuffree): scott@geom.umn.edu, Richard Gumpertz: - use a temporary variable to hold the offsetof result. - - * configure.in: scott@geom.umn.edu: define HAVE_SYS_SELECT_H - correctly. - - * protg.c (fgsend_control): Niels Baggesen: report all non-RR - packets if DEBUG_ABNORMAL. - - * unix/cusub.c (uscu_child): Ed Carp: apparently the read and - write calls can get EAGAIN on some systems. - - * unix/status.c (fsysdep_get_status, fsysdep_set_status): Chip - Salzenberg: map status values when using SPOOLDIR_HDB. - - * rec.c (fremote_send_reply): do file restart correctly for E - commands. - -Sun Nov 22 15:09:43 1992 Ian Lance Taylor (ian@airs.com) - - * protz.c: Chip Salzenberg: always do bitwise operations on - unsigned values. - - * getopt.h: Chip Salzenberg: don't rely on __STDC__. - -Thu Nov 19 00:13:46 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/freblk.c: Niels Baggesen: loop over the right list. - - * uulog.c (main): Peter Wemm: added -D, -F and -S options, made -f - take an argument and default to showing 10 current lines. - (ulusage): added new options and missing old ones. - -Wed Nov 18 22:26:36 1992 Ian Lance Taylor (ian@airs.com) - - * rec.c (frec_file_end): Andrey G Blochintsev: call - fsysdep_remember_reception as soon as the file has been moved to - the final destination; write fake execution file via a temporary - file to prevent uuxqt from getting at it early. - * trans.c (usent_receive_ack): don't call - fsysdep_remember_reception here. - - * unix/tmpfil.c (ZDIGS): don't use '.', since we use it to - separate parts of the file name. - -Sun Nov 15 15:31:49 1992 Ian Lance Taylor (ian@airs.com) - - * uustat.c (fsquery_show, csunits_show): Marc Unangst, Chip - Salzenberg: line up uustat -q output. - - * sysh.unx, ftw.c (ftw_dir, ftw), srmdir.c (isremove_dir), walk.c - (iswalk_dir): Marc Unangst: stat argument to function argument to - ftw is const. - - * unix/serial.c (fsserial_set): Mike Bernson: set CSIZE correctly - when changing parity. - - * uux.c (main): Andrew A. Chernov: check for executions which name - the local system, to handle dumb mailers. - - * uucp.h: Doug Evans: #undef strerror if HAVE_STRERROR is 0, to - avoid macro definition on Xenix. - - * unix/serial.c (fsserial_set): Peter Wemm: only check CRTSCTS if - HAVE_POSIX_TERMIOS. - - * cu.c (main): Peter Wemm: use alternates for systems if a call - fails. - - * tstuu.c (uprepare_test): Gerben Wierda: set execute bits for - Chat1 and Chat2. - - * trans.c (floop): Marc Unangst: don't hang up when requested - unless the send queue is empty. - - * uuxqt.c (iqrequestor): Marc Boucher: new function to accept R - command with two arguments, as generated by UUPC. - - * uucico.c (faccept_call): Christian Seyb: don't free the system - info until after writing the status. - - * configure.in: Marc Boucher: check -lsocket and -lnsl together. - - * unix/portnm.c: Stephen J. Walick: it's types.tcp.h, not - tcp.types.h. - - * configure.in: Brian Campbell: check for /usr/bin/mailx. - -Sat Nov 14 11:11:04 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/hlocnm.c (uuconf_hdb_login_localname): Christian Seyb: - check for _uuconf_unset as well as NULL. - - * conn.c (fconn_dial): initialize *ptdialerfound. - - * many files: rearranged header files to include "sysdep.h" before - system header files. Also eliminated various pedantic warnings, - and made _uuconf_unset char * to avoid possible alignment - problems. - -Tue Nov 10 00:16:35 1992 Ian Lance Taylor (ian@airs.com) - - * trans.h, uucico.c (fcall, faccept_call), trans.c (uclear_queue, - floop): Stephen J. Walick: move clean up from end of floop into - uclear_queue, and call it instead of just doing - usysdep_get_work_free. - - * unix/serial.c (fsserial_lockfile): Marc Unangst: bad #endif - location for HAVE_SVR4_LOCKFILES. - (fsserial_init): Doug Evans: null terminate the device name. - -Sun Nov 8 10:58:59 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fcall, faccept_call): Stephen J. Walick: call - usysdep_get_work_free here. - trans.c (floop): don't call usysdep_get_work free here. - -Sun Nov 1 17:05:07 1992 Ian Lance Taylor (ian@airs.com) - - * Released gamma version 1.04. - - * configure.in: check that sys/select.h and sys/time.h work - together, since that's how they are currently used. - - * cu.c, uustat.c, uuconf/diacod.c: add casts to eliminate - warnings. - - * configure.in: don't add strlwr to LIBOBJS. - - * policy.h, unix/cohtty.c: Bob Hemedinger: finish Coherent style - locking. - -Wed Oct 28 00:20:15 1992 Ian Lance Taylor (ian@airs.com) - - * tstuu.c: Ralf Stephan: check HAVE_POLL_H and HAVE_STROPTS_H. - - * Nickolay Saukh: accept SVR4 style R request file position. - uudefs.h: added ipos field to struct scmd. - lib/parse.c: accept SVR4 style R request with file position to - start from. - send.c (fremote_rec_file_init): start transferring file from - requested position. - uucp.c, uux.c, uuxqt.c, xcmd.c: initialize ipos field. - -Sun Oct 25 10:39:23 1992 Ian Lance Taylor (ian@airs.com) - - * unix/serial.c (fsysdep_conn_write, fsysdep_conn_io): T. William - Wells: take special care to ensure we don't write after SIGHUP. - - * policy.h, sysh.unx, unix/MANIFEST, unix/Makefile.in, - unix/serial.c (fsserial_lockfile), unix/cohtty.c (new file): Bob - Hemedinger: added HAVE_COHERENT_LOCKFILES. - - * unix/cusub.c (uscu_child): Igor V. Semenyuk: accept a 0 return - from read until we have read some data at some point. - -Thu Oct 22 10:38:32 1992 Ian Lance Taylor (ian@airs.com) - - * proti.c: various tweaks for bad connections. - - * uucp.h: T. William Wells: rename strcasecmp and strncasecmp, if - the system doesn't provide them, to avoid the ANSI C name space. - - * lib/buffer.c: Bob Hemedinger: put ab in union so that offsetof - will not take the address of an array. - - * uuxqt.c (uqdo_xqt_file): Bob Hemedinger: don't take address of - array. - -Wed Oct 21 00:05:31 1992 Ian Lance Taylor (ian@airs.com) - - * uustat.c (fsnotify): Gert Doering: if the file appears to be - binary, don't include it in any mail message. - - * unix/mkdir.c: Michael Yu.Yaroslavtsev: check whether directory - already exists before spawning /bin/mkdir. - - * proti.c: Michael Yu.Yaroslavtsev: iIsendpos and iIrecpos should - be long. - - * send.c (flocal_send_await_reply): Gert Doering: improved error - messages. - - * tli.c, unix/detach.c: include "sysdep.h" before <sys/ioctl.h>. - - * configure.in, conf.h.in: added some system specific checks - provided by autoconf. - - * tstuu.c, unix/serial.c: Merlyn LeRoy: check for ENODATA as well - as EAGAIN and EWOULDBLOCK. - - * uucico.c (faccept_call): Zacharias J. Beckman: if calling back, - clear status first. - - * uucico.c (fdo_call, faccept_call): Hans-Dieter Doll: avoid - overflow when turning ulimit value into bytes. - -Tue Oct 20 23:12:26 1992 Ian Lance Taylor (ian@airs.com) - - * serial.c (fsmodem_carrier): Hans-Dieter Doll: use IS68K LNOMDM - bit if available. - - * chat.c (fcsend): Hans-Dieter Doll: advance z after EOT. - - * cu.c: T. William Wells: beep on connected and disconnected - messages (only if ANSI_C, to use \a). - - * unix/run.c: Peter Wemm: pass fsetuid as TRUE to ixsspawn. - -Sun Oct 18 13:58:17 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, unix/serial.c (fsmodem_close): Stephen J. Walick: - added HAVE_RESET_BUG for SCO Xenix. - - * configure.in: Igor V. Semenyuk: avoid looking in -linet for - getline, since ISC has a different function there by that name. - - * unix/ufopen.c: Igor V. Semenyuk: handle unsigned uid_t. - -Sat Oct 17 11:00:30 1992 Ian Lance Taylor (ian@airs.com) - - * conf.h.in, configure.in, uucp.h, unix/serial.c - (fsserial_lockfile), lib/MANIFEST: eliminated strlwr. - -Fri Oct 16 01:10:56 1992 Ian Lance Taylor (ian@airs.com) - - * Igor V. Semenyuk: uuchk.c (ukshow): print max-remote-debug - correctly. - lib/debug.c (idebug_parse): accept DEBUG_NONE. - -Thu Oct 15 00:49:58 1992 Ian Lance Taylor (ian@airs.com) - - * unix/cusub.c (fsysdep_terminal_puts): don't modify zalc before - freeing it up. - - * protg.c (fgcheck_errors, fggot_ack, fgprocess_data): Mark E. - Mallett: better handling of error decay. - -Wed Oct 14 22:09:20 1992 Ian Lance Taylor (ian@airs.com) - - * unix/lock.c: Tomi Vainio: make sure SEEK_SET is defined. - - * tcp.c (ftcp_dial): print a better error message if gethostbyname - doesn't set errno. - - * Stephen J. Walick: configure.in, conf.h.in: check for - <sys/types.tcp.h>. - tcp.c, unix/opensr.c: include <sys/types.tcp.h> if available. - lib/debug.c, unix/portnm.c, uuconf/int.c, uuconf/llocnm.c, - uuconf/time.c: cast more arguments to eliminate more warnings. - -Tue Oct 13 00:25:03 1992 Ian Lance Taylor (ian@airs.com) - - * prot.h, proti.c (fistart, fijstart), protj.c, uucico.c, tstuu.c - (uprepare_test), Makefile.in, MANIFEST: added 'j' protocol. - -Sun Oct 11 23:45:20 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, unix/serial.c (fsserial_set): added HAVE_STRIP_BUG to - policy.h to get around stupid Ultrix bug. - - * sysh.unx, unix/cusub.c, unix/serial.c (fsserial_open): for - HAVE_BSD_TTY, keep tchars and ltchars in the sterminal structure, - and in fsserial_open disable all interrupt characters. - -Sat Oct 10 01:18:31 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/tinit.c (itunknown): Gert Doering: don't save "unknown" - with the other arguments. - -Fri Oct 9 00:56:43 1992 Ian Lance Taylor (ian@airs.com) - - * unix/lock.c: check for running process before doing kill. - -Thu Oct 8 00:20:12 1992 Ian Lance Taylor (ian@airs.com) - - * chat.c, protf.c, send.c, rec.c, unix/locfil.c: Stephen J. - Walick: cast arguments to strtol and strcspn to avoid warnings. - - * uustat.c (fsnotify): Marc Boucher: don't free string from - uuconf_localname, and only prepend remote system name to execution - requests, not to local UUCP commands. - - * unix/lock.c (fsdo_lock): Marc Boucher: set fret to TRUE before - going around the loop again. - - * uucico.c: Marc Boucher: use 'a' protocol before 'g'. - - * unix/spool.c (zsfind_file): Matthias Zepf: fixed typos for - SPOOLDIR_BSD*. - -Wed Oct 7 00:03:08 1992 Ian Lance Taylor (ian@airs.com) - - * uuname.c (main): Marc Boucher: reverse sense of -a, and do not - display aliases by default. - - * uucico.c (fdo_call): Marc Boucher: some systems only provide 14 - characters in the Shere line. - - * tstuu.c (main): Marc Boucher: add support for STREAMS ptys. - -Tue Oct 6 23:16:15 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h: Marc Boucher: improve comments to describe SVR4. - - * chat.c (fcsend, fcecho_send, fcecho_send_strip, - fcecho_send_nostrip): Marc Boucher: don't send CR after BREAK or - EOT, and let chat-seven-bit apply to echo checking. - - * uuname.c (main): Andreas Vogel: usysdep_exit (TRUE) rather than - usysdep_exit (EXIT_SUCCESS). - -Mon Oct 5 22:59:51 1992 Ian Lance Taylor (ian@airs.com) - - * sysh.unx, unix/serial.c (fsserial_init): Marc Boucher: avoid - freeing unallocated string. - - * unix/serial.c (fsmodem_carrier): Peter Wemm: eliminated useless - undeclared variable which only appeared if HAVE_CLOCAL_BUG. - - * cu.c (main): don't require carrier when opening a direct line. - (fcudo_cmd, fcudo_subcmd, uculist_fns, icuunrecogfn): T. William - Wells: give reasonable error messages. - -Sun Oct 4 00:03:10 1992 Ian Lance Taylor (ian@airs.com) - - * */Makefile.in: T. William Wells: use ar qc rather than ar rc. - - * many: T. William Wells: renamed isysdep_* functions to - ixsysdep_*, and renamed isfork, isspawn, and isswait similarly, to - avoid ANSI C namespace restrictions. - - * uucp.h: T. William Wells: default size_t to unsigned, not int. - - * configure.in: T. William Wells: new definition for - AC_RETSIGTYPE. - - * configure.in: T. William Wells: test for sh builtin echo. - conf.h.in: default ECHO_PROGRAM to undefined. - - * proti.c (fiprocess_data, fiprocess_packet): fix confusion - between iIremote_winsize and iIrequest_winsize. - - * proti.c (fiwindow_wait, fisenddata): wait for a window opening - before sending SPOS. - - * proti.c (fiprocess_data): don't send a NAK for a duplicate of - the most recent packet. - - * configure.in: Stephen J. Walick: don't use AC_PREFIX, check for - /usr/bin/mail. - - * system.h, sysh.unx, send.c (flocal_send_file_init, - fsend_exec_file_init), rec.c (flocal_rec_file_init, - fremote_send_file_init, frec_file_end), xcmd.c - (fremote_xcmd_init), uuxqt.c (uqdo_xqt_file, uqcleanup), uux.c - (main, uxadd_send_file), uucp.c (main, uccopy), uustat.c - (fsworkfile_show, fsexecutions, fsnotify), unix/filnam.c - (zsfile_name, zsysdep_data_file_name, zsysdep_xqt_file_name), - unix/jobid.c (zsfile_to_jobid, zsjobid_to_file), unix/splcmd.c - (zsysdep_spool_commands), unix/splnam.c (zsysdep_spool_file_name), - spool.c (zsfind_file), statsb.c (fskill_or_rejuv, - isysdep_work_time), work.c (fswork_file, fsysdep_get_work, - zsysdep_jobid, bsgrade): Marc Unangst, Brian Murrell: Corrected - support for SPOOLDIR_SVR4, since SVR4 doesn't use grades in file - names. Changed flocal argument to pseq argument in - zsysdep_spool_file_name, and changed flocal argument to bgrade - argument in zfind_file. Added fxqt argument to - zsysdep_data_file_name. Added bsgrade function. Added bgrade - argument to zsfile_to_jobid, and pbgrade argument to - zsjobid_to_file. - -Sat Oct 3 11:03:13 1992 Ian Lance Taylor (ian@airs.com) - - * MANIFEST, Makefile.in, lib/MANIFEST, lib/Makefile.in, - lib/parse.c: moved parse.c from main directory to lib. - - * system.h, unix/size.c, unix/Makefile.in, unix/MANIFEST: moved - csysdep_size into its own file, made it return -1 if the file does - not exist or -2 on other errors. - uustat.c (fsworkfile_show): handle errors from csysdep_size. - send.c (flocal_send_file_init): handle errors from csysdep_size, - removed unneeded calls to fsysdep_file_exists. - - * trans.c (flocal_poll_file), tcp.c (ftcp_dial): Bob Cunningham: - declare functions consistently static. - - * Makefile.in: Marc Unangst: don't run config.status - unnecessarily. - - * configure.in: Marc Unangst: check for socket and t_open in - -lsocket, -lnsl and -lxti. - - * uuconf/cmdarg.c: check first character to avoid calls to - strcmp or strcasecmp. - -Thu Oct 1 23:44:24 1992 Ian Lance Taylor (ian@airs.com) - - * trans.h, uucico.c (fdo_call, faccept_call), parse.c - (fparse_cmd), send.c (flocal_send_request): Gert Doering: SVR4 - UUCP uses a dummy string between the notify field and the size, - for some reason. - - * tstuu.c (main, uprepare_test): added -n switch to not destroy - existing configuration files. - -Fri Sep 25 00:16:35 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgsenddata): T. William Wells: clear bytes correctly so - that resending a packet doesn't get a completely incorrect size. - - * send.c (usadd_exec_line): Stephen J. Walick: don't send trailing - spaces on the created execute file, because it confuses Waffle. - -Thu Sep 24 00:25:18 1992 Ian Lance Taylor (ian@airs.com) - - * unix/jobid.c (zsjobid_to_file): Franc,ois Pinard: if the job ID - is too short, return NULL rather than dumping core. - unix/statsb.c (fskill_or_rejuv, isysdep_work_time): handle a NULL - return from zsjobid_to_file. - -Mon Sep 21 09:01:02 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/init.c, uuconf/syssub.c: Lele Gaifax: moved - declaration of _uuconf_unset from syssub.c to addstr.c because - NeXT linker does not pull in object files solely because of - variable declarations. - - * sysh.unx: Lele Gaifax: typo in ftw declaration. - - * lib/Makefile.in, unix/Makefile.in: Lele Gaifax: bug in clean - target. - -Thu Sep 17 01:01:13 1992 Ian Lance Taylor (ian@airs.com) - - * Released beta version 1.04. - -Wed Sep 16 01:02:55 1992 Ian Lance Taylor (ian@airs.com) - - * uux.c (main): null terminate the options list for an 'E' - command. - - * ustat.c (fsexecutions): allow privileged users to kill remote - execution files, and handle local executions correctly. - - * uuconf/hinit.c: added parens to avoid warning. - - * unix/splcmd.c: cast to avoid warning. - - * unix/serial.c (fsmodem_close): fixed HAVE_SYSV_TERMIO typo. - - * trans.c (uqueue_receive, floop, fgot_data): improved timing code - to make fewer system calls. - - * send.c (fsend_exec_file_init, fsend_exec_file): handle separate - E file correctly, and make a good statistics file entry for it. - - * Makefile.in, unix/Makefile.in, uuconf/Makefile.in, - lib/Makefile.in: use -I flags to permit compilation in a separate - directory. Set up clean targets per GNU standards. - -Tue Sep 15 00:07:09 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (zget_uucp_cmd): can't set size_t variable to -1. - - * Makefile.in (install): don't install info files. Added new - targets info and install-info. - -Mon Sep 14 13:19:42 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (main): Gregory Bond: canonicalize the system name given - by the -s argument. - - * system.h, uuconf.h, uucico.c (faccept_call), unix/unknwn.c, - unix/Makefile.in, unix/MANIFEST, uuconf/syshdr.unx, - uuconf/remunk.c, uuconf/hrmunk.c, uuconf/Makefile.in, - uuconf/MANIFEST: support HDB remote.unknown shell script. - - * protg.c (igchecksum, igchecksum2): Inspired by Mark Pizzolato, - put in new, improved checksum routines. - - * uuxqt.c (uqdo_xqt_file): make sure the execution file still - exists after locking it. - - * unix/lock.c (fsdo_lock): don't fail if the lock file is removed - between the link and the open. - - * unix/xqtsub.c (fsysdep_execute, fsysdep_lock_uuxqt_dir, - fsysdep_unlock_uuxqt_dir, fsysdep_move_uuxqt_files): use .Xqtdir - for first uuxqt execution, not .Xqtdir0000. - -Sun Sep 13 11:51:22 1992 Ian Lance Taylor (ian@airs.com) - - * trans.h, uucico.c (fdo_call, faccept_call), send.c - (flocal_send_request), rec.c (flocal_rec_send_request) parse.c - (fparse_cmd): send file size in hex for SVR4 compatibility. - Required new FEATURE_V103 for 1.03 backward compatibility, since - 1.03 requires decimal size. - - * various: eliminated remaining calls to alloca. - - * tcp.c (ftcp_open), tli.c (ftli_open): set FD_CLOEXEC for sockets - and TLI descriptors. - - * tcp.c (ftcp_open): switch to real user ID before binding the - socket when running as a server. This will permit uucico invoked - by root to open privileged TCP ports. Don't switch to real ID if - effective ID is already root, to permit an suid root program to be - invoked by anybody. - - * uuxqt.c (uqdo_xqt_file): removed special case for system which - does not permit any commands: unnecessary and unusual. - - * uucico.c (fconn_call): Ed Carp: clear the SIGHUP signal - indication before opening the modem. - - * trans.h, trans.c (fqueue, fcheck_queue, floop, fgot_data), - send.c (fsend_await_confirm), rec.c (frec_file_send_confirm), - uucico.c (fcall, faccept_call): recheck the work queue every 10 - minutes. Honor CYM from the remote system. Send CYM if we have - something to do. - -Sat Sep 12 15:47:52 1992 Ian Lance Taylor (ian@airs.com) - - * Makefile.in: use $(MAKE) instead of make for recursive calls. - - * system.h, uucp.c (main), uux.c (main), unix/ufopen.c, - unix/MANIFEST, unix/Makefile.in: added esysdep_user_open to open a - file with user permissions. - -Fri Sep 11 00:27:32 1992 Ian Lance Taylor (ian@airs.com) - - * uudefs.h, copy.c: added fcopy_open_file. - - * policy.h: added HAVE_SAVED_SETUID. - - * configure.in, conf.h.in: check for setreuid. - -Tue Sep 8 00:11:10 1992 Ian Lance Taylor (ian@airs.com) - - * protf.c (ffsendcmd), prott.c (ftsendcmd): eliminate calls to - alloca. - - * uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c (main), - uustat.c (main), uuchk.c (main), uuconv.c (main), uuname.c (main), - uulog.c (main), uupick.c (main), cu.c (main), lib/getop1.c, - lib/Makefile.in, lib/MANIFEST: added getopt_long, and changed all - calls to getopt to call getopt_long instead. - -Mon Sep 7 22:26:51 1992 Ian Lance Taylor (ian@airs.com) - - * getopt.h, lib/getopt.c, lib/Makefile.in: bring getopt up to - glibc 1.04; call malloc instead of alloca in exchange. - - * system.h, uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c - (main), uustat.c (main), cu.c (main), uuname.c (main), unix/init.c - (usysdep_initialize): added INIT_SUID, for old systems which don't - do setuid correctly for root. - - * cu.c, unix/cusub.c: various minor improvements. - -Sun Sep 6 20:25:20 1992 Ian Lance Taylor (ian@airs.com) - - * uux.c (uxcopy_stdin): use getchar rather than fread to avoid - SVR4 bug. - - * uucico.c (fsend_uucp_cmd): Niels Baggesen: report message when - DEBUG_HANDSHAKE. - - * protg.c (fgsend_control): Niels Baggesen: report sending an RJ - when DEBUG_ABNORMAL. - -Tue Aug 25 00:07:20 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/time.c: Zacharias Beckman: let user defined time tables - override the defaults. - -Mon Aug 24 00:25:23 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uuxqt.c (uqdo_xqt_file), unix/xqtsub.c - (zsysdep_xqt_local_file): Jarmo Raiha: expand ~name in uuxqt.c. - - * send.c (fremote_rec_reply): SVR4 sends the size of the file with - the RY string, so we do too. We don't look for it, though. - - * uustat.c, uustat.1: Don Phillips: removed all printing of years - and seconds. Hope nobody complains. - - * uucico.c (fdo_call): don't set the status to TALKING until we - see the Shere string. - - * configure.in, conf.h.in, unix/wldcrd.c: if the system has glob, - use it for wildcards. If it doesn't, quote special characters in - the wildcard string. - - * uucico.c (fdo_call): Zacharias Beckman: don't report ``Login - successful'' until we see the Shere string. - - * prot.c (fsend_data): Don Lewis: bug in crec calculation. - - * uustat.c (fsworkfile_show, usworkfile_header, fsnotify): Don - Lewis: show poll files. - - * unix/init.c: check LOGNAME and USER environment variables before - invoking getlogin. - - * unix/serial.c: Brian Campbell: check for B57600, B76800 and - B115200 in baud rate table. - -Sun Aug 23 13:05:28 1992 Ian Lance Taylor (ian@airs.com) - - * chat.c (fcsend), tstuu.c (uchild): Chip Salzenberg: call sleep - (2) instead of sleep (1). Hopefully this won't break any chat - scripts. - - * system.h, parse.c, trans.c (fqueue, flocal_poll_file), uustat.c - (fsworkfiles_system, fsquery_system), unix/work.c - (fsysdep_get_work, fsysdep_get_work_init): don't delete poll files - immediately, but instead return a 'P' command and delete them when - the command is passed to fsysdep_did_work. - - * tstuu.c (uprepare_test): change ``call-request'' to ``request''. - - * uuconf/iniglb.c (_uuconf_itimetable): return CMDTABRET_KEEP so - we don't lose the timetable name and definition. - - * uuconf.h, send.c (fremote_rec_file_init), rec.c - (fremote_send_file_init), uuchk.c (ukshow), uuconv.c - (uvwrite_taylor_system, uvwrite_hdb_system), uuconf/tsinfo.c - (iirequest), uuconf/hsinfo.c, uuconf/hunk.c, uuconf/syssub.c: - added ``send-request'' and ``receive-request'' commands, - eliminated ``call-request'' and ``called-request'' commands. - - * uux.c (main): make sure we are permitted to transfer files - before queuing requests. - - * uuconf.h, uucico.c (fcall), uuconf/tsinfo.c, uuconf/syssub.c: - David Nugent: added ``success-wait'' command for systems, to set a - minimum time between successful calls. - - * send.c (fremote_rec_file_init): Don Phillips: let a request only - specify the file base name in the TO argument. - - * uucico.c (main): Don Lewis: don't exit with success just because - we were able to start uuxqt. - - * unix/serial.c (fsmodem_close, fsserial_read): always drop DTR - when closing a modem connection. Also, retry if we time out when - setting MIN. - -Sat Aug 22 22:31:34 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/time.c: Stephen Walick: don't require a comma between - time strings, since HDB doesn't seem to. - - * protg.c (fgcheck_errors): added "error-decay" protocol parameter - to decay errors as packets are successfully received. - - * uustat.c (fsmachines), uustat.1: Chris Lewis: don't display the - year or seconds for uustat -m. Probably uustat -q should be - changed as well. - - * tstuu.c: Larry Fahnoe: don't report EWOULDBLOCK errors when - writing to a pty. Also removed functions which are now in lib. - - * MANIFEST, Makefile.in, uusched.in: added a simple uusched shell - script. - - * parse.c: Heiko Rupp: don't die if there is trailing garbage in - an 'R' command. - - * policy.h, system.h, sysh.unx, send.c, rec.c, uuxqt.c, uux.c, - unix/filnam.c, unix/init.c, unix/jobid.c, unix/splnam.c, - unix/spool.c, unix/statsb.c, unix/tmpfil.c, unix/work.c, - unix/xqtfil.c: Brian J. Murrell and Don Phillips: added - SPOOLDIR_SVR4. - -Thu Aug 20 00:06:32 1992 Ian Lance Taylor (ian@airs.com) - - * sysh.unx: Chiaki Ishikawa: some systems define some but not all - of the S_ file mode bits. - - * uuchk.c (ikshow_port): Chiaki Ishikawa: display lockname. - -Wed Aug 19 22:41:39 1992 Ian Lance Taylor (ian@airs.com) - - * log.c (ustats): Scott Blachowicz: avoid overflow when reporting - bytes per second. - - * unix/lock.c (fsdo_lock): Chip Salzenberg: sometimes other - programs create lock files that uucp can't write. - - * trans.h, system.h, trans.c (floop, fgot_data, usent_receive_ack, - uwindow_acked), send.c (flocal_send_await_reply, - flocal_send_fail), rec.c (fremote_send_fail_send, - frec_file_send_confirm), prote.c, protf.c, protg.c, proti.c, - prott.c, protz.c (calls to fgot_data), unix/recep.c, - unix/MANIFEST, unix/Makefile.in: keep trace of whether we have - already received a file, in case the other side never sees our - ack. Added new SN8 rejection, meaning that the file has already - been received. - -Sat Aug 15 11:50:32 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf/time.c (itadd_span): Don Lewis: fixed bug if later span - overlapped two or more earlier spans. - -Thu Aug 13 00:19:50 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, rec.c (fremote_send_file_init, fremote_send_reply), - uucico.c (fdo_call, faccept_call), uucp.c (main), uux.c (main), - unix/opensr.c (zsysdep_receive_temp, esysdep_open_receive): - implemented file restart. - -Wed Aug 12 23:32:05 1992 Ian Lance Taylor (ian@airs.com) - - * proti.c (fiprocess_data): ensure that the first argument to - fgot_data is always > 0 if the second argument is > 0. - -Mon Aug 10 22:43:40 1992 Ian Lance Taylor (ian@airs.com) - - * trans.c (floop, ustats_failed): handle half-duplex connections - and failed calls correctly. - -Sun Aug 9 17:56:32 1992 Ian Lance Taylor (ian@airs.com) - - * proti.c (firesend, fisenddata, ficheck_errors): made several - changes to improve performance on a lossy line: can now shrink - packet size using SYNC packets, avoids multiple bad header errors - in a sequence of INTRO characters, avoids letting one side lock up - if a NAK is lost. - - * configure.in: set HAVE_LONG_FILE_NAMES to 0 if - cross-configuring. - - * tstuu.c: changed -p option to be mod 1000, not mod 100. - - * MANIFEST, Makefile.in, prot.h, uucico.c, protz.c, trans.c: Doug - Evans: added Doug Evans's zmodem implementation as protocol 'a'. - -Wed Aug 5 22:28:14 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, uuconf.h, uucico.c (fcall), uuconf/tsinfo.c, - uuconf/hsinfo.c, uuconf/syssub.c: added "max-retries" command for - systems, eliminated CMAXRETRIES configuration parameter, set - max_retries to 0 for HDB if retry time given, (from Chris Lewis) - call once a day even if max_retries has been exceeded. - - * prot.h, uucico.c (fdo_call, faccept_call), prott.c, prote.c, - proti.c, protg.c, protf.c: added pzlog argument to pfstart - protocol entry point, changed handshake successful message to - display it. - -Tue Aug 4 00:04:31 1992 Ian Lance Taylor (ian@airs.com) - - * prot.h, uucico.c, protg.c (fbiggstart, cGshort_packets): Chip - Salzenberg: added support for 'G' protocol. Added "short-packets" - protocol parameter for 'g' and 'G' protocols. - - * uuconf.h, rec.c (flocal_rec_file_init), uucp.c, uux.c, uuxqt.c, - uuchk.c, uuconv.c, uuconf/local.c, uuconf/tsinfo.c, - uuconf/syssub.c: support UUCP forwarding. Added "forward-from", - "forward-to", and "forward" commands for systems. - - * unix/spawn.c: don't close the file descriptor after dupping it. - -Sun Aug 2 23:04:18 1992 Ian Lance Taylor (ian@airs.com) - - * trans.c (fremote_hangup_reply): don't hangup if a file transfer - is in progress. - - * send.c (flocal_send_cancelled): don't pass a NULL buffer to - pfsenddata. - -Sun Jul 26 13:28:27 1992 Ian Lance Taylor (ian@airs.com) - - * unix/work.c (fsysdep_get_work_init): return TRUE if there is no - work directory. - - * configure.in, sysh.unx: don't run any programs in configure if - we are cross-configuring; this applies to HAVE_FTIME and - HAVE_RESTARTABLE_SYSCALLS. The code can cope with the buggy - ftime. If we are cross-configuring, HAVE_RESTARTABLE_SYSCALLS is - set to -1, and sysh.unx guesses that if the system has sigvec but - not sigaction or SV_INTERRUPT it is on 4.2BSD and system calls are - automatically restarted. - - * configure.in, conf.h.in, tstuu.c, unix/serial.c: removed - COMBINED_UNBLOCK configuration parameter, and changed the code - which sets O_NONBLOCK and O_NDELAY to drop back to using just - O_NONBLOCK if it gets an EINVAL error. - - * configure.in, conf.h.in, uucp.h, protg.c (fgsenddata), cu.c - (icutake), chat.c (icexpect), lib/MANIFEST: removed all calls to - memmove, avoiding the SCO bug and making the 'g' protocol slightly - more efficient. - -Sat Jul 25 14:20:30 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h, uudefs.h, many other files: broke part of uucp.h out - into uudefs.h, stopped including uuconf.h in uucp.h, fixed up .c - files to include uudefs.h and uuconf.h as necessary. - - * uuconf/syshdr.unx, uuconf/callin.c, uuconf/diacod.c - uuconf/hdial.c, uuconf/hdnams.c, uuconf/hport.c, uuconf/hsinfo.c, - uuconf/hsnams.c uuconf/rdlocs.c, uuconf/tcalou.c, uuconf/tdial.c, - uuconf/tdnams.c, uuconf/tport.c, uuconf/vport.c, uuconf/vsinfo.c, - uuconf/vsnams.c: changed uuconf library to not return an error if - a configuration file does not exist; it now acts as though - whatever it is is not found. - - * tstuu.c (main): use perror if execl fails. - - * configure.in, conf.h.in, uucp.h, uuconf.h, sysh.unx, conn.h, - MANIFEST, Makefile.in, tli.c, chat.c (ccescape), conn.c - (fconn_init), tcp.c, uucico.c (faccept_call), uuconv.c, uuchk.c, - lib/MANIFEST, lib/Makefile.in, lib/escape.c, unix/cusub.c, - unix/serial.c, uuconf/hport.c, uuconf/tportc.c: added support for - TLI connections. Moved ccescape from chat.c to cescape in - lib/escape.c. Made all connections on Unix use the same - system dependent structure. - -Tue Jul 21 22:08:10 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h, trans.h, uucico.c (fdo_call, faccept_call), uuxqt.c - (uqdo_xqt_file), uucp.c (main), uux.c (main), uustat.c - (fsworkfile_show), parse.c (fparse_cmd), trans.c (fqueue, - fgot_data, ftadd_cmd), send.c, rec.c, xcmd.c, protf.c - (ffprocess_data), proti.c (fiprocess_data), tstuu.c - (uprepare_tests), unix/splcmd.c (zsysdep_spool_commands), - unix/statsb.c (fskill_or_rejuv), unix/work.c (fsysdep_get_work): - added E request to send file executions which only require reading - from standard input. - -Sat Jul 18 20:22:50 1992 Ian Lance Taylor (ian@airs.com) - - * proti.c, Makefile.in, MANIFEST, prot.h, system.h, trans.h, - uucico.c, prote.c, protf.c, protg.c, prott.c, trans.c, send.c, - rec.c, xcmd.c, unix/opensr.c: added 'i' protocol. Added local and - remote channel arguments to protocol sendcmd and senddata entry - points. Cleaned up send and receive state machines. Removed - pfgone argument from esysdep_open_send. - -Fri Jul 17 09:41:05 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (uqdo_xqt_file): only report base name of execution - file, not full name. - -Thu Jul 16 00:45:06 1992 Ian Lance Taylor (ian@airs.com) - - * lib/crc.c: unroll the loop a bit. - - * configure.in, conf.h.in, unix/init.c: updated to autoconf 0.120. - -Wed Jul 15 14:45:32 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconv.c, uuconf/uucnfi.h, uuconf/reliab.c, - uuconf/tportc.c, uuconf/tdialc.c, uuconf/diasub.c, uuconf/hport.c, - uuconf/prtsub.c, uuconf/vsinfo.c: added UUCONF_RELIABLE_FULLDUPLEX - and "half-duplex" command for ports and dialers. - -Mon Jul 13 16:53:04 1992 Ian Lance Taylor (ian@airs.com) - - * prot.h, lib/crc.c, lib/Makefile.in, lib/MANIFEST: added icrc - function to compute 32 bit CRC (from Gary S. Brown, via Doug - Evans). - -Sun Jul 12 21:40:15 1992 Ian Lance Taylor (ian@airs.com) - - * uuconv.c (uvwrite_time): Chris Lewis: don't output two commas in - a row. - - * uuconv.c (uvwrite_taylor_system, uvwrite_taylor_port): Chris - Lewis: generate command "protocol", not "protocols". - -Sat Jul 11 17:09:09 1992 Ian Lance Taylor (ian@airs.com) - - * xcmd.c (fremote_xcmd_init): Chris Lewis: use qdaemon->puuconf, - since puuconf is not defined. - - * uuconf/syshdr.unx, uuconf/hinit.c (uuconf_hdb_init): Chris - Lewis: added HDB_SEPARATOR to insert between oldconfiglib and - strings in HDB Sysfiles. - - * uuconf/syshdr.unx: Chris Lewis: define strerror as a macro. - - * uuconf/freblk.c, uuconf/free.c: Chris Lewis: don't define as - void when ! UUCONF_ANSI_C. - -Thu Jul 9 09:17:55 1992 Ian Lance Taylor (ian@airs.com) - - * prot.h, uucico.c (fdo_call, faccept_call), prote.c (festart), - protf.c (ffstart), protg.c (fgstart), prott.c (ftstart): no need - to pass fmaster as a separate argument to protocol start routine. - - * protf.c (ffawait_ack, ffawait_cksum): don't try to resend if we - don't have a file. - -Wed Jul 8 14:28:23 1992 Ian Lance Taylor (ian@airs.com) - - * unix/srmdir.c (fsysdep_rmdir), unix/walk.c (usysdep_walk_tree): - cast to char * to avoid warning. - - * cu.c (main): don't compare boolean to NULL. - - * unix/serial.c (isblocksigs), unix/signal.c (usset_signal): use - extra parens to avoid bug in SCO 3.2.2 sys/signal.h header file. - - * sysh.unx: always define struct ssysdep_tcp, for the benefit of - systems for which HAVE_TCP is 0. - - * MANIFEST, Makefile.in, unix/Makefile.in, uuconf/Makefile.in, - lib/Makefile.in: updated automatic distribution code for multiple - directories. - - * unix/cusub.c, unix/serial.c: don't clobber CR when using TERMIO - or TERMIOS, and default MIN to 1 to the convenience of cu. - - * Makefile.in, uucp.h, system.h, prot.h, trans.h, uucico.c, - trans.c, send.c, rec.c, xcmd.c, prot.c, protg.c, protf.c, prote.c, - prott.c, log.c, file.c, unix/opensr.c, unix/work.c: rewrote file - transfer internals to support bidirectional transfers. Keep queue - of jobs to do, and support connections. Added new files trans.h, - trans.c, send.c, rec.c, xcmd.c, and removed old file file.c. - -Mon Jun 29 15:14:15 1992 Ian Lance Taylor (ian@airs.com) - - * Makefile.in: Stephen J. Walick: copy uustat.1 to - uustat.$(manext), not uucp.($manext). Also try to create - $(infodir). - - * chat.c (fcsend, fcprogram): check for NULL return from - uuconf_callout. - -Thu Jun 18 22:37:28 1992 Ian Lance Taylor (ian@airs.com) - - * configure.in, Makefile.in: updated to autoconf 0.118. - -Wed Jun 17 14:22:11 1992 Ian Lance Taylor (ian@airs.com) - - * unix/serial.c (fsserial_init): add /dev if necessary to device - as well as to port name. - - * cu.c (main): set zdevice to NULL when faking line. - - * cu.c (main), uucp.c (main), uux.c (main), uuxqt.c (main): don't - call zsysdep_localname until we've called usysdep_initialize. - -Tue Jun 16 17:42:50 1992 Ian Lance Taylor (ian@airs.com) - - * unix/signal.c (usset_signal): set SA_INTERRUPT to force system - calls to be interrupted on SunOS. - -Mon Jun 15 15:10:24 1992 Ian Lance Taylor (ian@airs.com) - - * everything: integrated uuconf library. Split out lib and unix - libraries. Made many changes, including defaults for port and - dialer files, better handling of changed local name, better - handling of HDB Permissions, new zbufalc routines to manage - strings on the heap. Incorporated uuconv. - -Wed Jun 10 23:51:03 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/Makefile.in, uuconf/locnm.c, uuconf/llocnm.c, - uuconf/hlocnm.c, uuconf/tlocnm.c: renamed uuconf_localname to - uuconf_login_localname and added new uuconf_localname which - doesn't need to read system information. - -Tue Jun 9 14:19:20 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/Makefile.in, uuconf/local.c: wrote - uuconf_system_local. - -Mon Jun 8 14:14:30 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h: changed description of LOCKDIR, which now need not - always be defined. - - * uuconf.h, uuconf/uucnfi.h, uuconf/lckdir.c, uuconf/iniglb.c, - uuconf/tinit.c, uuconf/Makefile.in: added uuconf_lockdir, and - ``lockdir'' command to config. - -Sat Jun 6 22:07:58 1992 Ian Lance Taylor (ian@airs.com) - - * configure.in: updated to autoconf 0.115, added code to set - LIBOBJS. - - * uuconf/Makefile.in, uuconf/uucnfi.h: removed references to - routines now in lib/, changed to include regular UUCP header - files. - -Fri Jun 5 15:31:29 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/uucnfi.h, uuconf/syssub.c, uuconf/uuconv.c: - always set zpubdir for every system, changed uuconf_zpubdir to - const char *. - -Wed Jun 3 15:15:32 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/Makefile.in, uuconf/deblev.c, uuconf/maxuxq.c, - uuconf/pubdir.c, uuconf/spool.c: wrote uuconf_debuglevel, - uuconf_maxuuxqts, uuconf_pubdir, uuconf_spooldir. - - * configure.in: updated to autoconf 0.114. - - * uuconf/tportc.c: default TCP ports to being fully reliable. - -Mon Jun 1 17:03:22 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/prtsub.c: removed uuconf_psysdep from - uuconf_port. - -Sun May 31 00:07:40 1992 Ian Lance Taylor (ian@airs.com) - - * uuconf.h, uuconf/Makefile.in, uuconf/diacod.c: wrote - uuconf_dialcode. - - * uuconf.h, uuconf/Makefile.in, uuconf/logfil.c, uuconf/debfil.c, - uuconf/stafil.c: wrote uuconf_logfile, uuconf_debugfile, - uuconf_statsfile. - - * uuconf.h, uuconf/Makefile.in, uuconf/callin.c: wrote - uuconf_callin. - - * uuconf/chatc.c, uuconf/time.c: Jean Mehat: only call tolower if - isupper is true. - - * uuconf.h, uuconf/Makefile.in, uuconf/val.c, uuconf/tval.c: wrote - uuconf_validate, uuconf_taylor_validate. - -Sat May 30 12:37:02 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, sys1.unx: changed zsysdep_local_name to - zsysdep_localname, and made it fatal out rather than return NULL. - - * uuconf.h, uuconf/Makefile.in, uuconf/uucnfi.h, uuconf/iniglb.c, - uuconf/rdlocs.c, uuconf/locnm.c, uuconf/tlocnm.c, uuconf/hlocnm.c: - wrote uuconf_localname, uuconf_taylor_localname, - uuconf_hdb_localname. - - * uuconf.h, uuconf/Makefile.in, uuconf/uucnfi.h, uuconf/iniglb.c, - uuconf/tinit.c, uuconf/tsinfo.c, uuconf/hunk.c, uuconf/unk.c: - wrote uuconf_system_unknown, uuconf_hdb_system_unknown, - uuconf_taylor_system_unknown. - - * log.c, time.c: always include <sys/types.h> in uucp.h. - - * configure.in, conf.h.in: check for size_t, renamed checks for - time_t. - - * configure.in, conf.h.in: check for <stddef.h>. - -Fri May 29 00:03:05 1992 Ian Lance Taylor (ian@airs.com) - - * sysinf.c (ztranslate_system): Jac Kersing: must xstrdup the - argument, since it points to a buffer that will be reused. - -Thu May 28 12:42:20 1992 Ian Lance Taylor (ian@airs.com) - - * sys3.unx (zsysdep_real_file_name): Ted Lindgreen: check return - value of zstilde_expand. - - * copy.c, sys1.unx (usysdep_detach), sys2.unx (fsserial_close), - sys3.unx, sys5.unx, sys7.unx: opening /dev/tty in usysdep_detach - confuses the NeXT, so instead we just call TIOCNOTTY on 0. In - fsserial_close we call TIOCNOTTY on the port before closing it, to - make sure that we have ditched it under BSD. Also added O_NOCTTY - to every open call other than opening a port, although there are - still several fopen calls which should probably have it somehow. - - * system.h, uucico.c (fcall), uustat.c (fsquery_system, - fsquery_show), sys3.unx (fsysdep_get_status), sys7.unx - (zsysdep_all_status): Bob Izenberg: changed output of uustat -q to - count number of commands rather than number of files being - transferred, and to not report a non-existent status. Added - pfnone argument to fsysdep_get_status, and changed all calls. - - * uucico.c, sys1.unx, sys2.unx, sys3.unx, sys5.unx, sys6.unx, - sys7.unx: Rolf Nerstheimer: cast a bunch of arguments to open, - creat, stat and chmod to avoid compiler warnings. - - * uucp.h, log.c (ulog), port.c (fport_close), prot.c (fgetcmd): - Chip Salzenberg: don't log a SIGHUP signal while we're closing - down the connection, since the other side might hang up faster - than we do (we still react to it correctly, we just don't put it - in the log file). - - * sys1.unx (usysdep_detach), tcp.c (ftcp_open): Petri Helenius: - update the process ID we log after a fork. - - * Makefile.in, sys1.unx: Chip Salzenberg: changed LIBDIR to - SBINDIR. - - * uucp.c (main, uccopy): Andreas Vogel: check local-receive of the - correct system, rather than always using sLocalsys. - - * configure.in, conf.h.in, sys2.unx, tstuu.c: Rob Janssen: look - for <sys/select.h>, and include it if it exists and we are using - select. - - * protg.c: Rob Janssen: rearrange macros to avoid bug in XENIX - compiler. - - * configure.in: Scott Blachowicz: check WIFEXITED before assuming - HAVE_UNION_WAIT, to avoid problems on HP/UX. - - * configure.in, conf.h.in, sysh.unx, sys1.unx: John Theus: use - sv_onstack instead of sv_flags in the sigvec structure on 4.2BSD. - -Wed May 27 23:23:39 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, sys2.unx (fsysdep_modem_no_carrier): Scott Reynolds: - added HAVE_CLOCAL_BUG compilation parameter to work around - problems on some serial ports. - -Tue May 26 15:50:17 1992 Ian Lance Taylor (ian@airs.com) - - * uustat.c, uustat.1: added a bunch of options to support uuclean: - -e, -i, -K, -M, -N, -W, -Q. - - * system.h, sys7.unx (fsysdep_privileged, fskill_or_rejuv): added - fsysdep_privileged function. - -Thu May 21 13:30:21 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (uqdo_xqt_file): processing of execution file has to be - case significant; this will change handling of "n" flag, which was - not correctly handled before. - -Wed May 20 14:22:12 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx (usysdep_detach): close the statistics file when - detaching. - - * policy.h, sys3.unx (fsdo_lock, fsdo_unlock), sys7.unx - (fsysdep_lock_status): force LOCKDIR to always be defined. - - * uucp.h: put in an extern for alloca. - - * sysh.unx, sys1.unx, sys5.unx, sys6.unx: defined all the ?_OK - macros in sysh.unx, which means that <unistd.h> must be included - before "sysdep.h" when they are both included. - - * sys2.unx (fsserial_set): corrected case in termio switch - expression. - - * chat.c (fcsend): simplified expression for old compilers. - - * sys1.unx (rmdir): wrote rmdir replacement which invokes - /bin/rmdir for old systems. - - * configure.in, conf.h.in, Makefile.in: updated for autoconf - 0.112, added checks for ftw, ftw.h, and rmdir. - - * sys1.unx: added extern for ctime, removed externs for functions - returning int, protected externs with ifndefs. - - * uucp.h, prot.h, system.h, uucico.c (fuucp), uuxqt.c - (uqdo_xqt_file), prot.c (freceive_file), file.c (freceived_file), - sys3.unx (fsysdep_move_file, fsysdep_change_mode), sys4.unx - (zsysdep_save_temp_file): changed fsysdep_move_file to not set the - file mode, and added fsysdep_change_mode to do it instead. - - * system.h, uucp.c (main, ucdirfile, uccopy), sys6.unx - (usysdep_walk_tree, isdir, ftw, do_ftw): added -R option to uucp - to recursively copy directories. - -Tue May 19 18:29:32 1992 Ian Lance Taylor (ian@airs.com) - - * sys3.unx: changed zsysdep_in_dir to always append the filename - to the directory, even if the directory did not already exist. - - * sysh.unx, sys1.unx, sys3.unx, sys4.unx, sys5.unx: renamed - fsdirectory_exists to fsysdep_directory. - -Mon May 18 14:49:35 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uucp.c (main), sys6.unx (zsysdep_uuto): added -t - option to uucp to emulate uuto, wrote zsysdep_uuto to do Unix - dependent destination translation for uuto, added -p option to - uucp as synonym for -C for uuto compatibility. - -Sun May 17 22:04:09 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgexchange_init): permit a second INITB to override the - segment size given in the first INITB. - -Tue May 5 16:03:22 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main, fdo_call), uucico.8: Chip Salzenberg: added -c - option to uucico to not warn if invoked when the system may not be - called. - -Tue Apr 28 15:05:01 1992 Ian Lance Taylor (ian@airs.com) - - * sysh.unx, sys2.unx (fsserial_open, fsblock): preserve file - status flags. - - * protg.c (fgwait_for_packet): Heiko Rupp: only send RJ packet if - there are no unacknowledged packets. - -Mon Apr 27 18:56:42 1992 Ian Lance Taylor (ian@airs.com) - - * system.h: added several routines for cu. - - * cu.c, cu.h, sys8.unx: checked into RCS. - - * uux.c (main): Jose Manas: dumb bug when checking against - calloc_args. - -Fri Apr 24 20:32:06 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx: changed HAVE_LONG_NAMES to HAVE_LONG_FILENAMES for new - version of autoconf. - - * sys7.unx: check UTIME_NULL_MISSING with #if rather than #ifdef. - - * sys3.unx: check FS_* macros with #if rather than #ifdef. - - * uucp.h, sysh.unx: changed standard type definitions for new - version of autoconf. - - * sysh.unx, sys1.unx, sys2.unx, tstuu.c: changed SIGtype to - RETSIGTYPE for new version of autoconf. - - * sys1.unx, tstuu.c: make include of <sys/times.h> optional. - - * sys2.unx: get the right versions of major and minor. - -Wed Apr 22 11:19:11 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgsenddata, fggot_ack): Michael Haberler: the slow - start after error code was essentially shrinking the window size. - - * sysh.unx, system.h, sys1.unx (usysdep_initialize), uuchk.c, - uucico.c, uucp.c, uulog.c, uuname.c, uustat.c, uux.c, uuxqt.c: - changed usysdep_initialize to take a single argument with bit - flags, added INIT_NOCHDIR as one of the flags. - - * uucp.h, log.c (ulog): added pfLstart and pfLend functions for - ulog, so that cu can use them to restore the terminal settings. - - * bnu.c (ubnu_read_systems, fbnu_read_dialer_info), v2.c - (uv2_read_systems): Michael Richardson: don't core dump if no chat - script. - -Tue Apr 21 00:19:47 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (faccept_call): Chris Lewis: a successful call in - should clear the number of retries. - - * sys2.unx (fsserial_set): set LLITOUT if going to CBREAK mode. - - * port.h, prote.c (festart), protf.c (ffstart), protg.c (fgstart), - prott.c (ftstart), port.c (fport_set), sys2.unx - (fsysdep_stdin_set, fsysdep_modem_set, fsysdep_direct_set, - fsserial_set): gave fport_set independent control over output - parity generation, input parity checking, and XON/XOFF - handshaking, all to support cu. - -Mon Apr 20 11:47:23 1992 Ian Lance Taylor (ian@airs.com) - - * port.h, uucico.c (fdo_call), port.c (fport_dial, fmodem_dial), - tcp.c (ftcp_dial): added separate zphone argument to fport_dial to - support cu. - -Thu Apr 16 01:15:42 1992 Ian Lance Taylor (ian@airs.com) - - * bnu.c (ubadd_perm, ubadd_perm_alternate): Chris Lewis: handle a - combination of Permissions entries which specify just LOGNAME with - entries that specify both MACHINE and LOGNAME. - -Wed Apr 15 16:11:48 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx (usysdep_initialize, zsysdep_login_name): John Theus: - don't die if can't get login name, unless it's really needed. - -Tue Apr 14 12:39:18 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main, fcall): Petri Helenius: must relock system after - detaching from terminal when trying different alternates. - - * system.h, uucico.c (fuucp), uustat.c (fsworkfiles_system, - fsquery_system), sys4.unx (fsysdep_get_work_init, - fsysdep_get_work): Marty Shannon: uustat would remove empty - command files. - - * bnu.c (ubadd_perm_alternate): John Harkin: permit ALIAS in - Permissions. - - * Makefile.in: John Harkin: add sys?.c dependencies to sys?.o to - work around old makes which don't handle transitive .SUFFIXES. - - * sys2.unx: cast some function calls to void. - - * time.c (qttime_parse): cast to void warning. - - * sys1.unx (iswait): cast waitpid argument to avoid warning. - - * configure.in, policy.h, uucp.h, sys7.unx, tstuu.c: Zacharias - Beckman: minor touchups for NeXT. - - * sys1.unx (usysdep_initialize), sys6.unx (zsysdep_add_cwd), uux.c - (main): Jarmo Raiha: heuristic for whether to get the current - directory can fail. - - * sys1.unx: pass argument to uudir, cast sigemptyset calls to - void. - - * uucp.texi: Harlan Stenn: correct case of references. - -Tue Apr 7 01:02:17 1992 Ian Lance Taylor (ian@airs.com) - - * Released version 1.03. - -Mon Apr 6 15:49:08 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (faccept_call): Marc Boucher: set *pqsys to NULL. - - * bnu.c (ubnu_read_systems, fbnu_find_port): Erik Forsberg: - support multiple character modem classes. - -Fri Apr 3 00:37:25 1992 Ian Lance Taylor (ian@airs.com) - - * sys2.unx: Petri Helenius: only clear known bits in termio or - termios structure; didn't change HAVE_BSD_TTY handling--maybe next - version. - - * configure.in: test TIMES_DECLARATION_OK correctly. - - * Makefile.in: update version to 1.03, remove distclean, add - mostlyclean per GNU standards. - - * sys1.unx, chat.c: minor cleanups for gcc 2.1. - -Thu Apr 2 17:51:36 1992 Ian Lance Taylor (ian@airs.com) - - * tstuu.c: conditionally declare times. - - * uucp.h, prot.c, sysinf.c, prtinf.c: added gcc 2.0 format - checking to ulog, and fixed a few problems it discovered. - -Wed Apr 1 16:21:08 1992 Ian Lance Taylor (ian@airs.com) - - * sys3.unx (esysdep_open_receive): David J. MacKenzie: some - USG_STATFS systems use 512 as the block size of f_bfree, despite - the existence of f_bsize. - - * port.c (fport_open): initialize stdin port. - - * policy.h, log.c: added CLOSE_LOGFILES configuration parameter. - - * sys2.unx: T. William Wells: handle a system without <poll.h> or - <stropts.h>. - - * configure.in: Franc,ois Pinard: warn if none of napms, nap, - usleep, poll or select are available, since \p will sleep for a - full second. - - * Makefile.in: Gerben Wierda: fixed uninstall to set file owner - and mode correctly. Also changed install to handle uucp.info-4 - and uustat.1. - - * MANIFEST: added uucp.info-4 and uustat.1. - - * uustat.1: Wrote. - - * uucico.8, uuxqt.8, uucp.1, uux.1: updated -x switch, cleaned up - a bit. - -Tue Mar 31 14:40:06 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx (usysdep_initialize): use $PWD to get the current - working directory if it's defined and correct. - - * sys1.unx (usysdep_initialize): Brian Antoine: use name from - getpwname rather than getlogin. - - * uucp.texi: David J. MacKenzie: put in a number of corrections. - Also split sys file and config file nodes, and rearranged several - nodes. - - * protg.c (fgsenddata): Niels Baggesen: packet to retransmit did - not get reset correctly. - -Mon Mar 30 10:03:28 1992 Ian Lance Taylor (ian@airs.com) - - * tcp.c (ftcp_reset): Petri Helenius: TCP server never started - uuxqt, because it exited in ftcp_reset. - - * policy.h, sysh.unx, sys2.unx (fsserial_lockfile): added - HAVE_SVR4_LOCKFILES configuration parameter. - - * sys3.unx (esysdep_open_receive): Niels Baggesen: USG statfs has - an f_bsize field. - -Sun Mar 29 23:04:20 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h, sysinf.c, prot.c, prote.c, protf.c, protg.c, prott.c: - Niels Baggesen: added new debugging types abnormal and uucp-proto. - - * uucico.c (fuucp), prot.c (freceive_file), file.c - (fstore_recfile): Dirk Musstopf: if a file receive fails before it - starts, perhaps because the file was too large, remember to remove - the temporary file. - - * sys2.unx (fsserial_lock, fsserial_open, fsserial_write, - fsserial_io): always block and unblock the read and write - descriptors together. - -Sat Mar 28 14:40:50 1992 Ian Lance Taylor (ian@airs.com) - - * uustat.c: allow multiple systems and users to be specified at - once; likewise for kills and rejuvenates. Allow old and young to - be combined with systems and users. As suggested by Niels - Baggesen, make machine status output more columnar. - - * uucp.h, uucico.c, config.c, sys3.unx: Michael I Bushnell: - renamed enum tstatus to tstatus_type to avoid conflict with - <sys/ioctl.h> on some systems. - - * config.c, sysinf.c, prtinf.c, chat.c: David J. MacKenzie: allow - backslash newline quoting in all TAYLOR_CONFIG configuration - files. - - * chat.c (fchat): David J. MacKenzie: handle empty subexpect - strings correctly. - - * uucico.c (main, fcall): Petri Helenius: must dump controlling - terminal before going to next alternate. Also fixed David J. - MacKenzie bug in which a signal did not prevent the next - alternates from being tried. Also made sure qtime was always - freed up. - - * uucp.h, uucico.c (fdo_call), sysinf.c (tialternate), uuchk.c - (ukshow): Franc,ois Pinard: allow a name to be given to an - alternate, and display the name when placing a call. - - * chat.c (fcprogram), port.c (fport_open, fport_close): David J. - MacKenzie: send port device rather than port name to a chat - program using \Y; make sure port device is reset if port open - fails and when port is closed. - - * uucico.c (fuucp), log.c (ulog, ustats, ustats_close): close log - and statistics file every time master and slave switch roles. - -Fri Mar 27 00:31:23 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call): Mark Mallett: minor cleanup. - - * uuname.c (main): Franc,ois Pinard: output aliases, added -a - switch. - - * uucico.8, uuxqt.8, uux.1, uucp.1: David J. MacKenzie: changed - .TP5 to .TP 5; also updated to 1.03. - - * tstuu.c: Roberto Biancardi: if SIGCHLD is not defined, define it - as SIGCLD. - - * config.c: David J. MacKenzie: cMaxuuxqts is independent of - HAVE_TAYLOR_CONFIG. - - * uucp.h: Gerben Wierda: don't always declare bzero. - - * sys7.unx (ussettime, fsysdep_lock_status): Niels Baggesen, - Gerben Wierda: minor patches. - - * sys2.unx: Gerben Wierda: minor cleanups. - - * uucp.h: Niels Baggesen: simplified debugging message macros to - avoid broken compilers. - - * sys2.unx: don't use TIOCEXCL locking. - - * sys2.unx: rework HAVE_UNBLOCKED_WRITES == 0 to work even if - writes are unblocked. Correct initialization of fwrite_blocking. - - * Makefile.in, configure.in: David J. MacKenzie: various cleanups. - Changed default newconfigdir definition. Supported compilation in - a different directory. Used symbolic links if available. Changed - default infodir definition per Franc,ois Pinard. - - * policy.h: David J. MacKenzie: various cleanups. - -Thu Mar 26 12:17:41 1992 Ian Lance Taylor (ian@airs.com) - - * sys3.unx: reduced race condition in fsdo_lock. - - * sys1.unx: Gerben Wierda: various cleanups. Also don't set - sa_flags to SV_INTERRUPT per Chip Salzenberg. - -Wed Mar 25 22:20:24 1992 Ian Lance Taylor (ian@airs.com) - - * configure.in: Overhauled for readability and functionality as - suggested by T. William Wells and others. Added bug checks, - including for SCO memmove and ftime. - -Tue Mar 24 12:18:56 1992 Ian Lance Taylor (ian@airs.com) - - * sysinf.c (uiread_systems): fixed handling of alternates in - file-wide defaults. - -Wed Mar 18 01:01:25 1992 Ian Lance Taylor (ian@airs.com) - - * config.c (tprocess_one_cmd): handle CMDTABTYPE_FULLSTRING - correctly if there are no arguments. - - * Released beta version 1.03 - - * sys1.unx (usysdep_detach): open the controlling terminal in non - delay mode since it might be a modem. - -Tue Mar 17 00:01:53 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call, faccept_call): T. William Wells: set current - time in status file when call completes. - - * sys1.unx (iswait), sys2.unx (fsserial_read, fsserial_write, - fsserial_io): log signals when they occur, even if we continue - some sort of loop, rather than waiting for the next ulog call. - - * sys2.unx (fsserial_lock, fsserial_open): don't block when - opening the write descriptor. - -Mon Mar 16 00:14:43 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uuxqt.c (uqdo_xqt_file), sys5.unx (fsysdep_execute): - pass command to fsysdep_execute as first element of argument - array. - - * tcp.c: declare _exit. - - * uucp.h: move definition of const before use for non ANSI C. - - * uucp.h, sys1.unx: undefine remove in uucp.h if the system does - not have it to avoid conflict with macro definitions. - - * uucico.c, uuxqt.c, protf.c, prott.c, prote.c, config.c, chat.c, - port.c, sys2.unx: miscellaneous cleanups. - - * tcp.c (ftcp_open): cast argument to bzero. - - * time.c (qtimegrade_parse): cast argument to qttime_parse to - long. - - * file.c: changed iRecmode to unsigned int. - - * configure.in, uucp.h: on SCO 3.2.2 sig_atomic_t is defined in - <sys/types.h> but not <signal.h>. - - * sys1.unx: undefined remove before the function definition to - avoid trouble on systems for which it is a macro. - - * Makefile.in: removed dependencies of getopt.o. - - * sys1.unx, sys7.unx, tstuu.c: adjusted external declarations. - - * getopt.h, getopt.c: get new versions from glibc 1.01. - - * sys1.unx: don't declare sigemptyset. - - * version.c: updated to beta 1.03. - - * chat.c (fcsend): Scott Ballantyne: go ahead and send a character - for an illegal escape sequence rather than failing out. - - * uuxqt.c (uqdo_xqt_file), sys5.unx (zsysdep_find_command): cast - result of alloca. - - * protg.c (fgprocess_data): Niels Baggesen: improved debugging - information. Also tweaked fgprocess_data code to use memchr to - find the next DLE rather than searching for it by hand. - - * uucico.c (faccept_call, fuucp): accept SVR4 -U flag giving - maximum file transfer size; accept and ignore SVR4 -R flag meaning - that the system supports file restart. - -Sun Mar 15 00:21:56 1992 Ian Lance Taylor (ian@airs.com) - - * sysinf.c (titime, titimegrade): permit a retry time to be - specified as an optional additional argument. - - * uucico.c (zget_uucp_cmd, zget_typed_line): turn off DEBUG_PORT - when doing DEBUG_HANDSHAKE. - - * policy.h, sysh.unx, sys1.unx, sys2.unx (fsblock_writes, - fsserial_write, fsserial_io): added configuration parameters - HAVE_UNBLOCKED_WRITES and SINGLE_WRITE. Also blocked signals - while clearing afSignal in fsysdep_modem_close. - - * chat.c (icexpect, fcsend): turn off DEBUG_PORT while doing chat - script debugging. - - * sysh.unx, sys2.unx (fsserial_lock, fsserial_open, - fsserial_write, fsserial_io, fsysdep_tcp_read, fsysdep_tcp_write, - fsysdep_tcp_io): T. William Wells: some systems don't support - unblocked writes, so don't use them. - - * port.c (fport_read, fport_write): show calls to fport_read and - fport_write under DEBUG_PORT. - - * bnu.c (fbnu_find_port): Scott Ballantyne: accept "Any" as a - Device speed. - -Sat Mar 14 20:52:11 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h, system.h, sysh.unx, uucico.c (main, zget_typed_line), - uuxqt.c (main), uucp.c (main), uux.c (main, uxcopy_stdin), tcp.c - (ftcp_open), log.c (ulog, ulog_close), sys1.unx (ussignal), - sys2.unx (fsserial_close, fsysdep_modem_end_dial, fsserial_read, - fsserial_write, fsserial_io, fsysdep_tcp_read, fsysdep_tcp_write, - fsysdep_tcp_io): T. William Wells and Chip Salzenberg: keep an - array of signals so that a new signal doesn't obliterate our - knowledge of an old signal. Johan Vromans: if we get SIGINT - continue the current session but don't start any new ones. - - * sysh.unx, sys1.unx (isspawn, espopen, iswait, fsysdep_mail, - fsysdep_run, getcwd, mkdir), sys2.unx (fsrun_chat), sys3.unx - (fsysdep_wildcard_start), sys5.unx (fsysdep_execute), sys7.unx - (fsysdep_lock_status), uuxqt.c (uqdo_xqt_file), tcp.c (ftcp_open), - tstuu.c (uchild): added function isspawn, espopen and iswait and - channeled all execs of new processes and waits through them. - -Fri Mar 13 18:00:04 1992 Ian Lance Taylor (ian@airs.com) - - * sysinf.c (uset_system_defaults): Chip Salzenberg: changed - default login script timeout to 10 seconds. - - * prot.h, prot.c (freceive_data, breceive_char), protg.c, protf.c, - prott.c, prote.c: changed breceive_char to go through - freceive_data rather than calling fport_read directly. Added an - freport argument to freceive_data, and change all old calls to - pass it in as FALSE. - -Thu Mar 12 14:49:59 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h: added a padding byte to scmd structure, since at least - one compiler needs it. - - * uucp.c (main): use fake local name (from ``myname'' command) - when generating an execution request intended for the local - system. - - * sysh.unx: corrected readdir prototype. - - * sys2.unx: moved local header files ahead of sleep routine - determination. - - * General overhaul to change debugging system. Debugging is now - done by type rather than by number. iDebug is now interpreted as - a bit sequence. DEBUG may only be 0 (no checks or debugging), 1 - (checks, no debugging) or 2 (checks and debugging). The debugging - names are parsed by idebug_parse and tidebug_parse in config.c. - The debugging types are additive. Many source files changed. - Inspired by Michael Richardson, Johan Vromans and Peter da Silva. - -Wed Mar 11 12:01:03 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, uuxqt.c (uqdo_xqt_file): Chip Salzenberg: support - Internet mail addresses in uuxqt replies (added configuration - parameter HAVE_INTERNET_MAIL to control this). - - * sys7.unx (fskill_or_rejuv): permit uucp user to delete any job. - - * uucp.h, system.h, sysh.unx, config.c, uuxqt.c (main, uqabort), - sys5.unx (isysdep_lock_uuxqt, fsysdep_unlock_uuxqt), bnu.c - (ubnu_read_sysfiles): Marty Shannon: added max-uuxqts command, - along with support for BNU Maxuuxqts, to limit number of - concurrent uuxqt processes. - - * chat.c (icexpect, fcsend), uucico.c (zget_uucp_cmd, - zget_typed_line): improved debugging by avoiding incredibly long - lines. - - * system.h, sys5.unx (fsysdep_execute), uuxqt.c (uqdo_xqt_file): - Jon Zeef: if a temporary failure occurs, retry the execution - later. - -Tue Mar 10 12:40:30 1992 Ian Lance Taylor (ian@airs.com) - - * sysh.unx, sys1.unx (isfork), sys2.unx, sys5.unx, tcp.c: - Franc,ois Pinard: retry fork several times before giving up. - - * uucp.h, prot.c (fploop, fgot_data), file.c (usendfile_error, - urecfile_error, frecfile_rewind): Niels Baggesen: if we can't read - or write a file, treat it as a temporary error rather than a - permanent error; if we get an error on write, drop the connection - rather they try to continue. - - * uucp.h, system.h, sysh.unx, uucico.c (fuucp), prot.c - (fsend_file, freceive_file), file.c (fsent_file, usendfile_error, - freceived_file, urecfile_error, fmail_transfer), sys1.unx - (usmake_spool_dir), sys4.unx (zsysdep_save_temp_file): if a file - send fails, save the file away rather than lose it forever. - - * uucico.c (main): don't run uuxqt if we got a SIGTERM. - - * tcp.c (ftcp_open): Petri Helenius: have server fork twice to - avoid zombies. - - * port.h, prtinf.c, v2.c, bnu.c (fbnu_find_port), uucico.c - (fdo_call, faccept_call), uuchk.c (fkshow_port): added protocol - command for ports, mostly to support BNU. Also modified uuchk to - make the absence of any matching port or dialer more obvious. - - * sys3.unx (esysdep_open_receive): check size of destination file - system as well as temporary file system; handle f_bsize field - under FS_MNTENT. - - * configure.in, sysh.unx: test for including <termios.h> and - <sys/ioctl.h> in the same file, setting new configuration - parameter HAVE_TERMIOS_AND_SYS_IOCTL_H accordingly; handle it in - sysh.unx. - -Mon Mar 9 00:06:12 1992 Ian Lance Taylor (ian@airs.com) - - * sys2.unx (fsserial_close): Franc,ois Pinard: sleep for a second - after closing the serial port to give it a chance to settle. - - * sysh.unx (fsetterminfodrain), sys2.unx (fsserial_close, - fsserial_reset, fsserial_set): wait for terminal output to drain - before closing it, resetting it, or changing its parameters. - - * uucico.c (zget_uucp_cmd): Ted Lindgreen: strip parity bit from - initial handshake strings. - - * system.h, sys3.unx (esysdep_open_send), uucico.c (fuucp): Ted - Lindgreen: don't send a mail message if a file to send has been - removed, since it might have been sent in a previous session. - - * uuchk.c (ukshow): Zacharias Beckman: put list of permitted - programs and execution path on separate lines. - - * uucico.c (fdo_call, faccept_call): only look for hangup string - in debugging mode, since there's nothing to be done with it - anyhow. - - * uucico.c (faccept_call): Ted Lindgreen: report the minimum - transfer grade requested during an incoming call in the log file. - - * uucp.h, uutime.h, config.c, uucico.c (fcall), time.c - (ftimespan_match, btimegrade, cmax_size_now): added a new status - type for ``wrong time to call''. If a system can never be called, - this status type is not used (if an attempt is made to call the - system, the status is left unchanged). - -Sun Mar 8 11:41:45 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main, flogin_prompt, faccept_call): Ted Lindgreen: if - we were asked to call a single system, or if a single system - called in, then start uuxqt with -s for just that system. - - * uucico.c (main): Ted Lindgreen: ignore the -u option. - - * tstuu.c: Ted Lindgreen: don't include <sys/ioct.h> if it's not - there. Also removed the ``ignore this error'' message from the - chat scripts since it's no longer marked as an error. - - * sys2.unx (fsserial_set): Ted Lindgreen: if CRTSCTS is defined - and turned on, then don't turn on IXOFF. - - * uucp.h, log.c, uucico.c (fdo_call, faccept_call): Ted Lindgreen: - report the port name and (for incoming calls) the login name in - the log file. - -Sat Mar 7 10:00:47 1992 Ian Lance Taylor (ian@airs.com) - - * port.h, prtinf.c, sys2.unx (fsserial_lockfile, fsserial_lock): - Peter da Silva: added ``lockname'' command to ports to permit - specification of the file name to use when locking. - - * sys1.unx (usysdep_detach): let setpgrp fail silently. - - * sys2.unx: always include <sys/ioctl.h> if it's present on the - system. - - * time.c (btimegrade, cmax_size_now): removed extraneous - semicolons. - - * sys2.unx (fsserial_lock, fsserial_open, fsserial_close): support - TIOCEXCL locking. - - * sys2.unx (fsserial_open): preserve unknown bits in c_cflag when - using HAVE_SYSV_TERMIO or HAVE_POSIX_TERMIOS. - - * prot.h: never included more than once. - -Fri Mar 6 21:53:28 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h: Eric Ziegast: some systems don't define EXIT_SUCCESS or - EXIT_FAILURE in stdlib.h. - - * uucp.h, uutime.h, uucico.c (fuucp), sysinf.c (uinittimetables, - uaddtimetable), uuchk.c (main, ukshow_size, ukshow_time, - qcompress_span), time.c (all new): rewrote time routines - completely for consistency and simplicity. Fixed bug causing - incorrect maximum possible transfer size. Added new file - uutime.h. - -Wed Mar 4 10:06:13 1992 Ian Lance Taylor (ian@airs.com) - - * sys2.unx (fsserial_lockfile, fsserial_lock, fsysdep_modem_open, - fsysdep_direct_open, fsysdep_modem_close, fsysdep_direct_close): - Petri Helenius: if the open failed on a serial port, the lock - files were not removed. - - * config.c (igradecmp): the local variables in igradecmp have to - be integers; signed characters might not work correctly (although - they would in all normal cases). - - * sys4.unx (fsysdep_has_work): Johan Vromans: set *pbgrade - correctly if we still have work left over that we haven't looked - at yet. - - * tstuu.c (main, uchoose, fwriteable): Roberto Biancardi: use poll - if we haven't got select. - - * uucico.c (zget_uucp_cmd): Michael Haberler: some systems send \n - after Shere, rather than a null byte. - -Tue Mar 3 01:03:22 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (main, uqdo_xqt_file): permit local executions, don't - get grade out of system dependent file name. - - * sys4.unx (fsysdep_get_work): Bob Denny: warn if we can't open a - command file. - - * v2.c (uv2_read_systems): Jeff Putsch: infinite loop when reading - time string. - - * uucp.h, sys1.unx, sys2.unx, sys3.unx, tstuu.c, configure.in: - Thomas Fischer: some NeXT compatibility stuff: removed externs of - sleep and alarm, included <libc.h> in uucp.h. - - * uucp.h, port.h, uucico.c (zget_uucp_cmd, zget_typed_line), - port.c (cdebug_char, udebug_buffer), chat.c (icexpect, fcsend, - fcphone), log.c (ulog): Michael Richardson: added LOG_DEBUG_START, - LOG_DEBUG_CONTINUE and LOG_DEBUG_END to allow a debugging line in - the log file to be built character by character. Used this new - feature in chat script debugging, rather than having each - character appear on a separate line. Added fPort_debug variable - to control port debugging. - - * uustat.c (fsquery, fsquery_system, fsquery_show): handle - execution files queued up for the local system correctly when - using -q option (they still don't show up on any other option). - - * uucp.texi, protg.c (fgstart, fgshutdown): Aleksey P. Rudnev: - added remote-window and remote-packet-size 'g' protocol - parameters. Reset the parameters to their default values in - fgshutdown. - - * sysh.unx, sys2.unx (fsserial_read, usalarm), sys1.unx - (usset_signal, usysdep_detach), uucico.c (main): overhauled - fsserial_read yet again. The timeout passed in is now an absolute - bound. A special SIGALRM handler does some wierd stuff to avoid - any possible race. - - * config.c (uread_config), sysinf.c (uiread_systems, - fcallout_login, fcheck_login), prtinf.c (ffind_port, - fread_dialer_info), chat.c (fctranslate), uucico.c (faccept_call): - T. William Wells: when using HAVE_TAYLOR_CONFIG in combination - with V2 or BNU configuration files, don't complain if the - HAVE_TAYLOR_CONFIG files are missing. - -Mon Mar 2 10:21:36 1992 Ian Lance Taylor (ian@airs.com) - - * sys2.unx (fsserial_read): T. William Wells: don't arbitrarily - extend read timeout. - - * uux.c (main): check iSignal before entering fread, since the - user may have hit ^C earlier in the program. - -Sun Mar 1 23:39:33 1992 Ian Lance Taylor (ian@airs.com) - - * policy.h, uucp.h, sysh.unx, sys2.unx (fsserial_lock, - fsysdep_modem_close, fsysdep_direct_close), util.c (strlwr), - configure.in: Marc Unangst: added HAVE_SCO_LOCKFILES configuration - parameter to force lock file names to lower case. - -Fri Feb 28 00:07:12 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uucico.c (faccept_call, fdo_xcmd), uuxqt.c - (uqdo_xqt_file), uux.c (main), uucp.c (main, ucspool_cmds), - sys3.unx (zsysdep_spool_cmds), uux.1, uucp.1: added -j switch to - uucp and uux to display the jobid of the spooled job. - - * uucp.h, system.h, sysh.unx, uucico.c (fuucp, fdo_xcmd, - fok_to_send, fok_to_receive), uuxqt.c (uqdo_xqt_files), uux.c - (main, uxcopy_stdin), uucp.c (main), file.c (freceived_file), - config.c (fin_directory_list), sys1.unx (fsysdep_file_exists, - fsuser_access, fsysdep_in_directory), sys3.unx (esysdep_open_send, - fsysdep_move_file), sys5.unx (fsysdep_xqt_check_file): Chip - Salzenberg: recheck file access permissions before sending, to try - to avoid symbolic link games. Check that the user has search - access on all directories down to the file, and read or write - access to the file or directory itself. Check in uucp and uux as - well as uucico, to provide early messages. Check the standard - input file in uuxqt. Be more careful about creating files in the - spool directory. This eliminates all security problems I know of, - except for a very short race in fsysdep_move_file. - - * sys3.unx (esysdep_open_send): give an error message if we try to - send a directory (used to just fail silently). - - * system.h, sysh.unx, sys1.unx (usysdep_detach, ussignal, - fsysdep_catch, usysdep_start_catch), sys2.unx - (fsysdep_modem_end_dial, fsserial_read), uux.c (main): T. William - Wells: fsysdep_catch obviously must be a macro, since it calls - setjmp. Also TIOCNOTTY sets the process group to 0, so we don't - have to fork before calling it. - -Thu Feb 27 00:08:09 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx, sys6.unx, sys7.unx: added some extern definitions. - - * configure.in, uucp.h, system.h, sysh.unx, uucico.c (main, - ucatch, uabort, zget_typed_line, zget_uucp_cmd), uuxqt.c (main, - uqcatch, uqabort), uux.c (main, uxcatch, uxrecord_file, uxabort), - uucp.c (main, uccatch, ucrecord_file, ucabort), uustat.c (main, - uscatch), uulog.c (main, ulcatch), uuname.c (main, uncatch), - uucheck.c (main, ukcatch), log.c (ulog_fatal_fn, ulog, - ulog_close), tstuu.c (main, uchild, uprepare_test), sys1.unx - (usysdep_initialize, usysdep_detach, usysdep_signal, - fsysdep_catch, usysdep_end_catch, ussignal, fsset_signal, - fsysdep_run, raise), sys2.unx (usalarm, usysdep_pause, - fsserial_lock, fsserial_open, fsysdep_stdin_close, - fsysdep_modem_close, fsysdep_modem_end_dial, fsserial_read, - fsserial_write, fsserial_io), sys5.unx (fsysdep_execute): T. - William Wells: overhaul to support detaching from the terminal and - completely reliable signals. uucico now calls usysdep_detach at - various points; new option -D prevents detaching. The signal - handling code all goes through usysdep_signal, fsysdep_catch and - usysdep_end_catch. A signal now just sets iSignal, which is - checked at various points, notably in the port routines and in the - main loops in uucico and uuxqt. - -Tue Feb 25 10:59:23 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgwait_for_packet): Bob Denny: reset the count of - timeouts only when data is recognized, so that we aren't fooled by - a sequence of imperfect echoes. - - * sys5.unx (zsysdep_get_xqt): Bob Denny: don't warn if opendir - gets ENOENT. I think POSIX requires ENOTDIR, but what can you do? - -Mon Feb 24 14:37:10 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main, uusage): don't treat an extra argument as a port - name. - - * sys3.unx (esysdep_truncate): Roberto Biancardi: support F_CHSIZE - and F_FREESP in esysdep_truncate. - - * configure.in, sys2.unx (fsserial_read, usysdep_pause): Roberto - Biancardi: use poll to sleep less than a second if we haven't got - anything else. - - * v2.c (uv2_read_systems, fv2_find_port), bnu.c - (ubnu_read_systems, fbnu_find_port, fbnu_read_dialer_info), - uustat.c (fsworkfile_show): Roberto Biancardi: skip spaces and - tabs after doing a strtok ((char *) NULL, ""). - - * copy.c (fcopy_file), sys1.unx (esysdep_fopen), sys2.unx, - sys3.unx (esysdep_open_receive, esysdep_truncate, fsdo_lock, - fscmd_seq), sys5.unx (fsysdep_execute), sys7.unx, tstuu.c: John - Theus: some systems use <sys/file.h> instead of <fcntl.h>. Also - changed the code to call creat instead of open when appropriate. - Should now work on V7, with the exception of O_NONBLOCK and - O_NDELAY in sys2.unx and tstuu.c. - - * uucp.h: John Theus: if we don't have vprintf, ulog is defined - without an ellipsis, so don't declare it with one. - -Sun Feb 23 14:45:53 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.h, system.h, bnu.c (ubnu_read_systems), config.c - (fin_directory_list), sys1.unx (fsysdep_in_directory), sys5.unx - (fsysdep_xqt_check_file), uucp.c (main), uuxqt.c (uqdo_xqt_file), - uucico.c (fdo_xcmd, fok_to_send, fok_to_receive), tstuu.c - (uprepare_test): only permit files to be received into directories - that are world writeable. Check for this in fsysdep_in_directory, - with a new argument. Changed calls appropriately. In tstuu - create /usr/tmp/tstuu as world writeable. - - * bnu.c (ubadd_perm_alternate): Doug Evans: after all that, I got - it wrong: WRITE only applies to remote requests. - - * uucp.h, uucico.c (fuucp, fdo_xcmd, fok_to_send, fok_to_receive), - uuxqt.c (uqdo_xqt_file), uuchk.c (ukshow), sysinf.c - (uset_system_defaults, tialternate), sys5.unx - (fsysdep_xqt_check_file), bnu.c (ubadd_perm_alternate): fixed READ - and WRITE handling to match BNU semantics. Added - zcalled_local_send, zcalled_local_receive, zcalled_remote_send and - zcalled_remote_receive fields to ssysteminfo structure for this, - and handled them in all the appropriate places. - -Sat Feb 22 22:30:59 1992 Ian Lance Taylor (ian@airs.com) - - * Complete overhaul of configuration to use automatic shell - script. Eliminated conf.h, now generated by configure. Renamed - Makefile to Makefile.in. Added policy.h for administrative - decisions and other choices which can not be made automatically. - Many changes to many source files, none having to do with code. - -Thu Feb 20 17:57:55 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call): Chip Salzenberg: some systems truncate the - Shere= machine name to 7 characters. - -Wed Feb 19 14:36:31 1992 Ian Lance Taylor (ian@airs.com) - - * sys7.unx (fskill_or_rejuv): make sure that only the submitter or - the superuser is permitted to cancel (or rejuvenate) a request. - - * system.h, sysh.unx, sys3.unx (zsfile_to_jobid, zsjobid_to_file), - sys4.unx (zsysdep_jobid), sys7.unx, uustat.c, Makefile, MANIFEST: - wrote uustat. Changed CSEQLEN in sys3.unx from 5 to 4. Added - several new system dependent functions, mostly in sys7.unx. - - * system.h, sys1.unx, log.c, file.c, chat.c, protg.c, uucico.c: - rearranged the time functions for the convenience of uustat. Made - isysdep_time take an optional pimicros arguments. Renamed - usysdep_full_time to isysdep_process_time, and made clear that it - need only work within a single process. Changed usysdep_localtime - to take a time returned by isysdep_time rather than always use the - current time. Changed the calls as appropriate. - -Tue Feb 18 14:03:19 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (main): pass fdaemon argument correctly to - usysdep_initialize. - -Mon Feb 17 17:09:16 1992 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (uqdo_xqt_file): T. William Wells: make sure sh uses - absolute path of command, rather than relying on PATH. - - * sys5.unx (zsysdep_find_command): Michael Nolan: allow full - command name to be specified by remote system, not just basename, - if command is not in path. - - * log.c (ulog): don't use headers when outputting to terminal. - - * sys2.unx (fsrun_chat): Bob Denny: log chat program messages as - LOG_NORMAL, not LOG_ERROR. - -Fri Feb 14 00:17:57 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (ucatch), uuxqt.c (uqcatch): Neils Baggesen: under - HAVE_BNU_LOGGING, don't lose the system name when dieing. - - * uulog.c, Makefile, MANIFEST: wrote uulog. - - * uuname.c, Makefile, MANIFEST: wrote uuname. - - * bnu.c (ubadd_perm_alternate): T. William Wells: must xstrdup the - system name before calling uadd_validate. - - * log.c (ulog_close): Micheal Nolan: don't refer to eLdebug if the - DEBUG configuration parameter is 0. - - * uucp.c (main): Niels Baggesen: abtname must be copied into - memory, or it will be overwritten by the next file to be copied. - -Sun Feb 9 00:12:58 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fuucp), prot.c (fsend_file, freceive_file): Bob Denny: - call fmail_transfer before calling fsysdep_did_work, because the - latter frees up strings used by the former. - - * sysh.unx, sys1.unx (mkdir), uudir.c (new file), Makefile: added - HAVE_MKDIR configuration parameter for systems without the mkdir - system call. The emulation function in sys1.unx invokes the new - suid program uudir which sets its uid to uucp and invokes - /bin/mkdir. Added rules to create uudir to Makefile. - -Sat Feb 8 14:25:50 1992 Ian Lance Taylor (ian@airs.com) - - * sysh.unx, sys1.unx (opendir, readdir, closedir), sys4.unx, - sys5.unx: added HAVE_OLD_DIRECTORIES configuration parameter to - support systems without opendir/readdir/closedir which use - original Unix directory format. - - * sysh.unx, sys1.unx (dup2): added HAVE_DUP2 configuration - parameter and dup2 emulation function. - - * sys1.unx (zsysdep_local_name): put utsname structure on stack - rather than making it static. - - * sysh.unx, sys1.unx (usysdep_initialize, getcwd): if we have - neither getcwd nor getwd, fork /bin/pwd to get the current working - directory. - - * system.h, uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c - (main), uuchk.c (main), sys1.unx (usysdep_initialize), sys6.unx - (fsysdep_needs_cwd, zsysdep_add_cwd): because getting the current - working directory can be expensive on Unix, since some - implementation of getcwd fork a shell to execute pwd, only try to - get the cwd if it is going to be needed by uux or uucp. - - * uucico.c (main), uuxqt.c (main), uux.c (main), uucp.c (main), - uuchk.c (main), log.c (ulog): handle all possible signals raised - by abort, namely SIGABRT, SIGILL and SIGIOT. In ulog always call - abort rather than raise (SIGABRT). - - * sys4.unx (usysdep_get_work_free): the qSwork_file information - was freed up incorrectly if a file transfer failed. - - * sysh.unx, sys2.unx: Archaic Zilog System III computers use - setret and longret rather than setjmp and longjmp, so I added a - HAVE_SETRET configuration option. - - * prott.c (ftstart, ftsenddata): shifts of integers by more than - 15 are not portable. - - * prot.c (fsend_file, freceive_file, fploop, fgot_data): I ran - into an old compiler which couldn't handle the calls to pffile, so - I simplified them to use a variable. - - * port.c (fmodem_dial): cast result of alloca. - - * getopt.h, getopt.c: Jay Vassos-Libove: renamed getopt and - related variables by macro defining them to gnu_*. This avoids - conflicts with system header files and system libraries. - -Fri Feb 7 12:08:42 1992 Ian Lance Taylor (ian@airs.com) - - * everything: added HAVE_STRING_H and HAVE_STRINGS_H. Removed - include of <string.h> in every source file and put it in uucp.h. - Since I had to change everything anyhow, added 1992 to the - copyright date. - - * uucico.c (fcall): Bob Denny: retry time not reached is not - really an error, so just make a normal log entry for it. - -Sun Feb 2 01:38:47 1992 Ian Lance Taylor (ian@airs.com) - - * uucp.c (main): Get the file name for the destination of a local - copy using zsysdep_real_file_name rather than zsysdep_in_dir, - since the latter doesn't get the basename of the argument. - - * sys3.unx (fsysdep_get_status): Niels Baggesen: cast enum to int - before comparison. - - * system.h, uucp.c (main), uux.c (main), sys6.unx (fsysdep_access, - fsysdep_daemon_access): Niels Baggesen: check user access to file - since programs are running setuid. Previously uucp and uux - permitted a file readable only by uucp to be transferred to - another system by user request! - - * chat.c (fchat): Michael Nolan: portions of a chat string might - be separated by more than just a single space if they are read - from a V2 or BNU configuration file. - -Fri Jan 31 19:51:57 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c: Chip Salzenberg: change default window size to 7. - - * sys3.unx (fsdo_unlock): Michael Nolan: cast result of alloca to - (char *), not that it really matters. - - * log.c (ulog): Michael Nolan: if SIGABRT is not defined, just - call abort. - -Thu Jan 30 18:19:33 1992 Ian Lance Taylor (ian@airs.com) - - * bnu.c (ubadd_perm): Michael Nolan: debugging check was done - wrong for entry with LOGNAME but no MACHINE. - -Wed Jan 29 13:28:59 1992 Ian Lance Taylor (ian@airs.com) - - * uucico.c (zget_uucp_cmd): Patrick Smith: only wait a short time - for the hangup string. - - * sys4.unx (iswork_cmp): Patrick Smith: fixed casts to not cast - away const. - -Tue Jan 28 11:06:34 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx, sys3.unx, tstuu.c: Jay Vassos-Libove: removed some - declarations of system functions that conflict with system header - files on BSD/386 alpha. - - * Makefile: Jeff Ross: make sure the uninstall target restores the - original file owner and mode. - - * protg.c (fgsendcmd): the previous patch wasn't really correct. - -Mon Jan 27 22:30:47 1992 Ian Lance Taylor (ian@airs.com) - - * log.c (ustats): Marty Shannon: don't report a failed transfer - under USE_BNU_LOGGING. - - * sys3.unx (zsysdep_real_file_name): Marty Shannon: a trailing '/' - on the name means that it is a directory, even if the directory - does not already exist. - - * uucico.c (fuucp): Marty Shannon: the -f flag indicating that - directories should not be created was not being handled correctly. - - * uucico.c (fcall): Chip Salzenberg: set .Status correctly if - wrong time to call. - - * protg.c (fgsendcmd): John Antypas: didn't handle null byte at - end of command which was exactly a power of two in length - correctly. - -Tue Jan 21 14:37:10 1992 Ian Lance Taylor (ian@airs.com) - - * Released version 1.02. - - * system.h, uucico.c (main), uux.c (main), uucp.c (main, - zcone_system), sys1.unx (fsysdep_run): Chip Salzenberg: have uucp - and uux start up uucico -s system rather than uucico -r1. - -Mon Jan 20 11:45:38 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx (fsysdep_make_dirs): don't try to create a directory - with no name. - - * version.c: change version number to 1.02. - - * uucico.8, uuxqt.8, uucp.1, uux.1: change version number to 1.02. - - * MANIFEST: removed texinfo.tex; it's twice the size of any other - file, so I think it's just to large to distribute. - - * uucico.c (fcall, fdo_call): Marty Shannon: update the time in - the .Status file if it's the wrong time to call, and upon - receiving a call. - -Sun Jan 19 13:29:23 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgsendcmd, fgsenddata): Dave Platt: if the remote UUCP - accepts packets larger than 64 bytes, assume it can handle - differing packet sizes, so if we have a small amount of data to - send, use a small packet. Besides the two routines mentioned, - also made minor changes to other routines to get the packet length - out of the packet data rather than always assuming the same packet - size. - - * conf.h, uucp.h: Matthew Lyle: some systems don't declare errno - in <errno.h>, so I added HAVE_ERRNO_DECLARATION. - - * conf.h, uucp.h, util.c (bsearch): added HAVE_BSEARCH - configuration parameter. - -Sat Jan 18 17:45:28 1992 Ian Lance Taylor (ian@airs.com) - - * tstuu.c (utransfer): Mike Park: don't sleep when the input - buffer is full; it's too slow. - - * Makefile: when making a distribution,change the mode of separate - copies of the configuration files Makefile, conf.h and sysh.unx. - - * uucico.c (faccept_call): Marty Shannon: update .Status file on - incoming calls. - - * uucp.h, prot.h, uucico.c (fuucp), prot.c (fsend_file, - fpsendfile_confirm, freceive_file, fprecfile_confirm, fxcmd, - ustats_failed), file.c (fsent_file, usendfile_error, - freceived_file, urecfile_error, frecfile_rewind, fmail_transfer): - reworked calls to fsydep_did_work and sending of mail messages to - be more sensible. Now sends mail to requestor if request fails - permanently and does not remove file if request fails only - temporarily. - -Thu Jan 16 11:33:08 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgsendcmd, fgsenddata): zero out unused bytes in short - packets. - - * prot.c (zgetcmd), protf.c (ffsendcmd), prott.c (ftsendcmd), - prote.c (fesendcmd): Niels Baggesen: added some debugging - messages. - - * protg.c (fgsendcmd): corrected misspelling in debugging message. - - * log.c (ustats): Niels Baggesen: add FAILED to end of xferstats - line if appropriate. - - * uuxqt.c (uqdo_xqt_file): Niels Baggesen: was checking strcmp - return value incorrectly, so messages to other systems were not - being sent. - - * sys2.unx, tstuu.c: Mike Park: ioctl is sometimes declared - varadic, so we can't declare it. - -Wed Jan 15 02:03:43 1992 Ian Lance Taylor (ian@airs.com) - - * sys1.unx: put \n at end of fsysdep_run error message. - - * sysh.unx, sys1.unx, sys2.unx, tstuu.c: Mike Park: on some - systems <sys/time.h> includes <time.h> but <time.h> can only be - included once; added HAVE_SYS_TIME_AND_TIME_H to sysh.unx. - - * tstuu.c: Mike Park: removed prototype for times since some - systems don't have clock_t. - - * conf.h, sys2.unx, util.c: Mike Park: some systems don't have - <limits.h>. Every macro used from it already had a check to make - sure it was defined anyhow. - - * tstuu.c (uprepare_test): Mike Park: sh on NeXT interprets a - leading ~, so we have to quote the argument to system(3). - Incredible. - - * conf.h, uucp.h: Mike Park: if HAVE_ALLOCA is 0 when compiling - with gcc, don't define alloca as a macro. This will let the NeXT - define it in some header file. - - * sysh.unx, sys2.unx, sys5.unx, tstuu.c: Mike Park: handle - HAVE_UNION_WAIT completely. Assume that system(3) returns an int - which should be put into the w_status field. Define macros for - union wait if they are not already defined. Move all this stuff - into sysh.unx rather than duplicating it in three different files. - - * conf.h, uucp.h, sysh.unx, config.c, bnu.c, v2.c, uucico.c, - uuxqt.c, uux.c, uucp.c, uuchk.c, Makefile: set directory to look - for configuration files in in Makefile rather than in sysh.unx. - This forced a number of changes, as now all new style - configuration files are looked up using NEWCONFIGLIB. Old style - configuration files are looked up using OLDCONFIGLIB. - -Mon Jan 13 00:35:43 1992 Ian Lance Taylor (ian@airs.com) - - * sys3.unx: David Nugent: don't declare chmod, since it may be - prototyped to take an argument that is smaller than an int. - - * uucico.c (faccept_call): Chip Salzenberg: only declare sportinfo - if it will be used (if HAVE_TAYLOR_CONFIG is true). - - * sys3.unx (isysdep_get_sequence): Chip Salzenberg: avoid use - before set warning from gcc. - - * protf.c (ffprocess_data): Chip Salzenberg: avoid use before set - warning from gcc. - - * sysh.unx, sys2.unx (fsserial_read, usysdep_pause): Chip - Salzenberg: added HAVE_USLEEP configuration parameter for the AIX - usleep routine. - - * uuchk.c, prtinf.c, config.c: Chip Salzenberg: strcmp is a macro - on AIX, so avoid declaring it and undef it in config.c where we - want to declare it because we want to take its address. - - * uucp.h, sys3.unx (fsysdep_get_status, fsysdep_set_status): Chip - Salzenberg: handle out of range status codes in status files. - - * Makefile, sysh.unx: defined LIBDIR in the Makefile, rather than - forcing the user to define it in two different places. - - * sys.unx, tstuu.c: Chip Salzenberg: can't declare execl, since it - is varadic. - - * sys1.unx, sys2.unx, sys3.unx, sys5.unx, tstuu.c: David Nugent: - can't declare open or fcntl, since they may use ... in header file - prototype; added declaration for popen; added casts of first mkdir - argument to char *. - - * sysh.unx, tstuu.c (uchild): Mike Park: added HAVE_WAITPID and - HAVE_WAIT4 configuration parameters to allow the use of wait4 as - found on the NeXT. - - * tstuu.c (uprepare_test): Mike Park: use IPUBLIC_DIRECTORY_MODE - rather than S_IRWXU | S_IRWXG | S_IRWXO. - - * sysinf.c (tisystem): Mike Park: ulog was being passed the wrong - number of arguments. - -Sun Jan 12 14:32:47 1992 Ian Lance Taylor (ian@airs.com) - - * Eliminated CONFIG, INSTALL and THANKS. They are now included in - uucp.texi. Changed README and MANIFEST accordingly. Added - uucp.info* and texinfo.tex to MANIFEST. - - * Makefile, uucp.texi: renamed taylor.texi to uucp.texi. - - * uucico.c (fcall, fdo_call): John Antypas: pass in sportinfo - structure for fdo_call to use for an unknown port. - - * log.c (ulog): allocate enough bytes to name file if - HAVE_BNU_LOGGING is in use but zLogfile has no %s. - -Sat Jan 11 12:11:56 1992 Ian Lance Taylor (ian@airs.com) - - * Makefile: changed to correspond to GNU standards, according to - standards.text of 24 Nov 91. - - * Makefile: Franc,ois Pinard: use $(INSTALL_PROGRAM) and - $(INSTALL) rather than cp to install the programs. - - * time.c (ftime_now), sys1.unx (usysdep_localtime): John Antypas: - use memcpy to get the result of localtime rather than relying on - structure assignment. - - * sysh.unx, prtinf.c: Hannu Strang: changed definition of - SYSDEP_STDIN_CMDS to pass structure instead of address of - structure to avoid bug in AIX compiler which causes it to fail to - recognize an address constant containing the -> operator. - -Tue Jan 7 10:22:43 1992 Ian Lance Taylor (ian@airs.com) - - * Released beta 1.02. - - * protg.c (fgcheck_errors): discount out of order packets in the - total error count, and allow a negative error count to mean that - any number of errors are accepted. - - * sysinf.c (tadd_proto_param): Niels Baggesen: allocate number of - protocol parameters based on *pc, not sIhold.cproto_params. - -Sat Jan 4 16:42:21 1992 Ian Lance Taylor (ian@airs.com) - - * log.c (ulog): tweaked HAVE_V2_LOGGING slightly. - - * v2.c (uv2_read_systems): set chat script correctly. - - * uucp.h, sys3.unx: avoid redefining SEEK_SET if it appears in - <unistd.h> but not <stdio.h>. - - * chat.c (fcsend): made fcsend into a static function. - - * uucp.h, uucico.c, uuxqt.c, uux.c, uucp.c, uuchk.c, version.c: - changed abProgram and abVersion from const char [] to char [] - because the Microsoft compiler on SCO can't handle const char [] - arrays correctly. - - * uux.c (main): allocate enough space for log message. - - * sys1.unx (usysdep_localtime): to get the current time, we can't - call usysdep_full_time if the latter uses times. - - * sys1.unx, sys3.unx: added a couple more extern definitions for - SCO 3.2.2. - - * uucico.c (main): start uuxqt even if a call fails. - - * sysh.unx, system.h, uuxqt.c (uqdo_xqt_file), sys5.unx - (fsysdep_xqt_check_file): Chip Salzenberg: added configuration - option ALLOW_FILENAME_ARGUMENTS to permit arguments that look like - filenames, to allow undoing the patch I just made. - -Fri Jan 3 00:44:59 1992 Ian Lance Taylor (ian@airs.com) - - * system.h, uuxqt.c (uqdo_xqt_file), sys5.unx - (fsysdep_xqt_check_file): David J. Fiander: make sure that if an - argument looks like a filename we are permitted to access it. - - * sys3.unx (fsdo_lock): remove temporary file if link fails in - fsdo_lock. - -Thu Jan 2 00:01:53 1992 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgstart, fgshutdown, fgprocess_data): count remote - rejections separately from resent packets when counting errors. - -Tue Dec 31 14:31:38 1991 Ian Lance Taylor (ian@airs.com) - - * protg.c (fgstart): Franc,ois Pinard: forgot to initialize - cGdelayed_packets. - - * prot.h, uucico.c, prote.c: added the 'e' protocol, creating the - new file prote.c - - * prot.c (freceive_data), protf.c (fffile), prott.c (ftfile): - changed pffile protocol entry point to pass number of bytes being - sent; fixed bug in freceive_data which caused to ask for the wrong - number of bytes when the buffer was empty. - -Mon Dec 30 23:16:48 1991 Ian Lance Taylor (ian@airs.com) - - * sys2.unx (fsserial_open): Chip Salzenberg: don't turn on IXON - and IXOFF initially; after all, the initialization packets might - contain an XOFF character. - -Sun Dec 29 00:00:42 1991 Ian Lance Taylor (ian@airs.com) - - * uucp.h, prot.c (fploop): John Theus: check for EOF before - reading from file to work around bug in Tektronix library. - - * protg.c (fprocess_data): don't send RR packets when an error - occurs; the other side will probably ignore them, and it may - confuse some Telebit modems. - - * sys1.unx (usysdep_localtime): don't take the address of a cast - value. - - * log.c (zldate_and_time): wasn't allocating enough buffer space. - -Sat Dec 28 01:09:58 1991 Ian Lance Taylor (ian@airs.com) - - * uuxqt.c (uqdo_xqt_file): forgot to initialize zmail. - - * uucp.h, time.c, copy.c, sys1.unx, sys2.unx, sys3.unx, sys4.unx, - sys5.unx, config.c, log.c, uuxqt.c, uux.c, tstuu.c: added a bunch - of externs to decrease the number of implicit function - definitions. - - * system.h, sys1.unx (usysdep_localtime), log.c (zldate_and_time): - Lele Gaifax: put the full year in the log file, using the format - YYYY-MM-DD HH:MM:SS.HH (ending in hundredths of seconds). - - * config.c (uprocesscmds): Terry Gardner: allow a # to be quoted - in a configuration file. Also made uprocesscmds reentrant. - - * sysh.unx, sys2.unx (fsrun_chat), sys5.unx (fsysdep_execute), - tstuu.c (uchild): Monty Solomon: added HAVE_UNION_WAIT - configuration option to pass a variable of type union wait to the - wait and waitpid system calls. - - * sysh.unx, sys1.unx (usysdep_initialize): John Theus: added - HAVE_GETWD to use getwd instead of getcwd. - - * sysh.unx, sys1.unx (usysdep_full_time): added HAVE_FTIME - configuration option. - - * tstuu.c (uchild): use TIMES_TICK from sysh.unx rather than - CLK_TCK. - - * conf.h, uucp.h, util.c, getopt.c, tstuu.c: added HAVE_STRCHR and - HAVE_INDEX to conf.h. - -Fri Dec 27 01:00:41 1991 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fuucp): set fmasterdone correctly when running as a - slave. - - * port.c (cpshow, upshow, fport_read, fport_write, fport_io): - cleaned up debugging code by isolating out upshow and by making - cpshow handle backslash. - - * tstuu.c (uprepare_test): create spool directories by hand, to - make sure test 6 can be done and to test creating needed - directories. - - * conf.h, uucp.h, bnu.c, v2.c, chat.c, protg.c, prott.c, sysinf.c, - tcp.c, getopt.c, tstuu.c, util.c: added HAVE_MEMFNS and HAVE_BFNS - to conf.h. Changed memset calls to use bzero. - - * protg.c (fgcheck_errors, fgprocess_data): added protocol - parameter ``errors'' to set maximum number of errors permitted. - Also made fgprocess_data only reply once per batch of data. - -Thu Dec 26 17:54:54 1991 Ian Lance Taylor (ian@airs.com) - - * tcp.c (ftcp_dial, itcp_port_number): Monty Solomon: cast - arguments to avoid prototype errors on NeXT. - -Mon Dec 23 00:16:19 1991 Ian Lance Taylor (ian@airs.com) - - * uucp.h, sysinf.c, uucico.c (main, flogin_prompt, faccept_call), - uuchk.c (main): David Nugent: allow debugging level to be set for - a specific system. - -Sun Dec 22 15:51:10 1991 Ian Lance Taylor (ian@airs.com) - - * conf.h, uucp.c, sysh.unx, tcp.c, sys1.unx, sys2.unx, sys3.unx, - sys5.unx, sys6.unx, tstuu.c: Monty Solomon: added HAVE_UNISTD_H to - conf.h for systems which don't have <unistd.h>. Also added - externs for all functions from <unistd.h>, which required adding - definitions for pid_t, uid_t and off_t to sysh.unx. - - * config.c, prtinf.c, time.c, uuchk.c: added externs for - strcasecmp or strncasecmp, to avoid implicit function definitions - now that I took the prototypes out of uucp.h. - - * sys3.unx (fsysdep_get_status): Franc,ois Pinard: the code added - to avoid scanf had a stupid bug. - - * uucp.h: Monty Solomon: removed prototypes for strcasecmp and - strncasecmp from uucp.h, since they may be in string.h. - -Sat Dec 21 16:04:58 1991 Ian Lance Taylor (ian@airs.com) - - * uucp.h, uucico.c (ucatch), prot.c (fpsendfile_confirm, - fprecfile_confirm, ustats_failed), file.c (fsent_file, - freceived_file), log.c (ustats): Terry Gardner: record failed file - transfers in the statistics file. - - * uucico.c: change protocol ordering to 't', 'g', 'f'. - - * uucico.c (faccept_call), tstuu.c (uprepare_test): John Theus: - don't warn if the port file doesn't exist when the slave mode - uucico looks up the port. - - * sys1.unx, sys5.unx: moved fsysdep_file_exists from sys5.unx to - sys1.unx so that uucico can call it. - - * uux.c: Fran,cois Pinard: remove parentheses from ZSHELLSEPS so - that they may be used to quote arguments as documented. This - means that may not be used to start subshell, but that is no great - loss. - - * uux.c (main): use ulog to report illegal grade error message. - - * sys1.unx (fsysdep_run): use the real program name from abProgram - in the error messages in fsysdep_run. - -Thu Dec 19 19:02:28 1991 Ian Lance Taylor (ian@airs.com) - - * uucico.c (fdo_call, faccept_call): Terry Gardner: put the length - of the conversation in the ``Call complete'' log file message. - - * uux.c: added space and tab to ZSHELLSEPS, because otherwise the - command was parsed to include whitespace. - - * protg.c, protf.c: Oleg Tabarovsky: added statistical logging - messages to the 'g' and 'f' protocols. These go to the main log - file right now, but I'm not sure if that's appropriate. - - * sys2.unx (fsserial_set): don't change terminal settings if we - don't have to. - - * port.c (fport_io): add complete diagnostics for fport_io so we - can see every byte that goes in or out. - - * uucico.c (fuucp): don't give user name in errors produced by - getting the next command. - - * uuxqt.c (main): don't process execute files for unknown systems. - This is not unreasonable, I hope, and it avoids errors caused by - an uninitialized sUnknown structure. - - * sys4.unx (fsysdep_get_work_init): sort the previously found - files all together so we can correctly check new files using - bsearch. - - * protf.c (pfprocess, pfprocess_data, pfwait): Franc,ois Pinard: - don't kill 'f' protocol because of an illegal byte. Also slightly - optimized the protocol to wait for up to seven characters at a - time rather than just one. - -Wed Dec 18 00:12:42 1991 Ian Lance Taylor (ian@airs.com) - - * sysh.unx, sys2.unx, tstuu.c: Terry Gardner: added - USE_FOR_UNBLOCKED configuration parameter to support systems that - don't permit O_NONBLOCK and O_NDELAY to both be set. - - * tstuu.c (uchild): give the uucico processes a chance to die on - their own rather than killing them immediately. - - * uuxqt.c (main, uqdo_xqt_file): David Nugent: keep rescanning the - list of execute files until nothing can be done. Also, don't - remove the execute file if we get some sort of internal error. - - * sys4.unx (fsysdep_get_work, usysdep_get_work_free): David - Nugent: after we've processed all the work files we found - initially, rescan the work directory to pick up any that may have - come in in the meantime. Also, reset iSwork_file to 0 in - usysdep_get_work_free so that we can handle more than one system. - - * tstuu.c, uucico.c (main, fwait_for_calls, flogin_prompt): added - -l option to uucico to prompt for the login name and password once - and then exit. - -Tue Dec 17 00:24:41 1991 Ian Lance Taylor (ian@airs.com) - - * uucp.h, uucico.c, uuxqt.c, uux.c, uucp.c, config.c - (uread_config), log.c (ulog): eliminated ulog_program and added - abProgram and ulog_to_file. Made log messages output to stderr - more Unix like. - - * log.c (ulog): use a fixed number of fields in a log file message - by replacing a missing system or user with '-'. - - * port.h, chat.c (renamed fchat_send to fcsend), bnu.c - (fbnu_read_dialer_info), prtinf.c (tpcomplete), sys2.unx - (fsysdep_modem_close), uuchk.c (ukshow_dialer): T. William Wells: - change the modem complete and abort strings into chat scripts. - - * sys2.unx (fsserial_open): on BSD start in RAW mode to avoid - dropping characters when we switch over. I originally thought - being able to use XON/XOFF was worth the risk; I no longer think - so. - - * tstuu.c (uprepare_test): have shell script sleep before printing - the login name to make sure the second system has finished - flushing its input buffer. - - * protg.c (fginit_sendbuffers), prott.c (ftsendcmd): David Nugent: - avoid sending confidential information by zeroing out memory - buffers before using them. - - * sysinf.c (tirequest, titransfer), prtinf.c (tpseven_bit, - tpreliable, tpdtr_toggle): Marc Unangst: several functions did not - accept true and false as boolean strings, contradicting the - documentation. - - * uucp.h, system.h, sysh.unx, sys1.unx (usysdep_full_time), file.c - (fstore_sendfile, fsent_file, fstore_recfile, freceived_file), - log.c (ustats): generate statistics in microseconds instead of - seconds for more accurate time keeping. - - * sys2.unx (fsserial_open): David Nugent: flush pending input - when a serial port is opened. This will clear out a - NO\sCARRIER string left by a previous dropped connection. - -Mon Dec 16 11:26:17 1991 Ian Lance Taylor (ian@airs.com) - - * uucico.c (main), uuxqt.c (main), tstuu.c (main, uchild): David - Nugent: ignore SIGHUP in uucico and uuxqt, so that they are - unaffected by the parent shell closing down and by the remote - terminal dropping the connection. - - * bnu.c (ubnu_read_sysfiles, ubnu_read_systems, fbnu_find_port, - fbnu_read_dialer_info): Mike Bernson: ignore lines that begin with - whitespace, fix compilation error. - -Sat Dec 14 20:59:10 1991 Ian Lance Taylor (ian@airs.com) - - * sys2.unx (fsserial_open): don't turn on ISTRIP initially. - - * uucp.h, sysinf.c, chat.c (icexpect), uuchk.c (ukshow_chat): - added chat-seven-bit command to allow control over whether - parity bits are stripped out of chat scripts. - - * uucp.h, port.h, chat.c (fchat, fcprogram), - config.c (tprocess_one_cmd), prtinf.c, - sysinf.c (tichat, tprocess_chat_cmd), - bnu.c (fbnu_read_dialer_info), port.c (fpdo_dial), - uucico.c (fdo_call, faccept_call) uuchk.c (ukshow_chat): - changed processing of chat commands to go through - tprocess_chat_cmd, avoiding repetition. All chat script - information is now held in an schat_info structure. - Eliminated the fchat_program function, renaming it fcprogram - and making it static to chat.c (it is now called via fchat). - Added CMDTABTYPE_PREFIX. Added INIT_CHAT macro to initialize - chat script information. Added TTYPE_CMDTABTYPE and - CARGS_CMDTABTYPE to eliminate hex constants in - tprocess_one_cmd. - - * sys5.unx (zsysdep_get_xqt): Oleg Tabarovsky: don't stop - processing files just because opendir failed on one; it could just - be because we don't have read permission. - -Fri Dec 13 17:43:52 1991 Ian Lance Taylor (ian@airs.com) - - * config.c (uprocesscmds): don't continually allocate and free the - array of arguments. - -Thu Dec 12 12:46:01 1991 Ian Lance Taylor (ian@airs.com) - - * prot.c (fgetcmd): Franc,ois Pinard: don't bother to give an - error if the final HY doesn't come in; apparently the MtXinu UUCP - doesn't send it. - - * chat.c (icexpect, fchat_send): Franc,ois Pinard: add some chat - script debugging messages. - - * log.c (ulog): David Nugent: move ERROR: from the start of the - line to after the date and time; this makes it easier to use awk - on log files. - - * sys3.unx (fsdo_lock), sys1.unx (usysdep_initialize): do locking - using link rather than O_CREAT | O_EXCL to avoid race conditions - and to safely run as the superuser. - - * sys3.unx (fsysdep_move_file): fcopyfile now creates the - destination file with IPRIVATE_MODE, so we don't need to chmod to - it. - - * sys1.unx (usysdep_initialize, fsysdep_other_config): set the - GID as well as the UID, in case anybody wants to run this as a - setgid package. - -Wed Dec 11 10:03:22 1991 Ian Lance Taylor (ian@airs.com) - - * conf.h, uucp.h, util.c (strtol): Mark Powell: added my own - version of strtol to util.c, for systems which lack it. - - * protg.c (fgstart, fgexchange_init): if we start resending - packets during initialization, don't forget which packets we have - already seen; otherwise the other side may assume we've already - seen them while we're looking for them. - -Tue Dec 10 15:42:41 1991 Ian Lance Taylor (ian@airs.com) - - * conf.h, sysh.unx, log.c (ulog, ustats), tstuu.c (uprepare_test): - Arne Ludwig: merged in Arne Ludwig's patches to support V2 and BNU - style logging, with some minor additions and changes. - - * sys1.unx, sys3.unx, sys5.unx, uux.c, uucp.c, uucico.c, copy.c, - uucp.h, system.h: create directories when necessary rather than - assuming that they exist. Added fmkdirs argument to esysdep_fopen - and fcopy_file, changing all calls. Added fpublic argument to - fsysdep_make_dirs, changing all calls. Moved fsysdep_make_dirs - and fsdirectory_exists from sys3.unx to sys1.unx. Added checks - for ENOENT in several places in sys3.unx and sys5.unx. - - * log.c, port.c (fport_open), sys2.unx (fsserial_open): added - ulog_device routine to record device name. This is currently only - used for the BNU statistics file, but more uses might arise later. - - * file.c, log.c, uucp.h: moved statistics file routines from - file.c to log.c in preparation for supporting BNU log file - routines. - -Mon Dec 9 12:00:52 1991 Ian Lance Taylor (ian@airs.com) - - * bnu.c (ubnu_read_systems): Arne Ludwig: the device entry for a - system can be followed by a comma and a list of protocols. - - * sysh.unx, sys3.unx (fsdo_lock): Richard Todd: add - HAVE_V2_LOCKFILES, in which the process ID is written out in - binary. - - * uuxqt.c (uqdo_xqt_file): Richard Todd: the requestor address is - relative to the requesting system. - - * config.c (uprocesscmds, umulti_pushback): Richard Todd: each - line pushed back because of "#" is local to a particular - smulti_file structure. - - * prtinf.c (asPdialer_cmds): Richard Todd: exit the current dialer - if the special command "#" is seen. A similar thing should be put - in for ports, but it's marginally more complex. - - * config.c (uprocesscmds): Richard Todd: don't warn if the special - "#" command is unrecognized. - -Sat Dec 7 13:05:40 1991 Ian Lance Taylor (ian@airs.com) - - * config.c (uprocesscmds): Franc,ois Pinard: don't limit the - number of arguments to a command! - - * chat.c (fchat): handle a chat script which consists only of a - single string. - -Fri Dec 6 16:11:29 1991 Ian Lance Taylor (ian@airs.com) - - * sys5.unx (fsysdep_execute): David J. Fiander: if execve fails - with ENOEXEC, try using /bin/sh with a quoted argument. - - * uux.c (main): split arguments the way /bin/sh does. If any - shell metacharacters appears, request uuxqt to execute the command - using /bin/sh. - - * tstuu.c (uprepare_test): allow the uux to test to send a failure - message. - - * uuxqt.c (uqdo_xqt_file): don't send mail on successful execution - unless specifically requested; pay attention to the 'n' line - which requests mail on success; ignore the 'Z' line because it - now specifies the default action. - - * sys1.unx (usysdep_initialize), sys6.unx (zsysdep_add_cwd): - Franc,ois Pinard: getcwd may legitimately fail, so only give an - error if we really need the result. - - * chat.c (ccescape): Franc,ois Pinard: ccescape should never - return a negative number, since the callers don't know how to deal - with that. - -Mon Dec 2 16:26:16 1991 Ian Lance Taylor (ian@airs.com) - - * bnu.c (ubnu_read_systems): Dave Buck: time strings with grades - were parsed in an endless loop! - - * sys3.unx (fsdo_lock, fsdo_unlock): the alloca when using LOCKDIR - was one byte too small. - - * config.c (tprocess_one_cmd): pass 10 to strtol rather than 0 to - avoid surprises if a leading zero is used. - - * prtinf.c (tpproto_param, tpdialer_proto_param): Niels Baggesen: - the ``protocol-parameter'' command didn't work for ports or - dialers. - -Sun Dec 1 09:46:12 1991 Ian Lance Taylor (ian@airs.com) - - * tstuu.c: don't use the fd_set typedef at all. - - * tstuu.c (uprepare_test): don't read V2 or BNU configuration - files while testing. - - * bnu.c, v2.c, config.c (uread_config): David Nugent: even if the - code was compiled with HAVE_TAYLOR_CONFIG, read the V2 and BNU - configuration files if the code was compiled to support them. - - * uuchk.c (fkshow_port): Bob Izenberg: report dialer/token pairs - correctly. - -Sat Nov 30 17:40:00 1991 Ian Lance Taylor (ian@airs.com) - - * tstuu.c: Bob Izenberg: copied over conditional definitions of - EAGAIN and EWOULDBLOCK from sys2.unx. - - * bnu.c (fbnu_read_dialer_info): Niels Baggesen: accept dialers - with no substitutions. - - * bnu.c (ubnu_read_systems, ubadd_perm): Niels Baggesen: don't - free up zline in ubadd_perm; in fact, changed the calling sequence - to not even pass zline in at all. - - * bnu.c (ubadd_perm): Niels Baggesen: didn't handle multiple - MACHINE= and multiple LOGNAME= values in a single Permissions - line, because it was clobbering the machine name while processing - the first logname. - - * bnu.c: Made zread and zwrite elements of sperm structure const - char * to avoid warning. - - * copy.c, sys1.unx, sys2.unx, sys3.unx, sys5.unx, tstuu.c: Niels - Baggesen: don't multiply include <unistd.h>. Eventually there - should be a macro controlling whether it gets included at all, for - non-POSIX systems. - - * sys3.unx (fsysdep_get_status, isysdep_get_sequence): Marty - Shannon: accept a truncated status file. I also eliminated scanf - calls in sys3.unx, since that was the only place it was called; - this was to make the executables smaller for systems which cared. - - * bnu.c (ubnu_read_sysfiles): Marty Shannon: accept comment - characters in Sysfiles. - - * sysh.unx, sys3.unx: Marty Shannon: added HAVE_RENAME, put a fake - rename system call in sys3.unx. - - * prtinf.c (ffind_port): Marty Shannon: failed to handle multiple - ports in the port file since I forgot to reset my pointer - variable. - - * bnu.c (ubnu_read_systems): Marty Shannon: don't initialize the - auto array abpubdir, since old cc didn't permit initialization of - auto aggregates. - -Mon Nov 25 20:56:39 1991 Ian Lance Taylor (ian@airs.com) - - * tstuu.c: Bob Denny: add definitions for FD_SET, FD_ZERO and - FD_ISSET. - - * config.c: Bob Denny: add explicit externs for strcmp and - strcasecmp. - - * sys2.unx: the fread_blocking and fwrite_blocking fields were - not getting initialized correctly in the TCP support routines. - - * sysh.unx, sys2.unx, sys5.unx, tstuu.c: Marty Shannon: added - configuration option HAVE_SYSWAIT_H. - - * bnu.c (fbnu_find_port, fbnu_read_dialer_info), v2.c - (fv2_find_port): Marty Shannon: the ireliable field of ports - and dialers was not getting initialized. - -Sun Nov 24 15:06:37 1991 Ian Lance Taylor (ian@airs.com) - - * tcp.c (itcp_port_number): Michael Haberler: wasn't calling - htons if passed a numeric string. - -Sat Nov 23 13:43:52 1991 Ian Lance Taylor (ian@airs.com) - - * Released version 1.01 to alt.sources and uunet - diff --git a/gnu/libexec/uucp/Makefile b/gnu/libexec/uucp/Makefile index 23d6e1a..9f39c61 100644 --- a/gnu/libexec/uucp/Makefile +++ b/gnu/libexec/uucp/Makefile @@ -1,10 +1,6 @@ # This is the Makefile for Taylor UUCP # $FreeBSD$ -# subdir 'sample' called by /usr/src/etc/Makefile -SUBDIR= libunix libuucp libuuconf \ - doc \ - cu uuchk uucico uuconv uucp uulog uuname uupick uusched \ - uustat uuto uux uuxqt +SUBDIR= libunix libuucp libuuconf cu .include <bsd.subdir.mk> diff --git a/gnu/libexec/uucp/NEWS b/gnu/libexec/uucp/NEWS deleted file mode 100644 index 738068e..0000000 --- a/gnu/libexec/uucp/NEWS +++ /dev/null @@ -1,154 +0,0 @@ -Changes in version 1.06: - - As usual, many bugs were fixed. - - Support was added for the 'y' protocol, contributed by Jorge Cwik, - the designer of the protocol. - - The name of command files was changed when using SPOOLDIR_TAYLOR; - they now use a much longer sequence number. This affects the - jobid strings reported by uustat. The change makes uux and uucp - more efficient. - - Added ``called-timegrade'' command to sys file. - - Added --nostop and -E/--escape options to cu. - - Added -s option to uuchk. - - Added ``strip-login'' and ``strip-proto'' commands to config file. - - uux will now create a poll file if invoked as ``uux SYSTEM!''. - - If an execution fails, the data file is saved, if there is enough - free disk space. - - uux now uses POSIX file locking, if available, when locking the - sequence file. - - The man pages were incorporated into the Texinfo manual. - - The UUCP Internals FAQ was incorporated into the Texinfo manual. - - The spool directory layout is now documented in the Texinfo - manual. - -Changes in version 1.05: - - As usual, many bugs were fixed. - - Support was added for the UUPC/extended 'v' protocol. - - Initial hardware flow control support was added, contributed by - Peter Wemm. - - A new port type, ``pipe'', was added; this sends data to a program - such as rlogin, and was contributed by Marc Boucher. - - The programs all now accept long option names with a leading --. - They all support --help and --version. - - uuxqt now saves execution files it can not parse in - $(SPOOLDIR)/.Corrupt. - - If a received file can not be moved to the final location, and - there is enough disk space, it is kept in the spool directory. - - A run-uuxqt command was added to config, to permit specifying when - uuxqt should be run. - - The 'i' protocol has a new ack-frequency protocol parameter. The - remote-window protocol parameter was removed, as it did not work - correctly. - - Chat scripts now permit /W in an expect string to set the timeout. - - TCP ports now support the ``dialer-sequence'' command. - - Direct ports now support the ``carrier'' command. - - Some support was added to read UUCP passwords from /etc/passwd, - and to use encrypted passwords. - - uucico now accepts a -C argument to only call a system named by -S - or -s if there is work for it. - - uucico accepts a -i TLI argument to use TLI I/O calls on standard - input. - - uucico accepts a -u argument to set the user name. - - uucico accepts a -z argument to try the next alternate if a call - fails. - - uustat accepts a -R argument to rejuvenate each listed job. - - Mailer configuration was moved from configure checking to - policy.h. - - Support was added for QNX, contributed by Joe Wells. - -Changes in version 1.04: - -IMPORTANT: the default when talking to another version of 1.04 is to -use the new bidirectional 'i' protocol. If you are using a -half-duplex modem, such as a Telebit T2500, you will want to either -mark the port as half-duplex with the ``half-duplex'' command, or -force use of the 'g' protocol by using the ``protocol'' command in the -sys or port file or by adding ``,g'' after the port name in the -Systems or L.sys or Devices file. - - As usual, many bugs were fixed. - - Bidirectional transfers are supported with the new 'i' protocol; - it requires an eight-bit clear datapath. - - New programs: uusched, cu, uuto and uupick. - - The 'G' protocol and a new Zmodem protocol were added. - - A number of uustat options were added to support uuclean, and a - sample uuclean shell script was added to the contrib directory. - The uustat output formats were changed slightly. - - A protocol extension eliminates transfer of the command file for - simple commands, such as rmail or rnews, when talking to another - version of 1.04. - - Some TLI support was added. - - UUCP forwarding was added, along with the ``forward-to'', - ``forward-from'' and ``forward'' commands. - - If a file transfer fails in the middle, the retry will now start - from where it left off. The implementation is compatible with - SVR4. - - The work queue is checked every 10 minutes during a conversation; - if there is new work and a bidirectional protocol is not in use, - the receiving uucico requests the sender to transfer control. - - The amount of free disk space is checked periodically as a file is - received, and if it drops too low the call is aborted. - - The UUCP configuration file reading routines were moved into a - standalone library, uuconf. All known bugs in V2 and HDB - configuration file reading were fixed. - - The ``half-duplex'' command was added for the port and dialer - files. - - The ``max-retries'', ``success-wait'', ``send-request'' and - ``receive-request'' commands were added for the sys file. The - ``call-request'' and ``called-request'' commands were eliminated - (they did not work correctly anyhow). - - \d in chat scripts now calls sleep (2) rather than sleep (1), so - it will sleep longer (on some systems sleep(1) may delay much less - than one second). - - SPOOLDIR_SVR4 was added for SVR4 style spool directories. - - Defaults are now permitted in the port and dialer files. - - The ALIAS field is supported in the HDB Permissions file. diff --git a/gnu/libexec/uucp/README b/gnu/libexec/uucp/README deleted file mode 100644 index 3297da3..0000000 --- a/gnu/libexec/uucp/README +++ /dev/null @@ -1,173 +0,0 @@ -This is the README file for version 1.06 of the Taylor UUCP package. - -It was written by Ian Lance Taylor. I can be reached at ian@airs.com, -or, equivalently, uunet!cygint!airs!ian, or c/o Cygnus Support, -48 Grove Street, Somerville, MA 02144, USA. - -There is a mailing list for discussion of the package. The list is -hosted by Eric Schnoebelen at cirr.com. To join (or get off) the -list, send mail to taylor-uucp-request@cirr.com. Mail to this address -is answered by the majordomo program. To join the list, send the -message ``subscribe ADDRESS'' where ADDRESS is your e-mail address. -To send a message to the list, send it to taylor-uucp@cirr.com. The -old list address, taylor-uucp@gnu.ai.mit.edu, will also work. There -is an archive of all messages sent to the mailing list at ftp.cirr.com. - -This package is covered by the Gnu Public License. See the file -COPYING for details. If you would like to do something with this -package that you feel is reasonable but you feel is prohibited by the -license, contact me to see if we can work it out. - -The most recent version may be obtained from any Gnu archive site. -The canonical site is prep.ai.mit.edu. There are many mirror sites, -including ftp.uu.net and wuarchive.wustl.edu. - -WHAT IT IS - -This is the complete source code for a Unix UUCP package. It provides -everything you need to make a UUCP connection. It includes versions -of uucico, uusched, uuxqt, uux, uucp, uustat, uulog, uuname, uuto, -uupick, and cu, as well as uuchk (a program to check configuration -files), uuconv (a program to convert from one type of configuration -file to another) and tstuu (a test harness for the package). - -This is the standard UUCP package of the Free Software Foundation. - -The package currently supports the 'f', 'g' (in all window and packet -sizes), 'G', 't' and 'e' protocols, as well a Zmodem protocol, the FX -UUCICO 'y' protocol, and two new bidirectional protocols. If you have -a Berkeley sockets library, it can make TCP connections. If you have -TLI libraries, it can make TLI connections. It supports a new -configuration file mechanism which I like (but other people dislike). - -The package has a few advantages over regular UUCP: - - You get the source code. - - It uses significantly less CPU time than many UUCP packages. - - You can specify a chat script to run when a system calls in, - allowing adjustment of modem parameters on a per system basis. - - You can specify failure strings for chat scripts, allowing the - chat script to fail immediately if the modem returns ``BUSY''. - - If you are talking to another instance of the package, you can use - the new bidirectional protocol for rapid data transfer in both - directions at once. You can also restrict file transfers by size - based on the time of day and who placed the call. - -On the other hand: - - It only runs on Unix. The code is carefully divided into system - dependent and system independent portions, so it should be - possible to port it to other systems. It would not be trivial. - - You don't get uuclean, uusend, uuq, uusnap, uumonitor, uutry, - uupoll, etc. If you have current copies of these programs, you - may be able to use them. Shell scripts versions of uuclean and - uutry are provided, with most, if not all, of the functionality of - the usual programs. I believe the supplied uustat program allows - you to do everything that uuq, uusnap and uumonitor do. uupoll - could be written as a shell script. - - The package does not read modemcap or acucap files, although you - can use V2 configuration files with a BNU Dialers file or a dialer - file written in my new configuration file format. - - The package cannot use SCO dialer programs directly, although it - can with a simple shell script interface. - -If you start using this package, I suggest that you join the mailing -list (see above) to keep up to date on patches and new versions. I am -also open to suggestions for improvements and modifications. - -DOCUMENTATION - -The documentation is in the file uucp.texi, which is a Texinfo file. -Texinfo is a format used by the Free Software Foundation. You can -print the documentation using TeX in combination with the file -texinfo.tex. DVI, PostScript and info versions of the documentation -are available in a separate package, uucp-doc-1.06.tar.gz. - -See the TODO file for things which should be done. Please feel free -to do them, although you may want to check with me first. Send me -suggestions for new things to do. - -The compilation instructions are in uucp.texi. Here is a summary. - - Edit Makefile.in to set installation directories. - - Type ``sh configure''. You can pass a number of arguments in the - environment (using bash or sh, enter something like ``CC=gcc - configure''; using csh, enter something like ``setenv CC gcc; sh - configure''): - CC: C compiler to use; default is gcc if it exists, else cc - CFLAGS: Flags to pass to $CC when compiling; default -g - LDFLAGS: Flags to pass to $CC when only linking; default none - LIBS: Library arguments to pass to $CC; default none - INSTALL: Install program; default install -c or cp - The configure script will compile a number of test programs to see - what is available on your system, so if your system is at all - unusual you will need to pass in $CC and $LIBS correctly. - - The configure script will create config.h from config.h.in and - Makefile from Makefile.in. It will also create config.status, - which is a shell script which actually creates the files. Please - report any configuration problems, so that they can be fixed in - later versions. - - Igor V. Semenyuk provided this (lightly edited) note about ISC - Unix 3.0. The configure script will default to passing -posix to - gcc. However, using -posix changes the environment to POSIX, and - on ISC 3.0, at least, the default for POSIX_NO_TRUNC is 1. This - means nothing for uucp, but can lead to a problem when uuxqt - executes rmail. IDA sendmail has dbm configuration files named - mailertable.{dir,pag}. Notice these names are 15 characters long. - When uuxqt compiled with -posix executes rmail, which in turn - executes sendmail, the later is run under POSIX environment too! - This leads to sendmail bombing out with 'error opening 'M' - database: name too long' (mailertable.dir). It's rather obscure - behaviour, and it took me a day to find out the cause. I don't - use -posix, instead I run gcc with -D_POSIX_SOURCE, and add - -lcposix to LIBS. - - On some versions of BSDI there is a bug in the shell which causes - the default value for CFLAGS to be set incorrectly. If ``echo - ${CFLAGS--g}'' echoes ``g'' rather than ``-g'', then you must set - CFLAGS in the environment before running configure. There is a - patch available from BSDI for this bug. (Reported by David - Vrona). - - On AIX 3.2.5, and possibly other versions, cc -E does not work, - reporting ``Option NOROCONST is not valid.'' Test this before - running configure by doing something like - touch /tmp/foo.c - cc -E /tmp/foo.c - This may give a warning about the file being empty, but it should - not give the ``Option NOROCONST'' warning. The workaround is to - remove the ",noroconst" entry from the "options" clause in the - "cc" stanza in /etc/xlc.cfg. (Reported by Chris Lewis). - - Examine config.h and Makefile to make sure they're right. - - Edit policy.h for your local system. - - Type ``make''. - - Use ``uuchk'' to check configuration files. You can use - ``uuconv'' to convert between configuration file formats. - - Type ``make install'' to install. Note that by default the - programs are compiled with debugging information, and they are not - stripped when they are installed. Read the man page for strip for - more information. - - On older System V based systems which do not have the setreuid - system call, problems may arise if ordinary users can start an - execution of uuxqt, perhaps indirectly via uucp or uux. UUCP jobs - may wind up executing with a real user ID of the user who invoked - uuxqt, which can cause problems if the UUCP job checks the real - user ID for security purposes. On such systems, it is safest to - put ``run-uuxqt never'' in the `config' file, so that uucico never - starts uuxqt, and invoke uuxqt directly from cron. diff --git a/gnu/libexec/uucp/TODO b/gnu/libexec/uucp/TODO deleted file mode 100644 index f1bed5f..0000000 --- a/gnu/libexec/uucp/TODO +++ /dev/null @@ -1,777 +0,0 @@ -This is a list of things to do for the Taylor UUCP package. Please -feel free to work on any of them. You may want to check with me first -to make sure that nobody else is working on them as well. - -Some of these are my thoughts, but most are suggestions from other -people; I have tried to give credit. They are in the order I received -them; the missing numbers have already been implemented. - -Just because something is on the list doesn't mean that I necessarily -think it is a good idea. It does mean that I think it's worth -thinking about. - -2. - -John Cowan <cowan@snark.thyrsus.com> says: - ->I think you should accept a broader range of time specifications. ->Consider using getdate() (from your handy Usenet news source code) ->with its high-powered yacc parser. - -Of course, getdate() accepts a single date, but we want a range. A -better syntax would be certainly be nice. - -9. - -Gordon Burditt <gordon@sneaky.lonestar.org> warns about modifications -to the TZ environment variable, to fool uucico into dialing out at an -inappropriate time. - -10. - -Gordon Burditt <gordon@sneaky.lonestar.org> says: - ->(4) Less important, because few people will have this problem, is a ->port-specific dialcodes file. Why? Well, one system I had was connected ->to 2 inside lines "dial 9 for outside line", and one outside line (which ->doesn't want the 9). A number of the systems called were "inside", so ->you didn't add the 9 on those lines dialing from inside, but you did add ->"390" to the 4-digit number if you dialed it via "outside". Also not ->unheard of are systems with 2 outside lines that are local to different ->area codes, or one local outside line and one WATS line (which MUST ->have an area code). ->Example: -> inside-line Dialcodes outside-line Dialcodes -> pbx "" pbx "390" -> local "9" local "" -> nyc "9-1212" nyc "1212" - -12. - -Ralf E. Stranzenbach <ralf@reswi.ruhr.de> says: - ->It would be nice to also have the option of running a shell script each time ->uucico connects/disconnects a systen. I do not mean shell scripts for dial/in. ->I would like to do some accounting and batching when the connection ->establishes. - -13. - -les@chinet.chi.il.us (Leslie Mikesell) writes: - ->>local-send /usr/spool/uucppublic !/usr/spool/uucpublic/private ->> ->>The directories are searched from left to right, and the last one to ->>match determines whether the file may be sent or not. This is ->>slightly more general than NOWRITE, since it permits a public ->>directory within a private directory within a public directory, ->>although probably nobody will ever want that. -> ->Interesting... The obvious enhancement is to generalize to shell-like ->wild cards for the READ/WRITE/COMMANDS entries. - -14. - -Should there be a way for chat scripts to specify the parity to -generate? I don't think there's much point to specifying what parity -to accept. - -17. - -The -b and -s switches to uux are not implemented by uuxqt. - -18. - -If we are supposed to call a system back, we should do it immediately -rather than merely queuing up an empty command file. - -22. - -Add an ftp port type which uses anonymous ftp rather than any of the -UUCP protocols to do file transfers. This would allow ftp work to be -done late at night, and allow neighbors of cooperative Internet sites -to use UUCP forwarding for anonymous FTP. - -32. - -It would be nice if uucico could sleep until a line was available. -This is complicated by the possibility of wanting to wait for any of -several different lines, and one would really want some sort of -semaphore function to do it right. If the available lines could be -sorted, then each could be assigned to a byte in a line lock file. -Looking for a line could be done by sleeping on a read lock on all -possible lines. Once it came through, write locks would be attempted. -If they all failed, somebody else snuck in, so you would sleep on a -read lock again. This isn't great because a process could be starved, -but it might be better than nothing. - -This could be tied in to uucp and uux, such that they wouldn't -actually fire up uucico unless a line was known to be available; an -additional switch would be used to fire up uucico anyhow (or one could -switch the default behaviour and the switch). - -So how do you sort the lines? You could just use the index in the -port (or Devices) file, but what if multiple ports used the same -physical device? Hmmm. - -43. - -David Nugent: it would be nice to be able to set debugging, log, and -statistics files on a site by site basis. -Brian Murrell: heck, set those files on a port by port basis as well. - -74. - -Yanek Martinson: allow each system to independently choose whether to -permit shell execution. - -81. - -Marty Shannon: log reason for dial failure (chat-fail string) in -.Status file. - -83. - -Switch between 'M' and 'S' correctly in the BNU log file output. - -86. - -Les Mikesell: allow a separate program to be specified to handle the -communications with a particular system. - -105. - -T. William Wells: close and open the Debug file after each file -transfer. Alternatively, cycle through a series of Debug file names -every 1000 lines or so. - -106. - -Marty Shannon: add a time command for ports, to specify when they may -be used. - -115. - -T. William Wells: new options for uustat: - -i display job ids only -Also, there should perhaps be a configuration option to request uustat -to only display jobs submitted by the user running uustat, except for -root and uucp. - -117. - -Marc Unangst: provide some way to change the debugging level of a -running uucico. T. William Wells suggests having it read a file to -change arbitrary configuration information, although obviously one has -to be careful of what gets changed while a connection is active. - -120. - -Jarmo Raiha: new chat-fail commands: one to not update the status file -and require a retry wait, and one to permit the string to occur a few -times before reporting an error. - -124. - -Peter da Silva: perhaps there should be a ``chat-end-program'' command -to let a program be run after the initial handshake has been completed -and the protocol has been selected and turned on. This would let -people run stty to change their terminal parameters. - -128. - -Richard Stallman: have an interactive program to set up a chat script. -It would let you type directly to the port, recording what you type as -send strings and recording what comes back from the other side as -expect strings. - -129. - -Use POSIX fcntl locks when possible instead of creating a lock file. - -138. - -T. William Wells: BNU apparently uses a file named A.whatever to hold -the line number reached in current C. file processing. This is a -hack, and won't work right with size control anyhow, but -fsysdep_did_work could, for example, clobber the first byte in the -line to a # or something to mark that it had been finished. Still a -hack, but a better one. - -139. - -Patrick Smith: incorporate patches to generate full debugging traces -with less debugging file overhead. The debugging file repeats too -much information at great length right now--not good. - -141. - -Franc,ois Pinard: batch up pauses and delays in chat scripts and do -them all at once in a single system call. This is particularly useful -for pauses on systems which don't support subsecond sleeps. For -everything else it's a fairly minor optimization. - -142. - -Franc,ois Pinard: give uustat an option to requeue jobs to another -system. This only makes a lot of sense for rmail executions, but it's -fairly easy to do for any type of command. I think uucico does all -the file checking needed to ensure that this doesn't break security, -but that should be double-checked. - -144. - -T. William Wells: add a -g option to uucico to permit specifying the -maximum grade to be transferred at that time. This could restrict the -timegrade command further, but should not be permitted to override it. - -145. - -T. William Wells: if uucico or uuxqt get started with bad arguments, -put an indication in the log file since stderr may be /dev/null. - -146. - -Richard Todd: it would be nice to sometimes be able to request the -other side to turn on debugging. - -147. - -Bart Schaefer: some more possible options for uucico: - -R reverse roles (hangup immediately). Not too exciting. - some method to restrict calling to particular systems. - -148. - -Jarmo Raiha: some method to control the work queue at the remote end. -This could get awfully general, though. - -149. - -The interaction of the time command and defaults can be confusing, -since any time command in the actual system entry, even a fairly -specific one, will wipe out the default entry. Not sure what can be -done about this. - -150. - -Jarmo Raiha: should there be some way to specify modem initialization -strings when uucico is hanging on a port with -l or -e? This would -presumably require a new type of chat script associated with a dialer. - -151. - -Petri Helenius: log complete CONNECT string reported by modem, so that -the baud rate is recorded in the log file. - -152. - -Marc Evans: let the protocol selection be based on the CONNECT string, -so that different protocols could be selected based on what type of -connection was made. - -153. - -Chris Lewis: provide a signal to get a core dump even on systems which -won't do core dumps if the uid is not the euid. One could catch a -signal, call setuid (getuid ()), and then raise the signal again. -Unfortunately the core dump has to wind up in a directory which is -world writable, so that the process is able to create the core file, -but is not world readable, since that would permit anybody to read the -core dump file and extract private information from it. - -154. - -Les Mikesell: write a new version of dial.o, with provisions for -running a chat script. - -155. - -Scott Blachowicz: perhaps there should be some way to telling uucico -to not log certain errors. This could get fairly complex, though. - -156. - -Franc,ois Pinard: have uustat -m report the time of the last -successful conversation when reporting a failure. - -158. - -Thomas Fischer: should there be a way to completely disable an entry -in the sys, port or dial file? Such as a ``disable'' command? - -159. - -Petri Helenius: when uuxqt -s is invoked, lock uuxqt for the system so -that only one uuxqt is invoked per system. If the -c option is used, -don't lock on a per system basis, and ignore any per system locks -(regardless of -s). If neither option is used, respect existing -system and command locks, and do any other type of file. - -161. - -Scott Blachowicz: provide some sort of include mechanism for the -configuration files. - -164. - -Ed Carp: preserve files if uuxqt execution fails. - -165. - -Marc Sheldon: use exit codes from <sysexits.h> in uux and uucp. - -166. - -Chip Salzenberg: allow chat failure strings to specify a retry time. - -168. - -Jose A. Manas: allow a maximum connect time, after which we try to -hang up the connection. This requires a protocol extension, since -there's no way to force the other side to hang up. The best we can do -without an extension is refuse to send any new jobs ourselves. Of -course, we could just drop the connection. - -169. - -Franc,ois Pinard: when given uustat -k00FC, check each possible job ID -and use it if there is an unambiguous one. - -170. - -T. William Wells: if ! HAVE_SETREUID && ! HAVE_SAVED_SETUID, fork a -subprocesses to revoke setuid and read the file over a pipe. - -171. - -Provide some option to have the internal uuconf functions not start -with an underscore. - -172. - -T. William Wells: have some way to configure the parity for cu. - -173. - -Gert Doering: uuchk should display unknown system information. - -175. - -T. William Wells: -Cu will not let itself be interrupted before the connection is -established. If the chat script doesn't write something, cu does -something odd, I've forgotten exactly what. Cu takes an -inordinate amount of time after the line drops to exit. Somebody, -cu, I think, but maybe uucico, drops dtr twice sometimes. Again, -somebody will attempt to write after a hangup signal has been -received. Once a hangup has been received, I/O should not be -attempted. Among other things this will save the bacon of those -who have brain damaged serial drivers (FAS, sigh, is among them) -that don't handle output properly on a dropped line. - -Me: -Note that sometimes you do want to write to a line after receiving a -hangup signal. For example, you might want to use ATZ to reset a -modem. - -176. - -Hans-Dieter Doll: provide some way (another escape sequence) to pass -the protocol to a chat-program. Or, allow the protocol as an argument -to the chat script command, which is more general, but maybe a bit too -fancy. - -177. - -Nickolay Saukh: use a default port for cu, you can just do ``cu -number''. - -180. - -Nickolay Saukh: if we have received a partial file, request the remote -system to start sending from that point. We currently accept SVR4 -style remote file positioning requests, but we do not generate them. - -181. - -Mark Powell: provide some way to restrict file transfer by size as -well as grade? One way would be to let uux select the grade based on -the file size. - -182. - -Mark Powell: permit using multiple timetables in a single time -statement. - -183. - -Optionally check for interrupts in fcopy_file, since it can take a -long time to copy a file named in a uucp request. - -185. - -A syntax error in a command received from the remote system should not -hold up the queue. Unfortunately, I don't know what can be done -except deny the command and report it. Reporting a garbled command -error should report the command correctly, rather than just the first -character. - -186. - -Franc,ois Pinard: have an option to control nostop vs. stop on the cu -command line. - -187. - -Fix the notion of %nostop to be SVID compatible. - -188. - -Frank Conrad: provide a means to set the strip mode for a port, to -make it easy to use it from cu. - -189. - -Marc Unangst: there should be a way to specify that a system should -only be called if there are jobs of a certain grade, but if the system -is called then jobs of any grade should be transferred. This -basically means splitting the ``timegrade'' command into two commands: -``place-call-timegrade'' and ``transfer-timegrade''. Or maybe another -optional argument to ``timegrade'': - timegrade grade time-string [retry] [transfer-any] -not to mention - time time-string [retry] [transfer-any] -Or maybe a separate command for a system or port like - transfer-any BOOL - -190. - -Chip Salzenberg: it would be really nice if uucico could automatically -figure out when it could use an E command, so that uux didn't have to -generate it and so that uucico could use with other versions of uux. -Unfortunately, it would require uucico to read the execution file to -see if it were suitable; this would be complex, but it would probably -be worth it since normally the execution file would wind up not being -sent. Of course, the current method works too; it's just harder to -combine with other versions of UUCP. - -191. - -Brian J. Murrell: should there be a way to cu a specific alternate? - -192. - -Andrew A. Chernov: Perhaps cu -pport system should be able to try -different alternates for the system, because there might be different -phone numbers to try. - -193. - -Brian J. Murrell: it would be nice to be able to ^C a cu chat script -if you know it's going to fail. Right now you have to use ^\. - -194. - -Steven S. Dick: have some way to force uucico off the phone at a -certain time. If that is done, it might be cool to have some way to -predict how long a file transfer will take, and not do it if it will -take too long. But, if doing file restart, you can just quit and then -pick it up later. - -195. - -Franc,ois Pinard: if the disk fills up, or some other error occurs, -while receiving a file, perhaps it would make sense to turn the -connection around immediately and see if the other side had anything -to do, and then try again later. This would require a protocol -extension. I don't know if it's worth it. The code should be checked -to see how well it handles a disk full situation. - -197. - -Try alternate IP addresses if there are any. - -198. - -Lele Gaifax: mention the device in Stats, and provide some way to -associate the entry in Log with the entry in Stats. - -199. - -Michael Richardson: provide some way to turn on parity for the login -chat, since some systems apparently require it. Provide some way for -cu to control parity after connecting. - -200. - -Chip Salzenberg: add max-remote-debug to config. - -201. - -Gert Doering: change the timeout message in chat scripts to reflect -which chat script timed out (dialer or login). - -202. - -Bill Foote: have uuchk check whether a system is defined more than -once. - -203. - -Eric Ziegast: allow specification of the minimum grade to receive, as -well as the maximum grade. Probably sending a second character after -the -pM argument would work fine. - -204. - -Tom Rushworth: perhaps there should be some program which can be used -to retrieve the current spool directory. Perhaps on option on uustat. - -207. - -James B. O'Connor: use additional messages in the status file when -placing a call, such as Dialing, Chatting, and the like. Slightly -less efficient. - -208. - -When checking whether a file may be received into a directory, perhaps -uucico should check using the real user ID rather than insisting that -the directory be world writable. This should be a policy.h parameter. -This would enable sites which use different uids for each incoming -UUCP login to have better control over security. - -209. - -Jon Vos: add an alias command for ports. - -210. - -Joe Wells: I'd like to have a way so that if the dial chat fails due -to "NO CARRIER", in addition to this log message: - - ERROR: Chat script failed: Got "NO\sCARRIER" - -I would get another log message right next to it that would look like -this: - - ERROR: Chat script failed: 5 "RRING" strings seen - -Ian: I doubt this is worth implementing in uucico, but it might make -sense for an external, or otherwise more independent and controllable, -chat program. - -211. - -Joe Wells: In some cases it would be nice to be able to change the set -of chat-fail strings in the middle of the chat script. Personally, I -think this is too complex for the simple chat scripts currently -implemented. - -212. - -Joe Wells: There should be an option to all programs directing them to -send all debugging output to the log file. This would just involve -calling ulog_to_file at some point just after reporting any usage -messages. - -213. - -Joe Wells: There should be a way to specify the execution directory -used by uuxqt. This would avoid certain sorts of permissions -problems. Some mechanism would still be needed for using multiple -directories. - -214. - -Joe Wells: uuto should be documented. - -215. - -Joe Wells: Perhaps it should be possible to use multiple spool -directories. It would be a lot of work, though. - -216. - -Joe Wells: It should be possible to specify only one of complete or -abort. - -217. - -Dan Everhart: It would be nice if the chat-fail string could affect -the error message reported by uustat, so that uustat could say -something ``Line was busy''. - -218. - -Andrew A. Chernov: Add a chat-char-delay xx configuration parameter, -which has the effect of adding \p after each character, with delay xx. -This is to accommodate modems which can't accept command characters at -a given baud rate. - -219. - -Gert Doering: Provide some mechanism for specifying the maximum length -of a call. Convenient for anonymous UUCP sites. - -220. - -Joe Wells: There should be some way for "cu" to obey user commands -during the dial chat. Right now, the only thing the user can do is -send signals (e.g. type Control-C). This leads to user complaints -that "cu" is not obeying its documentation. - -221. - -Joe Wells: Right now, if there is any failure in the dial or login -chat scripts, the remote system alternate is skipped even though the -cause of the failure may have been the local serial port or modem. -"uucico" will not try another modem with the same remote system -alternate. If the remote system only has one alternate, then it is -skipped entirely. - -Thus, there should be a way to specify that when certain expect -strings are not seen or certain chat-fail strings are seen that the -port is skipped instead of the remote system alternate. - -222. - -Richard H. Gumpertz: Support pipelines in uuxqt. Right now they are -only supported if uux puts in an 'e' line (which it does) and shell -executions are permitted (which they normally are not). It would be -possible to permit restricted pipelines by handling the pipe character -specially and making sure all commands in the pipeline were permitted. - -223. - -Bill Sommerfeld: When dialing out, set the status to DIALING rather -than CONNECTION CLOSED. Setting the status takes a bit of time; it's -hard to tell where the right break-even point is. - -224. - -Joe Wells: Keep track of the last successful incoming call separately -from the last successful outgoing call. Currently the two times are -both put together in the status file. - -225. - -Joe Wells: It would be nice if uustat would provide a way to avoid -bouncing mail that it sent itself, to avoid sending notification -e-mail for notification e-mail. I can't think of a mechanism, though -(using a special grade for uustat does not work because most mail -programs do not provide a mechanism for passing a grade through to -uux). - -226. - -Joe Wells: It would be nice if uustat could know whether it had sent -mail for a particular job, to avoid generating multiple messages for -the job. - -227. - -Joe Wells: It would be nice if dialcode suffixes were supported, as -well as prefixes. - -228. - -Joe Wells: It would be nice to support another spool directory scheme -which split stuff up more to avoid very large directories. This would -be most useful for the files which are named in C. and X. files, -rather than for the C. and X. files themselves (since C. and X. files -are rarely looked up by name). Basically, some sort of partition of -the D. directory is called for. - -229. - -Joe Wells: ``It would be nice if the exit sequence of "cu", where it -runs the complete chat script and then disconnects could be aborted -without disconnecting. (Yes, I know, this is a strange desire.) It -would be nice to be able to reinvoke the dial chat by user command in -"cu". It would be nice to be able to invoke an arbitrary named chat -script in "cu".'' - -230. - -Kevin Johnson: Provide some mechanism such that all requests to a -particular system were automatically forwarded through some other -system. This would be useful to hide details of a non-strongly- -connected network, particularly if the details were subject to change. - -231. - -Gert Doering: Perhaps it should be possible to -r the default for uucp -and uux. This would require adding a new option to force the -invocation of uucico. - -232. - -Mark Davies: spaces are not handled correctly in the -a argument of -uux. If an E command is generated, the requestor address is not -quoted correctly, nor is it parsed correctly. If an execution file is -generated, the R line is not parsed correctly. - -233. - -Emmanuel Mogenet: provide some mechanism for a maximum number of -garbage bytes during a chat script before giving up. - -234. - -Scott Ballantyne: The address for a TCP port should be separate from -the phone number, so that a TCP dialer can use \D. - -235. - -Peter Wemm: The 'i' protocol default parameters do not work at 2400 -baud, because the time it takes to transfer half the packets is less -than the timeout time. Of course people can always change the -parameters, but it would be nice if this were dealt with somehow. - -236. - -Andrew A. Chernov: Perhaps uuxqt should log when it terminates. - -237. - -dialer-sequence doesn't really do the right thing. There is no way to -specify both the TCP address and a phone number. - -238. - -cu -t doesn't work at all. It does nothing. - -239. - -Paul Pryor: Perhaps a service command should be added to the sys and -port files. This command would be used as ``service cu'' to indicate -that the system or port was only available to cu, not to UUCP. - -240. - -Tim Iverson: The 'g' and 'i' protocol code tends to parse data packet -headers twice. It processes them once to find out how large the -packet is, waits for that data to arrive, and then processes the -header again the second time around. It would be possible to avoid -this by changing the code to be a simple state machine which -remembered where it was in the process of parsing the packet. - -241. - -Klaus Dahlenburg: Log a more precise reason for failure in the .Status -file: e.g., all ports in use, no matching ports, etc. - -242. - -Steven S. Dick: It would be helpful if there was a way to get uuchk to -dump the data from ports/dialers/etc that was NOT picked up from the -sys file. In other words, add some option to scan the port file and -the dial file, presumably using uuconf_find_port for the former and -uuconf_dialer_names for the latter. - -243. - -Kai Michael Kretschmann: Add a configure option to drop the connection -if jobs are coming in too slowly, indicating a bad connection. diff --git a/gnu/libexec/uucp/VERSION b/gnu/libexec/uucp/VERSION deleted file mode 100644 index 6e1a45b..0000000 --- a/gnu/libexec/uucp/VERSION +++ /dev/null @@ -1,4 +0,0 @@ -Version 1.06.1 - -a complete, unmodified version of this program is available from -prep.ai.mit.edu. diff --git a/gnu/libexec/uucp/common_sources/trans.h b/gnu/libexec/uucp/common_sources/trans.h deleted file mode 100644 index d057ab2..0000000 --- a/gnu/libexec/uucp/common_sources/trans.h +++ /dev/null @@ -1,288 +0,0 @@ -/* trans.h - Header file for file and command transfer routines. - - Copyright (C) 1992, 1993, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* The maximum possible number of channels. */ -#define IMAX_CHAN (16) - -/* The ifeatures field of the sdaemon structure is an or of the - following values. These values are sent during the uucico - handshake, and MUST NOT CHANGE. */ - -/* File size negotiation. */ -#define FEATURE_SIZES (01) - -/* File transfer restart. */ -#define FEATURE_RESTART (02) - -/* The E (execute) command. */ -#define FEATURE_EXEC (04) - -/* Version 1.03: requires decimal size in S and R command. Needless - to say, this should not be used by any new programs. */ -#define FEATURE_V103 (010) - -/* SVR4 UUCP: expects dummy string between notify field and size field - in send command. There is probably some meaning to this string, - but I don't know what it is. If I ever find out, this flag will - still be used to indicate it. */ -#define FEATURE_SVR4 (020) - -/* This structure is used to hold information concerning the - communication link established with the remote system. */ - -struct sdaemon -{ - /* Global uuconf pointer. */ - pointer puuconf; - /* Configuration file name argument (from -I option). */ - const char *zconfig; - /* How often to spawn uuxqt (from uuconf_runuuxqt). */ - int irunuuxqt; - /* Remote system information. */ - const struct uuconf_system *qsys; - /* Local name being used. */ - const char *zlocalname; - /* Connection structure. */ - struct sconnection *qconn; - /* Protocol being used. */ - const struct sprotocol *qproto; - /* Number of channels being used. */ - int cchans; - /* The largest file size permitted for a local request. */ - long clocal_size; - /* The largest file size permitted for a remote request. */ - long cremote_size; - /* The largest file size that may ever be transferred. */ - long cmax_ever; - /* The remote system ulimit. */ - long cmax_receive; - /* Number of bytes sent. */ - long csent; - /* Number of bytes received. */ - long creceived; - /* Number of execution files received since the last time we spawned - uuxqt. */ - long cxfiles_received; - /* Features supported by the remote side. */ - int ifeatures; - /* TRUE if we should request the remote side to hang up. */ - boolean frequest_hangup; - /* TRUE if the remote side requested a hangup. */ - boolean fhangup_requested; - /* TRUE if we are hanging up. */ - boolean fhangup; - /* TRUE if the local system is currently the master. */ - boolean fmaster; - /* TRUE if the local system placed the call. */ - boolean fcaller; - /* UUCONF_RELIABLE_* flags for the connection. */ - int ireliable; - /* If fcaller is FALSE, the lowest grade which may be transferred - during this call. */ - char bgrade; -}; - -/* This structure is used to hold a file or command transfer which is - in progress. */ - -struct stransfer -{ - /* Next file transfer in queue. */ - struct stransfer *qnext; - /* Previous file transfer in queue. */ - struct stransfer *qprev; - /* Points to the queue this structure is on. */ - struct stransfer **pqqueue; - /* The function to call to send some data. */ - boolean (*psendfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon)); - /* The function to call when data is received. */ - boolean (*precfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); - /* Type specific information. */ - pointer pinfo; - /* TRUE if we are sending the file e (this is used to avoid a call - to psendfn). */ - boolean fsendfile; - /* TRUE if we are receiving the file e (this is used to avoid a call - to precfn). */ - boolean frecfile; - /* The file to read or write. */ - openfile_t e; - /* The position we are at in the file. */ - long ipos; - /* TRUE if we are waiting for a command string. */ - boolean fcmd; - /* The command string we have so far. */ - char *zcmd; - /* The length of the command string we have so far. */ - size_t ccmd; - /* Local destination number. */ - int ilocal; - /* Remote destination number. */ - int iremote; - /* The command. */ - struct scmd s; - /* A message to log when work starts. */ - char *zlog; - /* The process time; imicros can be negative. */ - long isecs; - long imicros; - /* Number of bytes sent or received. */ - long cbytes; -}; - -/* Reasons that a file transfer might fail. */ - -enum tfailure -{ - /* No failure. */ - FAILURE_NONE, - /* No permission for operation. */ - FAILURE_PERM, - /* Can't open necessary file. */ - FAILURE_OPEN, - /* Not enough space to receive file. */ - FAILURE_SIZE, - /* File was received in a previous conversation. */ - FAILURE_RECEIVED -}; - -/* The main loop which talks to the remote system, passing transfer - requests and file back and forth. */ -extern boolean floop P((struct sdaemon *qdaemon)); - -/* Allocate a new transfer structure. */ -extern struct stransfer *qtransalc P((struct scmd *qcmd)); - -/* Free a transfer structure. */ -extern void utransfree P((struct stransfer *qtrans)); - -/* Queue up local requests. If pfany is not NULL, this sets *pfany to - TRUE if there are, in fact, any local requests which can be done at - this point. */ -extern boolean fqueue P((struct sdaemon *qdaemon, boolean *pfany)); - -/* Clear away any queued requests. This may be called more than once - at the end of a call. */ -extern void uclear_queue P((struct sdaemon *qdaemon)); - -/* Queue a new transfer request made by the local system. */ -extern boolean fqueue_local P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* Queue a new transfer request made by the remote system. */ -extern boolean fqueue_remote P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* Queue a transfer request which wants to send something. */ -extern boolean fqueue_send P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* Queue a transfer request which wants to receiving something. */ -extern boolean fqueue_receive P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* Prepare to send a file by local or remote request. */ -extern boolean flocal_send_file_init P((struct sdaemon *qdaemon, - struct scmd *qcmd)); -extern boolean fremote_send_file_init P((struct sdaemon *qdaemon, - struct scmd *qcmd, - int iremote)); - -/* Prepare to receive a file by local or remote request. */ -extern boolean flocal_rec_file_init P((struct sdaemon *qdaemon, - struct scmd *qcmd)); -extern boolean fremote_rec_file_init P((struct sdaemon *qdaemon, - struct scmd *qcmd, - int iremote)); - -/* Prepare to request work by local or remote request. */ -extern boolean flocal_xcmd_init P((struct sdaemon *qdaemon, - struct scmd *qcmd)); -extern boolean fremote_xcmd_init P((struct sdaemon *qdaemon, - struct scmd *qcmd, - int iremote)); - -/* We have lost the connection; record any in progress file transfers - in the statistics file and discard any temporary files. */ -extern void ufailed P((struct sdaemon *qdaemon)); - -/* Check that there is enough disk space for a file receive. Return - FALSE if there is not. */ -extern boolean frec_check_free P((struct stransfer *qtrans, - long cfree_space)); - -/* Discard the temporary file being used to receive a file, if - appropriate. */ -extern boolean frec_discard_temp P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* Handle data received by a protocol. This is called by the protocol - specific routines as data comes in. The data is passed as two - buffers because that is convenient for packet based protocols, but - normally csecond will be 0. The ilocal argument is the local - channel number, and the iremote argument is the remote channel - number. Either may be -1, if the protocol does not have channels. - The ipos argument is the position in the file, if the protocol - knows it; for most protocols, this will be -1. The fallacked - argument should be set to TRUE if the remote has acknowledged all - outstanding data; see uwindow_acked, below, for details. This will - set *pfexit to TRUE if there is something for the main loop to do. - A file is complete is when a zero length buffer is passed (cfirst - == 0). A command is complete when data containing a null byte is - passed. This will return FALSE on error. If the protocol pfwait - entry point should exit and let the top level loop continue, - *pfexit will be set to TRUE (if pfexit is not NULL). This will not - set *pfexit to FALSE, so the caller must do that. */ -extern boolean fgot_data P((struct sdaemon *qdaemon, - const char *zfirst, size_t cfirst, - const char *zsecond, size_t csecond, - int ilocal, int iremote, - long ipos, boolean fallacked, - boolean *pfexit)); - -/* This routine is called when an ack is sent for a file receive. */ -extern void usent_receive_ack P((struct sdaemon *qdaemon, - struct stransfer *qtrans)); - -/* A protocol may call this routine to indicate the packets have been - acknowledged by the remote system. If the fallacked argument is - TRUE, then all outstanding packets have been acknowledged; for - convenience, this may also be indicated by passing fallacked as - TRUE to fgot_data, above. Otherwise this routine should be called - each time a complete window is acked by the remote system. The - transfer code uses this information to keep track of when an - acknowledgement of a file receive has been seen by the other side, - so that file receives may be handled cleanly if the connection is - lost. */ -extern void uwindow_acked P((struct sdaemon *qdaemon, - boolean fallacked)); - -/* Spawn a uuxqt process. The ffork argument is passed to - fsysdep_run. If the zsys argument is not NULL, then -s zsys is - passed to uuxqt. The zconfig argument is the name of the - configuration file, from the -I option. */ -extern boolean fspawn_uuxqt P((boolean ffork, const char *zsys, - const char *zconfig)); diff --git a/gnu/libexec/uucp/common_sources/util.c b/gnu/libexec/uucp/common_sources/util.c deleted file mode 100644 index 3e85af9..0000000 --- a/gnu/libexec/uucp/common_sources/util.c +++ /dev/null @@ -1,184 +0,0 @@ -/* util.c - A couple of UUCP utility functions. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char util_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Get information for an unknown system. This will leave the name - allocated on the heap. We could fix this by breaking the - abstraction and adding the name to qsys->palloc. It makes sure the - name is not too long, but takes no other useful action. */ - -boolean -funknown_system (puuconf, zsystem, qsys) - pointer puuconf; - const char *zsystem; - struct uuconf_system *qsys; -{ - char *z; - int iuuconf; - - if (strlen (zsystem) <= cSysdep_max_name_len) - z = zbufcpy (zsystem); - else - { - char **pznames, **pz; - boolean ffound; - - z = zbufalc (cSysdep_max_name_len + 1); - memcpy (z, zsystem, cSysdep_max_name_len); - z[cSysdep_max_name_len] = '\0'; - - iuuconf = uuconf_system_names (puuconf, &pznames, TRUE); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - ffound = FALSE; - for (pz = pznames; *pz != NULL; pz++) - { - if (strcmp (*pz, z) == 0) - ffound = TRUE; - xfree ((pointer) *pz); - } - xfree ((pointer) pznames); - - if (ffound) - { - ubuffree (z); - return FALSE; - } - } - - iuuconf = uuconf_system_unknown (puuconf, qsys); - if (iuuconf == UUCONF_NOT_FOUND) - { - ubuffree (z); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - for (; qsys != NULL; qsys = qsys->uuconf_qalternate) - qsys->uuconf_zname = z; - - return TRUE; -} - -/* Remove all occurrences of the local system name followed by an - exclamation point from the front of a string, returning the new - string. This is used by uucp and uux. */ - -char * -zremove_local_sys (qlocalsys, z) - struct uuconf_system *qlocalsys; - char *z; -{ - size_t clen; - char *zexclam; - - clen = strlen (qlocalsys->uuconf_zname); - zexclam = strchr (z, '!'); - while (zexclam != NULL) - { - if (z == zexclam - || (zexclam - z == clen - && strncmp (z, qlocalsys->uuconf_zname, clen) == 0)) - ; - else if (qlocalsys->uuconf_pzalias == NULL) - break; - else - { - char **pzal; - - for (pzal = qlocalsys->uuconf_pzalias; *pzal != NULL; pzal++) - if (strlen (*pzal) == zexclam - z - && strncmp (z, *pzal, (size_t) (zexclam - z)) == 0) - break; - if (*pzal == NULL) - break; - } - z = zexclam + 1; - zexclam = strchr (z, '!'); - } - - return z; -} - -/* See whether a file is in a directory list, and make sure the user - has appropriate access. */ - -boolean -fin_directory_list (zfile, pzdirs, zpubdir, fcheck, freadable, zuser) - const char *zfile; - char **pzdirs; - const char *zpubdir; - boolean fcheck; - boolean freadable; - const char *zuser; -{ - boolean fmatch; - char **pz; - - fmatch = FALSE; - - for (pz = pzdirs; *pz != NULL; pz++) - { - char *zuse; - - if (pz[0][0] == '!') - { - zuse = zsysdep_local_file (*pz + 1, zpubdir, (boolean *) NULL); - if (zuse == NULL) - return FALSE; - - if (fsysdep_in_directory (zfile, zuse, FALSE, - FALSE, (const char *) NULL)) - fmatch = FALSE; - } - else - { - zuse = zsysdep_local_file (*pz, zpubdir, (boolean *) NULL); - if (zuse == NULL) - return FALSE; - - if (fsysdep_in_directory (zfile, zuse, fcheck, - freadable, zuser)) - fmatch = TRUE; - } - - ubuffree (zuse); - } - - return fmatch; -} diff --git a/gnu/libexec/uucp/contrib/Dial.Hayes b/gnu/libexec/uucp/contrib/Dial.Hayes deleted file mode 100644 index 32eef82..0000000 --- a/gnu/libexec/uucp/contrib/Dial.Hayes +++ /dev/null @@ -1,108 +0,0 @@ -#!xchat -# @(#) dial.hayes V1.1 Tue Sep 1 13:59:58 1992 (Bob Denny) -# -# xchat script for dialing a vanilla Hayes modem -# -# Usage: -# xchat dial.hayes telno -# -# where telno is the telephone number, subject to pause and wait -# character modification. -# -# Uncomment the first two lines after "start:" to get debugging -# in file "Dial.Log" -# -# Flush input, zero counter, set telephone number if supplied, -# else fail if no telephone number given. -# -start: -### dbgfile Dial.Log -### dbgset 15 - zero - flush - ifnstr notelno 0 - telno 0 - goto initmodem -# -# Missing telephone number. -# -notelno: - logerr No telephone number given - failed -# -# Reset the modem to nonvolatile profile. -# Allow 3 sec. for response, as some modems are slow to reset. -# -initmodem: - count - ifgtr cantinit 4 - send ATZ\r - timeout initmodem 3000 - expect setupmodem OK -# -# No response from modem -# -cantinit: - logerr Can't wake modem - failed -# -# Send the stuff needed to initialize the modem to the modes -# needed for the particular modem flavor. The string below -# is provided as a vanilla example. Allow 2 sec. for the -# modem to respond to this command. -# -setupmodem: - sleep 1000 - send ATM0S7=90S11=120\r - timeout setupfail 2000 - expect setupfail ERROR - expect dialnumber OK -# -# Modem barfed or died on setup command. -# -setupfail: - logerr Error in modem setup string - failed -# -# Dial the supplied number. Handle the various errors that -# can come back from the modem by logging the error. -# -dialnumber: - sleep 1000 - send ATDT - dial - send \r - flush - timeout timeout 90000 - expect connected CONNECT - expect busy BUSY - expect nocarrier NO CARRIER - expect noanswer NO ANSWER - expect nodialtone NO DIALTONE -# -# Success! -# -connected: - success -# -# Handle modem dial failures -# -timeout: - logerr Modem or carrier timeout. - failed -busy: - logerr BUSY - failed -nocarrier: - logerr NO CARRIER - failed -noanswer: - logerr NO ANSWER - failed -nodialtone: - logerr NO DIALTONE - failed -# -# end -# - diff --git a/gnu/libexec/uucp/contrib/Hangup.Hayes b/gnu/libexec/uucp/contrib/Hangup.Hayes deleted file mode 100644 index c111c00..0000000 --- a/gnu/libexec/uucp/contrib/Hangup.Hayes +++ /dev/null @@ -1,57 +0,0 @@ -#!xchat -# @(#) Hangup.Hayes V1.1 Tue Sep 1 14:04:25 1992 (Bob Denny) -# -# xchat script for hanging up a Hayes-type modem. When used with Taylor -# UUCP, this script should be run as the dialer-complete and dialer-abort -# script with xchat. -# -# Usage: -# xchat Hangup.Hayes [ x ] -# -# where 'x' is any string. If it is present, this script will log the -# modem reset as an ABORT reset, otherwise it will not log anything. -# -# Uncomment the lines starting with '###' to get debugging log. -# -start: -### dbgfile Hangup.Log -### dbgset 15 - zero - sleep 2000 # Wait for trailing garbage - flush # Toss it out - ifnstr wakemodem 0 # No abort indicator - log Hangup on abort -# -# Get modem's attention via Hayes 'escape' protocol. -# -wakemodem: - sleep 4000 - send +++ - sleep 4000 - send \r - timeout reset 2000 - expect reset OK -# -# We're (probably) in command mode. Use ATZ (reset) to hang up -# as some modems don't behave well with ATH0 command. -# -reset: - send ATZ\r - timeout silent 5000 - expect done OK -# -# Finished, modem is back in initial state. -# -done: - success -# -# No response to escape protocol. Log the error and force DTR low -# in an attempt to get control of the modem. Then send ATZ just to -# make sure. -# -silent: - logerr Hangup: no response from modem - hangup # Force DTR low as last gasp - send ATZ\r - sleep 5000 - failed diff --git a/gnu/libexec/uucp/contrib/Login.LAT b/gnu/libexec/uucp/contrib/Login.LAT deleted file mode 100644 index d557f97..0000000 --- a/gnu/libexec/uucp/contrib/Login.LAT +++ /dev/null @@ -1,137 +0,0 @@ -#!xchat -# @(#) login.LAT V1.2 Tue Sep 1 13:25:28 1992 -# -# xchat script for logging into a VMS system through a LAT -# terminal server port. If no VMS password parameter supplied, -# skips password phase of VMS login. If LAT-password supplied, -# will log into LAT server using that password. NOTE: does not -# handle the situation where a LAT password is needed but no -# VMS password is needed. -# -# Usage: -# xchat login.LAT sysname username [ password [ LAT-password ] ] -# -# History: -# rbd Fri Aug 14 13:37:06 1992 -# Changes for Lantronix ETS-16. It says "type help at the Local> -# prompt..." then it gives the prompt for real! Prompt may need -# to be something other than "Local>". We match the real Local> -# prompt by matching the leading newline! -# -# rbd Tue Sep 1 13:04:32 1992 -# Remove absolute path name from log file. Now defaults per config. -# -start: - dbgfile Login.Log - dbgset 15 - sleep 2000 # Wait 2 seconds - flush # Flush typeahead - ifnstr svrstart 3 # Skip server password if not given -# -# Starting point if server password supplied. Handle situation -# where the server line may have been left waiting for username -# or at local> prompt. -# -getsvrpwp: - zero -l0: - count # Get server's password prompt - ifgtr deadmux 5 # die if 5 cr's don't do it - send \r - timeout l0 1000 # Wait and try again - expect dosvrpw ssword> - expect svrlogin ername> - expect connect \nLocal> -# -# Send server's password. Fail if don't get Username -# or Local> prompt. -# -dosvrpw: - zero -l2: - sendstr 3 - send \r - timeout badsvrpw 5000 # Die if invalid - expect svrlogin ername> - expect connect \nLocal> -# -# Starting point if NO server password supplied. Handle situation -# where the server line may have been left at local> prompt. -# -svrstart: - zero -l1: - count # Get username> or local> prompt - ifgtr deadmux 5 # Die if 5 cr's don't do it - send \r - timeout l1 1000 # Wait and try again - expect svrlogin ername> - expect connect \nLocal> -# -# Server asked for a username. Just give 'uucp'. -# -svrlogin: - send uucp\r - timeout deadmux 2000 - expect connect \nLocal> -# -# At this point, we have the Local> prompt. Send the connect -# command for the specified LAT host service name, and wait for -# VMS "Username:" prompt. Die after 10 seconds. -# -connect: - send c\s - sendstr 0 - send \r - timeout nologin 10000 - expect gotlogin ername: -# -# Got VMS "Username:" prompt. Send the username. If a password -# was given, wait for the "Password:" prompt. Die after 10 seconds. -# if no password was given, we're done! -# -gotlogin: - sendstr 1 - send \r - ifnstr done 2 - timeout nopasswd 10000 - expect gotpasswd ssword: -# -# Got VMS "Password:" prompt. Send the password and we're done! -# -gotpasswd: - sendstr 2 - send \r -# -# Success! -# -done: - success -# -# ERROR HANDLERS -# -# -# LAT server appears dead. Fail. -# -deadmux: - logerr No response from LAT server - failed -# -# The server password was bad. Fail. -# -badsvrpw: - logerr Invalid LAT server password - failed -# -# VMS system appears to be dead. Fail. -# -nologin: - logerr No VMS Username: prompt - failed -# -# Failed to get "Password:" prompt. Fail. -# -nopasswd: - logerr No VMS Password: prompt. Invalid password? - failed - diff --git a/gnu/libexec/uucp/contrib/Login.PortSel b/gnu/libexec/uucp/contrib/Login.PortSel deleted file mode 100644 index d8c3a66..0000000 --- a/gnu/libexec/uucp/contrib/Login.PortSel +++ /dev/null @@ -1,133 +0,0 @@ -#!xchat -# @(#) Login.PortSelUnix V1.0 Tue Sep 1 14:57:05 1992 (Bob Denny) -# -# NOTE: Untested with xchat V1.1. Taken from DECUS UUCP. -# -# From: "Kent C. Brodie" <moocow!brodie@CSD4.MILW.WISC.EDU> -# uucp: {uunet!marque,csd4.milw.wisc.edu}!moocow!brodie -# special script for "uwmcsd4", have to go through a port selector (and then -# log in via standard Unix procedures). -# -# Also included is the ability to wait in the port selector queue. -# Be forwarned that the debug log can get pretty big depending on -# how many times you "wait" in the queue. -# (C) 1989 Kent C. Brodie - Medical College of Wisconsin - -# P0 is systemname , P1 is username, P2 is password. - - zero - -# send a CR to get the selector's attention. Sleep a little bit -# due to large login text of selector. It sends "Which System?" -# when it's ready. - -getprtslct: - count - ifgtr noprtslct 6 - break - send \r - sleep 2000 - flush - expect prtslctok ystem? - timeout getprtslct 15000 - -noprtslct: - logerr Sent cr, no "Which System?" from port selector - failed - -# Send the system name. We either get "OK" (connected), or we -# get "No ports available, would you like to wait?" (wait in queue) - -prtslctok: - zero - sendstr 0 - send \r - expect connected OK - expect prtslctwait wait? - timeout noconnect 10000 - -# Usually we get "nn Your place in queue" messages. JUST in case we -# get a free port right away, check for 'Are you ready?' as well. - -prtslctwait: - zero - send Y\r - expect prtslctque queue - expect prtslctrdy ready? - timeout prtwaitbad 70000 - -prtwaitbad: - logerr Sent "Y" to wait in queue, did not get valid response. - failed - -# Here's where we wait in the queue. The port selector sends us a status -# message about once a minute. We either get "nn Your place in queue" -# or we get "System Available. Are you Ready?". -# If something goes wrong, we time out waiting for either response. -# The reason we don't sleep for 40-50 seconds is because as SOON as the -# port is ready, it informs us. If we wait too long, it drops us. -# This setup is laid out for a maximum of 20 "tries" which is ABOUT -# 20 minutes. Note: This constant retrying can make log files -# kind of big.... - -prtslctque: - count - ifgtr prtslcttry 20 - expect prtslctque queue - expect prtslctrdy ready? - timeout noportwait 70000 - -prtslcttry: - logerr Too many (20) wait/retries -- queue too busy. - failed - -prtslctrdy: - send Y\r - expect connected OK - timeout noconnect 20000 - - -noportwait: - logerr Timed out awaiting place in port queue - failed - -noconnect: - logerr Sent system name, no "OK" from selector - failed - -# standard Unix login stuff. Send cr, expect "ogin:", if no, send a break -# (which tells Unix to try the next bit rate) and try again. - -connected: - send \r - zero - goto waitlogin - -sendbreak: - count - ifgtr nolgi 6 - flush - break - -waitlogin: - expect gotlogin ogin: - timeout sendbreak 5000 - -nolgi: - logerr No login: prompt - failed - -gotlogin: - sendstr 1 - send \r - expect gotword word: - timeout nopwd 10000 - -nopwd: - logerr No password: prompt - failed - -gotword: - sendstr 2 - send \r - success diff --git a/gnu/libexec/uucp/contrib/Login.VMS b/gnu/libexec/uucp/contrib/Login.VMS deleted file mode 100644 index d6196cb..0000000 --- a/gnu/libexec/uucp/contrib/Login.VMS +++ /dev/null @@ -1,96 +0,0 @@ -#!xchat -# @(#) Login.VMS V1.1 Tue Sep 1 13:24:54 1992 (Bob Denny) -# -# -# xchat script for logging into a VMS system. If no VMS password -# parameter supplied, skips password phase of VMS login. If syspass -# parameter given, will go through steps needed to log into a VMS -# system where a "system password" was set on the port. -# -# Cannot handle situation where system password is required but -# no password needed. -# -# -# Usage: -# xchat Login.VMS username [ password [ syspass ] ] -# -# Uncomment the lines starting with "###" to get debug logging. -# -start: -### dbgfile Login.Log -### dbgset 15 - sleep 2000 # Wait 2 seconds - zero - flush # Flush typeahead - ifnstr login 2 # Skip sys passwd if not given -# -# Need system password. Send <CR> to get bell. -# Try 5 times at 2 sec. intervals. Skip to do -# username if we see "Username:". -# -syspass: - count - ifgtr nobell 5 # Fail after 5 tries - send \r - timeout syspass 2000 # Wait 2 sec. and try again - expect gotbell \007 - expect gotlogin Username: -# -# Got the bell. Send the system password. Repeat 5 times -# at 2 sec. intervals. Fail if we don't get Username: -# -gotbell: - zero - sleep 2000 -l1: - count - ifgtr nologin 5 # Fail after 5 tries - sendstr 2 - send \r - timeout l1 2000 # Wait 2 sec. and try again - expect gotlogin Username: -# -# Start here if no system password supplied. -# Send <CR> until we get Username: Try 5 times at 2 sec. intervals. -# -login: - count - ifgtr nologin 5 # Fail after 5 tries - send \r - timeout login 2000 # Wait 2 sec. and try again - expect gotlogin Username: -# -# Got VMS "Username:" prompt. Send the username. If a password -# was given, wait for the "Password:" prompt. Die after 10 seconds. -# if no password was given, we're done! -# -gotlogin: - sendstr 0 - send \r - ifnstr done 1 - timeout nopasswd 10000 - expect gotpasswd Password: -# -# Got VMS "Password:" prompt. Send the password and we're done! -# -gotpasswd: - sendstr 1 - send \r -# -# Success! -# -done: - success -# -# ERROR HANDLERS -# -nobell: - logerr No VMS system password prompt (bell) - failed -nologin: - logerr No VMS Username: prompt - failed -nopasswd: - logerr No VMS Password: prompt. - failed - diff --git a/gnu/libexec/uucp/contrib/Makefile.uurt b/gnu/libexec/uucp/contrib/Makefile.uurt deleted file mode 100644 index 8558977..0000000 --- a/gnu/libexec/uucp/contrib/Makefile.uurt +++ /dev/null @@ -1,40 +0,0 @@ -# $FreeBSD$ -# Makefile for uurate 1.10 -# - -# Prefix directory for installation directories. -prefix = /usr/local - -# Directory where the needed .h files are installed (uucp.h ...). -uucpsrcs = ../ - -# Where uurate is installed -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 -CC=gcc -O2 -CFLAGS=-I.. -Wall -LDFLAGS=-s - -SHELL=/bin/sh -PROGS=uurate - -#----------- -MORECFLAGS= -I. -I$(uucpsrcs) -DNEWCONFIGLIB=\"$(newconfigdir)\" - -all: $(PROGS) - -uurate: uurate.c - $(CC) $(CFLAGS) $(MORECFLAGS) $@.c -o $@ $(LDFLAGS) - -install: $(PROGS) - cp $(PROGS) $(BIN) - cp uurate.man $(MAN)/uurate.1 - -clean: - rm -f $(PROGS) core diff --git a/gnu/libexec/uucp/contrib/Makefile.xchat b/gnu/libexec/uucp/contrib/Makefile.xchat deleted file mode 100644 index 5e9aaa8..0000000 --- a/gnu/libexec/uucp/contrib/Makefile.xchat +++ /dev/null @@ -1,31 +0,0 @@ -# -# Makefile for xchat 1.1 -# -# Bob Denny - Tue Sep 1 15:58:22 1992 -# -CC=cc -SHELL=/bin/sh -BIN=/usr/local/lib/uucp -PROGS=xchat - -#----------- - -all: $(PROGS) - -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 - -clean: - rm -f $(PROGS) core - - - - - diff --git a/gnu/libexec/uucp/contrib/README b/gnu/libexec/uucp/contrib/README deleted file mode 100644 index 8e4651a9..0000000 --- a/gnu/libexec/uucp/contrib/README +++ /dev/null @@ -1,82 +0,0 @@ -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 - driven by scripts which are written in its own little language. - It is a powerful program that can add a lot of flexibility to your - chat scripts. - -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. This version was - tweaked by Stephan Niemz and Klaus Dahlenburg. - -uutraf: - Another program to produce neat reports from your log files, this - one a perl script by Johan Vromans. - -savelog.sh, savelog.man: - A handy shell script to rename a log file and cycle old versions - through a set of names, throwing away the oldest one. It will - also optionally compress the old log files. I believe that this - is originally from smail. It was written by Ronald S. Karr and - Landon Curt Noll, and was given to me by Bob Denny. - -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 - prints the last 80 lines as a nicely formatted table. - -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 - tstuu with the system UUCP on Ultrix 4.0, for reasons that escape - me. Most people will have little use for this. diff --git a/gnu/libexec/uucp/contrib/README-UURATE b/gnu/libexec/uucp/contrib/README-UURATE deleted file mode 100644 index 0ef6375..0000000 --- a/gnu/libexec/uucp/contrib/README-UURATE +++ /dev/null @@ -1,21 +0,0 @@ -uurate V1.10 - Gather and display Taylor UUCP traffic statistics - -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 or sym-link Makefile.uurt to Makefile. - -(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. diff --git a/gnu/libexec/uucp/contrib/README-XCHAT b/gnu/libexec/uucp/contrib/README-XCHAT deleted file mode 100644 index 5f93a28..0000000 --- a/gnu/libexec/uucp/contrib/README-XCHAT +++ /dev/null @@ -1,42 +0,0 @@ -This is xchat V1.1 (Tue Sep 1 15:50:56 1992) - -Introduction: ------------- - -Xchat is a general-purpose dialing and login program designed for use -with Taylor UUCP as a "chat-program", taking the place (or augmenting) -the built-in chat scripting facility. It provides the ability to -closely control timeouts, multiple simultaneous expect strings with -separate actions, extended terminal control, modem command character -pacing, and more. - -When used in conjunction with Taylor UUCP's configuration features, -xchat can provide you the ability to manage the most intricate login, -dial and hangup needs. The scripts are written in a shell-like (well, -sort-of) style with labels, commands, and parameters, easing the task -of writing procedures for complex terminal communications situations. - -Installation: ------------- - -(1) Copy xc-conf.h-dist to xc-conf.h, then edit xc-conf.h to reflect - your condifuration. A description of the settings is in that file. - -(2) Copy Makefile.xchat to Makefile and edit it to set BIN to where - you want xchat installed. - -(2) Do a 'make' to build xchat. - -(3) Do a 'make install' to install it. - -(4) Format and print xchat.8, and install it if you want. - -(5) Print out copies of the scripts in the ./scripts subdirectory. - -(6) Read xchat.8 and the scripts together. - - -Author: ------- - -Robert B. Denny (denny@alisa.com) diff --git a/gnu/libexec/uucp/contrib/amiga.c b/gnu/libexec/uucp/contrib/amiga.c deleted file mode 100644 index d982364..0000000 --- a/gnu/libexec/uucp/contrib/amiga.c +++ /dev/null @@ -1,43 +0,0 @@ -/* 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 deleted file mode 100644 index cb26621..0000000 --- a/gnu/libexec/uucp/contrib/dialHDB.c +++ /dev/null @@ -1,187 +0,0 @@ -/* -# 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/savelog.man b/gnu/libexec/uucp/contrib/savelog.man deleted file mode 100644 index 919b94f..0000000 --- a/gnu/libexec/uucp/contrib/savelog.man +++ /dev/null @@ -1,130 +0,0 @@ -.\" @(#)man/man8/savelog.an 1.2 24 Oct 1990 05:18:46 -.de pP -.if n .sp 1 -.if t .sp .4 -.. -.de tP -.pP -.ta \\n(pDu -.ti -\\n(pDu -.. -.TH SAVELOG X_MAN8_EXT_X "31 January 1988" "Local" -.SH NAME -savelog \- cycle and truncate log files -.SH SYNOPSIS -.na -.B X_UTIL_BIN_DIR_X/savelog -[ -.B \-m -.I mode -] [ -.B \-u -.I user -] [ -.B \-g -.I group -] [ -.B \-c -.I cycle -] [ -.B \-t -] [ -.B \-l -] -.I logfile -.br -.ad -.SH DESCRIPTION -The -.I savelog -command renames and optionally compresses a log file and cycles it -through a set of names based on the original log file, removing the -last name in the cycle. -.SH OPTIONS -The -.I savelog -command accepts the following options: -.TP -\fB\-m\fP \fImode\fP -Change the permissions mode for renamed log files to -.IR mode . -By default the mode is unchanged. -.TP -\fB\-u\fP \fIuser\fP -Change the owner for renamed log files to -.IR user . -By default the owner is unchanged. -.TP -\fB\-g\fP \fIgroup\fP -Change the group for renamed log files to -.IR group . -By default the group is unchanged. -.TP -\fB\-c\fP \fIcycle\fP -Save -.I cycle -versions of the logfile, where -.I cycle -is a decimal number. The default value is 7. -.TP -.B \-l -Do not compress log files. By default, a compression program is used, -if one is available. -.TP -.B \-t -Ensure that a new logfile exists when the savelog operation is -complete. Use of -.BR \-m , -.BR \-u -or -.BR \-g -imply this, ensuring that the logfile will have the designated mode. -.SH "OPERATION" -The given logfile is cycled through files named: -.RS - -OLD/\fIfile\fP.\fInumber\fP - -.RE -where -.I file -is the basename for the logfile and where -.I number -ranges from 0 to one less then the -.I cycle -count specified for the command. -The -.I OLD -dirctory is created, as necessary, and is under the same directory as -the logfile itself. -.PP -This cycle operation is accomplished by renaming the file numbered -.IR cycle -2 -to a file numbered -.IR cycle -1 -and so on until the file numbered 0 is renamed to the file numbered 1. -If compression is being used, the first cycle file is compressed after -being renamed to cycle 1. After the cycle files are moved through the -various names, the filefile itself is moved to the cycle 0 file. -This cycle normally occurs once every time -.I savelog -is executed. -If the log file does not exist, savelog ignores it and does -not cycle the OLD files. -.PP -If compression is being used, then compressed log files will have an -additional suffix appropriate for the compression program that is -used. -.SH "SEE ALSO" -.IR smail (X_MAN5_EXT_X) -and -.IR smail (X_MAN8_EXT_X). -.SH COPYRIGHT -Copyright(C)1987, 1988 Ronald S. Karr and Landon Curt Noll -.br -See a file COPYING, -distributed with the source code, -or type -.I "smail \-bc" -for distribution rights and restrictions -associated with this software. diff --git a/gnu/libexec/uucp/contrib/savelog.sh b/gnu/libexec/uucp/contrib/savelog.sh deleted file mode 100755 index 64c989f..0000000 --- a/gnu/libexec/uucp/contrib/savelog.sh +++ /dev/null @@ -1,247 +0,0 @@ -#! /bin/sh -# @(#)util/savelog.sh 1.4 26 Oct 1991 22:49:39 -# -# savelog - save a log file -# -# Copyright (C) 1987, 1988 Ronald S. Karr and Landon Curt Noll -# -# See the file COPYING, distributed with smail, for restriction -# and warranty information. -# -# usage: savelog [-m mode] [-u user] [-g group] [-t] [-c cycle] [-l] file... -# -# -m mode - chmod log files to mode -# -u user - chown log files to user -# -g group - chgrp log files to group -# -c cycle - save cycle versions of the logfile (default: 7) -# -t - touch file -# -l - don't compress any log files (default: compress) -# file - log file names -# -# The savelog command saves and optionally compresses old copies of files -# into an 'dir'/OLD sub-directory. The 'dir' directory is determined from -# the directory of each 'file'. -# -# Older version of 'file' are named: -# -# OLD/'file'.<number><compress_suffix> -# -# where <number> is the version number, 0 being the newest. By default, -# version numbers > 0 are compressed (unless -l prevents it). The -# version number 0 is never compressed on the off chance that a process -# still has 'file' opened for I/O. -# -# If the 'file' does not exist or if it is zero length, no further processing -# is performed. However if -t was also given, it will be created. -# -# For files that do exist and have lengths greater than zero, the following -# actions are performed. -# -# 1) Version numered files are cycled. That is version 6 is moved to -# version 7, version is moved to becomes version 6, ... and finally -# version 0 is moved to version 1. Both compressed names and -# uncompressed names are cycled, regardless of -t. Missing version -# files are ignored. -# -# 2) The new OLD/file.1 is compressed and is changed subject to -# the -m, -u and -g flags. This step is skipped if the -t flag -# was given. -# -# 3) The main file is moved to OLD/file.0. -# -# 4) If the -m, -u, -g or -t flags are given, then file is created -# (as an empty file) subject to the given flags. -# -# 5) The new OLD/file.0 is chanegd subject to the -m, -u and -g flags. -# -# Note: If the OLD sub-directory does not exist, it will be created -# with mode 0755. -# -# Note: If no -m, -u or -g flag is given, then the primary log file is -# not created. -# -# Note: Since the version numbers start with 0, version number <cycle> -# is never formed. The <cycle> count must be at least 2. -# -# Bugs: If a process is still writing to the file.0 and savelog -# moved it to file.1 and compresses it, data could be lost. -# Smail does not have this problem in general because it -# restats files often. - -# common location -PATH="X_UTIL_PATH_X:X_SECURE_PATH_X"; export PATH -COMPRESS="X_COMPRESS_X" -COMP_FLAG="X_COMP_FLAG_X" -DOT_Z="X_DOT_Z_X" -CHOWN="X_CHOWN_X" -GETOPT="X_UTIL_BIN_DIR_X/getopt" - -# parse args -exitcode=0 # no problems to far -prog=$0 -mode= -user= -group= -touch= -count=7 -set -- `$GETOPT m:u:g:c:lt $*` -if [ $# -eq 0 -o $? -ne 0 ]; then - echo "usage: $prog [-m mode][-u user][-g group][-t][-c cycle][-l] file ..." 1>&2 - exit 1 -fi -for i in $*; do - case $i in - -m) mode=$2; shift 2;; - -u) user=$2; shift 2;; - -g) group=$2; shift 2;; - -c) count=$2; shift 2;; - -t) touch=1; shift;; - -l) COMPRESS=""; shift;; - --) shift; break;; - esac -done -if [ "$count" -lt 2 ]; then - echo "$prog: count must be at least 2" 1>&2 - exit 2 -fi - -# cycle thru filenames -while [ $# -gt 0 ]; do - - # get the filename - filename=$1 - shift - - # catch bogus files - if [ -b "$filename" -o -c "$filename" -o -d "$filename" ]; then - echo "$prog: $filename is not a regular file" 1>&2 - exitcode=3 - continue - fi - - # if not a file or empty, do nothing major - if [ ! -s $filename ]; then - # if -t was given and it does not exist, create it - if [ ! -z "$touch" -a ! -f $filename ]; then - touch $filename - if [ "$?" -ne 0 ]; then - echo "$prog: could not touch $filename" 1>&2 - exitcode=4 - continue - fi - if [ ! -z "$user" ]; then - $CHOWN $user $filename - fi - if [ ! -z "$group" ]; then - chgrp $group $filename - fi - if [ ! -z "$mode" ]; then - chmod $mode $filename - fi - fi - continue - fi - - # be sure that the savedir exists and is writable - savedir=`expr "$filename" : '\(.*\)/'` - if [ -z "$savedir" ]; then - savedir=./OLD - else - savedir=$savedir/OLD - fi - if [ ! -s $savedir ]; then - mkdir $savedir - if [ "$?" -ne 0 ]; then - echo "$prog: could not mkdir $savedir" 1>&2 - exitcode=5 - continue - fi - chmod 0755 $savedir - fi - if [ ! -d $savedir ]; then - echo "$prog: $savedir is not a directory" 1>&2 - exitcode=6 - continue - fi - if [ ! -w $savedir ]; then - echo "$prog: directory $savedir is not writable" 1>&2 - exitcode=7 - continue - fi - - # deterine our uncompressed file names - newname=`expr "$filename" : '.*/\(.*\)'` - if [ -z "$newname" ]; then - newname=$savedir/$filename - else - newname=$savedir/$newname - fi - - # cycle the old compressed log files - cycle=`expr $count - 1` - rm -f $newname.$cycle $newname.$cycle$DOT_Z - while [ "$cycle" -gt 1 ]; do - # --cycle - oldcycle=$cycle - cycle=`expr $cycle - 1` - # cycle log - if [ -f $newname.$cycle$DOT_Z ]; then - mv -f $newname.$cycle$DOT_Z $newname.$oldcycle$DOT_Z - fi - if [ -f $newname.$cycle ]; then - # file was not compressed for some reason move it anyway - mv -f $newname.$cycle $newname.$oldcycle - fi - done - - # compress the old uncompressed log if needed - if [ -f $newname.0 ]; then - if [ -z "$COMPRESS" ]; then - newfile=$newname.1 - mv $newname.0 $newfile - else - newfile=$newname.1$DOT_Z - $COMPRESS $COMP_FLAG < $newname.0 > $newfile - rm -f $newname.0 - fi - if [ ! -z "$user" ]; then - $CHOWN $user $newfile - fi - if [ ! -z "$group" ]; then - chgrp $group $newfile - fi - if [ ! -z "$mode" ]; then - chmod $mode $newfile - fi - fi - - # move the file into the file.0 holding place - mv -f $filename $newname.0 - - # replace file if needed - if [ ! -z "$touch" -o ! -z "$user" -o \ - ! -z "$group" -o ! -z "$mode" ]; then - touch $filename - fi - if [ ! -z "$user" ]; then - $CHOWN $user $filename - fi - if [ ! -z "$group" ]; then - chgrp $group $filename - fi - if [ ! -z "$mode" ]; then - chmod $mode $filename - fi - - # fix the permissions on the holding place file.0 file - if [ ! -z "$user" ]; then - $CHOWN $user $newname.0 - fi - if [ ! -z "$group" ]; then - chgrp $group $newname.0 - fi - if [ ! -z "$mode" ]; then - chmod $mode $newname.0 - fi -done -exit $exitcode diff --git a/gnu/libexec/uucp/contrib/stats.sh b/gnu/libexec/uucp/contrib/stats.sh deleted file mode 100755 index ac1d0f5..0000000 --- a/gnu/libexec/uucp/contrib/stats.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# -# uuspeed - a script to parse a Taylor UUCP Stats file into pretty results. -# Zacharias J. Beckman. - -grep bytes /usr/spool/uucp/Stats | grep -v 'bytes 0.00 secs' | grep -v 'failed after' | tail -80 | \ -gawk ' - BEGIN { - printf(" UUCP transmission history:\n"); - format=" %8d bytes %8s(%8s) in %7.2f sec = %5.0f baud, %4.1fK / min\n"; - average=0.01; - samples=0; - } - - { - if ($6 > 100) { - printf (format, $6, $5, $2, $9, $6/$9*10, ($6/$9*60)/1000); - - average += ($6/$9*10); - samples += 1; - } - } - - END { - printf (" average speed %d baud\n", average/samples); - } -' diff --git a/gnu/libexec/uucp/contrib/tstout.c b/gnu/libexec/uucp/contrib/tstout.c deleted file mode 100644 index 92eca75..0000000 --- a/gnu/libexec/uucp/contrib/tstout.c +++ /dev/null @@ -1,160 +0,0 @@ -/* tstout.c - Put together by Ian Lance Taylor <ian@airs.com> - - This program is used to logout a program run by the tstuu program. - I needed this because on Ultrix 4.0 I can't get the uucp program - to run without invoking it via /bin/login and having it start up - as a shell. If I don't do it this way, it gets a SIGSEGV trap - for some reason. Most systems probably don't need to do things - this way. It will only work on BSD systems anyhow, I suspect. - - The code for this comes from "UNIX Network Programming" by W. - Richard Stevens, Prentice-Hall 1990. Most of it is from 4.3BSD, as - noted in the comments. - - This program must run suid to root. - */ - -/* $FreeBSD$ */ - -#include <stdio.h> -#include <string.h> - -#include <sys/types.h> -#include <sys/file.h> -#include <sys/time.h> -#include <sys/stat.h> -#include <utmp.h> - -static int logout P((const char *zdev)); -static void logwtmp P((const char *zdev, const char *zname, - const char *zhost)); - -int -main (argc, argv) - int argc; - char **argv; -{ - char *z; - - if (argc != 2 - || strncmp (argv[1], _PATH_DEV, sizeof _PATH_DEV - 1) != 0) - { - fprintf (stderr, "Usage: tstout device\n"); - exit (EXIT_FAILURE); - } - - z = argv[1] + 5; - - if (logout (z)) - logwtmp (z, "", ""); - - chmod (argv[1], 0666); - chown (argv[1], 0, 0); - - *z = 'p'; - chmod (argv[1], 0666); - chown (argv[1], 0, 0); - - exit (EXIT_SUCCESS); -} - -/* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)logout.c 5.2 (Berkeley) 2/17/89"; -#endif /* LIBC_SCCS and not lint */ - -#define UTMPFILE "/etc/utmp" - -/* 0 on failure, 1 on success */ - -static int -logout(line) - register const char *line; -{ - register FILE *fp; - struct utmp ut; - int rval; - time_t time(); - - if (!(fp = fopen(UTMPFILE, "r+"))) - return(0); - rval = 0; - while (fread((char *)&ut, sizeof(struct utmp), 1, fp) == 1) { - if (!ut.ut_name[0] || - strncmp(ut.ut_line, line, sizeof(ut.ut_line))) - continue; - bzero(ut.ut_name, sizeof(ut.ut_name)); - bzero(ut.ut_host, sizeof(ut.ut_host)); - (void)time((time_t *)&ut.ut_time); - (void)fseek(fp, (long)-sizeof(struct utmp), L_INCR); - (void)fwrite((char *)&ut, sizeof(struct utmp), 1, fp); - (void)fseek(fp, (long)0, L_INCR); - rval = 1; - } - (void)fclose(fp); - return(rval); -} - -/* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)logwtmp.c 5.2 (Berkeley) 9/20/88"; -#endif /* LIBC_SCCS and not lint */ - -#define WTMPFILE "/usr/adm/wtmp" - -static void -logwtmp(line, name, host) - const char *line, *name, *host; -{ - struct utmp ut; - struct stat buf; - int fd; - time_t time(); - char *strncpy(); - - if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) - return; - if (!fstat(fd, &buf)) { - (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); - (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); - (void)time((time_t *)&ut.ut_time); - if (write(fd, (char *)&ut, sizeof(struct utmp)) != - sizeof(struct utmp)) - (void)ftruncate(fd, buf.st_size); - } - (void)close(fd); -} diff --git a/gnu/libexec/uucp/contrib/uuclean b/gnu/libexec/uucp/contrib/uuclean deleted file mode 100644 index 1cfb633..0000000 --- a/gnu/libexec/uucp/contrib/uuclean +++ /dev/null @@ -1,25 +0,0 @@ -# This is a sample uuclean shell script -# Copyright (C) 1992 Ian Lance Taylor -# Do whatever you like with this script. -# -# Set some variables -bindir=/usr/local/bin -spooldir=/usr/spool/uucp -# -# Warn about all mail over two days old -$(bindir)/uustat -c rmail -o 48 -N -Q -W"Unable to deliver; will try up to one week" -# Return all mail over a week old -$(bindir)/uustat -c rmail -o 168 -K -M -N -Q -W"Could not be delivered for over one week" -# Throw away other requests over a week old -$(bindir)/uustat -o 168 -K -M -N -Q -W"Over one week old" -# Throw away any executions over three days old -$(bindir)/uustat -o 72 -M -N -Q -W"Unable to execute for three days" -# -# Now delete any old spool files -find $(spooldir) -ctime +8 -name '[CDX].*' -print -exec rm -f \{\} \; -# Delete any old temporary files -find $(spooldir) -atime +1 -ctime +1 -name 'TM.*' -print -exec rm -f \{\} \; -# Delete any old preserved files -find $(spooldir)/.Preserve -atime +14 -ctime +14 -print -exec rm -f \{\} \; -# Delete any old failed execution files -find $(spooldir)/.Failed -atime +14 -ctime +14 -print -exec rm -f \{\} \; diff --git a/gnu/libexec/uucp/contrib/uucomp.shar b/gnu/libexec/uucp/contrib/uucomp.shar deleted file mode 100644 index da131d0..0000000 --- a/gnu/libexec/uucp/contrib/uucomp.shar +++ /dev/null @@ -1,552 +0,0 @@ -#! /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 deleted file mode 100644 index 31a8fa6..0000000 --- a/gnu/libexec/uucp/contrib/uudemon.shar +++ /dev/null @@ -1,82 +0,0 @@ -#! /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 deleted file mode 100644 index fa4f72f..0000000 --- a/gnu/libexec/uucp/contrib/uupoll.shar +++ /dev/null @@ -1,2687 +0,0 @@ -#!/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[] = "$FreeBSD$"; -#endif /* not lint */ -X -X/* Log: uupoll.shar,v -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 -X/* $FreeBSD$ */ -X/* Log: uupoll.shar,v -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[] = "$FreeBSD$"; -#endif /* not lint */ -X -X/* Log: uupoll.shar,v -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/uuq.sh b/gnu/libexec/uucp/contrib/uuq.sh deleted file mode 100755 index a5d88e9..0000000 --- a/gnu/libexec/uucp/contrib/uuq.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/sh -# -# uuq - a script to examine and display the Taylor spool directory contents. -# note - uses the uuname script or similar functionality. -# Zacharias Beckman - -SPOOLDIR="/usr/spool/uucp" -SYSTEMS=`uuname` -TMPFILE="/tmp/uuq.tmp" -FORSYSTEM="" -DELETE="" -LONG=0 -SINGLE=0 - -while [ "$1" != "" ] -do - case $1 in - -l) LONG=1 - shift - ;; - -s) shift - SYSTEMS=$argv[1] - SINGLE=1 - shift - ;; - -d) shift - DELETE=$argv[1] - shift - ;; - -h) echo "uuq: usage uuq [options]" - echo " -l long listing (may take a while)" - echo " -s n run uuq only for system n" - echo " -d n delete item n from the queue (required -s)" - exit 1 - ;; - *) echo "uuq: invalid option" - exit 1 - ;; - esac -done - -if [ "${DELETE}" != "" ] && [ ${SINGLE} != 1 ] ; then - echo "uuq: you must specify a system to delete the job from:" - echo " uuq -s wizard -d D.0004" - exit 1 -fi - -cd ${SPOOLDIR} - -# if we are deleting a job, then do that first and exit without showing -# any other queue information - -if [ "${DELETE}" != "" ] ; then - if [ -d ${SYSTEMS}/D. ] ; then - cd ${SYSTEMS}/C. - PACKET=${DELETE} - if [ -f ${PACKET} ] ; then - EXFILE=../D.X/`awk '{if (NR == 2) print $2}' ${PACKET}` - DFILE=../D./`awk '{if (NR == 1) print $2}' ${PACKET}` - echo "deleting job ${PACKET}" - rm ${PACKET} - rm ${EXFILE} - rm ${DFILE} - else - echo "uuq: job ${PACKET} not found" - exit 1 - fi - else - echo "uuq: system ${SYSTEMS} not found" - fi - - exit 1 -fi - -# use the 'uuname' script to obtain a list of systems for the 'sys' file, -# then step through each directory looking for appropriate information. - -if [ ${LONG} -gt 0 ] ; then - echo "system" - echo -n "job# act size command" -fi - -for DESTSYSTEM in ${SYSTEMS} ; do - # if there is an existing directory for the named system, cd into it and - # "do the right thing." - - if [ -d ${DESTSYSTEM} ] ; then - cd ${DESTSYSTEM}/C. - - PACKET=`ls` - - if [ "${PACKET}" != "" ] ; then - # if a long listing has been required, extra information is printed - - echo "" - echo "${DESTSYSTEM}:" - - # now each packet must be examined and appropriate information is - # printed for this system - - if [ ${LONG} -gt 0 ] ; then - for PACKET in * ; do - EXFILE=../D.X/`awk '{if (NR == 2) print $2}' ${PACKET}` - DFILE=../D./`awk '{if (NR == 1) print $2}' ${PACKET}` - echo -n "${PACKET} " > ${TMPFILE} - gawk '{if (NR == 2) printf(" %s ", $1);}' ${PACKET} >> ${TMPFILE} - ls -l ${DFILE}|awk '{printf("%-10d ", $4)}' >> ${TMPFILE} - if [ -f ${EXFILE} ] ; then - gawk '/U / {printf("(%s)", $2);}\ - /C / {print substr($0,2,length($0));}' ${EXFILE} >> ${TMPFILE} - else - echo "---" >> ${TMPFILE} - fi - - cat ${TMPFILE} - done - cat ${SPOOLDIR}/.Status/${DESTSYSTEM} - else - ls - fi - fi - fi - - cd ${SPOOLDIR} -done diff --git a/gnu/libexec/uucp/contrib/uurate.c b/gnu/libexec/uucp/contrib/uurate.c deleted file mode 100644 index 83be734..0000000 --- a/gnu/libexec/uucp/contrib/uurate.c +++ /dev/null @@ -1,1854 +0,0 @@ -/* - * @(#)uurate.c 1.2 - Thu Sep 3 18:32:46 1992 - * - * This program digests log and stats files in the "Taylor" format - * and outputs various statistical data to standard out. - * - * Author: - * Bob Denny (denny@alisa.com) - * Fri Feb 7 13:38:36 1992 - * - * Original author: - * 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. - * 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. - * - * Bob Denny - Sun Aug 30 14:18:50 1992 - * 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.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.2"; -static char rcsid[] = "$FreeBSD$"; -#include <ctype.h> /* Character Classification */ -#include <math.h> -#include "uucp.h" -/* uucp.h includes string.h or strings.h, no include here. */ - -#if HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -#define _DEBUG_ 0 - -/* - * Direction of Calling and Data Transmission - */ - -#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 */ - }; - -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 */ - }; - -struct Execution_Command - { - struct Execution_Command *next; - char Commandname[64]; - 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 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 */ -#if ! HAVE_STDLIB_H - extern pointer *calloc(); -#endif /* HAVE_STDLIB_H */ -/* - * Default files to read. Taken from Taylor compile-time configuration. - * def_logs must look like an argvec, hence the dummy argv[0]. - * Maybe later modified by scanning the config - */ - -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]; - -/* - * Boolean switches for various decisions - */ - - 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 - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - FILE *Log = NULL; - 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, 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 && !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 - - /* - * get some mem to store the default config name (def's are in - * policy.h ) - */ - - 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; - - /* - * Process the command line arguments - */ - - 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 - * 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 (!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) - { - perror(argv[1]); - exit (8); - } - 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)) - { - /* - * 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); - - argc--; - argv++; - } /* end of while (for (argv ....) */ - - /* - * do we have *any* data ? - */ - - if (cur == NULL) - { - puts("\n(I) Sorry! No data is available for any requested report\n"); - exit(0); - } - - /* - * 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 */ - } - } - - /* - * *********** - * * REPORTS * - * *********** - */ - -#if _DEBUG_ - putchar('\n'); -#endif - - /* ------------------------------------------------------------------ - * - * Summary report only when no other report except option -t is given - * - * I know, this code could be tightened (rbd)... - * ------------------------------------------------------------------ - */ - - 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_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_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_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)) ) - { - 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 */ - /* - * 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; - * ------------------------------------------------------------------ - */ - -static void fmtime(dsec, buf) - double dsec; - char *buf; -{ - long hrs, min, lsec; - - 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); - -} - - /* ------------------------------------------------------------------ - * fmbytes - Format size in bytes - * ------------------------------------------------------------------ - */ - -static void fmbytes(n, buf) - unsigned long n; - char *buf; -{ - if ( n == 0 ) - { - strcpy( buf, "0.0" ); - return; - } - sprintf(buf, "%.1f", (double)n / 1000.0); /* Display in Kilobytes */ -} - - - /* ------------------------------------------------------------------ - * 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 deleted file mode 100644 index f6c0399..0000000 --- a/gnu/libexec/uucp/contrib/uurate.man +++ /dev/null @@ -1,280 +0,0 @@ -''' $FreeBSD$ -.TH uurate 1 -.SH NAME -uurate \- Report Taylor UUCP statistics -.SH SYNOPSIS -.BR uurate " [ " "\-acdefhipqtvx" " ] [ " "\-s " -.I host -.RI " ] [ " "\-I " -.I config -.RI " ][ " "logfile..." " ] " -.PP -or simply, -.PP -.B uurate -.PP -for a traffic summary report. -.SH DESCRIPTION -The -.I uurate -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 -call, file transfer, and command execution -.RI "(" "uuxqt" ")" -activity. -.PP -The log and stats files given to -.I uurate -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, -respectively. For reports to be meaningful, the -.I Log -and -.I Stats -files should be given to -.I uurate -together, and cover the same time period. -.PP -If neither the -.B \-i -or -.B \-I -option nor any -.I logfile -options are given, -.I uurate -defaults to taking its input from the current Taylor -.I Log -and -.I Stats -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, 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 -.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 \-d -will print the default config file to be used. -.TP 5 -.B \-e -Report on efficiency (total connect time versus time spent transferring -files). Requires data from both a -.I Log -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 ")." -Requires data from a -.I Log -file. -.TP 5 -.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 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" -If no report options are given, -.I uurate -displays a traffic summary report. This is particularly useful in daily -.I cron -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 -each active host system. The fields are described below: -.PP -.br -.nf -.in +.3i -.ta 1.0i -.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 -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 +.3i -.ta 1.0i -.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. -The fields are described below: -.PP -.br -.nf -.in +.3i -.ta 1.0i -.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, like -.I rmail -and -.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 +.3i -.ta 1.0i -.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 +.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 other than V2/TAYLOR logging formats. Anyone care to -volunteer to add the not mentioned? -.PP -Scanning the arguments of logfile and statfile keywords -in config should handle lines continued with the backslash as well. -.PP -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). -.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.perl b/gnu/libexec/uucp/contrib/uureroute.perl deleted file mode 100755 index 3eeb654..0000000 --- a/gnu/libexec/uucp/contrib/uureroute.perl +++ /dev/null @@ -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/uusnap.c b/gnu/libexec/uucp/contrib/uusnap.c deleted file mode 100644 index 992aa04..0000000 --- a/gnu/libexec/uucp/contrib/uusnap.c +++ /dev/null @@ -1,321 +0,0 @@ -/* uusnap.c - (c) 1992 Heiko W.Rupp hwr@pilhuhn.ka.sub.org - uusnap is a tool to display the activities of the connected - systems. - - Put a file uusnap.systems in NEWCONFIGDIR (see Makefile), in which - the systems, you want to monitor are listed, one on a single line. - The sequence of the files there determine the sequence of the - listing. - - At the moment it only works with taylor config and taylor dirs - - compile it form the Makefile or: - cc -c -g -pipe -O -I. -I. -DNEWCONFIGLIB=\"/usr/local/lib/uucp\" uusnap.c - cc -o uusnap uusnap.o - For this, uusnap.[ch] must be in the same directory as uucp.h and so. - - uusnap must have read access to SPOOLDIR/.Status in order to work. -*/ - -#define MAXSYS 30 /* maximum number of systems */ -#define WAIT_NORMAL 10 /* wait period if noone is talking */ -#define WAIT_TALKING 2 /* refresh display every second if */ - /* someone is talking with us */ - -#include "uucp.h" -#if USE_RCS_ID -char uusnap_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <time.h> -#include <sys/types.h> -#include <sys/dir.h> - -extern char *ctime(time_t*); - -struct sysInfo { - char sysname[10]; /* name of the system to watch */ - char *statfile; /* name of its status file */ - char *spooldir; /* root of its spooldir */ - int in; /* number of unprocessed in-files */ - int out; /* number of files to send them */ - time_t last; /* last poll time */ - time_t next; /* time of next poll */ - time_t lastidir; /* time of last in-spooldir access */ - time_t lastodir; /* time of last outgoing spd acc */ - time_t laststat; /* time of last status file access */ - int status; /* status of the system */ - int num_retries; /* number of retries */ -}; - -struct sysInfo Systems[MAXSYS]; - - -/* I have extend the system status. If time for the specified system - is Never, I say so. To get this to work, one also should extend - uucico.c. It is not important to do this. With the normal uucico, - one only gets no status. -*/ - -const char *azStatus[] = /* Status codes as defined by uucico */ -{ /* listing them here instead of */ - "Conversation complete", /* including the appropriate file */ - "Port unavailable", /* reduces the size of the executable */ - "Dial failed", - "Login failed", - "Handshake failed", - "Call failed", - "Talking", - "Wrong time to call", - "Time to call = Never !" -}; - -main() -{ - int i; - i=get_systems(); - display_info(i); - - exit(0); -} - -int -get_systems() -{ - char filename[1024]; - char fn[1024]; - char line[80]; - FILE *fp; - int i=0; - int j; - struct stat stbuf; - struct sysInfo sys; - - strcpy(filename,NEWCONFIGLIB); - strcat(filename,"/uusnap.systems"); - if ((fp=fopen(filename,"r"))!=NULL) { - while (fgets(line,80,fp)!=NULL) { - *(rindex(line,'\n'))='\0'; - strcpy(sys.sysname,line); /* get the name of the system */ - strcpy(fn,SPOOLDIR); /* get the name of the statusfile */ - strcat(fn,"/.Status/"); - strcat(fn,line); - sys.statfile=malloc(strlen(fn)+1); - strcpy(sys.statfile,fn); - strcpy(fn,SPOOLDIR); /* get the name of the spooldir */ - strcat(fn,"/"); - strcat(fn,line); - sys.spooldir=malloc(strlen(fn)+1); - strcpy(sys.spooldir,fn); - sys.laststat=0; - sys.lastidir=sys.lastodir=0; - Systems[i]=sys; /* get_stat_for_system needs it */ - get_stat_for_system(i); /* now get the system status */ - get_inq_num(i,TRUE); /* number of unprocessed files */ - get_outq_num(i,TRUE); /* number of files to send */ - i++; - } - fclose(fp); - } - else { - fprintf(stderr,"Can't open %s \n",filename); - exit(1); - } - return i; -} - - - -display_info(int numSys) -{ - char *filename; - int sysnum; - FILE *fp; - char contentline[80]; - char isTalking=FALSE; - struct stat stbuf; - struct sysInfo sys; - time_t time; - - filename = (char*)malloc(1024); - if (filename == NULL) { - fprintf(stderr, "Can't malloc 1024 bytes"); - exit(1); - } - - while(TRUE) { - display_headline(); - for (sysnum=0;sysnum<numSys;sysnum++) { - sys = Systems[sysnum]; - stat(sys.statfile,&stbuf); - if ((time=stbuf.st_atime) > sys.laststat) { - get_stat_for_system(sysnum); - } - if(display_status_line(sysnum)==1) - isTalking=TRUE; - } - if (isTalking) { - sleep(WAIT_TALKING); - isTalking = FALSE; - } - else - sleep(WAIT_NORMAL); /* wait a bit */ - } - return 0; -} - -int -display_status_line(int sn) -{ - char *time_s; - - int sys_stat,num_retries,wait; - int i; - time_t last_time; - time_t next_time; - - struct sysInfo sys; - - sys = Systems[sn]; - - printf("%10s ",sys.sysname); - get_inq_num(sn); - if (sys.in==0) - printf(" "); - else - printf("%3d ",sys.in); - get_outq_num(sn); - if (sys.out==0) - printf(" "); - else - printf("%3d ",sys.out); - time_s = ctime(&sys.last); - time_s = time_s + 11; - *(time_s+8)='\0'; - printf("%8s ",time_s); /* time of last poll */ - time_s = ctime(&sys.next); - time_s = time_s + 11; - *(time_s+8)='\0'; - if (sys.last == sys.next) - printf(" "); - else - printf("%8s ",time_s); /* time of next poll */ - if (sys.num_retries==0) - printf(" "); - else - printf("%2d ",sys.num_retries); - if (sys_stat==6) /* system is talking */ - printf("\E[7m"); /* reverse video on */ - printf("%s",azStatus[sys.status]); - if (sys.status==6) { - printf("\E[m\n"); /* reverse video off */ - return 1; - } - else { - printf("\n"); - return 0; - } -} - - -display_headline() -{ - printf("\E[;H\E[2J"); /* clear screen */ - printf("\E[7muusnap (press CTRL-C to escape)\E[m \n\n"); - printf(" System #in #out last next #ret Status\n"); - return 0; -} - -get_inq_num(int num,char firstTime) -{ - int i=0; - char filename[1024]; - struct stat stbuf; - DIR *dirp; - - strcpy(filename,Systems[num].spooldir); - strcat(filename,"/X./."); - stat(filename,&stbuf); - if ((stbuf.st_mtime > Systems[num].lastidir) || (firstTime)) { - if ((dirp=opendir(filename))!=NULL) { - while(readdir(dirp)) - i++; - closedir(dirp); - stat(filename,&stbuf); - Systems[num].lastidir=stbuf.st_mtime; - } - else { - fprintf(stderr,"Can't open %s \n",filename); - exit(1); - } - if (i>=2) - i-=2; /* correct . and .. */ - Systems[num].in=i; - } - return 0; -} - -get_outq_num(int sys,char firstTime) -{ - int i=0; - char filename[1024]; - struct stat stbuf; - DIR *dirp; - - strcpy(filename,Systems[sys].spooldir); - strcat(filename,"/C./."); - stat(filename,&stbuf); - if ((stbuf.st_mtime > Systems[sys].lastodir) || (firstTime)) { - if ((dirp=opendir(filename))!=NULL) { - while(readdir(dirp)) - i++; - closedir(dirp); - stat(filename,&stbuf); - Systems[sys].lastodir=stbuf.st_mtime; - } - else { - fprintf(stderr,"Can't open %s \n",filename); - exit(1); - } - if (i>=2) - i-=2; /* correct . and .. */ - Systems[sys].out=i; - } - return 0; -} - -get_stat_for_system(int i) -{ - char fn[80]; - struct sysInfo sys; - struct stat stbuf; - FILE *fp; - time_t wait; - - sys = Systems[i]; - stat(sys.statfile,&stbuf); - if (stbuf.st_atime > sys.laststat) { - if ((fp=fopen(sys.statfile,"r"))!=NULL) { - fgets(fn,80,fp); - fclose(fp); - sscanf(fn,"%d %d %ld %d", - &sys.status, - &sys.num_retries, - &sys.last, - &wait); - sys.next=sys.last+wait; - } - else { - sys.status=0; - sys.num_retries=0; - sys.last=0; - sys.next=0; - } - stat(sys.statfile,&stbuf); - sys.laststat=stbuf.st_atime; - } - Systems[i] = sys; - return 0; -} diff --git a/gnu/libexec/uucp/contrib/uutraf b/gnu/libexec/uucp/contrib/uutraf deleted file mode 100644 index 00e4b03..0000000 --- a/gnu/libexec/uucp/contrib/uutraf +++ /dev/null @@ -1,210 +0,0 @@ -#!/usr/bin/perl -# uutraf.pl -- UUCP Traffic Analyzer -# SCCS Status : @(#)@ uutraf 1.8 -# Author : Johan Vromans -# Created On : *** -# Last Modified By: Johan Vromans -# Last Modified On: Mon Aug 30 15:02:22 1993 -# Update Count : 6 -# Status : OK -# Requires: : Perl V4 or later - -# Reads UUCP syslog, and generates a report from it. -# -# Created by Johan Vromans <jv@mh.nl> -# Loosely based on an idea by Greg Hackney (hack@texbell.swbt.com) - -# Usage: uutraf [-taylor|-hdb|-bnu|-bsd] [syslog] - -# Logfile formats: -# -# BSD: -# -# jv mhres (2/23-5:18) (698818735) received 135 b 2 secs -# root mhres (2/23-5:19) (698818742) sent 2365 b 3 secs, Pk: 38, Rxmt: 0 -# -# HDB: -# -# uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, \ -# 474 bytes/sec -# -# Taylor: -# -# jv mhres (1992-02-24 20:49:04.06) sent 16234 bytes in 148.780 seconds \ -# (109 bytes/sec) -# jv mhres (1992-02-24 21:04:05.76) received 449 bytes in 6.550 seconds \ -# (68 bytes/sec) - -$uucp_type = "gnu"; - -%hosts = (); # hosts seen -%bytes_in = (); # of bytes received from host -%bytes_out = (); # of bytes sent to host -%secs_in = (); # of seconds connect for recving -%secs_out = (); # of seconds connect for sending -%files_in = (); # of input requests -%files_out = (); # of output requests - -# read info, break the lines and tally - -if ( $ARGV[0] =~ /^-/ ) { - ($uucp_type = substr (shift (@ARGV), 1)) =~ tr/A-Z/a-z/; -} - -if ( $uucp_type eq "taylor" || $uucp_type eq "gnu" ) { - @ARGV = ("/usr/local/spool/uucp/Stats") unless $#ARGV >= 0; - $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/ .]+)\\) " . - "(sent|received) (\\d+) bytes in (\\d+)\\.(\\d+) seconds"; - $uucp_type = 0; - $recv = "received"; -} -elsif ( $uucp_type eq "hdb" || $uucp_type eq "bnu" ) { - @ARGV = ("/usr/spool/uucp/.Admin/xferstats") unless $#ARGV >= 0; - $pat = "^([^!]+)![^(]+\\(([-0-9:\\/]+)\\).+([<>])-? " . - "(\\d+) \\/ (\\d+)\\.(\\d+) secs"; - $uucp_type = 1; - $recv = "<"; -} -elsif ( $uucp_type eq "bsd" || $uucp_type eq "v7" ) { - @ARGV = ("/usr/spool/uucp/SYSLOG") unless $#ARGV >= 0; - $pat = "^[^ ]+ ([^ ]+) \\(([-0-9:\\/]+)\\) \\([^)]+\\) " . - "(sent|received) (\\d+) b (\\d+) secs"; - $uucp_type = 2; - $recv = "received"; -} -else { - die ("FATAL: Unknown UUCP type: $uucp_type\n"); -} - -$garbage = 0; - -while ( <> ) { - unless ( /$pat/o ) { - print STDERR "$_"; - next if /failed/; - if ( $garbage++ > 10 ) { - die ("FATAL: Too much garbage; wrong UUCP type?\n"); - } - next; - } - - # 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} = - $bytes_in{$1} = $bytes_out{$1} = - $secs_in{$1} = $secs_out{$1} = 0; - } - - # Taylor and HDB have milliseconds, BSD has not. - $secs = ($uucp_type == 2) ? ($5 + ($5 == 0 ? 0.5 : 0)) : ($5 + $6/1000); - - # tally - if ( $3 eq $recv ) { # recv - $bytes_in{$1} += $4; - $files_in{$1}++; - $secs_in{$1} += $secs; - } - else { # xmit - $bytes_out{$1} += $4; - $files_out{$1}++; - $secs_out{$1} += $secs; - } - $garbage = 0; -} - -@hosts = keys (%hosts); -die ("No info found, stopped\n") if $#hosts < 0; - -################ report section ################ - -$thishost = &gethostname(); -$thishost = (defined $thishost) ? "on node $thishost" : "report"; - -if ( $uucp_type eq 0 ) { # Taylor UUCP - substr ($first_date, 16) = ""; - substr ($last_date, 16) = ""; -} - -format std_head = -@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -"UUCP traffic $thishost from $first_date to $last_date" - -Remote -----------K-Bytes----------- ----Hours---- --Avg CPS-- --Files-- - Host Recv Sent Total Recv Sent Recv Sent Recv Sent -. -format std_out = -@<<<<<<< @>>>>>>>> @>>>>>>>> @>>>>>>>> @>>>>> @>>>>> @>>>> @>>>> @>>> @>>> -$Zhost, $Zi_bytes, $Zo_bytes, $Zt_bytes, $Zi_hrs, $Zo_hrs, $Zi_acps, $Zo_acps, $Zi_count, $Zo_count -. - -$^ = "std_head"; -$~ = "std_out"; - -&print_dashes (); - -reset "T"; # reset totals - -foreach $host (@hosts) { - &print_line ($host, $bytes_in{$host}, $bytes_out{$host}, - $secs_in{$host}, $secs_out{$host}, - $files_in{$host}, $files_out{$host}); - -} - -&print_dashes (); -&print_line ("Total", $Ti_bytes, $To_bytes, - $Ti_secs, $To_secs, $Ti_count, $To_count); - -################ that's it ################ - -sub print_line { - reset "Z"; # reset print fields - local ($Zhost, - $Zi_bytes, $Zo_bytes, - $Zi_secs, $Zo_secs, - $Zi_count, $Zo_count) = @_; - $Ti_bytes += $Zi_bytes; - $To_bytes += $Zo_bytes; - $Zt_bytes = $Zi_bytes + $Zo_bytes; - $Tt_bytes += $Zt_bytes; - $Zi_acps = ($Zi_secs > 0) ? sprintf ("%.0f", $Zi_bytes/$Zi_secs) : "0"; - $Zo_acps = ($Zo_secs > 0) ? sprintf ("%.0f", $Zo_bytes/$Zo_secs) : "0"; - $Zi_bytes = sprintf ("%.1f", $Zi_bytes/1000); - $Zo_bytes = sprintf ("%.1f", $Zo_bytes/1000); - $Zt_bytes = sprintf ("%.1f", $Zt_bytes/1000); - $Zi_hrs = sprintf ("%.1f", $Zi_secs/3600); - $Zo_hrs = sprintf ("%.1f", $Zo_secs/3600); - $Ti_secs += $Zi_secs; - $To_secs += $Zo_secs; - $Ti_count += $Zi_count; - $To_count += $Zo_count; - write; -} - -sub print_dashes { - $Zhost = $Zi_bytes = $Zo_bytes = $Zt_bytes = - $Zi_hrs = $Zo_hrs = $Zi_acps = $Zo_acps = $Zi_count = $Zo_count = - "------------"; - write; - # easy, isn't it? -} - -################ missing ################ - -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]+$/; - return undef; -} diff --git a/gnu/libexec/uucp/contrib/uutry b/gnu/libexec/uucp/contrib/uutry deleted file mode 100644 index 258bb30..0000000 --- a/gnu/libexec/uucp/contrib/uutry +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# -# This script was hacked together by Marc Evans (marc@Synergytics.Com) -# I claim no copyright to it and don't really care what people do -# with it, hence, it is public domain. I take no responsibility for -# for happens if you use this script, providing no warentee. This -# section of the comments may be removed if you so desire. -# -# Usage: -# uutry [-x#] systemname -# where '-x#' has the value [0-9], higher values providing more detail - -# -# The following variables should be gropped from the configuration -# files rather then being hard coded here. -# -Spool=/usr/spool/uucp -Lib=/usr/local/lib/uucp -Status=$Spool/.Status -Debug=$Spool/Debug -Uucico=$Lib/uucico -# -# Default option values -# -x="-x5" -s="" - -for i in $* ; do - case $i in - -x*) x="$i" ;; - *) s="$i" ;; - esac -done - -if [ x$s != x ]; then - rm -f $Status/$s - $Uucico -r1 $x -s$s & - >$Debug - tail -f $Debug -else - echo "Usage: uutry systemname" - exit 1 -fi diff --git a/gnu/libexec/uucp/contrib/uuxconv b/gnu/libexec/uucp/contrib/uuxconv deleted file mode 100755 index 843f9e0..0000000 --- a/gnu/libexec/uucp/contrib/uuxconv +++ /dev/null @@ -1,50 +0,0 @@ -#!/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/xc-conf.h-dist b/gnu/libexec/uucp/contrib/xc-conf.h-dist deleted file mode 100644 index 8810dd7..0000000 --- a/gnu/libexec/uucp/contrib/xc-conf.h-dist +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ************* - * * XC-CONF.H * - * ************* - * - * Configuration file for xchat 1.1. Edit this file prior to make-ing - * xchat. - * - * History: - * Bob Denny - Tue Sep 1 11:42:54 1992 - */ - -/* - * Edit this to reflect the relative location of xchat sources to - * the main Taylor UUCP source directory. As distributed, xchat - * is in the ./contrib sub-directory under the main Taylor UUCP - * directory. Therefore, Taylor's conf.h is in our parent directory. - */ -#include "../conf.h" - -/* - * The following definition establishes the default path to the - * scripts used by xchat. You may lleave this blank (""), but - * the command line given to xchat (e.g., in the 'sys' file entry) - * must specify a full (absolute) path name to the script to be - * executed. Normally, this is the same place you put your config - * and system files for UUCP. - */ -#define SCRIPT_DIR "/usr/local/conf/uucp/" /* MUST HAVE TRAILING "/" */ - -/* - * The following definition establishes the default path to the - * log files that are produced by the 'dbgfile' statement. Normally - * this is the same location you configured Taylor UUCP to put its - * log files. - */ -#define LOG_DIR "/usr/spool/uucp/" /* MUST HAVE TRAILING "/" */ - diff --git a/gnu/libexec/uucp/contrib/xchat.c b/gnu/libexec/uucp/contrib/xchat.c deleted file mode 100644 index b44549e..0000000 --- a/gnu/libexec/uucp/contrib/xchat.c +++ /dev/null @@ -1,1473 +0,0 @@ -/* - * *********** - * * XCHAT.C * - * *********** - * - * Extended chat processor for Taylor UUCP. See accompanying documentation. - * - * Written by: - * 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. - * - * Bob Denny - Sun Aug 30 18:41:30 1992 - * V1.1 - long overdue changes for other systems. Rip out interval - * timer code, use timer code from Taylor UUCP, use select() - * 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? - */ - -#include <sys/types.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <signal.h> -#include <time.h> -#include <sys/ioctl.h> -#include <sys/termio.h> - -#include "xc-conf.h" - -/* - * Pick a timing routine to use, as done in Taylor UUCP. - */ -#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS || HAVE_POLL -#define USE_SELECT_TIMER 0 -#else -#define USE_SELECT_TIMER HAVE_SELECT -#if USE_SELECT_TIMER -#include <sys/time.h> -#endif -#endif - -#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS -#undef HAVE_POLL -#define HAVE_POLL 0 -#endif - -#if HAVE_USLEEP || HAVE_NAP -#undef HAVE_NAPMS -#define HAVE_NAPMS 0 -#endif - -#if HAVE_USLEEP -#undef HAVE_NAP -#define HAVE_NAP 0 -#endif - -static int ttblind(); -static int ttcd(); - -/* script entry -- "compiled" form of dial, hangup, or login script */ - -struct script { - struct script *next; /* pointer to next entry, or null */ - int opcode; /* numeric opcode */ - char *strprm; /* pointer to string param */ - long intprm; /* integer parameter */ - char *newstate; /* new state name */ -}; - -/* opcode definition array element -- one for each possible opcode */ - -struct script_opdef { - char *opname; - int opcode; /* numeric opcode -- same as array index */ - int prmtype; /* one of SC_NONE, SC_STR, SC_XSTR, SC_INT */ - int newstate; /* one of SC_NONE, SC_NWST */ -}; - - /* values for opcode */ - -#define SC_LABEL 0 /* "label" (state name) */ -#define SC_CDLY 1 /* set char output delay in msec */ -#define SC_PCHR 2 /* pause char for dial string (from P in input) */ -#define SC_PTIM 3 /* seconds to allow for pause char */ -#define SC_WCHR 4 /* wait char for dial string (from W in input) */ -#define SC_WTIM 5 /* seconds to allow for wait char */ -#define SC_ZERO 6 /* zero counter */ -#define SC_INCR 7 /* increment counter */ -#define SC_IFGT 8 /* change state if counter > int param */ -#define SC_WAIT 9 /* wait for int param seconds */ -#define SC_GOTO 10 /* unconditional change to new state */ -#define SC_SEND 11 /* send strparam (after sprintf substitutions) */ -#define SC_BRK 12 /* send a break */ -#define SC_HANG 13 /* drop DTR */ -#define SC_DIAL 14 /* send telno string (after subst PCHR & WCHR) */ -#define SC_DTIM 15 /* time in msec per digit (for timeout calculations) */ - /* default = 100 (one tenth second) */ -#define SC_CTIM 16 /* additional time (in seconds) to wait for carrier */ - /* default = 45 seconds */ -#define SC_EXIT 17 /* script done, success */ -#define SC_FAIL 18 /* script done, failure */ -#define SC_LOG 19 /* write strparam to uucp.log */ -#define SC_LOGE 20 /* write strparam to uucp.log w/error ind */ -#define SC_DBG 21 /* write strparam to debug log if debug lvl = LGI */ -#define SC_DBGE 22 /* write strparam to debug log if debug lvl = LGIE */ -#define SC_DBST 23 /* 'or' intparam into debug mask */ -#define SC_DBCL 24 /* 'bicl' intparam into debug mask */ -#define SC_TIMO 25 /* newstate if no match in intparam secs */ - /* (uses calculated dial time if intparam is 0) */ -#define SC_XPCT 26 /* wait for strparam, goto _newstate if found */ -#define SC_CARR 27 /* goto _newstate if carrier detected */ -#define SC_FLSH 28 /* flush typeahead buffer */ -#define SC_IFBL 29 /* change state if controller is blind w/o CD */ -#define SC_IFBG 30 /* chg state if ctlr is blind and counter > intprm */ -#define SC_SNDP 31 /* send parameter n */ -#define SC_IF1P 32 /* if parameter n present */ -#define SC_IF0P 33 /* if parameter n absent */ -#define SC_DBOF 34 /* open debugging file */ -#define SC_TELN 35 /* Set telno from parameter n */ -#define SC_7BIT 36 /* Set port to 7-bit stripping */ -#define SC_8BIT 37 /* Set port for 8-bit characters */ -#define SC_PNON 38 /* Set port for 8-bit, no parity */ -#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_XPST 42 /* Expect a param string */ -#define SC_END 43 /* end of array */ - - /* values for prmtype, prm2type */ - -#define SC_NONE 0 /* no parameter */ -#define SC_STR 1 /* simple string */ -#define SC_INT 2 /* integer */ -#define SC_NWST 3 /* new state name */ -#define SC_XSTR 4 /* translated string */ - -/* opcode definition table for dial/login/hangup scripts */ - -static struct script_opdef sc_opdef[] = - { - {"label", SC_LABEL, SC_NONE, SC_NONE}, - {"chrdly", SC_CDLY, SC_INT, SC_NONE}, - {"pchar", SC_PCHR, SC_STR, SC_NONE}, - {"ptime", SC_PTIM, SC_INT, SC_NONE}, - {"wchar", SC_WCHR, SC_STR, SC_NONE}, - {"wtime", SC_WTIM, SC_INT, SC_NONE}, - {"zero", SC_ZERO, SC_NONE, SC_NONE}, - {"count", SC_INCR, SC_NONE, SC_NONE}, - {"ifgtr", SC_IFGT, SC_INT, SC_NWST}, - {"sleep", SC_WAIT, SC_INT, SC_NONE}, - {"goto", SC_GOTO, SC_NONE, SC_NWST}, - {"send", SC_SEND, SC_XSTR, SC_NONE}, - {"break", SC_BRK, SC_NONE, SC_NONE}, - {"hangup", SC_HANG, SC_NONE, SC_NONE}, - {"7bit", SC_7BIT, SC_NONE, SC_NONE}, - {"8bit", SC_8BIT, SC_NONE, SC_NONE}, - {"nopar", SC_PNON, SC_NONE, SC_NONE}, - {"evenpar", SC_PEVN, SC_NONE, SC_NONE}, - {"oddpar", SC_PODD, SC_NONE, SC_NONE}, - {"telno", SC_TELN, SC_INT, SC_NONE}, - {"dial", SC_DIAL, SC_NONE, SC_NONE}, - {"dgttime", SC_DTIM, SC_INT, SC_NONE}, - {"ctime", SC_CTIM, SC_INT, SC_NONE}, - {"success", SC_EXIT, SC_NONE, SC_NONE}, - {"failed", SC_FAIL, SC_NONE, SC_NONE}, - {"log", SC_LOG, SC_XSTR, SC_NONE}, - {"logerr", SC_LOGE, SC_XSTR, SC_NONE}, - {"debug", SC_DBG, SC_XSTR, SC_NONE}, - {"debuge", SC_DBGE, SC_XSTR, SC_NONE}, - {"dbgset", SC_DBST, SC_INT, SC_NONE}, - {"dbgclr", SC_DBCL, SC_INT, SC_NONE}, - {"dbgfile", SC_DBOF, SC_XSTR, SC_NONE}, - {"timeout", SC_TIMO, SC_INT, SC_NWST}, - {"expect", SC_XPCT, SC_XSTR, SC_NWST}, - {"ifcarr", SC_CARR, SC_NONE, SC_NWST}, - {"ifhang", SC_HUPS, SC_NONE, SC_NWST}, - {"flush", SC_FLSH, SC_NONE, SC_NONE}, - {"ifblind", SC_IFBL, SC_NONE, SC_NWST}, - {"ifblgtr", SC_IFBG, SC_INT, SC_NWST}, - {"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} - }; - -#define SUCCESS 0 -#define FAIL 1 -#define ERROR -1 -#define MAX_SCLINE 255 /* max length of a line in a script file */ -#define MAX_EXPCT 127 /* max length of an expect string */ -#define CTL_DELIM " \t\n\r" /* Delimiters for tokens */ -#define SAME 0 /* if (strcmp(a,b) == SAME) ... */ -#define SLOP 10 /* Slop space on arrays */ -#define MAX_STRING 200 /* Max length string to send/expect */ - -#define DEBUG_LEVEL(level) \ - (Debug & (1 << level)) - -#define DB_LOG 0 /* error messages and a copy of the LOGFILE output */ -#define DB_LGIE 1 /* dial,login,init trace -- errors only */ -#define DB_LGI 2 /* dial,login,init trace -- nonerrors (incl chr I/O) */ -#define DB_LGII 3 /* script processing internals */ - -#define TRUE 1 -#define FALSE 0 - -#define NONE 0 -#define EVEN 1 -#define ODD 2 - -#define logit(m, p1) fprintf(stderr, "%s %s\n", m, p1) - -static char **paramv; /* Parameter vector */ -static int paramc; /* Parameter count */ -static char telno[64]; /* Telephone number w/meta-chars */ -static int Debug; -static int fShangup = FALSE; /* TRUE if HUP signal received */ -static FILE *dbf = NULL; -static struct termio old, new; - -extern int usignal(); -extern int uhup(); - -static struct siglist -{ - int signal; - int (*o_catcher) (); - int (*n_catcher) (); -} sigtbl[] = { - { SIGHUP, NULL, uhup }, - { SIGINT, NULL, usignal }, - { SIGIOT, NULL, usignal }, - { SIGQUIT, NULL, usignal }, - { SIGTERM, NULL, usignal }, - { SIGALRM, NULL, usignal }, - { 0, NULL, NULL } /* Table end */ - }; - -extern struct script *read_script(); -extern void msleep(); -extern char xgetc(); -extern void charlog(); -extern void setup_tty(); -extern void restore_tty(); -extern void ttoslow(); -extern void ttflui(); -extern void tthang(); -extern void ttbreak(); -extern void tt7bit(); -extern void ttpar(); -extern void DEBUG(); - -extern void *malloc(); - - -/* - * ********************************** - * * BEGIN EXECUTION - MAIN PROGRAM * - * ********************************** - * - * This program is called by Taylor UUCP with a list of - * arguments in argc/argv, and stdin/stdout mapped to the - * tty device, and stderr mapped to the Taylor logfile, where - * anything written to stdout will be logged as an error. - * - */ -int main(argc, argv) -int argc; -char *argv[]; -{ - int i, stat; - FILE *sf; - char sfname[256]; - struct script *script; - struct siglist *sigs; - - /* - * The following is needed because my cpp does not have the - * #error directive... - */ -#if ! HAVE_SELECT - no_select_sorry(); /* Sad way to fail make */ -#endif - - paramv = &argv[2]; /* Parameters start at 2nd arg */ - paramc = argc - 2; /* Number of live parameters */ - - telno[0] = '\0'; - - if (argc < 2) - { - fprintf(stderr, "%s: no script file supplied\n", argv[0]); - exit(FAIL); - } - - /* - * If the script file argument begins with '/', then we assume - * it is an absolute pathname, otherwise, we prepend the - * SCRIPT_DIR path. - */ - *sfname = '\0'; /* Empty name string */ - if(argv[1][0] != '/') /* If relative path */ - strcat(sfname, SCRIPT_DIR); /* Prepend the default dir. */ - strcat(sfname, argv[1]); /* Add the script file name */ - - /* - * Now open the script file. - */ - if ((sf = fopen(sfname, "r")) == NULL) - { - fprintf(stderr, "%s: Failed to open script %s\n", argv[0], sfname); - perror(" "); - exit(FAIL); - } - - /* - * COMPILE SCRIPT - */ - if ((script = read_script(sf)) == NULL) - { - fprintf(stderr, "%s: script error in \"%s\"\n", argv[0], argv[1]); - exit(FAIL); - } - - /* - * Set up a signal catcher so the line can be returned to - * it's current state if something nasty happens. - */ - sigs = &sigtbl[0]; - while(sigs->signal) - { - sigs->o_catcher = (int (*) ())signal(sigs->signal, sigs->n_catcher); - sigs += 1; - } - - /* - * Save current tty settings, then set up raw, single - * character input processing, with 7-bit stripping. - */ - setup_tty(); - - /* - * EXECUTE SCRIPT - */ - if ((stat = do_script(script)) != SUCCESS) - fprintf(stderr, "%s: script %s failed.\n", argv[0], argv[1]); - - /* - * Clean up and exit. - */ - restore_tty(); -#ifdef FIXSIGS - sigs = &sigtbl[0]; - while(sigs->signal) - if(sigs->o_catcher != -1) - signal(sigs->signal, sigs->o_catcher); -#endif - exit(stat); -} - -/* - * deal_script - deallocate a script and all strings it points to - */ -int deal_script(loc) -struct script *loc; -{ - /* - * If pointer is null, just exit - */ - if (loc == (struct script *)NULL) - return SUCCESS; - - /* - * Deallocate the rest of the script - */ - deal_script(loc->next); - - /* - * Deallocate the string parameter, if any - */ - if (loc->strprm != (char *)NULL) - free(loc->strprm); - - /* - * Deallocate the new state name parameter, if any - */ - if (loc->newstate != (char *)NULL) - free(loc->newstate); - - /* - * Deallocate this entry - */ - free(loc); - - return SUCCESS; -} - - -/* - * read_script - * - * Read & compile a script, return pointer to first entry, or null if bad - */ -struct script *read_script(fd) - FILE *fd; -{ - struct script *this = NULL; - struct script *prev = NULL; - struct script *first = NULL; - long len, i; - char inpline[MAX_SCLINE]; - char inpcopy[MAX_SCLINE]; - char *c, *cln, *opc, *cp; - - /* - * MAIN COMPILATION LOOP - */ - while ((c = fgets(inpline, (sizeof inpline - 1), fd)) != (char *)NULL) - { - /* - * Skip comments and blank lines - */ - if (*c == '#' || *c == '\n') - continue; - - /* - * Get rid of the trailing newline, and copy the string - */ - inpline[strlen(inpline)-1] = '\0'; - strcpy(inpcopy, inpline); - - /* - * Look for text starting in the first col (a label) - */ - if ((!isspace(inpline[0])) && - (cln = strchr (inpline, ':')) != (char *)NULL) { - this = (struct script *)malloc (sizeof (struct script)); - if (prev != (struct script *)NULL) - prev->next = this; - prev = this; - if (first == (struct script *)NULL) - first = this; - this->next = (struct script *)NULL; - this->opcode = SC_LABEL; - len = cln - c; - this->strprm = (char *)malloc(len+1); - strncpy(this->strprm, c, len); - (this->strprm)[len] = '\0'; - this->intprm = 0; - this->newstate = (char *)NULL; - c = cln + 1; - } - - /* - * Now handle the opcode. Fold it to lower case. - */ - opc = strtok(c, CTL_DELIM); - if (opc == (char *)NULL) /* If no opcode... */ - continue; /* ...read the next line */ - cp = opc; - while(*cp) - tolower(*cp++); - - /* - * If we have an opcode but we haven't seen anything - * else (like a label) yet, i.e., this is the first - * entry, and there was no label. We need to - * cobble up a label so that read_script is happy - */ - if (first == (struct script *)NULL) - { - this = (struct script *)malloc (sizeof (struct script)); - prev = this; - first = this; - this->next = (struct script *)NULL; - this->opcode = SC_LABEL; - this->strprm = (char *)malloc(2); - strcpy(this->strprm, ":"); - this->intprm = 0; - this->newstate = (char *)NULL; - } - - /* - * Find opcode - ndex through the opcode definition table - */ - for (i=1; sc_opdef[i].opcode != SC_END; i++) - if (strcmp(opc, sc_opdef[i].opname) == SAME) - break; - if ((sc_opdef[i].opcode) == SC_END) - { - logit ("Bad opcode in script", opc); - deal_script(first); - return (struct script *)NULL; - } - - /* - * Found opcode. Allocate a new command node and initialize - */ - this = (struct script *)malloc(sizeof (struct script)); - prev->next = this; - prev = this; - this->next = (struct script *)NULL; - this->opcode = sc_opdef[i].opcode; - this->strprm = (char *)NULL; - this->intprm = 0; - this->newstate = (char *)NULL; - - /* - * Pick up new state parameter, if any - */ - if (sc_opdef[i].newstate == SC_NWST) - { - c = strtok((char *)NULL, CTL_DELIM); - if (c == (char *)NULL) - { - logit("Missing new state", opc); - deal_script(first); - return (struct script *)NULL; - } - else - { - this->newstate = (char *)malloc(strlen(c)+1); - strcpy(this->newstate, c); - } - } - - /* - * Pick up the string or integer parameter. Handle missing - * parameter gracefully. - */ - switch (sc_opdef[i].prmtype) - { - /* - * INT parameter - convert and store in node - */ - case SC_INT: - c = strtok((char *)NULL, CTL_DELIM); - if (c == (char *)NULL) - { - logit("Missing script param", opc); - deal_script(first); - return (struct script *)NULL; - } - /* - * If this is the parameter to DBST or DBCL, force - * base-10 conversion, else convert per parameter. - */ - if (sc_opdef[i].opcode == SC_DBST || - sc_opdef[i].opcode == SC_DBCL) - this->intprm = strtol(c, (char **)NULL, 0); - else - this->intprm = strtol(c, (char **)NULL, 10); - break; - - /* - * STR/XSTR strings. - */ - case SC_STR: - case SC_XSTR: - c = strtok((char *)NULL, CTL_DELIM); - if (c == (char *)NULL) - { - logit("Missing script param", opc); - deal_script(first); - return (struct script *)NULL; - } - /* - * For XSTR opcode, use c to find out where - * the string param begins in the copy of the - * input line, and pick up all that's left of - * the line (to allow imbedded blanks, etc.). - */ - if (sc_opdef[i].prmtype == SC_XSTR) - c = &inpcopy[0] + (c - &inpline[0]); - - /* - * Allocate a buffer for the string parameter - */ - this->strprm = (char *)malloc(strlen(c)+1); - - /* - * For XSTR, Translate the string and store its - * length. Note that, after escape sequences are - * compressed, the resulting string may well be a - * few bytes shorter than the input string (whose - * length was the basis for the malloc above), - * but it will never be longer. - */ - if (sc_opdef[i].prmtype == SC_XSTR) - { - this->intprm = xlat_str(this->strprm, c); - this->strprm[this->intprm] = '\0'; - } - else - strcpy(this->strprm, c); - break; - - } - } - - /* - * EOF - */ - return first; -} - - -/* - * xlat_str - * - * Translate embedded escape characters in a "send" or "expect" string. - * - * Called by read_script(), above. - * - * Returns the actual length of the resulting string. Note that imbedded - * nulls (specified by \000 in the input) ARE allowed in the result. - */ -xlat_str(out, in) - char *out, *in; -{ - register int i = 0, j = 0; - int byte, k; - - while (in[i]) - { - if (in[i] != '\\') - { - out[j++] = in[i++]; - } - else - { - switch (in[++i]) - { - case 'd': /* EOT */ - out[j++] = 0x04; - break; - case 'N': /* null */ - out[j++] = 0x00; - break; - case 'n': /* line feed */ - out[j++] = 0x0a; - break; - case 'r': /* carriage return */ - out[j++] = 0x0d; - break; - case 's': /* space */ - out[j++] = ' '; - break; - case 't': /* tab */ - out[j++] = '\t'; - break; - case '-': /* hyphen */ - out[j++] = '-'; - break; - case '\\': /* back slash */ - out[j++] = '\\'; - break; - case '0': /* '\nnn' format */ - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - byte = in[i] - '0'; - k = 0; - - while (3 > ++k) - if ((in[i+1] < '0') || (in[i+1] > '7')) - break; - else - { - byte = (byte<<3) + in[i+1] - '0'; - ++i; - } - out[j++] = byte; - break; - default: /* don't know so skip it */ - break; - } - ++i; - } - } - return j; -} - - -/* find a state within a script */ - -struct script * - find_state(begin, newstate) -struct script *begin; -char *newstate; -{ - struct script *here; - - for (here=begin; here != (struct script *)NULL; here=here->next) { - if (here->opcode == SC_LABEL && - strcmp(here->strprm, newstate) == SAME) - return here; - } - return (struct script *)NULL; -} - - -/* - * do_script() - execute a script - */ -int do_script(begin) - struct script *begin; -{ - struct script *curstate, *newstate, *curscr; - int dbgsave; - char tempstr[MAX_SCLINE]; - char dfname[256]; - char *c, chr; - int prmlen; - int dbfd; - - time_t sc_carrtime = 45000; /* time to wf carr after dial */ - time_t sc_chrdly = 100; /* delay time for ttoslow */ - time_t sc_ptime = 2000; /* time to allow for pause char */ - time_t sc_wtime = 10000; /* time to allow for wait char */ - time_t sc_dtime = 100; /* time to allow for each digit */ - time_t sc_dtmo; /* total time to dial number */ - int sc_counter; /* random counter */ - char sc_pchar = ','; /* modem pause character */ - char sc_wchar = 'W'; /* modem wait-for-dialtone character */ - time_t sc_begwait; /* time at beg of wait */ - time_t sc_secs; /* timeout period */ - - int expcnt; - int expin; - static char expbuf[MAX_EXPCT]; - - dbgsave = Debug; - curstate = begin; - - if (curstate == (struct script *)NULL) - return SUCCESS; - - _newstate: - /* - * do all of curstate's actions. Enter with curstate pointing - * to a label entry - */ - expin = 0; - - for (curscr = curstate->next; /* point to 1st scr after label */ - (curscr != (struct script *)NULL) && /* do until end of scr */ - (curscr->opcode != SC_LABEL); /* or next label */ - curscr = curscr->next) - { - expcnt = 0; - switch (curscr->opcode) - { - case SC_LABEL: - logit("Script proc err", curstate->strprm); - return FAIL; - - case SC_FLSH: - DEBUG(DB_LGII, "Flushing typeahead buffer\n", 0); - ttflui(); - break; - - case SC_CDLY: - sc_chrdly = curscr->intprm; - DEBUG(DB_LGII, "Set chrdly to %d\n", sc_chrdly); - break; - - case SC_PCHR: - sc_pchar = *(curscr->strprm); - DEBUG(DB_LGII, "Set pause char to %c\n", sc_pchar); - break; - - case SC_PTIM: - sc_ptime = curscr->intprm; - DEBUG(DB_LGII, "Set pause time to %d\n", sc_ptime); - break; - - case SC_WCHR: - sc_wchar = *(curscr->strprm); - DEBUG(DB_LGII, "Set wait char to %c\n", sc_wchar); - break; - - case SC_WTIM: - sc_wtime = curscr->intprm; - DEBUG(DB_LGII, "Set wait time to %d\n", sc_wtime); - break; - - case SC_ZERO: - sc_counter = 0; - DEBUG(DB_LGII, "Set counter to %d\n", sc_counter); - break; - - case SC_INCR: - sc_counter++; - DEBUG(DB_LGII, "Incr counter to %d\n", sc_counter); - break; - - case SC_WAIT: - DEBUG(DB_LGII, "Sleeping %d tenth-secs\n", curscr->intprm); - msleep(curscr->intprm); - break; - - case SC_DTIM: - sc_dtime = curscr->intprm; - DEBUG(DB_LGII, "Digit time is %d\n", sc_dtime); - break; - - case SC_CTIM: - sc_carrtime = curscr->intprm; - DEBUG(DB_LGII, "Carrier time is %d\n", sc_carrtime); - break; - - case SC_EXIT: - Debug = dbgsave; - DEBUG(DB_LGI, "Script ended successfully\n", 0); - return SUCCESS; - - case SC_FAIL: - Debug = dbgsave; - if (DEBUG_LEVEL(DB_LGI) && dbf != NULL) - fprintf(dbf, "Script failed\n"); - else if (expin) - charlog(expbuf, expin, DB_LOG, - "Script failed. Last received data"); - return FAIL; - - case SC_LOG: - logit(curscr->strprm, ""); - break; - - case SC_LOGE: - logit("ERROR: ", curscr->strprm); - break; - - case SC_DBOF: - /* - * If the debug file name does not begin with "/", then - * we prepend the LOG_DIR to the string. Then CREATE the - * file. This WIPES OUT previous logs. - */ - *dfname = '\0'; /* Zero name string */ - if(curscr->strprm[0] != '/') - strcat(dfname, LOG_DIR); /* Prepend default directory */ - strcat(dfname, curscr->strprm); /* Add given string */ - DEBUG(DB_LGII, "Open debug file %s\n", dfname); - if ((dbfd = creat (dfname, 0600)) <= 0) - { - logit("Failed to create debug log %s", dfname); - perror(""); - return FAIL; - } - if ((dbf = fdopen(dbfd, "w")) == NULL) - { - logit("Failed to open debug log fildes.", ""); - perror(""); - return FAIL; - } - break; - - case SC_DBG: - DEBUG(DB_LGI, "<%s>\n", curscr->strprm); - break; - - case SC_DBGE: - DEBUG(DB_LGIE, "ERROR: <%s>\n", curscr->strprm); - break; - - case SC_DBST: - Debug |= curscr->intprm; - DEBUG(DB_LGII, "Debug mask set to %04o (octal)\n", Debug); - break; - - case SC_DBCL: - Debug &= ~(curscr->intprm); - DEBUG(DB_LGII, "Debug mask set to %04o (octal)\n", Debug); - break; - - case SC_BRK: - DEBUG(DB_LGI, "Sending break\n", 0); - ttbreak(); - break; - - case SC_HANG: - DEBUG(DB_LGI, "Dropping DTR\n", 0); - tthang(); - break; - - case SC_7BIT: - DEBUG(DB_LGI, "Enabling 7-bit stripping\n", 0); - tt7bit(TRUE); - break; - - case SC_8BIT: - DEBUG(DB_LGI, "Disabling 7-bit stripping\n", 0); - tt7bit(FALSE); - break; - - case SC_PNON: - DEBUG(DB_LGI, "Setting 8-bit, no parity\n", 0); - ttpar(NONE); - break; - - case SC_PEVN: - DEBUG(DB_LGI, "Setting 7-bit, even parity\n", 0); - ttpar(EVEN); - break; - - case SC_PODD: - DEBUG(DB_LGI, "Setting 7-bit, odd parity\n", 0); - ttpar(ODD); - break; - - case SC_IFBL: - if (ttblind()) - { - DEBUG(DB_LGI, "Blind mux,\n", 0); - goto _chgstate; - } - break; - - case SC_IFBG: - if (ttblind() && sc_counter > curscr->intprm) - { - DEBUG(DB_LGI, "Blind mux & ctr > %d\n", - curscr->intprm); - goto _chgstate; - } - break; - - case SC_IFGT: - if (sc_counter > curscr->intprm) - { - DEBUG(DB_LGI, "Counter > %d\n", curscr->intprm); - goto _chgstate; - } - break; - - case SC_GOTO: - _chgstate: - DEBUG(DB_LGI, "Changing to state %s\n", - curscr->newstate); - curstate = find_state(begin, curscr->newstate); - if (curstate == NULL) - { - logit("New state not found", - curscr->newstate); - return FAIL; - } - goto _newstate; - - case SC_SEND: - ttoslow(curscr->strprm, curscr->intprm, sc_chrdly); - break; - - case SC_TELN: - if (curscr->intprm > paramc - 1) - { - sprintf(tempstr, "telno - param #%d", curscr->intprm); - logit(tempstr, " not present"); - return FAIL; - } - strcpy(telno, paramv[curscr->intprm]); - DEBUG(DB_LGII, "telno set to %s\n", telno); - break; - - case SC_SNDP: - if (curscr->intprm > paramc - 1) - { - sprintf(tempstr, "sendstr - param #%d", curscr->intprm); - logit(tempstr, " not present"); - return FAIL; - } - prmlen = xlat_str(tempstr, paramv[curscr->intprm]); - ttoslow(tempstr, prmlen, sc_chrdly); - break; - - case SC_IF1P: - if (curscr->intprm < paramc) - goto _chgstate; - break; - - case SC_IF0P: - if (curscr->intprm >= paramc) - goto _chgstate; - break; - - case SC_DIAL: - if(telno[0] == '\0') - { - logit("telno not set", ""); - return(FAIL); - } - /* - * Compute and set a default timeout for the 'timeout' - * command. Some parameters in this computation may be - * changed by the script. See the man page xchat(8) for - * details. - */ - sc_dtmo = (sc_dtime+sc_chrdly)*strlen(telno) - + sc_carrtime; - c=strcpy(tempstr, telno); - for (; *c!='\0'; c++) - { - if (*c == 'W') - { - *c = sc_wchar; - sc_dtmo += sc_wtime; - } - else if (*c == 'P') - { - *c = sc_pchar; - sc_dtmo += sc_ptime; - } - } - DEBUG(DB_LGI, "Dialing, default timeout is %d millisecs\n", sc_dtmo); - ttoslow(tempstr, 0, sc_chrdly); - break; - - 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; - } - - } - - /* we've done the current state's actions, now do its expects, if any */ - - if (expcnt == 0) - { - if (curscr != (struct script *)NULL && - (curscr->opcode == SC_LABEL)) - { - curstate = curscr; - DEBUG(DB_LGI, "Fell through to state %s\n", - curstate->strprm); - goto _newstate; - } - else - { - logit("No way out of state", curstate->strprm); - return FAIL; - } - } - - time(&sc_begwait); /* log time at beg of expect */ - DEBUG(DB_LGI, "Doing expects for state %s\n", curstate->strprm); - charlog((char *)NULL, 0, DB_LGI, "Received"); - - while (1) - { - chr = xgetc(1); /* Returns upon char input or 1 sec. tmo */ - - charlog(&chr, 1, DB_LGI, (char *)NULL); - - if (chr != EOF) - { - if (expin < MAX_EXPCT) - { - expbuf[expin++] = chr & 0x7f; - } - else - { - strncpy(expbuf, &expbuf[1], MAX_EXPCT-1); - expbuf[MAX_EXPCT-1] = chr & 0x7f; - } - } - - /* for each entry in the current state... */ - - for (curscr = curstate->next; - (curscr != (struct script *)NULL) && - (curscr->opcode != SC_LABEL); - curscr = curscr->next) - { - - switch (curscr->opcode) - { - case SC_TIMO: - sc_secs = curscr->intprm; - if (sc_secs == 0) - sc_secs = sc_dtmo; - sc_secs /= 1000; - if (time(NULL)-sc_begwait > sc_secs) - { - DEBUG(DB_LGI, - "\nTimed out (%d secs)\n", sc_secs); - goto _chgstate; - } - break; - - case SC_CARR: - if (ttcd()) - { - DEBUG(DB_LGI, "\nGot carrier\n", 0); - goto _chgstate; - } - break; - - case SC_HUPS: - if (fShangup) - { - DEBUG(DB_LGI, "\nGot data set hangup\n", 0); - goto _chgstate; - } - break; - - case SC_XPCT: - if ((expin >= curscr->intprm) && - (strncmp(curscr->strprm, - &expbuf[expin - curscr->intprm], - curscr->intprm) == SAME)) - { - charlog(curscr->strprm, curscr->intprm, - DB_LGI, "Matched"); - goto _chgstate; - } - break; - - } - } - } -} - /* 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 - */ - -/* - * usignal - generic signal catcher - */ -static int usignal(isig) - int isig; -{ - DEBUG(DB_LOG, "Caught signal %d. Exiting...\n", isig); - restore_tty(); - exit(FAIL); -} - -/* - * uhup - HUP catcher - */ -static int uhup(isig) - int isig; -{ - DEBUG(DB_LOG, "Data set hangup.\n"); - fShangup = TRUE; -} - -/* - * TERMINAL I/O ROUTINES - */ - -/* - * xgetc - get a character with timeout - * - * Assumes that stdin is opened on a terminal or TCP socket - * with O_NONBLOCK. - */ -static char xgetc(tmo) -int tmo; /* Timeout, seconds */ -{ - char c; - struct timeval s; - int f = 1; /* Select on stdin */ - int result; - - if(read(0, &c, 1) <= 0) /* If no data available */ - { - s.tv_sec = (long)tmo; - s.tv_usec = 0L; - if(select (1, &f, (int *) NULL, &f, &s) == 1) - read(0, &c, 1); - else - c = '\377'; - } - - return(c); -} - -/* - * Pause for an interval in milliseconds - */ -void msleep(msec) -long msec; -{ - -#if HAVE_USLEEP - if(msec == 0) /* Skip all of this if delay = 0 */ - return; - usleep (msec * (long)1000); -#endif /* HAVE_USLEEP */ - -#if HAVE_NAPMS - if(msec == 0) /* Skip all of this if delay = 0 */ - return; - napms (msec); -#endif /* HAVE_NAPMS */ - -#if HAVE_NAP - if(msec == 0) /* Skip all of this if delay = 0 */ - return; - nap (msec); -#endif /* HAVE_NAP */ - -#if HAVE_POLL - struct pollfd sdummy; - - if(msec == 0) - return; - /* - * We need to pass an unused pollfd structure because poll checks - * the address before checking the number of elements. - */ - poll (&sdummy, 0, msec); -#endif /* HAVE_POLL */ - -#if USE_SELECT_TIMER - struct timeval s; - - if(msec == 0) - return; - s.tv_sec = msec / 1000L; - s.tv_usec = (msec % 1000L) * 1000L; - select (0, (int *) NULL, (int *) NULL, (int *) NULL, &s); -#endif /* USE_SELECT_TIMER */ - -#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP && \ - ! HAVE_POLL && ! USE_SELECT_TIMER - if(msec == 0) - return; - sleep (1); /* Sleep for a whole second (UGH!) */ -#endif /* HAVE_ and USE_ nothing */ -} - -/* - * Debugging output - */ -static void DEBUG(level, msg1, msg2) -int level; -char *msg1, *msg2; -{ - if ((dbf != NULL) && DEBUG_LEVEL(level)) - fprintf(dbf, msg1, msg2); -} - -/* - * charlog - log a string of characters - * - * SPECIAL CASE: msg=NULL, len=1 and msg[0]='\377' gets logged - * when read does its 1 sec. timeout. Log "<1 sec.>" - * so user can see elapsed time - */ -static void charlog(buf, len, mask, msg) -char *buf; -int len, mask; -char *msg; -{ - char tbuf[256]; - - if (DEBUG_LEVEL(mask) && dbf != NULL) - { - if(msg == (char *)NULL) - msg = ""; - strncpy(tbuf, buf, len); - tbuf[len] = '\0'; - if(len == 1 && tbuf[0] == '\377') - strcpy(tbuf, "<1 sec.>"); - fprintf(dbf, "%s %s\n", msg, tbuf); - } -} - -/* - * setup_tty() - * - * Save current tty settings, then set up raw, single - * character input processing, with 7-bit stripping. - */ -static void setup_tty() -{ - register int i; - - ioctl(0, TCGETA, &old); - - new = old; - - for(i = 0; i < 7; i++) - new.c_cc[i] = '\0'; - new.c_cc[VMIN] = 0; /* MIN = 0, use requested count */ - new.c_cc[VTIME] = 10; /* TIME = 1 sec. */ - new.c_iflag = ISTRIP; /* Raw mode, 7-bit stripping */ - new.c_lflag = 0; /* No special line discipline */ - - ioctl(0, TCSETA, &new); -} - -/* - * restore_tty() - restore signal handlers and tty modes on exit. - */ -static void restore_tty(sig) -int sig; -{ - ioctl(0, TCSETA, &old); - return; -} - -/* - * ttoslow() - Send characters with pacing delays - */ -static void ttoslow(s, len, delay) - char *s; - int len; - time_t delay; -{ - int i; - - if (len == 0) - len = strlen(s); - - charlog (s, len, DB_LGI, "Sending slowly"); - - for (i = 0; i < len; i++, s++) - { - write(1, s, 1); - msleep(delay); - } -} - -/* - * ttflui - flush input buffer - */ -static void ttflui() -{ - if(isatty(0)) - (void) ioctl ( 0, TCFLSH, 0); -} - -/* - * ttcd - Test if carrier is present - * - * NOT IMPLEMENTED. I don't know how!!! - */ -static int ttcd() -{ - return TRUE; -} - -/* - * tthang - Force DTR low for 1-2 sec. - */ -static void tthang() -{ - if(!isatty()) - return; - -#ifdef TCCLRDTR - (void) ioctl (1, TCCLRDTR, 0); - sleep (2); - (void) ioctl (1, TCSETDTR, 0); -#endif - - return; -} - -/* - * ttbreak - Send a "break" on the line - */ -static void ttbreak() -{ - (void) ioctl (1, TCSBRK, 0); -} - -/* - * ttblind - return TRUE if tty is "blind" - * - * NOT IMPLEMENTED - Don't know how!!! - */ -static int ttblind() -{ - return FALSE; -} - -/* - * tt7bit - enable/disable 7-bit stripping on line - */ -static void tt7bit(enable) - int enable; -{ - if(enable) - new.c_iflag |= ISTRIP; - else - new.c_iflag &= ~ISTRIP; - - ioctl(0, TCSETA, &new); -} - -/* - * ttpar - Set parity mode on line. Ignore parity errors on input. - */ -static void ttpar(mode) - int mode; -{ - switch(mode) - { - case NONE: - new.c_iflag &= ~(INPCK | IGNPAR); - new.c_cflag &= ~(CSIZE | PARENB | PARODD); - new.c_cflag |= CS8; - break; - - case EVEN: - new.c_iflag |= (INPCK | IGNPAR); - new.c_cflag &= ~(CSIZE | PARODD); - new.c_cflag |= (CS7 | PARENB); - - break; - - case ODD: - new.c_iflag |= (INPCK | IGNPAR); - new.c_cflag &= ~(CSIZE); - new.c_cflag |= (CS7 | PARENB | PARODD); - break; - } - - ioctl(0, TCSETA, &new); -} - - - - - - - diff --git a/gnu/libexec/uucp/contrib/xchat.man b/gnu/libexec/uucp/contrib/xchat.man deleted file mode 100644 index 55537be..0000000 --- a/gnu/libexec/uucp/contrib/xchat.man +++ /dev/null @@ -1,628 +0,0 @@ -.TH xchat 8 -.SH NAME -xchat - Extended chat processor -.SH SYNOPSIS -.BI "xchat " "scriptfile" -.RI " [ " parameter... " ] " -.PP -where -.I scriptfile -is the name of a file containing an -.I xchat -script. If -.I scriptfile -begins with ``/'', then it is assumed to be a full path name for the -script file. If not, a configuration-dependent default directory path -(usually -.B "/usr/local/conf/uucp/" -) is prepended to the script file name. Normally, the default path -is the same as that for the Taylor UUCP configuration files. -.SH DESCRIPTION -.I Xchat -is a general-purpose dialing and login program designed for use -with Taylor UUCP as a ``chat-program'', taking the place (or -augmenting) the built-in chat scripting facility. It provides the -ability to closely control timeouts, multiple simultaneous ``expect'' -strings with separate actions, extended terminal control, modem -command character pacing, and more. -.PP -When used in conjunction with Taylor UUCP's -configuration features, -.I xchat -can provide you the ability to manage the most intricate login, -dial and hangup needs. The scripts are written in a shell-like (well, -sort-of) style with labels, commands, and parameters, easing the task -of writing procedures for complex terminal communications situations. -.PP -Because -.I xchat -assumes that it is connected to the terminal device via stdin/stdout, -you can easily debug scripts by invoking it from the shell and -responding to the script from the keyboard. A debug logging facility -is included, with the debug output going to a separate user-specified -file. This makes it easy to debug connection problems without wading -through large -.I uucico -log and debug files. -.PP -Formally, a script describes a state machine; -.I xchat -interprets the script and does what the state machine -tells it to. This section will be much easier to understand -if you obtain listings of the script files supplied with -.I xchat. -.SH "SCRIPT FILE FORMAT" -Script files are ordinary text files containing comments, labels, -and statements. Blank lines are ignored. -Comments are denoted by leading ``#'' -characters. Some statements (those which do not end with an -``extended string'' argument; see below) can also have trailing -comments. -.PP -.I Labels -begin in column one and are ended by colons (:). A label -specifies a state name. All lines between a pair of labels are -the statements for a single state. -.PP -Processing always begins at the head of the script (no leading -state name is necessary). -.PP -.I Statements -are divided into two categories, ``action'' and ``expect''. -When a state is entered, all of its actions are performed in the -order in which they appear in the file. -.PP -A -.I transition -to another state may occur for any of three reasons: -.IP (1) 5 -One of the actions may cause a transition to -another state, in which case the rest of the -current state's actions are skipped. -Processing resumes with the first action -statement of the new state. -.IP (2) 5 -If none of the actions cause a state -transition, and there are no expects in the -state, processing ``falls through'' to the next -state in the file. -.IP (3) 5 -If none of the actions cause a state -transition, but there are expects in the -state, the state machine pauses until one of -the expects is ``satisfied''. It then transitions -to the state named in the expect -statement. -.PP -Finally, there are two action statements which, when executed, -cause the script to exit. -.SH "SCRIPT FILE STATEMENTS" -This section describes all of the statements that may appear in script -files, except for a few special action statements. Those are described -in a later section, ``Overriding Defaults''. -.PP -Some statements accept one or two arguments, referred to in the -following descriptions as -.IR int ", " ns ", " str ", or " -.IR xstr ", to" -indicate whether the argument is an integer, a new state name, a -string, or an ``extended string'' (described in a later section). -.PP -For all statements that accept two arguments, the first is the -name of a new state, and the second specifies a condition or -reason for changing to the new state. -.SS "Termination And Informational Statements" -These statements are used to place entries into the Taylor UUCP -.I Log -file, and to cause -.I xchat -to exit with successful or failure status. It is also possible to open a -separate -.I debug -log file and control the level of tracing and error reporting that will go -into that log file. This is very useful in debugging -.I xchat -scripts. -.br -.ta 1.0i 1.5i 2.0i -.TP 2.0i -.B failed -Exit script with ``failed'' status. This causes -.I xchat -to exit with status 0. -.TP 2.0i -.B success -Exit script with ``success'' status. This causes -.I xchat -to exit with status 1. -.TP 2.0i -.BI "log " xstr -Send informational message -.I xstr -to standard error. When used with Taylor UUCP, this is the -.I Log -file for the -.I uucico -program. -.TP 2.0i -.BI "logerr " xstr -Send message -.I xstr -to standard error, with ``ERROR:'' indicator. When used -with Taylor UUCP, this is the -.I Log -file for the -.I uucico -program. -.TP 2.0i -.BI "dbgfile " xstr -Open script debugging file -.I xstr. -If -.I xstr -begins with ``/'', it is assumed to be an absolute path name for the -debugging file. If not, then a configuration-dependent default directory -path (usually -.B "/usr/spool/uucp" -) is prepended to -.I xstr. -Normally the default path is that of the directory where Taylor UUCP -puts its log files. -The debugging file is used to capture a detailed log of the data sent -and received, errors encountered, and a trace of script execution. -The various types of logging are controlled by the -.I "debug mask," -described next. -.B Note: -A new log file is created each time -.I xchat -runs. Use the -.B log -and -.B loge -commands to log -continuous information onto standard out, which is connected -to the Taylor UUCP -.I Log -file when -.I xchat -is run by the Taylor -.I uucico. -.TP 2.0i -.BI "dbgset " int -Set the bits specified in -.I int -in the debugging mask. The value in -.I int -is ``or''ed into the mask. Set bit 0 (value \= 1) for error messages, -bit 1 (value \= 2) for dial, login and init errors, bit 2 (value \= 4) -for dial, login and init trace with character I/O, and bit 3 (value \= 8) -for script processing internals. Normally, you will just turn it all on -with a value of 15. -.TP 2.0i -.BI "dbgclr " int -Clear the bits specified in -.I int -from the debugging mask. -.TP 2.0i -.BI "debug " xstr -Write -.I -xstr -into the debug log. The entry will be enclosed in angle brackets. -.TP 2.0i -.BI "debuge " xstr -Write -.I xstr -into the debug log with ``ERROR: '' prepended. The entry will be enclosed -in angle brackets. -.SS "Sending Data" -These statements are used to transmit data to standard out (the tty or TCP -port when used with Taylor UUCP). -.I -No implied carriage returns are sent. -You must include a \\r if you want a carriage return in the string -sent by the -.B send -command. If you want a return sent after -.B dial -or -.B sendstr, -you must send it with a separate -.B send -command. -.TP 2.0i -.B dial -Send the string previously set by the -.B telno -command to the serial port. -.B W -and -.B P -characters in the phone number are -converted as described under -.B -Dial Strings, -below. This statement also sets a default -timeout value, as described under the -.B timeout -statement. -.TP 2.0i -.BI "send " xstr -Send the string -.I xstr -to the serial port. -.TP 2.0i -.BI "sendstr " int -The argument of this statement is a digit from 0 -through 7. Send the corresponding string -parameter as passed to -.I xchat -following the script file name. The parameter is interpreted -as an extended string. -.SS "Special Terminal Control Statements" -These statements are used to cause the terminal port to perform some special action, or to change the mode of the port. -.I -The modes of the port are restored to their original settings -.I -by xchat before it exits. -.TP 2.0i -.B flush -Flush the terminal port's input buffer. -.TP 2.0i -.B break -Send a break signal. -.TP 2.0i -.B hangup -Momentarily drop Data Terminal Ready (DTR) on the -serial port, causing the modem to hang up. (Not -usually needed, since -.I uucico -does this at the end of each call.) -.TP 2.0i -.B 7bit -Change the port to strip incoming characters to 7 bits. -.I -This is the default mode. -This mode -is implied when the port has parity enabled, since parity characters -are 7-bits wide. -.TP 2.0i -.B 8bit -Change the port to allow incoming 8-bit characters to be passed -to the script processor. This mode has no effect if parity is -enabled, since parity characters are 7-bits wide. -.TP 2.0i -.B nopar -Change the port to 8-bits, no parity. -.I -This is the default mode. -.TP 2.0i -.B evenpar -Change the port to 7-bits, even parity. -.I -Incoming characters with parity errors are discarded. -.TP 2.0i -.B oddpar -Change the port to 7-bits, odd parity. -.I -Incoming characters with parity errors are discarded. -.SS "Counting, Branching, Timing and Testing Statements" -These statements are used to control the flow of the -.I xchat -script itself, including branching, delays, and counter manipulation. -.TP 2.0i -.BI "sleep " int -Delay for -.I int -milliseconds. -.TP 2.0i -.B zero -Clear the counter. -.TP 2.0i -.B count -Add one to the counter. -.TP 2.0i -.BI "ifgtr " "ns int" -Go to state -.I ns -if counter greater than -.I int. -.TP 2.0i -.BI "goto " ns -Go to state -.I ns -unconditionally. -.TP 2.0i -.BI "ifstr " "ns int" -Go to state -.I ns -if string parameter -.I int -is nonempty. -.TP 2.0i -.BI "ifnstr " "ns int" -Go to state -.I ns -if string parameter -.I int -is empty. -.TP 2.0i -.BI "ifblind " ns -Change to state -.I ns -if the port is ``blind'' without carrier (CD) asserted. -.I -This is not yet implemented, the test always fails. -.TP 2.0i -.BI "ifblgtr " "ns int" -Change to state -.I ns -if the port is ``blind'' without carrier (CD) asserted, and counter -is greater then -.I int. -.I -This is not yet implemented, the test always fails. -.SS "Expect Statements" -Expect statements are usually the last statements that appear in a -given state, though in fact they can appear anywhere within the -state. Even if they appear at the beginning, the script processor -always does all of the action statements first. As a practical -matter, the order of these statements is not significant; they are -all interpreted ``in parallel''. -.TP 2.0i -.BI "expect " "ns xstr" -Change to state -.I ns -if the string specified by -.I xstr -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 -if Carrier Detect (CD) is true. -.I -Not currently implemented. Always changes state. -.TP 2.0i -.BI "ifhang " ns -Change to state -.I ns -if a data set hangup occurs (SIGHUP signal received). -.TP 2.0i -.BI "timeout " "ns int" -Change to state -.I ns -if the time (in milliseconds) -given by -.I int -has elapsed without satisfying any -expects. If the time specified is 0, a default -timeout value (calculated from the length and -other characteristics of the most recent dial -string) is used. -.SH "SCRIPT PROCESSING DETAILS" -.SS "Extended Strings" -In the statements that accept string arguments, the strings are -interpreted as -.I -extended strings. -Extended strings begin with -the first nonblank character and continue, including all imbedded -and trailing blanks and other whitespace, until (but not -including) the end of the line in the script file. (There is no -provision for line continuation.) No trailing spaces should be -present between the last ``desired'' character of the string and the -end of the line, as they will be included in the stored string and -sent or expected, just as they appear in the script file. And, -obviously, no trailing comments are permitted! They will just be -stored as part of the string. -.PP -Within an extended string, the following ``escape sequences'' will -be converted as indicated before being sent or expected: -.br -.nf -.in +0.5i -\fB\\d\fR EOT character (control-D) -\fB\\N\fR null character -\fB\\n\fR line feed -\fB\\r\fR carriage return -\fB\\s\fR space -\fB\\t\fR tab -\fB\\\-\fR hyphen -\fB\\\\\fR backslash -\fB\\ooo\fR character with value ooo (in octal) -.in -0.5i -.fi -.PP -Since extended strings in scripts can include embedded spaces, -tabs, etc., these escape sequences are only required in strings -appearing in systems entries, though they may be used in script -files to improve readability. -.PP -The octal-character specification (\\ooo) may have from one to -three octal digits; it is terminated either after the third digit -or when a non-octal character is encountered. But if you want to -specify one of these followed by something that happens to be a -valid octal character (for example, a control-A followed by a 7) -make sure to include all three digits after the \\ . So \\0017 -would become a control-A followed by the Ascii character ``7'', but -\\17 or \\017 would become a control-Y (decimal value 25). \\1S -would convert to a control-A followed by an ``S''. -.PP -Extended strings are stored without a trailing carriage return -unless one is explicitly present in the string (via \\r). -.SS "String Parameters" -The -.B sendstr -statement sends (after conversion from extended string -format) one of the parameters given on the -.I xchat -command line following the script file name. -The parameter is selected by the integer -argument of the statement. -.PP -This allows ``generic'' script files to serve -for many different systems; the string parameters -provide the phone number, username, password, etc. Character -substitutions described under ``extended strings'' above are -performed on these strings. -.PP -The ifstr and ifnstr statements allow further generality in script -files, by testing whether a particular parameter is present in the -systems entry. For example, a single script can be -used both for those systems that require a password and -those that do not. The password is specified as the last argument -in the -.xchat -command; the script can test for this -parameter's existence and skip the password sequence if -the parameter is empty. -.SS "``Wait'' And ``Pause'' Characters In Dial Strings" -An additional conversion is performed on dial strings. Dial strings -are interpreted as extended strings. Then the characters -.B W -and -.B P -within a dial string are interpreted as ``wait for dial -tone'' and ``pause'', and may be converted to other characters. By -default, -.B W -is left alone, and -.B P -is converted to a comma (,); -these are appropriate for Hayes-type modems. The script may -specify other substitutions (see below). -.PP -.B NOTE: -The Taylor UUCP documentation states that the ``wait'' and ``pause'' -characters are ``='' and ``-'', respectively. These are actual characters -understood by some modems. When using -.I xchat -you should put -.B W -and -.B P -in the dial strings you specify in the Taylor configuration files. -This way, the -.I xchat -processor can make the substitution appropriate for the particular -modem in use. Make a separate -.I xchat -script for each modem type, e.g., -.I "dial.hayes" -and specify the translation there. This way, the phone number strings -in the Taylor configuration files can be used with a variety of modems. -.SS "Default Timeouts For Dial Strings" -When a -.B dial -statement is executed, a default timeout value is set. -This is the timeout value used by a subsequent timeout statement -if the statement specifies a timeout value of 0. -.PP -The default timeout is given by: -.br -.nf -.in +2 -\fIctime\fR + (\fIndigits\fR * \fIdgttime\fR) + (\fInwchar\fR * \fIwtime\fR) + (\fInpchar\fR * \fI ptime\fR) -.in -2 -.fi -.PP -where -.I -ndigits, nwchar, -and -.I npchar -are the number of digits, wait characters, and pause characters in -the dial string, and -.I ctime, dgttime, wtime, -and -.I ptime -are 45 seconds, 0.1 seconds, 10 seconds, and 2 seconds, -respectively. -All of these times may be changed as specified below under -``Overriding Defaults.'' -.SS "Trailing Carriage Returns Not Assumed" -In the -.B dial -and -.B sendstr -statements, the dial string or -parameter is sent with no trailing carriage return; -if a carriage return must be sent after one of these, a separate -send statement must provide it. -.SH "OVERRIDING DEFAULTS" -The script processor sets several default values. The following -statements, which override these defaults, may be useful in -certain circumstances. -.TP 2.0i -.BI "chrdly " int -Since many modems cannot accept dialing commands -at full ``computer speed'', the script processor -sends all strings with a brief inter-character -delay. This statement specifies the delay time, -in milliseconds. The default is 100 (0.1 second). -.TP 2.0i -.BI "pchar " str -Specifies the character to which -.BR P s -in the -dial string should be converted. Default is -``,'', for use with Hayes-type modems. -.TP 2.0i -.BI "ptime " int -Specifies the time, in milliseconds, to allow in -the default timeout for each pause character in -the dial string. Default is 2000 (2 seconds). -.TP 2.0i -.BI "wchar " str -Specifies the character to which -.BR W s -in the -dial string should be converted. Default is -``W'', for Hayes modems. -.TP 2.0i -.BI "wtime " int -Specifies the time, in milliseconds, to allow in -the default timeout for each wait-for-dialtone -character in the dial string. Default is 10000 -(10 seconds). -.TP 2.0i -.BI "dgttime " int -Specifies the time, in milliseconds, to allow in -the default timeout for each digit character in -the dial string. Default is 100 (0.1 second). -.TP 2.0i -.BI "ctime " int -Specifies the time, in milliseconds, to allow in -the default timeout for carrier to appear after -the dial string is sent. Default is 45000 (45 -seconds). -.SH "SEE ALSO" -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 -Hanrahan, et. al. -.SH BUGS -This version (1.1) does not support BSD terminal facilities. Anyone -volunteer to add this? - diff --git a/gnu/libexec/uucp/doc/Makefile b/gnu/libexec/uucp/doc/Makefile deleted file mode 100644 index 8066a9b..0000000 --- a/gnu/libexec/uucp/doc/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -INFO= uucp -INFOSECTION= "System Utilities" - -.include <bsd.info.mk> diff --git a/gnu/libexec/uucp/doc/uucp.texi b/gnu/libexec/uucp/doc/uucp.texi deleted file mode 100644 index a73d34b..0000000 --- a/gnu/libexec/uucp/doc/uucp.texi +++ /dev/null @@ -1,8395 +0,0 @@ -\input texinfo @c -*-texinfo-*- - -@c $FreeBSD$ - -@c %**start of header -@setfilename uucp.info -@settitle Taylor UUCP -@setchapternewpage odd -@c %**end of header - -@iftex -@finalout -@end iftex - -@ifinfo -@format -START-INFO-DIR-ENTRY -* UUCP: (uucp). Transfer mail and news across phone lines. -END-INFO-DIR-ENTRY -@end format - -This file documents Taylor UUCP, version 1.06. - -Copyright @copyright{} 1992, 1993, 1994, 1995 Ian Lance Taylor - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``Copying'' are included exactly as in the original, and -provided that the entire resulting derived work is distributed under the -terms of a permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``Copying'' may be included in a -translation approved by the author instead of in the original English. -@end ifinfo - -@titlepage -@title Taylor UUCP -@subtitle Version 1.06 -@author Ian Lance Taylor @code{<ian@@airs.com>} - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993, 1994, 1995 Ian Lance Taylor - -Published by Ian Lance Taylor @code{<ian@@airs.com>}. - -Permission is granted to make and distribute verbatim copies of this -manual provided the copyright notice and this permission notice are -preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``Copying'' are included exactly as in the original, and -provided that the entire resulting derived work is distributed under the -terms of a permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``Copying'' may be included in a -translation approved by the author instead of in the original English. -@end titlepage - -@node Top, Copying, (dir), (dir) -@top Taylor UUCP 1.06 - -This is the documentation for the Taylor UUCP package, version 1.06. -The programs were written by Ian Lance Taylor. The author can be -reached at @code{<ian@@airs.com>}, or at -@display -Ian Lance Taylor -c/o Cygnus Support -48 Grove Street -Somerville, MA 02144 -USA -@end display - -There is a mailing list for discussion of the package. The list is -hosted by Eric Schnoebelen at @code{cirr.com}. To join (or get off) the -list, send mail to @code{taylor-uucp-request@@cirr.com}. Mail to this -address is answered by the majordomo program. To join the list, send -the message @samp{subscribe @var{address}} where @var{address} is your -e-mail address. To send a message to the list, send it to -@code{taylor-uucp@@cirr.com}. The old list address, -@code{taylor-uucp@@gnu.ai.mit.edu}, will also work. There is an archive -of all messages sent to the mailing list at @code{ftp.cirr.com}. - -@menu -* Copying:: Taylor UUCP Copying Conditions -* Introduction:: Introduction to Taylor UUCP -* Invoking the UUCP Programs:: Invoking the UUCP Programs -* Installing Taylor UUCP:: Installing Taylor UUCP -* Using Taylor UUCP:: Using Taylor UUCP -* Configuration Files:: Taylor UUCP Configuration Files -* Protocols:: UUCP Protocol Descriptions -* Hacking:: Hacking Taylor UUCP -* Acknowledgements:: Acknowledgements - -* Index (concepts):: Concept Index -* Index (configuration file):: Index to New Configuration Files - - --- The Detailed Node Listing --- - -Invoking the UUCP Programs - -* Standard Options:: Standard Options for the UUCP Programs -* Invoking uucp:: Invoking uucp -* Invoking uux:: Invoking uux -* Invoking uustat:: Invoking uustat -* Invoking uuname:: Invoking uuname -* Invoking uulog:: Invoking uulog -* Invoking uuto:: Invoking uuto -* Invoking uupick:: Invoking uupick -* Invoking cu:: Invoking cu -* Invoking uucico:: Invoking uucico -* Invoking uuxqt:: Invoking uuxqt -* Invoking uuchk:: Invoking uuchk -* Invoking uuconv:: Invoking uuconv -* Invoking uusched:: Invoking uusched - -Invoking uucp - -* uucp Description:: Description of uucp -* uucp Options:: Options Supported by uucp - -Invoking uux - -* uux Description:: Description of uux -* uux Options:: Options Supported by uux -* uux Examples:: Examples of uux Usage - -Invoking uustat - -* uustat Description:: Description of uustat -* uustat Options:: Options Supported by uustat -* uustat Examples:: Examples of uustat Usage - -Invoking cu - -* cu Description:: Description of cu -* cu Commands:: Commands Supported by cu -* cu Variables:: Variables Supported by cu -* cu Options:: Options Supported by cu - -Invoking uucico - -* uucico Description:: Description of uucico -* uucico Options:: Options Supported by uucico - -Installing Taylor UUCP - -* Compilation:: Compiling Taylor UUCP -* Testing the Compilation:: Testing the Compilation -* Installing the Binaries:: Installing the Binaries -* Configuration:: Configuring Taylor UUCP -* Testing the Installation:: Testing the Installation - -Using Taylor UUCP - -* Calling Other Systems:: Calling Other Systems -* Accepting Calls:: Accepting Calls -* Mail and News:: Using UUCP for Mail and News -* The Spool Directory Layout:: The Spool Directory Layout -* Spool Directory Cleaning:: Cleaning the UUCP Spool Directory - -Using UUCP for Mail and News. - -* Sending mail or news:: Sending mail or news via UUCP -* Receiving mail or news:: Receiving mail or news via UUCP - -The Spool Directory Layout - -* System Spool Directories:: System Spool Directories -* Status Directory:: Status Spool Directory -* Execution Subdirectories:: Execution Spool Subdirectories -* Other Spool Subdirectories:: Other Spool Subdirectories -* Spool Lock Files:: Spool Directory Lock Files - -Taylor UUCP Configuration Files - -* Configuration Overview:: Configuration File Overview -* Configuration File Format:: Configuration File Format -* Configuration Examples:: Examples of Configuration Files -* Time Strings:: How to Write Time Strings -* Chat Scripts:: How to Write Chat Scripts -* config File:: The Main Configuration File -* sys File:: The System Configuration File -* port File:: The Port Configuration Files -* dial File:: The Dialer Configuration Files -* UUCP Over TCP:: UUCP Over TCP -* Security:: Security Issues - -Examples of Configuration Files - -* config File Examples:: Examples of the Main Configuration File -* Leaf Example:: Call a Single Remote Site -* Gateway Example:: The Gateway for Several Local Systems - -The Main Configuration File - -* Miscellaneous (config):: Miscellaneous config File Commands -* Configuration File Names:: Using Different Configuration Files -* Log File Names:: Using Different Log Files -* Debugging Levels:: Debugging Levels - -The System Configuration File - -* Defaults and Alternates:: Using Defaults and Alternates -* Naming the System:: Naming the System -* Calling Out:: Calling Out -* Accepting a Call:: Accepting a Call -* Protocol Selection:: Protocol Selection -* File Transfer Control:: File Transfer Control -* Miscellaneous (sys):: Miscellaneous sys File Commands -* Default sys File Values:: Default Values - -Calling Out - -* When to Call:: When to Call -* Placing the Call:: Placing the Call -* Logging In:: Logging In - -UUCP Over TCP - -* TCP Client:: Connecting to Another System Over TCP -* TCP Server:: Running a TCP Server - -UUCP Protocol Internals - -* UUCP Protocol Sources:: Sources for UUCP Protocol Information -* UUCP Grades:: UUCP Grades -* UUCP Lock Files:: UUCP Lock Files -* Execution File Format:: Execution File Format -* UUCP Protocol:: UUCP Protocol -* g Protocol:: g protocol -* f Protocol:: f protocol -* t Protocol:: t protocol -* e Protocol:: e protocol -* Big G Protocol:: G protocol -* i Protocol:: i protocol -* j Protocol:: j protocol -* x Protocol:: x protocol -* y Protocol:: y protocol -* d Protocol:: d protocol -* h Protocol:: h protocol -* v Protocol:: v protocol - -UUCP Protocol - -* The Initial Handshake:: The Initial Handshake -* UUCP Protocol Commands:: UUCP Protocol Commands -* The Final Handshake:: The Final Handshake - -UUCP Protocol Commands - -* The S Command:: The S Command -* The R Command:: The R Command -* The X Command:: The X Command -* The E Command:: The E Command -* The H Command:: The H Command - -Hacking Taylor UUCP - -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches -@end menu - -@node Copying, Introduction, Top, Top -@unnumbered Taylor UUCP Copying Conditions - -This package is covered by the GNU Public License. See the file -@file{COPYING} for details. If you would like to do something with this -package that you feel is reasonable, but you feel is prohibited by the -license, contact me to see if we can work it out. - -The rest of this section is some descriptive text from the Free Software -Foundation. - -All the programs, scripts and documents relating to Taylor UUCP are -@dfn{free}; this means that everyone is free to use them and free to -redistribute them on a free basis. The Taylor UUCP-related programs are -not in the public domain; they are copyrighted and there are -restrictions on their distribution, but these restrictions are designed -to permit everything that a good cooperating citizen would want to do. -What is not allowed is to try to prevent others from further sharing any -version of these programs that they might get from you. - -Specifically, we want to make sure that you have the right to give away -copies of the programs that relate to Taylor UUCP, that you receive -source code or else can get it if you want it, that you can change these -programs or use pieces of them in new free programs, and that you know -you can do these things. - -To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of the Taylor UUCP related programs, you must give the recipients -all the rights that you have. You must make sure that they, too, -receive or can get the source code. And you must tell them their -rights. - -Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for the programs that relate to Taylor -UUCP. If these programs are modified by someone else and passed on, we -want their recipients to know that what they have is not what we -distributed, so that any problems introduced by others will not reflect -on our reputation. - -The precise conditions of the licenses for the programs currently being -distributed that relate to Taylor UUCP are found in the General Public -Licenses that accompany them. - -@node Introduction, Invoking the UUCP Programs, Copying, Top -@chapter Introduction to Taylor UUCP - -General introductions to UUCP are available, and perhaps one day I will -write one. In the meantime, here is a very brief one that concentrates -on the programs provided by Taylor UUCP. - -Taylor UUCP is a complete UUCP package. It is covered by the GNU Public -License, which means that the source code is always available. It is -composed of several programs; most of the names of these programs are -based on earlier UUCP packages. - -@table @code - -@item uucp - -The @code{uucp} program is used to copy file between systems. It is -similar to the standard Unix @code{cp} program, except that you can -refer to a file on a remote system by using @samp{system!} before the -file name. For example, to copy the file @file{notes.txt} to the system -@samp{airs}, you would say @samp{uucp notes.txt airs!~/notes.txt}. In -this example @samp{~} is used to name the UUCP public directory on -@samp{airs}. For more details, see @ref{Invoking uucp, uucp}. - -@item uux - -The @code{uux} program is used to request the execution of a program on -a remote system. This is how mail and news are transferred over UUCP. -As with @code{uucp}, programs and files on remote systems may be named -by using @samp{system!}. For example, to run the @code{rnews} program -on @samp{airs}, passing it standard input, you would say @samp{uux - -airs!rnews}. The @samp{-} means to read standard input and set things -up such that when @code{rnews} runs on @samp{airs} it will receive the -same standard input. For more details, see @ref{Invoking uux, uux}. - -@end table - -Neither @code{uucp} nor @code{uux} actually do any work immediately. -Instead, they queue up requests for later processing. They then start a -daemon process which processes the requests and calls up the appropriate -systems. Normally the system will also start the daemon periodically to -check if there is any work to be done. The advantage of this approach -is that it all happens automatically. You don't have to sit around -waiting for the files to be transferred. The disadvantage is that if -anything goes wrong it might be a while before anybody notices. - -@table @code - -@item uustat - -The @code{uustat} program does many things. By default it will simply -list all the jobs you have queued with @code{uucp} or @code{uux} that -have not yet been processed. You can use @code{uustat} to remove any of -your jobs from the queue. You can also it use it to show the status of -the UUCP system in various ways, such as showing the connection status -of all the remote systems your system knows about. The system -administrator can use @code{uustat} to automatically discard old jobs -while sending mail to the user who requested them. For more details, -see @ref{Invoking uustat, uustat}. - -@item uuname - -The @code{uuname} program by default lists all the remote systems your -system knows about. You can also use it to get the name of your local -system. It is mostly useful for shell scripts. For more details, see -@ref{Invoking uuname, uuname}. - -@item uulog - -The @code{uulog} program can be used to display entries in the UUCP log -file. It can select the entries for a particular system or a particular -user. You can use it to see what has happened to your queued jobs in -the past. For more details, see @ref{Invoking uulog, uulog}. - -@item uuto -@item uupick - -@code{uuto} is a simple shell script interface to @code{uucp}. It will -transfer a file, or the contents of a directory, to a remote system, and -notify a particular user on the remote system when it arrives. The -remote user can then retrieve the file(s) with @code{uupick}. For more -details, see @ref{Invoking uuto, uuto}, and see @ref{Invoking uupick, -uupick}. - -@item cu - -The @code{cu} program can be used to call up another system and -communicate with it as though you were directly connected. It can also -do simple file transfers, though it does not provide any error checking. -For more details, @ref{Invoking cu, cu}. - -@end table - -These eight programs just described, @code{uucp}, @code{uux}, -@code{uuto}, @code{uupick}, @code{uustat}, @code{uuname}, @code{uulog}, -and @code{cu} are the user programs provided by Taylor UUCP@. -@code{uucp}, @code{uux}, and @code{uuto} add requests to the work queue, -@code{uupick} extracts files from the UUCP public directory, -@code{uustat} examines the work queue, @code{uuname} examines the -configuration files, @code{uulog} examines the log files, and @code{cu} -just uses the UUCP configuration files. - -The real work is actually done by two daemon processes, which are -normally run automatically rather than by a user. - -@table @code - -@item uucico - -The @code{uucico} daemon is the program which actually calls the remote -system and transfers files and requests. @code{uucico} is normally -started automatically by @code{uucp} and @code{uux}. Most systems will -also start it periodically to make sure that all work requests are -handled. @code{uucico} checks the queue to see what work needs to be -done, and then calls the appropriate systems. If the call fails, -perhaps because the phone line is busy, @code{uucico} leaves the -requests in the queue and goes on to the next system to call. It is -also possible to force @code{uucico} to call a remote system even if -there is no work to be done for it, so that it can pick up any work that -may be queued up remotely. For more details, see @ref{Invoking uucico, -uucico}. - -@need 1000 -@item uuxqt - -The @code{uuxqt} daemon processes execution requests made by the -@code{uux} program on remote systems. It also processes requests made -on the local system which require files from a remote system. It is -normally started by @code{uucico}. For more details, see @ref{Invoking -uuxqt, uuxqt}. - -@end table - -Suppose you, on the system @samp{bantam}, want to copy a file to the -system @samp{airs}. You would run the @code{uucp} command locally, with -a command like @samp{uucp notes.txt airs!~/notes.txt}. This would queue -up a request on @samp{bantam} for @samp{airs}, and would then start the -@code{uucico} daemon. @code{uucico} would see that there was a request -for @samp{airs} and attempt to call it. When the call succeeded, -another copy of @code{uucico} would be started on @samp{airs}. The two -copies of @code{uucico} would tell each other what they had to do and -transfer the file from @samp{bantam} to @samp{airs}. When the file -transfer was complete the @code{uucico} on @samp{airs} would move it -into the UUCP public directory. - -UUCP is often used to transfer mail. This is normally done -automatically by mailer programs. When @samp{bantam} has a mail message -to send to @samp{ian} at @samp{airs}, it executes @samp{uux - airs!rmail -ian} and writes the mail message to the @code{uux} process as standard -input. The @code{uux} program, running on @samp{bantam}, will read the -standard input and store it, as well as the @code{rmail} request itself, -on the work queue for @samp{airs}. @code{uux} will then start the -@code{uucico} daemon. The @code{uucico} daemon will call up -@samp{airs}, just as in the @code{uucp} example, and transfer the work -request and the mail message. The @code{uucico} daemon on @samp{airs} -will put the files on a local work queue. When the communication -session is over, the @code{uucico} daemon on @samp{airs} will start the -@code{uuxqt} daemon. @code{uuxqt} will see the request on the work -queue, and will run @samp{rmail ian} with the mail message as standard -input. The @code{rmail} program, which is not part of the UUCP package, -is then responsible for either putting the message in the right mailbox -on @samp{airs} or forwarding the message on to another system. - -Taylor UUCP comes with a few other programs that are useful when -installing and configuring UUCP. - -@table @code - -@item uuchk - -The @code{uuchk} program reads the UUCP configuration files and displays -a rather lengthy description of what it finds. This is useful when -configuring UUCP to make certain that the UUCP package will do what you -expect it to do. For more details, see @ref{Invoking uuchk, uuchk}. - -@item uuconv - -The @code{uuconv} program can be used to convert UUCP configuration -files from one format to another. This can be useful for administrators -converting from an older UUCP package. Taylor UUCP is able to read and -use old configuration file formats, but some new features can not be -selected using the old formats. For more details, see @ref{Invoking -uuconv, uuconv}. - -@item uusched - -The @code{uusched} script is provided for compatibility with older UUCP -releases. It starts @code{uucico} to call, one at a time, all the -systems for which work has been queued. For more details, see -@ref{Invoking uusched, uusched}. - -@item tstuu - -The @code{tstuu} program is a test harness for the UUCP package; it can -help check that the package has been configured and compiled correctly. -However, it uses pseudo-terminals, which means that it is less portable -than the rest of the package. If it works, it can be useful when -initially installing Taylor UUCP. For more details, see @ref{Testing -the Compilation, tstuu}. - -@end table - -@node Invoking the UUCP Programs, Installing Taylor UUCP, Introduction, Top -@chapter Invoking the UUCP Programs - -This chapter describes how to run the UUCP programs. - -@menu -* Standard Options:: Standard Options for the UUCP Programs -* Invoking uucp:: Invoking uucp -* Invoking uux:: Invoking uux -* Invoking uustat:: Invoking uustat -* Invoking uuname:: Invoking uuname -* Invoking uulog:: Invoking uulog -* Invoking uuto:: Invoking uuto -* Invoking uupick:: Invoking uupick -* Invoking cu:: Invoking cu -* Invoking uucico:: Invoking uucico -* Invoking uuxqt:: Invoking uuxqt -* Invoking uuchk:: Invoking uuchk -* Invoking uuconv:: Invoking uuconv -* Invoking uusched:: Invoking uusched -@end menu - -@node Standard Options, Invoking uucp, Invoking the UUCP Programs, Invoking the UUCP Programs -@section Standard Options - -All of the UUCP programs support a few standard options. - -@table @samp -@item -x type -@itemx --debug type -Turn on particular debugging types. The following types are recognized: -@samp{abnormal}, @samp{chat}, @samp{handshake}, @samp{uucp-proto}, -@samp{proto}, @samp{port}, @samp{config}, @samp{spooldir}, -@samp{execute}, @samp{incoming}, @samp{outgoing}. Not all types of -debugging are effective for all programs. See the @code{debug} -configuration command for details (@pxref{Debugging Levels}). - -Multiple types may be given, separated by commas, and the @samp{--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, -@samp{--debug 2} is equivalent to @samp{--debug abnormal,chat}. To turn -on all types of debugging, use @samp{-x all}. - -The @code{uulog} program uses @samp{-X} rather than @samp{-x} to select -the debugging type; for @code{uulog}, @samp{-x} has a different meaning, -for reasons of historical compatibility. - -@item -I file -@itemx --config file -Set the main configuration file to use. @xref{config File}. When this -option is used, the programs will revoke any setuid privileges. - -@item -v -@itemx --version -Report version information and exit. - -@item --help -Print a help message and exit. -@end table - -@need 2000 -@node Invoking uucp, Invoking uux, Standard Options, Invoking the UUCP Programs -@section Invoking uucp - -@menu -* uucp Description:: Description of uucp -* uucp Options:: Options Supported by uucp -@end menu - -@node uucp Description, uucp Options, Invoking uucp, Invoking uucp -@subsection uucp Description - -@example -uucp [options] @file{source-file} @file{destination-file} -uucp [options] @file{source-file}... @file{destination-directory} -@end example - -The @code{uucp} command copies files between systems. Each @file{file} -argument is either a file name on the local machine or is of the form -@samp{system!file}. The latter is interpreted as being on a remote -system. - -When @code{uucp} is used with two non-option arguments, the contents of -the first file are copied to the second. With more than two non-option -arguments, each source file is copied into the destination directory. - -A file may be transferred to or from @samp{system2} via @samp{system1} -by using @samp{system1!system2!file}. - -Any file name that does not begin with @samp{/} or @samp{~} will be -prepended with the current directory (unless the @samp{-W} or -@samp{--noexpand} options are used). For example, if you are in the -directory @samp{/home/ian}, then @samp{uucp foo remote!bar} is -equivalent to @samp{uucp /home/ian/foo remote!/home/ian/bar}. Note that -the resulting file name may not be valid on a remote system. - -A file name beginning with a simple @samp{~} starts at the UUCP public -directory; a file name beginning with @samp{~name} starts at the home -directory of the named user. The @samp{~} is interpreted on the -appropriate system. Note that some shells will interpret an initial -@samp{~} before @code{uucp} sees it; to avoid this the @samp{~} must be -quoted. - -The shell metacharacters @samp{?} @samp{*} @samp{[} and @samp{]} are -interpreted on the appropriate system, assuming they are quoted to -prevent the shell from interpreting them first. - -The file copy does not take place immediately, but is queued up for the -@code{uucico} daemon; the daemon is started immediately unless the -@samp{-r} or @samp{--nouucico} option is given. The next time the -remote system is called, the file(s) will be copied. @xref{Invoking -uucico}. - -The file mode is not preserved, except for the execute bit. The -resulting file is owned by the uucp user. - -@node uucp Options, , uucp Description, Invoking uucp -@subsection uucp Options - -The following options may be given to @code{uucp}. - -@table @samp -@item -c -@itemx --nocopy -Do not copy local source files to the spool directory. If they are -removed before being processed by the @code{uucico} daemon, the copy -will fail. The files must be readable by the @code{uucico} daemon, and -by the invoking user. - -@item -C -@itemx --copy -Copy local source files to the spool directory. This is the default. - -@item -d -@itemx --directories -Create all necessary directories when doing the copy. This is the -default. - -@item -f -@itemx --nodirectories -If any necessary directories do not exist for the destination file name, -abort the copy. - -@item -R -@itemx --recursive -If any of the source file names are directories, copy their contents -recursively to the destination (which must itself be a directory). - -@item -g grade -@itemx --grade grade -Set the grade of the file transfer command. Jobs of a higher grade are -executed first. Grades run @kbd{0} to @kbd{9}, @kbd{A} to @kbd{Z}, -@kbd{a} to @kbd{z}, from high to low. @xref{When to Call}. - -@item -m -@itemx --mail -Report completion or failure of the file transfer by sending mail. - -@item -n user -@itemx --notify user -Report completion or failure of the file transfer by sending mail to the -named user on the destination system. - -@item -r -@itemx --nouucico -Do not start the @code{uucico} daemon immediately; merely queue up the -file transfer for later execution. - -@item -j -@itemx --jobid -Print the jobid on standard output. The job may be later cancelled by -passing this jobid to the @samp{-kill} switch of @code{uustat}. -@xref{Invoking uustat}. - -It is possible for some complex operations to produce more than one -jobid, in which case each will be printed on a separate line. For -example -@example -uucp sys1!~user1/file1 sys2!~user2/file2 ~user3 -@end example -will generate two separate jobs, one for the system @samp{sys1} and one -for the system @samp{sys2}. - -@item -W -@itemx --noexpand -Do not prepend remote relative file names with the current directory. - -@item -t -@itemx --uuto -This option is used by the @code{uuto} shell script; see @ref{Invoking -uuto}. It causes @code{uucp} to interpret the final argument as -@samp{system!user}. The file(s) are sent to -@samp{~/receive/@var{user}/@var{local}} on the remote system, where -@var{user} is from the final argument and @var{local} is the local UUCP -system name. Also, @code{uucp} will act as though @samp{--notify user} -were specified. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node Invoking uux, Invoking uustat, Invoking uucp, Invoking the UUCP Programs -@section Invoking uux - -@menu -* uux Description:: Description of uux -* uux Options:: Options Supported by uux -* uux Examples:: Examples of uux Usage -@end menu - -@node uux Description, uux Options, Invoking uux, Invoking uux -@subsection uux Description - -@example -uux [options] command -@end example - -The @code{uux} command is used to execute a command on a remote system, -or to execute a command on the local system using files from remote -systems. The command is not executed immediately; the request is queued -until the @code{uucico} daemon calls the system and transfers the -necessary files. The daemon is started automatically unless one of the -@samp{-r} or @samp{--nouucico} options is given. - -The actual command execution is done by the @code{uuxqt} daemon on the -appropriate system. - -File arguments can be gathered from remote systems to the execution -system, as can standard input. Standard output may be directed to a -file on a remote system. - -The command name may be preceded by a system name followed by an -exclamation point if it is to be executed on a remote system. An empty -system name is taken as the local system. - -Each argument that contains an exclamation point is treated as naming a -file. The system which the file is on is before the exclamation point, -and the file name on that system follows it. An empty system name is -taken as the local system; this form must be used to transfer a file to -a command being executed on a remote system. If the file name is not -absolute, the current working directory will be prepended to it; the -result may not be meaningful on the remote system. A file name may -begin with @samp{~/}, in which case it is relative to the UUCP public -directory on the appropriate system. A file name may begin with -@samp{~name/}, in which case it is relative to the home directory of the -named user on the appropriate system. - -Standard input and output may be redirected as usual; the file names -used may contain exclamation points to indicate that they are on remote -systems. Note that the redirection characters must be quoted so that -they are passed to @code{uux} rather than interpreted by the shell. -Append redirection (@samp{>>}) does not work. - -All specified files are gathered together into a single directory -before execution of the command begins. This means that each file -must have a distinct name. For example, -@example -uux 'sys1!diff sys2!~user1/foo sys3!~user2/foo >!foo.diff' -@end example -will fail because both files will be copied to @samp{sys1} and stored -under the name @file{foo}. - -Arguments may be quoted by parentheses to avoid interpretation of -exclamation points. This is useful when executing the @code{uucp} -command on a remote system. - -Most systems restrict the commands which may be executed using -@samp{uux}. Many permit only the execution of @samp{rmail} and -@samp{rnews}. - -A request to execute an empty command (e.g., @samp{uux sys!}) will -create a poll file for the specified system; see @ref{Calling Other -Systems} for an example of why this might be useful. - -@node uux Options, uux Examples, uux Description, Invoking uux -@subsection uux Options - -The following options may be given to @code{uux}. - -@table @samp -@item - -@itemx -p -@itemx --stdin -Read standard input up to end of file, and use it as the standard input -for the command to be executed. - -@item -c -@itemx --nocopy -Do not copy local files to the spool directory. This is the default. -If they are removed before being processed by the @code{uucico} daemon, -the copy will fail. The files must be readable by the @code{uucico} -daemon, as well as the by the invoker of @code{uux}. - -@item -C -@itemx --copy -Copy local files to the spool directory. - -@item -l -@itemx --link -Link local files into the spool directory. If a file can not be linked -because it is on a different device, it will be copied unless one of the -@samp{-c} or @samp{--nocopy} options also appears (in other words, use -of @samp{--link} switches the default from @samp{--nocopy} to -@samp{--copy}). If the files are changed before being processed by the -@code{uucico} daemon, the changed versions will be used. The files must -be readable by the @code{uucico} daemon, as well as by the invoker of -@code{uux}. - -@item -g grade -@itemx --grade grade -Set the grade of the file transfer command. Jobs of a higher grade are -executed first. Grades run @kbd{0} to @kbd{9}, @kbd{A} to @kbd{Z}, -@kbd{a} to @kbd{z}, from high to low. @xref{When to Call}. - -@item -n -@itemx --notification=no -Do not send mail about the status of the job, even if it fails. - -@item -z -@itemx --notification=error -Send mail about the status of the job if an error occurs. For many -@code{uuxqt} daemons, including the Taylor UUCP @code{uuxqt}, this is -the default action; for those, @samp{--notification=error} will have no -effect. However, some @code{uuxqt} daemons will send mail if the job -succeeds, unless the @samp{--notification=error} option is used. Some -other @code{uuxqt} daemons will not send mail even if the job fails, -unless the @samp{--notification=error} option is used. - -@item -a address -@itemx --requestor address -Report job status, as controlled by the @samp{--notification} option, to -the specified mail address. - -@item -r -@itemx --nouucico -Do not start the @code{uucico} daemon immediately; merely queue up the -execution request for later processing. - -@item -j -@itemx --jobid -Print the jobid on standard output. A jobid will be generated for each -file copy operation required to execute the command. These file copies -may be later cancelled by passing the jobid to the @samp{-kill} switch -of @code{uustat}. @xref{Invoking uustat}. Cancelling any file copies -will make it impossible to complete execution of the job. - -@item -x type -@itemx --debug type -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node uux Examples, , uux Options, Invoking uux -@subsection uux Examples - -Here are some examples of using @code{uux}. - -@example -uux -z - sys1!rmail user1 -@end example -This will execute the command @samp{rmail user1} on the system -@samp{sys1}, giving it as standard input whatever is given to @code{uux} -as standard input. If a failure occurs, mail will be sent to the user -who ran the command. - -@example -uux 'diff -c sys1!~user1/file1 sys2!~user2/file2 >!file.diff' -@end example -This will fetch the two named files from system @samp{sys1} and system -@samp{sys2} and execute @samp{diff}, putting the result in -@file{file.diff} in the current directory on the local system. The -current directory must be writable by the @code{uuxqt} daemon for this -to work. - -@example -uux 'sys1!uucp ~user1/file1 (sys2!~user2/file2)' -@end example -Execute @code{uucp} on the system @samp{sys1} copying @file{file1} (on -system @samp{sys1}) to @samp{sys2}. This illustrates the use of -parentheses for quoting. - -@node Invoking uustat, Invoking uuname, Invoking uux, Invoking the UUCP Programs -@section Invoking uustat - -@menu -* uustat Description:: Description of uustat -* uustat Options:: Options Supported by uustat -* uustat Examples:: Examples of uustat Usage -@end menu - -@node uustat Description, uustat Options, Invoking uustat, Invoking uustat -@subsection uustat Description - -@example -uustat -a -uustat --all -uustat [-eKRiMNQ] [-sS system] [-uU user] [-cC command] [-oy hours] - [-B lines] [--executions] [--kill-all] [--rejuvenate-all] - [--prompt] [--mail] [--notify] [--no-list] [--system system] - [--not-system system] [--user user] [--not-user user] - [--command command] [--not-command command] [--older-than hours] - [--younger-than hours] [--mail-lines lines] -uustat [-kr jobid] [--kill jobid] [--rejuvenate jobid] -uustat -q [-sS system] [-oy hours] [--system system] - [--not-system system ] [--older-than hours] [--younger-than hours] -uustat --list [-sS system] [-oy hours] [--system system ] - [--not-system system] [--older-than hours] [--younger-than hours] -uustat -m -uustat --status -uustat -p -uustat --ps -@end example - -The @code{uustat} command can display various types of status -information about the UUCP system. It can also be used to cancel or -rejuvenate requests made by @code{uucp} or @code{uux}. - -With no options, @code{uustat} displays all jobs queued up for the -invoking user, as if given the @samp{--user} option with the appropriate -argument. - -If any of the @samp{-a}, @samp{--all}, @samp{-e}, @samp{--executions}, -@samp{-s}, @samp{--system}, @samp{-S}, @samp{--not-system}, @samp{-u}, -@samp{--user}, @samp{-U}, @samp{--not-user}, @samp{-c}, -@samp{--command}, @samp{-C}, @samp{--not-command}, @samp{-o}, -@samp{--older-than}, @samp{-y}, or @samp{--younger-than} options are -given, then all jobs which match the combined specifications are -displayed. - -The @samp{-K} or @samp{--kill-all} option may be used to kill off a -selected group of jobs, such as all jobs more than 7 days old. - -@node uustat Options, uustat Examples, uustat Description, Invoking uustat -@subsection uustat Options - -The following options may be given to @code{uustat}. - -@table @samp -@item -a -@itemx --all -List all queued file transfer requests. - -@item -e -@itemx --executions -List queued execution requests rather than queued file transfer -requests. Queued execution requests are processed by @code{uuxqt} -rather than @code{uucico}. Queued execution requests may be waiting for -some file to be transferred from a remote system. They are created by -an invocation of @code{uux}. - -@item -s system -@itemx --system system -List all jobs queued up for the named system. These options may be -specified multiple times, in which case all jobs for all the named -systems will be listed. If used with @samp{--list}, only the systems -named will be listed. - -@item -S system -@itemx --not-system system -List all jobs queued for systems other than the one named. These -options may be specified multiple times, in which case no jobs from any -of the specified systems will be listed. If used with @samp{--list}, -only the systems not named will be listed. These options may not be -used with @samp{-s} or @samp{--system}. - -@item -u user -@itemx --user user -List all jobs queued up for the named user. These options may be -specified multiple times, in which case all jobs for all the named users -will be listed. - -@item -U user -@itemx --not-user user -List all jobs queued up for users other than the one named. These -options may be specified multiple times, in which case no jobs from any -of the specified users will be listed. These options may not be used -with @samp{-u} or @samp{--user}. - -@item -c command -@itemx --command command -List all jobs requesting the execution of the named command. If -@samp{command} is @samp{ALL} this will list all jobs requesting the -execution of some command (as opposed to simply requesting a file -transfer). These options may be specified multiple times, in which case -all jobs requesting any of the commands will be listed. - -@item -C command -@itemx --not-command command -List all jobs requesting execution of some command other than the named -command, or, if @samp{command} is @samp{ALL}, list all jobs that simply -request a file transfer (as opposed to requesting the execution of some -command). These options may be specified multiple times, in which case -no job requesting one of the specified commands will be listed. These -options may not be used with @samp{-c} or @samp{--command}. - -@item -o hours -@itemx --older-than hours -List all queued jobs older than the given number of hours. If used with -@samp{--list}, only systems whose oldest job is older than the given -number of hours will be listed. - -@item -y hours -@itemx --younger-than hours -List all queued jobs younger than the given number of hours. If used -with @samp{--list}, only systems whose oldest job is younger than the -given number of hours will be listed. - -@item -k jobid -@itemx --kill jobid -Kill the named job. The job id is shown by the default output format, -as well as by the @samp{-j} or @samp{--jobid} options to @code{uucp} or -@code{uux}. A job may only be killed by the user who created the job, -or by the UUCP administrator, or the superuser. The @samp{-k} or -@samp{--kill} options may be used multiple times on the command line to -kill several jobs. - -@item -r jobid -@itemx --rejuvenate jobid -Rejuvenate the named job. This will mark it as having been invoked at -the current time, affecting the output of the @samp{-o}, -@samp{--older-than}, @samp{-y}, or @samp{--younger-than} options, -possibly preserving it from any automated cleanup daemon. The job id is -shown by the default output format, as well as by the @samp{-j} or -@samp{--jobid} options to @code{uucp} or @code{uux}. A job may only be -rejuvenated by the user who created the job, or by the UUCP -administrator, or the superuser. The @samp{-r} or @samp{--rejuvenate} -options may be used multiple times on the command line to rejuvenate -several jobs. - -@item -q -@itemx --list -Display the status of commands, executions and conversations for all -remote systems for which commands or executions are queued. The -@samp{-s}, @samp{--system}, @samp{-S}, @samp{--not-system}, @samp{-o}, -@samp{--older-than}, @samp{-y}, and @samp{--younger-than} options may be -used to restrict the systems which are listed. Systems for which no -commands or executions are queued will never be listed. - -@item -m -@itemx --status -Display the status of conversations for all remote systems. - -@item -p -@itemx --ps -Display the status of all processes holding UUCP locks on systems or -ports. - -@need 500 -@item -i -@itemx --prompt -For each listed job, prompt whether to kill the job or not. If the -first character of the input line is @kbd{y} or @kbd{Y}, the job will be -killed. - -@item -K -@itemx --kill-all -Automatically kill each listed job. This can be useful for automatic -cleanup scripts, in conjunction with the @samp{--mail} and -@samp{--notify} options. - -@item -R -@itemx --rejuvenate-all -Automatically rejuvenate each listed job. This may not be used with -@samp{--kill-all}. - -@item -M -@itemx --mail -For each listed job, send mail to the UUCP administrator. If the job is -killed (due to @samp{--kill-all}, or @samp{--prompt} with an affirmative -response) the mail will indicate that. A comment specified by the -@samp{--comment} option may be included. If the job is an execution, -the initial portion of its standard input will be included in the mail -message; the number of lines to include may be set with the -@samp{--mail-lines} option (the default is 100). If the standard input -contains null characters, it is assumed to be a binary file and is not -included. - -@item -N -@itemx --notify -For each listed job, send mail to the user who requested the job. The -mail is identical to that sent by the @samp{-M} or @samp{--mail} -options. - -@item -W comment -@itemx --comment comment -Specify a comment to be included in mail sent with the @samp{-M}, -@samp{--mail}, @samp{-N}, or @samp{--notify} options. - -@item -B lines -@itemx --mail-lines lines -When the @samp{-M}, @samp{--mail}, @samp{-N}, or @samp{--notify} options -are used to send mail about an execution with standard input, this -option controls the number of lines of standard input to include in the -message. The default is 100. - -@item -Q -@itemx --no-list -Do not actually list the job, but only take any actions indicated by the -@samp{-i}, @samp{--prompt}, @samp{-K}, @samp{--kill-all}, @samp{-M}, -@samp{--mail}, @samp{-N} or @samp{--notify} options. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node uustat Examples, , uustat Options, Invoking uustat -@subsection uustat Examples - -@example -uustat --all -@end example -Display status of all jobs. A sample output line is as follows: -@smallexample -bugsA027h bugs ian 04-01 13:50 Executing rmail ian@@airs.com (sending 12 bytes) -@end smallexample -The format is -@example -jobid system user queue-date command (size) -@end example -The jobid may be passed to the @samp{--kill} or @samp{--rejuvenate} -options. The size indicates how much data is to be transferred to the -remote system, and is absent for a file receive request. The -@samp{--system}, @samp{--not-system}, @samp{--user}, @samp{--not-user}, -@samp{--command}, @samp{--not-command}, @samp{--older-than}, and -@samp{--younger-than} options may be used to control which jobs are -listed. - -@example -uustat --executions -@end example -Display status of queued up execution requests. A sample output line -is as follows: -@smallexample -bugs bugs!ian 05-20 12:51 rmail ian -@end smallexample -The format is -@example -system requestor queue-date command -@end example -The @samp{--system}, @samp{--not-system}, @samp{--user}, -@samp{--not-user}, @samp{--command}, @samp{--not-command}, -@samp{--older-than}, and @samp{--younger-than} options may be used to -control which requests are listed. - -@example -uustat --list -@end example -Display status for all systems with queued up commands. A sample -output line is as follows: -@smallexample -bugs 4C (1 hour) 0X (0 secs) 04-01 14:45 Dial failed -@end smallexample -This indicates the system, the number of queued commands, the age of the -oldest queued command, the number of queued local executions, the age of -the oldest queued execution, the date of the last conversation, and the -status of that conversation. - -@example -uustat --status -@end example -Display conversation status for all remote systems. A sample output -line is as follows: -@smallexample -bugs 04-01 15:51 Conversation complete -@end smallexample -This indicates the system, the date of the last conversation, and the -status of that conversation. If the last conversation failed, -@code{uustat} will indicate how many attempts have been made to call the -system. If the retry period is currently preventing calls to that -system, @code{uustat} also displays the time when the next call will be -permitted. - -@example -uustat --ps -@end example -Display the status of all processes holding UUCP locks. The output -format is system dependent, as @code{uustat} simply invokes @code{ps} on -each process holding a lock. - -@example -uustat -c rmail -o 168 -K -Q -M -N -W "Queued for over 1 week" -@end example -This will kill all @samp{rmail} commands that have been queued up -waiting for delivery for over 1 week (168 hours). For each such -command, mail will be sent both to the UUCP administrator and to the -user who requested the rmail execution. The mail message sent will -include the string given by the @samp{-W} option. The @samp{-Q} option -prevents any of the jobs from being listed on the terminal, so any -output from the program will be error messages. - -@node Invoking uuname, Invoking uulog, Invoking uustat, Invoking the UUCP Programs -@section Invoking uuname - -@example -uuname [-a] [--aliases] -uuname -l -uuname --local -@end example - -By default, the @code{uuname} program simply lists the names of all the -remote systems mentioned in the UUCP configuration files. - -The @code{uuname} program may also be used to print the UUCP name of the -local system. - -The @code{uuname} program is mainly for use by shell scripts. - -The following options may be given to @code{uuname}. - -@table @samp -@item -a -@itemx --aliases -List all aliases for remote systems, as well as their canonical names. -Aliases may be specified in the @file{sys} file (@pxref{Naming the -System}). - -@item -l -@itemx --local -Print the UUCP name of the local system, rather than listing the names -of all the remote systems. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node Invoking uulog, Invoking uuto, Invoking uuname, Invoking the UUCP Programs -@section Invoking uulog - -@example -uulog [-#] [-n lines] [-sf system] [-u user] [-DSF] [--lines lines] - [--system system] [--user user] [--debuglog] [--statslog] - [--follow] [--follow=system] -@end example - -The @code{uulog} program may be used to display the UUCP log file. -Different options may be used to select which parts of the file to -display. - -@table @samp -@item -# -@itemx -n lines -@itemx --lines lines -Here @samp{#} is a number; e.g., @samp{-10}. The specified number of -lines is displayed from the end of the log file. The default is to -display the entire log file, unless the @samp{-f}, @samp{-F}, or -@samp{--follow} options are used, in which case the default is to -display 10 lines. - -@item -s system -@itemx --system system -Display only log entries pertaining to the specified system. - -@item -u user -@itemx --user user -Display only log entries pertaining to the specified user. - -@item -D -@itemx --debuglog -Display the debugging log file. - -@item -S -@itemx --statslog -Display the statistics log file. - -@item -F -@itemx --follow -Keep displaying the log file forever, printing new lines as they are -appended to the log file. - -@item -f system -@itemx --follow=system -Keep displaying the log file forever, displaying only log entries -pertaining to the specified system. - -@item -X type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. Note that @code{uulog} specifies the debugging -type using @samp{-X} rather than the usual @samp{-x}. -@end table - -The operation of @code{uulog} depends to some degree upon the type of -log files generated by the UUCP programs. This is a compile time -option. If the UUCP programs have been compiled to use HDB style log -files, @code{uulog} changes in the following ways: - -@itemize @bullet -@item -The new options @samp{-x} and @samp{--uuxqtlog} may be used to list the -@code{uuxqt} log file. - -@item -It is no longer possible to omit all arguments: one of @samp{-s}, -@samp{--system}, @samp{-f}, @samp{--follow=system}, @samp{-D}, -@samp{--debuglog}, @samp{-S}, @samp{--statslog}, @samp{-x}, or -@samp{--uuxqtlog} must be used. - -@item -The option @samp{--system ANY} may be used to list log file entries -which do not pertain to any particular system. -@end itemize - -@node Invoking uuto, Invoking uupick, Invoking uulog, Invoking the UUCP Programs -@section Invoking uuto - -@example -uuto files... system!user -@end example - -The @code{uuto} program may be used to conveniently send files to a -particular user on a remote system. It will arrange for mail to be sent -to the remote user when the files arrive on the remote system, and he or -she may easily retrieve the files using the @code{uupick} program -(@pxref{Invoking uupick}). Note that @code{uuto} does not provide any -security---any user on the remote system can examine the files. - -The last argument specifies the system and user name to which to send -the files. The other arguments are the files or directories to be sent. - -The @code{uuto} program is actually just a trivial shell script which -invokes the @code{uucp} program with the appropriate arguments. Any -option which may be given to @code{uucp} may also be given to -@code{uuto}. @xref{Invoking uucp}. - -@need 2000 -@node Invoking uupick, Invoking cu, Invoking uuto, Invoking the UUCP Programs -@section Invoking uupick - -@example -uupick [-s system] [--system system] -@end example - -The @code{uupick} program is used to conveniently retrieve files -transferred by the @code{uuto} program. - -For each file transferred by @code{uuto}, @code{uupick} will display the -source system, the file name, and whether the name refers to a regular -file or a directory. It will then wait for the user to specify an -action to take. One of the following commands must be entered: - -@table @samp -@item q -Quit out of @code{uupick}. - -@item RETURN -Skip the file. - -@item m [directory] -Move the file or directory to the specified directory. If no directory -is specified, the file is moved to the current directory. - -@item a [directory] -Move all files from this system to the specified directory. If no -directory is specified, the files are moved to the current directory. - -@item p -List the file on standard output. - -@item d -Delete the file. - -@item ! [command] -Execute @samp{command} as a shell escape. -@end table - -The @samp{-s} or @samp{--system} option may be used to restrict -@code{uupick} to only present files transferred from a particular -system. The @code{uupick} program also supports the standard UUCP -program options; see @ref{Standard Options}. - -@need 2000 -@node Invoking cu, Invoking uucico, Invoking uupick, Invoking the UUCP Programs -@section Invoking cu - -@menu -* cu Description:: Description of cu -* cu Commands:: Commands Supported by cu -* cu Variables:: Variables Supported by cu -* cu Options:: Options Supported by cu -@end menu - -@node cu Description, cu Commands, Invoking cu, Invoking cu -@subsection cu Description - -@example -cu [options] [system | phone | "dir"] -@end example - -The @code{cu} program is used to call up another system and act as a -dial in terminal. It can also do simple file transfers with no error -checking. - -The @code{cu} program takes a single non-option argument. - -If the argument is the string @samp{dir} cu will make a direct -connection to the port. This may only be used by users with write -access to the port, as it permits reprogramming the modem. - -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 @samp{-z} or @samp{--system} options may be used to name a system -beginning with a digit, and the @samp{-c} or @samp{--phone} options may -be used to name a phone number that does not begin with a digit. - -The @code{cu} program 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 @samp{-p}, @samp{--port}, @samp{-l}, -@samp{--line}, @samp{-s}, and @samp{--speed} options may be used to -control the port selection. - -When a connection is made to the remote system, @code{cu} forks into two -processes. One reads from the port and writes to the terminal, while -the other reads from the terminal and writes to the port. - -@node cu Commands, cu Variables, cu Description, Invoking cu -@subsection cu Commands - -The @code{cu} program provides several commands that may be used during -the conversation. The commands all begin with an escape character, -which by default is @kbd{~} (tilde). The escape character is only -recognized at the beginning of a line. To send an escape character to -the remote system at the start of a line, it must be entered twice. All -commands are either a single character or a word beginning with @kbd{%} -(percent sign). - -The @code{cu} program recognizes the following commands. - -@table @samp -@item ~. -Terminate the conversation. - -@item ~! command -Run command in a shell. If command is empty, starts up a shell. - -@item ~$ command -Run command, sending the standard output to the remote system. - -@item ~| command -Run command, taking the standard input from the remote system. - -@item ~+ command -Run command, taking the standard input from the remote system and -sending the standard output to the remote system. - -@item ~#, ~%break -Send a break signal, if possible. - -@item ~c directory, ~%cd directory -Change the local directory. - -@item ~> file -Send a file to the remote system. This just dumps the file over the -communication line. It is assumed that the remote system is expecting -it. - -@item ~< -Receive a file from the remote system. This prompts for the local file -name and for the remote command to execute to begin the file transfer. -It continues accepting data until the contents of the @samp{eofread} -variable are seen. - -@item ~p from to -@itemx ~%put from to -Send a file to a remote Unix system. This runs the appropriate -commands on the remote system. - -@item ~t from to -@itemx ~%take from to -Retrieve a file from a remote Unix system. This runs the appropriate -commands on the remote system. - -@item ~s variable value -Set a @code{cu} variable to the given value. If value is not given, the -variable is set to @samp{true}. - -@item ~! variable -Set a @code{cu} variable to @samp{false}. - -@item ~z -Suspend the cu session. This is only supported on some systems. On -systems for which @kbd{^Z} may be used to suspend a job, @samp{~^Z} will -also suspend the session. - -@item ~%nostop -Turn off XON/XOFF handling. - -@item ~%stop -Turn on XON/XOFF handling. - -@item ~v -List all the variables and their values. - -@item ~? -List all commands. -@end table - -@node cu Variables, cu Options, cu Commands, Invoking cu -@subsection cu Variables - -The @code{cu} program also supports several variables. They may be -listed with the @samp{~v} command, and set with the @samp{~s} or -@samp{~!} commands. - -@table @samp -@item escape -The escape character. The default is @kbd{~} (tilde). - -@item delay -If this variable is true, @code{cu} will delay for a second, after -recognizing the escape character, before printing the name of the local -system. The default is true. - -@item eol -The list of characters which are considered to finish a line. The -escape character is only recognized after one of these is seen. The -default is @kbd{carriage return}, @kbd{^U}, @kbd{^C}, @kbd{^O}, -@kbd{^D}, @kbd{^S}, @kbd{^Q}, @kbd{^R}. - -@item binary -Whether to transfer binary data when sending a file. If this is false, -then newlines in the file being sent are converted to carriage returns. -The default is false. - -@item binary-prefix -A string used before sending a binary character in a file transfer, if -the @samp{binary} variable is true. The default is @samp{^V}. - -@item echo-check -Whether to check file transfers by examining what the remote system -echoes back. This probably doesn't work very well. The default is -false. - -@item echonl -The character to look for after sending each line in a file. The -default is carriage return. - -@item timeout -The timeout to use, in seconds, when looking for a character, either -when doing echo checking or when looking for the @samp{echonl} -character. The default is 30. - -@item kill -The character to use delete a line if the echo check fails. The default -is @kbd{^U}. - -@item resend -The number of times to resend a line if the echo check continues to -fail. The default is 10. - -@item eofwrite -The string to write after sending a file with the @samp{~>} command. -The default is @samp{^D}. - -@item eofread -The string to look for when receiving a file with the @samp{ ~<} -command. The default is @samp{$}, which is intended to be a typical -shell prompt. - -@item verbose -Whether to print accumulated information during a file transfer. The -default is true. -@end table - -@node cu Options, , cu Variables, Invoking cu -@subsection cu Options - -The following options may be given to @code{cu}. - -@table @samp -@item -e -@itemx --parity=even -Use even parity. - -@item -o -@itemx --parity=odd -Use odd parity. - -@item --parity=none -Use no parity. No parity is also used if both @samp{-e} and @samp{-o} -are given. - -@item -h -@itemx --halfduplex -Echo characters locally (half-duplex mode). - -@item --nostop -Turn off XON/XOFF handling (it is on by default). - -@item -E char -@itemx --escape char -Set the escape character. Initially @kbd{~} (tilde). To eliminate the -escape character, use @samp{-E ''}. - -@item -z system -@itemx --system system -The system to call. - -@item -c phone-number -@itemx --phone phone-number -The phone number to call. - -@item -p port -@itemx -a port -@itemx --port port -Name the port to use. - -@item -l line -@itemx --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. - -@item -s speed -@itemx -# -@itemx --speed speed -The speed (baud rate) to use. Here, @samp{-#} means an actual number; -e.g., @samp{-9600}. - -@item -n -@itemx --prompt -Prompt for the phone number to use. - -@item -d -Enter debugging mode. Equivalent to @samp{--debug all}. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node Invoking uucico, Invoking uuxqt, Invoking cu, Invoking the UUCP Programs -@section Invoking uucico - -@menu -* uucico Description:: Description of uucico -* uucico Options:: Options Supported by uucico -@end menu - -@node uucico Description, uucico Options, Invoking uucico, Invoking uucico -@subsection uucico Description - -@example -uucico [options] -@end example - -The @code{uucico} daemon processes file transfer requests queued by -@code{uucp} and @code{uux}. It is started when @code{uucp} or -@code{uux} is run (unless they are given the @samp{-r} or -@samp{--nouucico} options). It is also typically started periodically -using entries in the @file{crontab} table(s). - -When @code{uucico} is invoked with @samp{-r1}, @samp{--master}, -@samp{-s}, @samp{--system}, or @samp{-S}, the daemon will place a call -to a remote system, running in master mode. Otherwise the daemon will -start in slave mode, accepting a call from a remote system. Typically a -special login name will be set up for UUCP which automatically invokes -@code{uucico} when a remote system calls in and logs in under that name. - -When @code{uucico} terminates, it invokes the @code{uuxqt} daemon, -unless the @samp{-q} or @samp{--nouuxqt} options were given; -@code{uuxqt} executes any work orders created by @code{uux} on a remote -system, and any work orders created locally which have received remote -files for which they were waiting. - -If a call fails, @code{uucico} will normally refuse to retry the call -until a certain (configurable) amount of time has passed. This may be -overriden by the @samp{-f}, @samp{--force}, or @samp{-S} options. - -The @samp{-l}, @samp{--prompt}, @samp{-e}, or @samp{--loop} options may -be used to force @code{uucico} to produce its own prompts of -@samp{login: } and @samp{Password:}. When another @code{uucico} daemon -calls in, it will see these prompts and log in as usual. The login name -and password will normally be checked against a separate list kept -specially for @code{uucico}, rather than the @file{/etc/passwd} file -(@pxref{Configuration File Names}). It is possible, on some systems, to -configure @code{uucico} to use @file{/etc/passwd}. The @samp{-l} or -@samp{--prompt} options will prompt once and then exit; in this mode the -UUCP administrator, or the superuser, may use the @samp{-u} or -@samp{--login} option to force a login name, in which case @code{uucico} -will not prompt for one. The @samp{-e} or @samp{--loop} options will -prompt again after the first session is over; in this mode @code{uucico} -will permanently control a port. - -If @code{uucico} receives a @code{SIGQUIT}, @code{SIGTERM} or -@code{SIGPIPE} signal, it will cleanly abort any current conversation -with a remote system and exit. If it receives a @code{SIGHUP} signal it -will abort any current conversation, but will continue to place calls to -(if invoked with @samp{-r1} or @samp{--master}) and accept calls from -(if invoked with @samp{-e} or @samp{--loop}) other systems. If it -receives a @code{SIGINT} signal it will finish the current conversation, -but will not place or accept any more calls. - -@node uucico Options, , uucico Description, Invoking uucico -@subsection uucico Options - -The following options may be given to @code{uucico}. - -@table @samp -@item -r1 -@itemx --master -Start in master mode: call out to a remote system. Implied by -@samp{-s}, @samp{--system}, or @samp{-S}. If no system is specified, -sequentially call every system for which work is waiting to be done. - -@item -r0 -@itemx --slave -Start in slave mode. This is the default. - -@item -s system -@itemx --system system -Call the specified system. - -@item -S system -Call the specified system, ignoring any required wait. This is -equivalent to @samp{-s system -f}. - -@item -f -@itemx --force -Ignore any required wait for any systems to be called. - -@item -l -@itemx --prompt -Prompt for login name and password using @samp{login: } and -@samp{Password:}. This allows @code{uucico} to be easily run from -@code{inetd}. The login name and password are checked against the UUCP -password file, which need not be @file{/etc/passwd}. The @samp{--login} -option may be used to force a login name, in which cause @code{uucico} -will only prompt for a password. - -@item -p port -@itemx --port port -Specify a port to call out on or to listen to. - -@item -e -@itemx --loop -Enter an endless loop of login/password prompts and slave mode daemon -execution. The program will not stop by itself; you must use -@code{kill} to shut it down. - -@item -w -@itemx --wait -After calling out (to a particular system when @samp{-s}, -@samp{--system}, or @samp{-S} is specifed, or to all systems which have -work when just @samp{-r1} or @samp{--master} is specifed), begin an -endless loop as with @samp{--loop}. - -@item -q -@itemx --nouuxqt -Do not start the @code{uuxqt} daemon when finished. - -@item -c -@itemx --quiet -If no calls are permitted at this time, then don't make the call, but -also do not put an error message in the log file and do not update the -system status (as reported by @code{uustat}). This can be convenient -for automated polling scripts, which may want to simply attempt to call -every system rather than worry about which particular systems may be -called at the moment. This option also suppresses the log message -indicating that there is no work to be done. - -@item -C -@itemx --ifwork -Only call the system named by @samp{-s}, @samp{--system}, or @samp{-S} -if there is work for that system. - -@item -D -@itemx --nodetach -Do not detach from the controlling terminal. Normally @code{uucico} -detaches from the terminal before each call out to another system and -before invoking @code{uuxqt}. This option prevents this. - -@item -u name -@itemx --login name -Set the login name to use instead of that of the invoking user. This -option may only be used by the UUCP administrator or the superuser. If -used with @samp{--prompt}, this will cause @code{uucico} to prompt only -for the password, not the login name. - -@item -z -@itemx --try-next -If a call fails after the remote system is reached, try the next -alternate rather than simply exiting. - -@item -i type -@itemx --stdin type -Set the type of port to use when using standard input. The only -supported port type is TLI, and this is only available on machines which -support the TLI networking interface. Specifying @samp{-i TLI} causes -@code{uucico} to use TLI calls to perform I/O. - -@item -X type -Same as the standard option @samp{-x type}. Provided for historical -compatibility. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config file -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node Invoking uuxqt, Invoking uuchk, Invoking uucico, Invoking the UUCP Programs -@section Invoking uuxqt - -@example -uuxqt [-c command] [-s system] [--command command] [--system system] -@end example - -The @code{uuxqt} daemon executes commands requested by @code{uux} from -either the local system or from remote systems. It is started -automatically by the @code{uucico} daemon (unless @code{uucico} is given -the @samp{-q} or @samp{--nouuxqt} options). - -There is normally no need to run @code{uuxqt}, since it will be invoked -by @code{uucico}. However, @code{uuxqt} can be invoked directly to -provide greater control over the processing of the work queue. - -Multiple invocations of @code{uuxqt} may be run at once, as controlled -by the @code{max-uuxqts} configuration command; see @ref{Miscellaneous -(config)}. - -The following options may be given to @code{uuxqt}. - -@table @samp -@item -c command -@itemx --command command -Only execute requests for the specified command. For example, -@samp{uuxqt --command rmail}. - -@item -s system -@itemx --system system -Only execute requests originating from the specified system. - -@item -x type -@itemx --debug type -@itemx -I file -@itemx --config -@itemx -v -@itemx --version -@itemx --help -@xref{Standard Options}. -@end table - -@node Invoking uuchk, Invoking uuconv, Invoking uuxqt, Invoking the UUCP Programs -@section Invoking uuchk - -@example -uuchk [-s system] [--system system] -@end example - -The @code{uuchk} program displays information read from the UUCP -configuration files. It should be used to ensure that UUCP has been -configured correctly. - -The @samp{-s} or @samp{--system} options may be used to display the -configuration for just the specified system, rather than for all -systems. The @code{uuchk} program also supports the standard UUCP -program options; see @ref{Standard Options}. - -@need 2000 -@node Invoking uuconv, Invoking uusched, Invoking uuchk, Invoking the UUCP Programs -@section Invoking uuconv - -@example -uuconv -i type -o type [-p program] [--program program] -uuconv --input type --output type [-p program] [--program program] -@end example - -The @code{uuconv} program converts UUCP configuration files from one -format to another. The type of configuration file to read is specified -using the @samp{-i} or @samp{--input} options. The type of -configuration file to write is specified using the @samp{-o} or -@samp{--output} options. - -The supported configuration file types are @samp{taylor}, @samp{v2}, and -@samp{hdb}. For a description of the @samp{taylor} configuration files, -see @ref{Configuration Files}. The other types of configuration files -are used by traditional UUCP packages, and are not described in this -manual. - -An input configuration of type @samp{v2} or @samp{hdb} is read from a -compiled in directory (specified by @samp{oldconfigdir} in -@file{Makefile}). An input configuration of type @samp{taylor} is read -from a compiled in directory by default, but may be overridden with the -standard @samp{-I} or @samp{--config} options (@pxref{Standard -Options}). - -The output configuration is written to files in the directory in which -@code{uuconv} is run. - -Some information in the input files may not be representable in the -desired output format, in which case @code{uuconv} will silently discard -it. The output of @code{uuconv} should be carefully checked before it -is used. The @code{uuchk} program may be used for this purpose; see -@ref{Invoking uuchk}. - -The @samp{-p} or @samp{--program} option may be used to convert specific -@code{cu} configuration information, rather than the default of only -converting the @code{uucp} configuration information; see @ref{config -File}. - -The @code{uuchk} program also supports the standard UUCP program -options; see @ref{Standard Options}. - -@node Invoking uusched, , Invoking uuconv, Invoking the UUCP Programs -@section Invoking uusched - -The @code{uusched} program is actually just a shell script which invokes -the @code{uucico} daemon. It is provided for backward compatibility. -It causes @code{uucico} to call all systems for which there is work. -Any option which may be given to @code{uucico} may also be given to -@code{uusched}. @xref{Invoking uucico}. - -@node Installing Taylor UUCP, Using Taylor UUCP, Invoking the UUCP Programs, Top -@chapter Installing Taylor UUCP - -These are the installation instructions for the Taylor UUCP package. - -@menu -* Compilation:: Compiling Taylor UUCP -* Testing the Compilation:: Testing the Compilation -* Installing the Binaries:: Installing the Binaries -* Configuration:: Configuring Taylor UUCP -* Testing the Installation:: Testing the Installation -@end menu - -@node Compilation, Testing the Compilation, Installing Taylor UUCP, Installing Taylor UUCP -@section Compiling Taylor UUCP - -If you have a source code distribution, you must first compile it for -your system. Free versions of Unix, such as Linux, NetBSD, or FreeBSD, -often come with pre-compiled binary distributions of UUCP. If you are -using a binary distribution, you may skip to the configuration section -(@pxref{Configuration}). - -Follow these steps to compile the source code. - -@enumerate - -@item -Take a look at the top of @file{Makefile.in} and set the appropriate -values for your system. These control where the programs are installed -and which user on the system owns them (normally they will be owned by a -special user @code{uucp} rather than a real person; they should probably -not be owned by @code{root}). - -@item -Run the shell script @code{configure}. This script was generated using -the @code{autoconf} program written by David MacKenzie of the Free -Software Foundation. It takes a while to run. It will generate the -file @file{config.h} based on @file{config.h.in}, and, for each source -code directory, will generate @file{Makefile} based on -@file{Makefile.in}. - -You can pass certain arguments to @code{configure} in the environment. -Because @code{configure} will compile little test programs to see what -is available on your system, you must tell it how to run your compiler. -It recognizes the following environment variables: - -@table @samp -@item CC -The C compiler. If this is not set, then if @code{configure} can find -@samp{gcc} it will use it, otherwise it will use @samp{cc}. -@item CFLAGS -Flags to pass to the C compiler when compiling the actual code. If this -is not set, @code{configure} will use @samp{-g}. -@item LDFLAGS -Flags to pass to the C compiler when only linking, not compiling. If -this is not set, @code{configure} will use the empty string. -@item LIBS -Libraries to pass to the C compiler. If this is not set, -@code{configure} will use the empty string. -@item INSTALL -The program to run to install UUCP in the binary directory. If this is -not set, then if @code{configure} finds the BSD @code{install} program, -it will set this to @samp{install -c}; otherwise, it will use @samp{cp}. -@end table - -Suppose, for example, you want to set the environment variable @samp{CC} -to @samp{rcc}. If you are using @code{sh}, @code{bash}, or @code{ksh}, -invoke @code{configure} as @samp{CC=rcc configure}. If you are using -@code{csh}, do @samp{setenv CC rcc; sh configure}. - -On some systems you will want to use @samp{LIBS=-lmalloc}. On Xenix -derived versions of Unix do not use @samp{LIBS=-lx} because this will -bring in the wrong versions of certain routines; if you want to use -@samp{-lx} you must specify @samp{LIBS=-lc -lx}. - -If @code{configure} fails for some reason, or if you have a very weird -system, you may have to configure the package by hand. To do this, copy -the file @file{config.h.in} to @file{config.h} and edit it for your -system. Then for each source directory (the top directory, and the -subdirectories @file{lib}, @file{unix}, and @file{uuconf}) copy -@file{Makefile.in} to @file{Makefile}, find the words within @kbd{@@} -characters, and set them correctly for your system. - -@item -Igor V. Semenyuk provided this (lightly edited) note about ISC Unix 3.0. -The @code{configure} script will default to passing @samp{-posix} to -@code{gcc}. However, using @samp{-posix} changes the environment to -POSIX, and on ISC 3.0, at least, the default for @code{POSIX_NO_TRUNC} -is 1. This can lead to a problem when @code{uuxqt} executes -@code{rmail}. @code{IDA sendmail} has dbm configuration files named -@file{mailertable.@{dir,pag@}}. Notice these names are 15 characters -long. When @code{uuxqt} compiled with the @samp{-posix} executes -@code{rmail}, which in turn executes @code{sendmail}, the later is run -under the POSIX environment too. This leads to @code{sendmail} bombing -out with @samp{'error opening 'M' database: name too long' -(mailertable.dir)}. It's rather obscure behaviour, and it took me a day -to find out the cause. I don't use the @samp{-posix} switch; instead, I -run @code{gcc} with @samp{-D_POSIX_SOURCE}, and add @samp{-lcposix} to -@samp{LIBS}. - -@item -On some versions of BSDI there is a bug in the shell which causes the -default value for @samp{CFLAGS} to be set incorrectly. If @samp{echo -$@{CFLAGS--g@}} echoes @samp{g} rather than @samp{-g}, then you must set -@samp{CFLAGS} in the environment before running configure. There is a -patch available from BSDI for this bug. (Reported by David Vrona). - -@item -On AIX 3.2.5, and possibly other versions, @samp{cc -E} does not work, -reporting @samp{Option NOROCONST is not valid}. Test this before -running configure by doing something like @samp{touch /tmp/foo.c; cc -E -/tmp/foo.c}. This may give a warning about the file being empty, but it -should not give the @samp{Option NOROCONST} warning. The workaround is -to remove the @samp{,noroconst} entry from the @samp{options} clause in -the @samp{cc} stanza in @file{/etc/xlc.cfg}. (Reported by Chris Lewis). - -@item -You should verify that @code{configure} worked correctly by checking -@file{config.h} and the instances of @file{Makefile}. - -@item -Edit @file{policy.h} for your local system. The comments explain the -various choices. The default values are intended to be reasonable, so -you may not have to make any changes. - -You must decide what type of configuration files to use; for more -information on the choices, see @ref{Configuration}. - -You must also decide what sort of spool directory you want to use. If -this is a new installation, I recommend @samp{SPOOLDIR_TAYLOR}; -otherwise, select the spool directory corresponding to your existing -UUCP package. - -@item -Type @samp{make} to compile everything. - -The @file{tstuu.c} file is not particularly portable; if you can't -figure out how to compile it you can safely ignore it, as it is only -used for testing. To use STREAMS pseudo-terminals, tstuu.c must be -compiled with @samp{-DHAVE_STREAMS_PTYS}; this is not determined by the -configure script. - -If you have any other problems there is probably a bug in the -@code{configure} script. - -@item -Please report any problems you have. That is the only way they will get -fixed for other people. Supply a patch if you can (@pxref{Patches}), or -just ask for help. - -@end enumerate - -@node Testing the Compilation, Installing the Binaries, Compilation, Installing Taylor UUCP -@section Testing the Compilation - -If your system supports pseudo-terminals, and you compiled the code to -support the new style of configuration files (@code{HAVE_TAYLOR_CONFIG} -was set to 1 in @file{policy.h}), you should be able to use the -@code{tstuu} program to test the @code{uucico} daemon. If your system -supports STREAMS based pseudo-terminals, you must compile tstuu.c with -@samp{-DHAVE_STREAMS_PTYS}. (The STREAMS based code was contributed by -Marc Boucher). - -To run @code{tstuu}, just type @samp{tstuu} with no arguments. You must -run it in the compilation directory, since it runs @file{./uucp}, -@file{./uux} and @file{./uucico}. The @code{tstuu} program will run a -lengthy series of tests (it takes over ten minutes on a slow VAX). You -will need a fair amount of space available in @file{/usr/tmp}. You will -probably want to put it in the background. Do not use @kbd{^Z}, because -the program traps on @code{SIGCHLD} and winds up dying. The -@code{tstuu} program will create a directory @file{/usr/tmp/tstuu} and -fill it with configuration files, and create spool directories -@file{/usr/tmp/tstuu/spool1} and @file{/usr/tmp/tstuu/spool2}. - -If your system does not support the @code{FIONREAD} call, the -@samp{tstuu} program will run very slowly. This may or may not get -fixed in a later version. - -The @code{tstuu} program will finish with an execute file named -@file{X.@var{something}} and a data file named @file{D.@var{something}} -in the directory @file{/usr/tmp/tstuu/spool1} (or, more likely, in -subdirectories, depending on the choice of @code{SPOOLDIR} in -@file{policy.h}). Two log files will be created in the directory -@file{/usr/tmp/tstuu}. They will be named @file{Log1} and @file{Log2}, -or, if you have selected @code{HAVE_HDB_LOGGING} in @file{policy.h}, -@file{Log1/uucico/test2} and @file{Log2/uucico/test1}. There should be -no errors in the log files. - -You can test @code{uuxqt} with @samp{./uuxqt -I /usr/tmp/tstuu/Config1}. -This should leave a command file @file{C.@var{something}} and a data -file @file{D.@var{something}} in @file{/usr/tmp/tstuu/spool1} or in -subdirectories. Again, there should be no errors in the log file. - -Assuming you compiled the code with debugging enabled, the @samp{-x} -switch can be used to set debugging modes; see the @code{debug} command -for details (@pxref{Debugging Levels}). Use @samp{-x all} to turn on -all debugging and generate far more output than you will ever want to -see. The @code{uucico} daemons will put debugging output in the files -@file{Debug1} and @file{Debug2} in the directory @file{/usr/tmp/tstuu}. -After that, you're pretty much on your own. - -On some systems you can also use @code{tstuu} to test @code{uucico} -against the system @code{uucico}, by using the @samp{-u} switch. For -this to work, change the definitions of @code{ZUUCICO_CMD} and -@code{UUCICO_EXECL} at the top of @file{tstuu.c} to something -appropriate for your system. The definitions in @file{tstuu.c} are what -I used for Ultrix 4.0, on which @file{/usr/lib/uucp/uucico} is -particularly obstinate about being run as a child; I was only able to -run it by creating a login name with no password whose shell was -@file{/usr/lib/uucp/uucico}. Calling login in this way will leave fake -entries in @file{wtmp} and @file{utmp}; if you compile @file{tstout.c} -(in the @file{contrib} directory) as a setuid @code{root} program, -@code{tstuu} will run it to clear those entries out. On most systems, -such hackery should not be necessary, although on SCO I had to su to -@code{root} (@code{uucp} might also have worked) before I could run -@file{/usr/lib/uucp/uucico}. - -You can test @code{uucp} and @code{uux} (give them the @samp{-r} switch -to keep them from starting @code{uucico}) to make sure they create the -right sorts of files. Unfortunately, if you don't know what the right -sorts of files are, I'm not going to tell you here. - -If you can not run @code{tstuu}, or if it fails inexplicably, don't -worry about it too much. On some systems @code{tstuu} will fail because -of problems using pseudo terminals, which will not matter in normal use. -The real test of the package is talking to another system. - -@node Installing the Binaries, Configuration, Testing the Compilation, Installing Taylor UUCP -@section Installing the Binaries - -You can install the executable files by becoming @code{root} and typing -@samp{make install}. Or you can look at what @samp{make install} does -and do it by hand. It tries to preserve your old programs, if any, but -it only does this the first time Taylor UUCP is installed (so that if -you install several versions of Taylor UUCP, you can still go back to -your original UUCP programs). You can retrieve the original programs by -typing @samp{make uninstall}. - -Note that by default the programs are compiled with debugging -information, and they are not stripped when they are installed. You may -want to strip the installed programs to save disk space. For more -information, see your system documentation for the @code{strip} program. - -Of course, simply installing the executable files is not enough. You -must also arrange for them to be used correctly. - -@node Configuration, Testing the Installation, Installing the Binaries, Installing Taylor UUCP -@section Configuring Taylor UUCP - -You will have to decide what types of configuration files you want to -use. This package supports a new sort of configuration file; see -@ref{Configuration Files}. It also supports V2 configuration files -(@file{L.sys}, @file{L-devices}, etc.) and HDB configuration files -(@file{Systems}, @file{Devices}, etc.). No documentation is provided -for V2 or HDB configuration files. All types of configuration files can -be used at once, if you are so inclined. Currently using just V2 -configuration files is not really possible, because there is no way to -specify a dialer (there are no built in dialers, and the program does -not know how to read @file{acucap} or @file{modemcap}); however, V2 -configuration files can be used with a new style dial file (@pxref{dial -File}), or with a HDB @file{Dialers} file. - -Use of HDB configuration files has two known bugs. A blank line in the -middle of an entry in the @file{Permissions} file will not be ignored as -it should be. Dialer programs, as found in some versions of HDB, are -not recognized directly. If you must use a dialer program, rather than -an entry in @file{Devices}, you must use the @code{chat-program} command -in a new style dial file; see @ref{dial File}. You will have to invoke -the dialer program via a shell script or another program, since an exit -code of 0 is required to recognize success; the @code{dialHDB} program -in the @file{contrib} directory may be used for this purpose. - -The @code{uuconv} (@pxref{Invoking uuconv}) program can be used to -convert from V2 or HDB configuration files to the new style (it can also -do the reverse translation, if you are so inclined). It will not do all -of the work, and the results should be carefully checked, but it can be -quite useful. - -If you are installing a new system, you will, of course, have to write -the configuration files; see @ref{Configuration Files} for details on -how to do this. - -After writing the configuration files, use the @code{uuchk} program to -verify that they are what you expect; see @ref{Invoking uuchk}. - -@node Testing the Installation, , Configuration, Installing Taylor UUCP -@section Testing the Installation - -After you have written the configuration files, and verified them with -the @code{uuchk} program (@pxref{Invoking uuchk}), you must check that -UUCP can correctly contact another system. - -Tell @code{uucico} to dial out to the system by using the @samp{-s} -system switch (e.g., @samp{uucico -s uunet}). The log file should tell -you what happens. The exact location of the log file depends upon the -settings in @file{policy.h} when you compiled the program, and on the -use of the @code{logfile} command in the @file{config} file. Typical -locations are @file{/usr/spool/uucp/Log} or a subdirectory under -@file{/usr/spool/uucp/.Log}. - -If you compiled the code with debugging enabled, you can use debugging -mode to get a great deal of information about what sort of data is -flowing back and forth; the various possibilities are described with the -@code{debug} command (@pxref{Debugging Levels}). When initially setting -up a connection @samp{-x chat} is probably the most useful (e.g., -@samp{uucico -s uunet -x chat}); you may also want to use @samp{-x -handshake,incoming,outgoing}. You can use @samp{-x} multiple times on -one command line, or you can give it comma separated arguments as in the -last example. Use @samp{-x all} to turn on all possible debugging -information. - -The debugging information is written to a file, normally -@file{/usr/spool/uucp/Debug}, although the default can be changed in -@file{policy.h}, and the @file{config} file can override the default -with the @code{debugfile} command. The debugging file may contain -passwords and some file contents as they are transmitted over the line, -so the debugging file is only readable by the @code{uucp} user. - -You can use the @samp{-f} switch to force @code{uucico} to call out even -if the last call failed recently; using @samp{-S} when naming a system -has the same effect. Otherwise the status file (in the @file{.Status} -subdirectory of the main spool directory, normally -@file{/usr/spool/uucp}) (@pxref{Status Directory}) will prevent too many -attempts from occurring in rapid succession. - -On older System V based systems which do not have the @code{setreuid} -system call, problems may arise if ordinary users can start an execution -of @code{uuxqt}, perhaps indirectly via @code{uucp} or @code{uux}. UUCP -jobs may wind up executing with a real user ID of the user who invoked -@code{uuxqt}, which can cause problems if the UUCP job checks the real -user ID for security purposes. On such systems, it is safest to put -@samp{run-uuxqt never} (@pxref{Miscellaneous (config)}) in the -@file{config} file, so that @code{uucico} never starts @code{uuxqt}, and -invoke @code{uuxqt} directly from a @file{crontab} file. - -Please let me know about any problems you have and how you got around -them. If you do report a problem, please include the version number of -the package you are using, the operating system you are running it on, -and a sample of the debugging file showing the problem (debugging -information is usually what is needed, not just the log file). General -questions such as ``why doesn't @code{uucico} dial out'' are impossible -to answer without much more information. - -@node Using Taylor UUCP, Configuration Files, Installing Taylor UUCP, Top -@chapter Using Taylor UUCP - -@menu -* Calling Other Systems:: Calling Other Systems -* Accepting Calls:: Accepting Calls -* Mail and News:: Using UUCP for Mail and News -* The Spool Directory Layout:: The Spool Directory Layout -* Spool Directory Cleaning:: Cleaning the UUCP Spool Directory -@end menu - -@node Calling Other Systems, Accepting Calls, Using Taylor UUCP, Using Taylor UUCP -@section Calling Other Systems -@cindex calling out - -By default @code{uucp} and @code{uux} will automatically start up -@code{uucico} to call another system whenever work is queued up. -However, the call may fail, or you may have put in time restrictions -which prevent the call at that time (perhaps because telephone rates are -high) (@pxref{When to Call}). Also, a remote system may have work -queued up for your system, but may not be calling you for some reason -(perhaps you have agreed that your system should always place the call). -To make sure that work gets transferred between the systems withing a -reasonable time period, you should arrange to periodically invoke -@code{uucico}. - -These periodic invocations are normally triggered by entries in the -@file{crontab} file. The exact format of @file{crontab} files, and how -new entries are added, varies from system to system; check your local -documentation (try @samp{man cron}). - -To attempt to call all systems with outstanding work, use the command -@samp{uucico -r1}. To attempt to call a particular system, use the -command @samp{uucico -s @var{system}}. To attempt to call a particular -system, but only if there is work for it, use the command @samp{uucico --C -s @var{system}}. (@pxref{Invoking uucico}). - -A common case is to want to try to call a system at a certain time, with -periodic retries if the call fails. A simple way to do this is to -create an empty UUCP command file, known as a @dfn{poll file}. If a -poll file exists for a system, then @samp{uucico -r1} will place a call -to it. If the call succeeds, the poll file will be deleted. - -A poll file can be easily created using the @samp{uux} command, by -requesting the execution of an empty command. To create a poll file for -@var{system}, just do something like this: -@example -uux -r @var{system}! -@end example -The @samp{-r} tells @samp{uux} to not start up @samp{uucico} -immediately. Of course, if you do want @samp{uucico} to start up right -away, omit the @samp{-r}; if the call fails, the poll file will be left -around to cause a later call. - -For example, I use the following crontab entries locally: - -@example -45 * * * * /bin/echo /usr/lib/uucp/uucico -r1 | /bin/su uucpa -40 4,10,15 * * * /usr/bin/uux -r uunet! -@end example - -Every hour, at 45 minutes past, this will check if there is any work to -be done, and, if there is, will call the appropriate system. Also, at -4:40am, 10:40am, and 3:40pm, this will create a poll file file for -@samp{uunet}, forcing the next run of @code{uucico} to call -@samp{uunet}. - -@node Accepting Calls, Mail and News, Calling Other Systems, Using Taylor UUCP -@section Accepting Calls -@cindex calling in -@cindex accepting calls - -To accept calls from another system, you must arrange matters such that -when that system calls in, it automatically invokes @code{uucico} on -your system. - -The most common arrangement is to create a special user name and -password for incoming UUCP calls. This user name typically uses the -same user ID as the regular @code{uucp} user (Unix permits several user -names to share the same user ID). The shell for this user name should -be set to @code{uucico}. - -Here is a sample @file{/etc/passwd} line to accept calls from a remote -system named airs: -@example -Uairs:@var{password}:4:8:airs UUCP:/usr/spool/uucp:/usr/lib/uucp/uucico -@end example -The details may vary on your system. You must use reasonable user and -group ID's. You must use the correct file name for @code{uucico}. The -@var{password} must appear in the UUCP configuration files on the remote -system, but will otherwise never be seen or typed by a human. - -Note that @code{uucico} appears as the login shell, and that it will be -run with no arguments. This means that it will start in slave mode and -accept an incoming connection. @xref{Invoking uucico}. - -On some systems, creating an empty file named @file{.hushlogin} in the -home directory will skip the printing of various bits of information -when the remote @code{uucico} logs in, speeding up the UUCP connection -process. - -For the greatest security, each system which calls in should use a -different user name, each with a different password, and the -@code{called-login} command should be used in the @file{sys} file to -ensure that the correct login name is used. @xref{Accepting a Call}, -and see @ref{Security}. - -If you never need to dial out from your system, but only accept incoming -calls, you can arrange for @code{uucico} to handle logins itself, -completely controlling the port, by using the @samp{--endless} option. -@xref{Invoking uucico}. - -@node Mail and News, The Spool Directory Layout, Accepting Calls, Using Taylor UUCP -@section Using UUCP for Mail and News. -@cindex mail -@cindex news - -Taylor UUCP does not include a mail package. All Unix systems come with -some sort of mail delivery agent, typically @code{sendmail} or -@code{MMDF}. Source code is available for some alternative mail -delivery agents, such as @code{IDA sendmail} and @code{smail}. - -Taylor UUCP also does not include a news package. The two major Unix -news packages are @code{C-news} and @code{INN}. Both are available in -source code form. - -Configuring and using mail delivery agents is a notoriously complex -topic, and I will not be discussing it here. Configuring news systems -is usually simpler, but I will not be discussing that either. I will -merely describe the interactions between the mail and news systems and -UUCP. - -A mail or news system interacts with UUCP in two ways: sending and -receiving. - -@menu -* Sending mail or news:: Sending mail or news via UUCP -* Receiving mail or news:: Receiving mail or news via UUCP -@end menu - -@node Sending mail or news, Receiving mail or news, Mail and News, Mail and News -@subsection Sending mail or news via UUCP - -When mail is to be sent from your machine to another machine via UUCP, -the mail delivery agent will invoke @code{uux}. It will generally run a -command such as @samp{uux - @var{system}!rmail @var{address}}, where -@var{system} is the remote system to which the mail is being sent. It -may pass other options to @code{uux}, such as @samp{-r} or @samp{-g} -(@pxref{Invoking uux}). - -The news system also invokes @code{uux} in order to transfer articles to -another system. The only difference is that news will use @code{uux} to -invoke @code{rnews} on the remote system, rather than @code{rmail}. - -You should arrange for your mail and news systems to invoke the Taylor -UUCP version of @code{uux}. If you only have Taylor UUCP, or if you -simply replace any existing version of @code{uux} with the Taylor UUCP -version, this will probably happen automatically. However, if you have -two UUCP packages installed on your system, you will probably have to -modify the mail and news configuration files in some way. - -Actually, if both the system UUCP and Taylor UUCP are using the same -spool directory format, the system @code{uux} will probably work fine -with the Taylor @code{uucico} (the reverse is not the case: the Taylor -@code{uux} requires the Taylor @code{uucico}). However, data transfer -will be somewhat more efficient if the Taylor @code{uux} is used. - -@node Receiving mail or news, , Sending mail or news, Mail and News -@subsection Receiving mail or news via UUCP - -To receive mail, all that is necessary is for UUCP to invoke -@code{rmail}. Any mail delivery agent will provide an appropriate -version of @code{rmail}; you must simply make sure that it is in the -command path used by UUCP (it almost certainly already is). The default -command path is set in @file{policy.h}, and it may be overridden for a -particular system by the @code{command-path} command -(@pxref{Miscellaneous (sys)}). - -Similarly, for news UUCP must be able to invoke @code{rnews}. Any news -system will provide a version of @code{rnews}, and you must ensure that -is in a directory on the path that UUCP will search. - -@node The Spool Directory Layout, Spool Directory Cleaning, Mail and News, Using Taylor UUCP -@section The Spool Directory Layout -@cindex spool directory - -In general, the layout of the spool directory may be safely ignored. -However, it is documented here for the curious. This description only -covers the @code{SPOOLDIR_TAYLOR} layout. The ways in which the other -spool directory layouts differ are described in the source file -@file{unix/spool.c}. - -Directories and files are only created when they are needed, so a -typical system will not have all of the entries described here. - -@menu -* System Spool Directories:: System Spool Directories -* Status Directory:: Status Spool Directory -* Execution Subdirectories:: Execution Spool Subdirectories -* Other Spool Subdirectories:: Other Spool Subdirectories -* Spool Lock Files:: Spool Directory Lock Files -@end menu - -@node System Spool Directories, Status Directory, The Spool Directory Layout, The Spool Directory Layout -@subsection System Spool Directories -@cindex system spool directories - -@table @file -@item @var{system} -There is a subdirectory of the main spool directory for each remote -system. - -@item @var{system}/C. -This directory stores files describing file transfer commands to be sent -to the @var{system}. Each file name starts with @file{C.@var{g}}, where -@var{g} is the job grade. Each file contains one or more commands. For -details of the commands, see @ref{UUCP Protocol Commands}. - -@item @var{system}/D. -This directory stores data files. Files with names like -@file{D.@var{g}@var{ssss}}, where @var{g} is the grade and @var{ssss} is -a sequence number, are waiting to be transferred to the @var{system}, as -directed by the files in the @file{@var{system}/C.} directory. Files -with other names, typically @file{D.@var{system}@var{g}@var{ssss}}, have -been received from @var{system} and are waiting to be processed by an -execution file in the @file{@var{system}/X.} directory. - -@item @var{system}/D.X -This directory stores data files which will become execution files on -the remote system. In current practice, this directory rarely exists, -because most simple executions, including typical uses of @code{rmail} -and @code{rnews}, send an @samp{E} command rather than an execution file -(@pxref{The E Command}). - -@item @var{system}/X. -This directory stores execution files which have been received from -@var{system}. This directory normally exists, even though the -corresponding @file{D.X} directory does not, because @code{uucico} will -create an execution file on the fly when it receives an @samp{E} -command. - -@item @var{system}/SEQF -This file holds the sequence number of the last job sent to -@var{system}. The sequence number is used to ensure that file names are -unique in the remote system spool directory. The file is four bytes -long. Sequence numbers are composed of digits and the upper case -letters. -@end table - -@node Status Directory, Execution Subdirectories, System Spool Directories, The Spool Directory Layout -@subsection Status Directory - -@table @file -@item .Status -@cindex .Status -@cindex status files -This directory holds status files for each remote system. The name of -the status file is the name of the system which it describes. Each -status file describes the last conversation with the system. Running -@code{uustat --status} basically just formats and prints the contents of -the status files (@pxref{uustat Examples}). - -Each status file has a single text line with six fields. - -@table @asis -@item code -A code indicating the status of the last conversation. The following -values are defined, though not all are actually used. -@table @samp -@item 0 -Conversation completed normally. -@item 1 -@code{uucico} was unable to open the port. -@item 2 -The last call to the system failed while dailing. -@item 3 -The last call to the system failed while logging in. -@item 4 -The last call to the system failed during the initial UUCP protocol -handshake (@pxref{The Initial Handshake}). -@item 5 -The last call to the system failed after the initial handshake. -@item 6 -@code{uucico} is currently talking to the system. -@item 7 -The last call to the system failed because it was the wrong time to call -(this is not used if calling the system is never permitted). -@end table - -@item retries -The number of retries since the last successful call. - -@item time of last call -The time of the last call, in seconds since the epoch (as returned by -the @code{time} system call). - -@item wait -If the last call failed, this is the number of seconds since the last -call before @code{uucico} may attempt another call. This is set based -on the retry time; see @ref{When to Call}. The @samp{-f} or @samp{-S} -options to @code{uucico} direct it to ignore this wait time; see -@ref{Invoking uucico}. - -@item description -A text description of the status, corresponding to the code in the first -field. This may contain spaces. - -@item system name -The name of the remote system. -@end table -@end table - -@node Execution Subdirectories, Other Spool Subdirectories, Status Directory, The Spool Directory Layout -@subsection Execution Subdirectories - -@table @file -@item .Xqtdir -@cindex .Xqtdir -When @code{uuxqt} executes a job requested by @code{uux}, it first -changes the working directory to the @file{.Xqtdir} subdirectory. This -permits the job to create any sort of temporary file without worrying -about overwriting other files in the spool directory. Any files left -in the @file{.Xqtdir} subdirectory are removed after each execution is -complete. - -@item .Xqtdir@var{nnnn} -When several instances of @code{uuxqt} are executing simultaneously, -each one executes jobs in a separate directory. The first uses -@file{.Xqtdir}, the second uses @file{.Xqtdir0001}, the third uses -@file{.Xqtdir0002}, and so forth. - -@item .Corrupt -@cindex .Corrupt -If @code{uuxqt} encounters an execution file which it is unable to -parse, it saves it in the @file{.Corrupt} directory, and sends mail -about it to the UUCP administrator. - -@item .Failed -@cindex .Failed -If @code{uuxqt} executes a job, and the job fails, and there is enough -disk space to hold the command file and all the data files, then -@code{uuxqt} saves the files in the @file{.Failed} directory, and sends -mail about it to the UUCP administrator. -@end table - -@node Other Spool Subdirectories, Spool Lock Files, Execution Subdirectories, The Spool Directory Layout -@subsection Other Spool Subdirectories - -@table @file -@item .Sequence -@cindex .Sequence -This directory holds conversation sequence number files. These are used -if the @code{sequence} command is used for a system -(@pxref{Miscellaneous (sys)}). The sequence number for the system -@var{system} is stored in the file @file{.Sequence/@var{system}}. It is -simply stored as a printable number. - -@item .Temp -@cindex .Temp -This directory holds data files as they are being received from a remote -system, before they are moved to their final destination. For file send -requests which use a valid temporary file name in the @var{temp} field -of the @samp{S} or @samp{E} command (@pxref{The S Command}), -@code{uucico} receives the file into -@file{.Temp/@var{system}/@var{temp}}, where @var{system} is the name of -the remote system, and @var{temp} is the temporary file name. If a -conversation fails during a file transfer, these files are used to -automatically restart the file transfer from the point of failure. - -If the @samp{S} or @samp{E} command does not include a temporary file -name, automatic restart is not possible. In this case, the files are -received into a randomly named file in the @file{.Temp} directory -itself. - -@item .Preserve -@cindex .Preserve -This directory holds data files which could not be transferred to a -remote system for some reason (for example, the data file might be -large, and exceed size restrictions imposed by the remote system). When -a locally requested file transfer fails, @code{uucico} will store the -data file in the @file{.Preserve} directory, and send mail to the -requestor describing the failure and naming the saved file. - -@item .Received -@cindex .Received -This directory records which files have been received. If a -conversation fails just after @code{uucico} acknowledges receipt of a -file, it is possible for the acknowledgement to be lost. If this -happens, the remote system will resend the file. If the file were an -execution request, and @code{uucico} did not keep track of which files -it had already received, this could lead to the execution being -performed twice. - -To avoid this problem, when a conversation fails, @code{uucico} records -each file that has been received, but for which the remote system may -not have received the acknowledgement. It records this information by -creating an empty file with the name -@file{.Received/@var{system}/@var{temp}}, where @var{system} is the name -of the remote system, and @var{temp} is the @var{temp} field of the -@samp{S} or @samp{E} command from the remote system (@pxref{The S -Command}). Then, if the remote system offers the file again in the next -conversation, @code{uucico} refuses the send request and deletes the -record in the @file{.Received} directory. This approach only works for -file sends which use a temporary file name, but this is true of all -execution requests. -@end table - -@node Spool Lock Files, , Other Spool Subdirectories, The Spool Directory Layout -@subsection Lock Files in the Spool Directory -@cindex lock files in spool directory - -Lock files for devices and systems are stored in the lock directory, -which may or may not be the same as the spool directory. The lock -directory is set at compilation time by @code{LOCKDIR} in -@file{policy.h}, which may be overridden by the @code{lockdir} command -in the @file{config} file (@pxref{Miscellaneous (config)}). - -For a description of the names used for device lock files, and the -format of the contents of a lock file, see @ref{UUCP Lock Files}. - -@table @file -@item LCK..@var{sys} -@cindex LCK..@var{sys} -@cindex system lock files -A lock file for a system, where @var{sys} is the system name. As noted -above, these lock files are kept in the lock directory, which may not be -the spool directory. These lock files are created by @code{uucico} -while talking to a remote system, and are used to prevent multiple -simultaneous conversations with a system. - -On systems which limit file names to 14 characters, only the first eight -characters of the system name are used in the lock file name. This -requires that the names of each directly connected remote system be -unique in the first eight characters. - -@item LCK.XQT.@var{NN} -@cindex LCK.XQT.@var{NN} -When @code{uuxqt} starts up, it uses lock files to determine how many -other @code{uuxqt} daemons are currently running. It first tries to -lock @file{LCK.XQT.0}, then @file{LCK.XQT.1}, and so forth. This is -used to implement the @code{max-uuxqts} command (@pxref{Miscellaneous -(config)}). It is also used to parcel out the @file{.Xqtdir} -subdirectories (@pxref{Execution Subdirectories}). - -@item LXQ.@var{cmd} -@cindex LXQ.@var{cmd} -When @code{uuxqt} is invoked with the @samp{-c} or @samp{--command} -option (@pxref{Invoking uuxqt}), it creates a lock file named after the -command it is executing. For example, @samp{uuxqt -c rmail} will create -the lock file @file{LXQ.rmail}. This prevents other @code{uuxqt} -daemons from executing jobs of the specified type. - -@item @var{system}/X./L.@var{xxx} -@cindex L.@var{xxx} -While @code{uuxqt} is executing a particular job, it creates a lock file -with the same name as the @file{X.} file describing the job, but -replacing the initial @samp{X} with @samp{L}. This ensures that if -multiple @code{uuxqt} daemons are running, they do not simultaneously -execute the same job. - -@item LCK..SEQ -This lock file is used to control access to the sequence files for each -system (@pxref{System Spool Directories}). It is only used on systems -which do not support POSIX file locking using the @code{fcntl} system -call. -@end table - -@node Spool Directory Cleaning, , The Spool Directory Layout, Using Taylor UUCP -@section Cleaning the Spool Directory -@cindex spool directory, cleaning -@cindex cleaning the spool directory - -The spool directory may need to be cleaned up periodically. Under some -circumstances, files may accumulate in various subdirectories, such as -@file{.Preserve} (@pxref{Other Spool Subdirectories}) or @file{.Corrupt} -(@pxref{Execution Subdirectories}). - -Also, if a remote system stops calling in, you may want to arrange for -any queued up mail to be returned to the sender. This can be done using -the @code{uustat} command (@pxref{Invoking uustat}). - -The @file{contrib} directory includes a simple @file{uuclean} script -which may be used as an example of a clean up script. It can be run -daily out of @file{crontab}. - -You should periodically trim the UUCP log files, as they will otherwise -grow without limit. The names of the log files are set in -@file{policy.h}, and may be overridden in the configuration file -(@pxref{config File}). By default they are are -@file{/usr/spool/uucp/Log} and @file{/usr/spool/uucp/Stats}. You may -find the @code{savelog} program in the @file{contrib} directory to be of -use. There is a manual page for it in @file{contrib} as well. - -@node Configuration Files, Protocols, Using Taylor UUCP, Top -@chapter Taylor UUCP Configuration Files - -This chapter describes the configuration files accepted by the Taylor -UUCP package if compiled with @code{HAVE_TAYLOR_CONFIG} set to 1 in -@file{policy.h}. - -The configuration files are normally found in the directory -@var{newconfigdir}, which is defined by the @file{Makefile} variable -@file{newconfigdir}; by default @var{newconfigdir} is -@file{/usr/local/conf/uucp}. However, the main configuration file, -@file{config}, is the only one which must be in that directory, since it -may specify a different location for any or all of the other files. You -may run any of the UUCP programs with a different main configuration -file by using the @samp{-I} or @samp{--config} option; this can be -useful when testing a new configuration. When you use the @samp{-I} -option the programs will revoke any setuid privileges. - -@menu -* Configuration Overview:: Configuration File Overview -* Configuration File Format:: Configuration File Format -* Configuration Examples:: Examples of Configuration Files -* Time Strings:: How to Write Time Strings -* Chat Scripts:: How to Write Chat Scripts -* config File:: The Main Configuration File -* sys File:: The System Configuration File -* port File:: The Port Configuration Files -* dial File:: The Dialer Configuration Files -* UUCP Over TCP:: UUCP Over TCP -* Security:: Security Issues -@end menu - -@node Configuration Overview, Configuration File Format, Configuration Files, Configuration Files -@section Configuration File Overview - -UUCP uses several different types of configuration files, each -describing a different kind of information. The commands permitted in -each file are described in detail below. This section is a brief -description of some of the different types of files. - -The @file{config} file is the main configuration file. It describes -general information not associated with a particular remote system, such -as the location of various log files. There are reasonable defaults for -everything that may be specified in the @file{config} file, so you may -not actually need one on your system. - -There may be only one @file{config} file, but there may be one or more -of each other type of file. The default is one file for each type, but -more may be listed in the @file{config} file. - -The @file{sys} files are used to describe remote systems. Each remote -system to which you connect must be listed in a @file{sys} file. A -@file{sys} file will include information for a system, such as the speed -(baud rate) to use, or when to place calls. - -For each system you wish to call, you must describe one or more ports; -these ports may be defined directly in the @file{sys} file, or they may -be defined in a @file{port} file. - -The @file{port} files are used to describe ports. A port is a -particular hardware connection on your computer. You would normally -define as many ports as there are modems attached to your computer. A -TCP connection is also described using a port. - -The @file{dial} files are used to describe dialers. Dialer is -essentially another word for modem. The @file{dial} file describes the -commands UUCP should use to dial out on a particular type of modem. You -would normally define as many dialers as there are types of modems -attached to your computer. For example, if you have three Telebit -modems used for UUCP, you would probably define three ports and one -dialer. - -There are other types of configuration files, but these are the -important ones. The other types are described below. - -@node Configuration File Format, Configuration Examples, Configuration Overview, Configuration Files -@section Configuration File Format - -All the configuration files follow a simple line-oriented -@samp{@var{keyword} @var{value}} format. Empty lines are ignored, as -are leading spaces; unlike HDB, lines with leading spaces are read. The -first word on each line is a keyword. The rest of the line is -interpreted according to the keyword. Most keywords are followed by -numbers, boolean values or simple strings with no embedded spaces. - -The @kbd{#} character is used for comments. Everything from a @kbd{#} -to the end of the line is ignored unless the @kbd{#} is preceded by a -@kbd{\} (backslash); if the @kbd{#} is preceeded by a @kbd{\}, the -@kbd{\} is removed but the @kbd{#} remains in the line. This can be -useful for a phone number containing a @kbd{#}. To enter the sequence -@samp{\#}, use @samp{\\#}. - -The backslash character may be used to continue lines. If the last -character in a line is a backslash, the backslash is removed and the -line is continued by the next line. The second line is attached to the -first with no intervening characters; if you want any whitespace between -the end of the first line and the start of the second line, you must -insert it yourself. - -However, the backslash is not a general quoting character. For example, -you cannot use it to get an embedded space in a string argument. - -Everything after the keyword must be on the same line. A @var{boolean} -may be specified as @kbd{y}, @kbd{Y}, @kbd{t}, or @kbd{T} for true and -@kbd{n}, @kbd{N}, @kbd{f}, or @kbd{F} for false; any trailing characters -are ignored, so @code{true}, @code{false}, etc., are also acceptable. - -@node Configuration Examples, Time Strings, Configuration File Format, Configuration Files -@section Examples of Configuration Files - -This section provides few typical examples of configuration files. -There are also sample configuration files in the @file{sample} -subdirectory of the distribution. - -@menu -* config File Examples:: Examples of the Main Configuration File -* Leaf Example:: Call a Single Remote Site -* Gateway Example:: The Gateway for Several Local Systems -@end menu - -@node config File Examples, Leaf Example, Configuration Examples, Configuration Examples -@subsection config File Examples -@cindex config file examples - -To start with, here are some examples of uses of the main configuration -file, @file{config}. For a complete description of the commands that -are permitted in @file{config}, see @ref{config File}. - -In many cases you will not need to create a @file{config} file at all. -The most common reason to create one is to give your machine a special -UUCP name. Other reasons might be to change the UUCP spool directory, -or to permit any remote system to call in. - -If you have an internal network of machines, then it is likely that the -internal name of your UUCP machine is not the name you want to use when -calling other systems. For example, here at @file{airs.com} our -mail/news gateway machine is named @file{elmer.airs.com} (it is one of -several machines all named @file{@var{localname}.airs.com}). If we did -not provide a @file{config} file, then our UUCP name would be -@file{elmer}; however, we actually want it to be @file{airs}. -Therefore, we use the following line in @file{config}: - -@example -nodename airs -@end example - -@cindex changing spool directory -@cindex spool directory, changing -The UUCP spool directory name is set in @file{policy.h} when the code is -compiled. You might at some point decide that it is appropriate to move -the spool directory, perhaps to put it on a different disk partition. -You would use the following commands in @file{config} to change to -directories on the partition @file{/uucp}: - -@example -spool /uucp/spool -pubdir /uucp/uucppublic -logfile /uucp/spool/Log -debugfile /uucp/spool/Debug -@end example - -You would then move the contents of the current spool directory to -@file{/uucp/spool}. If you do this, make sure that no UUCP processes -are running while you change @file{config} and move the spool directory. - -@cindex anonymous UUCP -Suppose you wanted to permit any system to call in to your system and -request files. This is generally known as @dfn{anonymous UUCP}, since -the systems which call in are effectively anonymous. By default, -unknown systems are not permitted to call in. To permit this you must -use the @code{unknown} command in @file{config}. The @code{unknown} -command is followed by any command that may appear in the system file; -for full details, see @ref{sys File}. - -I will show two possible anonymous UUCP configurations. The first will -let any system call in and download files, but will not permit them to -upload files to your system. - -@example -# No files may be transferred to this system -unknown receive-request no -# The public directory is /usr/spool/anonymous -unknown pubdir /usr/spool/anonymous -# Only files in the public directory may be sent (the default anyhow) -unknown remote-send ~ -@end example - -@noindent -Setting the public directory is convenient for the systems which call -in. It permits to request a file by prefixing it with @file{~/}. For -example, assuming your system is known as @samp{server}, then to -retrieve the file @file{/usr/spool/anonymous/INDEX} a user on a remote -site could just enter @samp{uucp server!~/INDEX ~}; this would transfer -@file{INDEX} from @samp{server}'s public directory to the user's local -public directory. Note that when using @samp{csh} or @samp{bash} the -@kbd{!} and the second @kbd{~} must be quoted. - -The next example will permit remote systems to upload files to a special -directory named @file{/usr/spool/anonymous/upload}. Permitting a remote -system to upload files permits it to send work requests as well; this -example is careful to prohibit commands from unknown systems. - -@example -# No commands may be executed (the list of permitted commands is empty) -unknown commands -# The public directory is /usr/spool/anonymous -unknown pubdir /usr/spool/anonymous -# Only files in the public directory may be sent; users may not download -# files from the upload directory -unknown remote-send ~ !~/upload -# May only upload files into /usr/spool/anonymous/upload -unknown remote-receive ~/upload -@end example - -@node Leaf Example, Gateway Example, config File Examples, Configuration Examples -@subsection Leaf Example - -@cindex leaf site -@cindex sys file example (leaf) -A relatively common simple case is a @dfn{leaf site}, a system which -only calls or is called by a single remote site. Here is a typical -@file{sys} file that might be used in such a case. For full details on -what commands can appear in the @file{sys} file, see @ref{sys File}. - -This is the @file{sys} file that is used at @file{airs.com}. We use a -single modem to dial out to @file{uunet}. This example shows how you -can specify the port and dialer information directly in the @file{sys} -file for simple cases. It also shows the use of the following: - -@table @code - -@item call-login -Using @code{call-login} and @code{call-password} allows the default -login chat script to be used. In this case, the login name is specified -in the call-out login file (@pxref{Configuration File Names}). - -@item call-timegrade -@file{uunet} is requested to not send us news during the daytime. - -@item chat-fail -If the modem returns @samp{BUSY} or @samp{NO CARRIER} the call is -immediately aborted. - -@item protocol-parameter -Since @file{uunet} tends to be slow, the default timeout has been -increased. - -@end table - -This @file{sys} file relies on certain defaults. It will allow -@file{uunet} to queue up @samp{rmail} and @samp{rnews} commands. It -will allow users to request files from @file{uunet} into the UUCP public -directory. It will also allow @file{uunet} to request files from the -UUCP public directory; in fact @file{uunet} never requests files, but -for additional security we could add the line @samp{request false}. - -@example -# The following information is for uunet -system uunet - -# The login name and password are kept in the callout password file -call-login * -call-password * - -# We can send anything at any time. -time any - -# During the day we only accept grade `Z' or above; at other times -# (not mentioned here) we accept all grades. uunet queues up news -# at grade `d', which is lower than `Z'. -call-timegrade Z Wk0755-2305,Su1655-2305 - -# The phone number. -phone 7389449 - -# uunet tends to be slow, so we increase the timeout -chat-timeout 120 - -# We are using a preconfigured Telebit 2500. -port type modem -port device /dev/ttyd0 -port speed 19200 -port carrier true -port dialer chat "" ATZ\r\d\c OK ATDT\D CONNECT -port dialer chat-fail BUSY -port dialer chat-fail NO\sCARRIER -port dialer complete \d\d+++\d\dATH\r\c -port dialer abort \d\d+++\d\dATH\r\c - -# Increase the timeout and the number of retries. -protocol-parameter g timeout 20 -protocol-parameter g retries 10 -@end example - -@node Gateway Example, , Leaf Example, Configuration Examples -@subsection Gateway Example - -@cindex gateway -@cindex sys file example (gateway) -Many organizations have several local machines which are connected by -UUCP, and a single machine which connects to the outside world. This -single machine is often referred to as a @dfn{gateway} machine. - -For this example I will assume a fairly simple case. It should still -provide a good general example. There are three machines, @file{elmer}, -@file{comton} and @file{bugs}. @file{elmer} is the gateway machine for -which I will show the configuration file. @file{elmer} calls out to -@file{uupsi}. As an additional complication, @file{uupsi} knows -@file{elmer} as @file{airs}; this will show how a machine can have one -name on an internal network but a different name to the external world. -@file{elmer} has two modems. It also has an TCP connection to -@file{uupsi}, but since that is supposed to be reserved for interactive -work (it is, perhaps, only a 9600 baud SLIP line) it will only use it if -the modems are not available. - -A network this small would normally use a single @file{sys} file. -However, for pedagogical purposes I will show two separate @file{sys} -files, one for the local systems and one for @file{uupsi}. This is done -with the @code{sysfile} command in the @file{config} file. Here is the -@file{config} file. - -@example -# This is config -# The local sys file -sysfile /usr/local/lib/uucp/sys.local -# The remote sys file -sysfile /usr/local/lib/uucp/sys.remote -@end example - -Using the defaults feature of the @file{sys} file can greatly simplify -the listing of local systems. Here is @file{sys.local}. Note that this -assumes that the local systems are trusted; they are permited to request -any world readable file and to write files into any world writable -directory. - -@example -# This is sys.local -# Get the login name and password to use from the call-out file -call-login * -call-password * - -# The systems must use a particular login -called-login Ulocal - -# Permit sending any world readable file -local-send / -remote-send / - -# Permit receiving into any world writable directory -local-receive / -remote-receive / - -# Call at any time -time any - -# Use port1, then port2 -port port1 - -alternate - -port port2 - -# Now define the systems themselves. Because of all the defaults we -# used, there is very little to specify for the systems themselves. - -system comton -phone 5551212 - -system bugs -phone 5552424 -@end example - -The @file{sys.remote} file describes the @file{uupsi} connection. The -@code{myname} command is used to change the UUCP name to @file{airs} -when talking to @file{uupsi}. - -@example -# This is sys.remote -# Define uupsi -system uupsi - -# The login name and password are in the call-out file -call-login * -call-password * - -# We can call out at any time -time any - -# uupsi uses a special login name -called-login Uuupsi - -# uuspi thinks of us as `airs' -myname airs - -# The phone number -phone 5554848 - -# We use port2 first, then port1, then TCP - -port port2 - -alternate - -port port1 - -alternate - -# We don't bother to make a special entry in the port file for TCP, we -# just describe the entire port right here. We use a special chat -# script over TCP because the usual one confuses some TCP servers. -port type TCP -address uu.psi.com -chat ogin: \L word: \P -@end example - -The ports are defined in the file @file{port} (@pxref{port File}). For -this example they are both connected to the same type of 2400 baud -Hayes-compatible modem. - -@example -# This is port - -port port1 -type modem -device /dev/ttyd0 -dialer hayes -speed 2400 - -port port2 -type modem -device /dev/ttyd1 -dialer hayes -speed 2400 -@end example - -Dialers are described in the @file{dial} file (@pxref{dial File}). - -@example -# This is dial - -dialer hayes - -# The chat script used to dial the phone. \D is the phone number. -chat "" ATZ\r\d\c OK ATDT\D CONNECT - -# If we get BUSY or NO CARRIER we abort the dial immediately -chat-fail BUSY -chat-fail NO\sCARRIER - -# When the call is over we make sure we hangup the modem. -complete \d\d+++\d\dATH\r\c -abort \d\d+++\d\dATH\r\c -@end example - -@node Time Strings, Chat Scripts, Configuration Examples, Configuration Files -@section Time Strings -@cindex time strings - -Several commands use time strings to specify a range of times. This -section describes how to write time strings. - -A time string may be a list of simple time strings separated with a -vertical bar @samp{|} or a comma @samp{,}. - -Each simple time string must begin with @samp{Su}, @samp{Mo}, @samp{Tu}, -@samp{We}, @samp{Th}, @samp{Fr}, or @samp{Sa}, or @samp{Wk} for any -weekday, or @samp{Any} for any day. - -Following the day may be a range of hours separated with a hyphen using -24 hour time. The range of hours may cross 0; for example -@samp{2300-0700} means any time except 7 AM to 11 PM. If no time is -given, calls may be made at any time on the specified day(s). - -The time string may also be the single word @samp{Never}, which does not -match any time. The time string may also be a single word with a name -defined in a previous @code{timetable} command (@pxref{Miscellaneous -(config)}). - -Here are a few sample time strings with an explanation of what they -mean. - -@table @samp - -@item Wk2305-0855,Sa,Su2305-1655 - -This means weekdays before 8:55 AM or after 11:05 PM, any time Saturday, -or Sunday before 4:55 PM or after 11:05 PM. These are approximately the -times during which night rates apply to phone calls in the U.S.A. Note -that this time string uses, for example, @samp{2305} rather than -@samp{2300}; this will ensure a cheap rate phone call even if the -computer clock is running up to five minutes ahead of the real time. - -@item Wk0905-2255,Su1705-2255 - -This means weekdays from 9:05 AM to 10:55 PM, or Sunday from 5:05 PM to -10:55 PM. This is approximately the opposite of the previous example. - -@item Any - -This means any day. Since no time is specified, it means any time on -any day. - -@end table - -@node Chat Scripts, config File, Time Strings, Configuration Files -@section Chat Scripts -@cindex chat scripts - -Chat scripts are used in several different places, such as dialing out -on modems or logging in to remote systems. Chat scripts are made up of -pairs of strings. The program waits until it sees the first string, -known as the @dfn{expect} string, and then sends out the second string, -the @dfn{send} string. - -Each chat script is defined using a set of commands. These commands -always end in a string beginning with @code{chat}, but may start with -different strings. For example, in the @file{sys} file there is one set -of commands beginning with @code{chat} and another set beginning with -@code{called-chat}. The prefixes are only used to disambiguate -different types of chat scripts, and this section ignores the prefixes -when describing the commands. - -@table @code - -@item chat @var{strings} -@findex chat - -Specify a chat script. The arguments to the @code{chat} command are -pairs of strings separated by whitespace. The first string of each pair -is an expect string, the second is a send string. The program will wait -for the expect string to appear; when it does, the program will send the -send string. If the expect string does not appear within a certain -number of seconds (as set by the @code{chat-timeout} command), the chat -script fails and, typically, the call is aborted. If the final expect -string is seen (and the optional final send string has been sent), the -chat script is successful. - -An expect string may contain additional subsend and subexpect strings, -separated by hyphens. If the expect string is not seen, the subsend -string is sent and the chat script continues by waiting for the -subexpect string. This means that a hyphen may not appear in an expect -string; on an ASCII system, use @samp{\055} instead. - -An expect string may simply be @samp{""}, meaning to skip the expect -phase. Otherwise, the following escape characters may appear in expect -strings: - -@table @samp -@item \b -a backspace character -@item \n -a newline or line feed character -@item \N -a null character (for HDB compatibility) -@item \r -a carriage return character -@item \s -a space character -@item \t -a tab character -@item \\ -a backslash character -@item \@var{ddd} -character @var{ddd}, where @var{ddd} are up to three octal digits -@item \x@var{ddd} -character @var{ddd}, where @var{ddd} are hexadecimal digits. -@end table - -As in C, there may be up to three octal digits following a backslash, -but the hexadecimal escape sequence continues as far as possible. To -follow a hexadecimal escape sequence with a hex digit, interpose a send -string of @samp{""}. - -A chat script expect string may also specify a timeout. This is done by -using the escape sequence @samp{\W@var{seconds}}. This escape sequence -may only appear at the very end of the expect string. It temporarily -overrides the timeout set by @code{chat-timeout} (described below) only -for the expect string to which it is attached. - -A send string may simply be @samp{""} to skip the send phase. -Otherwise, all of the escape characters legal for expect strings may be -used, and the following escape characters are also permitted: - -@table @samp -@item EOT -send an end of transmission character (@kbd{^D}) -@item BREAK -send a break character (may not work on all systems) -@item \c -suppress trailing carriage return at end of send string -@item \d -delay sending for 1 or 2 seconds -@item \e -disable echo checking -@item \E -enable echo checking -@item \K -same as @samp{BREAK} (for HDB compatibility) -@item \p -pause sending for a fraction of a second -@end table - -Some specific types of chat scripts also define additional escape -sequences that may appear in the send string. For example, the login -chat script defines @samp{\L} and @samp{\P} to send the login name and -password, respectively. - -A carriage return will be sent at the end of each send string, unless -the @kbd{\c} escape sequence appears in the string. Note that some UUCP -packages use @kbd{\b} for break, but here it means backspace. - -Echo checking means that after writing each character the program will -wait until the character is echoed. Echo checking must be turned on -separately for each send string for which it is desired; it will be -turned on for characters following @kbd{\E} and turned off for characters -following @kbd{\e}. - -@item chat-timeout @var{number} -@findex chat-timeout - -The number of seconds to wait for an expect string in the chat script, -before timing out and sending the next subsend, or failing the chat -script entirely. The default value is 10 for a login chat or 60 for any -other type of chat. - -@item chat-fail @var{string} -@findex chat-fail - -If the @var{string} is seen at any time during a chat script, the chat -script is aborted. The string may not contain any whitespace -characters: escape sequences must be used for them. Multiple -@code{chat-fail} commands may appear in a single chat script. The -default is to have none. - -This permits a chat script to be quickly aborted if an error string is -seen. For example, a script used to dial out on a modem might use the -command @samp{chat-fail BUSY} to stop the chat script immediately if the -string @samp{BUSY} was seen. - -The @code{chat-fail} strings are considered in the order they are -listed, so if one string is a suffix of another the longer one should be -listed first. This affects the error message which will be logged. Of -course, if one string is contained within another, but is not a suffix, -the smaller string will always be found before the larger string could -match. - -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit - -If the argument is true, all incoming characters are stripped to seven -bits when being compared to the expect string. Otherwise all eight bits -are used in the comparison. The default is true, because some Unix -systems generate parity bits during the login prompt which must be -ignored while running a chat script. This has no effect on any -@code{chat-program}, which must ignore parity by itself if necessary. - -@item chat-program @var{strings} -@findex chat-program - -Specify a program to run before executing the chat script. This program -could run its own version of a chat script, or it could do whatever it -wants. If both @code{chat-program} and @code{chat} are specified, the -program is executed first followed by the chat script. - -The first argument to the @code{chat-program} command is the program -name to run. The remaining arguments are passed to the program. The -following escape sequences are recognized in the arguments: - -@table @kbd -@item \Y -port device name -@item \S -port speed -@item \\ -backslash -@end table - -Some specific uses of @code{chat-program} define additional escape -sequences. - -Arguments other than escape sequences are passed exactly as they appear -in the configuration file, except that sequences of whitespace are -compressed to a single space character (this exception may be removed in -the future). - -If the @code{chat-program} command is not used, no program is run. - -On Unix, the standard input and standard output of the program will be -attached to the port in use. Anything the program writes to standard -error will be written to the UUCP log file. No other file descriptors -will be open. If the program does not exit with a status of 0, it will -be assumed to have failed. This means that the dialing programs used by -some versions of HDB may not be used directly, but you may be able to -run them via the @code{dialHDB} program in the @file{contrib} directory. - -The program will be run as the @code{uucp} user, and the environment -will be that of the process that started @code{uucico}, so care must be -taken to maintain security. - -No search path is used to find the program; a full file name must be -given. If the program is an executable shell script, it will be passed -to @file{/bin/sh} even on systems which are unable to execute shell -scripts. - -@end table - -Here is a simple example of a chat script that might be used to reset a -Hayes compatible modem. - -@example -chat "" ATZ OK-ATZ-OK -@end example - -The first expect string is @samp{""}, so it is ignored. The chat script -then sends @samp{ATZ}. If the modem responds with @samp{OK}, the chat -script finishes. If 60 seconds (the default timeout) pass before seeing -@samp{OK}, the chat script sends another @samp{ATZ}. If it then sees -@samp{OK}, the chat script succeeds. Otherwise, the chat script fails. - -For a more complex chat script example, see @ref{Logging In}. - -@node config File, sys File, Chat Scripts, Configuration Files -@section The Main Configuration File -@cindex config file -@cindex main configuration file -@cindex configuration file (config) - -The main configuration file is named @file{config}. - -Since all the values that may be specified in the main configuration -file also have defaults, there need not be a main configuration file at -all. - -Each command in @file{config} may have a program prefix, which is a -separate word appearing at the beginning of the line. The currently -supported prefixes are @samp{uucp} and @samp{cu}. Any command prefixed -by @samp{uucp} will not be read by the @code{cu} program. Any command -prefixed by @samp{cu} will only be read by the @code{cu} program. For -example, to use a list of systems known only to @code{cu}, list them in -a separate file @file{@var{file}} and put @samp{cu sysfile -@file{@var{file}}} in @file{config}. - -@menu -* Miscellaneous (config):: Miscellaneous config File Commands -* Configuration File Names:: Using Different Configuration Files -* Log File Names:: Using Different Log Files -* Debugging Levels:: Debugging Levels -@end menu - -@node Miscellaneous (config), Configuration File Names, config File, config File -@subsection Miscellaneous config File Commands - -@table @code - -@item nodename @var{string} -@findex nodename -@itemx hostname @var{string} -@findex hostname -@itemx uuname @var{string} -@findex uuname -@cindex UUCP system name -@cindex system name - -These keywords are equivalent. They specify the UUCP name of the local -host. If there is no configuration file, an appropriate system function -will be used to get the host name, if possible. - -@item spool @var{string} -@findex spool -@cindex spool directory, setting -@cindex /usr/spool/uucp - -Specify the spool directory. The default is from @file{policy.h}. This -is where UUCP files are queued. Status files and various sorts of -temporary files are also stored in this directory and subdirectories of -it. - -@item pubdir @var{string} -@findex pubdir in config file -@cindex public directory -@cindex uucppublic -@cindex /usr/spool/uucppublic - -Specify the public directory. The default is from @file{policy.h}. -When a file is named using a leading @kbd{~/}, it is taken from or to -the public directory. Each system may use a separate public directory -by using the @code{pubdir} command in the system configuration file; see -@ref{Miscellaneous (sys)}. - -@item lockdir @var{string} -@findex lockdir -@cindex lock directory - -Specify the directory to place lock files in. The default is from -@file{policy.h}; see the information in that file. Normally the lock -directory should be set correctly in @file{policy.h}, and not changed -here. However, changing the lock directory is sometimes useful for -testing purposes. This only affects lock files for devices and systems; -it does not affect certain internal lock files which are stored in the -spool directory (@pxref{Spool Lock Files}). - -@item unknown @var{string} @dots{} -@findex unknown -@cindex unknown systems - -The @var{string} and subsequent arguments are treated as though they -appeared in the system file (@pxref{sys File}). They are used to apply -to any unknown systems that may call in, probably to set file transfer -permissions and the like. If the @code{unknown} command is not used, -unknown systems are not permitted to call in. - -@item strip-login @var{boolean} -@findex strip-login -@cindex parity in login names - -If the argument is true, then, when @code{uucico} is doing its own login -prompting with the @samp{-e}, @samp{-l}, or @samp{-w} switches, it will -strip the parity bit when it reads the login name and password. -Otherwise all eight bits will be used when checking the strings against -the UUCP password file. The default is true, since some other UUCP -packages send parity bits with the login name and password, and few -systems use eight bit characters in the password file. - -@item strip-proto @var{boolean} -@findex strip-proto - -If the argument is true, then @code{uucico} will strip the parity bit -from incoming UUCP protocol commands. Otherwise all eight bits will be -used. This only applies to commands which are not encapsulated in a -link layer protocol. The default is true, which should always be -correct unless your UUCP system names use eight bit characters. - -@item max-uuxqts @var{number} -@findex max-uuxqts - -Specify the maximum number of @code{uuxqt} processes which may run at -the same time. Having several @code{uuxqt} processes running at once -can significantly slow down a system, but, since @code{uuxqt} is -automatically started by @code{uucico}, it can happen quite easily. The -default for @code{max-uuxqts} is 0, which means that there is no limit. -If HDB configuration files are being read and the code was compiled -without @code{HAVE_TAYLOR_CONFIG}, then, if the file @file{Maxuuxqts} in -the configuration directory contains a readable number, it will be used -as the value for @code{max-uuxqts}. - -@item run-uuxqt @var{string} or @var{number} -@findex run-uuxqt - -Specify when @code{uuxqt} should be run by @code{uucico}. This may be a -positive number, in which case @code{uucico} will start a @code{uuxqt} -process whenever it receives the given number of execution files from -the remote system, and, if necessary, at the end of the call. The -argument may also be one of the strings @samp{once}, @samp{percall}, or -@samp{never}. The string @samp{once} means that @code{uucico} will -start @code{uuxqt} once at the end of execution. The string -@samp{percall} means that @code{uucico} will start @code{uuxqt} once per -call that it makes (this is only different from @code{once} when -@code{uucico} is invoked in a way that causes it to make multiple calls, -such as when the @samp{-r1} option is used without the @samp{-s} -option). The string @samp{never} means that @code{uucico} will never -start @code{uuxqt}, in which case @code{uuxqt} should be periodically -run via some other mechanism. The default depends upon which type of -configuration files are being used; if @code{HAVE_TAYLOR_CONFIG} is used -the default is @samp{once}, otherwise if @code{HAVE_HDB_CONFIG} is used -the default is @samp{percall}, and otherwise, for @code{HAVE_V2_CONFIG}, -the default is @samp{10}. - -@item timetable @var{string} @var{string} -@findex timetable - -The @code{timetable} defines a timetable that may be used in -subsequently appearing time strings; see @ref{Time Strings}. The first -string names the timetable entry; the second is a time string. - -The following @code{timetable} commands are predefined. The NonPeak -timetable is included for compatibility. It originally described the -offpeak hours of Tymnet and Telenet, but both have since changed their -schedules. - -@example -timetable Evening Wk1705-0755,Sa,Su -timetable Night Wk2305-0755,Sa,Su2305-1655 -timetable NonPeak Wk1805-0655,Sa,Su -@end example - -If this command does not appear, then, obviously, no additional -timetables will be defined. - -@item v2-files @var{boolean} -@findex v2-files - -If the code was compiled to be able to read V2 configuration files, a -false argument to this command will prevent them from being read. -This can be useful while testing. The default is true. - -@item hdb-files @var{boolean} -@findex hdb-files - -If the code was compiled to be able to read HDB configuration files, a -false argument to this command will prevent them from being read. -This can be useful while testing. The default is true. - -@end table - -@node Configuration File Names, Log File Names, Miscellaneous (config), config File -@subsection Configuration File Names - -@table @code - -@item sysfile @var{strings} -@findex sysfile - -Specify the system file(s). The default is the file @file{sys} in the -directory @var{newconfigdir}. These files hold information about other -systems with which this system communicates; see @ref{sys File}. -Multiple system files may be given on the line, and the @code{sysfile} -command may be repeated; each system file has its own set of defaults. - -@item portfile @var{strings} -@findex portfile - -Specify the port file(s). The default is the file @file{port} in the -directory @var{newconfigdir}. These files describe ports which are used -to call other systems and accept calls from other systems; see @ref{port -File}. No port files need be named at all. Multiple port files may be -given on the line, and the @code{portfile} command may be repeated. - -@item dialfile @var{strings} -@findex dialfile - -Specify the dial file(s). The default is the file @file{dial} in the -directory @var{newconfigdir}. These files describe dialing devices -(modems); see @ref{dial File}. No dial files need be named at all. -Multiple dial files may be given on the line, and the @code{dialfile} -command may be repeated. - -@item dialcodefile @var{strings} -@findex dialcodefile -@cindex configuration file (dialcode) -@cindex dialcode file -@cindex dialcode configuration file - -Specify the dialcode file(s). The default is the file @file{dialcode} -in the directory @var{newconfigdir}. These files specify dialcodes that -may be used when sending phone numbers to a modem. This permits using -the same set of phone numbers in different area-codes or with different -phone systems, by using dialcodes to specify the calling sequence. When -a phone number goes through dialcode translation, the leading alphabetic -characters are stripped off. The dialcode files are read line by line, -just like any other configuration file, and when a line is found whose -first word is the same as the leading characters from the phone number, -the second word on the line (which would normally consist of numbers) -replaces the dialcode in the phone number. No dialcode file need be -used. Multiple dialcode files may be specified on the line, and the -@code{dialcodefile} command may be repeated; all the dialcode files will -be read in turn until a dialcode is located. - -@item callfile @var{strings} -@findex callfile -@cindex call out file -@cindex call configuration file -@cindex call out login name -@cindex call out password -@cindex configuration file (call) - -Specify the call out login name and password file(s). The default is -the file @file{call} in the directory @var{newconfigdir}. If the call -out login name or password for a system are given as @kbd{*} -(@pxref{Logging In}), these files are read to get the real login name or -password. Each line in the file(s) has three words: the system name, -the login name, and the password. The login name and password may -contain escape sequences like those in a chat script expect string -(@pxref{Chat Scripts}). This file is only used when placing calls to -remote systems; the password file described under @code{passwdfile} -below is used for incoming calls. The intention of the call out file is -to permit the system file to be publically readable; the call out files -must obviously be kept secure. These files need not be used. Multiple -call out files may be specified on the line, and the @code{callfile} -command may be repeated; all the files will be read in turn until the -system is found. - -@item passwdfile @var{strings} -@findex passwdfile -@cindex passwd file -@cindex passwd configuration file -@cindex configuration file (passwd) -@cindex call in login name -@cindex call in password - -Specify the password file(s) to use for login names when @code{uucico} -is doing its own login prompting, which it does when given the -@samp{-e}, @samp{-l} or @samp{-w} switches. The default is the file -@file{passwd} in the directory @var{newconfigdir}. Each line in the -file(s) has two words: the login name and the password (e.g., @code{Ufoo -foopas}). They may contain escape sequences like those in a chat script -expect string (@pxref{Chat Scripts}). The login name is accepted before -the system name is known, so these are independent of which system is -calling in; a particular login may be required for a system by using the -@code{called-login} command in the system file (@pxref{Accepting a -Call}). These password files are optional, although one must exist if -@code{uucico} is to present its own login prompts. - -As a special exception, a colon may be used to separate the login name -from the password, and a colon may be used to terminate the password. -This means that the login name and password may not contain a colon. -This feature, in conjunction with the @code{HAVE_ENCRYPTED_PASSWORDS} -macro in @file{policy.h}, permits using a standard Unix -@file{/etc/passwd} as a UUCP password file, providing the same set of -login names and passwords for both @code{getty} and @code{uucico}. - -Multiple password files may be specified on the line, and the -@code{passwdfile} command may be repeated; all the files will be read in -turn until the login name is found. - -@end table - -@node Log File Names, Debugging Levels, Configuration File Names, config File -@subsection Log File Names - -@table @code - -@item logfile @var{string} -@findex logfile -@cindex log file - -Name the log file. The default is from @file{policy.h}. Logging -information is written to this file. If @code{HAVE_HDB_LOGGING} is -defined in @file{policy.h}, then by default a separate log file is used -for each system; using this command to name a log file will cause all -the systems to use it. - -@item statfile @var{string} -@findex statfile -@cindex statistics file - -Name the statistics file. The default is from @file{policy.h}. -Statistical information about file transfers is written to this file. - -@item debugfile @var{string} -@findex debugfile -@cindex debugging file - -Name the file to which all debugging information is written. The -default is from @file{policy.h}. This command is only effective if the -code has been compiled to include debugging (this is controlled by the -@code{DEBUG} macro in @file{policy.h}). If debugging is on, messages -written to the log file are also written to the debugging file to make -it easier to keep the order of actions straight. The debugging file is -different from the log file because information such as passwords can -appear in it, so it must be not be publically readable. - -@end table - -@node Debugging Levels, , Log File Names, config File -@subsection Debugging Levels - -@table @code - -@item debug @var{string} @dots{} -@findex debug in config file - -Set the debugging level. This command is only effective if the code has -been compiled to include debugging. The default is to have no -debugging. The arguments are strings which name the types of debugging -to be turned on. The following types of debugging are defined: - -@table @samp -@item abnormal -Output debugging messages for abnormal situations, such as recoverable errors. -@item chat -Output debugging messages for chat scripts. -@item handshake -Output debugging messages for the initial handshake. -@item uucp-proto -Output debugging messages for the UUCP session protocol. -@item proto -Output debugging messages for the individual link protocols. -@item port -Output debugging messages for actions on the communication port. -@item config -Output debugging messages while reading the configuration files. -@item spooldir -Output debugging messages for actions in the spool directory. -@item execute -Output debugging messages whenever another program is executed. -@item incoming -List all incoming data in the debugging file. -@item outgoing -List all outgoing data in the debugging file. -@item all -All of the above. -@end table - -The debugging level may also be specified as a number. A 1 will set -@samp{chat} debugging, a 2 will set both @samp{chat} and -@samp{handshake} debugging, and so on down the possibilities. Currently -an 11 will turn on all possible debugging, since there are 11 types of -debugging messages listed above; more debugging types may be added in -the future. The @code{debug} command may be used several times in the -configuration file; every debugging type named will be turned on. When -running any of the programs, the @samp{-x} switch (actually, for -@code{uulog} it's the @samp{-X} switch) may be used to turn on -debugging. The argument to the @samp{-x} switch is one of the strings -listed above, or a number as described above, or a comma separated list -of strings (e.g., @samp{-x chat,handshake}). The @samp{-x} switch may -also appear several times on the command line, in which case all named -debugging types will be turned on. The @samp{-x} debugging is in -addition to any debugging specified by the @code{debug} command; there -is no way to cancel debugging information. The debugging level may also -be set specifically for calls to or from a specific system with the -@code{debug} command in the system file (@pxref{Miscellaneous (sys)}). - -The debugging messages are somewhat idiosyncratic; it may be necessary -to refer to the source code for additional information in some cases. - -@end table - -@node sys File, port File, config File, Configuration Files -@section The System Configuration File -@cindex sys file -@cindex system configuration file -@cindex configuration file (sys) - -By default there is a single system configuration, named @file{sys} in -the directory @var{newconfigdir}. This may be overridden by the -@code{sysfile} command in the main configuration file; see -@ref{Configuration File Names}. - -These files describe all remote systems known to the UUCP package. - -@menu -* Defaults and Alternates:: Using Defaults and Alternates -* Naming the System:: Naming the System -* Calling Out:: Calling Out -* Accepting a Call:: Accepting a Call -* Protocol Selection:: Protocol Selection -* File Transfer Control:: File Transfer Control -* Miscellaneous (sys):: Miscellaneous sys File Commands -* Default sys File Values:: Default Values -@end menu - -@node Defaults and Alternates, Naming the System, sys File, sys File -@subsection Defaults and Alternates - -The first set of commands in the file, up to the first @code{system} -command, specify defaults to be used for all systems in that file. Each -@file{sys} file uses a different set of defaults. - -Subsequently, each set of commands from @code{system} up to the next -@code{system} command describe a particular system. Default values may -be overridden for specific systems. - -Each system may then have a series of alternate choices to use when -calling out or calling in. The first set of commands for a particular -system, up to the first @code{alternate} command, provide the first -choice. Subsequently, each set of commands from @code{alternate} up to -the next @code{alternate} command describe an alternate choice for -calling out or calling in. - -When a system is called, the commands before the first @code{alternate} -are used to select a phone number, port, and so forth; if the call fails -for some reason, the commands between the first @code{alternate} and the -second are used, and so forth. Well, not quite. Actually, each -succeeding alternate will only be used if it is different in some -relevant way (different phone number, different chat script, etc.). If -you want to force the same alternate to be used again (to retry a phone -call more than once, for example), enter the phone number (or any other -relevant field) again to make it appear different. - -The alternates can also be used to give different permissions to an -incoming call based on the login name. This will only be done if the -first set of commands, before the first @code{alternate} command, uses -the @code{called-login} command. The list of alternates will be -searched, and the first alternate with a matching @code{called-login} -command will be used. If no alternates match, the call will be -rejected. - -The @code{alternate} command may also be used in the file-wide defaults -(the set of commands before the first @code{system} command). This -might be used to specify a list of ports which are available for all -systems (for an example of this, see @ref{Gateway Example}) or to -specify permissions based on the login name used by the remote system -when it calls in. The first alternate for each system will default to -the first alternate for the file-wide defaults (as modified by the -commands used before the first @code{alternate} command for this -system), the second alternate for each system to the second alternate -for the file-wide defaults (as modified the same way), and so forth. If -a system specifies more alternates than the file-wide defaults, the -trailing ones will default to the last file-wide default alternate. If -a system specifies fewer alternates than the file-wide defaults, the -trailing file-wide default alternates will be used unmodified. The -@code{default-alternates} command may be used to modify this behaviour. - -This can all get rather confusing, although it's easier to use than to -describe concisely; the @code{uuchk} program may be used to ensure that -you are getting what you want. - -@need 2000 -@node Naming the System, Calling Out, Defaults and Alternates, sys File -@subsection Naming the System - -@table @code - -@item system @var{string} -@findex system - -Specify the remote system name. Subsequent commands up to the next -@code{system} command refer to this system. - -@item alternate [@var{string}] -@findex alternate - -Start an alternate set of commands (@pxref{Defaults and Alternates}). -An optional argument may be used to name the alternate. This name will -be recorded in the log file if the alternate is used to call the system. -There is no way to name the first alternate (the commands before the -first @code{alternate} command). - -@item default-alternates @var{boolean} -@findex default-alternates - -If the argument is false, any remaining default alternates (from the -defaults specified at the top of the current system file) will not be -used. The default is true. - -@item alias @var{string} -@findex alias - -Specify an alias for the current system. The alias may be used by local -@code{uucp} and @code{uux} commands, as well as by the remote system -(which can be convenient if a remote system changes its name). The -default is to have no aliases. - -@item myname @var{string} -@findex myname - -Specifies a different system name to use when calling the remote system. -Also, if @code{called-login} is used and is not @samp{ANY}, then, when a -system logs in with that login name, @var{string} is used as the local -system name. Because the local system name must be determined before -the remote system has identified itself, using @code{myname} and -@code{called-login} together for any system will set the local name for -that login; this means that each locally used system name must have a -unique login name associated with it. This allows a system to have -different names for an external and an internal network. The default is -to not use a special local name. - -@end table - -@node Calling Out, Accepting a Call, Naming the System, sys File -@subsection Calling Out - -This section describes commands used when placing a call to another -system. - -@menu -* When to Call:: When to Call -* Placing the Call:: Placing the Call -* Logging In:: Logging In -@end menu - -@need 2000 -@node When to Call, Placing the Call, Calling Out, Calling Out -@subsubsection When to Call - -@table @code - -@item time @var{string} [@var{number}] -@findex time - -Specify when the system may be called. The first argument is a time -string; see @ref{Time Strings}. The optional second argument specifies -a retry time in minutes. If a call made during a time that matches the -time string fails, no more calls are permitted until the retry time has -passed. By default an exponentially increasing retry time is used: -after each failure the next retry period is longer. A retry time -specified in the @code{time} command is always a fixed amount of time. - -The @code{time} command may appear multiple times in a single alternate, -in which case if any time string matches the system may be called. When -the @code{time} command is used for a particular system, any @code{time} -or @code{timegrade} commands that appeared in the system defaults are -ignored. - -The default time string is @samp{Never}. - -@item timegrade @var{character} @var{string} [@var{number}] -@findex timegrade -@cindex grades - -The @var{character} specifies a grade. It must be a single letter or -digit. The @var{string} is a time string (@pxref{Time Strings}). All -jobs of grade @var{character} or higher (where @kbd{0} > @kbd{9} > -@kbd{A} > @kbd{Z} > @kbd{a} > @kbd{z}) may be run at the specified time. -An ordinary @code{time} command is equivalent to using @code{timegrade} -with a grade of @kbd{z}, permitting all jobs. If there are no jobs of a -sufficiently high grade according to the time string, the system will -not be called. Giving the @samp{-s} switch to @code{uucico} to force it -to call a system causes it to assume there is a job of grade @kbd{0} -waiting to be run. - -The optional third argument specifies a retry time in minutes. See the -@code{time} command, above, for more details. - -Note that the @code{timegrade} command serves two purposes: 1) if there -is no job of sufficiently high grade the system will not be called, and -2) if the system is called anyway (because the @samp{-s} switch was -given to @code{uucico}) only jobs of sufficiently high grade will be -transferred. However, if the other system calls in, the -@code{timegrade} commands are ignored, and jobs of any grade may be -transferred (but see @code{call-timegrade} and @code{called-timegrade}, -below). Also, the @code{timegrade} command will not prevent the other -system from transferring any job it chooses, regardless of who placed -the call. - -The @code{timegrade} command may appear multiple times without using -@code{alternate}. When the @code{timegrade} command is used for a -particular system, any @code{time} or @code{timegrade} commands that -appeared in the system defaults are ignored. - -If this command does not appear, there are no restrictions on what grade -of work may be done at what time. - -@item max-retries @var{number} -@findex max-retries - -Gives the maximum number of times this system may be retried. If this -many calls to the system fail, it will be called at most once a day -whatever the retry time is. The default is 26. - -@item success-wait @var{number} - -A retry time, in seconds, which applies after a successful call. This -can be used to put a limit on how frequently the system is called. For -example, an argument of 1800 means that the system will not be called -more than once every half hour. The default is 0, which means that -there is no limit. - -@item call-timegrade @var{character} @var{string} -@findex call-timegrade - -The @var{character} is a single character @kbd{A} to @kbd{Z}, @kbd{a} to -@kbd{z}, or @kbd{0} to @kbd{9} and specifies a grade. The @var{string} -is a time string (@pxref{Time Strings}). If a call is placed to the -other system during a time which matches the time string, the remote -system will be requested to only run jobs of grade @var{character} or -higher. Unfortunately, there is no way to guarantee that the other -system will obey the request (this UUCP package will, but there are -others which will not); moreover, job grades are historically somewhat -arbitrary, so specifying a grade will only be meaningful if the other -system cooperates in assigning grades. This grade restriction only -applies when the other system is called, not when the other system calls -in. - -The @code{call-timegrade} command may appear multiple times without -using @code{alternate}. If this command does not appear, or if none of -the time strings match, the remote system will be allowed to send -whatever grades of work it chooses. - -@item called-timegrade @var{character} @var{string} -@findex called-timegrade - -The @var{character} is a single character @kbd{A} to @kbd{Z}, @kbd{a} to -@kbd{z}, or @kbd{0} to @kbd{9} and specifies a grade. The @var{string} -is a time string (@pxref{Time Strings}). If a call is received from the -other system during a time which matches the time string, only jobs of -grade @var{character} or higher will be sent to the remote system. This -allows the job grade to be set for incoming calls, overriding any -request made by the remote uucico. As noted above, job grades are -historically somewhat arbitrary, so specifying a grade will only be -meaningful if the other system cooperates in assigning grades. This -grade restriction only applies to jobs on the local system; it does not -affect the jobs transferred by the remote system. This grade -restriction only applies when the other system calls in, not when the -other system is called. - -The @code{called-timegrade} command may appear multiple times. If this -command does not appear, or if none of the time strings match, any grade -may be sent to the remote system upon receiving a call. - -@end table - -@need 2000 -@node Placing the Call, Logging In, When to Call, Calling Out -@subsubsection Placing the Call - -@table @code - -@itemx speed @var{number} -@findex speed in sys file -@item baud @var{number} -@findex baud in sys file - -Specify the speed (the term @dfn{baud} is technically incorrect, but -widely understood) at which to call the system. This will try all -available ports with that speed until an unlocked port is found. The -ports are defined in the port file. If both @code{speed} and -@code{port} commands appear, both are used when selecting a port. To -allow calls at more than one speed, the @code{alternate} command must be -used (@pxref{Defaults and Alternates}). If this command does not -appear, there is no default; the speed may be specified in the port -file, but if it is not then the natural speed of the port will be used -(whatever that means on the system). Specifying an explicit speed of 0 -will request the natural speed of the port (whatever the system sets it -to), overriding any default speed from the defaults at the top of the -file. - -@item port @var{string} -@findex port in sys file - -Name a particular port or type of port to use when calling the system. -The information for this port is obtained from the port file. If this -command does not appear, there is no default; a port must somehow be -specified in order to call out (it may be specified implicitly using the -@code{speed} command or explicitly using the next version of -@code{port}). There may be many ports with the same name; each will be -tried in turn until an unlocked one is found which matches the desired -speed. - -@item port @var{string} @dots{} - -If more than one string follows the @code{port} command, the strings are -treated as a command that might appear in the port file (@pxref{port -File}). If a port is named (by using a single string following -@code{port}) these commands are ignored; their purpose is to permit -defining the port completely in the system file rather than always -requiring entries in two different files. In order to call out, a port -must be specified using some version of the @code{port} command, or by -using the @code{speed} command to select ports from the port file. - -@item phone @var{string} -@findex phone -@itemx address @var{string} -@findex address - -Give a phone number to call (when using a modem port) or a remote host -to contact (when using a TCP or TLI port). The commands @code{phone} -and @code{address} are equivalent; the duplication is intended to -provide a mnemonic choice depending on the type of port in use. - -When used with a modem port, an @kbd{=} character in the phone number -means to wait for a secondary dial tone (although only some modems -support this); a @kbd{-} character means to pause while dialing for 1 -second (again, only some modems support this). If the system has more -than one phone number, each one must appear in a different alternate. -The @code{phone} command must appear in order to call out on a modem; -there is no default. - -When used with a TCP port, the string names the host to contact. It may -be a domain name or a numeric Internet address. If no address is -specified, the system name is used. - -When used with a TLI port, the string is treated as though it were an -expect string in a chat script, allowing the use of escape characters -(@pxref{Chat Scripts}). The @code{dialer-sequence} command in the port -file may override this address (@pxref{port File}). - -When used with a port that not a modem or TCP or TLI, this command is -ignored. - -@end table - -@node Logging In, , Placing the Call, Calling Out -@subsubsection Logging In -@table @code - -@item chat @var{strings} -@findex chat in sys file -@item chat-timeout @var{number} -@findex chat-timeout in sys file -@item chat-fail @var{string} -@findex chat-fail in sys file -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit in sys file -@item chat-program @var{strings} -@findex chat-program in sys file - -These commands describe a chat script to use when logging on to a remote -system. This login chat script is run after any chat script defined in -the @file{dial} file (@pxref{dial File}). Chat scripts are explained in -@ref{Chat Scripts}. - -Two additional escape sequences may be used in send strings. - -@table @samp -@item \L -Send the login name, as set by the @code{call-login} command. -@item \P -Send the password, as set by the @code{call-password} command. -@end table - -Three additional escape sequences may be used with the -@code{chat-program} command. These are @samp{\L} and @samp{\P}, which -become the login name and password, respectively, and @samp{\Z}, which -becomes the name of the system of being called. - -The default chat script is: - -@example -chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P -@end example - -This will send a carriage return (the @kbd{\c} suppresses the additional -trailing carriage return that would otherwise be sent) and waits for the -string @samp{ogin:} (which would be the last part of the @samp{login:} -prompt supplied by a Unix system). If it doesn't see @samp{ogin:}, it -sends a break and waits for @samp{ogin:} again. If it still doesn't see -@samp{ogin:}, it sends another break and waits for @samp{ogin:} again. -If it still doesn't see @samp{ogin:}, the chat script aborts and hangs -up the phone. If it does see @samp{ogin:} at some point, it sends the -login name (as specified by the @code{call-login} command) followed by a -carriage return (since all send strings are followed by a carriage -return unless @kbd{\c} is used) and waits for the string @samp{word:} -(which would be the last part of the @samp{Password:} prompt supplied by -a Unix system). If it sees @samp{word:}, it sends the password and a -carriage return, completing the chat script. The program will then -enter the handshake phase of the UUCP protocol. - -This chat script will work for most systems, so you will only be -required to use the @code{call-login} and @code{call-password} commands. -In fact, in the file-wide defaults you could set defaults of -@samp{call-login *} and @samp{call-password *}; you would then just have -to make an entry for each system in the call-out login file. - -Some systems seem to flush input after the @samp{login:} prompt, so they -may need a version of this chat script with a @kbd{\d} before the -@kbd{\L}. When using UUCP over TCP, some servers will not be handle the -initial carriage return sent by this chat script; in this case you may -have to specify the simple chat script @samp{ogin: \L word: \P}. - -@item call-login @var{string} -@findex call-login - -Specify the login name to send with @kbd{\L} in the chat script. If the -string is @samp{*} (e.g., @samp{call-login *}) the login name will be -fetched from the call out login name and password file -(@pxref{Configuration File Names}). The string may contain escape -sequences as though it were an expect string in a chat script -(@pxref{Chat Scripts}). There is no default. - -@item call-password @var{string} -@findex call-password - -Specify the password to send with @kbd{\P} in the chat script. If the -string is @samp{*} (e.g., @samp{call-password *}) the password will be -fetched from the call-out login name and password file -(@pxref{Configuration File Names}). The string may contain escape -sequences as though it were an expect string in a chat script -(@pxref{Chat Scripts}). There is no default. - -@end table - -@node Accepting a Call, Protocol Selection, Calling Out, sys File -@subsection Accepting a Call - -@table @code - -@item called-login @var{strings} -@findex called-login - -The first @var{string} specifies the login name that the system must use -when calling in. If it is @samp{ANY} (e.g., @samp{called-login ANY}) any -login name may be used; this is useful to override a file-wide default -and to indicate that future alternates may have different login names. -Case is significant. The default value is @samp{ANY}. - -Different alternates (@pxref{Defaults and Alternates}) may use different -@code{called-login} commands, in which case the login name will be used -to select which alternate is in effect; this will only work if the first -alternate (before the first @code{alternate} command) uses the -@code{called-login} command. - -Additional strings may be specified after the login name; they are a -list of which systems are permitted to use this login name. If this -feature is used, then normally the login name will only be given in a -single @code{called-login} command. Only systems which appear on the -list, or which use an explicit @code{called-login} command, will be -permitted to use that login name. If the same login name is used more -than once with a list of systems, all the lists are concatenated -together. This feature permits you to restrict a login name to a -particular set of systems without requiring you to use the -@code{called-login} command for every single system; you can achieve a -similar effect by using a different system file for each permitted login -name with an appropriate @code{called-login} command in the file-wide -defaults. - -@item callback @var{boolean} -@findex callback - -If @var{boolean} is true, then when the remote system calls -@code{uucico} will hang up the connection and prepare to call it back. -The default is false. - -@item called-chat @var{strings} -@findex called-chat -@item called-chat-timeout @var{number} -@findex called-chat-timeout -@item called-chat-fail @var{string} -@findex called-chat-fail -@item called-chat-seven-bit @var{boolean} -@findex called-chat-seven-bit -@item called-chat-program @var{strings} -@findex called-chat-program - -These commands may be used to define a chat script (@pxref{Chat -Scripts}) that is run whenever the local system is called by the system -being defined. The chat script defined by the @code{chat} command -(@pxref{Logging In}), on the other hand, is used when the remote system -is called. This called chat script might be used to set special modem -parameters that are appropriate to a particular system. It is run after -protocol negotiation is complete, but before the protocol has been -started. For additional escape sequence which may be used besides those -defined for all chat scripts, see @ref{Logging In}. There is no default -called chat script. If the called chat script fails, the incoming call -will be aborted. - -@end table - -@node Protocol Selection, File Transfer Control, Accepting a Call, sys File -@subsection Protocol Selection - -@table @code - -@item protocol @var{string} -@findex protocol in sys file - -Specifies which protocols to use for the other system, and in which -order to use them. This would not normally be used. For example, -@samp{protocol tfg}. - -The default depends on the characteristics of the port and the dialer, -as specified by the @code{seven-bit} and @code{reliable} commands. If -neither the port nor the dialer use either of these commands, the -default is to assume an eight-bit reliable connection. The commands -@samp{seven-bit true} or @samp{reliable false} might be used in either -the port or the dialer to change this. Each protocol has particular -requirements that must be met before it will be considered during -negotiation with the remote side. - -The @samp{t} and @samp{e} protocols are intended for use over TCP or -some other communication path with end to end reliability, as they do no -checking of the data at all. They will only be considered on a TCP port -which is both reliable and eight bit. For technical details, see @ref{t -Protocol}, and @ref{e Protocol}. - -The @samp{i} protocol is a bidirectional protocol. It requires an -eight-bit connection. It will run over a half-duplex link, such as -Telebit modems in PEP mode, but for efficient use of such a connection -you must use the @code{half-duplex} command (@pxref{port File}). -@xref{i Protocol}. - -The @samp{g} protocol is robust, but requires an eight-bit connection. -@xref{g Protocol}. - -The @samp{G} protocol is the System V Release 4 version of the @samp{g} -protocol. @xref{Big G Protocol}. - -The @samp{a} protocol is a Zmodem like protocol, contributed by Doug -Evans. It requires an eight-bit connection, but unlike the @samp{g} or -@samp{i} protocol it will work if certain control characters may not be -transmitted. - -The @samp{j} protocol is a variant of the @samp{i} protocol which can -avoid certain control characters. The set of characters it avoids can -be set by a parameter. While it technically does not require an eight -bit connection (it could be configured to avoid all characters with the -high bit set) it would be very inefficient to use it over one. It is -useful over a eight-bit connection that will not transmit certain -control characters. @xref{j Protocol}. - -The @samp{f} protocol is intended for use with X.25 connections; it -checksums each file as a whole, so any error causes the entire file to -be retransmitted. It requires a reliable connection, but only uses -seven-bit transmissions. It is a streaming protocol, so, while it can -be used on a serial port, the port must be completely reliable and flow -controlled; many aren't. @xref{f Protocol}. - -The @samp{v} protocol is the @samp{g} protocol as used by the DOS -program UUPC/Extended. It is provided only so that UUPC/Extended users -can use it; there is no particular reason to select it. @xref{v -Protocol}. - -The @samp{y} protocol is an efficient streaming protocol. It does error -checking, but when it detects an error it immediately aborts the -connection. This requires a reliable, flow controlled, eight-bit -connection. In practice, it is only useful on a connection that is -nearly always error-free. Unlike the @samp{t} and @samp{e} protocols, -the connection need not be entirely error-free, so the @samp{y} protocol -can be used on a serial port. @xref{y Protocol}. - -The protocols will be considered in the order shown above. This means -that if neither the @code{seven-bit} nor the @code{reliable} command are -used, the @samp{t} protocol will be used over a TCP connection and the -@samp{i} protocol will be used over any other type of connection -(subject, of course, to what is supported by the remote system; it may -be assumed that all systems support the @samp{g} protocol). - -Note that currently specifying both @samp{seven-bit true} and -@samp{reliable false} will not match any protocol. If this occurs -through a combination of port and dialer specifications, you will have -to use the @code{protocol} command for the system or no protocol will be -selected at all (the only reasonable choice would be @samp{protocol f}). - -A protocol list may also be specified for a port (@pxref{port File}), -but, if there is a list for the system, the list for the port is -ignored. - -@item protocol-parameter @var{character} @var{string} @dots{} -@findex protocol-parameter in sys file - -@var{character} is a single character specifying a protocol. The -remaining strings are a command specific to that protocol which will be -executed if that protocol is used. A typical command is something like -@samp{window 7}. The particular commands are protocol specific. - -The @samp{i} protocol supports the following commands, all of which take -numeric arguments: - -@table @code -@item window -The window size to request the remote system to use. This must be -between 1 and 16 inclusive. The default is 16. -@item packet-size -The packet size to request the remote system to use. This must be -between 1 and 4095 inclusive. The default is 1024. -@item remote-packet-size -If this is between 1 and 4095 inclusive, the packet size requested by -the remote system is ignored, and this is used instead. The default is -0, which means that the remote system's request is honored. -@item sync-timeout -The length of time, in seconds, to wait for a SYNC packet from the remote -system. SYNC packets are exchanged when the protocol is started. The -default is 10. -@item sync-retries -The number of times to retry sending a SYNC packet before giving up. -The default is 6. -@item timeout -The length of time, in seconds, to wait for an incoming packet before -sending a negative acknowledgement. The default is 10. -@item retries -The number of times to retry sending a packet or a negative -acknowledgement before giving up and closing the connection. The -default is 6. -@item errors -The maximum number of errors to permit before closing the connection. -The default is 100. -@item error-decay -The rate at which to ignore errors. Each time this many packets are -received, the error count is decreased by one, so that a long connection -with an occasional error will not exceed the limit set by @code{errors}. -The default is 10. -@item ack-frequency -The number of packets to receive before sending an acknowledgement. The -default is half the requested window size, which should provide good -performance in most cases. -@end table - -The @samp{g}, @samp{G} and @samp{v} protocols support the following -commands, all of which take numeric arguments, except -@code{short-packets} which takes a boolean argument: - -@table @code -@item window -The window size to request the remote system to use. This must be -between 1 and 7 inclusive. The default is 7. -@item packet-size -The packet size to request the remote system to use. This must be a -power of 2 between 32 and 4096 inclusive. The default is 64 for the -@samp{g} and @samp{G} protocols and 1024 for the @samp{v} protocol. -Many older UUCP packages do not support packet sizes larger than 64, and -many others do not support packet sizes larger than 128. Some UUCP -packages will even dump core if a larger packet size is requested. The -packet size is not a negotiation, and it may be different in each -direction. If you request a packet size larger than the remote system -supports, you will not be able to send any files. -@item startup-retries -The number of times to retry the initialization sequence. The default -is 8. -@item init-retries -The number of times to retry one phase of the initialization sequence -(there are three phases). The default is 4. -@item init-timeout -The timeout in seconds for one phase of the initialization sequence. The -default is 10. -@item retries -The number of times to retry sending either a data packet or a request -for the next packet. The default is 6. -@item timeout -The timeout in seconds when waiting for either a data packet or an -acknowledgement. The default is 10. -@item garbage -The number of unrecognized bytes to permit before dropping the -connection. This must be larger than the packet size. The default is -10000. -@item errors -The number of errors (malformed packets, out of order packets, bad -checksums, or packets rejected by the remote system) to permit before -dropping the connection. The default is 100. -@item error-decay -The rate at which to ignore errors. Each time this many packets are -received, the error count is decreased by one, so that a long connection -with an occasional error will not exceed the limit set by @code{errors}. -The default is 10. -@item remote-window -If this is between 1 and 7 inclusive, the window size requested by the -remote system is ignored and this is used instead. This can be useful -when dealing with some poor UUCP packages. The default is 0, which -means that the remote system's request is honored. -@item remote-packet-size -If this is between 32 and 4096 inclusive the packet size requested by -the remote system is ignored and this is used instead. There is -probably no good reason to use this. The default is 0, which means that -the remote system's request is honored. -@item short-packets -If this is true, then the code will optimize by sending shorter packets -when there is less data to send. This confuses some UUCP packages, such -as System V Release 4 (when using the @samp{G} protocol) and Waffle; -when connecting to such a package, this parameter must be set to false. -The default is true for the @samp{g} and @samp{v} protocols and false -for the @samp{G} protocol. -@end table - -The @samp{a} protocol is a Zmodem like protocol contributed by Doug -Evans. It supports the following commands, all of which take numeric -arguments except for @code{escape-control}, which takes a boolean -argument: - -@table @code -@item timeout -Number of seconds to wait for a packet to arrive. The default is 10. -@item retries -The number of times to retry sending a packet. The default is 10. -@item startup-retries -The number of times to retry sending the initialization packet. The -default is 4. -@item garbage -The number of garbage characters to accept before closing the -connection. The default is 2400. -@item send-window -The number of characters that may be sent before waiting for an -acknowledgement. The default is 1024. -@item escape-control -Whether to escape control characters. If this is true, the protocol may -be used over a connection which does not transmit certain control -characters, such as @code{XON} or @code{XOFF}. The connection must -still transmit eight bit characters other than control characters. The -default is false. -@end table - -The @samp{j} protocol can be used over an eight bit connection that will -not transmit certain control characters. It accepts the same protocol -parameters that the @samp{i} protocol accepts, as well as one more: - -@table @code -@item avoid -A list of characters to avoid. This is a string which is interpreted as -an escape sequence (@pxref{Chat Scripts}). The protocol does not have a -way to avoid printable ASCII characters (byte values from 32 to 126, -inclusive); only ASCII control characters and eight-bit characters may -be avoided. The default value is @samp{\021\023}; these are the -characters @code{XON} and @code{XOFF}, which many connections use for -flow control. If the package is configured to use @code{HAVE_BSD_TTY}, -then on some versions of Unix you may have to avoid @samp{\377} as well, -due to the way some implementations of the BSD terminal driver handle -signals. -@end table - -The @samp{f} protocol is intended for use with error-correcting modems -only; it checksums each file as a whole, so any error causes the entire -file to be retransmitted. It supports the following commands, both of -which take numeric arguments: - -@table @code -@item timeout -The timeout in seconds before giving up. The default is 120. -@item retries -How many times to retry sending a file. The default is 2. -@end table - -The @samp{t} and @samp{e} protocols are intended for use over TCP or -some other communication path with end to end reliability, as they do no -checking of the data at all. They both support a single command, which -takes a numeric argument: - -@table @code -@item timeout -The timeout in seconds before giving up. The default is 120. -@end table - -The @samp{y} protocol is a streaming protocol contributed by Jorge Cwik. -It supports the following commands, both of which take numeric -arguments: - -@table @code -@item timeout -The timeout in seconds when waiting for a packet. The default is 60. -@item packet-size -The packet size to use. The default is 1024. -@end table - -The protocol parameters are reset to their default values after each -call. - -@end table - -@node File Transfer Control, Miscellaneous (sys), Protocol Selection, sys File -@subsection File Transfer Control - -@table @code - -@item send-request @var{boolean} -@findex send-request - -The @var{boolean} determines whether the remote system is permitted to -request files from the local system. The default is yes. - -@item receive-request @var{boolean} -@findex receive-request - -The @var{boolean} determines whether the remote system is permitted to -send files to the local system. The default is yes. - -@item request @var{boolean} -@findex request - -A shorthand command, equivalent to specifying both @samp{send-request -@var{boolean}} and @samp{receive-request @var{boolean}}. - -@item call-transfer @var{boolean} -@findex call-transfer - -The @var{boolean} is checked when the local system places the call. It -determines whether the local system may do file transfers queued up for -the remote system. The default is yes. - -@item called-transfer @var{boolean} -@findex called-transfer - -The @var{boolean} is checked when the remote system calls in. It -determines whether the local system may do file transfers queued up for -the remote system. The default is yes. - -@item transfer @var{boolean} -@findex transfer - -A shorthand command, equivalent to specifying both @samp{call-transfer -@var{boolean}} and @samp{called-transfer @var{boolean}}. - -@item call-local-size @var{number} @var{string} -@findex call-local-size - -The @var{string} is a time string (@pxref{Time Strings}). The -@var{number} is the size in bytes of the largest file that should be -transferred at a time matching the time string, if the local system -placed the call and the request was made by the local system. This -command may appear multiple times in a single alternate. If this -command does not appear, or if none of the time strings match, there are -no size restrictions. - -With all the size control commands, the size of a file from the remote -system (as opposed to a file from the local system) will only be checked -if the other system is running this package: other UUCP packages will -not understand a maximum size request, nor will they provide the size of -remote files. - -@item call-remote-size @var{number} @var{string} -@findex call-remote-size - -Specify the size in bytes of the largest file that should be transferred -at a given time by remote request, when the local system placed the -call. This command may appear multiple times in a single alternate. If -this command does not appear, there are no size restrictions. - -@item called-local-size @var{number} @var{string} -@findex called-local-size - -Specify the size in bytes of the largest file that should be transferred -at a given time by local request, when the remote system placed the -call. This command may appear multiple times in a single alternate. If -this command does not appear, there are no size restrictions. - -@item called-remote-size @var{number} @var{string} -@findex called-remote-size - -Specify the size in bytes of the largest file that should be transferred -at a given time by remote request, when the remote system placed the -call. This command may appear multiple times in a single alternate. If -this command does not appear, there are no size restrictions. - -@item local-send @var{strings} -@findex local-send - -Specifies that files in the directories named by the @var{strings} may -be sent to the remote system when requested locally (using @code{uucp} -or @code{uux}). The directories in the list should be separated by -whitespace. A @samp{~} may be used for the public directory. On a Unix -system, this is typically @file{/usr/spool/uucppublic}; the public -directory may be set with the @code{pubdir} command. Here is an example -of @code{local-send}: - -@example -local-send ~ /usr/spool/ftp/pub -@end example - -Listing a directory allows all files within the directory and all -subdirectories to be sent. Directories may be excluded by preceding -them with an exclamation point. For example: - -@example -local-send /usr/ftp !/usr/ftp/private ~ -@end example - -@noindent -means that all files in @file{/usr/ftp} or the public directory may be -sent, except those files in @file{/usr/ftp/private}. The list of -directories is read from left to right, and the last directory to apply -takes effect; this means that directories should be listed from top -down. The default is the root directory (i.e., any file at all may be -sent by local request). - -@item remote-send @var{strings} -@findex remote-send - -Specifies that files in the named directories may be sent to the remote -system when requested by the remote system. The default is @samp{~}. - -@item local-receive @var{strings} -@findex local-receive - -Specifies that files may be received into the named directories when -requested by a local user. The default is @samp{~}. - -@item remote-receive @var{strings} -@findex remote-receive - -Specifies that files may be received into the named directories when -requested by the remote system. The default is @samp{~}. On Unix, the -remote system may only request that files be received into directories -that are writeable by the world, regardless of how this is set. - -@item forward-to @var{strings} -@findex forward-to - -Specifies a list of systems to which files may be forwarded. The remote -system may forward files through the local system on to any of the -systems in this list. The string @samp{ANY} may be used to permit -forwarding to any system. The default is to not permit forwarding to -other systems. Note that if the remote system is permitted to execute -the @code{uucp} command, it effectively has the ability to forward to -any system. - -@item forward-from @var{strings} -@findex forward-from - -Specifies a list of systems from which files may be forwarded. The -remote system may request files via the local system from any of the -systems in this list. The string @samp{ANY} may be used to permit -forwarding to any system. The default is to not permit forwarding from -other systems. Note that if a remote system is permitted to execute the -@code{uucp} command, it effectively has the ability to request files -from any system. - -@item forward @var{strings} -@findex forward - -Equivalent to specifying both @samp{forward-to @var{strings}} and -@samp{forward-from @var{strings}}. This would normally be used rather -than either of the more specific commands. - -@end table - -@node Miscellaneous (sys), Default sys File Values, File Transfer Control, sys File -@subsection Miscellaneous sys File Commands - -@table @code - -@item sequence @var{boolean} -@findex sequence - -If @var{boolean} is true, then conversation sequencing is automatically -used for the remote system, so that if somebody manages to spoof as the -remote system, it will be detected the next time the remote system -actually calls. This is false by default. - -@item command-path @var{strings} -@findex command-path - -Specifies the path (a list of whitespace separated directories) to be -searched to locate commands to execute. This is only used for commands -requested by @code{uux}, not for chat programs. The default is from -@file{policy.h}. - -@item commands @var{strings} -@findex commands - -The list of commands which the remote system is permitted to execute -locally. For example: @samp{commands rnews rmail}. If the value is -@samp{ALL} (case significant), all commands may be executed. The -default is @samp{rnews rmail}. - -@item free-space @var{number} -@findex free-space - -Specify the minimum amount of file system space (in bytes) to leave free -after receiving a file. If the incoming file will not fit, it will be -rejected. This initial rejection will only work when talking to another -instance of this package, since older UUCP packages do not provide the -file size of incoming files. Also, while a file is being received, -@code{uucico} will periodically check the amount of free space. If it -drops below the amount given by the @code{free-space} command, the file -transfer will be aborted. The default amount of space to leave free is -from @file{policy.h}. This file space checking may not work on all -systems. - -@item pubdir @var{string} -@findex pubdir in sys file - -Specifies the public directory that is used when @samp{~} is specifed in -a file transfer or a list of directories. This essentially overrides -the public directory specified in the main configuration file for this -system only. The default is the public directory specified in the main -configuration file (which defaults to a value from @file{policy.h}). - -@item debug @var{string} @dots{} -@findex debug in sys file - -Set additional debugging for calls to or from the system. This may be -used to debug a connection with a specific system. It is particularly -useful when debugging incoming calls, since debugging information will -be generated whenever the call comes in. See the @code{debug} command -in the main configuration file (@pxref{Debugging Levels}) for more -details. The debugging information specified here is in addition to -that specified in the main configuration file or on the command line. - -@item max-remote-debug @var{string} @dots{} -@findex max-remote-debug - -When the system calls in, it may request that the debugging level be set -to a certain value. The @code{max-remote-debug} command may be used to -put a limit on the debugging level which the system may request, to -avoid filling up the disk with debugging information. Only the -debugging types named in the @code{max-remote-debug} command may be -turned on by the remote system. To prohibit any debugging, use -@samp{max-remote-debug none}. - -@end table - -@node Default sys File Values, , Miscellaneous (sys), sys File -@subsection Default sys File Values - -The following are used as default values for all systems; they can be -considered as appearing before the start of the file. - -@example -time Never -chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P -chat-timeout 10 -callback n -sequence n -request y -transfer y -local-send / -remote-send ~ -local-receive ~ -remove-receive ~ -command-path [ from @file{policy.h} ] -commands rnews rmail -max-remote-debug abnormal,chat,handshake -@end example - -@node port File, dial File, sys File, Configuration Files -@section The Port Configuration File -@cindex port file -@cindex port configuration file -@cindex configuration file (port) - -The port files may be used to name and describe ports. By default there -is a single port file, named @file{port} in the directory -@var{newconfigdir}. This may be overridden by the @code{portfile} -command in the main configuration file; see @ref{Configuration File -Names}. - -Any commands in a port file before the first @code{port} command specify -defaults for all ports in the file; however, since the @code{type} -command must appear before all other commands for a port, the defaults -are only useful if all ports in the file are of the same type (this -restriction may be lifted in a later version). All commands after a -@code{port} command up to the next @code{port} command then describe -that port. There are different types of ports; each type supports its -own set of commands. Each command indicates which types of ports -support it. There may be many ports with the same name; if a system -requests a port by name then each port with that name will be tried -until an unlocked one is found. - -@table @code - -@item port @var{string} -@findex port in port file - -Introduces and names a port. - -@item type @var{string} -@findex type - -Define the type of port. The default is @samp{modem}. If this command -appears, it must immediately follow the @code{port} command. The type defines -what commands are subsequently allowed. Currently the types are: - -@table @samp -@item modem -For a modem hookup. -@item stdin -For a connection through standard input and standard output, as when -@code{uucico} is run as a login shell. -@item direct -For a direct connection to another system. -@item tcp -For a connection using TCP. -@item tli -For a connection using TLI. -@item pipe -For a connection through a pipe running another program. -@end table - -@item protocol @var{string} -@findex protocol in port file - -Specify a list of protocols to use for this port. This is just like the -corresponding command for a system (@pxref{Protocol Selection}). A -protocol list for a system takes precedence over a list for a port. - -@item protocol-parameter @var{character} @var{strings} [ any type ] -@findex protocol-parameter in port file - -The same command as the @code{protocol-parameter} command used for -systems (@pxref{Protocol Selection}). This one takes precedence. - -@item seven-bit @var{boolean} [ any type ] -@findex seven-bit in port file - -This is only used during protocol negotiation; if the argument is true, -it forces the selection of a protocol which works across a seven-bit -link. It does not prevent eight bit characters from being transmitted. -The default is false. - -@item reliable @var{boolean} [ any type ] -@findex reliable in port file - -This is only used during protocol negotiation; if the argument is -false, it forces the selection of a protocol which works across -an unreliable communication link. The default is true. It would -be more common to specify this for a dialer rather than a port. - -@item half-duplex @var{boolean} [ any type ] -@findex half-duplex in port file - -If the argument is true, it means that the port only supports -half-duplex connections. This only affects bidirectional protocols, and -causes them to not do bidirectional transfers. - -@item device @var{string} [ modem, direct and tli only ] -@findex device - -Names the device associated with this port. If the device is not named, -the port name is taken as the device. Device names are system -dependent. On Unix, a modem or direct connection might be something -like @file{/dev/ttyd0}; a TLI port might be @file{/dev/inet/tcp}. - -@itemx speed @var{number} [modem and direct only ] -@findex speed in port file -@item baud @var{number} [ modem and direct only ] -@findex baud in port file - -The speed this port runs at. If a system specifies a speed but no port -name, then all ports which match the speed will be tried in order. If -the speed is not specified here and is not specified by the system, the -natural speed of the port will be used by default. - -@itemx speed-range @var{number} @var{number} [ modem only ] -@findex speed-range -@item baud-range @var{number} @var{number} [ modem only ] -@findex baud-range - -Specify a range of speeds this port can run at. The first number is the -minimum speed, the second number is the maximum speed. These numbers -will be used when matching a system which specifies a desired speed. -The simple @code{speed} (or @code{baud}) command is still used to -determine the speed to run at if the system does not specify a speed. -For example, the command @samp{speed-range 300 19200} means that the -port will match any system which uses a speed from 300 to 19200 baud -(and will use the speed specified by the system); this could be combined -with @samp{speed 2400}, which means that when this port is used with a -system that does not specify a speed, the port will be used at 2400 -baud. - -@item carrier @var{boolean} [ modem and direct only ] -@findex carrier in port file - -The argument indicates whether the port supports carrier. - -If a modem port does not support carrier, the carrier detect signal will -never be required on this port, regardless of what the modem chat script -indicates. The default for a modem port is true. - -If a direct port supports carrier, the port will be set to expect -carrier whenever it is used. The default for a direct port is false. - -@item hardflow @var{boolean} [ modem and direct only ] -@findex hardflow - -The argument indicates whether the port supports hardware flow control. -If it does not, hardware flow control will not be turned on for this -port. The default is true. Hardware flow control is only supported on -some systems. - -@item dial-device @var{string} [ modem only ] -@findex dial-device - -Dialing instructions should be output to the named device, rather than -to the normal port device. The default is to output to the normal port -device. - -@item dialer @var{string} [ modem only ] -@findex dialer in port file - -Name a dialer to use. The information is looked up in the dial file. -There is no default. Some sort of dialer information must be specified -to call out on a modem. - -@item dialer @var{string} @dots{} [ modem only ] - -If more than one string follows the @code{dialer} command, the strings -are treated as a command that might appear in the dial file (@pxref{dial -File}). If a dialer is named (by using the first form of this command, -described just above), these commands are ignored. They may be used to -specify dialer information directly in simple situations without needing -to go to a separate file. There is no default. Some sort of dialer -information must be specified to call out on a modem. - -@item dialer-sequence @var{strings} [ modem or tcp or tli only ] -@findex dialer-sequence - -Name a sequence of dialers and tokens (phone numbers) to use. The first -argument names a dialer, and the second argument names a token. The -third argument names another dialer, and so on. If there are an odd -number of arguments, the phone number specified with a @code{phone} -command in the system file is used as the final token. The token is -what is used for @kbd{\D} or @kbd{\T} in the dialer chat script. If the -token in this string is @kbd{\D}, the system phone number will be used; -if it is @kbd{\T}, the system phone number will be used after undergoing -dialcodes translation. A missing final token is taken as @kbd{\D}. - -This command currently does not work if @code{dial-device} is specified; -to handle this correctly will require a more systematic notion of chat -scripts. Moreover, the @code{complete} and @code{abort} chat scripts, -the protocol parameters, and the @code{carrier} and @code{dtr-toggle} -commands are ignored for all but the first dialer. - -This command basically lets you specify a sequence of chat scripts to -use. For example, the first dialer might get you to a local network and -the second dialer might describe how to select a machine from the local -network. This lets you break your dialing sequence into simple modules, -and may make it easier to share dialer entries between machines. - -This command is to only way to use a chat script with a TCP port. This -can be useful when using a modem which is accessed via TCP. - -When this command is used with a TLI port, then if the first dialer is -@samp{TLI} or @samp{TLIS} the first token is used as the address to -connect to. If the first dialer is something else, or if there is no -token, the address given by the @code{address} command is used -(@pxref{Placing the Call}). Escape sequences in the address are -expanded as they are for chat script expect strings (@pxref{Chat -Scripts}). The different between @samp{TLI} and @samp{TLIS} is that the -latter implies the command @samp{stream true}. These contortions are -all for HDB compatibility. Any subsequent dialers are treated as they -are for a TCP port. - -@item lockname @var{string} [ modem and direct only ] -@findex lockname - -Give the name to use when locking this port. On Unix, this is the name -of the file that will be created in the lock directory. It is used as -is, so on Unix it should generally start with @samp{LCK..}. For -example, if a single port were named both @file{/dev/ttycu0} and -@file{/dev/tty0} (perhaps with different characteristics keyed on the -minor device number), then the command @code{lockname LCK..ttycu0} could -be used to force the latter to use the same lock file name as the -former. - -@item service @var{string} [ tcp only ] -@findex service - -Name the TCP port number to use. This may be a number. If not, it will -be looked up in @file{/etc/services}. If this is not specified, the -string @samp{uucp} is looked up in @file{/etc/services}. If it is not -found, port number 540 (the standard UUCP-over-TCP port number) will be -used. - -@item family @var{string} [ tcp only ] -@findex family - -Name the protocol family to use. Available value is @samp{inet} for -IPv4 only, @samp{inet6} for IPv6 only, or @samp{inet46} for both IPv4 -and IPv6. The default is @samp{inet46}. - -@item push @var{strings} [ tli only ] -@findex push - -Give a list of modules to push on to the TLI stream. - -@item stream @var{boolean} [ tli only ] -@findex stream - -If this is true, and the @code{push} command was not used, the -@samp{tirdwr} module is pushed on to the TLI stream. - -@item server-address @var{string} [ tli only ] -@findex server-address - -Give the address to use when running as a TLI server. Escape sequences -in the address are expanded as they are for chat script expect strings -(@pxref{Chat Scripts}). - -The string is passed directly to the TLI @code{t_bind} function. The -value needed may depend upon your particular TLI implementation. Check -the manual pages, and, if necessary, try writing some sample programs. - -For AT&T 3B2 System V Release 3 using the Wollongong TCP/IP stack, which -is probably typical, the format of TLI string is @samp{SSPPIIII}, where -@samp{SS} is the service number (for TCP, this is 2), @samp{PP} is the -TCP port number, and @samp{IIII} is the Internet address. For example, -to accept a connection from on port 540 from any interface, use -@samp{server-address \x00\x02\x02\x1c\x00\x00\x00\x00}. To only accept -connections from a particular interface, replace the last four digits -with the network address of the interface. (Thanks to Paul Pryor for -the information in this paragraph). - -@item command @var{strings} [ pipe only ] -@findex command - -Give the command, with arguments, to run when using a pipe port type. -When a port of this type is used, the command is executed and -@code{uucico} communicates with it over a pipe. This permits -@code{uucico} or @code{cu} to communicate with another system which can -only be reached through some unusual means. A sample use might be -@samp{command /bin/rlogin -E -8 -l @var{login} @var{system}}. The -command is run with the full privileges of UUCP; it is responsible for -maintaining security. - -@end table - -@node dial File, UUCP Over TCP, port File, Configuration Files -@section The Dialer Configuration File -@cindex dial file -@cindex dialer configuration file -@cindex configuration file (dial) - -The dialer configuration files define dialers. By default there is a -single dialer file, named @file{dial} in the directory -@var{newconfigdir}. This may be overridden by the @code{dialfile} -command in the main configuration file; see @ref{Configuration File -Names}. - -Any commands in the file before the first @code{dialer} command specify -defaults for all the dialers in the file. All commands after a -@code{dialer} command up to the next @code{dialer} command are -associated with the named dialer. - -@table @code - -@item dialer @var{string} -@findex dialer in dial file - -Introduces and names a dialer. - -@item chat @var{strings} -@findex chat in dial file -@item chat-timeout @var{number} -@findex chat-timeout in dial file -@item chat-fail @var{string} -@findex chat-fail in dial file -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit in dial file -@item chat-program @var{strings} -@findex chat-program in dial file - -Specify a chat script to be used to dial the phone. This chat script is -used before the login chat script in the @file{sys} file, if any -(@pxref{Logging In}). For full details on chat scripts, see @ref{Chat -Scripts}. - -The @code{uucico} daemon will sleep for one second between attempts to -dial out on a modem. If your modem requires a longer wait period, you -must start your chat script with delays (@samp{\d} in a send string). - -The chat script will be read from and sent to the port specified by the -@code{dial-device} command for the port, if there is one. - -The following escape addition escape sequences may appear in send -strings: - -@table @kbd -@item \D -send phone number without dialcode translation -@item \T -send phone number with dialcode translation -@item \M -do not require carrier -@item \m -require carrier (fail if not present) -@end table - -See the description of the dialcodes file (@pxref{Configuration File -Names}) for a description of dialcode translation. If the port does not -support carrier, as set by the @code{carrier} command in the port file, -@kbd{\M} and @kbd{\m} are ignored. If both the port and the dialer -support carrier, as set by the @code{carrier} command in the port file -and the @code{carrier} command in the dialer file, then every chat -script implicitly begins with @kbd{\M} and ends with @kbd{\m}. There is -no default chat script for dialers. - -The following additional escape sequences may be used in -@code{chat-program}: - -@table @kbd -@item \D -phone number without dialcode translation -@item \T -phone number with dialcode translation -@end table - -If the program changes the port in any way (e.g., sets parity) the -changes will be preserved during protocol negotiation, but once the -protocol is selected it will change the port settings. - -@item dialtone @var{string} -@findex dialtone - -A string to output when dialing the phone number which causes the modem -to wait for a secondary dial tone. This is used to translate the -@kbd{=} character in a phone number. The default is a comma. - -@item pause @var{string} -@findex pause - -A string to output when dialing the phone number which causes the modem -to wait for 1 second. This is used to translate the @kbd{-} character -in a phone number. The default is a comma. - -@item carrier @var{boolean} -@findex carrier in dial file - -An argument of true means that the dialer supports the modem carrier -signal. After the phone number is dialed, @code{uucico} will require -that carrier be on. One some systems, it will be able to wait for it. -If the argument is false, carrier will not be required. The default is -true. - -@item carrier-wait @var{number} -@findex carrier-wait - -If the port is supposed to wait for carrier, this may be used to -indicate how many seconds to wait. The default is 60 seconds. Only -some systems support waiting for carrier. - -@item dtr-toggle @var{boolean} @var{boolean} -@findex dtr-toggle - -If the first argument is true, then DTR is toggled before using -the modem. This is only supported on some systems and some ports. The -second @var{boolean} need not be present; if it is, and it is -true, the program will sleep for 1 second after toggling DTR. -The default is to not toggle DTR. - -@need 500 -@item complete-chat @var{strings} -@findex complete-chat -@item complete-chat-timeout @var{number} -@findex complete-chat-timeout -@item complete-chat-fail @var{string} -@findex complete-chat-fail -@item complete-chat-seven-bit @var{boolean} -@findex complete-chat-seven-bit -@item complete-chat-program @var{strings} -@findex complete-chat-program - -These commands define a chat script (@pxref{Chat Scripts}) which is run -when a call is finished normally. This allows the modem to be reset. -There is no default. No additional escape sequences may be used. - -@item complete @var{string} -@findex complete - -This is a simple use of @code{complete-chat}. It is equivalent to -@code{complete-chat "" @var{string}}; this has the effect of sending -@var{string} to the modem when a call finishes normally. - -@item abort-chat @var{strings} -@findex abort-chat -@item abort-chat-timeout @var{number} -@findex abort-chat-timeout -@item abort-chat-fail @var{string} -@findex abort-chat-fail -@item abort-chat-seven-bit @var{boolean} -@findex abort-chat-seven-bit -@item abort-chat-program @var{strings} -@findex abort-chat-program - -These commands define a chat script (@pxref{Chat Scripts}) to be run -when a call is aborted. They may be used to interrupt and reset the -modem. There is no default. No additional escape sequences may be -used. - -@item abort @var{string} -@findex abort - -This is a simple use of @code{abort-chat}. It is equivalent to -@code{abort-chat "" @var{string}}; this has the effect of sending -@var{string} to the modem when a call is aborted. - -@item protocol-parameter @var{character} @var{strings} -@findex protocol-parameter in dial file - -Set protocol parameters, just like the @code{protocol-parameter} command -in the system configuration file or the port configuration file; see -@ref{Protocol Selection}. These parameters take precedence, then those -for the port, then those for the system. - -@item seven-bit @var{boolean} -@findex seven-bit in dial file - -This is only used during protocol negotiation; if it is true, it -forces selection of a protocol which works across a seven-bit link. It -does not prevent eight bit characters from being transmitted. The -default is false. It would be more common to specify this for a -port than for a dialer. - -@item reliable @var{boolean} -@findex reliable in dial file - -This is only used during protocol negotiation; if it is false, it -forces selection of a protocol which works across an unreliable -communication link. The default is true. - -@item half-duplex @var{boolean} [ any type ] -@findex half-duplex in dial file - -If the argument is true, it means that the dialer only supports -half-duplex connections. This only affects bidirectional protocols, and -causes them to not do bidirectional transfers. - -@end table - -@node UUCP Over TCP, Security, dial File, Configuration Files -@section UUCP Over TCP - -If your system has a Berkeley style socket library, or a System V style -TLI interface library, you can compile the code to permit making -connections over TCP. Specifying that a system should be reached via -TCP is easy, but nonobvious. - -@menu -* TCP Client:: Connecting to Another System Over TCP -* TCP Server:: Running a TCP Server -@end menu - -@node TCP Client, TCP Server, UUCP Over TCP, UUCP Over TCP -@subsection Connecting to Another System Over TCP - -If you are using the new style configuration files (@pxref{Configuration -Files}), add the line @samp{port type tcp} to the entry in the -@file{sys} file. By default UUCP will get the port number by looking up -@samp{uucp} in @file{/etc/services}; if the @samp{uucp} service is not -defined, port 540 will be used. You can set the port number to use with -the command @samp{port service @var{xxx}}, where @var{xxx} can be either -a number or a name to look up in @file{/etc/services}. By default UUCP -will determine the protocol family by querying DNS; if the AAAA record -is found, IPv6 will be used, and if not found, IPv4 will be used. You -can set the protocol family to use with the command @samp{port family -@var{xxx}}, where @var{xxx} can be @samp{inet} for IPv4 only, -@samp{inet6} for IPv6 only or @samp{inet46} for both. You can specify -the address of the remote host with @samp{address @var{a.b.c}}; if you -don't give an address, the remote system name will be used. You should -give an explicit chat script for the system when you use TCP; the -default chat script begins with a carriage return, which will not work -with some UUCP TCP servers. - -If you are using V2 configuration files, add a line like this to -@file{L.sys}: -@example -@var{sys} Any TCP uucp @var{host}.@var{domain} chat-script -@end example -This will make an entry for system @var{sys}, to be called at any time, -over TCP, using port number @samp{uucp} (as found in -@file{/etc/services}; this may be specified as a number), using remote -host @file{@var{host}.@var{domain}}, with some chat script. - -If you are using HDB configuration files, add a line like this to -Systems: -@example -@var{sys} Any TCP - @var{host}.@var{domain} chat-script -@end example -and a line like this to @file{Devices}: -@example -TCP uucp - - -@end example -You only need one line in @file{Devices} regardless of how many systems -you contact over TCP. This will make an entry for system @var{sys}, to -be called at any time, over TCP, using port number @samp{uucp} (as found -in @file{/etc/services}; this may be specified as a number), using -remote host @file{@var{host}.@var{domain}}, with some chat script. - -@samp{port family @var{xxx}} command is not supported by V2 -configuration files or HDB configuration files. So, with these -configuration files, IPv6 is disabled for compatibility reason. - -@node TCP Server, , TCP Client, UUCP Over TCP -@subsection Running a TCP Server - -The @code{uucico} daemon may be run as a TCP server. To use the default -port number, which is a reserved port, @code{uucico} must be invoked by -the superuser (or it must be set user ID to the superuser, but I don't -recommend doing that). - -You must define a port, either using the port file (@pxref{port File}), -if you are using the new configuration method, or with an entry in -@file{Devices} if you are using HDB; there is no way to define a port -using V2. If you are using HDB the port must be named @samp{TCP}; a -line as shown above will suffice. You can then start @code{uucico} as -@samp{uucico -p TCP} (after the @samp{-p}, name the port; in HDB it must -be @samp{TCP}). This will wait for incoming connections, and fork off a -child for each one. Each connection will be prompted with @samp{login:} -and @samp{Password:}; the results will be checked against the UUCP (not -the system) password file (@pxref{Configuration File Names}). - -By default UUCP will listen on both IPv4 and IPv6. You can set the -protocol family to listen with the command @samp{port family @var{xxx}}, -where @var{xxx} can be @samp{inet} for IPv4 only, @samp{inet6} for IPv6 -only or @samp{inet46} for both IPv4 and IPv6. - -@samp{port family @var{xxx}} command is not supported by V2 -configuration files or HDB configuration files. So, with these -configuration files, IPv6 is disabled for compatibility reason. - -Another way to run a UUCP TCP server is to use the BSD @code{uucpd} -program. - -Yet another way to run a UUCP TCP server is to use @code{inetd}. -Arrange for @code{inetd} to start up @code{uucico} with the @samp{-l} -switch. This will cause @code{uucico} to prompt with @samp{login:} and -@samp{Password:} and check the results against the UUCP (not the system) -password file (you may want to also use the @samp{-D} switch to avoid a -fork, which in this case is unnecessary). - -@node Security, , UUCP Over TCP, Configuration Files -@section Security - -This discussion of UUCP security applies only to Unix. It is a bit -cursory; suggestions for improvement are solicited. - -UUCP is traditionally not very secure. Taylor UUCP addresses some -security issues, but is still far from being a secure system. - -If security is very important to you, then you should not permit any -external access to your computer, including UUCP. Any opening to the -outside world is a potential security risk. - -When local users use UUCP to transfer files, Taylor UUCP can do little -to secure them from each other. You can allow somewhat increased -security by putting the owner of the UUCP programs (normally -@code{uucp}) into a separate group; the use of this is explained in the -following paragraphs, which refer to this separate group as -@code{uucp-group}. - -When the @code{uucp} program is invoked to copy a file to a remote -system, it will, by default, copy the file into the UUCP spool -directory. When the @code{uux} program is used, the @samp{-C} switch -must be used to copy the file into the UUCP spool directory. In any -case, once the file has been copied into the spool directory, other -local users will not be able to access it. - -When a file is requested from a remote system, UUCP will only permit it -to be placed in a directory which is writable by the requesting user. -The directory must also be writable by UUCP. A local user can create a -directory with a group of @code{uucp-group} and set the mode to permit -group write access. This will allow the file be requested without -permitting it to be viewed by any other user. - -There is no provision for security for @code{uucp} requests (as opposed -to @code{uux} requests) made by a user on a remote system. A file sent -over by a remote request may only be placed in a directory which is -world writable, and the file will be world readable and writable. This -will permit any local user to destroy or replace the contents of the -file. A file requested by a remote system must be world readable, and -the directory it is in must be world readable. Any local user will be -able to examine, although not necessarily modify, the file before it is -sent. - -There are some security holes and race conditions that apply to the -above discussion which I will not elaborate on. They are not hidden -from anybody who reads the source code, but they are somewhat technical -and difficult (though scarcely impossible) to exploit. Suffice it to -say that even under the best of conditions UUCP is not completely -secure. - -For many sites, security from remote sites is a more important -consideration. Fortunately, Taylor UUCP does provide some support in -this area. - -The greatest security is provided by always dialing out to the other -site. This prevents anybody from pretending to be the other site. Of -course, only one side of the connection can do this. - -If remote dialins must be permitted, then it is best if the dialin line -is used only for UUCP. If this is the case, then you should create a -call-in password file (@pxref{Configuration File Names}) and let -@code{uucico} do its own login prompting. For example, to let remote -sites log in on a port named @samp{entry} in the port file (@pxref{port -File}), you might invoke @samp{uucico -e -p entry}. This would cause -@code{uucico} to enter an endless loop of login prompts and daemon -executions. The advantage of this approach is that even if remote users -break into the system by guessing or learning the password, they will -only be able to do whatever @code{uucico} permits them to do. They will -not be able to start a shell on your system. - -If remote users can dial in and log on to your system, then you have a -security hazard more serious than that posed by UUCP. But then, you -probably knew that already. - -Once your system has connected with the remote UUCP, there is a fair -amount of control you can exercise. You can use the @code{remote-send} -and @code{remote-receive} commands to control the directories the remote -UUCP can access. You can use the @code{request} command to prevent the -remote UUCP from making any requests of your system at all; however, if -you do this it will not even be able to send you mail or news. If you -do permit remote requests, you should be careful to restrict what -commands may be executed at the remote system's request. The default is -@code{rmail} and @code{rnews}, which will suffice for most systems. - -If different remote systems call in and they must be granted different -privileges (perhaps some systems are within the same organization and -some are not) then the @code{called-login} command should be used for -each system to require that they use different login names. Otherwise, -it would be simple for a remote system to use the @code{myname} command -and pretend to be a different system. The @code{sequence} command can -be used to detect when one system pretended to be another, but, since -the sequence numbers must be reset manually after a failed handshake, -this can sometimes be more trouble than it's worth. - -@c START-OF-FAQ -@ignore -This chapter is used to generate the comp.mail.uucp UUCP Internals FAQ, -as well as being part of the Taylor UUCP manual. Text that should -appear only in the manual is bracketed by ifclear faq. Text that should -appear only in the FAQ is bracketed by ifset faq. -@end ignore - -@ifset faq -@paragraphindent asis -@format -Subject: UUCP Internals Frequently Asked Questions -Newsgroups: comp.mail.uucp,comp.answers,news.answers -Followup-To: comp.mail.uucp -Reply-To: ian@@airs.com (Ian Lance Taylor) -Keywords: UUCP, protocol, FAQ -Approved: news-answers-request@@MIT.Edu - -Archive-name: uucp-internals -Version: $Revision: 1.2 $ -Last-modified: $Date: 1995/08/19 21:24:55 $ -@end format -@end ifset - -@node Protocols, Hacking, Configuration Files, Top -@chapter UUCP Protocol Internals - -@ifclear faq -This chapter describes how the various UUCP protocols work, and -discusses some other internal UUCP issues. - -This chapter is quite technical. You do not need to understand it, or -even read it, in order to use Taylor UUCP. It is intended for people -who are interested in how the UUCP code works. - -The information in this chapter is posted monthly to the Usenet -newsgroups @samp{comp.mail.uucp}, @samp{news.answers}, and -@samp{comp.answers}. The posting is available from any -@samp{news.answers} archive site, such as @samp{rtfm.mit.edu}. If you -plan to use this information to write a UUCP program, please make sure -you get the most recent version of the posting, in case there have been -any corrections. -@end ifclear - -@ifset faq -Recent changes: -@itemize @bullet -@item Conversion to Texinfo format. -@item Description of the @samp{E} command. -@item Description of optional number following @samp{-N} and @samp{ROKN} -in UUCP protocol startup. -@item Detailed description of the @samp{y} protocol. -@item Mention the name uuxqt uses for lock files. -@end itemize - -This article was written by Ian Lance Taylor @samp{<ian@@airs.com>} and -I may even update it periodically. Please send me mail about -suggestions or inaccuracies. - -This article describes how the various UUCP protocols work, and -discusses some other internal UUCP issues. It does not describe how to -configure UUCP, nor how to solve UUCP connection problems, nor how to -deal with UUCP mail. I do not know of any FAQ postings on these topics. -There are some documents on the net describing UUCP configuration, but I -can not keep an up to date list here; try using archie. - -If you haven't read the @samp{news.announce.newusers} articles, read -them. - -This article is in digest format. Some newsreaders will be able to -break it apart into separate articles. Please don't ask me how to do -this, though. - -This article covers the following topics. If questions about one of -these topics is posted to @samp{comp.mail.uucp}, please send mail to the -poster referring her or him to this FAQ. There is no reason to post a -followup, as most of us know the answer already. -@end ifset - -@menu -* UUCP Protocol Sources:: Sources for UUCP Protocol Information -* UUCP Grades:: UUCP Grades -* UUCP Lock Files:: UUCP Lock Files -* Execution File Format:: Execution File Format -* UUCP Protocol:: UUCP Protocol -* g Protocol:: g protocol -* f Protocol:: f protocol -* t Protocol:: t protocol -* e Protocol:: e protocol -* Big G Protocol:: G protocol -* i Protocol:: i protocol -* j Protocol:: j protocol -* x Protocol:: x protocol -* y Protocol:: y protocol -* d Protocol:: d protocol -* h Protocol:: h protocol -* v Protocol:: v protocol -@end menu - -@ifset faq -@format -UUCP Protocol Sources -Alarm in Debugging Output -UUCP Grades -UUCP Lock Files -Execution File Format -UUCP Protocol -UUCP @samp{g} Protocol -UUCP @samp{f} Protocol -UUCP @samp{t} Protocol -UUCP @samp{e} Protocol -UUCP @samp{G} Protocol -UUCP @samp{i} Protocol -UUCP @samp{j} Protocol -UUCP @samp{x} Protocol -UUCP @samp{y} Protocol -UUCP @samp{d} Protocol -UUCP @samp{h} Protocol -UUCP @samp{v} Protocol -Thanks - ----------------------------------------------------------------------- - -From: UUCP Protocol Sources -Subject: UUCP Protocol Sources - -@end format -@end ifset - -@node UUCP Protocol Sources, UUCP Grades, Protocols, Protocols -@section UUCP Protocol Sources - -@quotation -``Unix-to-Unix Copy Program,'' said PDP-1. ``You will never find a more -wretched hive of bugs and flamers. We must be cautious.'' -@flushright ----DECWars -@end flushright -@end quotation - -I took a lot of the information from Jamie E. Hanrahan's paper in the -Fall 1990 DECUS Symposium, and from @cite{Managing UUCP and Usenet} by Tim -O'Reilly and Grace Todino (with contributions by several other -people). The latter includes most of the former, and is published by -@example -O'Reilly & Associates, Inc. -103 Morris Street, Suite A -Sebastopol, CA 95472 -@end example -It is currently in its tenth edition. The ISBN number is -@samp{0-937175-93-5}. - -Some information is originally due to a Usenet article by Chuck Wegrzyn. -The information on execution files comes partially from Peter Honeyman. -The information on the @samp{g} protocol comes partially from a paper by -G.L.@: Chesson of Bell Laboratories, partially from Jamie E. Hanrahan's -paper, and partially from source code by John Gilmore. The information -on the @samp{f} protocol comes from the source code by Piet Berteema. -The information on the @samp{t} protocol comes from the source code by -Rick Adams. The information on the @samp{e} protocol comes from a -Usenet article by Matthias Urlichs. The information on the @samp{d} -protocol comes from Jonathan Clark, who also supplied information about -QFT. The UUPlus information comes straight from Christopher J. Ambler, -of UUPlus Development; it applies to version 1.52 and up of the -shareware version of UUPlus Utilities, called FSUUCP 1.52, but referred -to in this article as UUPlus. - -Although there are few books about UUCP, there are many about networks -and protocols in general. I recommend two non-technical books which -describe the sorts of things that are available on the network: -@cite{The Whole Internet}, by Ed Krol, and @cite{Zen and the Art of the -Internet}, by Brendan P. Kehoe. Good technical discussions of -networking issues can be found in @cite{Internetworking with TCP/IP}, by -Douglas E. Comer and David L. Stevens and in @cite{Design and Validation -of Computer Protocols} by Gerard J. Holzmann. - -@ifset faq -@c Note that this section is only in the FAQ, since it does not fit in -@c here in the manual. -@format ------------------------------- - -From: Alarm in Debugging Output -Subject: Alarm in Debugging Output - -Alarm in Debugging Output -========================= -@end format - -The debugging output of many versions of UUCP will include messages like -@samp{alarm 1} or @samp{pkcget: alarm 1}. Taylor UUCP does not use the -word @samp{alarm}, but will instead log messages like @samp{Timed out -waiting for packet}. - -These types of messages mean that the UUCP package has timed out while -waiting for some sort of response from the remote system. If it happens -consistently when trying to transfer a particular file, then the most -likely problem is that one of the modems will not transmit the XON or -XOFF characters. Several UUCP protocols require an eight bit clean -connection, which means that the modems must treat XON or XOFF as normal -data characters, not as flow control signals. This should always be -checked first. - -Other possible problems are that the modems have simply dropped their -connection, or perhaps on one side or the other the serial buffer is -overflowing and dropping characters. Another possibility is that the -UUCP packages disagree about some aspect of the UUCP protocol, which is -uncommon but does happen occasionally. - -Using the information in the following sections, you should be able to -figure out what type of data your UUCP was expecting to receive. This -may give some indication as to exactly what the problem is. It is -difficult to be more specific, since there are many possiblities. - -@format ------------------------------- - -From: UUCP Grades -Subject: UUCP Grades -@end format -@end ifset - -@node UUCP Grades, UUCP Lock Files, UUCP Protocol Sources, Protocols -@section UUCP Grades -@cindex grades implementation - -Modern UUCP packages support a priority grade for each command. The -grades generally range from @kbd{A} (the highest) to @kbd{Z} followed by -@kbd{a} to @kbd{z}. Some UUCP packages (including Taylor UUCP) also -support @kbd{0} to @kbd{9} before @kbd{A}. Some UUCP packages may -permit any ASCII character as a grade. - -On Unix, these grades are encoded in the name of the command file -created by @code{uucp} or @code{uux}. A command file name generally has -the form @file{C.nnnngssss} where @samp{nnnn} is the remote system name -for which the command is queued, @samp{g} is a single character grade, -and @samp{ssss} is a four character sequence number. For example, a -command file created for the system @samp{airs} at grade @samp{Z} might -be named @file{C.airsZ2551}. - -The remote system name will be truncated to seven characters, to -ensure that the command file name will fit in the 14 character file -name limit of the traditional Unix file system. UUCP packages which -have no other means of distinguishing which command files are intended -for which systems thus require all systems they connect to to have -names that are unique in the first seven characters. Some UUCP -packages use a variant of this format which truncates the system name -to six characters. HDB and Taylor UUCP use a different spool -directory format, which allows up to fourteen characters to be used -for each system name. - -The sequence number in the command file name may be a decimal integer, -or it may be a hexadecimal integer, or it may contain any alphanumeric -character. Different UUCP packages are different. -@ifclear faq -Taylor UUCP uses any alphanumeric character. -@end ifclear - -UUPlus Utilities (as FSUUCP, a shareware DOS based UUCP and news -package) uses up to 8 characters for file names in the spool (this is a -DOS file system limitation; actually, with the extension, 11 characters -are available, but FSUUCP reserves that for future use). FSUUCP -defaults mail to grade @samp{D}, and news to grade @samp{N}, except that -when the grade of incoming mail can be determined, that grade is -preserved if the mail is forwarded to another system. The default grades -may be changed by editing the @file{LIB/MAILRC} file for mail, or the -@file{UUPLUS.CFG} file for news. - -UUPC/extended for DOS, OS/2 and Windows NT handles mail at grade -@samp{C}, news at grade @samp{d}, and file transfers at grade @samp{n}. -The UUPC/extended @code{UUCP} and @code{RMAIL} commands accept grades to -override the default, the others do not. - -I do not know how command grades are handled in other non-Unix UUCP -packages. - -Modern UUCP packages allow you to restrict file transfer by grade -depending on the time of day. Typically this is done with a line in -the @file{Systems} (or @file{L.sys}) file like this: -@example - airs Any/Z,Any2305-0855 ... -@end example -This allows grades @samp{Z} and above to be transferred at any time. -Lower grades may only be transferred at night. I believe that this -grade restriction applies to local commands as well as to remote -commands, but I am not sure. It may only apply if the UUCP package -places the call, not if it is called by the remote system. - -Taylor UUCP can use the @code{timegrade} and @code{call-timegrade} -commands to achieve the same effect. -@ifclear faq -@xref{When to Call}. -@end ifclear -It supports the above format when reading @file{Systems} or -@file{L.sys}. - -UUPC/extended provides the @code{symmetricgrades} option to announce the -current grade in effect when calling the remote system. - -UUPlus allows specification of the highest grade accepted on a per-call -basis with the @samp{-g} option in @code{UUCICO}. - -This sort of grade restriction is most useful if you know what grades -are being used at the remote site. The default grades used depend on -the UUCP package. Generally @code{uucp} and @code{uux} have different -defaults. A particular grade can be specified with the @samp{-g} option -to @code{uucp} or @code{uux}. For example, to request execution of -@samp{rnews} on @samp{airs} with grade @samp{d}, you might use something -like -@example - uux -gd - airs!rnews < article -@end example - -Uunet queues up mail at grade @samp{C}, but increases the grade based on -the size. News is queued at grade @samp{d}, and file transfers at grade -@samp{n}. The example above would allow mail (below some large size) to -be received at any time, but would only permit news to be transferred at -night. - -@ifset faq -@format ------------------------------- - -From: UUCP Lock Files -Subject: UUCP Lock Files -@end format -@end ifset - -@node UUCP Lock Files, Execution File Format, UUCP Grades, Protocols -@section UUCP Lock Files -@cindex lock files - -This discussion applies only to Unix. I have no idea how UUCP locks -ports on other systems. - -UUCP creates files to lock serial ports and systems. On most, if not -all, systems, these same lock files are also used by @code{cu} to -coordinate access to serial ports. On some systems @code{getty} also -uses these lock files, often under the name @code{uugetty}. - -The lock file normally contains the process ID of the locking process. -This makes it easy to determine whether a lock is still valid. The -algorithm is to create a temporary file and then link it to the name -that must be locked. If the link fails because a file with that name -already exists, the existing file is read to get the process ID. If the -process still exists, the lock attempt fails. Otherwise the lock file -is deleted and the locking algorithm is retried. - -Older UUCP packages put the lock files in the main UUCP spool directory, -@file{/usr/spool/uucp}. HDB UUCP generally puts the lock files in a -directory of their own, usually @file{/usr/spool/locks} or -@file{/etc/locks}. - -The original UUCP lock file format encodes the process ID as a four byte -binary number. The order of the bytes is host-dependent. HDB UUCP -stores the process ID as a ten byte ASCII decimal number, with a -trailing newline. For example, if process 1570 holds a lock file, it -would contain the eleven characters space, space, space, space, space, -space, one, five, seven, zero, newline. Some versions of UUCP add a -second line indicating which program created the lock (@code{uucp}, -@code{cu}, or @code{getty/uugetty}). I have also seen a third type of -UUCP lock file which does not contain the process ID at all. - -The name of the lock file is traditionally @file{LCK..} followed by the -base name of the device. For example, to lock @file{/dev/ttyd0} the -file @file{LCK..ttyd0} would be created. On SCO Unix, the lock file -name is always forced to lower case even if the device name has upper -case letters. - -System V Release 4 UUCP names the lock file using the major and minor -device numbers rather than the device name. The file is named -@file{LK.@var{XXX}.@var{YYY}.@var{ZZZ}}, where @var{XXX}, @var{YYY} and -@var{ZZZ} are all three digit decimal numbers. @var{XXX} is the major -device number of the device holding the directory holding the device -file (e.g., @file{/dev}). @var{YYY} is the major device number of the -device file itself. @var{ZZZ} is the minor device number of the device -file itself. If @code{s} holds the result of passing the device to the -stat system call (e.g., @code{stat ("/dev/ttyd0", &s)}), the following -line of C code will print out the corresponding lock file name: -@example - printf ("LK.%03d.%03d.%03d", major (s.st_dev), - major (s.st_rdev), minor (s.st_rdev)); -@end example -The advantage of this system is that even if there are several links to -the same device, they will all use the same lock file name. - -When two or more instances of @code{uuxqt} are executing, some sort of -locking is needed to ensure that a single execution job is only started -once. I don't know how most UUCP packages deal with this. Taylor UUCP -uses a lock file for each execution job. The name of the lock file is -the same as the name of the @file{X.*} file, except that the initial -@samp{X} is changed to an @samp{L}. The lock file holds the process ID -as described above. - -@ifset faq -@format ------------------------------- - -From: Execution File Format -Subject: Execution File Format -@end format -@end ifset - -@node Execution File Format, UUCP Protocol, UUCP Lock Files, Protocols -@section Execution File Format -@cindex execution file format -@cindex @file{X.*} file format - -UUCP @file{X.*} files control program execution. They are created by -@code{uux}. They are transferred between systems just like any other -file. The @code{uuxqt} daemon reads them to figure out how to execute -the job requested by @code{uux}. - -An @file{X.*} file is simply a text file. The first character of each -line is a command, and the remainder of the line supplies arguments. -The following commands are defined: - -@table @samp -@item C command -This gives the command to execute, including the program and all -arguments. For example, @samp{rmail ian@@airs.com}. - -@item U user system -This names the user who requested the command, and the system from which -the request came. - -@item I standard-input -This names the file from which standard input is taken. If no standard -input file is given, the standard input will probably be attached to -@file{/dev/null}. If the standard input file is not from the system on -which the execution is to occur, it will also appear in an @samp{F} -command. - -@item O standard-output [system] -This names the standard output file. The optional second argument names -the system to which the file should be sent. If there is no second -argument, the file should be created on the executing system. - -@item F required-file [filename-to-use] -The @samp{F} command can appear multiple times. Each @samp{F} command -names a file which must exist before the execution can proceed. This -will usually be a file which is transferred from the system on which -@code{uux} was executed, but it can also be a file from the local system -or some other system. If the file is not from the local system, then -the command will usually name a file in the spool directory. If the -optional second argument appears, then the file should be copied to the -execution directory under that name. This is necessary for any file -other than the standard input file. If the standard input file is not -from the local system, it will appear in both an @samp{F} command and an -@samp{I} command. - -@item R requestor-address -This is the address to which mail about the job should be sent. It is -relative to the system named in the @samp{U} command. If the @samp{R} -command does not appear, then mail is sent to the user named in the -@samp{U} command. - -@item Z -This command takes no arguments. It means that a mail message should be -sent if the command failed. This is the default behaviour for most -modern UUCP packages, and for them the @samp{Z} command does not -actually do anything. - -@item N -This command takes no arguments. It means that no mail message should -be sent, even if the command failed. - -@item n -This command takes no arguments. It means that a mail message should be -sent if the command succeeded. Normally a message is sent only if the -command failed. - -@item B -This command takes no arguments. It means that the standard input -should be returned with any error message. This can be useful in cases -where the input would otherwise be lost. - -@item e -This command takes no arguments. It means that the command should be -processed with @file{/bin/sh}. For some packages this is the default -anyhow. Most packages will refuse to execute complex commands or -commands containing wildcards, because of the security holes this opens. - -@item E -This command takes no arguments. It means that the command should be -processed with the @code{execve} system call. For some packages this is -the default anyhow. - -@item M status-file -This command means that instead of mailing a message, the message should -be copied to the named file on the system named by the @samp{U} command. - -@item # comment -This command is ignored, as is any other unrecognized command. -@end table - -Here is an example. Given the following command executed on system -test1 -@example - uux - test2!cat - test2!~ian/bar !qux '>~/gorp' -@end example -(this is only an example, as most UUCP systems will not permit the cat -command to be executed) Taylor UUCP will produce something like the -following @file{X.} file: -@example -U ian test1 -F D.test1N003r qux -O /usr/spool/uucppublic test1 -F D.test1N003s -I D.test1N003s -C cat - ~ian/bar qux -@end example -The standard input will be read into a file and then transferred to the -file @file{D.test1N003s} on system @samp{test2}. The file @file{qux} -will be transferred to @file{D.test1N003r} on system @samp{test2}. When -the command is executed, the latter file will be copied to the execution -directory under the name @samp{qux}. Note that since the file -@file{~ian/bar} is already on the execution system, no action need be -taken for it. The standard output will be collected in a file, then -copied to the directory @file{/usr/spool/uucppublic} on the system -@samp{test1}. - -@ifset faq -@format ------------------------------- - -From: UUCP Protocol -Subject: UUCP Protocol -@end format -@end ifset - -@node UUCP Protocol, g Protocol, Execution File Format, Protocols -@section UUCP Protocol -@cindex UUCP protocol -@cindex protocol, UUCP - -The UUCP protocol is a conversation between two UUCP packages. A UUCP -conversation consists of three parts: an initial handshake, a series of -file transfer requests, and a final handshake. - -@menu -* The Initial Handshake:: The Initial Handshake -* UUCP Protocol Commands:: UUCP Protocol Commands -* The Final Handshake:: The Final Handshake -@end menu - -@node The Initial Handshake, UUCP Protocol Commands, UUCP Protocol, UUCP Protocol -@subsection The Initial Handshake -@cindex initial handshake - -Before the initial handshake, the caller will usually have logged in the -called machine and somehow started the UUCP package there. On Unix this -is normally done by setting the shell of the login name used to -@file{/usr/lib/uucp/uucico}. - -All messages in the initial handshake begin with a @kbd{^P} (a byte with -the octal value @samp{\020}) and end with a null byte (@samp{\000}). A -few systems end these messages with a line feed character (@samp{\012}) -instead of a null byte; the examples below assume a null byte is being -used. - -Some options below are supported by QFT, which stands for Queued File -Transfer, and is (or was) an internal Bell Labs version of UUCP. - -Taylor UUCP size negotiation was introduced by Taylor UUCP, and is -also supported by DOS based UUPlus and Amiga based wUUCP and -UUCP-1.17. - -The initial handshake goes as follows. It is begun by the called -machine. - -@table @asis -@item called: @samp{\020Shere=hostname\000} -The hostname is the UUCP name of the called machine. Older UUCP -packages do not output it, and simply send @samp{\020Shere\000}. - -@item caller: @samp{\020Shostname options\000} -The hostname is the UUCP name of the calling machine. The following -options may appear (or there may be none): - -@table @samp -@item -QSEQ -Report sequence number for this conversation. The sequence number is -stored at both sites, and incremented after each call. If there is a -sequence number mismatch, something has gone wrong (somebody may have -broken security by pretending to be one of the machines) and the call is -denied. If the sequence number changes on one of the machines, perhaps -because of an attempted breakin or because a disk backup was restored, -the sequence numbers on the two machines must be reconciled manually. - -@item -xLEVEL -Requests the called system to set its debugging level to the specified -value. This is not supported by all systems. - -@item -pGRADE -@itemx -vgrade=GRADE -Requests the called system to only transfer files of the specified grade -or higher. This is not supported by all systems. Some systems support -@samp{-p}, some support @samp{-vgrade=}. UUPlus allows either @samp{-p} -or @samp{-v} to be specified on a per-system basis in the @file{SYSTEMS} -file (@samp{gradechar} option). - -@item -R -Indicates that the calling UUCP understands how to restart failed file -transmissions. Supported only by System V Release 4 UUCP, QFT, and -Taylor UUCP. - -@item -ULIMIT -Reports the ulimit value of the calling UUCP. The limit is specified as -a base 16 number in C notation (e.g., @samp{-U0x1000000}). This number -is the number of 512 byte blocks in the largest file which the calling -UUCP can create. The called UUCP may not transfer a file larger than -this. Supported only by System V Release 4 UUCP, QFT and UUPlus. -UUPlus reports the lesser of the available disk space on the spool -directory drive and the ulimit variable in @file{UUPLUS.CFG}. Taylor -UUCP understands this option, but does not generate it. - -@item -N[NUMBER] -Indicates that the calling UUCP understands the Taylor UUCP size -negotiation extension. Not supported by traditional UUCP packages. -Supported by UUPlus. The optional number is a bitmask of features -supported by the calling UUCP, and is described below. -@end table - -@item called: @samp{\020ROK\000} -There are actually several possible responses. -@table @samp -@item ROK -The calling UUCP is acceptable, and the handshake proceeds to the -protocol negotiation. Some options may also appear; see below. -@item ROKN[NUMBER] -The calling UUCP is acceptable, it specified @samp{-N}, and the called -UUCP also understands the Taylor UUCP size limiting extensions. The -optional number is a bitmask of features supported by the called UUCP, -and is described below. -@item RLCK -The called UUCP already has a lock for the calling UUCP, which normally -indicates the two machines are already communicating. -@item RCB -The called UUCP will call back. This may be used to avoid impostors -(but only one machine out of each pair should call back, or no -conversation will ever begin). -@item RBADSEQ -The call sequence number is wrong (see the @samp{-Q} discussion above). -@item RLOGIN -The calling UUCP is using the wrong login name. -@item RYou are unknown to me -The calling UUCP is not known to the called UUCP, and the called UUCP -does not permit connections from unknown systems. Some versions of UUCP -just drop the line rather than sending this message. -@end table - -If the response is @samp{ROK}, the following options are supported by -System V Release 4 UUCP and QFT. -@table @samp -@item -R -The called UUCP knows how to restart failed file transmissions. -@item -ULIMIT -Reports the ulimit value of the called UUCP. The limit is specified as -a base 16 number in C notation. This number is the number of 512 byte -blocks in the largest file which the called UUCP can create. The -calling UUCP may not send a file larger than this. Also supported by -UUPlus. Taylor UUCP understands this option, but does not generate it. -@item -xLEVEL -I'm not sure just what this means. It may request the -calling UUCP to set its debugging level to the specified -value. -@end table - -If the response is not @samp{ROK} (or @samp{ROKN}) both sides hang up -the phone, abandoning the call. - -@item called: @samp{\020Pprotocols\000} -Note that the called UUCP outputs two strings in a row. The protocols -string is a list of UUCP protocols supported by the caller. Each UUCP -protocol has a single character name. These protocols are discussed in -more detail later in this document. For example, the called UUCP might -send @samp{\020Pgf\000}. - -@item caller: @samp{\020Uprotocol\000} -The calling UUCP selects which protocol to use out of the protocols -offered by the called UUCP. If there are no mutually supported -protocols, the calling UUCP sends @samp{\020UN\000} and both sides hang -up the phone. Otherwise the calling UUCP sends something like -@samp{\020Ug\000}. -@end table - -Most UUCP packages will consider each locally supported protocol in turn -and select the first one supported by the called UUCP. With some -versions of HDB UUCP, this can be modified by giving a list of protocols -after the device name in the @file{Devices} file or the @file{Systems} -file. For example, to select the @samp{e} protocol in @file{Systems}, -@example - airs Any ACU,e ... -@end example -or in Devices, -@example - ACU,e ttyXX ... -@end example -Taylor UUCP provides the @code{protocol} -command which may be used either -for a system -@ifclear faq -(@pxref{Protocol Selection}) -@end ifclear -or a -@ifclear faq -port (@pxref{port File}). -@end ifclear -@ifset faq -port. -@end ifset -UUPlus allows specification of the protocol string on a per-system basis -in the @file{SYSTEMS} file. - -The optional number following a @samp{-N} sent by the calling system, or -an @samp{ROKN} sent by the called system, is a bitmask of features -supported by the UUCP package. The optional number was introduced in -Taylor UUCP version 1.04. The number is sent as an octal number with a -leading zero. The following bits are currently defined. A missing -number should be taken as @samp{011}. - -@table @samp -@item 01 -UUCP supports size negotiation. - -@item 02 -UUCP supports file restart. - -@item 04 -UUCP supports the @samp{E} command. - -@item 010 -UUCP requires the file size in the @samp{S} and @samp{R} commands to be -in base 10. This bit is used by default if no number appears, but -should not be explicitly sent. - -@item 020 -UUCP expects a dummy string between the notify field and the size field -in an @samp{S} command. This is true of SVR4 UUCP. This bit should not -be used. -@end table - -After the protocol has been selected and the initial handshake has been -completed, both sides turn on the selected protocol. For some protocols -(notably @samp{g}) a further handshake is done at this point. - -@node UUCP Protocol Commands, The Final Handshake, The Initial Handshake, UUCP Protocol -@subsection UUCP Protocol Commands - -Each protocol supports a method for sending a command to the remote -system. This method is used to transmit a series of commands between -the two UUCP packages. At all times, one package is the master and the -other is the slave. Initially, the calling UUCP is the master. - -If a protocol error occurs during the exchange of commands, both sides -move immediately to the final handshake. - -The master will send one of five commands: @samp{S}, @samp{R}, @samp{X}, -@samp{E}, or @samp{H}. - -Any file name referred to below is either an absolute file name -beginning with @file{/}, a public directory file name beginning with -@file{~/}, a file name relative to a user's home directory beginning -with @file{~@var{USER}/}, or a spool directory file name. File names in -the spool directory are not absolute, but instead are converted to file -names within the spool directory by UUCP. They always begin with -@file{C.} (for a command file created by @code{uucp} or @code{uux}), -@file{D.} (for a data file created by @code{uucp}, @code{uux} or by an -execution, or received from another system for an execution), or -@file{X.} (for an execution file created by @code{uux} or received from -another system). - -@menu -* The S Command:: The S Command -* The R Command:: The R Command -* The X Command:: The X Command -* The E Command:: The E Command -* The H Command:: The H Command -@end menu - -@node The S Command, The R Command, UUCP Protocol Commands, UUCP Protocol Commands -@subsubsection The S Command -@cindex S UUCP protocol command -@cindex UUCP protocol S command - -@table @asis -@item master: @samp{S @var{from} @var{to} @var{user} -@var{options} @var{temp} @var{mode} @var{notify} @var{size}} -The @samp{S} and the @samp{-} are literal characters. This is a request -by the master to send a file to the slave. - -@table @var -@item from -The name of the file to send. If the @samp{C} option does not appear in -@var{options}, the master will actually open and send this file. -Otherwise the file has been copied to the spool directory, where it is -named @var{temp}. The slave ignores this field unless @var{to} is a -directory, in which case the basename of @var{from} will be used as the -file name. If @var{from} is a spool directory filename, it must be a -data file created for or by an execution, and must begin with @file{D.}. - -@item to -The name to give the file on the slave. If this field names a directory -the file is placed within that directory with the basename of -@var{from}. A name ending in @samp{/} is taken to be a directory even -if one does not already exist with that name. If @var{to} begins with -@file{X.}, an execution file will be created on the slave. Otherwise, -if @var{to} begins with @file{D.} it names a data file to be used by -some execution file. Otherwise, @var{to} should not be in the spool -directory. - -@item user -The name of the user who requested the transfer. - -@item options -A list of options to control the transfer. The following -options are defined (all options are single characters): -@table @samp -@item C -The file has been copied to the spool directory -(the master should use @var{temp} rather than @var{from}). -@item c -The file has not been copied to the spool directory (this is the -default). -@item d -The slave should create directories as necessary (this is the default). -@item f -The slave should not create directories if necessary, but should fail -the transfer instead. -@item m -The master should send mail to @var{user} when the transfer is complete. -@item n -The slave should send mail to @var{notify} when the transfer is -complete. -@end table - -@item temp -If the @samp{C} option appears in @var{options}, this names the file to -be sent. Otherwise if @var{from} is in the spool directory, @var{temp} -is the same as @var{from}. Otherwise @var{temp} may be a dummy string, -such as @file{D.0}. After the transfer has been succesfully completed, -the master will delete the file @var{temp}. - -@item mode -This is an octal number giving the mode of the file on the master. If -the file is not in the spool directory, the slave will always create it -with mode 0666, except that if (@var{mode} & 0111) is not zero (the file -is executable), the slave will create the file with mode 0777. If the -file is in the spool directory, some UUCP packages will use the -algorithm above and some will always create the file with mode 0600. -This field is ignored by UUPlus, since it is meaningless on DOS; UUPlus -uses 0666 for outgoing files. - -@item notify -This field may not be present, and in any case is only meaningful if the -@samp{n} option appears in @var{options}. If the @samp{n} option -appears, then, when the transfer is successfully completed, the slave -will send mail to @var{notify}, which must be a legal mailing address on -the slave. If a @var{size} field will appear but the @samp{n} option -does not appear, @var{notify} will always be present, typically as the -string @samp{dummy} or simply a pair of double quotes. - -@item size -This field is only present when doing Taylor UUCP or SVR4 UUCP size -negotiation. It is the size of the file in bytes. Taylor UUCP version -1.03 sends the size as a decimal integer, while versions 1.04 and up, -and all other UUCP packages that support size negotiation, send the size -in base 16 with a leading 0x. -@end table - -The slave then responds with an @samp{S} command response. - -@table @samp -@item SY @var{start} -The slave is willing to accept the file, and file transfer begins. The -@var{start} field will only be present when using file restart. It -specifies the byte offset into the file at which to start sending. If -this is a new file, @var{start} will be 0x0. - -@item SN2 -The slave denies permission to transfer the file. This can mean that -the destination directory may not be accessed, or that no requests are -permitted. It implies that the file transfer will never succeed. - -@item SN4 -The slave is unable to create the necessary temporary file. This -implies that the file transfer might succeed later. - -@item SN6 -This is only used by Taylor UUCP size negotiation. It means that the -slave considers the file too large to transfer at the moment, but it may -be possible to transfer it at some other time. - -@item SN7 -This is only used by Taylor UUCP size negotiation. It means that the -slave considers the file too large to ever transfer. - -@item SN8 -This is only used by Taylor UUCP. It means that the file was already -received in a previous conversation. This can happen if the receive -acknowledgement was lost after it was sent by the receiver but before it -was received by the sender. - -@item SN9 -This is only used by Taylor UUCP (versions 1.05 and up) and UUPlus -(versions 2.0 and up). It means that the remote system was unable to -open another channel (see the discussion of the @samp{i} protocol for -more information about channels). This implies that the file transfer -might succeed later. - -@item SN10 -This is reportedly used by SVR4 UUCP to mean that the file size is too -large. -@end table - -If the slave responds with @samp{SY}, a file transfer begins. When the -file transfer is complete, the slave sends a @samp{C} command response. - -@table @samp -@item CY -The file transfer was successful. -@item CYM -The file transfer was successful, and the slave wishes to become the -master; the master should send an @samp{H} command, described below. -@item CN5 -The temporary file could not be moved into the final location. This -implies that the file transfer will never succeed. -@end table -@end table - -After the @samp{C} command response has been received (in the @samp{SY} -case) or immediately (in an @samp{SN} case) the master will send another -command. - -@node The R Command, The X Command, The S Command, UUCP Protocol Commands -@subsubsection The R Command -@cindex R UUCP protocol command -@cindex UUCP protocol R command - -@table @asis -@item master: @samp{R @var{from} @var{to} @var{user} -@var{options} @var{size}} -The @samp{R} and the @samp{-} are literal characters. This is a request -by the master to receive a file from the slave. I do not know how SVR4 -UUCP or QFT implement file transfer restart in this case. - -@table @var -@item from -This is the name of the file on the slave which the master wishes to -receive. It must not be in the spool directory, and it may not contain -any wildcards. - -@item to -This is the name of the file to create on the master. I do not believe -that it can be a directory. It may only be in the spool directory if -this file is being requested to support an execution either on the -master or on some system other than the slave. - -@item user -The name of the user who requested the transfer. - -@item options -A list of options to control the transfer. The following -options are defined (all options are single characters): -@table @samp -@item d -The master should create directories as necessary (this is the default). -@item f -The master should not create directories if necessary, but should fail -the transfer instead. -@item m -The master should send mail to @var{user} when the transfer is complete. -@end table - -@item size -This only appears if Taylor UUCP size negotiation is being used. It -specifies the largest file which the master is prepared to accept (when -using SVR4 UUCP or QFT, this was specified in the @samp{-U} option -during the initial handshake). -@end table - -The slave then responds with an @samp{R} command response. UUPlus does -not support @samp{R} requests, and always responds with @samp{RN2}. - -@table @samp -@item RY @var{mode} [@var{size}] -The slave is willing to send the file, and file transfer begins. The -@var{mode} argument is the octal mode of the file on the slave. The -master treats this just as the slave does the @var{mode} argument in the -send command, q.v. I am told that SVR4 UUCP sends a trailing @var{size} -argument. For some versions of BSD UUCP, the @var{mode} argument may -have a trailing @samp{M} character (e.g., @samp{RY 0666M}). This means -that the slave wishes to become the master. - -@item RN2 -The slave is not willing to send the file, either because it is not -permitted or because the file does not exist. This implies that the -file request will never succeed. - -@item RN6 -This is only used by Taylor UUCP size negotiation. It means that the -file is too large to send, either because of the size limit specifies by -the master or because the slave considers it too large. The file -transfer might succeed later, or it might not (this may be cleared up in -a later release of Taylor UUCP). - -@item RN9 -This is only used by Taylor UUCP (versions 1.05 and up) and FSUUCP -(versions 1.5 and up). It means that the remote system was unable to -open another channel (see the discussion of the @samp{i} protocol for -more information about channels). This implies that the file transfer -might succeed later. -@end table - -If the slave responds with @samp{RY}, a file transfer begins. When the -file transfer is complete, the master sends a @samp{C} command. The -slave pretty much ignores this, although it may log it. - -@table @samp -@item CY -The file transfer was successful. -@item CN5 -The temporary file could not be moved into the final location. -@end table - -After the @samp{C} command response has been sent (in the @samp{RY} -case) or immediately (in an @samp{RN} case) the master will send another -command. -@end table - -@node The X Command, The E Command, The R Command, UUCP Protocol Commands -@subsubsection The X Command -@cindex X UUCP protocol command -@cindex UUCP protocol X command - -@table @asis -@item master: @samp{X @var{from} @var{to} @var{user} -@var{options}} -The @samp{X} and the @samp{-} are literal characters. This is a request -by the master to, in essence, execute uucp on the slave. The slave -should execute @samp{uucp @var{from} @var{to}}. - -@table @var -@item from -This is the name of the file or files on the slave which the master -wishes to transfer. Any wildcards are expanded on the slave. If the -master is requesting that the files be transferred to itself, the -request would normally contain wildcard characters, since otherwise an -@samp{R} command would suffice. The master can also use this command to -request that the slave transfer files to a third system. - -@item to -This is the name of the file or directory to which the files should be -transferred. This will normally use a UUCP name. For example, if the -master wishes to receive the files itself, it would use -@samp{master!path}. - -@item user -The name of the user who requested the transfer. - -@item options -A list of options to control the transfer. It is not clear which, if -any, options are supported by most UUCP packages. -@end table - -The slave then responds with an @samp{X} command response. FSUUCP does -not support @samp{X} requests, and always responds with @samp{XN}. - -@table @samp -@item XY -The request was accepted, and the appropriate file transfer commands -have been queued up for later processing. - -@item XN -The request was denied. No particular reason is given. -@end table - -In either case, the master will then send another command. -@end table - -@node The E Command, The H Command, The X Command, UUCP Protocol Commands -@subsubsection The E Command -@cindex E UUCP protocol command -@cindex UUCP protocol E command - -@table @asis -@item master: @samp{E @var{from} @var{to} @var{user} -@var{options} @var{temp} @var{mode} @var{notify} @var{size} @var{command}} -The @samp{E} command is only supported by Taylor UUCP 1.04 and up. It -is used to make an execution request without requiring a separate -@file{X.*} file. -@ifclear faq -@xref{Execution File Format}. -@end ifclear -It is only used when the command to be executed requires a single input -file which is passed to it as standard input. - -All the fields have the same meaning as they do for an @samp{S} command, -except for @var{options} and @var{command}. - -@table @var -@item options -A list of options to control the transfer. The following options are -defined (all options are single characters): -@table @samp -@item C -The file has been copied to the spool directory (the master should use -@var{temp} rather than @var{from}). -@item c -The file has not been copied to the spool directory (this is the -default). -@item N -No mail message should be sent, even if the command fails. This is the -equivalent of the @samp{N} command in an @file{X.*} file. -@item Z -A mail message should be sent if the command fails (this is generally -the default in any case). This is the equivalent of the @samp{Z} -command in an @file{X.*} file. -@item R -Mail messages about the execution should be sent to the address in the -@var{notify} field. This is the equivalent of the @samp{R} command in -an @file{X.*} file. -@item e -The execution should be done with @file{/bin/sh}. This is the -equivalent of the @samp{e} command in an @file{X.*} file. -@end table - -@item command -The command which should be executed. This is the equivalent of the -@samp{C} command in an @file{X.*} file. -@end table - -The slave then responds with an @samp{E} command response. These are -the same as the @samp{S} command responses, but the initial character is -@samp{E} rather than @samp{S}. - -If the slave responds with @samp{EY}, the file transfer begins. When -the file transfer is complete, the slave sends a @samp{C} command -response, just as for the @samp{S} command. After a successful file -transfer, the slave is responsible for arranging for the command to be -executed. The transferred file is passed as standard input, as though -it were named in the @samp{I} and @samp{F} commands of an @file{X.*} -file. - -After the @samp{C} command response has been received (in the @samp{EY} -case) or immediately (in an @samp{EN} case) the master will send another -command. -@end table - -@node The H Command, , The E Command, UUCP Protocol Commands -@subsubsection The H Command -@cindex H UUCP protocol command -@cindex UUCP protocol H command - -@table @asis -@item master: @samp{H} -This is used by the master to hang up the connection. The slave will -respond with an @samp{H} command response. - -@table @samp -@item HY -The slave agrees to hang up the connection. In this case the master -sends another @samp{HY} command. In some UUCP packages the slave will -then send a third @samp{HY} command. At this point the protocol is shut -down, and the final handshake is begun. -@item HN -The slave does not agree to hang up. In this case the master and the -slave exchange roles. The next command will be sent by the former -slave, which is the new master. The roles may be reversed several times -during a single connection. -@end table -@end table - -@node The Final Handshake, , UUCP Protocol Commands, UUCP Protocol -@subsection The Final Handshake -@cindex final handshake - -After the protocol has been shut down, the final handshake is performed. -This handshake has no real purpose, and some UUCP packages simply drop -the connection rather than do it (in fact, some will drop the connection -immediately after both sides agree to hangup, without even closing down -the protocol). - -@table @asis -@item caller: @samp{\020OOOOOO\000} - -@item called: @samp{\020OOOOOOO\000} -@end table - -That is, the calling UUCP sends six @samp{O} characters and the called -UUCP replies with seven @samp{O} characters. Some UUCP packages always -send six @samp{O} characters. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{g} Protocol -Subject: UUCP @samp{g} Protocol -@end format -@end ifset - -@node g Protocol, f Protocol, UUCP Protocol, Protocols -@section UUCP @samp{g} Protocol -@cindex @samp{g} protocol -@cindex protocol @samp{g} - -The @samp{g} protocol is a packet based flow controlled error correcting -protocol that requires an eight bit clear connection. It is the -original UUCP protocol, and is supported by all UUCP implementations. -Many implementations of it are only able to support small window and -packet sizes, specifically a window size of 3 and a packet size of 64 -bytes, but the protocol itself can support up to a window size of 7 and -a packet size of 4096 bytes. Complaints about the inefficiency of the -@samp{g} protocol generally refer to specific implementations, rather -than to the correctly implemented protocol. - -The @samp{g} protocol was originally designed for general packet -drivers, and thus contains some features that are not used by UUCP, -including an alternate data channel and the ability to renegotiate -packet and window sizes during the communication session. - -The @samp{g} protocol is spoofed by many Telebit modems. When spoofing -is in effect, each Telebit modem uses the @samp{g} protocol to -communicate with the attached computer, but the data between the modems -is sent using a Telebit proprietary error correcting protocol. This -allows for very high throughput over the Telebit connection, which, -because it is half-duplex, would not normally be able to handle the -@samp{g} protocol very well at all. When a Telebit is spoofing the -@samp{g} protocol, it forces the packet size to be 64 bytes and the -window size to be 3. - -This discussion of the @samp{g} protocol explains how it works, but does -not discuss useful error handling techniques. Some discussion of this -can be found in Jamie E. Hanrahan's paper, cited -@ifclear faq -above (@pxref{UUCP Protocol Sources}). -@end ifclear -@ifset faq -above. -@end ifset - -All @samp{g} protocol communication is done with packets. Each packet -begins with a six byte header. Control packets consist only of the -header. Data packets contain additional data. - -The header is as follows: - -@table @asis -@item @samp{\020} -Every packet begins with a @kbd{^P}. - -@item @var{k} (1 <= @var{k} <= 9) -The @var{k} value is always 9 for a control packet. For a data packet, -the @var{k} value indicates how much data follows the six byte header. -The amount of data is -@ifinfo -2 ** (@var{k} + 4), where ** indicates exponentiation. -@end ifinfo -@iftex -@tex -$2^{k + 4}$. -@end tex -@end iftex -Thus a @var{k} value of 1 means 32 data bytes and a -@var{k} value of 8 means 4096 data bytes. The @var{k} value for a data -packet must be between 1 and 8 inclusive. - -@item checksum low byte -@itemx checksum high byte -The checksum value is described below. - -@item control byte -The control byte indicates the type of packet, and is described below. - -@item xor byte -This byte is the xor of @var{k}, the checksum low byte, the checksum -high byte and the control byte (i.e., the second, third, fourth and -fifth header bytes). It is used to ensure that the header data is -valid. -@end table - -The control byte in the header is composed of three bit fields, referred -to here as @var{tt} (two bits), @var{xxx} (three bits) and @var{yyy} -(three bits). The control is @var{tt}@var{xxx}@var{yyy}, or @code{(@var{tt} -<< 6) + (@var{xxx} << 3) + @var{yyy}}. - -The @var{TT} field takes on the following values: - -@table @samp -@item 0 -This is a control packet. In this case the @var{k} byte in the -header must be 9. The @var{xxx} field indicates the type of control -packet; these types are described below. - -@item 1 -This is an alternate data channel packet. This is not used by UUCP. - -@item 2 -This is a data packet, and the entire contents of the attached data -field (whose length is given by the @var{k} byte in the header) are -valid. The @var{xxx} and @var{yyy} fields are described below. - -@item 3 -This is a short data packet. Let the length of the data field (as given -by the @var{k} byte in the header) be @var{l}. Let the first byte in -the data field be @var{b1}. If @var{b1} is less than 128 (if the most -significant bit of @var{b1} is 0), then there are @code{@var{l} - -@var{b1}} valid bytes of data in the data field, beginning with the -second byte. If @code{@var{b1} >= 128}, let @var{b2} be the second byte -in the data field. Then there are @code{@var{l} - ((@var{b1} & 0x7f) + -(@var{b2} << 7))} valid bytes of data in the data field, beginning with -the third byte. In all cases @var{l} bytes of data are sent (and all -data bytes participate in the checksum calculation) but some of the -trailing bytes may be dropped by the receiver. The @var{xxx} and -@var{yyy} fields are described below. -@end table - -In a data packet (short or not) the @var{xxx} field gives the sequence -number of the packet. Thus sequence numbers can range from 0 to 7, -inclusive. The @var{yyy} field gives the sequence number of the last -correctly received packet. - -Each communication direction uses a window which indicates how many -unacknowledged packets may be transmitted before waiting for an -acknowledgement. The window may range from 1 to 7, and may be different -in each direction. For example, if the window is 3 and the last packet -acknowledged was packet number 6, packet numbers 7, 0 and 1 may be sent -but the sender must wait for an acknowledgement before sending packet -number 2. This acknowledgement could come as the @var{yyy} field of a -data packet, or as the @var{yyy} field of a @samp{RJ} or @samp{RR} -control packet (described below). - -Each packet must be transmitted in order (the sender may not skip -sequence numbers). Each packet must be acknowledged, and each packet -must be acknowledged in order. - -In a control packet, the @var{xxx} field takes on the following values: - -@table @asis -@item 1 @samp{CLOSE} -The connection should be closed immediately. This is typically sent -when one side has seen too many errors and wants to give up. It is also -sent when shutting down the protocol. If an unexpected @samp{CLOSE} -packet is received, a @samp{CLOSE} packet should be sent in reply and -the @samp{g} protocol should halt, causing UUCP to enter the final -handshake. - -@item 2 @samp{RJ} or @samp{NAK} -The last packet was not received correctly. The @var{yyy} field -contains the sequence number of the last correctly received packet. - -@item 3 @samp{SRJ} -Selective reject. The @var{yyy} field contains the sequence number of a -packet that was not received correctly, and should be retransmitted. -This is not used by UUCP, and most implementations will not recognize -it. - -@item 4 @samp{RR} or @samp{ACK} -Packet acknowledgement. The @var{yyy} field contains the sequence -number of the last correctly received packet. - -@item 5 @samp{INITC} -Third initialization packet. The @var{yyy} field contains the maximum -window size to use. - -@item 6 @samp{INITB} -Second initialization packet. The @var{yyy} field contains the -packet size to use. It requests a size of -@ifinfo -2 ** (@var{yyy} + 5). -@end ifinfo -@iftex -@tex -$2^{yyy + 5}$. -@end tex -@end iftex -Note that this is not the same coding used for the @var{k} byte in the -packet header (it is 1 less). Most UUCP implementations that request a -packet size larger than 64 bytes can handle any packet size up to that -specified. - -@item 7 @samp{INITA} -First initialization packet. The @var{yyy} field contains the maximum -window size to use. -@end table - -To compute the checksum, call the control byte (the fifth byte in the -header) @var{c}. - -The checksum of a control packet is simply @code{0xaaaa - @var{c}}. - -The checksum of a data packet is @code{0xaaaa - (@var{check} ^ -@var{c})}, where @code{^} denotes exclusive or, and @var{check} is the -result of the following routine as run on the contents of the data field -(every byte in the data field participates in the checksum, even for a -short data packet). Below is the routine used by an early version of -Taylor UUCP; it is a slightly modified version of a routine which John -Gilmore patched from G.L.@: Chesson's original paper. The @code{z} -argument points to the data and the @code{c} argument indicates how much -data there is. - -@example -int -igchecksum (z, c) - register const char *z; - register int c; -@{ - register unsigned int ichk1, ichk2; - - ichk1 = 0xffff; - ichk2 = 0; - - do - @{ - register unsigned int b; - - /* Rotate ichk1 left. */ - if ((ichk1 & 0x8000) == 0) - ichk1 <<= 1; - else - @{ - ichk1 <<= 1; - ++ichk1; - @} - - /* Add the next character to ichk1. */ - b = *z++ & 0xff; - ichk1 += b; - - /* Add ichk1 xor the character position in the buffer counting from - the back to ichk2. */ - ichk2 += ichk1 ^ c; - - /* If the character was zero, or adding it to ichk1 caused an - overflow, xor ichk2 to ichk1. */ - if (b == 0 || (ichk1 & 0xffff) < b) - ichk1 ^= ichk2; - @} - while (--c > 0); - - return ichk1 & 0xffff; -@} -@end example - -When the @samp{g} protocol is started, the calling UUCP sends an -@samp{INITA} control packet with the window size it wishes the called -UUCP to use. The called UUCP responds with an @samp{INITA} packet with -the window size it wishes the calling UUCP to use. Pairs of -@samp{INITB} and @samp{INITC} packets are then similarly exchanged. -When these exchanges are completed, the protocol is considered to have -been started. - -Note that the window and packet sizes are not a negotiation. Each -system announces the window and packet size which the other system -should use. It is possible that different window and packet sizes will -be used in each direction. The protocol works this way on the theory -that each system knows how much data it can accept without getting -overrun. Therefore, each system tells the other how much data to send -before waiting for an acknowledgement. - -When a UUCP package transmits a command, it sends one or more data -packets. All the data packets will normally be complete, although some -UUCP packages may send the last one as a short packet. The command -string is sent with a trailing null byte, to let the receiving package -know when the command is finished. Some UUCP packages require the last -byte of the last packet sent to be null, even if the command ends -earlier in the packet. Some packages may require all the trailing bytes -in the last packet to be null, but I have not confirmed this. - -When a UUCP package sends a file, it will send a sequence of data -packets. The end of the file is signalled by a short data packet -containing zero valid bytes (it will normally be preceeded by a short -data packet containing the last few bytes in the file). - -Note that the sequence numbers cover the entire communication session, -including both command and file data. - -When the protocol is shut down, each UUCP package sends a @samp{CLOSE} -control packet. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{f} Protocol -Subject: UUCP @samp{f} Protocol -@end format -@end ifset - -@node f Protocol, t Protocol, g Protocol, Protocols -@section UUCP @samp{f} Protocol -@cindex @samp{f} protocol -@cindex protocol @samp{f} - -The @samp{f} protocol is a seven bit protocol which checksums an entire -file at a time. It only uses the characters between @samp{\040} and -@samp{\176} (ASCII @kbd{space} and @kbd{~}) inclusive, as well as the -carriage return character. It can be very efficient for transferring -text only data, but it is very inefficient at transferring eight bit -data (such as compressed news). It is not flow controlled, and the -checksum is fairly insecure over large files, so using it over a serial -connection requires handshaking (XON/XOFF can be used) and error -correcting modems. Some people think it should not be used even under -those circumstances. - -I believe that the @samp{f} protocol originated in BSD versions of UUCP. -It was originally intended for transmission over X.25 PAD links. - -The @samp{f} protocol has no startup or finish protocol. However, both -sides typically sleep for a couple of seconds before starting up, -because they switch the terminal into XON/XOFF mode and want to allow -the changes to settle before beginning transmission. - -When a UUCP package transmits a command, it simply sends a string -terminated by a carriage return. - -When a UUCP package transmits a file, each byte @var{b} of the file is -translated according to the following table: - -@example - 0 <= @var{b} <= 037: 0172, @var{b} + 0100 (0100 to 0137) - 040 <= @var{b} <= 0171: @var{b} ( 040 to 0171) - 0172 <= @var{b} <= 0177: 0173, @var{b} - 0100 ( 072 to 077) - 0200 <= @var{b} <= 0237: 0174, @var{b} - 0100 (0100 to 0137) - 0240 <= @var{b} <= 0371: 0175, @var{b} - 0200 ( 040 to 0171) - 0372 <= @var{b} <= 0377: 0176, @var{b} - 0300 ( 072 to 077) -@end example - -That is, a byte between @samp{\040} and @samp{\171} inclusive is -transmitted as is, and all other bytes are prefixed and modified as -shown. - -When all the file data is sent, a seven byte sequence is sent: two bytes -of @samp{\176} followed by four ASCII bytes of the checksum as printed -in base 16 followed by a carriage return. For example, if the checksum -was 0x1234, this would be sent: @samp{\176\1761234\r}. - -The checksum is initialized to 0xffff. For each byte that is sent it is -modified as follows (where @var{b} is the byte before it has been -transformed as described above): - -@example - /* Rotate the checksum left. */ - if ((ichk & 0x8000) == 0) - ichk <<= 1; - else - @{ - ichk <<= 1; - ++ichk; - @} - - /* Add the next byte into the checksum. */ - ichk += @var{b}; -@end example - -When the receiving UUCP sees the checksum, it compares it against its -own calculated checksum and replies with a single character followed -by a carriage return. - -@table @samp -@item G -The file was received correctly. - -@item R -The checksum did not match, and the file should be resent from the -beginning. - -@item Q -The checksum did not match, but too many retries have occurred and the -communication session should be abandoned. -@end table - -The sending UUCP checks the returned character and acts accordingly. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{t} Protocol -Subject: UUCP @samp{t} Protocol -@end format -@end ifset - -@node t Protocol, e Protocol, f Protocol, Protocols -@section UUCP @samp{t} Protocol -@cindex @samp{t} protocol -@cindex protocol @samp{t} - -The @samp{t} protocol is intended for use on links which provide -reliable end-to-end connections, such as TCP. It does no error checking -or flow control, and requires an eight bit clear channel. - -I believe the @samp{t} protocol originated in BSD versions of UUCP. - -When a UUCP package transmits a command, it first gets the length of the -command string, @var{c}. It then sends @code{((@var{c} / 512) + 1) * -512} bytes (the smallest multiple of 512 which can hold @var{c} bytes -plus a null byte) consisting of the command string itself followed by -trailing null bytes. - -When a UUCP package sends a file, it sends it in blocks. Each block -contains at most 1024 bytes of data. Each block consists of four bytes -containing the amount of data in binary (most significant byte first, -the same format as used by the Unix function @code{htonl}) followed by -that amount of data. The end of the file is signalled by a block -containing zero bytes of data. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{e} Protocol -Subject: UUCP @samp{e} Protocol -@end format -@end ifset - -@node e Protocol, Big G Protocol, t Protocol, Protocols -@section UUCP @samp{e} Protocol -@cindex @samp{e} protocol -@cindex protocol @samp{e} - -The @samp{e} protocol is similar to the @samp{t} protocol. It does no -flow control or error checking and is intended for use over networks -providing reliable end-to-end connections, such as TCP. - -The @samp{e} protocol originated in versions of HDB UUCP. - -When a UUCP package transmits a command, it simply sends the command -as an ASCII string terminated by a null byte. - -When a UUCP package transmits a file, it sends the complete size of the -file as an ASCII decimal number. The ASCII string is padded out to 20 -bytes with null bytes (i.e. if the file is 1000 bytes long, it sends -@samp{1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0}). It then sends the entire -file. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{G} Protocol -Subject: UUCP @samp{G} Protocol -@end format -@end ifset - -@node Big G Protocol, i Protocol, e Protocol, Protocols -@section UUCP @samp{G} Protocol -@cindex @samp{G} protocol -@cindex protocol @samp{G} - -The @samp{G} protocol is used by SVR4 UUCP. It is identical to the -@samp{g} protocol, except that it is possible to modify the window and -packet sizes. The SVR4 implementation of the @samp{g} protocol -reportedly is fixed at a packet size of 64 and a window size of 7. -Supposedly SVR4 chose to implement a new protocol using a new letter to -avoid any potential incompatibilities when using different packet or -window sizes. - -Most implementations of the @samp{g} protocol that accept packets larger -than 64 bytes will also accept packets smaller than whatever they -requested in the @samp{INITB} packet. The SVR4 @samp{G} implementation -is an exception; it will only accept packets of precisely the size it -requests in the INITB packet. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{i} Protocol -Subject: UUCP @samp{i} Protocol -@end format -@end ifset - -@node i Protocol, j Protocol, Big G Protocol, Protocols -@section UUCP @samp{i} Protocol -@cindex @samp{i} protocol -@cindex protocol @samp{i} - -The @samp{i} protocol was written by Ian Lance Taylor (who also wrote -this -@ifclear faq -manual). -@end ifclear -@ifset faq -FAQ). -@end ifset -It was first used by Taylor UUCP version 1.04. - -It is a sliding window packet protocol, like the @samp{g} protocol, but -it supports bidirectional transfers (i.e., file transfers in both -directions simultaneously). It requires an eight bit clear connection. -Several ideas for the protocol were taken from the paper @cite{A -High-Throughput Message Transport System} by P.@: Lauder. I don't know -where the paper was published, but the author's e-mail address is -@code{piers@@cs.su.oz.au}. The @samp{i} protocol does not adopt his -main idea, which is to dispense with windows entirely. This is because -some links still do require flow control and, more importantly, because -using windows sets a limit to the amount of data which the protocol must -be able to resend upon request. To reduce the costs of window -acknowledgements, the protocol uses a large window and only requires an -ack at the halfway point. - -Each packet starts with a six byte header, optionally followed by data -bytes with a four byte checksum. There are currently five defined -packet types (@samp{DATA}, @samp{SYNC}, @samp{ACK}, @samp{NAK}, -@samp{SPOS}, @samp{CLOSE}) which are described below. Although any -packet type may include data, any data provided with an @samp{ACK}, -@samp{NAK} or @samp{CLOSE} packet is ignored. - -Every @samp{DATA}, @samp{SPOS} and @samp{CLOSE} packet has a sequence -number. The sequence numbers are independent for each side. The first -packet sent by each side is always number 1. Each packet is numbered -one greater than the previous packet, modulo 32. - -Every packet has a local channel number and a remote channel number. -For all packets at least one channel number is zero. When a UUCP -command is sent to the remote system, it is assigned a non-zero local -channel number. All packets associated with that UUCP command sent by -the local system are given the selected local channel number. All -associated packets sent by the remote system are given the selected -number as the remote channel number. This permits each UUCP command -to be uniquely identified by the channel number on the originating -system, and therefore each UUCP package can associate all file data -and UUCP command responses with the appropriate command. This is a -requirement for bidirectional UUCP transfers. - -The protocol maintains a single global file position, which starts at 0. -For each incoming packet, any associated data is considered to occur at -the current file position, and the file position is incremented by the -amount of data contained. The exception is a packet of type -@samp{SPOS}, which is used to change the file position. The reason for -keeping track of the file position is described below. - -The header is as follows: - -@table @asis -@item @samp{\007} -Every packet begins with @kbd{^G}. - -@item @code{(@var{packet} << 3) + @var{locchan}} -The five bit packet number combined with the three bit local channel -number. @samp{DATA}, @samp{SPOS} and @samp{CLOSE} packets use the -packet sequence number for the @var{packet} field. @samp{NAK} packet -types use the @var{packet} field for the sequence number to be resent. -@samp{ACK} and @samp{SYNC} do not use the @var{packet} field, and -generally leave it set to 0. Packets which are not associated with a -UUCP command from the local system use a local channel number of 0. - -@item @code{(@var{ack} << 3) + @var{remchan}} -The five bit packet acknowledgement combined with the three bit remote -channel number. The packet acknowledgement is the number of the last -packet successfully received; it is used by all packet types. Packets -which are not sent in response to a UUCP command from the remote system -use a remote channel number of 0. - -@item @code{(@var{type} << 5) + (@var{caller} << 4) + @var{len1}} -The three bit packet type combined with the one bit packet direction -combined with the upper four bits of the data length. The packet -direction bit is always 1 for packets sent by the calling UUCP, and 0 -for packets sent by the called UUCP. This prevents confusion caused by -echoed packets. - -@item @var{len2} -The lower eight bits of the data length. The twelve bits of data length -permit packets ranging in size from 0 to 4095 bytes. - -@item @var{check} -The exclusive or of the second through fifth bytes of the header. This -provides an additional check that the header is valid. -@end table - -If the data length is non-zero, the packet is immediately followed by -the specified number of data bytes. The data bytes are followed by a -four byte CRC 32 checksum, with the most significant byte first. The -CRC is calculated over the contents of the data field. - -The defined packet types are as follows: - -@table @asis -@item 0 @samp{DATA} -This is a plain data packet. - -@item 1 @samp{SYNC} -@samp{SYNC} packets are exchanged when the protocol is initialized, and -are described further below. @samp{SYNC} packets do not carry sequence -numbers (that is, the @var{packet} field is ignored). - -@item 2 @samp{ACK} -This is an acknowledgement packet. Since @samp{DATA} packets also carry -packet acknowledgements, @samp{ACK} packets are only used when one side -has no data to send. @samp{ACK} packets do not carry sequence numbers. - -@item 3 @samp{NAK} -This is a negative acknowledgement. This is sent when a packet is -received incorrectly, and means that the packet number appearing in the -@var{packet} field must be resent. @samp{NAK} packets do not carry -sequence numbers (the @var{packet} field is already used). - -@item 4 @samp{SPOS} -This packet changes the file position. The packet contains four bytes -of data holding the file position, most significant byte first. The -next packet received will be considered to be at the named file -position. - -@item 5 @samp{CLOSE} -When the protocol is shut down, each side sends a @samp{CLOSE} packet. -This packet does have a sequence number, which could be used to ensure -that all packets were correctly received (this is not needed by UUCP, -however, which uses the higher level @samp{H} command with an @samp{HY} -response). -@end table - -When the protocol starts up, both systems send a @samp{SYNC} packet. -The @samp{SYNC} packet includes at least three bytes of data. The first -two bytes are the maximum packet size the remote system should send, -most significant byte first. The third byte is the window size the -remote system should use. The remote system may send packets of any -size up to the maximum. If there is a fourth byte, it is the number of -channels the remote system may use (this must be between 1 and 7, -inclusive). Additional data bytes may be defined in the future. - -The window size is the number of packets that may be sent before a -packet is acknowledged. There is no requirement that every packet be -acknowledged; any acknowledgement is considered to acknowledge all -packets through the number given. In the current implementation, if one -side has no data to send, it sends an @samp{ACK} when half the window is -received. - -Note that the @samp{NAK} packet corresponds to the unused @samp{g} -protocol @samp{SRJ} packet type, rather than to the @samp{RJ} packet -type. When a @samp{NAK} is received, only the named packet should be -resent, not any subsequent packets. - -Note that if both sides have data to send, but a packet is lost, it is -perfectly reasonable for one side to continue sending packets, all of -which will acknowledge the last packet correctly received, while the -system whose packet was lost will be unable to send a new packet because -the send window will be full. In this circumstance, neither side will -time out and one side of the communication will be effectively shut down -for a while. Therefore, any system with outstanding unacknowledged -packets should arrange to time out and resend a packet even if data is -being received. - -Commands are sent as a sequence of data packets with a non-zero local -channel number. The last data packet for a command includes a trailing -null byte (normally a command will fit in a single data packet). Files -are sent as a sequence of data packets ending with one of length zero. - -The channel numbers permit a more efficient implementation of the UUCP -file send command. Rather than send the command and then wait for the -@samp{SY} response before sending the file, the file data is sent -beginning immediately after the @samp{S} command is sent. If an -@samp{SN} response is received, the file send is aborted, and a final -data packet of length zero is sent to indicate that the channel number -may be reused. If an @samp{SY} reponse with a file position indicator -is received, the file send adjusts to the file position; this is why the -protocol maintains a global file position. - -Note that the use of channel numbers means that each UUCP system may -send commands and file data simultaneously. Moreover, each UUCP system -may send multiple files at the same time, using the channel number to -disambiguate the data. Sending a file before receiving an -acknowledgement for the previous file helps to eliminate the round trip -delays inherent in other UUCP protocols. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{j} Protocol -Subject: UUCP @samp{j} Protocol -@end format -@end ifset - -@node j Protocol, x Protocol, i Protocol, Protocols -@section UUCP @samp{j} Protocol -@cindex @samp{j} protocol -@cindex protocol @samp{j} - -The @samp{j} protocol is a variant of the @samp{i} protocol. It was -also written by Ian Lance Taylor, and first appeared in Taylor UUCP -version 1.04. - -The @samp{j} protocol is a version of the @samp{i} protocol designed for -communication links which intercept a few characters, such as XON or -XOFF. It is not efficient to use it on a link which intercepts many -characters, such as a seven bit link. The @samp{j} protocol performs no -error correction or detection; that is presumed to be the responsibility -of the @samp{i} protocol. - -When the @samp{j} protocol starts up, each system sends a printable -ASCII string indicating which characters it wants to avoid using. The -string begins with the ASCII character @kbd{^} (octal 136) and ends with -the ASCII character @kbd{~} (octal 176). After sending this string, -each system looks for the corresponding string from the remote system. -The strings are composed of escape sequences: @samp{\ooo}, where -@samp{o} is an octal digit. For example, sending the string -@samp{^\021\023~} means that the ASCII XON and XOFF characters should be -avoided. The union of the characters described in both strings (the -string which is sent and the string which is received) is the set of -characters which must be avoided in this conversation. Avoiding a -printable ASCII character (octal 040 to octal 176, inclusive) is not -permitted. - -After the exchange of characters to avoid, the normal @samp{i} protocol -start up is done, and the rest of the conversation uses the normal -@samp{i} protocol. However, each @samp{i} protocol packet is wrapped to -become a @samp{j} protocol packet. - -Each @samp{j} protocol packet consists of a seven byte header, followed -by data bytes, followed by index bytes, followed by a one byte trailer. -The packet header looks like this: - -@table @asis -@item @kbd{^} -Every packet begins with the ASCII character @kbd{^}, octal 136. - -@item @var{high} -@itemx @var{low} -These two characters give the total number of bytes in the packet. Both -@var{high} and @var{low} are printable ASCII characters. The length of -the packet is @code{(@var{high} - 040) * 0100 + (@var{low} - 040)}, -where @code{040 <= @var{high} < 0177} and @code{040 <= @var{low} < -0140}. This permits a length of 6079 bytes, but there is a further -restriction on packet size described below. - -@item @kbd{=} -The ASCII character @kbd{=}, octal 075. - -@item @var{data-high} -@itemx @var{data-low} -These two characters give the total number of data bytes in the packet. -The encoding is as described for @var{high} and @var{low}. The number -of data bytes is the size of the @samp{i} protocol packet wrapped inside -this @samp{j} protocol packet. - -@item @kbd{@@} -The ASCII character @kbd{@@}, octal 100. -@end table - -The header is followed by the number of data bytes given in -@var{data-high} and @var{data-low}. These data bytes are the @samp{i} -protocol packet which is being wrapped in the @samp{j} protocol packet. -However, each character in the @samp{i} protocol packet which the -@samp{j} protocol must avoid is transformed into a printable ASCII -character (recall that avoiding a printable ASCII character is not -permitted). Two index bytes are used for each character which must be -transformed. - -The index bytes immediately follow the data bytes. The index bytes are -created in pairs. Each pair of index bytes encodes the location of a -character in the @samp{i} protocol packet which was transformed to -become a printable ASCII character. Each pair of index bytes also -encodes the precise transformation which was performed. - -When the sender finds a character which must be avoided, it will -transform it using one or two operations. If the character is 0200 or -greater, it will subtract 0200. If the resulting character is less than -020, or is equal to 0177, it will xor by 020. The result is a printable -ASCII character. - -The zero based byte index of the character within the @samp{i} protocol -packet is determined. This index is turned into a two byte printable -ASCII index, @var{index-high} and @var{index-low}, such that the index -is @code{(@var{index-high} - 040) * 040 + (@var{index-low} - 040)}. -@var{index-low} is restricted such that @code{040 <= @var{index-low} < -0100}. @var{index-high} is not permitted to be 0176, so @code{040 <= -@var{index-high} < 0176}. @var{index-low} is then modified to encode -the transformation: - -@itemize @bullet -@item If the character transformation only had to subtract 0200, then -@var{index-low} is used as is. - -@item If the character transformation only had to xor by 020, then 040 -is added to @var{index-low}. - -@item If both operations had to be performed, then 0100 is added to -@var{index-low}. However, if the value of @var{index-low} was initially -077, then adding 0100 would result in 0177, which is not a printable -ASCII character. For that special case, @var{index-high} is set to -0176, and @var{index-low} is set to the original value of -@var{index-high}. -@end itemize - -The receiver decodes the index bytes as follows (this is the reverse of -the operations performed by the sender, presented here for additional -clarity): - -@itemize @bullet -@item The first byte in the index is @var{index-high}, and the second is -@var{index-low}. - -@item If @code{040 <= @var{index-high} < 0176}, the index refers to the -data byte at position @code{(@var{index-high} - 040) * 040 + -@var{index-low} % 040}. - -@item If @code{040 <= @var{index-low} < 0100}, then 0200 must be added -to indexed byte. - -@item If @code{0100 <= @var{index-low} < 0140}, then 020 must be xor'ed -to the indexed byte. - -@item If @code{0140 <= @var{index-low} < 0177}, then 0200 must be added -to the indexed byte, and 020 must be xor'ed to the indexed byte. - -@item If @code{@var{index-high} == 0176}, the index refers to the data -byte at position @code{(@var{index-low} - 040) * 040 + 037}. 0200 must -be added to the indexed byte, and 020 must be xor'ed to the indexed -byte. -@end itemize - -This means the largest @samp{i} protocol packet which may be wrapped -inside a @samp{j} protocol packet is @code{(0175 - 040) * 040 + (077 - -040) == 3007} bytes. - -The final character in a @samp{j} protocol packet, following the index -bytes, is the ASCII character @kbd{~} (octal 176). - -The motivation behind using an indexing scheme, rather than escape -characters, is to avoid data movement. The sender may simply add a -header and a trailer to the @samp{i} protocol packet. Once the receiver -has loaded the @samp{j} protocol packet, it may scan the index bytes, -transforming the data bytes, and then pass the data bytes directly on to -the @samp{i} protocol routine. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{x} Protocol -Subject: UUCP @samp{x} Protocol -@end format -@end ifset - -@node x Protocol, y Protocol, j Protocol, Protocols -@section UUCP @samp{x} Protocol -@cindex @samp{x} protocol -@cindex protocol @samp{x} - -The @samp{x} protocol is used in Europe (and probably elsewhere) with -machines that contain an builtin X.25 card and can send eight bit data -transparently across X.25 circuits, without interference from the X.28 -or X.29 layers. The protocol sends packets of 512 bytes, and relies on -a write of zero bytes being read as zero bytes without stopping -communication. It first appeared in the original System V UUCP -implementation. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{y} Protocol -Subject: UUCP @samp{y} Protocol -@end format -@end ifset - -@node y Protocol, d Protocol, x Protocol, Protocols -@section UUCP @samp{y} Protocol -@cindex @samp{y} protocol -@cindex protocol @samp{y} - -The @samp{y} protocol was developed by Jorge Cwik for use in FX UUCICO, -a PC uucico program. It is designed for communication lines which -handle error correction and flow control. It requires an eight bit -clean connection. It performs error detection, but not error -correction: when an error is detected, the line is dropped. It is a -streaming protocol, like the @samp{f} protocol; there are no packet -acknowledgements, so the protocol is efficient over a half-duplex -communication line such as PEP. - -Every packet contains a six byte header: - -@table @asis -@item sequence low byte -@itemx sequence high byte -A two byte sequence number, in little endian order. The first sequence -number is 0. Since the first packet is always a sync packet (described -below) the sequence number of the first data packet is always 1. Each -system counts sequence numbers independently. - -@item length low byte -@itemx length high byte -A two byte data length, in little endian order. If the high bit of the -sixteen bit field is clear, this is the number of data bytes which -follow the six byte header. If the high bit is set, there is no data, -and the length field is a type of control packet. - -@item checksum low byte -@itemx checksum high byte -A two byte checksum, in little endian order. The checksum is computed -over the data bytes. The checksum algorithm is described below. If -there are no data bytes, the checksum is sent as 0. -@end table - -When the protocol starts up, each side must send a sync packet. This is -a packet with a normal six byte header followed by data. The sequence -number of the sync packet should be 0. Currently at least four bytes of -data must be sent with the sync packet. Additional bytes should be -ignored. They are defined as follows: - -@table @asis -@item version -The version number of the protocol. Currently this must be 1. Larger -numbers should be ignored; it is the responsibility of the newer version -to accommodate the older one. - -@item packet size -The maximum data length to use divided by 256. This is sent as a single -byte. The maximum data length permitted is 32768, which would be sent -as 128. Customarily both systems will use the same maximum data length, -the lower of the two requested. - -@item flags low byte -@itemx flags high byte -Two bytes of flags. None are currently defined. These bytes should be -sent as 0, and ignored by the receiver. -@end table - -A length field with the high bit set is a control packet. The -following control packet types are defined: - -@table @asis -@item 0xfffe @samp{YPKT_ACK} -Acknowledges correct receipt of a file. - -@item 0xfffd @samp{YPKT_ERR} -Indicates an incorrect checksum. - -@item 0xfffc @samp{YPKT_BAD} -Indicates a bad sequence number, an invalid length, or some other error. -@end table - -If a control packet other than @samp{YPKT_ACK} is received, the -connection is dropped. If a checksum error is detected for a received -packet, a @samp{YPKT_ERR} control packet is sent, and the connection is -dropped. If a packet is received out of sequence, a @samp{YPKT_BAD} -control packet is sent, and the connection is dropped. - -The checksum is initialized to 0xffff. For each data byte in a packet -it is modified as follows (where @var{b} is the byte before it has been -transformed as described above): - -@example - /* Rotate the checksum left. */ - if ((ichk & 0x8000) == 0) - ichk <<= 1; - else - @{ - ichk <<= 1; - ++ichk; - @} - - /* Add the next byte into the checksum. */ - ichk += @var{b}; -@end example - -This is the same algorithm as that used by the @samp{f} protocol. - -A command is sent as a sequence of data packets followed by a null byte. -In the normal case, a command will fit into a single packet. The packet -should be exactly the length of the command plus a null byte. If the -command is too long, more packets are sent as required. - -A file is sent as a sequence of data packets, ending with a zero length -packet. The data packets may be of any length greater than zero and -less than or equal to the maximum permitted packet size specified in the -initial sync packet. - -After the zero length packet ending a file transfer has been received, -the receiving system sends a @samp{YPKT_ACK} control packet. The -sending system waits for the @samp{YPKT_ACK} control packet before -continuing; this wait should be done with a large timeout, since there -may be a considerable amount of data buffered on the communication path. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{d} Protocol -Subject: UUCP @samp{d} Protocol -@end format -@end ifset - -@node d Protocol, h Protocol, y Protocol, Protocols -@section UUCP @samp{d} Protocol -@cindex @samp{d} protocol -@cindex protocol @samp{d} - -The @samp{d} protocol is apparently used for DataKit muxhost (not -RS-232) connections. No file size is sent. When a file has been -completely transferred, a write of zero bytes is done; this must be read -as zero bytes on the other end. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{h} Protocol -Subject: UUCP @samp{h} Protocol -@end format -@end ifset - -@node h Protocol, v Protocol, d Protocol, Protocols -@section UUCP @samp{h} Protocol -@cindex @samp{h} protocol -@cindex protocol @samp{h} - -The @samp{h} protocol is apparently used in some places with HST modems. -It does no error checking, and is not that different from the @samp{t} -protocol. I don't know the details. - -@ifset faq -@format ------------------------------- - -From: UUCP @samp{v} Protocol -Subject: UUCP @samp{v} Protocol -@end format -@end ifset - -@node v Protocol, , h Protocol, Protocols -@section UUCP @samp{v} Protocol -@cindex @samp{v} protocol -@cindex protocol @samp{v} - -The @samp{v} protocol is used by UUPC/extended, a PC UUCP program. It -is simply a version of the @samp{g} protocol which supports packets of -any size, and also supports sending packets of different sizes during -the same conversation. There are many @samp{g} protocol implementations -which support both, but there are also many which do not. Using -@samp{v} ensures that everything is supported. - -@ifset faq -@format ------------------------------- - -From: Thanks -Subject: Thanks -@end format - -Besides the papers and information acknowledged at the top of this -article, the following people have contributed help, advice, -suggestions and information: -@format - Earle Ake 513-429-6500 <ake@@Dayton.SAIC.COM> - chris@@uuplus.com (Christopher J. Ambler) - jhc@@iscp.bellcore.com (Jonathan Clark) - jorge@@laser.satlink.net (Jorge Cwik) - celit!billd@@UCSD.EDU (Bill Davidson) - "Drew Derbyshire" <ahd@@kew.com> - erik@@pdnfido.fidonet.org - Matthew Farwell <dylan@@ibmpcug.co.uk> - dgilbert@@gamiga.guelphnet.dweomer.org (David Gilbert) - kherron@@ms.uky.edu (Kenneth Herron) - Mike Ipatow <mip@@fido.itc.e-burg.su> - Romain Kang <romain@@pyramid.com> - "Jonathan I. Kamens" <jik@@GZA.COM> - "David J. MacKenzie" <djm@@eng.umd.edu> - jum@@helios.de (Jens-Uwe Mager) - peter@@xpoint.ruessel.sub.org (Peter Mandrella) - david nugent <david@@csource.oz.au> - Stephen.Page@@prg.oxford.ac.uk - joey@@tessi.UUCP (Joey Pruett) - James Revell <revell@@uunet.uu.net> - Larry Rosenman <ler@@lerami.lerctr.org> - Rich Salz <rsalz@@bbn.com> - evesg@@etlrips.etl.go.jp (Gjoen Stein) - kls@@ditka.Chicago.COM (Karl Swartz) - Dima Volodin <dvv@@hq.demos.su> - John.Woods@@proteon.com (John Woods) - jon@@console.ais.org (Jon Zeeff) - Eric Ziegast <ziegast@@uunet.uu.net> - ------------------------------- - -End of UUCP Internals Frequently Asked Questions -****************************** -@end format -@end ifset -@c END-OF-FAQ - -@node Hacking, Acknowledgements, Protocols, Top -@chapter Hacking Taylor UUCP - -This chapter provides the briefest of guides to the Taylor UUCP source -code itself. - -@menu -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches -@end menu - -@node System Dependence, Naming Conventions, Hacking, Hacking -@section System Dependence - -The code is carefully segregated into a system independent portion and a -system dependent portion. The system dependent code is in the -@file{unix} subdirectory, and also in the file @file{sysh.unx} (also -known as @file{sysdep.h}). - -With the right configuration parameters, the system independent code -calls only ANSI C functions. Some of the less common ANSI C functions -are also provided in the @file{lib} directory. The replacement function -@code{strtol} in @file{lib/strtol.c} assumes that the characters @kbd{A} -to @kbd{F} and @kbd{a} to @kbd{f} appear in strictly sequential order. -The function @code{igradecmp} in @file{uuconf/grdcmp.c} assumes that the -upper and lower case letters appear in order. Both assumptions are true -for ASCII and EBCDIC, but neither is guaranteed by ANSI C. Disregarding -these caveats, I believe that the system independent portion of the code -is strictly conforming. - -That's not too exciting, since all the work is done in the system -dependent code. I think that this code can conform to POSIX 1003.1, -given the right compilation parameters. I'm a bit less certain about -this, though. - -The code has been used on a 16 bit segmented system with no function -prototypes, so I'm fairly certain that all casts to long and pointers -are done when necessary. - -@node Naming Conventions, Patches, System Dependence, Hacking -@section Naming Conventions - -I use a modified Hungarian naming convention for my variables and -functions. As with all naming conventions, the code is rather opaque if -you are not familiar with it, but becomes clear and easy to use with -time. - -The first character indicates the type of the variable (or function -return value). Sometimes additional characters are used. I use the -following type prefixes: - -@table @samp -@item a -array; the next character is the type of an element -@item b -byte or character -@item c -count of something -@item e -stdio FILE * -@item f -boolean -@item i -generic integer -@item l -double -@item o -file descriptor (as returned by open, creat, etc.) -@item p -generic pointer -@item q -pointer to structure -@item s -structure -@item u -void (function return values only) -@item z -character string -@end table - -A generic pointer (@code{p}) is sometimes a @code{void *}, sometimes a -function pointer in which case the prefix is pf, and sometimes a pointer -to another type, in which case the next character is the type to which -it points (pf is overloaded). - -An array of strings (@code{char *[]}) would be named @code{az} (array of -string). If this array were passed to a function, the function -parameter would be named @code{paz} (pointer to array of string). - -Note that the variable name prefixes do not necessarily indicate the -type of the variable. For example, a variable prefixed with @kbd{i} may -be int, long or short. Similarly, a variable prefixed with @kbd{b} may -be a char or an int; for example, the return value of @code{getchar} -would be caught in an int variable prefixed with @kbd{b}. - -For a non-local variable (extern or file static), the first character -after the type prefix is capitalized. - -Most static variables and functions use another letter after the type -prefix to indicate which module they come from. This is to help -distinguish different names in the debugger. For example, all static -functions in @file{protg.c}, the @samp{g} protocol source code, use a -module prefix of @samp{g}. This isn't too useful, as a number of -modules use a module prefix of @samp{s}. - -@node Patches, , Naming Conventions, Hacking -@section Patches - -I am always grateful for any patches sent in. Much of the flexibility -and portability of the code is due to other people. Please do not -hesitate to send me any changes you have found necessary or useful. - -When sending a patch, please send the output of the Unix @code{diff} -program invoked with the @samp{-c} option (if you have the GNU version -of @code{diff}, use the @samp{-p} option). Always invoke @code{diff} -with the original file first and the modified file second. - -If your @code{diff} does not support @samp{-c} (or you don't have -@code{diff}), send a complete copy of the modified file (if you have -just changed a single function, you can just send the new version of the -function). In particular, please do not send @code{diff} output without -the @samp{-c} option, as it is useless. - -If you have made a number of changes, it is very convenient for me if -you send each change as a separate mail message. Sometimes I will think -that one change is useful but another one is not. If they are in -different messages it is much easier for me to apply one but not the -other. - -I rarely apply the patches directly. Instead I work my way through the -hunks and apply each one separately. This ensures that the naming -remains consistent, and that I understand all the code. - -If you can not follow all these rules, then don't. But if you do, it -makes it more likely that I will incorporate your changes. I am not -paid for my UUCP work, and my available time is unfortunately very -restricted. The package is important to me, and I do what I can, but I -can not do all that I would like, much less all that everybody else -would like. - -Finally, please do not be offended if I do not reply to messages for -some time, even a few weeks. I am often behind on my mail, and if I -think your message deserves a considered reply I will often put it aside -until I have time to deal with it. - -@node Acknowledgements, Index (concepts), Hacking, Top -@chapter Acknowledgements - -This is a list of people who gave help or suggestions while I was -working on the Taylor UUCP project. Appearance on this list does not -constitute endorsement of the program, particularly since some of the -comments were criticisms. I've probably left some people off, and I -apologize for any oversight; it does not mean your contribution was -unappreciated. - -First of all, I would like to thank the people at Infinity Development -Systems (formerly AIRS, which lives on in the domain name) for -permitting me to use their computers and @file{uunet} access. I would -also like to thank Richard Stallman @code{<rms@@gnu.ai.mit.edu>} for -founding the Free Software Foundation, and John Gilmore -@code{<gnu@@cygnus.com>} for writing the initial version of gnuucp which -was a direct inspiration for this somewhat larger project. Chip -Salzenberg @code{<chip@@tct.com>} has contributed many patches. -@ifinfo -Franc,ois -@end ifinfo -@iftex -@tex -Fran\c cois -@end tex -@end iftex -Pinard @code{<pinard@@iro.umontreal.ca>} tirelessly tested the code and -suggested many improvements. He also put together the initial version -of this manual. Doug Evans contributed the zmodem protocol. Marc -Boucher @code{<marc@@CAM.ORG>} contributed the code supporting the pipe -port type. Jorge Cwik @code{jorge@@laser.satlink.net} contributed the -@samp{y} protocol code. Finally, Verbus M. Counts -@code{<verbus@@westmark.com>} and Centel Federal Systems, Inc., deserve -special thanks, since they actually paid me money to port this code to -System III. - -In alphabetical order: - -@example -"Earle F. Ake - SAIC" @code{<ake@@Dayton.SAIC.COM>} -@code{mra@@searchtech.com} (Michael Almond) -@code{cambler@@zeus.calpoly.edu} (Christopher J. Ambler) -Brian W. Antoine @code{<briana@@tau-ceti.isc-br.com>} -@code{jantypas@@soft21.s21.com} (John Antypas) -@code{james@@bigtex.cactus.org} (James Van Artsdalen) -@code{jima@@netcom.com} (Jim Avera) -@code{nba@@sysware.DK} (Niels Baggesen) -@code{uunet!hotmomma!sdb} (Scott Ballantyne) -Zacharias Beckman @code{<zac@@dolphin.com>} -@code{mike@@mbsun.ann-arbor.mi.us} (Mike Bernson) -@code{bob@@usixth.sublink.org} (Roberto Biancardi) -@code{statsci!scott@@coco.ms.washington.edu} (Scott Blachowicz) -@code{bag%wood2.cs.kiev.ua@@relay.ussr.eu.net} (Andrey G Blochintsev) -@code{spider@@Orb.Nashua.NH.US} (Spider Boardman) -Gregory Bond @code{<gnb@@bby.com.au>} -Marc Boucher @code{<marc@@CAM.ORG>} -Ard van Breemen @code{<ard@@cstmel.hobby.nl>} -@code{dean@@coplex.com} (Dean Brooks) -@code{jbrow@@radical.com} (Jim Brownfield) -@code{dave@@dlb.com} (Dave Buck) -@code{gordon@@sneaky.lonestar.org} (Gordon Burditt) -@code{dburr@@sbphy.physics.ucsb.edu} (Donald Burr) -@code{mib@@gnu.ai.mit.edu} (Michael I Bushnell) -Brian Campbell @code{<brianc@@quantum.on.ca>} -Andrew A. Chernov @code{<ache@@astral.msk.su>} -@code{jhc@@iscp.bellcore.com} (Jonathan Clark) -@code{mafc!frank@@bach.helios.de} (Frank Conrad) -Ed Carp @code{<erc@@apple.com>} -@code{mpc@@mbs.linet.org} (Mark Clements) -@code{verbus@@westmark.westmark.com} (Verbus M. Counts) -@code{cbmvax!snark.thyrsus.com!cowan} (John Cowan) -Bob Cunningham @code{<bob@@soest.hawaii.edu>} -@code{jorge@@laser.satlink.net} (Jorge Cwik) -@code{kdburg@@incoahe.hanse.de} (Klaus Dahlenburg) -Damon @code{<d@@exnet.co.uk>} -@code{celit!billd@@UCSD.EDU} (Bill Davidson) -@code{hubert@@arakis.fdn.org} (Hubert Delahaye) -@code{markd@@bushwire.apana.org.au} (Mark Delany) -Allen Delaney @code{<allen@@brc.ubc.ca>} -Gerriet M. Denkmann @code{gerriet@@hazel.north.de} -@code{denny@@dakota.alisa.com} (Bob Denny) -Drew Derbyshire @code{<ahd@@kew.com>} -@code{ssd@@nevets.oau.org} (Steven S. Dick) -@code{gert@@greenie.gold.sub.org} (Gert Doering) -@code{gemini@@geminix.in-berlin.de} (Uwe Doering) -Hans-Dieter Doll @code{<hd2@@Insel.DE>} -@code{deane@@deane.teleride.on.ca} (Dean Edmonds) -Mark W. Eichin @code{<eichin@@cygnus.com>} -@code{erik@@pdnfido.fidonet.org} -Andrew Evans @code{<andrew@@airs.com>} -@code{dje@@cygnus.com} (Doug Evans) -Marc Evans @code{<marc@@synergytics.com>} -Dan Everhart @code{<dan@@dyndata.com>} -@code{kksys!kegworks!lfahnoe@@cs.umn.edu} (Larry Fahnoe) -Matthew Farwell @code{<dylan@@ibmpcug.co.uk>} -@code{fenner@@jazz.psu.edu} (Bill Fenner) -@code{jaf@@inference.com} (Jose A. Fernandez) -"David J. Fiander" @code{<golem!david@@news.lsuc.on.ca>} -Thomas Fischer @code{<batman@@olorin.dark.sub.org>} -Mister Flash @code{<flash@@sam.imash.ras.ru>} -@code{louis@@marco.de} (Ju"rgen Fluk) -@code{erik@@eab.retix.com} (Erik Forsberg) -@code{andy@@scp.caltech.edu} (Andy Fyfe) -Lele Gaifax @code{<piggy@@idea.sublink.org>} -@code{Peter.Galbavy@@micromuse.co.uk} -@code{hunter@@phoenix.pub.uu.oz.au} (James Gardiner [hunter]) -Terry Gardner @code{<cphpcom!tjg01>} -@code{dgilbert@@gamiga.guelphnet.dweomer.org} (David Gilbert) -@code{ol@@infopro.spb.su} (Oleg Girko) -@code{jimmy@@tokyo07.info.com} (Jim Gottlieb) -Benoit Grange @code{<ben@@fizz.fdn.org>} -@code{elg@@elgamy.jpunix.com} (Eric Lee Green) -@code{ryan@@cs.umb.edu} (Daniel R. Guilderson) -@code{greg@@gagme.chi.il.us} (Gregory Gulik) -Richard H. Gumpertz @code{<rhg@@cps.com>} -Scott Guthridge @code{<scooter@@cube.rain.com>} -Michael Haberler @code{<mah@@parrot.prv.univie.ac.at>} -Daniel Hagerty @code{<hag@@eddie.mit.edu>} -@code{jh@@moon.nbn.com} (John Harkin) -@code{guy@@auspex.auspex.com} (Guy Harris) -@code{hsw1@@papa.attmail.com} (Stephen Harris) -Petri Helenius @code{<pete@@fidata.fi>} -@code{gabe@@edi.com} (B. Gabriel Helou) -Bob Hemedinger @code{<bob@@dalek.mwc.com>} -Andrew Herbert @code{<andrew@@werple.pub.uu.oz.au>} -@code{kherron@@ms.uky.edu} (Kenneth Herron) -Peter Honeyman @code{<honey@@citi.umich.edu>} -@code{jhood@@smoke.marlboro.vt.us} (John Hood) -Mike Ipatow @code{<mip@@fido.itc.e-burg.su>} -Bill Irwin @code{<bill@@twg.bc.ca>} -@code{pmcgw!personal-media.co.jp!ishikawa} (Chiaki Ishikawa) -@code{ai@@easy.in-chemnitz.de} (Andreas Israel) -@code{iverson@@lionheart.com} (Tim Iverson) -@code{bei@@dogface.austin.tx.us} (Bob Izenberg) -@code{djamiga!djjames@@fsd.com} (D.J.James) -Rob Janssen @code{<cmgit!rob@@relay.nluug.nl>} -@code{harvee!esj} (Eric S Johansson) -Kevin Johnson @code{<kjj@@pondscum.phx.mcd.mot.com>} -@code{rj@@rainbow.in-berlin.de} (Robert Joop) -Alan Judge @code{<aj@@dec4ie.IEunet.ie>} -@code{chris@@cj_net.in-berlin.de} (Christof Junge) -Romain Kang @code{<romain@@pyramid.com>} -@code{tron@@Veritas.COM} (Ronald S. Karr) -Brendan Kehoe @code{<brendan@@cs.widener.edu>} -@code{warlock@@csuchico.edu} (John Kennedy) -@code{kersing@@nlmug.nl.mugnet.org} (Jac Kersing) -@code{ok@@daveg.PFM-Mainz.de} (Olaf Kirch) -Gabor Kiss @code{<kissg@@sztaki.hu>} -@code{gero@@gkminix.han.de} (Gero Kuhlmann) -@code{rob@@pact.nl} (Rob Kurver) -"C.A. Lademann" @code{<cal@@zls.gtn.com>} -@code{kent@@sparky.IMD.Sterling.COM} (Kent Landfield) -Tin Le @code{<tin@@saigon.com>} -@code{lebaron@@inrs-telecom.uquebec.ca} (Gregory LeBaron) -@code{karl@@sugar.NeoSoft.Com} (Karl Lehenbauer) -@code{alex@@hal.rhein-main.de} (Alexander Lehmann) -@code{merlyn@@digibd.com} (Merlyn LeRoy) -@code{clewis@@ferret.ocunix.on.ca} (Chris Lewis) -@code{gdonl@@ssi1.com} (Don Lewis) -@code{libove@@libove.det.dec.com} (Jay Vassos-Libove) -@code{bruce%blilly@@Broadcast.Sony.COM} (Bruce Lilly) -Godfrey van der Linden @code{<Godfrey_van_der_Linden@@NeXT.COM>} -Ted Lindgreen @code{<tlindgreen@@encore.nl>} -@code{andrew@@cubetech.com} (Andrew Loewenstern) -"Arne Ludwig" @code{<arne@@rrzbu.hanse.de>} -Matthew Lyle @code{<matt@@mips.mitek.com>} -@code{djm@@eng.umd.edu} (David J. MacKenzie) -John R MacMillan @code{<chance!john@@sq.sq.com>} -@code{jum@@helios.de} (Jens-Uwe Mager) -Giles D Malet @code{<shrdlu!gdm@@provar.kwnet.on.ca>} -@code{mem@@mv.MV.COM} (Mark E. Mallett) -@code{pepe@@dit.upm.es} (Jose A. Manas) -@code{peter@@xpoint.ruessel.sub.org} (Peter Mandrella) -@code{martelli@@cadlab.sublink.org} (Alex Martelli) -W Christopher Martin @code{<wcm@@geek.ca.geac.com>} -Yanek Martinson @code{<yanek@@mthvax.cs.miami.edu>} -@code{thomasm@@mechti.wupper.de} (Thomas Mechtersheimer) -@code{jm@@aristote.univ-paris8.fr} (Jean Mehat) -@code{me@@halfab.freiburg.sub.org} (Udo Meyer) -@code{les@@chinet.chi.il.us} (Leslie Mikesell) -@code{bug@@cyberdex.cuug.ab.ca} (Trever Miller) -@code{mmitchel@@digi.lonestar.org} (Mitch Mitchell) -Emmanuel Mogenet @code{<mgix@@krainte.jpn.thomson-di.fr>} -@code{rmohr@@infoac.rmi.de} (Rupert Mohr) -Jason Molenda @code{<molenda@@sequent.com>} -@code{ianm@@icsbelf.co.uk} (Ian Moran) -@code{jmorriso@@bogomips.ee.ubc.ca} (John Paul Morrison) -@code{brian@@ilinx.wimsey.bc.ca} (Brian J. Murrell) -@code{service@@infohh.rmi.de} (Dirk Musstopf) -@code{lyndon@@cs.athabascau.ca} (Lyndon Nerenberg) -@code{rolf@@saans.north.de} (Rolf Nerstheimer) -@code{tom@@smart.bo.open.de} (Thomas Neumann) -@code{mnichols@@pacesetter.com} -Richard E. Nickle @code{<trystro!rick@@Think.COM>} -@code{stephan@@sunlab.ka.sub.org} (Stephan Niemz) -@code{nolan@@helios.unl.edu} (Michael Nolan) -david nugent @code{<david@@csource.oz.au>} -Jim O'Connor @code{<jim@@bahamut.fsc.com>} -@code{kevin%kosman.uucp@@nrc.com} (Kevin O'Gorman) -Petri Ojala @code{<ojala@@funet.fi>} -@code{oneill@@cs.ulowell.edu} (Brian 'Doc' O'Neill) -@code{Stephen.Page@@prg.oxford.ac.uk} -@code{abekas!dragoman!mikep@@decwrl.dec.com} (Mike Park) -Tim Peiffer @code{peiffer@@cs.umn.edu} -@code{don@@blkhole.resun.com} (Don Phillips) -"Mark Pizzolato 415-369-9366" @code{<mark@@infocomm.com>} -John Plate @code{<plate@@infotek.dk>} -@code{dplatt@@ntg.com} (Dave Platt) -@code{eldorado@@tharr.UUCP} (Mark Powell) -Mark Powell @code{<mark@@inet-uk.co.uk>} -@code{pozar@@kumr.lns.com} (Tim Pozar) -@code{joey@@tessi.UUCP} (Joey Pruett) -Paul Pryor @code{ptp@@fallschurch-acirs2.army.mil} -@code{putsch@@uicc.com} (Jeff Putsch) -@code{ar@@nvmr.robin.de} (Andreas Raab) -Jarmo Raiha @code{<jarmo@@ksvltd.FI>} -James Revell @code{<revell@@uunet.uu.net>} -Scott Reynolds @code{<scott@@clmqt.marquette.Mi.US>} -@code{mcr@@Sandelman.OCUnix.On.Ca} (Michael Richardson) -Kenji Rikitake @code{<kenji@@rcac.astem.or.jp>} -@code{arnold@@cc.gatech.edu} (Arnold Robbins) -@code{steve@@Nyongwa.cam.org} (Steve M. Robbins) -Ollivier Robert @code{<Ollivier.Robert@@keltia.frmug.fr.net>} -Serge Robyns @code{<sr@@denkart.be>} -Lawrence E. Rosenman @code{<ler@@lerami.lerctr.org>} -Jeff Ross @code{<jeff@@wisdom.bubble.org>} -Aleksey P. Rudnev @code{<alex@@kiae.su>} -"Heiko W.Rupp" @code{<hwr@@pilhuhn.ka.sub.org>} -@code{wolfgang@@wsrcc.com} (Wolfgang S. Rupprecht) -@code{tbr@@tfic.bc.ca} (Tom Rushworth) -@code{jsacco@@ssl.com} (Joseph E. Sacco) -@code{rsalz@@bbn.com} (Rich Salz) -Curt Sampson @code{<curt@@portal.ca>} -@code{sojurn!mike@@hobbes.cert.sei.cmu.edu} (Mike Sangrey) -Nickolay Saukh @code{<nms@@ussr.EU.net>} -@code{heiko@@lotte.sax.de} (Heiko Schlittermann) -Eric Schnoebelen @code{<eric@@cirr.com>} -@code{russell@@alpha3.ersys.edmonton.ab.ca} (Russell Schulz) -@code{scott@@geom.umn.edu} -Igor V. Semenyuk @code{<iga@@argrd0.argonaut.su>} -Christopher Sawtell @code{<chris@@gerty.equinox.gen.nz>} -@code{schuler@@bds.sub.org} (Bernd Schuler) -@code{uunet!gold.sub.org!root} (Christian Seyb) -@code{s4mjs!mjs@@nirvo.nirvonics.com} (M. J. Shannon Jr.) -@code{shields@@tembel.org} (Michael Shields) -@code{peter@@ficc.ferranti.com} (Peter da Silva) -@code{vince@@victrola.sea.wa.us} (Vince Skahan) -@code{frumious!pat} (Patrick Smith) -@code{roscom!monty@@bu.edu} (Monty Solomon) -@code{sommerfeld@@orchard.medford.ma.us} (Bill Sommerfeld) -Julian Stacey @code{<stacey@@guug.de>} -@code{evesg@@etlrips.etl.go.jp} (Gjoen Stein) -Harlan Stenn @code{<harlan@@mumps.pfcs.com>} -Ralf Stephan @code{<ralf@@ark.abg.sub.org>} -@code{johannes@@titan.westfalen.de} (Johannes Stille) -@code{chs@@antic.apu.fi} (Hannu Strang) -@code{ralf@@reswi.ruhr.de} (Ralf E. Stranzenbach) -@code{sullivan@@Mathcom.com} (S. Sullivan) -Shigeya Suzuki @code{<shigeya@@dink.foretune.co.jp>} -@code{kls@@ditka.Chicago.COM} (Karl Swartz) -@code{swiers@@plains.NoDak.edu} -Oleg Tabarovsky @code{<olg@@olghome.pccentre.msk.su>} -@code{ikeda@@honey.misystems.co.jp} (Takatoshi Ikeda) -John Theus @code{<john@@theus.rain.com>} -@code{rd@@aii.com} (Bob Thrush) -ppKarsten Thygesen @code{<karthy@@dannug.dk>} -Graham Toal @code{<gtoal@@pizzabox.demon.co.uk>} -@code{rmtodd@@servalan.servalan.com} (Richard Todd) -Martin Tomes @code{<mt00@@controls.eurotherm.co.uk>} -Len Tower @code{<tower-prep@@ai.mit.edu>} -Mark Towfiq @code{<justice!towfiq@@Eingedi.Newton.MA.US>} -@code{mju@@mudos.ann-arbor.mi.us} (Marc Unangst) -Matthias Urlichs @code{<urlichs@@smurf.noris.de>} -Tomi Vainio @code{<tomppa@@fidata.fi>} -@code{a3@@a3.xs4all.nl} (Adri Verhoef) -Andrew Vignaux @code{<ajv@@ferrari.datamark.co.nz>} -@code{vogel@@omega.ssw.de} (Andreas Vogel) -Dima Volodin @code{<dvv@@hq.demos.su>} -@code{jos@@bull.nl} (Jos Vos) -@code{jv@@nl.net} (Johan Vromans) -David Vrona @code{<dave@@sashimi.wwa.com>} -@code{Marcel.Waldvogel@@nice.usergroup.ethz.ch} (Marcel Waldvogel) -@code{steve@@nshore.org} (Stephen J. Walick) -@code{syd@@dsinc.dsi.com} (Syd Weinstein) -@code{gerben@@rna.indiv.nluug.nl} (Gerben Wierda) -@code{jbw@@cs.bu.edu} (Joe Wells) -@code{frnkmth!twwells.com!bill} (T. William Wells) -Peter Wemm @code{<Peter_Wemm@@zeus.dialix.oz.au>} -@code{mauxci!eci386!woods@@apple.com} (Greg A. Woods) -@code{John.Woods@@proteon.com} (John Woods) -Michael Yu.Yaroslavtsev @code{<mike@@yaranga.ipmce.su>} -Alexei K. Yushin @code{<root@@july.elis.crimea.ua>} -@code{jon@@console.ais.org} (Jon Zeeff) -Matthias Zepf @code{<agnus@@amylnd.stgt.sub.org>} -Eric Ziegast @code{<uunet!ziegast>} -@end example - -@node Index (concepts), Index (configuration file), Acknowledgements, Top -@unnumbered Concept Index - -@printindex cp - -@node Index (configuration file), , Index (concepts), Top -@unnumbered Configuration File Index - -@printindex fn - -@contents -@bye diff --git a/gnu/libexec/uucp/libunix/MANIFEST b/gnu/libexec/uucp/libunix/MANIFEST deleted file mode 100644 index 342650a..0000000 --- a/gnu/libexec/uucp/libunix/MANIFEST +++ /dev/null @@ -1,84 +0,0 @@ -Makefile.in -MANIFEST -access.c -addbas.c -app3.c -app4.c -basnam.c -bytfre.c -chmod.c -cohtty.c -corrup.c -cusub.c -cwd.c -detach.c -dirent.c -dup2.c -efopen.c -epopen.c -exists.c -failed.c -filnam.c -fsusg.c -fsusg.h -ftw.c -getcwd.c -indir.c -init.c -isdir.c -isfork.c -iswait.c -jobid.c -lcksys.c -link.c -locfil.c -lock.c -loctim.c -mail.c -mkdir.c -mkdirs.c -mode.c -move.c -opensr.c -pause.c -picksb.c -pipe.c -portnm.c -priv.c -proctm.c -recep.c -remove.c -rename.c -rmdir.c -run.c -seq.c -serial.c -signal.c -sindir.c -size.c -sleep.c -splcmd.c -splnam.c -spool.c -spawn.c -srmdir.c -statsb.c -status.c -strerr.c -sync.c -tcp.c -time.c -tli.c -tmpfil.c -trunc.c -uacces.c -ufopen.c -uid.c -ultspl.c -unknwn.c -uuto.c -walk.c -wldcrd.c -work.c -xqtfil.c -xqtsub.c diff --git a/gnu/libexec/uucp/libunix/Makefile b/gnu/libexec/uucp/libunix/Makefile index 750521e..a5d506f 100644 --- a/gnu/libexec/uucp/libunix/Makefile +++ b/gnu/libexec/uucp/libunix/Makefile @@ -2,16 +2,10 @@ # $FreeBSD$ LIB= unix -SRCS = access.c addbas.c app3.c app4.c basnam.c bytfre.c corrup.c \ - chmod.c cohtty.c cusub.c cwd.c detach.c efopen.c epopen.c \ - exists.c failed.c filnam.c fsusg.c indir.c init.c isdir.c \ - isfork.c iswait.c jobid.c lcksys.c link.c locfil.c lock.c \ - loctim.c mail.c mkdirs.c mode.c move.c opensr.c pause.c \ - picksb.c pipe.c portnm.c priv.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 sync.c tcp.c \ - time.c tli.c tmpfil.c trunc.c uacces.c ufopen.c uid.c ultspl.c \ - unknwn.c uuto.c walk.c wldcrd.c work.c xqtfil.c xqtsub.c ftw.c +SRCS= basnam.c cusub.c efopen.c epopen.c init.c isdir.c isfork.c \ + iswait.c lock.c loctim.c mail.c mkdirs.c pause.c pipe.c \ + portnm.c proctm.c serial.c signal.c sindir.c sleep.c spawn.c \ + sync.c tcp.c time.c ufopen.c uid.c CFLAGS+= -I$(.CURDIR)/../common_sources \ -DOWNER=\"$(owner)\" -DSBINDIR=\"$(libxdir)\" diff --git a/gnu/libexec/uucp/libunix/access.c b/gnu/libexec/uucp/libunix/access.c deleted file mode 100644 index c2c0eef..0000000 --- a/gnu/libexec/uucp/libunix/access.c +++ /dev/null @@ -1,83 +0,0 @@ -/* access.c - Check access to files by the user and by the daemon. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* See if the user has access to a file, to prevent the setuid uucp - and uux programs handing out unauthorized access. */ - -boolean -fsysdep_access (zfile) - const char *zfile; -{ - if (access (zfile, R_OK) == 0) - return TRUE; - ulog (LOG_ERROR, "%s: %s", zfile, strerror (errno)); - return FALSE; -} - -/* See if the daemon has access to a file. This is called if a file - is not being transferred to the spool directory, since if the - daemon does not have access the later transfer will fail. We - assume that the daemon will have the same euid (or egid) as the one - we are running under. If our uid (gid) and euid (egid) are the - same, we assume that we have access. Note that is not important - for security, since the check will be (implicitly) done again when - the daemon tries to transfer the file. This routine should work - whether the UUCP programs are installed setuid or setgid. */ - -boolean -fsysdep_daemon_access (zfile) - const char *zfile; -{ - struct stat s; - uid_t ieuid, iuid, iegid, igid; - boolean fok; - - ieuid = geteuid (); - if (ieuid == 0) - return TRUE; - iuid = getuid (); - iegid = getegid (); - igid = getgid (); - - /* If our effective uid and gid are the same as our real uid and - gid, we assume the daemon will have access to the file. */ - if (ieuid == iuid && iegid == igid) - return TRUE; - - if (stat ((char *) zfile, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return FALSE; - } - - /* If our euid is not our uid, but it is the file's uid, see if the - owner has read access. Otherwise, if our egid is not our gid, - but it is the file's gid, see if the group has read access. - Otherwise, see if the world has read access. We know from the - above check that at least one of our euid and egid are different, - so that is the only one we want to check. This check could fail - if the UUCP programs were both setuid and setgid, but why would - they be? */ - if (ieuid != iuid && ieuid == s.st_uid) - fok = (s.st_mode & S_IRUSR) != 0; - else if (iegid != igid && iegid == s.st_gid) - fok = (s.st_mode & S_IRGRP) != 0; - else - fok = (s.st_mode & S_IROTH) != 0; - - if (! fok) - { - ulog (LOG_ERROR, "%s: cannot be read by daemon", zfile); - return FALSE; - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/addbas.c b/gnu/libexec/uucp/libunix/addbas.c deleted file mode 100644 index 8597918..0000000 --- a/gnu/libexec/uucp/libunix/addbas.c +++ /dev/null @@ -1,50 +0,0 @@ -/* addbas.c - If we have a directory, add in a base name. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* If we have a directory, add a base name. */ - -char * -zsysdep_add_base (zfile, zname) - const char *zfile; - const char *zname; -{ - size_t clen; - const char *zlook; - char *zfree; - char *zret; - -#if DEBUG > 0 - if (*zfile != '/') - ulog (LOG_FATAL, "zsysdep_add_base: %s: Can't happen", zfile); -#endif - - clen = strlen (zfile); - - if (zfile[clen - 1] != '/') - { - if (! fsysdep_directory (zfile)) - return zbufcpy (zfile); - zfree = NULL; - } - else - { - /* Trim out the trailing '/'. */ - zfree = zbufcpy (zfile); - zfree[clen - 1] = '\0'; - zfile = zfree; - } - - zlook = strrchr (zname, '/'); - if (zlook != NULL) - zname = zlook + 1; - - zret = zsysdep_in_dir (zfile, zname); - ubuffree (zfree); - return zret; -} diff --git a/gnu/libexec/uucp/libunix/app3.c b/gnu/libexec/uucp/libunix/app3.c deleted file mode 100644 index f3c3555..0000000 --- a/gnu/libexec/uucp/libunix/app3.c +++ /dev/null @@ -1,32 +0,0 @@ -/* app3.c - Stick two directories and a file name together. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -char * -zsappend3 (zdir1, zdir2, zfile) - const char *zdir1; - const char *zdir2; - const char *zfile; -{ - size_t cdir1, cdir2, cfile; - char *zret; - - cdir1 = strlen (zdir1); - cdir2 = strlen (zdir2); - cfile = strlen (zfile); - zret = zbufalc (cdir1 + cdir2 + cfile + 3); - 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] = '/'; - zret[cdir1 + cdir2 + 1] = '/'; - zret[cdir1 + cdir2 + cfile + 2] = '\0'; - return zret; -} diff --git a/gnu/libexec/uucp/libunix/app4.c b/gnu/libexec/uucp/libunix/app4.c deleted file mode 100644 index d3a243f..0000000 --- a/gnu/libexec/uucp/libunix/app4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* app4.c - Stick three directories and a file name together. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -char * -zsappend4 (zdir1, zdir2, zdir3, zfile) - const char *zdir1; - const char *zdir2; - const char *zdir3; - const char *zfile; -{ - size_t cdir1, cdir2, cdir3, cfile; - char *zret; - - cdir1 = strlen (zdir1); - cdir2 = strlen (zdir2); - cdir3 = strlen (zdir3); - cfile = strlen (zfile); - zret = zbufalc (cdir1 + cdir2 + cdir3 + cfile + 4); - 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); - zret[cdir1] = '/'; - zret[cdir1 + cdir2 + 1] = '/'; - zret[cdir1 + cdir2 + cdir3 + 2] = '/'; - zret[cdir1 + cdir2 + cdir3 + cfile + 3] = '\0'; - return zret; -} diff --git a/gnu/libexec/uucp/libunix/bytfre.c b/gnu/libexec/uucp/libunix/bytfre.c deleted file mode 100644 index 3091e7a..0000000 --- a/gnu/libexec/uucp/libunix/bytfre.c +++ /dev/null @@ -1,27 +0,0 @@ -/* bytfre.c - Get the number of bytes free on a file system. */ - -#include "uucp.h" - -#include "system.h" -#include "sysdep.h" -#include "fsusg.h" - -#if HAVE_LIMITS_H -#include <limits.h> -#else -#define LONG_MAX 2147483647 -#endif - -long -csysdep_bytes_free (zfile) - const char *zfile; -{ - struct fs_usage s; - - if (get_fs_usage ((char *) zfile, (char *) NULL, &s) < 0) - return -1; - if (s.fsu_bavail >= LONG_MAX / (long) 512) - return LONG_MAX; - return s.fsu_bavail * (long) 512; -} diff --git a/gnu/libexec/uucp/libunix/chmod.c b/gnu/libexec/uucp/libunix/chmod.c deleted file mode 100644 index cf69f3e..0000000 --- a/gnu/libexec/uucp/libunix/chmod.c +++ /dev/null @@ -1,25 +0,0 @@ -/* chmod.c - Change the mode of a file. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* Change the mode of a file. */ - -boolean -fsysdep_change_mode (zfile, imode) - const char *zfile; - unsigned int imode; -{ - if (chmod ((char *) zfile, imode) < 0) - { - ulog (LOG_ERROR, "chmod (%s): %s", zfile, strerror (errno)); - return FALSE; - } - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/cohtty.c b/gnu/libexec/uucp/libunix/cohtty.c deleted file mode 100644 index 9cbe220..0000000 --- a/gnu/libexec/uucp/libunix/cohtty.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Coherent tty locking support. This file was contributed by Bob - Hemedinger <bob@dalek.mwc.com> of Mark Williams Corporation and - lightly edited by Ian Lance Taylor. */ - -/* $FreeBSD$ */ - -/* The bottom part of this file is lock.c. - * This is a hacked lock.c. A full lock.c can be found in the libmisc sources - * under /usr/src/misc.tar.Z. - * - * These are for checking for the existence of locks: - * lockexist(resource) - * lockttyexist(ttyname) - */ - -#include "uucp.h" - -#if HAVE_COHERENT_LOCKFILES - -/* cohtty.c: Given a serial device name, read /etc/ttys and determine if - * the device is already enabled. If it is, disable the - * device and return a string so that it can be re-enabled - * at the completion of the uucico session as part of the - * function that resets the serial device before uucico - * terminates. - * - */ - -#include "uudefs.h" -#include "sysdep.h" - -#include <ctype.h> -#include <access.h> -#include <paths.h> - -/* fscoherent_disable_tty() is a COHERENT specific function. It takes the name - * of a serial device and then scans /etc/ttys for a match. If it finds one, - * it checks the first field of the entry. If it is a '1', then it will disable - * the port and set a flag. The flag will be checked later when uucico wants to - * 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; - char **pzenable; -{ - - -struct ttyentry{ /* this is an /etc/ttys entry */ - char enable_disable[1]; - char remote_local[1]; - char baud_rate[1]; - char tty_device[16]; -}; - -struct ttyentry sought_tty; - -int x,y,z; /* dummy */ -FILE * infp; /* this will point to /etc/ttys */ -char disable_command[66]; /* this will be the disable command - * passed to the system. - */ -char enable_device[16]; /* this will hold our device name - * to enable. - */ - - *pzenable = NULL; - - strcpy(enable_device,""); /* initialize our strings */ - strcpy(sought_tty.tty_device,""); - - if( (infp = fopen("/etc/ttys","r")) == NULL){ - ulog(LOG_ERROR,"Error: check_disable_tty: failed to open /etc/ttys\n"); - return FALSE; - } - - while (NULL !=(fgets(&sought_tty, sizeof (sought_tty), infp ))){ - sought_tty.tty_device[strlen(sought_tty.tty_device) -1] = '\0'; - strcpy(enable_device,sought_tty.tty_device); - - /* we must strip away the suffix to the com port name or - * we will never find a match. For example, if we are passed - * /dev/com4l to call out with and the port is already enabled, - * 9/10 the port enabled will be com4r. After we strip away the - * suffix of the port found in /etc/ttys, then we can test - * if the base port name appears in the device name string - * passed to us. - */ - - for(z = strlen(sought_tty.tty_device) ; z > 0 ; z--){ - if(isdigit(sought_tty.tty_device[z])){ - break; - } - } - y = strlen(sought_tty.tty_device); - for(x = z+1 ; x <= y; x++){ - sought_tty.tty_device[x] = '\0'; - } - - -/* ulog(LOG_NORMAL,"found device {%s}\n",sought_tty.tty_device); */ - if(strstr(zdevice, sought_tty.tty_device)){ - if(sought_tty.enable_disable[0] == '1'){ - ulog(LOG_NORMAL, "coh_tty: Disabling device %s {%s}\n", - zdevice, sought_tty.tty_device); - sprintf(disable_command, "/etc/disable %s",enable_device); - { - pid_t ipid; - const char *azargs[3]; - int aidescs[3]; - - azargs[0] = "/etc/disable"; - azargs[1] = enable_device; - azargs[2] = NULL; - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - ipid = ixsspawn (azargs, aidescs, TRUE, - FALSE, - (const char *) NULL, TRUE, - TRUE, - (const char *) NULL, - (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - x = 1; - else - x = ixswait ((unsigned long) ipid, - (const char *) NULL); - } - *pzenable = zbufalc (sizeof _PATH_DEV - + strlen (enable_device)); - sprintf(*pzenable,"%s%s",_PATH_DEV, - enable_device); -/* ulog(LOG_NORMAL,"Enable string is {%s}",*pzenable); */ - return TRUE; - }else{ - /* device not enabled */ - return TRUE; - } - } - } - return TRUE; /* no ttys entry found */ -} - -/* The following is COHERENT 4.0 specific. It is used to test for any - * existing lockfiles on a port which would have been created by init - * when a user logs into a port. - */ - -#define LOCKSIG 9 /* Significant Chars of Lockable Resources. */ -#define LOKFLEN 64 /* Max Length of UUCP Lock File Name. */ - -#define LOCKPRE "LCK.." -#define PIDLEN 6 /* Maximum length of string representing a pid. */ - -#ifndef LOCKDIR -#define LOCKDIR SPOOLDIR -#endif - -/* There is a special version of DEVMASK for the PE multiport driver - * because of the peculiar way it uses the minor device number. For - * all other drivers, the lower 5 bits describe the physical port-- - * the upper 3 bits give attributes for the port. - */ - -#define PE_DRIVER 21 /* Major device number for the PE driver. */ -#define PE_DEVMASK 0x3f /* PE driver minor device mask. */ -#define DEVMASK 0x1f /* Minor device mask. */ - -/* - * Generates a resource name for locking, based on the major number - * and the lower 4 bits of the minor number of the tty device. - * - * Builds the name in buff as two "." separated decimal numbers. - * Returns NULL on failure, buff on success. - */ -static char * -gen_res_name(path, buff) -char *path; -char *buff; -{ - struct stat sbuf; - int status; - - if (0 != (status = stat(path, &sbuf))) { - /* Can't stat the file. */ - return (NULL); - } - - if (PE_DRIVER == major(sbuf.st_rdev)) { - sprintf(buff, "%d.%d", major(sbuf.st_rdev), - PE_DEVMASK & minor(sbuf.st_rdev)); - } else { - sprintf(buff, "%d.%d", major(sbuf.st_rdev), - DEVMASK & minor(sbuf.st_rdev)); - } - - return(buff); -} /* gen_res_name */ - -/* - * lockexist(resource) char *resource; - * - * Test for existance of a lock on the given resource. - * - * Returns: (1) Resource is locked. - * (0) Resource is not locked. - */ - -static boolean -lockexist(resource) -const char *resource; -{ - char lockfn[LOKFLEN]; - - if ( resource == NULL ) - return(0); - sprintf(lockfn, "%s/%s%.*s", LOCKDIR, LOCKPRE, LOCKSIG, resource); - - return (!access(lockfn, AEXISTS)); -} /* lockexist() */ - -/* - * lockttyexist(ttyname) char *ttyname; - * - * Test for existance of a lock on the given tty. - * - * Returns: (1) Resource is locked. - * (0) Resource is not locked. - */ -boolean -lockttyexist(ttyn) -const char *ttyn; -{ - char resource[LOKFLEN]; - char filename[LOKFLEN]; - - sprintf(filename, "%s%s", _PATH_DEV, ttyn); - if (NULL == gen_res_name(filename, resource)){ - return(0); /* Non-existent tty can not be locked :-) */ - } - - return(lockexist(resource)); -} /* lockttyexist() */ - -#endif /* HAVE_COHERENT_LOCKFILES */ diff --git a/gnu/libexec/uucp/libunix/corrup.c b/gnu/libexec/uucp/libunix/corrup.c deleted file mode 100644 index 87f19e6..0000000 --- a/gnu/libexec/uucp/libunix/corrup.c +++ /dev/null @@ -1,33 +0,0 @@ -/* 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/cwd.c b/gnu/libexec/uucp/libunix/cwd.c deleted file mode 100644 index 71d05d1..0000000 --- a/gnu/libexec/uucp/libunix/cwd.c +++ /dev/null @@ -1,58 +0,0 @@ -/* cwd.c - Routines dealing with the current working directory. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* See whether running this file through zsysdep_add_cwd would require - knowing the current working directory. This is used to avoid - determining the cwd if it will not be needed. */ - -boolean -fsysdep_needs_cwd (zfile) - const char *zfile; -{ - return *zfile != '/' && *zfile != '~'; -} - -/* Expand a local file, putting relative pathnames in the current - working directory. Note that ~/file is placed in the public - directory, rather than in the user's home directory. This is - consistent with other UUCP packages. */ - -char * -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, pfbadname); - else - return zsysdep_add_cwd (zfile); -} - -/* Add the current working directory to a remote file name. */ - -char * -zsysdep_add_cwd (zfile) - const char *zfile; -{ - if (*zfile == '/' || *zfile == '~') - return zbufcpy (zfile); - - if (zScwd == NULL) - { - ulog (LOG_ERROR, "Can't determine current directory"); - return NULL; - } - - return zsysdep_in_dir (zScwd, zfile); -} diff --git a/gnu/libexec/uucp/libunix/detach.c b/gnu/libexec/uucp/libunix/detach.c deleted file mode 100644 index ad753b4..0000000 --- a/gnu/libexec/uucp/libunix/detach.c +++ /dev/null @@ -1,184 +0,0 @@ -/* detach.c - Detach from the controlling terminal. - - Copyright (C) 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -/* $FreeBSD$ */ - -#include "uucp.h" - -#include "uudefs.h" -#include "system.h" -#include "sysdep.h" - -#include <errno.h> -#include <paths.h> - -#if HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif - -#ifdef TIOCNOTTY -#define HAVE_TIOCNOTTY 1 -#else -#define HAVE_TIOCNOTTY 0 -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#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 - signals from the port it calls out on. It is also called by uucico - just before it starts uuxqt, so that uuxqt is completely - independent of the terminal. */ - -void -usysdep_detach () -{ - pid_t igrp; - - /* Make sure that we can open the log file. We do this now so that, - if we can't, a message will be written to stderr. After we leave - this routine, stderr will be closed. */ - ulog (LOG_NORMAL, (const char *) NULL); - - /* Make sure we are not a process group leader. */ -#if HAVE_BSD_PGRP - igrp = getpgrp (0); -#else - igrp = getpgrp (); -#endif - - if (igrp == getpid ()) - { - boolean fignored; - pid_t ipid; - - /* Ignore SIGHUP, since our process group leader is about to - die. */ - usset_signal (SIGHUP, SIG_IGN, FALSE, &fignored); - - ipid = ixsfork (); - if (ipid < 0) - ulog (LOG_FATAL, "fork: %s", strerror (errno)); - - if (ipid != 0) - _exit (EXIT_SUCCESS); - - /* We'll always wind up as a child of process number 1, right? - Right? We have to wait for our parent to die before - reenabling SIGHUP. */ - while (getppid () != 1) - sleep (1); - - ipid = getpid (); - ulog_id (ipid); - - /* Restore SIGHUP catcher if it wasn't being ignored. */ - if (! fignored) - usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL); - - DEBUG_MESSAGE2 (DEBUG_PORT, - "usysdep_detach: Forked; old PID %ld, new pid %ld", - (long) igrp, (long) ipid); - } - -#if ! HAVE_SETSID && HAVE_TIOCNOTTY - /* Lose the original controlling terminal as well as our process - group. */ - { - int o; - - o = open ((char *) _PATH_TTY, O_RDONLY); - if (o >= 0) - { - (void) ioctl (o, TIOCNOTTY, (char *) NULL); - (void) close (o); - } - } -#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. */ - (void) close (0); - (void) close (1); - (void) close (2); - if (open ((char *) _PATH_DEVNULL, O_RDONLY) != 0 - || open ((char *) _PATH_DEVNULL, O_WRONLY) != 1 - || open ((char *) _PATH_DEVNULL, O_WRONLY) != 2) - ulog (LOG_FATAL, "open (%s): %s", _PATH_DEVNULL, strerror (errno)); - -#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. */ - if (setsid () < 0) - ulog (LOG_ERROR, "setsid: %s", strerror (errno)); - -#else /* ! HAVE_SETSID */ - -#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) -#endif - { - /* Some systems seem to give EPERM errors inappropriately. */ - if (errno != EPERM) - ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); - } - -#endif /* ! HAVE_SETSID */ - - /* At this point we have completely detached from our controlling - terminal. The next terminal device we open will probably become - our controlling terminal. */ -} diff --git a/gnu/libexec/uucp/libunix/dirent.c b/gnu/libexec/uucp/libunix/dirent.c deleted file mode 100644 index 7ad0ec6..0000000 --- a/gnu/libexec/uucp/libunix/dirent.c +++ /dev/null @@ -1,123 +0,0 @@ -/* dirent.c - Replacements for opendir, readdir and closedir for the original - Unix filesystem only. - - Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.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 - -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -/* Simple emulations of opendir/readdir/closedir for systems which - have the original format of Unix directories. It's probably better - to get Doug Gwyn's public domain set of emulation functions. */ - -DIR * -opendir (zdir) - const char *zdir; -{ - int o; - struct stat s; - DIR *qret; - - o = open ((char *) zdir, O_RDONLY | O_NOCTTY, 0); - if (o < 0) - return NULL; - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0 - || fstat (o, &s) < 0) - { - int isave; - - isave = errno; - (void) close (o); - errno = isave; - return NULL; - } - if (! S_ISDIR (s.st_mode)) - { - (void) close (o); - errno = ENOTDIR; - return NULL; - } - qret = (DIR *) xmalloc (sizeof (DIR)); - qret->o = o; - return qret; -} - -struct dirent * -readdir (q) - DIR *q; -{ - struct direct sdir; - int cgot; - - do - { - cgot = read (q->o, &sdir, sizeof (struct direct)); - if (cgot <= 0) - return NULL; - if (cgot != sizeof (struct direct)) - { - errno = ENOENT; - return NULL; - } - } - while (sdir.d_ino == 0); - - strncpy (q->s.d_name, sdir.d_name, DIRSIZ); - q->s.d_name[DIRSIZ] = '\0'; - return &q->s; -} - -int -closedir (q) - DIR *q; -{ - int o; - - o = q->o; - xfree (q); - return close (o); -} diff --git a/gnu/libexec/uucp/libunix/dup2.c b/gnu/libexec/uucp/libunix/dup2.c deleted file mode 100644 index a3fcea5..0000000 --- a/gnu/libexec/uucp/libunix/dup2.c +++ /dev/null @@ -1,69 +0,0 @@ -/* dup2.c - The Unix dup2 function, for systems which only have dup. - - Copyright (C) 1985, 1986, 1987, 1988, 1990 Free Software Foundation, Inc. - - 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.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 - -/* I basically took this from the emacs 18.57 distribution, although I - cleaned it up a bit and made it POSIX compliant. */ - -int -dup2 (oold, onew) - int oold; - int onew; -{ - if (oold == onew) - return onew; - (void) close (onew); - -#ifdef F_DUPFD - return fcntl (oold, F_DUPFD, onew); -#else - { - int onext, oret, isave; - - onext = dup (oold); - if (onext == onew) - return onext; - if (onext < 0) - return -1; - oret = dup2 (oold, onew); - isave = errno; - (void) close (onext); - errno = isave; - return oret; - } -#endif -} diff --git a/gnu/libexec/uucp/libunix/exists.c b/gnu/libexec/uucp/libunix/exists.c deleted file mode 100644 index 9473922..0000000 --- a/gnu/libexec/uucp/libunix/exists.c +++ /dev/null @@ -1,16 +0,0 @@ -/* exists.c - Check whether a file exists. */ - -#include "uucp.h" - -#include "sysdep.h" -#include "system.h" - -boolean -fsysdep_file_exists (zfile) - const char *zfile; -{ - struct stat s; - - return stat ((char *) zfile, &s) == 0; -} diff --git a/gnu/libexec/uucp/libunix/failed.c b/gnu/libexec/uucp/libunix/failed.c deleted file mode 100644 index 66c98a8..0000000 --- a/gnu/libexec/uucp/libunix/failed.c +++ /dev/null @@ -1,26 +0,0 @@ -/* failed.c - Save a file in the .Failed directory. */ - -#include "uucp.h" - -#include "sysdep.h" -#include "uudefs.h" -#include "system.h" - -char * -zsysdep_save_failed_file (zfile) - const char *zfile; -{ - char *zto; - - zto = zsappend3 (zSspooldir, FAILEDDIR, zfile); - - 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/filnam.c b/gnu/libexec/uucp/libunix/filnam.c deleted file mode 100644 index 6f804bb..0000000 --- a/gnu/libexec/uucp/libunix/filnam.c +++ /dev/null @@ -1,584 +0,0 @@ -/* filnam.c - Get names to use for UUCP files. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -/* We need a definition for SEEK_SET. */ - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -/* We use POSIX style fcntl locks if they are available, unless - O_CREAT is not defined. We could use them in the latter case, but - the code would have to become more complex to avoid races - concerning the use of creat. It is very unlikely that there is any - system which does have POSIX style locking but does not have - O_CREAT. */ -#if ! HAVE_BROKEN_SETLKW -#ifdef F_SETLKW -#ifdef O_CREAT -#define USE_POSIX_LOCKS 1 -#endif -#endif -#endif -#ifndef USE_POSIX_LOCKS -#define USE_POSIX_LOCKS 0 -#endif - -/* External functions. */ -#ifndef lseek -extern off_t lseek (); -#endif - -#define ZCHARS \ - "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - -/* Local functions. */ - -static boolean fscmd_seq P((const char *zsystem, char *zseq)); -static char *zsfile_name P((int btype, const char *zsystem, - const char *zlocalname, int bgrade, - boolean fxqt, char *ztname, char *zdname, - char *zxname)); - -/* Get a new command sequence number (this is not a sequence number to - be used for communicating with another system, but a sequence - number to be used when generating the name of a command file). - The sequence number is placed into zseq, which should be five - characters long. */ - -static boolean -fscmd_seq (zsystem, zseq) - const char *zsystem; - char *zseq; -{ - int cdelay; - char *zfree; - const char *zfile; - int o; - boolean flockfile; - int i; - boolean fret; - - cdelay = 5; - -#if ! USE_POSIX_LOCKS - { - boolean ferr; - - /* Lock the sequence file. */ - while (! fsdo_lock ("LCK..SEQ", TRUE, &ferr)) - { - if (ferr || FGOT_SIGNAL ()) - return FALSE; - sleep (cdelay); - if (cdelay < 60) - ++cdelay; - } - } -#endif - - zfree = NULL; - -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - zfile = "SEQF"; -#endif -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - zfree = zsysdep_in_dir (".Sequence", zsystem); - zfile = zfree; -#endif -#if SPOOLDIR_ULTRIX - if (! fsultrix_has_spool (zsystem)) - zfile = "sys/DEFAULT/.SEQF"; - else - { - zfree = zsappend3 ("sys", zsystem, ".SEQF"); - zfile = zfree; - } -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - zfree = zsysdep_in_dir (zsystem, "SEQF"); - zfile = zfree; -#endif /* SPOOLDIR_TAYLOR */ - -#ifdef O_CREAT - o = open ((char *) zfile, O_RDWR | O_CREAT | O_NOCTTY, IPRIVATE_FILE_MODE); -#else - o = open ((char *) zfile, O_RDWR | O_NOCTTY); - if (o < 0 && errno == ENOENT) - { - o = creat ((char *) zfile, IPRIVATE_FILE_MODE); - if (o >= 0) - { - (void) close (o); - o = open ((char *) zfile, O_RDWR | O_NOCTTY); - } - } -#endif - - if (o < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (zfile, FALSE)) - { -#if ! USE_POSIX_LOCKS - (void) fsdo_unlock ("LCK..SEQ", TRUE); -#endif - return FALSE; - } -#ifdef O_CREAT - o = open ((char *) zfile, - O_RDWR | O_CREAT | O_NOCTTY, - IPRIVATE_FILE_MODE); -#else - o = creat ((char *) zfile, IPRIVATE_FILE_MODE); - if (o >= 0) - { - (void) close (o); - o = open ((char *) zfile, O_RDWR | O_NOCTTY); - } -#endif - } - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); -#if ! USE_POSIX_LOCKS - (void) fsdo_unlock ("LCK..SEQ", TRUE); -#endif - return FALSE; - } - } - -#if ! USE_POSIX_LOCKS - flockfile = TRUE; -#else - { - struct flock slock; - - flockfile = FALSE; - - slock.l_type = F_WRLCK; - slock.l_whence = SEEK_SET; - slock.l_start = 0; - slock.l_len = 0; - while (fcntl (o, F_SETLKW, &slock) == -1) - { - boolean fagain; - - /* Some systems define F_SETLKW, but it does not work. We try - to catch those systems at runtime, and revert to using a - lock file. */ - if (errno == EINVAL) - { - boolean ferr; - - /* Lock the sequence file. */ - while (! fsdo_lock ("LCK..SEQ", TRUE, &ferr)) - { - if (ferr || FGOT_SIGNAL ()) - { - (void) close (o); - return FALSE; - } - sleep (cdelay); - if (cdelay < 60) - ++cdelay; - } - - flockfile = TRUE; - - break; - } - - fagain = FALSE; - if (errno == ENOMEM) - fagain = TRUE; -#ifdef ENOLCK - if (errno == ENOLCK) - fagain = TRUE; -#endif -#ifdef ENOSPC - if (errno == ENOSPC) - fagain = TRUE; -#endif - if (fagain) - { - sleep (cdelay); - if (cdelay < 60) - ++cdelay; - continue; - } - ulog (LOG_ERROR, "Locking %s: %s", zfile, strerror (errno)); - (void) close (o); - return FALSE; - } - } -#endif - - if (read (o, zseq, CSEQLEN) != CSEQLEN) - strcpy (zseq, "0000"); - zseq[CSEQLEN] = '\0'; - - /* We must add one to the sequence number and return the new value. - On Ultrix, arbitrary characters are allowed in the sequence - number. On other systems, the sequence number apparently must be - in hex. */ -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_HDB || SPOOLDIR_SVR4 - i = (int) strtol (zseq, (char **) NULL, 16); - ++i; - if (i > 0xffff) - i = 0; - /* The sprintf argument has CSEQLEN built into it. */ - sprintf (zseq, "%04x", (unsigned int) i); -#endif -#if SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR - for (i = CSEQLEN - 1; i >= 0; i--) - { - const char *zdig; - - zdig = strchr (ZCHARS, zseq[i]); - if (zdig == NULL || zdig[0] == '\0' || zdig[1] == '\0') - zseq[i] = '0'; - else - { - zseq[i] = zdig[1]; - break; - } - } -#endif /* SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR */ - - fret = TRUE; - - if (lseek (o, (off_t) 0, SEEK_SET) < 0 - || write (o, zseq, CSEQLEN) != CSEQLEN - || close (o) < 0) - { - ulog (LOG_ERROR, "lseek or write or close %s: %s", - zfile, strerror (errno)); - (void) close (o); - fret = FALSE; - } - - if (flockfile) - (void) fsdo_unlock ("LCK..SEQ", TRUE); - - ubuffree (zfree); - - return fret; -} - -/* Get the name of a command or data file for a remote system. The - btype argument should be C for a command file or D for a data file. - If the grade of a data file is X, it is assumed that this is going - to become an execute file on some other system. The zsystem - argument is the system that the file will be transferred to. The - ztname argument will be set to a file name that could be passed to - zsysdep_spool_file_name. The zdname argument, if not NULL, will be - set to a data file name appropriate for the remote system. The - zxname argument, if not NULL, will be set to the name of an execute - file on the remote system. None of the names will be more than 14 - characters long. */ - -/*ARGSUSED*/ -static char * -zsfile_name (btype, zsystem, zlocalname, bgrade, fxqt, ztname, zdname, zxname) - int btype; - const char *zsystem; - const char *zlocalname; - int bgrade; - boolean fxqt; - char *ztname; - char *zdname; - char *zxname; -{ - char abseq[CSEQLEN + 1]; - char absimple[11 + CSEQLEN]; - char *zname; - - if (zlocalname == NULL) - zlocalname = zSlocalname; - - while (TRUE) - { - if (! fscmd_seq (zsystem, abseq)) - return NULL; - - if (btype == 'C') - { -#if ! SPOOLDIR_TAYLOR - sprintf (absimple, "C.%.7s%c%s", zsystem, bgrade, abseq); -#else - sprintf (absimple, "C.%c%s", bgrade, abseq); -#endif - } - else if (btype == 'D') - { - /* This name doesn't really matter that much; it's just the - name we use on the local system. The name we use on the - remote system, which we return in zdname, should contain - our system name so that remote UUCP's running SPOOLDIR_V2 - and the like can distinguish while files come from which - systems. */ -#if SPOOLDIR_SVR4 - sprintf (absimple, "D.%.7s%c%s", zsystem, bgrade, abseq); -#else /* ! SPOOLDIR_SVR4 */ -#if ! SPOOLDIR_TAYLOR - sprintf (absimple, "D.%.7s%c%s", zlocalname, bgrade, abseq); -#else /* SPOOLDIR_TAYLOR */ - if (fxqt) - sprintf (absimple, "D.X%s", abseq); - else - sprintf (absimple, "D.%s", abseq); -#endif /* SPOOLDIR_TAYLOR */ -#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */ - } -#if DEBUG > 0 - else - ulog (LOG_FATAL, "zsfile_name: Can't happen"); -#endif - - zname = zsfind_file (absimple, zsystem, bgrade); - if (zname == NULL) - return NULL; - - if (! fsysdep_file_exists (zname)) - break; - - ubuffree (zname); - } - - if (ztname != NULL) - strcpy (ztname, absimple); - - if (zdname != NULL) - sprintf (zdname, "D.%.7s%c%s", zlocalname, bgrade, abseq); - - if (zxname != NULL) - sprintf (zxname, "X.%.7s%c%s", zlocalname, bgrade, abseq); - - return zname; -} - -/* Return a name to use for a data file to be copied to another - system. The name returned will be for a real file. The zlocalname - argument is the local name as seen by the remote system, the bgrade - argument is the file grade, and the fxqt argument is TRUE if this - file will become an execution file. The ztname argument, if not - NULL, will be set to a name that could be passed to - zsysdep_spool_file_name to get back the return value of this - function. The zdname argument, if not NULL, will be set to a name - that the file could be given on another system. The zxname - argument, if not NULL, will be set to a name for an execute file on - another system. */ - -char * -zsysdep_data_file_name (qsys, zlocalname, bgrade, fxqt, ztname, zdname, - zxname) - const struct uuconf_system *qsys; - const char *zlocalname; - int bgrade; - boolean fxqt; - char *ztname; - char *zdname; - char *zxname; -{ - return zsfile_name ('D', qsys->uuconf_zname, zlocalname, bgrade, fxqt, - ztname, zdname, zxname); -} - -#if SPOOLDIR_TAYLOR - -/* Write out a number in base 62 into a given number of characters, - right justified with zero fill. This is used by zscmd_file if - SPOOLDIR_TAYLOR. */ - -static void usput62 P((long i, char *, int c)); - -static void -usput62 (i, z, c) - long i; - char *z; - int c; -{ - for (--c; c >= 0; --c) - { - int d; - - d = i % 62; - i /= 62; - if (d < 26) - z[c] = 'A' + d; - else if (d < 52) - z[c] = 'a' + d - 26; - else - z[c] = '0' + d - 52; - } -} - -#endif /* SPOOLDIR_TAYLOR */ - -/* Get a command file name. */ - -char * -zscmd_file (qsys, bgrade) - const struct uuconf_system *qsys; - int bgrade; -{ -#if ! SPOOLDIR_TAYLOR - return zsfile_name ('C', qsys->uuconf_zname, (const char *) NULL, - bgrade, FALSE, (char *) NULL, (char *) NULL, - (char *) NULL); -#else - char *zname; - long isecs, imicros; - pid_t ipid; - - /* This file name is never seen by the remote system, so we don't - actually need to get a sequence number for it. We just need to - get a file name which is unique for this system. We don't try - this optimization for other spool directory formats, mainly due - to compatibility concerns. It would be possible for HDB and SVR4 - spool directory formats. - - We get a unique name by combining the process ID and the current - time. The file name must start with C.g, where g is the grade. - Note that although it is likely that this name will be unique, it - is not guaranteed, so the caller must be careful. */ - - isecs = ixsysdep_time (&imicros); - ipid = getpid (); - - /* We are going to represent the file name as a series of numbers in - base 62 (using the alphanumeric characters). The maximum file - name length is 14 characters, so we may use 11. We use 3 for the - seconds within the day, 3 for the microseconds, and 5 for the - process ID. */ - - /* Cut the seconds down to a number within a day (maximum value - 86399 < 62 ** 3 == 238328). */ - isecs %= (long) 24 * (long) 60 * (long) 60; - /* Divide the microseconds (max 999999) by 5 to make sure they are - less than 62 ** 3. */ - imicros %= 1000000; - imicros /= 5; - - while (TRUE) - { - char ab[15]; - - ab[0] = 'C'; - ab[1] = '.'; - ab[2] = bgrade; - usput62 (isecs, ab + 3, 3); - usput62 (imicros, ab + 6, 3); - usput62 ((long) ipid, ab + 9, 5); - ab[14] = '\0'; - - zname = zsfind_file (ab, qsys->uuconf_zname, bgrade); - if (zname == NULL) - return NULL; - - if (! fsysdep_file_exists (zname)) - break; - - ubuffree (zname); - - /* We hit a duplicate. Move backward in time until we find an - available name. Note that there is still a theoretical race - condition, since 5 base 62 digits might not be enough for the - process ID, and some other process might be running these - checks at the same time as we are. The caller must deal with - this. */ - if (imicros == 0) - { - imicros = (long) 62 * (long) 62 * (long) 62; - if (isecs == 0) - isecs = (long) 62 * (long) 62 * (long) 62; - --isecs; - } - --imicros; - } - - return zname; - -#endif -} - -/* Return a name for an execute file to be created locally. This is - used by uux to execute a command locally with remote files. */ - -char * -zsysdep_xqt_file_name () -{ - char abseq[CSEQLEN + 1]; - char absx[11 + CSEQLEN]; - char *zname; - - while (TRUE) - { - if (! fscmd_seq (zSlocalname, abseq)) - return NULL; - - sprintf (absx, "X.%.7sX%s", zSlocalname, abseq); - - zname = zsfind_file (absx, zSlocalname, -1); - if (zname == NULL) - return NULL; - - if (! fsysdep_file_exists (zname)) - break; - - ubuffree (zname); - } - - return zname; -} diff --git a/gnu/libexec/uucp/libunix/fsusg.c b/gnu/libexec/uucp/libunix/fsusg.c deleted file mode 100644 index 9189193..0000000 --- a/gnu/libexec/uucp/libunix/fsusg.c +++ /dev/null @@ -1,332 +0,0 @@ -/* fsusage.c -- return space usage of mounted filesystems - Copyright (C) 1991, 1992 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 - the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This file was modified slightly by Ian Lance Taylor, December 1992, - and again July 1995, for use with Taylor UUCP. */ - -#include "uucp.h" -#include "uudefs.h" -#include "sysdep.h" -#include "fsusg.h" - -int statfs (); - -#if HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -#if HAVE_SYS_MOUNT_H -#include <sys/mount.h> -#endif - -#if HAVE_SYS_VFS_H -#include <sys/vfs.h> -#endif - -#if HAVE_SYS_FILSYS_H -#include <sys/filsys.h> /* SVR2. */ -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#endif - -#if HAVE_SYS_STATFS_H -#include <sys/statfs.h> -#endif - -#if HAVE_SYS_DUSTAT_H /* AIX PS/2. */ -#include <sys/dustat.h> -#endif - -#if HAVE_SYS_STATVFS_H /* SVR4. */ -#include <sys/statvfs.h> -int statvfs (); -#endif - -#if HAVE_USTAT_H /* SVR2 and others. */ -#include <ustat.h> -#endif - -#if STAT_DISK_SPACE /* QNX. */ -#include <sys/disk.h> -#include <errno.h> -#endif - -#define STAT_NONE 0 - -#if ! STAT_STATFS3_OSF1 -#if ! STAT_STATFS2_FS_DATA -#if ! STAT_STATFS2_BSIZE -#if ! STAT_STATFS2_FSIZE -#if ! STAT_STATFS4 -#if ! STAT_STATVFS -#if ! STAT_DISK_SPACE -#if ! STAT_USTAT -#undef STAT_NONE -#define STAT_NONE 1 -#endif -#endif -#endif -#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 away from zero. - TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ - -static long -adjust_blocks (blocks, fromsize, tosize) - long blocks; - int fromsize, tosize; -{ - if (tosize <= 0) - abort (); - if (fromsize <= 0) - return -1; - - if (fromsize == tosize) /* E.g., from 512 to 512. */ - return blocks; - else if (fromsize > tosize) /* E.g., from 2048 to 512. */ - return blocks * (fromsize / tosize); - else /* E.g., from 256 to 512. */ - return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); -} - -#endif - -/* Fill in the fields of FSP with information about space usage for - the filesystem on which PATH resides. - DISK is the device on which PATH is mounted, for space-getting - methods that need to know it. - Return 0 if successful, -1 if not. */ - -int -get_fs_usage (path, disk, fsp) - char *path, *disk; - struct fs_usage *fsp; -{ -#if STAT_NONE - return -1; -#endif - -#if STAT_STATFS3_OSF1 - struct statfs fsd; - - if (statfs (path, &fsd, sizeof (struct statfs)) != 0) - return -1; -#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512) -#endif /* STAT_STATFS3_OSF1 */ - -#if STAT_STATFS2_FS_DATA /* Ultrix. */ - struct fs_data fsd; - - if (statfs (path, &fsd) != 1) - return -1; -#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); - fsp->fsu_files = fsd.fd_req.gtot; - fsp->fsu_ffree = fsd.fd_req.gfree; -#endif - -#if STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */ - struct statfs fsd; - - if (statfs (path, &fsd) < 0) - return -1; -#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512) -#endif - -#if STAT_STATFS2_FSIZE /* 4.4BSD. */ - struct statfs fsd; - - if (statfs (path, &fsd) < 0) - return -1; -#define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_fsize, 512) -#endif - -#if STAT_STATFS4 /* SVR3, Dynix, Irix. */ - struct statfs fsd; - - if (statfs (path, &fsd, sizeof fsd, 0) < 0) - return -1; - /* Empirically, the block counts on most SVR3 and SVR3-derived - systems seem to always be in terms of 512-byte blocks, - no matter what value f_bsize has. */ -# if _AIX -# define CONVERT_BLOCKS(b) adjust_blocks ((b), fsd.f_bsize, 512) -# else -# define CONVERT_BLOCKS(b) (b) -# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx. */ -# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */ -# define f_bavail f_bfree -# endif -# endif -# endif -#endif - -#if STAT_STATVFS /* SVR4. */ - struct statvfs fsd; - - if (statvfs (path, &fsd) < 0) - return -1; - /* f_frsize isn't guaranteed to be supported. */ -#define CONVERT_BLOCKS(b) \ - 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; - - 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); - fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree); - fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail); - fsp->fsu_files = fsd.f_files; - fsp->fsu_ffree = fsd.f_ffree; -#endif -#endif -#endif -#endif - - return 0; -} - -#ifdef _AIX -#ifdef _I386 -/* AIX PS/2 does not supply statfs. */ - -int -statfs (path, fsb) - char *path; - struct statfs *fsb; -{ - struct stat stats; - struct dustat fsd; - - if (stat (path, &stats)) - return -1; - if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd))) - return -1; - fsb->f_type = 0; - fsb->f_bsize = fsd.du_bsize; - fsb->f_blocks = fsd.du_fsize - fsd.du_isize; - fsb->f_bfree = fsd.du_tfree; - fsb->f_bavail = fsd.du_tfree; - fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb; - fsb->f_ffree = fsd.du_tinode; - fsb->f_fsid.val[0] = fsd.du_site; - fsb->f_fsid.val[1] = fsd.du_pckno; - return 0; -} -#endif /* _I386 */ -#endif /* _AIX */ diff --git a/gnu/libexec/uucp/libunix/fsusg.h b/gnu/libexec/uucp/libunix/fsusg.h deleted file mode 100644 index 2b9ddd5..0000000 --- a/gnu/libexec/uucp/libunix/fsusg.h +++ /dev/null @@ -1,31 +0,0 @@ -/* fsusage.h -- declarations for filesystem space usage info - Copyright (C) 1991, 1992 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 - the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - This files was modified slightly by Ian Lance Taylor for use with - Taylor UUCP. */ - -/* Space usage statistics for a filesystem. Blocks are 512-byte. */ -struct fs_usage -{ - long fsu_blocks; /* Total blocks. */ - long fsu_bfree; /* Free blocks available to superuser. */ - long fsu_bavail; /* Free blocks available to non-superuser. */ - long fsu_files; /* Total file nodes. */ - long fsu_ffree; /* Free file nodes. */ -}; - -extern int get_fs_usage P((char *path, char *disk, struct fs_usage *fsp)); diff --git a/gnu/libexec/uucp/libunix/ftw.c b/gnu/libexec/uucp/libunix/ftw.c deleted file mode 100644 index f7af66f..0000000 --- a/gnu/libexec/uucp/libunix/ftw.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ian Lance Taylor (ian@airs.com). - -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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. - -Modified by Ian Lance Taylor for Taylor UUCP, June 1992, and October 1993. */ - -#include "uucp.h" - -#include "sysdep.h" - -#include <errno.h> - -#if HAVE_LIMITS_H -#include <limits.h> -#endif - -#if HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -#if HAVE_FTW_H -#include <ftw.h> -#endif - -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif - -/* Traverse one level of a directory tree. */ - -static int -ftw_dir (dirs, level, descriptors, dir, len, func) - DIR **dirs; - int level; - int descriptors; - char *dir; - size_t len; - int (*func) P((const char *file, struct stat *status, int flag)); -{ - int got; - struct dirent *entry; - - got = 0; - - errno = 0; - - while ((entry = readdir (dirs[level])) != NULL) - { - size_t namlen; - struct stat s; - int flag, ret, newlev = 0; - - ++got; - - namlen = strlen (entry->d_name); - if (entry->d_name[0] == '.' - && (namlen == 1 || - (namlen == 2 && entry->d_name[1] == '.'))) - { - errno = 0; - continue; - } - - if (namlen + len + 1 > PATH_MAX) - { -#ifdef ENAMETOOLONG - errno = ENAMETOOLONG; -#else - errno = ENOMEM; -#endif - return -1; - } - - dir[len] = '/'; - memcpy ((dir + len + 1), entry->d_name, namlen + 1); - - if (stat (dir, &s) < 0) - { - if (errno != EACCES) - return -1; - flag = FTW_NS; - } - else if (S_ISDIR (s.st_mode)) - { - newlev = (level + 1) % descriptors; - - if (dirs[newlev] != NULL) - closedir (dirs[newlev]); - - dirs[newlev] = opendir (dir); - if (dirs[newlev] != NULL) - flag = FTW_D; - else - { - if (errno != EACCES) - return -1; - flag = FTW_DNR; - } - } - else - flag = FTW_F; - - ret = (*func) (dir, &s, flag); - - if (flag == FTW_D) - { - if (ret == 0) - ret = ftw_dir (dirs, newlev, descriptors, dir, - namlen + len + 1, func); - if (dirs[newlev] != NULL) - { - int save; - - save = errno; - closedir (dirs[newlev]); - errno = save; - dirs[newlev] = NULL; - } - } - - if (ret != 0) - return ret; - - if (dirs[level] == NULL) - { - int skip; - - dir[len] = '\0'; - dirs[level] = opendir (dir); - if (dirs[level] == NULL) - return -1; - skip = got; - while (skip-- != 0) - { - errno = 0; - if (readdir (dirs[level]) == NULL) - return errno == 0 ? 0 : -1; - } - } - - errno = 0; - } - - return errno == 0 ? 0 : -1; -} - -/* Call a function on every element in a directory tree. */ - -int -ftw (dir, func, descriptors) - const char *dir; - int (*func) P((const char *file, struct stat *status, int flag)); - int descriptors; -{ - DIR **dirs; - int c; - DIR **p; - size_t len; - char buf[PATH_MAX + 1]; - struct stat s; - int flag, ret; - - if (descriptors <= 0) - descriptors = 1; - - dirs = (DIR **) malloc (descriptors * sizeof (DIR *)); - if (dirs == NULL) - return -1; - c = descriptors; - p = dirs; - while (c-- != 0) - *p++ = NULL; - - len = strlen (dir); - memcpy (buf, dir, len + 1); - - if (stat (dir, &s) < 0) - { - if (errno != EACCES) - { - free ((pointer) dirs); - return -1; - } - flag = FTW_NS; - } - else if (S_ISDIR (s.st_mode)) - { - dirs[0] = opendir (dir); - if (dirs[0] != NULL) - flag = FTW_D; - else - { - if (errno != EACCES) - { - free ((pointer) dirs); - return -1; - } - flag = FTW_DNR; - } - } - else - flag = FTW_F; - - ret = (*func) (buf, &s, flag); - - if (flag == FTW_D) - { - if (ret == 0) - { - if (len == 1 && *buf == '/') - len = 0; - ret = ftw_dir (dirs, 0, descriptors, buf, len, func); - } - if (dirs[0] != NULL) - { - int save; - - save = errno; - closedir (dirs[0]); - errno = save; - } - } - - free ((pointer) dirs); - return ret; -} diff --git a/gnu/libexec/uucp/libunix/getcwd.c b/gnu/libexec/uucp/libunix/getcwd.c deleted file mode 100644 index d3623bd..0000000 --- a/gnu/libexec/uucp/libunix/getcwd.c +++ /dev/null @@ -1,59 +0,0 @@ -/* getcwd.c - Replacement for the getcwd function that just calls /bin/pwd. */ - -#include "uucp.h" - -#include "sysdep.h" - -#include <errno.h> - -char * -getcwd (zbuf, cbuf) - char *zbuf; - size_t cbuf; -{ - const char *azargs[2]; - FILE *e; - pid_t ipid; - int cread; - int ierr; - - azargs[0] = PWD_PROGRAM; - azargs[1] = NULL; - e = espopen (azargs, TRUE, &ipid); - if (e == NULL) - return NULL; - - ierr = 0; - - cread = fread (zbuf, sizeof (char), cbuf, e); - if (cread == 0) - ierr = errno; - - (void) fclose (e); - - if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0) - { - ierr = EACCES; - cread = 0; - } - - if (cread != 0) - { - if (zbuf[cread - 1] == '\n') - zbuf[cread - 1] = '\0'; - else - { - ierr = ERANGE; - cread = 0; - } - } - - if (cread == 0) - { - errno = ierr; - return NULL; - } - - return zbuf; -} diff --git a/gnu/libexec/uucp/libunix/indir.c b/gnu/libexec/uucp/libunix/indir.c deleted file mode 100644 index 88cdb0e..0000000 --- a/gnu/libexec/uucp/libunix/indir.c +++ /dev/null @@ -1,133 +0,0 @@ -/* indir.c - See if a file is in a directory. - - Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* See whether a file is in a directory, and optionally check access. */ - -boolean -fsysdep_in_directory (zfile, zdir, fcheck, freadable, zuser) - const char *zfile; - const char *zdir; - boolean fcheck; - boolean freadable; - const char *zuser; -{ - size_t c; - char *zcopy, *zslash; - struct stat s; - - if (*zfile != '/') - return FALSE; - c = strlen (zdir); - if (c > 0 && zdir[c - 1] == '/') - c--; - if (strncmp (zfile, zdir, c) != 0 - || (zfile[c] != '/' && zfile[c] != '\0')) - return FALSE; - if (strstr (zfile + c, "/../") != NULL) - return FALSE; - - /* If we're not checking access, get out now. */ - if (! fcheck) - return TRUE; - - zcopy = zbufcpy (zfile); - - /* Start checking directories after zdir. Otherwise, we would - require that all directories down to /usr/spool/uucppublic be - publically searchable; they probably are but it should not be a - requirement. */ - zslash = zcopy + c; - do - { - char b; - struct stat shold; - - b = *zslash; - *zslash = '\0'; - - shold = s; - if (stat (zcopy, &s) != 0) - { - if (errno != ENOENT) - { - ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno)); - ubuffree (zcopy); - return FALSE; - } - - /* If this is the top directory, any problems will be caught - later when we try to open it. */ - if (zslash == zcopy + c) - { - ubuffree (zcopy); - return TRUE; - } - - /* Go back and check the last directory for read or write - access. */ - s = shold; - break; - } - - /* If this is not a directory, get out of the loop. */ - if (! S_ISDIR (s.st_mode)) - break; - - /* Make sure the directory is searchable. */ - if (! fsuser_access (&s, X_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - ubuffree (zcopy); - return FALSE; - } - - /* If we've reached the end of the string, get out. */ - if (b == '\0') - break; - - *zslash = b; - } - while ((zslash = strchr (zslash + 1, '/')) != NULL); - - /* At this point s holds a stat on the last component of the path. - We must check it for readability or writeability. */ - if (! fsuser_access (&s, freadable ? R_OK : W_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - ubuffree (zcopy); - return FALSE; - } - - ubuffree (zcopy); - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/jobid.c b/gnu/libexec/uucp/libunix/jobid.c deleted file mode 100644 index b7f9145..0000000 --- a/gnu/libexec/uucp/libunix/jobid.c +++ /dev/null @@ -1,169 +0,0 @@ -/* jobid.c - Convert file names to jobids and vice versa. - - Copyright (C) 1991, 1992, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uuconf.h" -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* Translate a file name and an associated system into a job id. - These job ids are used by uustat. */ - -char * -zsfile_to_jobid (qsys, zfile, bgrade) - const struct uuconf_system *qsys; - const char *zfile; - int bgrade; -{ - size_t clen; - char *zret; - - clen = strlen (qsys->uuconf_zname); - -#if ! SPOOLDIR_TAYLOR - - /* We use the system name attached to the grade and sequence number. - This won't work correctly if the file name was actually created - by some other version of uucp that uses a different length for - the sequence number. Too bad. */ - - zret = zbufalc (clen + CSEQLEN + 2); - memcpy (zret, qsys->uuconf_zname, clen); - zret[clen] = bgrade; - memcpy (zret + clen + 1, zfile + strlen (zfile) - CSEQLEN, CSEQLEN + 1); - -#else - - /* We use the system name followed by a dot, the grade, and the - sequence number. In this case, the sequence number is a long - string. */ - - { - size_t cseqlen; - - /* zfile is SYS/C./C.gseq. */ - zfile = strrchr (zfile, '/'); - -#if DEBUG > 0 - if (zfile == NULL - || zfile[1] != 'C' - || zfile[2] != '.' - || zfile[3] == '\0') - ulog (LOG_FATAL, "zsfile_to_jobid: Can't happen"); -#endif - - /* Make zfile point at .gseq. */ - zfile += 2; - - cseqlen = strlen (zfile); - zret = zbufalc (clen + cseqlen + 1); - memcpy (zret, qsys->uuconf_zname, clen); - memcpy (zret + clen, zfile, cseqlen + 1); - } - -#endif - - return zret; -} - -/* Turn a job id back into a file name. */ - -char * -zsjobid_to_file (zid, pzsystem, pbgrade) - const char *zid; - char **pzsystem; - char *pbgrade; -{ -#if ! SPOOLDIR_TAYLOR - size_t clen; - const char *zend; - char *zsys; - char abname[CSEQLEN + 11]; - char *zret; - - clen = strlen (zid); - if (clen <= CSEQLEN) - { - ulog (LOG_ERROR, "%s: Bad job id", zid); - return NULL; - } - - zend = zid + clen - CSEQLEN - 1; - - zsys = zbufalc (clen - CSEQLEN); - memcpy (zsys, zid, clen - CSEQLEN - 1); - zsys[clen - CSEQLEN - 1] = '\0'; - - /* This must correspond to zsfile_name. */ - sprintf (abname, "C.%.7s%s", zsys, zend); - - zret = zsfind_file (abname, zsys, *zend); - - if (zret != NULL && pzsystem != NULL) - *pzsystem = zsys; - else - ubuffree (zsys); - - if (pbgrade != NULL) - *pbgrade = *zend; - - return zret; -#else /* SPOOLDIR_TAYLOR */ - char *zdot; - size_t csyslen; - char *zsys; - char ab[15]; - char *zret; - - zdot = strrchr (zid, '.'); - if (zdot == NULL) - { - ulog (LOG_ERROR, "%s: Bad job id", zid); - return NULL; - } - - csyslen = zdot - zid; - zsys = zbufalc (csyslen + 1); - memcpy (zsys, zid, csyslen); - zsys[csyslen] = '\0'; - - ab[0] = 'C'; - strcpy (ab + 1, zdot); - - zret = zsfind_file (ab, zsys, zdot[1]); - - if (zret != NULL && pzsystem != NULL) - *pzsystem = zsys; - else - ubuffree (zsys); - - if (pbgrade != NULL) - *pbgrade = zdot[1]; - - return zret; -#endif /* SPOOLDIR_TAYLOR */ -} diff --git a/gnu/libexec/uucp/libunix/lcksys.c b/gnu/libexec/uucp/libunix/lcksys.c deleted file mode 100644 index ab2e2c8..0000000 --- a/gnu/libexec/uucp/libunix/lcksys.c +++ /dev/null @@ -1,62 +0,0 @@ -/* lcksys.c - Lock and unlock a remote system. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -/* Do the actual lock or unlock. */ - -static boolean fslock_sys P((boolean, const char *)); - -static boolean -fslock_sys (flock, zname) - boolean flock; - const char *zname; -{ - size_t clen; - char *z; - boolean fret; - - clen = strlen (zname); - -#if ! HAVE_LONG_FILE_NAMES - if (clen > 8) - clen = 8; -#endif - - z = zbufalc (sizeof "LCK.." + clen); - memcpy (z, "LCK..", sizeof "LCK.." - 1); - memcpy (z + sizeof "LCK.." - 1, zname, clen); - z[sizeof "LCK.." - 1 + clen] = '\0'; - - if (flock) - fret = fsdo_lock (z, FALSE, (boolean *) NULL); - else - fret = fsdo_unlock (z, FALSE); - - ubuffree (z); - - return fret; -} - -/* Lock a remote system. */ - -boolean -fsysdep_lock_system (qsys) - const struct uuconf_system *qsys; -{ - return fslock_sys (TRUE, qsys->uuconf_zname); -} - -/* Unlock a remote system. */ - -boolean -fsysdep_unlock_system (qsys) - const struct uuconf_system *qsys; -{ - return fslock_sys (FALSE, qsys->uuconf_zname); -} diff --git a/gnu/libexec/uucp/libunix/link.c b/gnu/libexec/uucp/libunix/link.c deleted file mode 100644 index 4550c76..0000000 --- a/gnu/libexec/uucp/libunix/link.c +++ /dev/null @@ -1,38 +0,0 @@ -/* link.c - Link two files. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -boolean -fsysdep_link (zfrom, zto, pfworked) - const char *zfrom; - const char *zto; - boolean *pfworked; -{ - *pfworked = FALSE; - if (link (zfrom, zto) == 0) - { - *pfworked = TRUE; - return TRUE; - } - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (zto, TRUE)) - return FALSE; - if (link (zfrom, zto) == 0) - { - *pfworked = TRUE; - return TRUE; - } - } - if (errno == EXDEV) - return TRUE; - ulog (LOG_ERROR, "link (%s, %s): %s", zfrom, zto, strerror (errno)); - return FALSE; -} diff --git a/gnu/libexec/uucp/libunix/locfil.c b/gnu/libexec/uucp/libunix/locfil.c deleted file mode 100644 index 47581cf..0000000 --- a/gnu/libexec/uucp/libunix/locfil.c +++ /dev/null @@ -1,101 +0,0 @@ -/* locfil.c - Expand a file name on the local system. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <pwd.h> - -#if GETPWNAM_DECLARATION_OK -#ifndef getpwnam -extern struct passwd *getpwnam (); -#endif -#endif - -/* Turn a file name into an absolute path, by doing tilde expansion - and moving any other type of file into the public directory. */ - -char * -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); - - if (*zfile != '~') - zdir = zpubdir; - else - { - if (zfile[1] == '\0') - return zbufcpy (zpubdir); - - if (zfile[1] == '/') - { - zdir = zpubdir; - zfile += 2; - } - else - { - size_t cuserlen; - char *zcopy; - struct passwd *q; - - ++zfile; - cuserlen = strcspn ((char *) zfile, "/"); - zcopy = zbufalc (cuserlen + 1); - memcpy (zcopy, zfile, cuserlen); - zcopy[cuserlen] = '\0'; - - q = getpwnam (zcopy); - if (q == NULL) - { - ulog (LOG_ERROR, "User %s not found", zcopy); - ubuffree (zcopy); - if (pfbadname != NULL) - *pfbadname = TRUE; - return NULL; - } - ubuffree (zcopy); - - if (zfile[cuserlen] == '\0') - return zbufcpy (q->pw_dir); - - zdir = q->pw_dir; - zfile += cuserlen + 1; - } - } - - return zsysdep_in_dir (zdir, zfile); -} diff --git a/gnu/libexec/uucp/libunix/mkdir.c b/gnu/libexec/uucp/libunix/mkdir.c deleted file mode 100644 index 2546cbf..0000000 --- a/gnu/libexec/uucp/libunix/mkdir.c +++ /dev/null @@ -1,58 +0,0 @@ -/* mkdir.c - Create a directory. We must go through a subsidiary program to - force our real uid to be the uucp owner before invoking the setuid - /bin/mkdir program. */ - -#include "uucp.h" - -#include "sysdep.h" - -#include <errno.h> - -int -mkdir (zdir, imode) - const char *zdir; - int imode; -{ - struct stat s; - const char *azargs[3]; - int aidescs[3]; - pid_t ipid; - - /* Make sure the directory does not exist, since we will otherwise - get the wrong errno value. */ - if (stat (zdir, &s) == 0) - { - errno = EEXIST; - return -1; - } - - /* /bin/mkdir will create the directory with mode 777, so we set our - umask to get the mode we want. */ - (void) umask ((~ imode) & (S_IRWXU | S_IRWXG | S_IRWXO)); - - azargs[0] = UUDIR_PROGRAM; - azargs[1] = zdir; - azargs[2] = NULL; - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL, - TRUE, FALSE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - - (void) umask (0); - - if (ipid < 0) - return -1; - - if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0) - { - /* Make up an errno value. */ - errno = EACCES; - return -1; - } - - return 0; -} diff --git a/gnu/libexec/uucp/libunix/mode.c b/gnu/libexec/uucp/libunix/mode.c deleted file mode 100644 index 53f74ec..0000000 --- a/gnu/libexec/uucp/libunix/mode.c +++ /dev/null @@ -1,33 +0,0 @@ -/* mode.c - Get the Unix file mode of a file. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -unsigned int -ixsysdep_file_mode (zfile) - const char *zfile; -{ - struct stat s; - - if (stat ((char *) zfile, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return 0; - } - -#if S_IRWXU != 0700 - #error Files modes need to be translated -#endif - - /* We can't return 0, since that indicate an error. */ - if ((s.st_mode & 0777) == 0) - return 0400; - - return s.st_mode & 0777; -} diff --git a/gnu/libexec/uucp/libunix/move.c b/gnu/libexec/uucp/libunix/move.c deleted file mode 100644 index 19828c2..0000000 --- a/gnu/libexec/uucp/libunix/move.c +++ /dev/null @@ -1,162 +0,0 @@ -/* move.c - Move a file. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -/* Move (rename) a file from one name to another. This routine will - optionally create necessary directories, and fpublic indicates - whether the new directories should be publically accessible or not. - If fcheck is true, it will try to determine whether the named user - has write access to the new file. */ - -boolean -fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser) - const char *zorig; - const char *zto; - boolean fmkdirs; - boolean fpublic; - boolean fcheck; - const char *zuser; -{ - struct stat s; - int o; - - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "fsysdep_move_file: Moving %s to %s", zorig, zto); - - /* Optionally make sure that zuser has write access on the - directory. */ - if (fcheck) - { - char *zcopy; - char *zslash; - - zcopy = zbufcpy (zto); - zslash = strrchr (zcopy, '/'); - if (zslash == zcopy) - zslash[1] = '\0'; - else - *zslash = '\0'; - - if (stat (zcopy, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno)); - ubuffree (zcopy); - return FALSE; - } - if (! fsuser_access (&s, W_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - ubuffree (zcopy); - return FALSE; - } - ubuffree (zcopy); - - /* A malicious user now has a few milliseconds to change a - symbolic link to a directory uucp has write permission on but - the user does not (the obvious choice being /usr/lib/uucp). - The only certain method I can come up with to close this race - is to fork an suid process which takes on the users identity - and does the actual copy. This is sufficiently high overhead - that I'm not going to do it. */ - } - - /* We try to use rename to move the file. */ - - if (rename (zorig, zto) == 0) - return TRUE; - - if (fmkdirs && errno == ENOENT) - { - if (! fsysdep_make_dirs (zto, fpublic)) - return FALSE; - if (rename (zorig, zto) == 0) - return TRUE; - } - -#if HAVE_RENAME - /* On some systems the system call rename seems to fail for - arbitrary reasons. To get around this, we always try to copy the - file by hand if the rename failed. */ - errno = EXDEV; -#endif - - /* If we can't link across devices, we must copy the file by hand. */ - if (errno != EXDEV) - { - ulog (LOG_ERROR, "rename (%s, %s): %s", zorig, zto, - strerror (errno)); - return FALSE; - } - - /* Copy the file. */ - if (stat ((char *) zorig, &s) < 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zorig, strerror (errno)); - return FALSE; - } - - /* Make sure the file gets the right mode by creating it before we - call fcopy_file. */ - (void) remove (zto); - o = creat ((char *) zto, s.st_mode); - if (o < 0) - { - if (fmkdirs && errno == ENOENT) - { - if (! fsysdep_make_dirs (zto, fpublic)) - return FALSE; - o = creat ((char *) zto, s.st_mode); - } - if (o < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", zto, strerror (errno)); - return FALSE; - } - } - (void) close (o); - - if (! fcopy_file (zorig, zto, fpublic, fmkdirs, FALSE)) - return FALSE; - - if (remove (zorig) != 0) - ulog (LOG_ERROR, "remove (%s): %s", zorig, strerror (errno)); - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/opensr.c b/gnu/libexec/uucp/libunix/opensr.c deleted file mode 100644 index 5217741..0000000 --- a/gnu/libexec/uucp/libunix/opensr.c +++ /dev/null @@ -1,252 +0,0 @@ -/* opensr.c - Open files for sending and receiving. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" - -#include <errno.h> - -#if HAVE_TIME_H -#include <time.h> -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#ifndef time -extern time_t time (); -#endif - -/* Open a file to send to another system, and return the mode and - the size. */ - -openfile_t -esysdep_open_send (qsys, zfile, fcheck, zuser) - const struct uuconf_system *qsys; - const char *zfile; - boolean fcheck; - const char *zuser; -{ - struct stat s; - openfile_t e; - int o; - - if (fsysdep_directory (zfile)) - { - ulog (LOG_ERROR, "%s: is a directory", zfile); - return EFILECLOSED; - } - -#if USE_STDIO - e = fopen (zfile, BINREAD); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - return NULL; - } - o = fileno (e); -#else - e = open ((char *) zfile, O_RDONLY | O_NOCTTY, 0); - if (e == -1) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); - return -1; - } - o = e; -#endif - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) ffileclose (e); - return EFILECLOSED; - } - - if (fstat (o, &s) == -1) - { - ulog (LOG_ERROR, "fstat: %s", strerror (errno)); - s.st_mode = 0666; - } - - /* We have to recheck the file permission, although we probably - checked it already, because otherwise there would be a window in - which somebody could change the contents of a symbolic link to - point to some file which was only readable by uucp. */ - if (fcheck) - { - if (! fsuser_access (&s, R_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zfile, strerror (EACCES)); - (void) ffileclose (e); - return EFILECLOSED; - } - } - - return e; -} - -/* Get a temporary file name to receive into. We use the ztemp - argument to pick the file name, so that we restart the file if the - transmission is aborted. */ - -char * -zsysdep_receive_temp (qsys, zto, ztemp, frestart) - const struct uuconf_system *qsys; - const char *zto; - const char *ztemp; - boolean frestart; -{ - if (frestart - && ztemp != NULL - && *ztemp == 'D' - && strcmp (ztemp, "D.0") != 0) - return zsappend3 (".Temp", qsys->uuconf_zname, ztemp); - else - 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. */ - -openfile_t -esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart) - const struct uuconf_system *qsys; - const char *zto; - const char *ztemp; - const char *zreceive; - long *pcrestart; -{ - int o; - openfile_t e; - - /* If we used the ztemp argument in zsysdep_receive_temp, above, - then we will have a name consistent across conversations. In - that case, we may have already received some portion of this - file. */ - o = -1; - if (pcrestart != NULL) - *pcrestart = -1; - if (pcrestart != NULL - && ztemp != NULL - && *ztemp == 'D' - && strcmp (ztemp, "D.0") != 0) - { - o = open ((char *) zreceive, O_WRONLY); - if (o >= 0) - { - struct stat s; - - /* For safety, we insist on the file being less than 1 week - old. This can still catch people, unfortunately. I - don't know of any good solution to the problem of old - files hanging around. If anybody has a file they want - 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 + SECS_PER_WEEK < time ((time_t *) NULL)) - { - (void) close (o); - o = -1; - } - else - { - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, - "esysdep_open_receive: Reusing %s", - zreceive); - *pcrestart = (long) s.st_size; - } - } - } - - if (o < 0) - o = creat ((char *) zreceive, IPRIVATE_FILE_MODE); - - if (o < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (zreceive, FALSE)) - return EFILECLOSED; - o = creat ((char *) zreceive, IPRIVATE_FILE_MODE); - } - if (o < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", zreceive, strerror (errno)); - return EFILECLOSED; - } - } - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) close (o); - (void) remove (zreceive); - return EFILECLOSED; - } - -#if USE_STDIO - e = fdopen (o, (char *) BINWRITE); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen (%s): %s", zreceive, strerror (errno)); - (void) close (o); - (void) remove (zreceive); - return EFILECLOSED; - } -#else - e = o; -#endif - - return e; -} diff --git a/gnu/libexec/uucp/libunix/picksb.c b/gnu/libexec/uucp/libunix/picksb.c deleted file mode 100644 index 2aacc15..0000000 --- a/gnu/libexec/uucp/libunix/picksb.c +++ /dev/null @@ -1,234 +0,0 @@ -/* picksb.c - System dependent routines for uupick. - - Copyright (C) 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char picksb_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "system.h" -#include "sysdep.h" - -#include <errno.h> -#include <pwd.h> - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -#if GETPWUID_DECLARATION_OK -#ifndef getpwuid -extern struct passwd *getpwuid (); -#endif -#endif - -/* Local variables. */ - -/* Directory of ~/receive/USER. */ -static DIR *qStopdir; - -/* Name of ~/receive/USER. */ -static char *zStopdir; - -/* Directory of ~/receive/USER/SYSTEM. */ -static DIR *qSsysdir; - -/* Name of system. */ -static char *zSsysdir; - -/* Prepare to get a list of all the file to uupick for this user. */ - -/*ARGSUSED*/ -boolean -fsysdep_uupick_init (zsystem, zpubdir) - const char *zsystem; - const char *zpubdir; -{ - const char *zuser; - - zuser = zsysdep_login_name (); - - zStopdir = (char *) xmalloc (strlen (zpubdir) - + sizeof "/receive/" - + strlen (zuser)); - sprintf (zStopdir, "%s/receive/%s", zpubdir, zuser); - - qStopdir = opendir (zStopdir); - if (qStopdir == NULL && errno != ENOENT) - { - ulog (LOG_ERROR, "opendir (%s): %s", zStopdir, - strerror (errno)); - return FALSE; - } - - qSsysdir = NULL; - - return TRUE; -} - -/* Return the next file from the uupick directories. */ - -/*ARGSUSED*/ -char * -zsysdep_uupick (zsysarg, zpubdir, pzfrom, pzfull) - const char *zsysarg; - const char *zpubdir; - char **pzfrom; - char **pzfull; -{ - struct dirent *qentry; - - while (TRUE) - { - while (qSsysdir == NULL) - { - const char *zsystem; - char *zdir; - - if (qStopdir == NULL) - return NULL; - - if (zsysarg != NULL) - { - closedir (qStopdir); - qStopdir = NULL; - zsystem = zsysarg; - } - else - { - do - { - qentry = readdir (qStopdir); - if (qentry == NULL) - { - closedir (qStopdir); - qStopdir = NULL; - return NULL; - } - } - while (strcmp (qentry->d_name, ".") == 0 - || strcmp (qentry->d_name, "..") == 0); - - zsystem = qentry->d_name; - } - - zdir = zbufalc (strlen (zStopdir) + strlen (zsystem) + sizeof "/"); - sprintf (zdir, "%s/%s", zStopdir, zsystem); - - qSsysdir = opendir (zdir); - if (qSsysdir == NULL) - { - if (errno != ENOENT && errno != ENOTDIR) - ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno)); - } - else - { - ubuffree (zSsysdir); - zSsysdir = zbufcpy (zsystem); - } - - ubuffree (zdir); - } - - qentry = readdir (qSsysdir); - if (qentry == NULL) - { - closedir (qSsysdir); - qSsysdir = NULL; - continue; - } - - if (strcmp (qentry->d_name, ".") == 0 - || strcmp (qentry->d_name, "..") == 0) - continue; - - *pzfrom = zbufcpy (zSsysdir); - *pzfull = zsappend3 (zStopdir, zSsysdir, qentry->d_name); - return zbufcpy (qentry->d_name); - } -} - -/*ARGSUSED*/ -boolean -fsysdep_uupick_free (zsystem, zpubdir) - const char *zsystem; - const char *zpubdir; -{ - xfree ((pointer) zStopdir); - if (qStopdir != NULL) - { - closedir (qStopdir); - qStopdir = NULL; - } - ubuffree (zSsysdir); - zSsysdir = NULL; - if (qSsysdir != NULL) - { - closedir (qSsysdir); - qSsysdir = NULL; - } - - return TRUE; -} - -/* Expand a local file name for uupick. */ - -char * -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, pfbadname); - - q = getpwuid (getuid ()); - if (q == NULL) - { - ulog (LOG_ERROR, "Can't get home directory"); - return NULL; - } - - if (zfile[1] == '\0') - return zbufcpy (q->pw_dir); - - return zsysdep_in_dir (q->pw_dir, zfile + 2); -} diff --git a/gnu/libexec/uucp/libunix/priv.c b/gnu/libexec/uucp/libunix/priv.c deleted file mode 100644 index 207bd3d..0000000 --- a/gnu/libexec/uucp/libunix/priv.c +++ /dev/null @@ -1,24 +0,0 @@ -/* 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/recep.c b/gnu/libexec/uucp/libunix/recep.c deleted file mode 100644 index a1f893d..0000000 --- a/gnu/libexec/uucp/libunix/recep.c +++ /dev/null @@ -1,201 +0,0 @@ -/* recep.c - See whether a file has already been received. - - Copyright (C) 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_TIME_H -#include <time.h> -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -static char *zsreceived_name P((const struct uuconf_system *qsys, - const char *ztemp)); - -/* These routines are used to see whether we have already received a - file in a previous UUCP connection. It is possible for the - acknowledgement of a received file to be lost. The sending system - will then not know that the file was correctly received, and will - send it again. This can be a problem particularly with protocols - which support channels, since they may send several small files in - a single window, all of which may be received correctly although - the sending system never sees the acknowledgement. If these files - involve an execution, the execution will happen twice, which will - be bad. - - We use a simple system. For each file we want to remember, we - create an empty file names .Received/SYS/TEMP, where SYS is the - name of the system and TEMP is the name of the temporary file used - by the sender. If no temporary file is used by the sender, we - don't remember that we received the file. This is not perfect, but - execution files will always have a temporary file, so the most - important case is handled. Also, any file received from Taylor - UUCP 1.04 or greater will always have a temporary file. */ - -/* Return the name we are going use for the marker, or NULL if we have - no name. */ - -static char * -zsreceived_name (qsys, ztemp) - const struct uuconf_system *qsys; - const char *ztemp; -{ - if (ztemp != NULL - && *ztemp == 'D' - && strcmp (ztemp, "D.0") != 0) - return zsappend3 (".Received", qsys->uuconf_zname, ztemp); - else - return NULL; -} - -/* Remember that we have already received a file. */ - -/*ARGSUSED*/ -boolean -fsysdep_remember_reception (qsys, zto, ztemp) - const struct uuconf_system *qsys; - const char *zto; - const char *ztemp; -{ - char *zfile; - int o; - - zfile = zsreceived_name (qsys, ztemp); - if (zfile == NULL) - return TRUE; - o = creat (zfile, IPUBLIC_FILE_MODE); - if (o < 0) - { - if (errno == ENOENT) - { - if (fsysdep_make_dirs (zfile, FALSE)) - { - ubuffree (zfile); - return FALSE; - } - o = creat (zfile, IPUBLIC_FILE_MODE); - } - if (o < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", zfile, strerror (errno)); - ubuffree (zfile); - return FALSE; - } - } - - ubuffree (zfile); - - /* We don't have to actually put anything in the file; we just use - the name. This is more convenient than keeping a file with a - list of names. */ - if (close (o) < 0) - { - ulog (LOG_ERROR, "fsysdep_remember_reception: close: %s", - strerror (errno)); - return FALSE; - } - - 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 - file has already been received, FALSE if it has not. */ - -/*ARGSUSED*/ -boolean -fsysdep_already_received (qsys, zto, ztemp) - const struct uuconf_system *qsys; - const char *zto; - const char *ztemp; -{ - char *zfile; - struct stat s; - boolean fret; - - zfile = zsreceived_name (qsys, ztemp); - if (zfile == NULL) - return FALSE; - if (stat (zfile, &s) < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - ubuffree (zfile); - return FALSE; - } - - /* Ignore the file (return FALSE) if it is over one week old. */ - fret = s.st_mtime + SECS_PER_WEEK >= time ((time_t *) NULL); - - if (fret) - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, "fsysdep_already_received: Found %s", - zfile); - - ubuffree (zfile); - - return fret; -} - -/* Forget that we have received a file. */ - -/*ARGSUSED*/ -boolean -fsysdep_forget_reception (qsys, zto, ztemp) - const struct uuconf_system *qsys; - const char *zto; - const char *ztemp; -{ - char *zfile; - - zfile = zsreceived_name (qsys, ztemp); - if (zfile == NULL) - return TRUE; - if (remove (zfile) < 0 - && errno != ENOENT) - { - ulog (LOG_ERROR, "remove (%s): %s", zfile, strerror (errno)); - ubuffree (zfile); - return FALSE; - } - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/remove.c b/gnu/libexec/uucp/libunix/remove.c deleted file mode 100644 index b695888..0000000 --- a/gnu/libexec/uucp/libunix/remove.c +++ /dev/null @@ -1,13 +0,0 @@ -/* remove.c - Remove a file (Unix specific implementation). */ - -#include "uucp.h" - -#include "sysdep.h" - -int -remove (z) - const char *z; -{ - return unlink (z); -} diff --git a/gnu/libexec/uucp/libunix/rename.c b/gnu/libexec/uucp/libunix/rename.c deleted file mode 100644 index 0947ef5..0000000 --- a/gnu/libexec/uucp/libunix/rename.c +++ /dev/null @@ -1,27 +0,0 @@ -/* rename.c - Rename a file to a new name (Unix specific implementation). */ - -#include "uucp.h" - -#include "sysdep.h" - -#include <errno.h> - -/* This implementation will not work on directories, but fortunately - we never want to rename directories. */ - -int -rename (zfrom, zto) - const char *zfrom; - const char *zto; -{ - if (link (zfrom, zto) < 0) - { - if (errno != EEXIST) - return -1; - if (unlink (zto) < 0 - || link (zfrom, zto) < 0) - return -1; - } - return unlink (zfrom); -} diff --git a/gnu/libexec/uucp/libunix/rmdir.c b/gnu/libexec/uucp/libunix/rmdir.c deleted file mode 100644 index 12a7b9e..0000000 --- a/gnu/libexec/uucp/libunix/rmdir.c +++ /dev/null @@ -1,43 +0,0 @@ -/* rmdir.c - Remove a directory on a system which doesn't have the rmdir system - call. This is only called by uupick, which is not setuid, so we - don't have to worry about the problems of invoking the setuid - /bin/rmdir program. */ - -#include "uucp.h" - -#include "sysdep.h" - -#include <errno.h> - -int -rmdir (zdir) - const char *zdir; -{ - const char *azargs[3]; - int aidescs[3]; - pid_t ipid; - - azargs[0] = RMDIR_PROGRAM; - azargs[1] = zdir; - azargs[2] = NULL; - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL, - TRUE, TRUE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - - if (ipid < 0) - return -1; - - if (ixswait ((unsigned long) ipid, (const char *) NULL) != 0) - { - /* Make up an errno value. */ - errno = EBUSY; - return -1; - } - - return 0; -} diff --git a/gnu/libexec/uucp/libunix/run.c b/gnu/libexec/uucp/libunix/run.c deleted file mode 100644 index d789d37..0000000 --- a/gnu/libexec/uucp/libunix/run.c +++ /dev/null @@ -1,113 +0,0 @@ -/* run.c - Run a program. - - Copyright (C) 1992, 1993, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* Start up a new program. */ - -boolean -fsysdep_run (ffork, zprogram, zarg1, zarg2) - boolean ffork; - const char *zprogram; - const char *zarg1; - const char *zarg2; -{ - char *zlib; - const char *azargs[4]; - 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); - - azargs[0] = zlib; - azargs[1] = zarg1; - azargs[2] = zarg2; - azargs[3] = NULL; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - /* We pass fsetuid and fshell as TRUE, which permits uucico and - uuxqt to be replaced by (non-setuid) shell scripts. */ - ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL, - 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 deleted file mode 100644 index 321ed74..0000000 --- a/gnu/libexec/uucp/libunix/seq.c +++ /dev/null @@ -1,126 +0,0 @@ -/* seq.c - Get and increment the conversation sequence number for a system. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* Get the current conversation sequence number for a remote system, - and increment it for next time. The conversation sequence number - is kept in a file named for the system in the directory .Sequence - in the spool directory. This is not compatible with other versions - of UUCP, but it makes more sense to me. The sequence file is only - used if specified in the information for that system. */ - -long -ixsysdep_get_sequence (qsys) - const struct uuconf_system *qsys; -{ - FILE *e; - char *zname; - struct stat s; - long iseq; - - /* This will only be called when the system is locked anyhow, so there - is no need to use a separate lock for the conversation sequence - file. */ - zname = zsysdep_in_dir (".Sequence", qsys->uuconf_zname); - - iseq = 0; - if (stat (zname, &s) == 0) - { - boolean fok; - char *zline; - size_t cline; - - /* The file should only be readable and writable by uucp. */ - if ((s.st_mode & (S_IRWXG | S_IRWXO)) != 0) - { - ulog (LOG_ERROR, - "Bad file protection for conversation sequence file"); - ubuffree (zname); - return -1; - } - - e = fopen (zname, "r+"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno)); - ubuffree (zname); - return -1; - } - - ubuffree (zname); - - fok = TRUE; - zline = NULL; - cline = 0; - if (getline (&zline, &cline, e) <= 0) - fok = FALSE; - else - { - char *zend; - - iseq = strtol (zline, &zend, 10); - if (zend == zline) - fok = FALSE; - } - - xfree ((pointer) zline); - - if (! fok) - { - ulog (LOG_ERROR, "Bad format for conversation sequence file"); - (void) fclose (e); - return -1; - } - - rewind (e); - } - else - { - e = esysdep_fopen (zname, FALSE, FALSE, TRUE); - ubuffree (zname); - if (e == NULL) - return -1; - } - - ++iseq; - - fprintf (e, "%ld", iseq); - - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - return -1; - } - - return iseq; -} diff --git a/gnu/libexec/uucp/libunix/size.c b/gnu/libexec/uucp/libunix/size.c deleted file mode 100644 index 8d021db..0000000 --- a/gnu/libexec/uucp/libunix/size.c +++ /dev/null @@ -1,27 +0,0 @@ -/* size.c - Get the size in bytes of a file. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -long -csysdep_size (zfile) - const char *zfile; -{ - struct stat s; - - if (stat ((char *) zfile, &s) < 0) - { - if (errno == ENOENT) - return -1; - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return -2; - } - - return s.st_size; -} diff --git a/gnu/libexec/uucp/libunix/splcmd.c b/gnu/libexec/uucp/libunix/splcmd.c deleted file mode 100644 index d085cee..0000000 --- a/gnu/libexec/uucp/libunix/splcmd.c +++ /dev/null @@ -1,161 +0,0 @@ -/* splcmd.c - Spool a command. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> -#include <ctype.h> - -/* Given a set of commands to execute for a remote system, create a - command file holding them. This creates a single command file - holding all the commands passed in. It returns a jobid. */ - -char * -zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) - const struct uuconf_system *qsys; - int bgrade; - int ccmds; - const struct scmd *pascmds; -{ - char abtempfile[sizeof "TMP1234567890"]; - char *ztemp; - FILE *e; - int i; - const struct scmd *q; - char *z; - char *zjobid; - -#if DEBUG > 0 - if (! UUCONF_GRADE_LEGAL (bgrade)) - ulog (LOG_FATAL, "Bad grade %d", bgrade); -#endif - - /* 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 (ztemp, FALSE, FALSE, TRUE); - if (e == NULL) - { - ubuffree (ztemp); - return NULL; - } - - for (i = 0, q = pascmds; i < ccmds; i++, q++) - { - switch (q->bcmd) - { - case 'S': - fprintf (e, "S %s %s %s -%s %s 0%o %s\n", q->zfrom, q->zto, - q->zuser, q->zoptions, q->ztemp, q->imode, - q->znotify == NULL ? (const char *) "" : q->znotify); - break; - case 'R': - fprintf (e, "R %s %s %s -%s\n", q->zfrom, q->zto, q->zuser, - q->zoptions); - break; - case 'X': - fprintf (e, "X %s %s %s -%s\n", q->zfrom, q->zto, q->zuser, - q->zoptions); - break; - case 'E': - fprintf (e, "E %s %s %s -%s %s 0%o %s 0 %s\n", q->zfrom, q->zto, - q->zuser, q->zoptions, q->ztemp, q->imode, - q->znotify, q->zcmd); - break; - default: - ulog (LOG_ERROR, - "zsysdep_spool_commands: Unrecognized type %d", - q->bcmd); - (void) fclose (e); - (void) remove (ztemp); - ubuffree (ztemp); - return NULL; - } - } - - if (! fstdiosync (e, ztemp)) - { - (void) fclose (e); - (void) remove (ztemp); - ubuffree (ztemp); - return NULL; - } - - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (ztemp); - ubuffree (ztemp); - return NULL; - } - - /* The filename returned by zscmd_file is subject to some unlikely - race conditions, so keep trying the link until the destination - file does not already exist. Each call to zscmd_file should - return a file name which does not already exist, so we don't have - to do anything special before calling it again. */ - while (TRUE) - { - z = zscmd_file (qsys, bgrade); - if (z == NULL) - { - (void) remove (ztemp); - ubuffree (ztemp); - return NULL; - } - - if (link (ztemp, z) >= 0) - break; - - if (errno != EEXIST) - { - ulog (LOG_ERROR, "link (%s, %s): %s", ztemp, z, strerror (errno)); - (void) remove (ztemp); - ubuffree (ztemp); - ubuffree (z); - return NULL; - } - - ubuffree (z); - } - - (void) remove (ztemp); - ubuffree (ztemp); - - zjobid = zsfile_to_jobid (qsys, z, bgrade); - if (zjobid == NULL) - (void) remove (z); - ubuffree (z); - return zjobid; -} diff --git a/gnu/libexec/uucp/libunix/splnam.c b/gnu/libexec/uucp/libunix/splnam.c deleted file mode 100644 index 06ce360..0000000 --- a/gnu/libexec/uucp/libunix/splnam.c +++ /dev/null @@ -1,19 +0,0 @@ -/* splnam.c - Get the full name of a file in the spool directory. */ - -#include "uucp.h" - -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -/* Get the real name of a spool file. */ - -char * -zsysdep_spool_file_name (qsys, zfile, pseq) - const struct uuconf_system *qsys; - const char *zfile; - pointer pseq; -{ - return zsfind_file (zfile, qsys->uuconf_zname, bsgrade (pseq)); -} diff --git a/gnu/libexec/uucp/libunix/spool.c b/gnu/libexec/uucp/libunix/spool.c deleted file mode 100644 index b14b560..0000000 --- a/gnu/libexec/uucp/libunix/spool.c +++ /dev/null @@ -1,427 +0,0 @@ -/* spool.c - Find a file in the spool directory. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char spool_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* There are several types of files that go in the spool directory, - and they go into various different subdirectories. Whenever the - system name LOCAL appears below, it means whatever the local system - name is. - - Command files - These contain instructions for uucico indicating what files to transfer - to and from what systems. Each line of a work file is a command - beginning with S, R, X, or E. - #if ! SPOOLDIR_TAYLOR - They are named C.ssssssgqqqq, where ssssss is the system name to - transfer to or from, g is the grade and qqqq is the sequence number. - #if SPOOLDIR_V2 - They are put in the spool directory. - #elif SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - They are put in the directory "C.". - #elif SPOOLDIR_HDB - They are put in a directory named for the system for which they were - created. - #elif SPOOLDIR_ULTRIX - If the directory sys/ssssss exists, they are put in the directory - sys/ssssss/C; otherwise, they are put in the directory sys/DEFAULT/C. - #elif SPOOLDIR_SVR4 - They are put in the directory sys/g, where sys is the system name - and g is the grade. - #endif - #else SPOOLDIR_TAYLOR - They are named C.gqqqq, where g is the grade and qqqq is the - sequence number, and are placed in the directory ssssss/C. where - ssssss is the system name to transfer to or from. The sequence - number for a C. file is actually a long string; it is not based on - the sequence number file, but is generated via a process which - attempts to produce a unique string each time it is run. - #endif - - Data files - There are files to be transferred to other systems. Some files to - be transferred may not be in the spool directory, depending on how - uucp was invoked. Data files are named in work files, so it is - never necessary to look at them directly (except to remove old ones); - it is only necessary to create them. These means that the many - variations in naming are inconsequential. - #if ! SPOOLDIR_TAYLOR - They are named D.ssssssgqqqq where ssssss is a system name (which - may be LOCAL for locally initiated transfers or a remote system for - remotely initiated transfers, except that HDB appears to use the - system the file is being transferred to), g is the grade and qqqq - is the sequence number. Some systems use a trailing subjob ID - number, but we currently do not. The grade is not important, and - some systems do not use it. If the data file is to become an - execution file on another system the grade (if present) will be - 'X'. Otherwise Ultrix appears to use 'b'; the uux included with - gnuucp 1.0 appears to use 'S'; SCO does not appear to use a grade, - although it does use a subjob ID number. - #if SPOOLDIR_V2 - They are put in the spool directory. - #elif SPOOLDIR_BSD42 - If the name begins with D.LOCAL, the file is put in the directory - D.LOCAL. Otherwise the file is put in the directory D.. - #elif SPOOLDIR_BSD43 - If the name begins with D.LOCALX, the file is put in the directory - D.LOCALX. Otherwise if the name begins with D.LOCAL, the file is - put in the directory D.LOCAL Otherwise the file is put in the - directory "D.". - #elif SPOOLDIR_HDB - They are put in a directory named for the system for which they - were created. - #elif SPOOLDIR_ULTRIX - Say the file is being transferred to system REMOTE. If the - directory sys/REMOTE exists, then if the file begins with D.LOCALX - it is put in sys/REMOTE/D.LOCALX, if the file begins with D.LOCAL - it is put in sys/REMOTE/D.LOCAL, and otherwise it is put in - "sys/REMOTE/D.". If the directory sys/REMOTE does not exist, the - same applies except that DEFAULT is used instead of REMOTE. - #elif SPOOLDIR_SVR4 - They are put in the directory sys/g, where sys is the system name - and g is the grade. - #endif - #else SPOOLDIR_TAYLOR - If the file is to become an executable file on another system it is - named D.Xqqqq, otherwise it is named D.qqqq where in both cases - qqqq is a sequence number. If the corresponding C. file is in - directory ssssss/C., a D.X file is placed in ssssss/D.X and a D. - file is placed in "ssssss/D.". - #endif - - Execute files - These are files that specify programs to be executed. They are - created by uux, perhaps as run on another system. These names are - important, because a file transfer done to an execute file name - causes an execution to occur. The name is X.ssssssgqqqq, where - ssssss is the requesting system, g is the grade, and qqqq is a - sequence number. - #if SPOOLDIR_V2 || SPOOLDIR_BSD42 - These files are placed in the spool directory. - #elif SPOOLDIR_BSD43 - These files are placed in the directory X.. - #elif SPOOLDIR_HDB || SPOOLDIR_SVR4 - These files are put in a directory named for the system for which - the files were created. - #elif SPOOLDIR_ULTRIX - If there is a spool directory (sys/ssssss) for the requesting - system, the files are placed in sys/ssssss/X.; otherwise, the files - are placed in "sys/DEFAULT/X.". - #elif SPOOLDIR_TAYLOR - The system name is automatically truncated to seven characters when - a file is created. The files are placed in the subdirectory X. of - a directory named for the system for which the files were created. - #endif - - Temporary receive files - These are used when receiving files from another system. They are - later renamed to the final name. The actual name is unimportant, - although it generally begins with TM.. - #if SPOOLDIR_V2 || SPOOLDIR_BSD42 - These files are placed in the spool directory. - #elif SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR - These files are placed in the directory .Temp. - #elif SPOOLDIR_HDB || SPOOLDIR_SVR4 - These files are placed in a directory named for the system for - which they were created. - #endif - - System status files - These are used to record when the last call was made to the system - and what the status is. They are used to prevent frequent recalls - to a system which is not responding. I will not attempt to - recreate the format of these exactly, since they are not all that - important. They will be put in the directory .Status, as in HDB, - and they use the system name as the name of the file. - - Sequence file - This is used to generate a unique sequence number. It contains an - ASCII number. - #if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - The file is named SEQF and is kept in the spool directory. - #elif SPOOLDIR_HDB || SPOOLDIR_SVR4 - A separate sequence file is kept for each system in the directory - .Sequence with the name of the system. - #elif SPOOLDIR_ULTRIX - Each system with a file sys/ssssss has a sequence file in - sys/ssssss/.SEQF. Other systems use sys/DEFAULT/.SEQF. - #else SPOOLDIR_TAYLOR - A sequence file named SEQF is kept in the directory ssssss for each - system. - #endif - */ - -/* Given the name of a file as specified in a UUCP command, and the - system for which this file has been created, return where to find - it in the spool directory. The file will begin with C. (a command - file), D. (a data file) or X. (an execution file). Under - SPOOLDIR_SVR4 we need to know the grade of the file created by the - local system; this is the bgrade argument, which is -1 for a file - from a remote system. */ - -/*ARGSUSED*/ -char * -zsfind_file (zsimple, zsystem, bgrade) - const char *zsimple; - const char *zsystem; - int bgrade; -{ - /* 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; - } - -#if ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR - if (*zsimple == 'X') - { - 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 - the X. file. This is easy under SPOOLDIR_HDB or - SPOOLDIR_SVR4 SPOOLDIR_TAYLOR, because the file will be in a - directory named for the system. Under other schemes, we must - get the system name from the X. file name. To prevent - security violations, we set the system name directly here; - this will cause problems if the maximum file name length is - 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 < 5) - { - 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 */ - -#if SPOOLDIR_V2 - /* V2 never uses subdirectories. */ - return zbufcpy (zsimple); -#endif /* SPOOLDIR_V2 */ - -#if SPOOLDIR_HDB - /* HDB always uses the system name as a directory. */ - return zsysdep_in_dir (zsystem, zsimple); -#endif /* SPOOLDIR_HDB */ - -#if SPOOLDIR_SVR4 - /* SVR4 uses grade directories within the system directory for local - command and data files. */ - if (bgrade < 0 || *zsimple == 'X') - return zsysdep_in_dir (zsystem, zsimple); - else - { - char abgrade[2]; - - abgrade[0] = bgrade; - abgrade[1] = '\0'; - return zsappend3 (zsystem, abgrade, zsimple); - } -#endif /* SPOOLDIR_SVR4 */ - -#if ! SPOOLDIR_V2 && ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 - switch (*zsimple) - { - case 'C': - case 'T': -#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - return zsysdep_in_dir ("C.", zsimple); -#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */ -#if SPOOLDIR_ULTRIX - if (fsultrix_has_spool (zsystem)) - return zsappend4 ("sys", zsystem, "C.", zsimple); - else - return zsappend4 ("sys", "DEFAULT", "C.", zsimple); -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - return zsappend3 (zsystem, "C.", zsimple); -#endif /* SPOOLDIR_TAYLOR */ - - case 'D': -#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - { - size_t c; - boolean ftruncated; - - /* D.LOCAL in D.LOCAL/, others in D./. If BSD43, D.LOCALX in - D.LOCALX/. */ - ftruncated = TRUE; - if (strncmp (zsimple + 2, zSlocalname, strlen (zSlocalname)) == 0) - { - c = strlen (zSlocalname); - ftruncated = FALSE; - } - else if (strncmp (zsimple + 2, zSlocalname, 7) == 0) - c = 7; - else if (strncmp (zsimple + 2, zSlocalname, 6) == 0) - c = 6; - else - c = 0; -#if SPOOLDIR_BSD43 - if (c > 0 && zsimple[c + 2] == 'X') - c++; -#endif /* SPOOLDIR_BSD43 */ - if (c > 0) - { - char *zalloc; - - zalloc = zbufalc (c + 3); - memcpy (zalloc, zsimple, c + 2); - zalloc[c + 2] = '\0'; - - /* If we truncated the system name, and there is no existing - directory with the truncated name, then just use D.. */ - if (! ftruncated || fsysdep_directory (zalloc)) - { - char *zret; - - zret = zsysdep_in_dir (zalloc, zsimple); - ubuffree (zalloc); - return zret; - } - ubuffree (zalloc); - } - return zsysdep_in_dir ("D.", zsimple); - } -#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */ -#if SPOOLDIR_ULTRIX - { - size_t c; - boolean ftruncated; - char *zfree; - const char *zdir; - char *zret; - - /* D.LOCALX in D.LOCALX/, D.LOCAL in D.LOCAL/, others in D./. */ - ftruncated = TRUE; - if (strncmp (zsimple + 2, zSlocalname, strlen (zSlocalname)) == 0) - { - c = strlen (zSlocalname); - ftruncated = FALSE; - } - else if (strncmp (zsimple + 2, zSlocalname, 7) == 0) - c = 7; - else if (strncmp (zsimple + 2, zSlocalname, 6) == 0) - c = 6; - else - c = 0; - if (c > 0 && zsimple[c + 2] == 'X') - ++c; - if (c > 0) - { - zfree = zbufalc (c + 3); - memcpy (zfree, zsimple, c + 2); - zfree[c + 2] = '\0'; - zdir = zfree; - - /* If we truncated the name, and there is no directory for - the truncated name, then don't use it. */ - if (ftruncated) - { - char *zlook; - - zlook = zsappend3 ("sys", - (fsultrix_has_spool (zsystem) - ? zsystem - : "DEFAULT"), - zdir); - if (! fsysdep_directory (zlook)) - zdir = "D."; - ubuffree (zlook); - } - } - else - { - zfree = NULL; - zdir = "D."; - } - - zret = zsappend4 ("sys", - (fsultrix_has_spool (zsystem) - ? zsystem - : "DEFAULT"), - zdir, - zsimple); - ubuffree (zfree); - return zret; - } -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - if (zsimple[2] == 'X') - return zsappend3 (zsystem, "D.X", zsimple); - else - return zsappend3 (zsystem, "D.", zsimple); -#endif /* SPOOLDIR_TAYLOR */ - - - case 'X': -#if SPOOLDIR_BSD42 - return zbufcpy (zsimple); -#endif -#if SPOOLDIR_BSD43 - return zsysdep_in_dir ("X.", zsimple); -#endif -#if SPOOLDIR_ULTRIX - return zsappend4 ("sys", - (fsultrix_has_spool (zsystem) - ? zsystem - : "DEFAULT"), - "X.", - zsimple); -#endif -#if SPOOLDIR_TAYLOR - return zsappend3 (zsystem, "X.", zsimple); -#endif - } - - /* This is just to avoid warnings; it will never be executed. */ - return NULL; -#endif /* ! SPOOLDIR_V2 && ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */ -} diff --git a/gnu/libexec/uucp/libunix/srmdir.c b/gnu/libexec/uucp/libunix/srmdir.c deleted file mode 100644 index e143cdf..0000000 --- a/gnu/libexec/uucp/libunix/srmdir.c +++ /dev/null @@ -1,112 +0,0 @@ -/* srmdir.c - Remove a directory and all its contents. - - Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_FTW_H -#include <ftw.h> -#endif - -static int isremove_dir P((const char *, struct stat *, int)); - -/* Keep a list of directories to be removed. */ - -struct sdirlist -{ - struct sdirlist *qnext; - char *zdir; -}; - -static struct sdirlist *qSdirlist; - -/* Remove a directory and all files in it. */ - -boolean -fsysdep_rmdir (zdir) - const char *zdir; -{ - boolean fret; - struct sdirlist *q; - - qSdirlist = NULL; - - fret = TRUE; - if (ftw ((char *) zdir, isremove_dir, 5) != 0) - { - ulog (LOG_ERROR, "ftw: %s", strerror (errno)); - fret = FALSE; - } - - q = qSdirlist; - while (q != NULL) - { - struct sdirlist *qnext; - - if (rmdir (q->zdir) != 0) - { - ulog (LOG_ERROR, "rmdir (%s): %s", q->zdir, strerror (errno)); - fret = FALSE; - } - ubuffree (q->zdir); - qnext = q->qnext; - xfree ((pointer) q); - q = qnext; - } - - return fret; -} - -/* Remove a file in a directory. */ - -/*ARGSUSED*/ -static int -isremove_dir (zfile, qstat, iflag) - const char *zfile; - struct stat *qstat; - int iflag; -{ - if (iflag == FTW_D || iflag == FTW_DNR) - { - struct sdirlist *q; - - q = (struct sdirlist *) xmalloc (sizeof (struct sdirlist)); - q->qnext = qSdirlist; - q->zdir = zbufcpy (zfile); - qSdirlist = q; - } - else - { - if (remove (zfile) != 0) - ulog (LOG_ERROR, "remove (%s): %s", zfile, strerror (errno)); - } - - return 0; -} diff --git a/gnu/libexec/uucp/libunix/statsb.c b/gnu/libexec/uucp/libunix/statsb.c deleted file mode 100644 index 4989cad..0000000 --- a/gnu/libexec/uucp/libunix/statsb.c +++ /dev/null @@ -1,634 +0,0 @@ -/* statsb.c - System dependent routines for uustat. - - Copyright (C) 1992, 1993, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char statsb_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -#if HAVE_TIME_H -#include <time.h> -#endif - -#if HAVE_UTIME_H -#include <utime.h> -#endif - -/* Local functions. */ - -static int issettime P((const char *z, time_t inow)); -static boolean fskill_or_rejuv P((pointer puuconf, const char *zid, - boolean fkill)); - -/* 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 -issettime(z, inow) - const char *z; - time_t inow; -{ -#if HAVE_UTIME_H - struct utimbuf s; - - s.actime = inow; - s.modtime = inow; - return utime ((char *) z, &s); -#else - time_t ai[2]; - - ai[0] = inow; - ai[1] = inow; - return utime ((char *) z, ai); -#endif -} - -/* Kill a job, given the jobid. */ - -boolean -fsysdep_kill_job (puuconf, zid) - pointer puuconf; - const char *zid; -{ - return fskill_or_rejuv (puuconf, zid, TRUE); -} - -/* Rejuvenate a job, given the jobid. */ - -boolean -fsysdep_rejuvenate_job (puuconf, zid) - pointer puuconf; - const char *zid; -{ - return fskill_or_rejuv (puuconf, zid, FALSE); -} - -/* Kill or rejuvenate a job, given the jobid. */ - -static boolean -fskill_or_rejuv (puuconf, zid, fkill) - pointer puuconf; - const char *zid; - boolean fkill; -{ - char *zfile; - char *zsys; - char bgrade; - time_t inow = 0; - int iuuconf; - struct uuconf_system ssys; - FILE *e; - boolean fret; - char *zline; - size_t cline; - int isys; - - zfile = zsjobid_to_file (zid, &zsys, &bgrade); - if (zfile == NULL) - return FALSE; - - if (! fkill) - inow = time ((time_t *) NULL); - - iuuconf = uuconf_system_info (puuconf, zsys, &ssys); - if (iuuconf == UUCONF_NOT_FOUND) - { - if (! funknown_system (puuconf, zsys, &ssys)) - { - ulog (LOG_ERROR, "%s: Bad job id", zid); - ubuffree (zfile); - ubuffree (zsys); - return FALSE; - } - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (zfile); - ubuffree (zsys); - return FALSE; - } - - e = fopen (zfile, "r"); - if (e == NULL) - { - if (errno == ENOENT) - ulog (LOG_ERROR, "%s: Job not found", zid); - else - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - (void) uuconf_system_free (puuconf, &ssys); - ubuffree (zfile); - ubuffree (zsys); - return FALSE; - } - - /* Now we have to read through the file to identify any temporary - files. */ - fret = TRUE; - zline = NULL; - cline = 0; - while (getline (&zline, &cline, e) > 0) - { - struct scmd s; - - if (! fparse_cmd (zline, &s)) - { - ulog (LOG_ERROR, "Bad line in command file %s", zfile); - fret = FALSE; - continue; - } - - /* You are only permitted to delete a job if you submitted it or - if you are root or uucp. */ - if (strcmp (s.zuser, zsysdep_login_name ()) != 0 - && ! fsysdep_privileged ()) - { - ulog (LOG_ERROR, "%s: Not submitted by you", zid); - xfree ((pointer) zline); - (void) fclose (e); - (void) uuconf_system_free (puuconf, &ssys); - ubuffree (zfile); - ubuffree (zsys); - return FALSE; - } - - if (s.bcmd == 'S' || s.bcmd == 'E') - { - char *ztemp; - - ztemp = zsfind_file (s.ztemp, ssys.uuconf_zname, bgrade); - if (ztemp == NULL) - fret = FALSE; - else - { - if (fkill) - isys = remove (ztemp); - else - isys = issettime (ztemp, inow); - - if (isys != 0 && errno != ENOENT) - { - ulog (LOG_ERROR, "%s (%s): %s", - fkill ? "remove" : "utime", ztemp, - strerror (errno)); - fret = FALSE; - } - - ubuffree (ztemp); - } - } - } - - xfree ((pointer) zline); - (void) fclose (e); - (void) uuconf_system_free (puuconf, &ssys); - ubuffree (zsys); - - if (fkill) - isys = remove (zfile); - else - isys = issettime (zfile, inow); - - if (isys != 0 && errno != ENOENT) - { - ulog (LOG_ERROR, "%s (%s): %s", fkill ? "remove" : "utime", - zfile, strerror (errno)); - fret = FALSE; - } - - ubuffree (zfile); - - return fret; -} - -/* Get the time a work job was queued. */ - -long -ixsysdep_work_time (qsys, pseq) - const struct uuconf_system *qsys; - pointer pseq; -{ - char *zjobid, *zfile; - long iret; - - zjobid = zsysdep_jobid (qsys, pseq); - zfile = zsjobid_to_file (zjobid, (char **) NULL, (char *) NULL); - if (zfile == NULL) - return 0; - ubuffree (zjobid); - iret = ixsysdep_file_time (zfile); - ubuffree (zfile); - return iret; -} - -/* Get the time a file was created (actually, the time it was last - modified). */ - -long -ixsysdep_file_time (zfile) - const char *zfile; -{ - struct stat s; - - if (stat ((char *) zfile, &s) < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return ixsysdep_time ((long *) NULL); - } - - 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. */ - -boolean -fsysdep_all_status_init (phold) - pointer *phold; -{ - DIR *qdir; - - qdir = opendir ((char *) ".Status"); - if (qdir == NULL) - { - ulog (LOG_ERROR, "opendir (.Status): %s", strerror (errno)); - return FALSE; - } - - *phold = (pointer) qdir; - return TRUE; -} - -/* Get the next status file. */ - -char * -zsysdep_all_status (phold, pferr, qstat) - pointer phold; - boolean *pferr; - struct sstatus *qstat; -{ - DIR *qdir = (DIR *) phold; - struct dirent *qentry; - - while (TRUE) - { - errno = 0; - qentry = readdir (qdir); - if (qentry == NULL) - { - if (errno == 0) - *pferr = FALSE; - else - { - ulog (LOG_ERROR, "readdir: %s", strerror (errno)); - *pferr = TRUE; - } - return NULL; - } - - if (qentry->d_name[0] != '.') - { - struct uuconf_system ssys; - - /* Hack seriously; fsysdep_get_status only looks at the - zname element of the qsys argument, so if we fake that we - can read the status file. This should really be done - differently. */ - ssys.uuconf_zname = qentry->d_name; - if (fsysdep_get_status (&ssys, qstat, (boolean *) NULL)) - return zbufcpy (qentry->d_name); - - /* If fsysdep_get_status fails, it will output an error - message. We just continue with the next entry, so that - most of the status files will be displayed. */ - } - } -} - -/* Finish getting the status file. */ - -void -usysdep_all_status_free (phold) - pointer phold; -{ - DIR *qdir = (DIR *) phold; - - (void) closedir (qdir); -} - -/* Get the status of all processes holding lock files. We do this by - invoking ps after we've figured out the process entries to use. */ - -boolean -fsysdep_lock_status () -{ - DIR *qdir; - struct dirent *qentry; - int calc; - pid_t *pai; -#if HAVE_QNX_LOCKFILES - nid_t *painid; -#endif - int cgot; - int aidescs[3]; - char *zcopy, *ztok; - int cargs, iarg; - char **pazargs; - - qdir = opendir ((char *) zSlockdir); - if (qdir == NULL) - { - ulog (LOG_ERROR, "opendir (%s): %s", zSlockdir, strerror (errno)); - return FALSE; - } - - /* We look for entries that start with "LCK.." and ignore everything - else. This won't find all possible lock files, but it should - find all the locks on terminals and systems. */ - - 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; - pid_t ipid; - int icheck; - - if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0) - continue; - - zname = zsysdep_in_dir (zSlockdir, qentry->d_name); - o = open ((char *) zname, O_RDONLY | O_NOCTTY, 0); - if (o < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "open (%s): %s", zname, strerror (errno)); - ubuffree (zname); - continue; - } - -#if HAVE_V2_LOCKFILES - cread = read (o, &i, sizeof i); -#else - cread = read (o, ab, sizeof ab - 1); -#endif - - ierr = errno; - (void) close (o); - - if (cread < 0) - { - ulog (LOG_ERROR, "read %s: %s", zname, strerror (ierr)); - ubuffree (zname); - continue; - } - - 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 = (pid_t) i; -#else - ab[cread] = '\0'; - ipid = (pid_t) strtol (ab, (char **) NULL, 10); -#endif -#endif - -#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 = (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; - } - - if (cgot == 0) - return TRUE; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = 1; - aidescs[2] = 2; - - /* Parse PS_PROGRAM into an array of arguments. */ - zcopy = zbufcpy (PS_PROGRAM); - - cargs = 0; - for (ztok = strtok (zcopy, " \t"); - ztok != NULL; - ztok = strtok ((char *) NULL, " \t")) - ++cargs; - - pazargs = (char **) xmalloc ((cargs + 1) * sizeof (char *)); - - memcpy (zcopy, PS_PROGRAM, sizeof PS_PROGRAM); - for (ztok = strtok (zcopy, " \t"), iarg = 0; - ztok != NULL; - ztok = strtok ((char *) NULL, " \t"), ++iarg) - pazargs[iarg] = ztok; - pazargs[iarg] = NULL; - -#if ! HAVE_PS_MULTIPLE - /* We have to invoke ps multiple times. */ - { - 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%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, - (const char *) NULL); - if (ipid < 0) - ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno)); - else - (void) ixswait ((unsigned long) ipid, PS_PROGRAM); - } - ubuffree (zset); -#if HAVE_QNX_LOCKFILES - ubuffree (zsetnid); -#endif - } -#else - { - char *zlast; - int i; - pid_t ipid; - - zlast = zbufalc (strlen (pazargs[cargs - 1]) + cgot * 20 + 1); - strcpy (zlast, pazargs[cargs - 1]); - for (i = 0; i < cgot; i++) - { - char ab[20]; - - sprintf (ab, "%ld", (long) pai[i]); - strcat (zlast, ab); - if (i + 1 < cgot) - strcat (zlast, ","); - } - pazargs[cargs - 1] = zlast; - - ipid = ixsspawn ((const char **) pazargs, aidescs, FALSE, FALSE, - (const char *) NULL, FALSE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno)); - else - (void) ixswait ((unsigned long) ipid, PS_PROGRAM); - ubuffree (zlast); - } -#endif - - ubuffree (zcopy); - xfree ((pointer) pazargs); - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/status.c b/gnu/libexec/uucp/libunix/status.c deleted file mode 100644 index 66e1d385..0000000 --- a/gnu/libexec/uucp/libunix/status.c +++ /dev/null @@ -1,248 +0,0 @@ -/* status.c - Routines to get and set the status for a system. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> -#include <ctype.h> - -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - -/* If we are using HDB spool layout, store status using HDB status - values. SVR4 is a variant of HDB. */ - -#define MAP_STATUS 1 - -static const int aiMapstatus[] = -{ - 0, 13, 7, 6, 20, 4, 3, 2 -}; -#define CMAPENTRIES (sizeof (aiMapstatus) / sizeof (aiMapstatus[0])) - -#else /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */ - -#define MAP_STATUS 0 - -#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 */ - -/* Get the status of a system. This assumes that we are in the spool - directory. */ - -boolean -fsysdep_get_status (qsys, qret, pfnone) - const struct uuconf_system *qsys; - struct sstatus *qret; - boolean *pfnone; -{ - char *zname; - FILE *e; - char *zline; - char *zend, *znext; - boolean fbad; - int istat; - - if (pfnone != NULL) - *pfnone = FALSE; - - zname = zsysdep_in_dir (".Status", qsys->uuconf_zname); - e = fopen (zname, "r"); - if (e == NULL) - { - if (errno != ENOENT) - { - ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno)); - ubuffree (zname); - return FALSE; - } - zline = NULL; - } - else - { - size_t cline; - - zline = NULL; - cline = 0; - if (getline (&zline, &cline, e) <= 0) - { - xfree ((pointer) zline); - zline = NULL; - } - (void) fclose (e); - } - - if (zline == NULL) - { - /* There is either no status file for this system, or it's been - truncated, so fake a good status. */ - qret->ttype = STATUS_COMPLETE; - qret->cretries = 0; - qret->ilast = 0; - qret->cwait = 0; - qret->zstring = NULL; - if (pfnone != NULL) - *pfnone = TRUE; - ubuffree (zname); - return TRUE; - } - - /* It turns out that scanf is not used much in this program, so for - the benefit of small computers we avoid linking it in. This is - basically - - sscanf (zline, "%d %d %ld %d", &qret->ttype, &qret->cretries, - &qret->ilast, &qret->cwait); - - except that it's done with strtol. */ - - fbad = FALSE; - istat = (int) strtol (zline, &zend, 10); - if (zend == zline) - fbad = TRUE; - -#if MAP_STATUS - /* On some systems it may be appropriate to map system dependent status - values on to our status values. */ - { - int i; - - for (i = 0; i < CMAPENTRIES; ++i) - { - if (aiMapstatus[i] == istat) - { - istat = i; - break; - } - } - } -#endif /* MAP_STATUS */ - - if (istat < 0 || istat >= (int) STATUS_VALUES) - istat = (int) STATUS_COMPLETE; - qret->ttype = (enum tstatus_type) istat; - znext = zend; - qret->cretries = (int) strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - znext = zend; - qret->ilast = strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - znext = zend; - qret->cwait = (int) strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - - if (! fbad) - { - znext = zend; - while (isspace (BUCHAR (*znext))) - ++znext; - if (*znext == '\0') - qret->zstring = NULL; - else - { - if (*znext == '"') - ++znext; - qret->zstring = zbufcpy (znext); - zend = qret->zstring + strlen (qret->zstring); - while (zend != qret->zstring && *zend != ' ') - --zend; - if (*zend == '"' && zend != qret->zstring) - --zend; - if (zend != qret->zstring) - *zend = '\0'; - else - { - ubuffree (qret->zstring); - qret->zstring = NULL; - } - } - } - - xfree ((pointer) zline); - - if (fbad) - { - ulog (LOG_ERROR, "%s: Bad status file format", zname); - ubuffree (zname); - return FALSE; - } - - ubuffree (zname); - - return TRUE; -} - -/* Set the status of a remote system. This assumes the system is - locked when this is called, and that the program is in the spool - directory. */ - -boolean -fsysdep_set_status (qsys, qset) - const struct uuconf_system *qsys; - const struct sstatus *qset; -{ - char *zname; - FILE *e; - int istat; - - zname = zsysdep_in_dir (".Status", qsys->uuconf_zname); - - e = esysdep_fopen (zname, TRUE, FALSE, TRUE); - ubuffree (zname); - if (e == NULL) - return FALSE; - istat = (int) qset->ttype; - -#if MAP_STATUS - /* On some systems it may be appropriate to map istat onto a system - dependent number. */ - if (istat >= 0 && istat < CMAPENTRIES) - istat = aiMapstatus[istat]; -#endif /* MAP_STATUS */ - - fprintf (e, "%d %d %ld %d ", istat, qset->cretries, qset->ilast, - qset->cwait); - -#if SPOOLDIR_SVR4 - fprintf (e, "\"%s\"", azStatus[(int) qset->ttype]); -#else - fprintf (e, "%s", azStatus[(int) qset->ttype]); -#endif - - fprintf (e, " %s\n", qsys->uuconf_zname); - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/libunix/strerr.c b/gnu/libexec/uucp/libunix/strerr.c deleted file mode 100644 index 8e7480f..0000000 --- a/gnu/libexec/uucp/libunix/strerr.c +++ /dev/null @@ -1,24 +0,0 @@ -/* strerr.c - Return a string for a Unix errno value. */ - -#include "uucp.h" - -#include <errno.h> - -#ifndef sys_nerr -extern int sys_nerr; -#endif -#ifndef sys_errlist -extern char *sys_errlist[]; -#endif - -#undef strerror - -char * -strerror (ierr) - int ierr; -{ - if (ierr >= 0 && ierr < sys_nerr) - return sys_errlist[ierr]; - return (char *) "unknown error"; -} diff --git a/gnu/libexec/uucp/libunix/tli.c b/gnu/libexec/uucp/libunix/tli.c deleted file mode 100644 index 0330646..0000000 --- a/gnu/libexec/uucp/libunix/tli.c +++ /dev/null @@ -1,629 +0,0 @@ -/* tli.c - Code to handle TLI connections. - - Copyright (C) 1992, 1993, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char tli_rcsid[] = "$FreeBSD$"; -#endif - -#if HAVE_TLI - -#include "sysdep.h" -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "system.h" - -#include <errno.h> -#include <paths.h> - -#if HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif - -#if HAVE_TIUSER_H -#include <tiuser.h> -#else -#if HAVE_XTI_H -#include <xti.h> -#else -#if HAVE_SYS_TLI_H -#include <sys/tli.h> -#endif -#endif -#endif - -#if HAVE_STROPTS_H -#include <stropts.h> -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -/* The arguments to t_alloca have two different names. I want the - SVID ones, not the XPG3 ones. */ -#ifndef T_BIND -#define T_BIND T_BIND_STR -#endif -#ifndef T_CALL -#define T_CALL T_CALL_STR -#endif - -/* Hopefully these externs will not cause any trouble. This is how - they are shown in the SVID. */ -extern int t_errno; -extern char *t_errlist[]; -extern int t_nerr; - -#ifndef HAVE_TIUSER_H -#ifndef t_alloc -extern pointer t_alloc (); -#endif -#endif - -/* This code handles TLI connections. It's Unix specific. It's - largely based on code from Unix Network Programming, by W. Richard - Stevens. */ - -/* Local functions. */ -static const char *ztlierror P((void)); -static void utli_free P((struct sconnection *qconn)); -static boolean ftli_push P((struct sconnection *qconn)); -static boolean ftli_open P((struct sconnection *qconn, long ibaud, - boolean fwait)); -static boolean ftli_close P((struct sconnection *qconn, - pointer puuconf, - struct uuconf_dialer *qdialer, - boolean fsuccess)); -static boolean ftli_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 a TLI connection. */ -static const struct sconncmds stlicmds = -{ - utli_free, - NULL, /* pflock */ - NULL, /* pfunlock */ - ftli_open, - ftli_close, - ftli_dial, - fsysdep_conn_read, - fsysdep_conn_write, - fsysdep_conn_io, - NULL, /* pfbreak */ - NULL, /* pfset */ - NULL, /* pfcarrier */ - fsysdep_conn_chat, - NULL /* pibaud */ -}; - -/* Get a TLI error string. */ - -static const char * -ztlierror () -{ - if (t_errno == TSYSERR) - return strerror (errno); - if (t_errno < 0 || t_errno >= t_nerr) - return "Unknown TLI error"; - return t_errlist[t_errno]; -} - -/* Initialize a TLI connection. This may be called with qconn->qport - NULL, when opening standard input as a TLI connection. */ - -boolean -fsysdep_tli_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 = TRUE; - q->ibaud = 0; - - qconn->psysdep = (pointer) q; - qconn->qcmds = &stlicmds; - return TRUE; -} - -/* Free a TLI connection. */ - -static void -utli_free (qconn) - struct sconnection *qconn; -{ - xfree (qconn->psysdep); -} - -/* Push all desired modules onto a TLI stream. If the user requests a - STREAMS connection without giving a list of modules, we just push - tirdwr. If the I_PUSH ioctl is not defined on this system, we just - ignore any list of modules. */ - -static boolean -ftli_push (qconn) - struct sconnection *qconn; -{ -#ifdef I_PUSH - - struct ssysdep_conn *qsysdep; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - if (qconn->qport->uuconf_u.uuconf_stli.uuconf_pzpush != NULL) - { - char **pz; - - for (pz = qconn->qport->uuconf_u.uuconf_stli.uuconf_pzpush; - *pz != NULL; - pz++) - { - if (ioctl (qsysdep->o, I_PUSH, *pz) < 0) - { - ulog (LOG_ERROR, "ioctl (I_PUSH, %s): %s", *pz, - strerror (errno)); - return FALSE; - } - } - } - else if (qconn->qport->uuconf_u.uuconf_stli.uuconf_fstream) - { - if (ioctl (qsysdep->o, I_PUSH, "tirdwr") < 0) - { - ulog (LOG_ERROR, "ioctl (I_PUSH, tirdwr): %s", - strerror (errno)); - return FALSE; - } - } - - /* If we have just put the connection into stream mode, we must turn - off the TLI flag to avoid using TLI calls on it. */ - if (qconn->qport->uuconf_u.uuconf_stli.uuconf_fstream) - qsysdep->ftli = FALSE; - -#endif /* defined (I_PUSH) */ - - return TRUE; -} - -/* Open a TLI connection. If the fwait argument is TRUE, we are - running as a server. Otherwise we are just trying to reach another - system. */ - -static boolean -ftli_open (qconn, ibaud, fwait) - struct sconnection *qconn; - long ibaud; - boolean fwait; -{ - struct ssysdep_conn *qsysdep; - const char *zdevice; - char *zfreedev; - const char *zservaddr; - char *zfreeaddr; - uid_t ieuid; - boolean fswap; - struct t_bind *qtbind; - struct t_call *qtcall; - - /* Unlike most other device types, we don't bother to call - ulog_device here, because fconn_open calls it with the name of - the port anyhow. */ - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - zdevice = qconn->qport->uuconf_u.uuconf_stli.uuconf_zdevice; - if (zdevice == NULL) - zdevice = qconn->qport->uuconf_zname; - - zfreedev = NULL; - if (*zdevice != '/') - { - zfreedev = zbufalc (sizeof _PATH_DEV + strlen (zdevice)); - sprintf (zfreedev, "%s%s", _PATH_DEV, zdevice); - zdevice = zfreedev; - } - - /* If we are acting as a server, swap to our real user ID before - calling t_open. This will permit the server to use privileged - TCP ports when invoked by root. We only swap if our effective - user ID is not root, so that the program can also be made suid - root in order to get privileged ports when invoked by anybody. */ - fswap = fwait && geteuid () != 0; - if (fswap) - { - if (! fsuser_perms (&ieuid)) - { - ubuffree (zfreedev); - return FALSE; - } - } - - qsysdep->o = t_open (zdevice, O_RDWR, (struct t_info *) NULL); - if (qsysdep->o < 0) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_ERROR, "t_open (%s): %s", zdevice, ztlierror ()); - ubuffree (zfreedev); - return FALSE; - } - - if (fcntl (qsysdep->o, F_SETFD, - fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - ubuffree (zfreedev); - (void) t_close (qsysdep->o); - qsysdep->o = -1; - return FALSE; - } - - qsysdep->iflags = fcntl (qsysdep->o, F_GETFL, 0); - if (qsysdep->iflags < 0) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - ubuffree (zfreedev); - (void) t_close (qsysdep->o); - qsysdep->o = -1; - return FALSE; - } - - /* We save our process ID in the qconn structure. This is checked - in ftli_close. */ - qsysdep->ipid = getpid (); - - /* If we aren't waiting for a connection, we can bind to any local - address, and then we're finished. */ - if (! fwait) - { - /* fswap is known to be FALSE here. */ - ubuffree (zfreedev); - if (t_bind (qsysdep->o, (struct t_bind *) NULL, - (struct t_bind *) NULL) < 0) - { - ulog (LOG_ERROR, "t_bind: %s", ztlierror ()); - (void) t_close (qsysdep->o); - qsysdep->o = -1; - return FALSE; - } - return TRUE; - } - - /* Run as a server and wait for a new connection. The code in - uucico.c has already detached us from our controlling terminal. - From this point on if the server gets an error we exit; we only - return if we have received a connection. It would be more robust - to respawn the server if it fails; someday. */ - qtbind = (struct t_bind *) t_alloc (qsysdep->o, T_BIND, T_ALL); - if (qtbind == NULL) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_FATAL, "t_alloc (T_BIND): %s", ztlierror ()); - } - - zservaddr = qconn->qport->uuconf_u.uuconf_stli.uuconf_zservaddr; - if (zservaddr == NULL) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_FATAL, "Can't run as TLI server; no server address"); - } - - zfreeaddr = zbufcpy (zservaddr); - qtbind->addr.len = cescape (zfreeaddr); - if (qtbind->addr.len > qtbind->addr.maxlen) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_FATAL, "%s: TLI server address too long (max %d)", - zservaddr, qtbind->addr.maxlen); - } - memcpy (qtbind->addr.buf, zfreeaddr, qtbind->addr.len); - ubuffree (zfreeaddr); - - qtbind->qlen = 5; - - if (t_bind (qsysdep->o, qtbind, (struct t_bind *) NULL) < 0) - { - if (fswap) - (void) fsuucp_perms ((long) ieuid); - ulog (LOG_FATAL, "t_bind (%s): %s", zservaddr, ztlierror ()); - } - - if (fswap) - { - if (! fsuucp_perms ((long) ieuid)) - ulog (LOG_FATAL, "Could not swap back to UUCP user permissions"); - } - - (void) t_free ((pointer) qtbind, T_BIND); - - qtcall = (struct t_call *) t_alloc (qsysdep->o, T_CALL, T_ALL); - if (qtcall == NULL) - ulog (LOG_FATAL, "t_alloc (T_CALL): %s", ztlierror ()); - - while (! FGOT_SIGNAL ()) - { - int onew; - pid_t ipid; - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftli_open: Waiting for connections"); - - if (t_listen (qsysdep->o, qtcall) < 0) - ulog (LOG_FATAL, "t_listen: %s", ztlierror ()); - - onew = t_open (zdevice, O_RDWR, (struct t_info *) NULL); - if (onew < 0) - ulog (LOG_FATAL, "t_open (%s): %s", zdevice, ztlierror ()); - - if (fcntl (onew, F_SETFD, - fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0) - ulog (LOG_FATAL, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - - if (t_bind (onew, (struct t_bind *) NULL, (struct t_bind *) NULL) < 0) - ulog (LOG_FATAL, "t_bind: %s", ztlierror ()); - - if (t_accept (qsysdep->o, onew, qtcall) < 0) - { - /* We may have received a disconnect. */ - if (t_errno != TLOOK) - ulog (LOG_FATAL, "t_accept: %s", ztlierror ()); - if (t_rcvdis (qsysdep->o, (struct t_discon *) NULL) < 0) - ulog (LOG_FATAL, "t_rcvdis: %s", ztlierror ()); - (void) t_close (onew); - continue; - } - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftli_open: Got connection; forking"); - - ipid = ixsfork (); - if (ipid < 0) - ulog (LOG_FATAL, "fork: %s", strerror (errno)); - if (ipid == 0) - { - ulog_close (); - - (void) t_close (qsysdep->o); - qsysdep->o = onew; - - /* Push any desired modules. */ - if (! ftli_push (qconn)) - _exit (EXIT_FAILURE); - - /* Now we fork and let our parent die, so that we become - a child of init. This lets the main server code wait - for its child and then continue without accumulating - zombie children. */ - ipid = ixsfork (); - if (ipid < 0) - { - ulog (LOG_ERROR, "fork: %s", strerror (errno)); - _exit (EXIT_FAILURE); - } - - if (ipid != 0) - _exit (EXIT_SUCCESS); - - ulog_id (getpid ()); - - return TRUE; - } - - (void) t_close (onew); - - /* Now wait for the child. */ - (void) ixswait ((unsigned long) ipid, (const char *) NULL); - } - - /* We got a signal. */ - usysdep_exit (FALSE); - - /* Avoid compiler warnings. */ - return FALSE; -} - -/* Close the port. */ - -/*ARGSUSED*/ -static boolean -ftli_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; - if (qsysdep->o >= 0) - { - if (qsysdep->ftli) - { - if (t_close (qsysdep->o) < 0) - { - ulog (LOG_ERROR, "t_close: %s", ztlierror ()); - fret = FALSE; - } - } - else - { - if (close (qsysdep->o) < 0) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - fret = FALSE; - } - } - - qsysdep->o = -1; - } - - /* If the current pid is not the one we used to open the port, then - we must have forked up above and we are now the child. In this - case, we are being called from within the fendless loop in - uucico.c. We return FALSE to force the loop to end and the child - to exit. This should be handled in a cleaner fashion. */ - if (qsysdep->ipid != getpid ()) - fret = FALSE; - - return fret; -} - -/* Dial out on a TLI port, so to speak: connect to a remote computer. */ - -/*ARGSUSED*/ -static boolean -ftli_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialerfound) - struct sconnection *qconn; - pointer puuconf; - const struct uuconf_system *qsys; - const char *zphone; - struct uuconf_dialer *qdialer; - enum tdialerfound *ptdialerfound; -{ - struct ssysdep_conn *qsysdep; - char **pzdialer; - const char *zaddr; - struct t_call *qtcall; - char *zescape; - - qsysdep = (struct ssysdep_conn *) qconn->psysdep; - - *ptdialerfound = DIALERFOUND_FALSE; - - pzdialer = qconn->qport->uuconf_u.uuconf_stli.uuconf_pzdialer; - if (*pzdialer == NULL) - pzdialer = NULL; - - /* If the first dialer is "TLI" or "TLIS", we use the first token - (pzdialer[1]) as the address to connect to. */ - zaddr = zphone; - if (pzdialer != NULL - && (strcmp (pzdialer[0], "TLI") == 0 - || strcmp (pzdialer[0], "TLIS") == 0)) - { - if (pzdialer[1] == NULL) - ++pzdialer; - else - { - if (strcmp (pzdialer[1], "\\D") != 0 - && strcmp (pzdialer[1], "\\T") != 0) - zaddr = pzdialer[1]; - pzdialer += 2; - } - } - - if (zaddr == NULL) - { - ulog (LOG_ERROR, "No address for TLI connection"); - return FALSE; - } - - qtcall = (struct t_call *) t_alloc (qsysdep->o, T_CALL, T_ADDR); - if (qtcall == NULL) - { - ulog (LOG_ERROR, "t_alloc (T_CALL): %s", ztlierror ()); - return FALSE; - } - - zescape = zbufcpy (zaddr); - qtcall->addr.len = cescape (zescape); - if (qtcall->addr.len > qtcall->addr.maxlen) - { - ulog (LOG_ERROR, "%s: TLI address too long (max %d)", zaddr, - qtcall->addr.maxlen); - ubuffree (zescape); - return FALSE; - } - memcpy (qtcall->addr.buf, zescape, qtcall->addr.len); - ubuffree (zescape); - - if (t_connect (qsysdep->o, qtcall, (struct t_call *) NULL) < 0) - { - if (t_errno != TLOOK) - ulog (LOG_ERROR, "t_connect: %s", ztlierror ()); - else - { - if (t_rcvdis (qsysdep->o, (struct t_discon *) NULL) < 0) - ulog (LOG_ERROR, "t_rcvdis: %s", ztlierror ()); - else - ulog (LOG_ERROR, "Connection refused"); - } - return FALSE; - } - - /* We've connected to the remote. Push any desired modules. */ - if (! ftli_push (qconn)) - return FALSE; - - /* Handle the rest of the dialer sequence. */ - if (pzdialer != NULL && *pzdialer != NULL) - { - if (! fconn_dial_sequence (qconn, puuconf, pzdialer, qsys, zphone, - qdialer, ptdialerfound)) - return FALSE; - } - - return TRUE; -} - -#endif /* HAVE_TLI */ diff --git a/gnu/libexec/uucp/libunix/tmpfil.c b/gnu/libexec/uucp/libunix/tmpfil.c deleted file mode 100644 index f2f5ba8..0000000 --- a/gnu/libexec/uucp/libunix/tmpfil.c +++ /dev/null @@ -1,84 +0,0 @@ -/* tmpfil.c - Get a temporary file name. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" - -#define ZDIGS \ - "0123456789abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-" -#define CDIGS (sizeof ZDIGS - 1) - -/*ARGSUSED*/ -char * -zstemp_file (qsys) - const struct uuconf_system *qsys; -{ - static int icount; - const char *const zdigs = ZDIGS; - char ab[14]; - pid_t ime; - int iset; - - ab[0] = 'T'; - ab[1] = 'M'; - ab[2] = '.'; - - ime = getpid (); - iset = 3; - while (ime > 0 && iset < 10) - { - ab[iset] = zdigs[ime % CDIGS]; - ime /= CDIGS; - ++iset; - } - - ab[iset] = '.'; - ++iset; - - ab[iset] = zdigs[icount / CDIGS]; - ++iset; - ab[iset] = zdigs[icount % CDIGS]; - ++iset; - - ab[iset] = '\0'; - - ++icount; - if (icount >= CDIGS * CDIGS) - icount = 0; - -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 - return zbufcpy (ab); -#endif -#if SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX || SPOOLDIR_TAYLOR - return zsysdep_in_dir (".Temp", ab); -#endif -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - return zsysdep_in_dir (qsys->uuconf_zname, ab); -#endif -} diff --git a/gnu/libexec/uucp/libunix/trunc.c b/gnu/libexec/uucp/libunix/trunc.c deleted file mode 100644 index c93e82e..0000000 --- a/gnu/libexec/uucp/libunix/trunc.c +++ /dev/null @@ -1,157 +0,0 @@ -/* trunc.c - Truncate a file to zero length. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -/* External functions. */ -#ifndef lseek -extern off_t lseek (); -#endif - -/* Truncate a file to zero length. If this fails, it closes and - removes the file. We support a number of different means of - truncation, which is probably a waste of time since this function - is currently only called when the 'f' protocol resends a file. */ - -#if HAVE_FTRUNCATE -#undef HAVE_LTRUNC -#define HAVE_LTRUNC 0 -#endif - -#if ! HAVE_FTRUNCATE && ! HAVE_LTRUNC -#ifdef F_CHSIZE -#define HAVE_F_CHSIZE 1 -#else /* ! defined (F_CHSIZE) */ -#ifdef F_FREESP -#define HAVE_F_FREESP 1 -#endif /* defined (F_FREESP) */ -#endif /* ! defined (F_CHSIZE) */ -#endif /* ! HAVE_FTRUNCATE && ! HAVE_LTRUNC */ - -openfile_t -esysdep_truncate (e, zname) - openfile_t e; - const char *zname; -{ - int o; - -#if HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP - int itrunc; - - if (! ffilerewind (e)) - { - ulog (LOG_ERROR, "rewind: %s", strerror (errno)); - (void) ffileclose (e); - (void) remove (zname); - return EFILECLOSED; - } - -#if USE_STDIO - o = fileno (e); -#else - o = e; -#endif - -#if HAVE_FTRUNCATE - itrunc = ftruncate (o, 0); -#endif -#if HAVE_LTRUNC - itrunc = ltrunc (o, (long) 0, SEEK_SET); -#endif -#if HAVE_F_CHSIZE - itrunc = fcntl (o, F_CHSIZE, (off_t) 0); -#endif -#if HAVE_F_FREESP - /* This selection is based on an implementation of ftruncate by - kucharsk@Solbourne.com (William Kucharski). */ - { - struct flock fl; - - fl.l_whence = 0; - fl.l_len = 0; - fl.l_start = 0; - fl.l_type = F_WRLCK; - - itrunc = fcntl (o, F_FREESP, &fl); - } -#endif - - if (itrunc != 0) - { -#if HAVE_FTRUNCATE - ulog (LOG_ERROR, "ftruncate: %s", strerror (errno)); -#endif -#ifdef HAVE_LTRUNC - ulog (LOG_ERROR, "ltrunc: %s", strerror (errno)); -#endif -#ifdef HAVE_F_CHSIZE - ulog (LOG_ERROR, "fcntl (F_CHSIZE): %s", strerror (errno)); -#endif -#ifdef HAVE_F_FREESP - ulog (LOG_ERROR, "fcntl (F_FREESP): %s", strerror (errno)); -#endif - - (void) ffileclose (e); - (void) remove (zname); - return EFILECLOSED; - } - - return e; -#else /* ! (HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP) */ - (void) ffileclose (e); - (void) remove (zname); - - o = creat ((char *) zname, IPRIVATE_FILE_MODE); - - if (o == -1) - { - ulog (LOG_ERROR, "creat (%s): %s", zname, strerror (errno)); - return EFILECLOSED; - } - - if (fcntl (o, F_SETFD, fcntl (o, F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - (void) close (o); - return EFILECLOSED; - } - -#if USE_STDIO - e = fdopen (o, (char *) BINWRITE); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen (%s): %s", zname, strerror (errno)); - (void) close (o); - (void) remove (zname); - return NULL; - } -#else /* ! USE_STDIO */ - e = o; -#endif /* ! USE_STDIO */ - - return e; -#endif /* ! (HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP) */ -} diff --git a/gnu/libexec/uucp/libunix/uacces.c b/gnu/libexec/uucp/libunix/uacces.c deleted file mode 100644 index 8f37a8e..0000000 --- a/gnu/libexec/uucp/libunix/uacces.c +++ /dev/null @@ -1,205 +0,0 @@ -/* uacces.c - Check access to a file by user name. - - Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" - -#include <pwd.h> -#include <errno.h> - -#if HAVE_GETGRENT -#include <grp.h> -#if GETGRENT_DECLARATION_OK -#ifndef getgrent -extern struct group *getgrent (); -#endif -#endif -#endif /* HAVE_GETGRENT */ - -#if GETPWNAM_DECLARATION_OK -#ifndef getpwnam -extern struct passwd *getpwnam (); -#endif -#endif - -/* Do access(2) on a stat structure, except that the user name is - provided. If the user name in zuser is NULL, require the file to - be accessible to the world. Return TRUE if access is permitted, - FALSE otherwise. This does not log an error message. */ - -boolean -fsuser_access (q, imode, zuser) - const struct stat *q; - int imode; - const char *zuser; -{ - static char *zuser_hold; - static uid_t iuid_hold; - static gid_t igid_hold; - static int cgroups_hold; - static gid_t *paigroups_hold; - int ir, iw, ix, iand; - - if (imode == F_OK) - return TRUE; - - if (zuser != NULL) - { - /* We keep static variables around for the last user we did, to - avoid looking up a user multiple times. */ - if (zuser_hold == NULL || strcmp (zuser_hold, zuser) != 0) - { - struct passwd *qpwd; - - if (zuser_hold != NULL) - { - ubuffree (zuser_hold); - zuser_hold = NULL; - cgroups_hold = 0; - xfree ((pointer) paigroups_hold); - paigroups_hold = NULL; - } - - qpwd = getpwnam ((char *) zuser); - if (qpwd == NULL) - { - /* Check this as a remote request. */ - zuser = NULL; - } - else - { -#if HAVE_GETGRENT - struct group *qg; -#endif - - zuser_hold = zbufcpy (zuser); - - iuid_hold = qpwd->pw_uid; - igid_hold = qpwd->pw_gid; - -#if HAVE_GETGRENT - /* Get the list of groups for this user. This is - definitely more appropriate for BSD than for System - V. It may just be a waste of time, and perhaps it - should be configurable. */ - setgrent (); - while ((qg = getgrent ()) != NULL) - { - const char **pz; - - if (qg->gr_gid == igid_hold) - continue; - for (pz = (const char **) qg->gr_mem; *pz != NULL; pz++) - { - if ((*pz)[0] == *zuser - && strcmp (*pz, zuser) == 0) - { - paigroups_hold = ((gid_t *) - (xrealloc - ((pointer) paigroups_hold, - ((cgroups_hold + 1) - * sizeof (gid_t))))); - paigroups_hold[cgroups_hold] = qg->gr_gid; - ++cgroups_hold; - break; - } - } - } - endgrent (); -#endif - } - } - } - - - /* Now do the actual access check. */ - - if (zuser != NULL) - { - /* The superuser can do anything. */ - if (iuid_hold == 0) - return TRUE; - - /* If this is the uid we're running under, there's no point to - checking access further, because when we actually try the - operation the system will do the checking for us. */ - if (iuid_hold == geteuid ()) - return TRUE; - } - - ir = S_IROTH; - iw = S_IWOTH; - ix = S_IXOTH; - - if (zuser != NULL) - { - if (iuid_hold == q->st_uid) - { - ir = S_IRUSR; - iw = S_IWUSR; - ix = S_IXUSR; - } - else - { - boolean fgroup; - - fgroup = FALSE; - if (igid_hold == q->st_gid) - fgroup = TRUE; - else - { - int i; - - for (i = 0; i < cgroups_hold; i++) - { - if (paigroups_hold[i] == q->st_gid) - { - fgroup = TRUE; - break; - } - } - } - - if (fgroup) - { - ir = S_IRGRP; - iw = S_IWGRP; - ix = S_IXGRP; - } - } - } - - iand = 0; - if ((imode & R_OK) != 0) - iand |= ir; - if ((imode & W_OK) != 0) - iand |= iw; - if ((imode & X_OK) != 0) - iand |= ix; - - return (q->st_mode & iand) == iand; -} diff --git a/gnu/libexec/uucp/libunix/ultspl.c b/gnu/libexec/uucp/libunix/ultspl.c deleted file mode 100644 index 34921d2..0000000 --- a/gnu/libexec/uucp/libunix/ultspl.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ultspl.c - See whether there is an Ultrix spool directory for a system. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -boolean -fsultrix_has_spool (zsystem) - const char *zsystem; -{ - char *z; - boolean fret; - - z = zsysdep_in_dir ("sys", zsystem); - fret = fsysdep_directory (z); - ubuffree (z); - return fret; -} diff --git a/gnu/libexec/uucp/libunix/unknwn.c b/gnu/libexec/uucp/libunix/unknwn.c deleted file mode 100644 index 76f5345..0000000 --- a/gnu/libexec/uucp/libunix/unknwn.c +++ /dev/null @@ -1,43 +0,0 @@ -/* unknwn.c - Check remote.unknown shell script. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -/* Run the remote.unknown shell script. If it succeeds, we return - FALSE because that means that the system is not permitted to log - in. If the execution fails, we return TRUE. */ - -boolean -fsysdep_unknown_caller (zscript, zsystem) - const char *zscript; - const char *zsystem; -{ - const char *azargs[3]; - int aidescs[3]; - pid_t ipid; - - azargs[0] = zscript; - azargs[1] = zsystem; - azargs[2] = NULL; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ipid = ixsspawn (azargs, aidescs, TRUE, TRUE, (const char *) NULL, FALSE, - TRUE, (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno)); - return FALSE; - } - - return ixswait ((unsigned long) ipid, (const char *) NULL) != 0; -} diff --git a/gnu/libexec/uucp/libunix/uuto.c b/gnu/libexec/uucp/libunix/uuto.c deleted file mode 100644 index debba9d..0000000 --- a/gnu/libexec/uucp/libunix/uuto.c +++ /dev/null @@ -1,31 +0,0 @@ -/* uuto.c - Translate a destination for uuto. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -/* Translate a uuto destination for Unix. */ - -char * -zsysdep_uuto (zdest, zlocalname) - const char *zdest; - const char *zlocalname; -{ - const char *zexclam; - char *zto; - - zexclam = strrchr (zdest, '!'); - if (zexclam == NULL) - return NULL; - zto = (char *) zbufalc (zexclam - zdest - + sizeof "!~/receive///" - + strlen (zexclam) - + strlen (zlocalname)); - memcpy (zto, zdest, (size_t) (zexclam - zdest)); - sprintf (zto + (zexclam - zdest), "!~/receive/%s/%s/", - zexclam + 1, zlocalname); - return zto; -} diff --git a/gnu/libexec/uucp/libunix/walk.c b/gnu/libexec/uucp/libunix/walk.c deleted file mode 100644 index 85b94da..0000000 --- a/gnu/libexec/uucp/libunix/walk.c +++ /dev/null @@ -1,58 +0,0 @@ -/* walk.c - Walk a directory tree. */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#if HAVE_FTW_H -#include <ftw.h> -#endif - -static int iswalk_dir P((const char *zname, struct stat *qstat, int iflag)); - -/* Walk a directory tree. */ - -static size_t cSlen; -static void (*puSfn) P((const char *zfull, const char *zrelative, - pointer pinfo)); -static pointer pSinfo; - -boolean -usysdep_walk_tree (zdir, pufn, pinfo) - const char *zdir; - void (*pufn) P((const char *zfull, const char *zrelative, - pointer pinfo)); - pointer pinfo; -{ - cSlen = strlen (zdir) + 1; - puSfn = pufn; - pSinfo = pinfo; - return ftw ((char *) zdir, iswalk_dir, 5) == 0; -} - -/* Pass a file found in the directory tree to the system independent - function. */ - -/*ARGSUSED*/ -static int -iswalk_dir (zname, qstat, iflag) - const char *zname; - struct stat *qstat; - int iflag; -{ - char *zcopy; - - if (iflag != FTW_F) - return 0; - - zcopy = zbufcpy (zname + cSlen); - - (*puSfn) (zname, zcopy, pSinfo); - - ubuffree (zcopy); - - return 0; -} diff --git a/gnu/libexec/uucp/libunix/wldcrd.c b/gnu/libexec/uucp/libunix/wldcrd.c deleted file mode 100644 index 1aa17fa..0000000 --- a/gnu/libexec/uucp/libunix/wldcrd.c +++ /dev/null @@ -1,213 +0,0 @@ -/* wldcrd.c - Expand wildcards. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <ctype.h> -#include <errno.h> - -#if HAVE_GLOB && ! HAVE_GLOB_H -#undef HAVE_GLOB -#define HAVE_GLOB 0 -#endif - -#if HAVE_GLOB -#include <glob.h> -#endif - -/* Local variables to hold the wildcard in progress. */ - -#if HAVE_GLOB -static glob_t sSglob; -static int iSglob; -#else -static char *zSwildcard_alloc; -static char *zSwildcard; -#endif - -/* Start getting a wildcarded file spec. Use the glob function if it - is available, and otherwise use the shell. */ - -boolean -fsysdep_wildcard_start (zfile) - const char *zfile; -{ -#if HAVE_GLOB - -#if DEBUG > 0 - if (*zfile != '/') - ulog (LOG_FATAL, "fsysdep_wildcard: %s: Can't happen", zfile); -#endif - - if (glob (zfile, 0, (int (*) ()) NULL, &sSglob) != 0) - sSglob.gl_pathc = 0; - iSglob = 0; - return TRUE; - -#else /* ! HAVE_GLOB */ - - char *zcmd, *zto; - const char *zfrom; - size_t c; - const char *azargs[4]; - FILE *e; - pid_t ipid; - -#if DEBUG > 0 - if (*zfile != '/') - ulog (LOG_FATAL, "fsysdep_wildcard: %s: Can't happen", zfile); -#endif - - zSwildcard_alloc = NULL; - zSwildcard = NULL; - - zcmd = zbufalc (sizeof ECHO_PROGRAM + sizeof " " + 2 * strlen (zfile)); - memcpy (zcmd, ECHO_PROGRAM, sizeof ECHO_PROGRAM - 1); - zto = zcmd + sizeof ECHO_PROGRAM - 1; - *zto++ = ' '; - zfrom = zfile; - while (*zfrom != '\0') - { - /* To avoid shell trickery, we quote all characters except - letters, digits, and wildcard specifiers. We don't quote '/' - to avoid an Ultrix sh bug. */ - if (! isalnum (*zfrom) - && *zfrom != '*' - && *zfrom != '?' - && *zfrom != '[' - && *zfrom != ']' - && *zfrom != '/') - *zto++ = '\\'; - *zto++ = *zfrom++; - } - *zto = '\0'; - - azargs[0] = "/bin/sh"; - azargs[1] = "-c"; - azargs[2] = zcmd; - azargs[3] = NULL; - - e = espopen (azargs, TRUE, &ipid); - - ubuffree (zcmd); - - if (e == NULL) - { - ulog (LOG_ERROR, "espopen: %s", strerror (errno)); - return FALSE; - } - - zSwildcard_alloc = NULL; - c = 0; - if (getline (&zSwildcard_alloc, &c, e) <= 0) - { - xfree ((pointer) zSwildcard_alloc); - zSwildcard_alloc = NULL; - } - - if (ixswait ((unsigned long) ipid, ECHO_PROGRAM) != 0) - { - xfree ((pointer) zSwildcard_alloc); - return FALSE; - } - - if (zSwildcard_alloc == NULL) - return FALSE; - - DEBUG_MESSAGE1 (DEBUG_EXECUTE, - "fsysdep_wildcard_start: got \"%s\"", - zSwildcard_alloc); - - zSwildcard = zSwildcard_alloc; - - return TRUE; - -#endif /* ! HAVE_GLOB */ -} - -/* Get the next wildcard spec. */ - -/*ARGSUSED*/ -char * -zsysdep_wildcard (zfile) - const char *zfile; -{ -#if HAVE_GLOB - - char *zret; - - if (iSglob >= sSglob.gl_pathc) - return NULL; - zret = zbufcpy (sSglob.gl_pathv[iSglob]); - ++iSglob; - return zret; - -#else /* ! HAVE_GLOB */ - - char *zret; - - if (zSwildcard_alloc == NULL || zSwildcard == NULL) - return NULL; - - zret = zSwildcard; - - while (*zSwildcard != '\0' && ! isspace (BUCHAR (*zSwildcard))) - ++zSwildcard; - - if (*zSwildcard != '\0') - { - *zSwildcard = '\0'; - ++zSwildcard; - while (*zSwildcard != '\0' && isspace (BUCHAR (*zSwildcard))) - ++zSwildcard; - } - - if (*zSwildcard == '\0') - zSwildcard = NULL; - - return zbufcpy (zret); - -#endif /* ! HAVE_GLOB */ -} - -/* Finish up getting wildcard specs. */ - -boolean -fsysdep_wildcard_end () -{ -#if HAVE_GLOB - globfree (&sSglob); - return TRUE; -#else /* ! HAVE_GLOB */ - xfree ((pointer) zSwildcard_alloc); - zSwildcard_alloc = NULL; - zSwildcard = NULL; - return TRUE; -#endif /* ! HAVE_GLOB */ -} diff --git a/gnu/libexec/uucp/libunix/work.c b/gnu/libexec/uucp/libunix/work.c deleted file mode 100644 index 7e0c12e..0000000 --- a/gnu/libexec/uucp/libunix/work.c +++ /dev/null @@ -1,791 +0,0 @@ -/* work.c - Routines to read command files. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char work_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" - -#include <ctype.h> -#include <errno.h> - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -/* Local functions. */ - -static char *zswork_directory P((const char *zsystem)); -static boolean fswork_file P((const char *zsystem, const char *zfile, - char *pbgrade)); -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. */ - -/* 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 - used as a sequence pointer. The ztemp entry of the ssline - structure holds the name of a temporary file to delete, if any. */ - -#define CFILELINES (10) - -struct ssline -{ - char *zline; - struct ssfile *qfile; - char *ztemp; -}; - -struct ssfile -{ - char *zfile; - char bgrade; - /* bdummy is needed for some buggy compilers. */ - char bdummy; - int clines; - int cdid; - struct ssline aslines[CFILELINES]; -}; - -/* Static variables for the work scan. */ - -static struct ssfilename *asSwork_files; -static size_t cSwork_files; -static size_t iSwork_file; -static struct ssfile *qSwork_file; - -/* Given a system name, return a directory to search for work. */ - -static char * -zswork_directory (zsystem) - const char *zsystem; -{ -#if SPOOLDIR_V2 - return zbufcpy ("."); -#endif /* SPOOLDIR_V2 */ -#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43 - return zbufcpy ("C."); -#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */ -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - return zbufcpy (zsystem); -#endif /* SPOOLDIR_HDB || SPOOLDIR_SVR4 */ -#if SPOOLDIR_ULTRIX - return zsappend3 ("sys", - (fsultrix_has_spool (zsystem) - ? zsystem - : "DEFAULT"), - "C."); -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - return zsysdep_in_dir (zsystem, "C."); -#endif /* SPOOLDIR_TAYLOR */ -} - -/* See whether a file name from the directory returned by - zswork_directory is really a command for a particular system. - Return the command grade. */ - -/*ARGSUSED*/ -static boolean -fswork_file (zsystem, zfile, pbgrade) - const char *zsystem; - const char *zfile; - char *pbgrade; -{ -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX - int cfilesys, csys; - - /* The file name should be C.ssssssgqqqq, where g is exactly one - letter and qqqq is exactly four numbers. The system name may be - truncated to six or seven characters. The system name of the - file must match the system name we're looking for, since there - could be work files for several systems in one directory. */ - if (zfile[0] != 'C' || zfile[1] != '.') - return FALSE; - csys = strlen (zsystem); - cfilesys = strlen (zfile) - 7; - if (csys != cfilesys - && (csys < 6 || (cfilesys != 6 && cfilesys != 7))) - return FALSE; - *pbgrade = zfile[cfilesys + 2]; - return strncmp (zfile + 2, zsystem, cfilesys) == 0; -#endif /* V2 || BSD42 || BSD43 || ULTRIX */ -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - int clen; - - /* The HDB file name should be C.ssssssgqqqq where g is exactly one - letter and qqqq is exactly four numbers or letters. We don't - check the system name, because it is guaranteed by the directory - we are looking in and some versions of uucp set it to the local - system rather than the remote one. I'm not sure of the exact - format of the SVR4 file name, but it does not include the grade - at all. */ - if (zfile[0] != 'C' || zfile[1] != '.') - return FALSE; - clen = strlen (zfile); - if (clen < 7) - return FALSE; -#if ! SPOOLDIR_SVR4 - *pbgrade = zfile[clen - 5]; -#endif - return TRUE; -#endif /* SPOOLDIR_HDB || SPOOLDIR_SVR4 */ -#if SPOOLDIR_TAYLOR - /* We don't keep the system name in the file name, since that - forces truncation. Our file names are always C.gqqqq. */ - *pbgrade = zfile[2]; - return (zfile[0] == 'C' - && zfile[1] == '.' - && zfile[2] != '\0'); -#endif /* SPOOLDIR_TAYLOR */ -} - -/* A comparison function to look through the list of file names. */ - -static int -iswork_cmp (pkey, pdatum) - constpointer pkey; - constpointer pdatum; -{ - const struct ssfilename *qkey = (const struct ssfilename *) pkey; - const struct ssfilename *qdatum = (const struct ssfilename *) pdatum; - - return strcmp (qkey->zfile, qdatum->zfile); -} - -/* See whether there is any work to do for a particular system. */ - -boolean -fsysdep_has_work (qsys) - const struct uuconf_system *qsys; -{ - char *zdir; - DIR *qdir; - struct dirent *qentry; -#if SPOOLDIR_SVR4 - DIR *qgdir; - struct dirent *qgentry; -#endif - - zdir = zswork_directory (qsys->uuconf_zname); - if (zdir == NULL) - return FALSE; - qdir = opendir ((char *) zdir); - if (qdir == NULL) - { - ubuffree (zdir); - return FALSE; - } - -#if SPOOLDIR_SVR4 - qgdir = qdir; - while ((qgentry = readdir (qgdir)) != NULL) - { - char *zsub; - - if (qgentry->d_name[0] == '.' - || qgentry->d_name[1] != '\0') - continue; - zsub = zsysdep_in_dir (zdir, qgentry->d_name); - qdir = opendir (zsub); - ubuffree (zsub); - if (qdir == NULL) - continue; -#endif - - while ((qentry = readdir (qdir)) != NULL) - { - char bgrade; - - if (fswork_file (qsys->uuconf_zname, qentry->d_name, &bgrade)) - { - closedir (qdir); -#if SPOOLDIR_SVR4 - closedir (qgdir); -#endif - ubuffree (zdir); - return TRUE; - } - } - -#if SPOOLDIR_SVR4 - closedir (qdir); - } - qdir = qgdir; -#endif - - closedir (qdir); - ubuffree (zdir); - return FALSE; -} - -/* Initialize the work scan. We have to read all the files in the - work directory, so that we can sort them by work grade. The bgrade - argument is the minimum grade to consider. We don't want to return - files that we have already considered; usysdep_get_work_free will - clear the data out when we are done with the system. This returns - FALSE on error. */ - -#define CWORKFILES (10) - -boolean -fsysdep_get_work_init (qsys, bgrade) - const struct uuconf_system *qsys; - int bgrade; -{ - char *zdir; - DIR *qdir; - struct dirent *qentry; - size_t chad; - size_t callocated; -#if SPOOLDIR_SVR4 - DIR *qgdir; - struct dirent *qgentry; -#endif - - zdir = zswork_directory (qsys->uuconf_zname); - if (zdir == NULL) - return FALSE; - - qdir = opendir (zdir); - if (qdir == NULL) - { - boolean fret; - - if (errno == ENOENT) - fret = TRUE; - else - { - ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno)); - fret = FALSE; - } - ubuffree (zdir); - return fret; - } - - chad = cSwork_files; - callocated = cSwork_files; - - /* Sort the files we already know about so that we can check the new - ones with bsearch. It would be faster to use a hash table, and - the code should be probably be changed. The sort done at the end - of this function does not suffice because it only includes the - files added last time, and does not sort the entire array. Some - (bad) qsort implementations are very slow when given a sorted - array, which causes particularly bad effects here. */ - if (chad > 0) - qsort ((pointer) asSwork_files, chad, sizeof (struct ssfilename), - iswork_cmp); - -#if SPOOLDIR_SVR4 - qgdir = qdir; - while ((qgentry = readdir (qgdir)) != NULL) - { - char *zsub; - - if (qgentry->d_name[0] == '.' - || qgentry->d_name[1] != '\0' - || UUCONF_GRADE_CMP (bgrade, qgentry->d_name[0]) < 0) - continue; - zsub = zsysdep_in_dir (zdir, qgentry->d_name); - qdir = opendir (zsub); - if (qdir == NULL) - { - if (errno != ENOTDIR && errno != ENOENT) - { - ulog (LOG_ERROR, "opendir (%s): %s", zsub, - strerror (errno)); - ubuffree (zsub); - return FALSE; - } - ubuffree (zsub); - continue; - } - ubuffree (zsub); -#endif - - while ((qentry = readdir (qdir)) != NULL) - { - char bfilegrade; - char *zname; - struct ssfilename slook; - -#if ! SPOOLDIR_SVR4 - zname = zbufcpy (qentry->d_name); -#else - zname = zsysdep_in_dir (qgentry->d_name, qentry->d_name); - 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 - || (asSwork_files != NULL - && bsearch ((pointer) &slook, - (pointer) asSwork_files, - chad, sizeof (struct ssfilename), - iswork_cmp) != NULL)) - ubuffree (zname); - else - { - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, - "fsysdep_get_work_init: Found %s", - zname); - - if (cSwork_files >= callocated) - { - callocated += CWORKFILES; - asSwork_files = - ((struct ssfilename *) - xrealloc ((pointer) asSwork_files, - (callocated * sizeof (struct ssfilename)))); - } - - 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 - - closedir (qdir); - ubuffree (zdir); - - /* Sorting the files alphabetically will get the grades in the - right order, since all the file prefixes are the same. */ - if (cSwork_files > iSwork_file) - qsort ((pointer) (asSwork_files + iSwork_file), - cSwork_files - iSwork_file, - sizeof (struct ssfilename), iswork_cmp); - - return TRUE; -} - -/* Get the next work entry for a system. This must parse the next - line in the next work file. The type of command is set into - qcmd->bcmd If there are no more commands, qcmd->bcmd is set to 'H'. - Each field in the structure is set to point to a spot in an - malloced string. The grade argument is never used; it has been - used by fsysdep_get_work_init. */ - -/*ARGSUSED*/ -boolean -fsysdep_get_work (qsys, bgrade, qcmd) - const struct uuconf_system *qsys; - int bgrade; - struct scmd *qcmd; -{ - char *zdir; - - if (qSwork_file != NULL && qSwork_file->cdid >= qSwork_file->clines) - qSwork_file = NULL; - - if (asSwork_files == NULL) - { - qcmd->bcmd = 'H'; - return TRUE; - } - - zdir = NULL; - - /* This loop continues until a line is returned. */ - while (TRUE) - { - /* This loop continues until a file is opened and read in. */ - while (qSwork_file == NULL) - { - FILE *e; - struct ssfile *qfile; - int iline, callocated; - char *zline; - size_t cline; - char *zname; - char bfilegrade; - - /* Read all the lines of a command file into memory. */ - do - { - if (iSwork_file >= cSwork_files) - { - qcmd->bcmd = 'H'; - ubuffree (zdir); - return TRUE; - } - - if (zdir == NULL) - { - zdir = zswork_directory (qsys->uuconf_zname); - if (zdir == NULL) - return FALSE; - } - - zname = zsysdep_in_dir (zdir, asSwork_files[iSwork_file].zfile); - bfilegrade = asSwork_files[iSwork_file].bgrade; - - ++iSwork_file; - - e = fopen (zname, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zname, - strerror (errno)); - ubuffree (zname); - } - } - while (e == NULL); - - qfile = (struct ssfile *) xmalloc (sizeof (struct ssfile)); - callocated = CFILELINES; - iline = 0; - - zline = NULL; - cline = 0; - while (getline (&zline, &cline, e) > 0) - { - if (iline >= callocated) - { - /* The sizeof (struct ssfile) includes CFILELINES - entries already, so using callocated * sizeof - (struct ssline) will give us callocated * - CFILELINES entries. */ - qfile = - ((struct ssfile *) - xrealloc ((pointer) qfile, - (sizeof (struct ssfile) + - (callocated * sizeof (struct ssline))))); - callocated += CFILELINES; - } - qfile->aslines[iline].zline = zbufcpy (zline); - qfile->aslines[iline].qfile = NULL; - qfile->aslines[iline].ztemp = NULL; - iline++; - } - - xfree ((pointer) zline); - - if (fclose (e) != 0) - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - - if (iline == 0) - { - /* There were no lines in the file; this is a poll file, - for which we return a 'P' command. */ - qfile->aslines[0].zline = zbufcpy ("P"); - qfile->aslines[0].qfile = NULL; - qfile->aslines[0].ztemp = NULL; - iline = 1; - } - - qfile->zfile = zname; - qfile->bgrade = bfilegrade; - qfile->clines = iline; - qfile->cdid = 0; - qSwork_file = qfile; - } - - /* This loop continues until all the lines from the current file - are used up, or a line is returned. */ - while (TRUE) - { - int iline; - - if (qSwork_file->cdid >= qSwork_file->clines) - { - /* We don't want to free qSwork_file here, since it must - remain until all the lines have been completed. It - is freed in fsysdep_did_work. */ - qSwork_file = NULL; - /* Go back to the main loop which finds another file. */ - break; - } - - iline = qSwork_file->cdid; - ++qSwork_file->cdid; - - /* Now parse the line into a command. */ - if (! fparse_cmd (qSwork_file->aslines[iline].zline, qcmd)) - { - ulog (LOG_ERROR, "Bad line in command file %s", - qSwork_file->zfile); - ubuffree (qSwork_file->aslines[iline].zline); - 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]); - - if (qcmd->bcmd == 'S' || qcmd->bcmd == 'E') - { - char *zreal; - - zreal = zsysdep_spool_file_name (qsys, qcmd->ztemp, - qcmd->pseq); - if (zreal == NULL) - { - ubuffree (qSwork_file->aslines[iline].zline); - qSwork_file->aslines[iline].zline = NULL; - ubuffree (zdir); - return FALSE; - } - qSwork_file->aslines[iline].ztemp = zreal; - } - - ubuffree (zdir); - return TRUE; - } - } -} - -/* When a command has been complete, fsysdep_did_work is called. The - sequence entry was set above to be the address of an aslines - structure whose pfile entry points to the ssfile corresponding to - this file. We can then check whether all the lines have been - completed (they will have been if the pfile entry is NULL) and - remove the file if they have been. This means that we only remove - a command file if we manage to complete every transfer it specifies - in a single UUCP session. I don't know if this is how regular UUCP - works. */ - -boolean -fsysdep_did_work (pseq) - pointer pseq; -{ - struct ssfile *qfile; - struct ssline *qline; - int i; - - qline = (struct ssline *) pseq; - - ubuffree (qline->zline); - qline->zline = NULL; - - qfile = qline->qfile; - qline->qfile = NULL; - - /* Remove the temporary file, if there is one. It really doesn't - matter if this fails, and not checking the return value lets us - attempt to remove D.0 or whatever an unused temporary file is - called without complaining. */ - if (qline->ztemp != NULL) - { - (void) remove (qline->ztemp); - ubuffree (qline->ztemp); - qline->ztemp = NULL; - } - - /* If not all the lines have been returned from fsysdep_get_work, - we can't remove the file yet. */ - if (qfile->cdid < qfile->clines) - return TRUE; - - /* See whether all the commands have been completed. */ - for (i = 0; i < qfile->clines; i++) - if (qfile->aslines[i].qfile != NULL) - return TRUE; - - /* All commands have finished. */ - if (remove (qfile->zfile) != 0) - { - ulog (LOG_ERROR, "remove (%s): %s", qfile->zfile, - strerror (errno)); - return FALSE; - } - - ubuffree (qfile->zfile); - xfree ((pointer) qfile); - - if (qfile == qSwork_file) - qSwork_file = NULL; - - return TRUE; -} - -/* Free up the results of a work scan, when we're done with this - system. */ - -/*ARGSUSED*/ -void -usysdep_get_work_free (qsys) - const struct uuconf_system *qsys; -{ - if (asSwork_files != NULL) - { - size_t i; - - for (i = 0; i < cSwork_files; i++) - ubuffree ((pointer) asSwork_files[i].zfile); - xfree ((pointer) asSwork_files); - asSwork_files = NULL; - cSwork_files = 0; - iSwork_file = 0; - } - if (qSwork_file != NULL) - { - int i; - - ubuffree (qSwork_file->zfile); - for (i = 0; i < qSwork_file->cdid; i++) - { - ubuffree (qSwork_file->aslines[i].zline); - ubuffree (qSwork_file->aslines[i].ztemp); - } - for (i = qSwork_file->cdid; i < qSwork_file->clines; i++) - ubuffree (qSwork_file->aslines[i].zline); - xfree ((pointer) qSwork_file); - qSwork_file = NULL; - } -} - -/* Save the temporary file used by a send command, and return an - informative message to mail to the requestor. This is called when - a file transfer failed, to make sure that the potentially valuable - file is not completely lost. */ - -const char * -zsysdep_save_temp_file (pseq) - pointer pseq; -{ - struct ssline *qline = (struct ssline *) pseq; - char *zto, *zslash; - size_t cwant; - static char *zbuf; - static int cbuf; - - if (! fsysdep_file_exists (qline->ztemp)) - return NULL; - - zslash = strrchr (qline->ztemp, '/'); - if (zslash == NULL) - zslash = qline->ztemp; - else - ++zslash; - - zto = zbufalc (sizeof PRESERVEDIR + sizeof "/" + strlen (zslash)); - sprintf (zto, "%s/%s", PRESERVEDIR, zslash); - - 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"; - } - - cwant = sizeof "File saved as\n\t/" + strlen (zSspooldir) + strlen (zto); - if (cwant > cbuf) - { - ubuffree (zbuf); - zbuf = zbufalc (cwant); - cbuf = cwant; - } - - sprintf (zbuf, "File saved as\n\t%s/%s", zSspooldir, zto); - ubuffree (zto); - return zbuf; -} - -/* Get the jobid of a work file. This is needed by uustat. */ - -char * -zsysdep_jobid (qsys, pseq) - const struct uuconf_system *qsys; - pointer pseq; -{ - return zsfile_to_jobid (qsys, ((struct ssline *) pseq)->qfile->zfile, - bsgrade (pseq)); -} - -/* Get the grade of a work file. The pseq argument can be NULL when - this is called from zsysdep_spool_file_name, and simply means that - this is a remote file; returning -1 will cause zsfind_file to do - the right thing. */ - -int -bsgrade (pseq) - pointer pseq; -{ - const char *zfile; - char bgrade; - - if (pseq == NULL) - return -1; - - zfile = ((struct ssline *) pseq)->qfile->zfile; - -#if SPOOLDIR_TAYLOR - bgrade = *(strrchr (zfile, '/') + 3); -#else -#if ! SPOOLDIR_SVR4 - bgrade = zfile[strlen (zfile) - CSEQLEN - 1]; -#else - bgrade = *(strchr (zfile, '/') + 1); -#endif -#endif - - return bgrade; -} diff --git a/gnu/libexec/uucp/libunix/xqtfil.c b/gnu/libexec/uucp/libunix/xqtfil.c deleted file mode 100644 index 3019a32..0000000 --- a/gnu/libexec/uucp/libunix/xqtfil.c +++ /dev/null @@ -1,298 +0,0 @@ -/* xqtfil.c - Routines to read execute files. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char xqtfil_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "sysdep.h" -#include "system.h" - -#include <errno.h> - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -/* Under the V2 or BSD42 spool directory scheme, all execute files are - in the main spool directory. Under the BSD43 scheme, they are all - in the directory X.. Under the HDB or SVR4 scheme, they are in - directories named after systems. Under the ULTRIX scheme, they are - in X. subdirectories of subdirectories of sys. Under the TAYLOR - scheme, they are all in the subdirectory X. of a directory named - after the system. - - This means that for HDB, ULTRIX, SVR4 or TAYLOR, we have to search - directories of directories. */ - -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 -#define ZDIR "." -#define SUBDIRS 0 -#endif -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 || SPOOLDIR_TAYLOR -#define ZDIR "." -#define SUBDIRS 1 -#endif -#if SPOOLDIR_ULTRIX -#define ZDIR "sys" -#define SUBDIRS 1 -#endif -#if SPOOLDIR_BSD43 -#define ZDIR "X." -#define SUBDIRS 0 -#endif - -/* Static variables for the execute file scan. */ - -static DIR *qSxqt_topdir; -#if ! SUBDIRS -static const char *zSdir; -#else /* SUBDIRS */ -static boolean fSone_dir; -static char *zSdir; -static DIR *qSxqt_dir; -static char *zSsystem; -#endif /* SUBDIRS */ - -/* Initialize the scan for execute files. The function - usysdep_get_xqt_free will clear the data out when we are done with - the system. This returns FALSE on error. */ - -/*ARGSUSED*/ -boolean -fsysdep_get_xqt_init (zsystem) - const char *zsystem; -{ - usysdep_get_xqt_free ((const char *) NULL); - -#if SUBDIRS - if (zsystem != NULL) - { -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - zSdir = zbufcpy (zsystem); -#endif -#if SPOOLDIR_ULTRIX - zSdir = zsappend3 ("sys", zsystem, "X."); -#endif -#if SPOOLDIR_TAYLOR - zSdir = zsysdep_in_dir (zsystem, "X."); -#endif - - qSxqt_dir = opendir ((char *) zSdir); - if (qSxqt_dir != NULL) - { - qSxqt_topdir = qSxqt_dir; - fSone_dir = TRUE; - zSsystem = zbufcpy (zsystem); - return TRUE; - } - } - - fSone_dir = FALSE; -#endif - - qSxqt_topdir = opendir ((char *) ZDIR); - if (qSxqt_topdir == NULL) - { - if (errno == ENOENT) - return TRUE; - ulog (LOG_ERROR, "opendir (%s): %s", ZDIR, strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Return the name of the next execute file to read and process. If - this returns NULL, *pferr must be checked. If will be TRUE on - error, FALSE if there are no more files. On a successful return - *pzsystem will be set to the system for which the execute file was - created. */ - -/*ARGSUSED*/ -char * -zsysdep_get_xqt (zsystem, pzsystem, pferr) - const char *zsystem; - char **pzsystem; - boolean *pferr; -{ - *pferr = FALSE; - - if (qSxqt_topdir == NULL) - return NULL; - - /* This loop continues until we find a file. */ - while (TRUE) - { - DIR *qdir; - struct dirent *q; - -#if ! SUBDIRS - zSdir = ZDIR; - qdir = qSxqt_topdir; -#else /* SUBDIRS */ - /* This loop continues until we find a subdirectory to read. */ - while (qSxqt_dir == NULL) - { - struct dirent *qtop; - - qtop = readdir (qSxqt_topdir); - if (qtop == NULL) - { - (void) closedir (qSxqt_topdir); - qSxqt_topdir = NULL; - return NULL; - } - - /* No system name may start with a dot This allows us to - quickly skip impossible directories. */ - if (qtop->d_name[0] == '.') - continue; - - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Found %s in top directory", - qtop->d_name); - - ubuffree (zSdir); - -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 - zSdir = zbufcpy (qtop->d_name); -#endif -#if SPOOLDIR_ULTRIX - zSdir = zsappend3 ("sys", qtop->d_name, "X."); -#endif -#if SPOOLDIR_TAYLOR - zSdir = zsysdep_in_dir (qtop->d_name, "X."); -#endif - - ubuffree (zSsystem); - zSsystem = zbufcpy (qtop->d_name); - - qSxqt_dir = opendir (zSdir); - - if (qSxqt_dir == NULL - && errno != ENOTDIR - && errno != ENOENT) - ulog (LOG_ERROR, "opendir (%s): %s", zSdir, strerror (errno)); - } - - qdir = qSxqt_dir; -#endif /* SUBDIRS */ - - q = readdir (qdir); - -#if DEBUG > 1 - if (q != NULL) - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Found %s in subdirectory %s", - q->d_name, zSdir); -#endif - - /* If we've found an execute file, return it. We have to get - the system name, which is easy for HDB or TAYLOR. For other - spool directory schemes, we have to pull it out of the X. - file name; this would be insecure, except that zsfind_file - clobbers the file name to include the real system name. */ - if (q != NULL - && q->d_name[0] == 'X' - && q->d_name[1] == '.') - { - char *zret; - -#if SPOOLDIR_HDB || SPOOLDIR_SVR4 || SPOOLDIR_TAYLOR - *pzsystem = zbufcpy (zSsystem); -#else - { - size_t clen; - - clen = strlen (q->d_name) - 7; - *pzsystem = zbufalc (clen + 1); - memcpy (*pzsystem, q->d_name + 2, clen); - (*pzsystem)[clen] = '\0'; - } -#endif - - zret = zsysdep_in_dir (zSdir, q->d_name); -#if DEBUG > 1 - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Returning %s (system %s)", - zret, *pzsystem); -#endif - return zret; - } - - /* If we've reached the end of the directory, then if we are - using subdirectories loop around to read the next one, - otherwise we are finished. */ - if (q == NULL) - { - (void) closedir (qdir); - -#if SUBDIRS - qSxqt_dir = NULL; - if (! fSone_dir) - continue; -#endif - - qSxqt_topdir = NULL; - return NULL; - } - } -} - -/* Free up the results of an execute file scan, when we're done with - this system. */ - -/*ARGSUSED*/ -void -usysdep_get_xqt_free (zsystem) - const char *zsystem; -{ - if (qSxqt_topdir != NULL) - { - (void) closedir (qSxqt_topdir); - qSxqt_topdir = NULL; - } -#if SUBDIRS - if (qSxqt_dir != NULL) - { - (void) closedir (qSxqt_dir); - qSxqt_dir = NULL; - } - ubuffree (zSdir); - zSdir = NULL; - ubuffree (zSsystem); - zSsystem = NULL; - fSone_dir = FALSE; -#endif -} diff --git a/gnu/libexec/uucp/libunix/xqtsub.c b/gnu/libexec/uucp/libunix/xqtsub.c deleted file mode 100644 index 7435497..0000000 --- a/gnu/libexec/uucp/libunix/xqtsub.c +++ /dev/null @@ -1,711 +0,0 @@ -/* xqtsub.c - System dependent functions used only by uuxqt. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char xqtsub_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" - -#include <ctype.h> -#include <errno.h> - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#ifndef FD_CLOEXEC -#define FD_CLOEXEC 1 -#endif - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include <dirent.h> -#else /* ! HAVE_DIRENT_H */ -#include <sys/dir.h> -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -/* Get a value for EX_TEMPFAIL. */ - -#if HAVE_SYSEXITS_H -#include <sysexits.h> -#endif - -#ifndef EX_TEMPFAIL -#define EX_TEMPFAIL 75 -#endif - -/* Get the full pathname of the command to execute, given the list of - permitted commands and the allowed path. */ - -char * -zsysdep_find_command (zcmd, pzcmds, pzpath, pferr) - const char *zcmd; - char **pzcmds; - char **pzpath; - boolean *pferr; -{ - char **pz; - struct stat s; - - *pferr = FALSE; - - for (pz = pzcmds; *pz != NULL; pz++) - { - char *zslash; - - if (strcmp (*pz, "ALL") == 0) - break; - - zslash = strrchr (*pz, '/'); - if (zslash != NULL) - ++zslash; - else - zslash = *pz; - if (strcmp (zslash, zcmd) == 0 - || strcmp (*pz, zcmd) == 0) - { - /* If we already have an absolute path, we can get out - immediately. */ - if (**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; - } - } - - /* If we didn't find this command, get out. */ - if (*pz == NULL) - return NULL; - - /* We didn't find an absolute pathname, so we must look through - the path. */ - for (pz = pzpath; *pz != NULL; pz++) - { - char *zname; - - zname = zsysdep_in_dir (*pz, zcmd); - if (stat (zname, &s) == 0) - return zname; - } - - return NULL; -} - -/* Expand a local filename for uuxqt. This is special because uuxqt - only wants to expand filenames that start with ~ (it does not want - to prepend the current directory to other names) and if the ~ is - double, it is turned into a single ~. This returns NULL to - indicate that no change was required; it has no way to return - error. */ - -char * -zsysdep_xqt_local_file (qsys, zfile) - const struct uuconf_system *qsys; - const char *zfile; -{ - if (*zfile != '~') - return NULL; - if (zfile[1] == '~') - { - size_t clen; - char *zret; - - clen = strlen (zfile); - zret = zbufalc (clen); - memcpy (zret, zfile + 1, clen); - return zret; - } - return zsysdep_local_file (zfile, qsys->uuconf_zpubdir, - (boolean *) NULL); -} - -#if ! ALLOW_FILENAME_ARGUMENTS - -/* Check to see whether an argument specifies a file name; if it does, - make sure that the file may legally be sent and/or received. For - Unix, we do not permit any occurrence of "/../" in the name, nor - may it start with "../". Otherwise, if it starts with "/" we check - against the list of permitted files. */ - -boolean -fsysdep_xqt_check_file (qsys, zfile) - const struct uuconf_system *qsys; - const char *zfile; -{ - size_t clen; - - /* Disallow exact "..", prefix "../", suffix "/..", internal "/../", - and restricted absolute paths. */ - clen = strlen (zfile); - if ((clen == sizeof ".." - 1 - && strcmp (zfile, "..") == 0) - || strncmp (zfile, "../", sizeof "../" - 1) == 0 - || (clen >= sizeof "/.." - 1 - && strcmp (zfile + clen - (sizeof "/.." - 1), "/..") == 0) - || strstr (zfile, "/../") != NULL - || (*zfile == '/' - && (! fin_directory_list (zfile, qsys->uuconf_pzremote_send, - qsys->uuconf_zpubdir, TRUE, FALSE, - (const char *) NULL) - || ! fin_directory_list (zfile, qsys->uuconf_pzremote_receive, - qsys->uuconf_zpubdir, TRUE, FALSE, - (const char *) NULL)))) - { - ulog (LOG_ERROR, "Not permitted to refer to file \"%s\"", zfile); - return FALSE; - } - - return TRUE; -} - -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - -/* Invoke the command specified by an execute file. */ - -/*ARGSUSED*/ -boolean -fsysdep_execute (qsys, zuser, pazargs, zfullcmd, zinput, zoutput, - fshell, iseq, pzerror, pftemp) - const struct uuconf_system *qsys; - const char *zuser; - const char **pazargs; - const char *zfullcmd; - const char *zinput; - const char *zoutput; - boolean fshell; - int iseq; - char **pzerror; - boolean *pftemp; -{ - int aidescs[3]; - boolean ferr; - pid_t ipid; - int ierr; - char abxqtdir[sizeof XQTDIR + 4]; - const char *zxqtdir; - int istat; - char *zpath; -#if ALLOW_SH_EXECUTION - const char *azshargs[4]; -#endif - - *pzerror = NULL; - *pftemp = FALSE; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ferr = FALSE; - - if (zinput != NULL) - { - aidescs[0] = open ((char *) zinput, O_RDONLY | O_NOCTTY, 0); - if (aidescs[0] < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zinput, strerror (errno)); - ferr = TRUE; - } - else if (fcntl (aidescs[0], F_SETFD, - fcntl (aidescs[0], F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - ferr = TRUE; - } - } - - if (! ferr && zoutput != NULL) - { - aidescs[1] = creat ((char *) zoutput, IPRIVATE_FILE_MODE); - if (aidescs[1] < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", zoutput, strerror (errno)); - *pftemp = TRUE; - ferr = TRUE; - } - else if (fcntl (aidescs[1], F_SETFD, - fcntl (aidescs[1], F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - ferr = TRUE; - } - } - - if (! ferr) - { - *pzerror = zstemp_file (qsys); - aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE); - if (aidescs[2] < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (*pzerror, FALSE)) - { - *pftemp = TRUE; - ferr = TRUE; - } - else - aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE); - } - if (! ferr && aidescs[2] < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", *pzerror, strerror (errno)); - *pftemp = TRUE; - ferr = TRUE; - } - } - if (! ferr - && fcntl (aidescs[2], F_SETFD, - fcntl (aidescs[2], F_GETFD, 0) | FD_CLOEXEC) < 0) - { - ulog (LOG_ERROR, "fcntl (FD_CLOEXEC): %s", strerror (errno)); - ferr = TRUE; - } - } - - if (iseq == 0) - zxqtdir = XQTDIR; - else - { - sprintf (abxqtdir, "%s%04d", XQTDIR, iseq); - zxqtdir = abxqtdir; - } - - if (ferr) - { - if (aidescs[0] != SPAWN_NULL) - (void) close (aidescs[0]); - if (aidescs[1] != SPAWN_NULL) - (void) close (aidescs[1]); - if (aidescs[2] != SPAWN_NULL) - (void) close (aidescs[2]); - ubuffree (*pzerror); - return FALSE; - } - -#if ALLOW_SH_EXECUTION - if (fshell) - { - azshargs[0] = "/bin/sh"; - azshargs[1] = "-c"; - azshargs[2] = zfullcmd; - azshargs[3] = NULL; - pazargs = azshargs; - } -#else - fshell = FALSE; -#endif - - if (qsys->uuconf_pzpath == NULL) - zpath = NULL; - else - { - size_t c; - char **pz; - - c = 0; - for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++) - c += strlen (*pz) + 1; - zpath = zbufalc (c); - *zpath = '\0'; - for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++) - { - strcat (zpath, *pz); - if (pz[1] != NULL) - strcat (zpath, ":"); - } - } - - /* Pass zchdir as zxqtdir, fnosigs as TRUE, fshell as TRUE if we - aren't already using the shell. */ - ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, zxqtdir, TRUE, - ! fshell, zpath, qsys->uuconf_zname, zuser); - - ierr = errno; - - ubuffree (zpath); - - if (aidescs[0] != SPAWN_NULL) - (void) close (aidescs[0]); - if (aidescs[1] != SPAWN_NULL) - (void) close (aidescs[1]); - if (aidescs[2] != SPAWN_NULL) - (void) close (aidescs[2]); - - if (ipid < 0) - { - ulog (LOG_ERROR, "ixsspawn: %s", strerror (ierr)); - *pftemp = TRUE; - return FALSE; - } - - istat = ixswait ((unsigned long) ipid, "Execution"); - - if (istat == EX_TEMPFAIL) - *pftemp = TRUE; - - return istat == 0; -} - -/* Lock a uuxqt process. */ - -int -ixsysdep_lock_uuxqt (zcmd, cmaxuuxqts) - const char *zcmd; - int cmaxuuxqts; -{ - char ab[sizeof "LCK.XQT.9999"]; - int i; - - if (cmaxuuxqts <= 0 || cmaxuuxqts >= 10000) - cmaxuuxqts = 9999; - for (i = 0; i < cmaxuuxqts; i++) - { - sprintf (ab, "LCK.XQT.%d", i); - if (fsdo_lock (ab, TRUE, (boolean *) NULL)) - break; - } - if (i >= cmaxuuxqts) - return -1; - - if (zcmd != NULL) - { - char abcmd[sizeof "LXQ.123456789"]; - - sprintf (abcmd, "LXQ.%.9s", zcmd); - abcmd[strcspn (abcmd, " \t/")] = '\0'; - if (! fsdo_lock (abcmd, TRUE, (boolean *) NULL)) - { - (void) fsdo_unlock (ab, TRUE); - return -1; - } - } - - return i; -} - -/* Unlock a uuxqt process. */ - -boolean -fsysdep_unlock_uuxqt (iseq, zcmd, cmaxuuxqts) - int iseq; - const char *zcmd; - int cmaxuuxqts; -{ - char ab[sizeof "LCK.XQT.9999"]; - boolean fret; - - fret = TRUE; - - sprintf (ab, "LCK.XQT.%d", iseq); - if (! fsdo_unlock (ab, TRUE)) - fret = FALSE; - - if (zcmd != NULL) - { - char abcmd[sizeof "LXQ.123456789"]; - - sprintf (abcmd, "LXQ.%.9s", zcmd); - abcmd[strcspn (abcmd, " \t/")] = '\0'; - if (! fsdo_unlock (abcmd, TRUE)) - fret = FALSE; - } - - return fret; -} - -/* See whether a particular uuxqt command is locked (this depends on - the implementation of fsdo_lock). */ - -boolean -fsysdep_uuxqt_locked (zcmd) - const char *zcmd; -{ - char ab[sizeof "LXQ.123456789"]; - struct stat s; - - sprintf (ab, "LXQ.%.9s", zcmd); - return stat (ab, &s) == 0; -} - -/* Lock a particular execute file. */ - -boolean -fsysdep_lock_uuxqt_file (zfile) - const char *zfile; -{ - char *zcopy, *z; - boolean fret; - - zcopy = zbufcpy (zfile); - - z = strrchr (zcopy, '/'); - if (z == NULL) - *zcopy = 'L'; - else - *(z + 1) = 'L'; - - fret = fsdo_lock (zcopy, TRUE, (boolean *) NULL); - ubuffree (zcopy); - return fret; -} - -/* Unlock a particular execute file. */ - -boolean -fsysdep_unlock_uuxqt_file (zfile) - const char *zfile; -{ - char *zcopy, *z; - boolean fret; - - zcopy = zbufcpy (zfile); - - z = strrchr (zcopy, '/'); - if (z == NULL) - *zcopy = 'L'; - else - *(z + 1) = 'L'; - - fret = fsdo_unlock (zcopy, TRUE); - ubuffree (zcopy); - return fret; -} - -/* Lock the execute directory. Since we use a different directory - depending on which LCK.XQT.dddd file we got, there is actually no - need to create a lock file. We do make sure that the directory - exists, though. */ - -boolean -fsysdep_lock_uuxqt_dir (iseq) - int iseq; -{ - const char *zxqtdir; - char abxqtdir[sizeof XQTDIR + 4]; - - if (iseq == 0) - zxqtdir = XQTDIR; - else - { - sprintf (abxqtdir, "%s%04d", XQTDIR, iseq); - zxqtdir = abxqtdir; - } - - if (mkdir (zxqtdir, S_IRWXU) < 0 - && errno != EEXIST - && errno != EISDIR) - { - ulog (LOG_ERROR, "mkdir (%s): %s", zxqtdir, strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Unlock the execute directory and clear it out. The lock is - actually the LCK.XQT.dddd file, so we don't unlock it, but we do - remove all the files. */ - -boolean -fsysdep_unlock_uuxqt_dir (iseq) - int iseq; -{ - const char *zxqtdir; - char abxqtdir[sizeof XQTDIR + 4]; - DIR *qdir; - - if (iseq == 0) - zxqtdir = XQTDIR; - else - { - sprintf (abxqtdir, "%s%04d", XQTDIR, iseq); - zxqtdir = abxqtdir; - } - - qdir = opendir ((char *) zxqtdir); - if (qdir != NULL) - { - struct dirent *qentry; - - while ((qentry = readdir (qdir)) != NULL) - { - char *z; - - if (strcmp (qentry->d_name, ".") == 0 - || strcmp (qentry->d_name, "..") == 0) - continue; - z = zsysdep_in_dir (zxqtdir, qentry->d_name); - if (remove (z) < 0) - { - int ierr; - - ierr = errno; - if (! fsysdep_directory (z)) - ulog (LOG_ERROR, "remove (%s): %s", z, - strerror (ierr)); - else - (void) fsysdep_rmdir (z); - } - ubuffree (z); - } - - closedir (qdir); - } - - return TRUE; -} - -/* Move files into the execution directory. */ - -boolean -fsysdep_move_uuxqt_files (cfiles, pzfrom, pzto, fto, iseq, pzinput) - int cfiles; - const char *const *pzfrom; - const char *const *pzto; - boolean fto; - int iseq; - char **pzinput; -{ - char *zinput; - const char *zxqtdir; - char abxqtdir[sizeof XQTDIR + 4]; - int i; - - if (pzinput == NULL) - zinput = NULL; - else - zinput = *pzinput; - - if (iseq == 0) - zxqtdir = XQTDIR; - else - { - sprintf (abxqtdir, "%s%04d", XQTDIR, iseq); - zxqtdir = abxqtdir; - } - - for (i = 0; i < cfiles; i++) - { - const char *zfrom, *zto; - char *zfree; - - if (pzto[i] == NULL) - continue; - - zfree = zsysdep_in_dir (zxqtdir, pzto[i]); - - zfrom = pzfrom[i]; - zto = zfree; - - if (zinput != NULL && strcmp (zinput, zfrom) == 0) - { - *pzinput = zbufcpy (zto); - zinput = NULL; - } - - if (! fto) - { - const char *ztemp; - - ztemp = zfrom; - zfrom = zto; - zto = ztemp; - (void) chmod (zfrom, IPRIVATE_FILE_MODE); - } - - if (rename (zfrom, zto) < 0) - { -#if HAVE_RENAME - /* On some systems the system call rename seems to fail for - arbitrary reasons. To get around this, we always try to - copy the file by hand if the rename failed. */ - errno = EXDEV; -#endif - - if (errno != EXDEV) - { - ulog (LOG_ERROR, "rename (%s, %s): %s", zfrom, zto, - strerror (errno)); - ubuffree (zfree); - break; - } - - if (! fcopy_file (zfrom, zto, FALSE, FALSE, FALSE)) - { - ubuffree (zfree); - break; - } - if (remove (zfrom) < 0) - ulog (LOG_ERROR, "remove (%s): %s", zfrom, - strerror (errno)); - } - - if (fto) - (void) chmod (zto, IPUBLIC_FILE_MODE); - - ubuffree (zfree); - } - - if (i < cfiles) - { - if (fto) - (void) fsysdep_move_uuxqt_files (i, pzfrom, pzto, FALSE, iseq, - (char **) NULL); - return FALSE; - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/libuuconf/MANIFEST b/gnu/libexec/uucp/libuuconf/MANIFEST deleted file mode 100644 index d4ca25e..0000000 --- a/gnu/libexec/uucp/libuuconf/MANIFEST +++ /dev/null @@ -1,94 +0,0 @@ -README -COPYING.LIB -MANIFEST -Makefile.in -alloc.h -syshdr.unx -uucnfi.h -addblk.c -addstr.c -allblk.c -alloc.c -base.c -bool.c -callin.c -calout.c -chatc.c -cmdarg.c -cmdfil.c -cmdlin.c -debfil.c -deblev.c -diacod.c -dial.c -diasub.c -dnams.c -errno.c -errstr.c -filnam.c -freblk.c -fredia.c -free.c -freprt.c -fresys.c -grdcmp.c -hdial.c -hdnams.c -hinit.c -hlocnm.c -hport.c -hrmunk.c -hsinfo.c -hsnams.c -hsys.c -hunk.c -iniglb.c -init.c -int.c -lckdir.c -lineno.c -llocnm.c -local.c -locnm.c -logfil.c -maxuxq.c -mrgblk.c -paramc.c -port.c -pubdir.c -prtsub.c -rdlocs.c -rdperm.c -reliab.c -remunk.c -runuxq.c -sinfo.c -snams.c -split.c -spool.c -stafil.c -strip.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 diff --git a/gnu/libexec/uucp/libuuconf/Makefile b/gnu/libexec/uucp/libuuconf/Makefile index 6fc7942..3118be2 100644 --- a/gnu/libexec/uucp/libuuconf/Makefile +++ b/gnu/libexec/uucp/libuuconf/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ LIB= uuconf -SRCS = addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \ +SRCS= addblk.c addstr.c allblk.c alloc.c base.c bool.c callin.c \ calout.c chatc.c cmdarg.c cmdfil.c cmdlin.c debfil.c deblev.c \ diacod.c dial.c diasub.c dnams.c errno.c errstr.c filnam.c \ freblk.c fredia.c free.c freprt.c fresys.c grdcmp.c hdial.c \ diff --git a/gnu/libexec/uucp/libuuconf/README b/gnu/libexec/uucp/libuuconf/README deleted file mode 100644 index cc022ad..0000000 --- a/gnu/libexec/uucp/libuuconf/README +++ /dev/null @@ -1,113 +0,0 @@ -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!cygint!airs!ian, or c/o Cygnus Support, -48 Grove Street, Somerville, MA, 02144, 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 -something with this package that you feel is reasonable but you feel -is prohibited by the license, contact me to see if we can work it out. - -WHAT IT IS - -This is a beta release of the uuconf library. The uuconf library -provides a set of functions which can be used to read UUCP -configuration files. V2, HDB, and Taylor UUCP configuration files are -supported. - -Also included are two programs, uuchk and uuconv. uuchk will read -configuration files and display the information it finds in a verbose -format. This can be helpful to ensure that your configuration files -are set up as you expect. uuconv can be used to convert configuration -files from one type to another. This is particularly helpful for -people installing Taylor UUCP on a existing system who want to take -advantage of the additional functionality provided by the Taylor UUCP -configuration files. - -This is strictly a beta release. The library provides all the -information needed for uuchk and uuconv, but does not yet provide -everything needed for uucp or cu. I am releasing it now to get -feedback and to provide the uuconv program to people using Taylor -UUCP. - -This may well be the only time this library is release independently. -This library will be provided with Taylor UUCP, and future releases of -the library will probably only occur as part of the complete Taylor -UUCP package. - -HOW TO USE IT - -Configure and optionally install the package as described in INSTALL. - -The functions provided by the library are described in uuconf.h. At -the moment there is no additional documentation. - -Programs which use the library should include uuconf.h, and should not -include any of the other header files. The functions listed in -uuconf.h all begin with the string "uuconf_". The internal library -functions all begin with the string "_uuconf_". The internal library -functions should not be called by a program which uses the library, as -they may change in future releases. The uuchk program is an example -of program which uses the library; uuconv is not, as it relies upon -internal data structures. - -The uuchk program takes a single optional option, -I, which may be -used to specify an alternate Taylor UUCP main configuration file. The -default configuration file is $(newconfigdir)/config ($(newconfigdir) -is defined in Makefile). For example: - uuchk - uuchk -I /usr/tmp/tstuu/Config1 - -The uuconv program requires two options: -i to specify the input type -and -o to specify the output type. Both options take a string -argument, which must be one of "v2", "hdb", or "taylor". uuconv also -takes an optional -I option, which is the same as the -I option to -uuchk. The conversion is not intended to be perfect, and the results -should be manually inspected. In particular, the dialcode file is not -converted (as the format is the same for all three configuration file -types, it may simply be copied to the appropriate new name). uuconv -will create new files in the current working directory. For example: - uuconv -i hdb -o taylor - uuconv -i taylor -I /usr/tmp/tstuu/Config1 -o v2 - -NOTES - -The initial underscore on the internal library functions is required -by the GNU standards. As ANSI C reserves external identifiers with an -initial underscore for the implementation, it is possible, though -unlikely, that this will cause problems on other implementations; no -workaround is currently provided for such problems. - -The library functions rely upon the following functions: - - fclose fopen free fseek - ftell getc isalpha isdigit - islower isspace isupper malloc - realloc rewind strchr strcmp - strcspn strlen strncmp strspn - tolower toupper - -and the following header files: - - ctype.h errno.h stdio.h - -If the following functions cannot be found by the configure script, -replacements will be used (the replacement for strerror is Unix -dependent): - - getline memcpy strcasecmp strdup - strerror strncasecmp strtol - -If the following header files are found, they will be included: - - libc.h limits.h memory.h stddef.h - stdlib.h string.h strings.h sys/types.h - -The following functions are required on Unix only: - - fcntl fileno - -The following headers are used, if found, on Unix only: - - fcntl.h sys/file.h diff --git a/gnu/libexec/uucp/libuucp/MANIFEST b/gnu/libexec/uucp/libuucp/MANIFEST deleted file mode 100644 index 909eb67..0000000 --- a/gnu/libexec/uucp/libuucp/MANIFEST +++ /dev/null @@ -1,63 +0,0 @@ -COPYING -ChangeLog -MANIFEST -Makefile.in -NEWS -README -TODO -chat.c -config.h.in -configure -configure.in -conn.c -conn.h -copy.c -cu.1 -cu.c -cu.h -getopt.h -install-sh -log.c -policy.h -prot.c -prot.h -prote.c -protf.c -protg.c -proti.c -protj.c -prott.c -proty.c -protz.c -rec.c -send.c -sysh.unx -system.h -time.c -trans.c -trans.h -tstuu.c -util.c -uuchk.c -uucico.8 -uucico.c -uuconf.h -uuconv.c -uucp.1 -uucp.c -uucp.h -uucp.texi -uudefs.h -uudir.c -uulog.c -uuname.c -uupick.c -uusched.in -uustat.1 -uustat.c -uuto.in -uux.1 -uux.c -uuxqt.8 -uuxqt.c -xcmd.c diff --git a/gnu/libexec/uucp/libuucp/Makefile b/gnu/libexec/uucp/libuucp/Makefile index 3c4c5e9..4acbd9f 100644 --- a/gnu/libexec/uucp/libuucp/Makefile +++ b/gnu/libexec/uucp/libuucp/Makefile @@ -1,14 +1,13 @@ # This is the Makefile for the libuucp subdirectory of Taylor UUCP # $FreeBSD$ -LIB= uucp -SRCS = buffer.c crc.c debug.c escape.c getopt.c getop1.c parse.c spool.c \ - status.c xfree.c xmall.c xreall.c \ - getlin.c -CFLAGS+= -I$(.CURDIR)/../common_sources - -NOMAN= noman -NOPROFILE= noprofile +LIB= uucp +SRCS= buffer.c crc.c debug.c escape.c getlin.c getopt.c getop1.c \ + parse.c spool.c status.c xfree.c xmall.c xreall.c +CFLAGS+=-I$(.CURDIR)/../common_sources + +NOMAN= noman +NOPROFILE=noprofile install: diff --git a/gnu/libexec/uucp/libuucp/bsrch.c b/gnu/libexec/uucp/libuucp/bsrch.c deleted file mode 100644 index 58b8710..0000000 --- a/gnu/libexec/uucp/libuucp/bsrch.c +++ /dev/null @@ -1,54 +0,0 @@ -/* 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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. - -This file was modified slightly by Ian Lance Taylor, May 1992, for -Taylor UUCP. */ - -#include "uucp.h" - -/* Perform a binary search for KEY in BASE which has NMEMB elements - of SIZE bytes each. The comparisons are done by (*COMPAR)(). */ -pointer -bsearch (key, base, nmemb, size, compar) - register constpointer key; - register constpointer base; - size_t nmemb; - register size_t size; - register int (*compar) P((constpointer, constpointer)); -{ - register size_t l, u, idx; - register constpointer p; - register int comparison; - - l = 0; - u = nmemb; - while (l < u) - { - idx = (l + u) / 2; - p = (constpointer) (((const char *) base) + (idx * size)); - comparison = (*compar)(key, p); - if (comparison < 0) - u = idx; - else if (comparison > 0) - l = idx + 1; - else - return (pointer) p; - } - - return NULL; -} diff --git a/gnu/libexec/uucp/libuucp/bzero.c b/gnu/libexec/uucp/libuucp/bzero.c deleted file mode 100644 index 098e551..0000000 --- a/gnu/libexec/uucp/libuucp/bzero.c +++ /dev/null @@ -1,15 +0,0 @@ -/* bzero.c - Zero out a buffer. */ - -#include "uucp.h" - -void -bzero (parg, c) - pointer parg; - int c; -{ - char *p = (char *) parg; - - while (c-- != 0) - *p++ = 0; -} diff --git a/gnu/libexec/uucp/libuucp/memchr.c b/gnu/libexec/uucp/libuucp/memchr.c deleted file mode 100644 index c743154..0000000 --- a/gnu/libexec/uucp/libuucp/memchr.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - Based on strlen implemention by Torbjorn Granlund (tege@sics.se), - with help from Dan Sahlin (dan@sics.se) and - commentary by Jim Blandy (jimb@ai.mit.edu); - adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), - and implemented by Roland McGrath (roland@ai.mit.edu). - -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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. - -This file was modified slightly by Ian Lance Taylor, May 1992, for -Taylor UUCP. It assumes 32 bit longs. I'm willing to trust that any -system which does not have 32 bit longs will have its own -implementation of memchr. */ - -#include "uucp.h" - -/* Search no more than N bytes of S for C. */ - -pointer -memchr (s, c, n) - constpointer s; - int c; - size_t n; -{ - const char *char_ptr; - const unsigned long int *longword_ptr; - unsigned long int longword, magic_bits, charmask; - - c = BUCHAR (c); - - /* Handle the first few characters by reading one character at a time. - Do this until CHAR_PTR is aligned on a 4-byte border. */ - for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0; - --n, ++char_ptr) - if (BUCHAR (*char_ptr) == c) - return (pointer) char_ptr; - - longword_ptr = (unsigned long int *) char_ptr; - - /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits - the "holes." Note that there is a hole just to the left of - each byte, with an extra at the end: - - bits: 01111110 11111110 11111110 11111111 - bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD - - The 1-bits make sure that carries propagate to the next 0-bit. - The 0-bits provide holes for carries to fall into. */ - magic_bits = 0x7efefeff; - - /* Set up a longword, each of whose bytes is C. */ - charmask = c | (c << 8); - charmask |= charmask << 16; - - /* Instead of the traditional loop which tests each character, - we will test a longword at a time. The tricky part is testing - if *any of the four* bytes in the longword in question are zero. */ - while (n >= 4) - { - /* We tentatively exit the loop if adding MAGIC_BITS to - LONGWORD fails to change any of the hole bits of LONGWORD. - - 1) Is this safe? Will it catch all the zero bytes? - Suppose there is a byte with all zeros. Any carry bits - propagating from its left will fall into the hole at its - least significant bit and stop. Since there will be no - carry from its most significant bit, the LSB of the - byte to the left will be unchanged, and the zero will be - detected. - - 2) Is this worthwhile? Will it ignore everything except - zero bytes? Suppose every byte of LONGWORD has a bit set - somewhere. There will be a carry into bit 8. If bit 8 - is set, this will carry into bit 16. If bit 8 is clear, - one of bits 9-15 must be set, so there will be a carry - into bit 16. Similarly, there will be a carry into bit - 24. If one of bits 24-30 is set, there will be a carry - into bit 31, so all of the hole bits will be changed. - - The one misfire occurs when bits 24-30 are clear and bit - 31 is set; in this case, the hole at bit 31 is not - changed. If we had access to the processor carry flag, - we could close this loophole by putting the fourth hole - at bit 32! - - So it ignores everything except 128's, when they're aligned - properly. - - 3) But wait! Aren't we looking for C, not zero? - Good point. So what we do is XOR LONGWORD with a longword, - each of whose bytes is C. This turns each byte that is C - into a zero. */ - - longword = *longword_ptr++ ^ charmask; - - /* Add MAGIC_BITS to LONGWORD. */ - if ((((longword + magic_bits) - - /* Set those bits that were unchanged by the addition. */ - ^ ~longword) - - /* Look at only the hole bits. If any of the hole bits - are unchanged, most likely one of the bytes was a - zero. */ - & ~magic_bits) != 0) - { - /* Which of the bytes was C? If none of them were, it was - a misfire; continue the search. */ - - const char *cp = (const char *) (longword_ptr - 1); - - if (BUCHAR (cp[0]) == c) - return (pointer) cp; - if (BUCHAR (cp[1]) == c) - return (pointer) &cp[1]; - if (BUCHAR (cp[2]) == c) - return (pointer) &cp[2]; - if (BUCHAR (cp[3]) == c) - return (pointer) &cp[3]; - } - - n -= 4; - } - - char_ptr = (const char *) longword_ptr; - - while (n-- > 0) - { - if (BUCHAR (*char_ptr) == c) - return (pointer) char_ptr; - else - ++char_ptr; - } - - return NULL; -} diff --git a/gnu/libexec/uucp/libuucp/memcmp.c b/gnu/libexec/uucp/libuucp/memcmp.c deleted file mode 100644 index b61578a..0000000 --- a/gnu/libexec/uucp/libuucp/memcmp.c +++ /dev/null @@ -1,19 +0,0 @@ -/* memcmp.c - Compare two memory buffers. */ - -#include "uucp.h" - -int -memcmp (p1arg, p2arg, c) - constpointer p1arg; - constpointer p2arg; - size_t c; -{ - const char *p1 = (const char *) p1arg; - const char *p2 = (const char *) p2arg; - - while (c-- != 0) - if (*p1++ != *p2++) - return BUCHAR (*--p1) - BUCHAR (*--p2); - return 0; -} diff --git a/gnu/libexec/uucp/libuucp/memcpy.c b/gnu/libexec/uucp/libuucp/memcpy.c deleted file mode 100644 index 2258123..0000000 --- a/gnu/libexec/uucp/libuucp/memcpy.c +++ /dev/null @@ -1,18 +0,0 @@ -/* memcpy.c - Copy one memory buffer to another. */ - -#include "uucp.h" - -pointer -memcpy (ptoarg, pfromarg, c) - pointer ptoarg; - constpointer pfromarg; - size_t c; -{ - char *pto = (char *) ptoarg; - const char *pfrom = (const char *) pfromarg; - - while (c-- != 0) - *pto++ = *pfrom++; - return ptoarg; -} diff --git a/gnu/libexec/uucp/libuucp/strcas.c b/gnu/libexec/uucp/libuucp/strcas.c deleted file mode 100644 index 4bb2251..0000000 --- a/gnu/libexec/uucp/libuucp/strcas.c +++ /dev/null @@ -1,33 +0,0 @@ -/* strcas.c - Compare two strings case insensitively. */ - -#include "uucp.h" -#include <ctype.h> - -int -strcasecmp (z1, z2) - const char *z1; - const char *z2; -{ - char b1, b2; - - while ((b1 = *z1++) != '\0') - { - b2 = *z2++; - if (b2 == '\0') - return 1; - if (b1 != b2) - { - if (isupper (BUCHAR (b1))) - b1 = tolower (BUCHAR (b1)); - if (isupper (BUCHAR (b2))) - b2 = tolower (BUCHAR (b2)); - if (b1 != b2) - return b1 - b2; - } - } - if (*z2 == '\0') - return 0; - else - return -1; -} diff --git a/gnu/libexec/uucp/libuucp/strchr.c b/gnu/libexec/uucp/libuucp/strchr.c deleted file mode 100644 index ca8d8e9..0000000 --- a/gnu/libexec/uucp/libuucp/strchr.c +++ /dev/null @@ -1,16 +0,0 @@ -/* strchr.c - Look for a character in a string. This works for a null byte. */ - -#include "uucp.h" - -char * -strchr (z, b) - const char *z; - int b; -{ - b = (char) b; - while (*z != b) - if (*z++ == '\0') - return NULL; - return (char *) z; -} diff --git a/gnu/libexec/uucp/libuucp/strdup.c b/gnu/libexec/uucp/libuucp/strdup.c deleted file mode 100644 index 231e35b..0000000 --- a/gnu/libexec/uucp/libuucp/strdup.c +++ /dev/null @@ -1,18 +0,0 @@ -/* strdup.c - Duplicate a string into memory. */ - -#include "uucp.h" - -char * -strdup (z) - const char *z; -{ - size_t csize; - char *zret; - - csize = strlen (z) + 1; - zret = malloc (csize); - if (zret != NULL) - memcpy (zret, z, csize); - return zret; -} diff --git a/gnu/libexec/uucp/libuucp/strncs.c b/gnu/libexec/uucp/libuucp/strncs.c deleted file mode 100644 index 6959d62..0000000 --- a/gnu/libexec/uucp/libuucp/strncs.c +++ /dev/null @@ -1,39 +0,0 @@ -/* strncs.c - Compare two strings case insensitively up to a point. */ - -#include "uucp.h" -#include <ctype.h> - -int -strncasecmp (z1, z2, c) - const char *z1; - const char *z2; - size_t c; -{ - char b1, b2; - - if (c == 0) - return 0; - while ((b1 = *z1++) != '\0') - { - b2 = *z2++; - if (b2 == '\0') - return 1; - if (b1 != b2) - { - if (isupper (BUCHAR (b1))) - b1 = tolower (BUCHAR (b1)); - if (isupper (BUCHAR (b2))) - b2 = tolower (BUCHAR (b2)); - if (b1 != b2) - return b1 - b2; - } - --c; - if (c == 0) - return 0; - } - if (*z2 == '\0') - return 0; - else - return -1; -} diff --git a/gnu/libexec/uucp/libuucp/strrch.c b/gnu/libexec/uucp/libuucp/strrch.c deleted file mode 100644 index a88e4b4..0000000 --- a/gnu/libexec/uucp/libuucp/strrch.c +++ /dev/null @@ -1,24 +0,0 @@ -/* strrch.c - Look for the last occurrence of a character in a string. This is - supposed to work for a null byte, although we never actually call - it with one. */ - -#include "uucp.h" - -char * -strrchr (z, b) - const char *z; - int b; -{ - char *zret; - - b = (char) b; - zret = NULL; - do - { - if (*z == b) - zret = (char *) z; - } - while (*z++ != '\0'); - return zret; -} diff --git a/gnu/libexec/uucp/libuucp/strstr.c b/gnu/libexec/uucp/libuucp/strstr.c deleted file mode 100644 index 2cf1097..0000000 --- a/gnu/libexec/uucp/libuucp/strstr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 1991, 1992 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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. - -This file was modified slightly by Ian Lance Taylor, May 1992, for -Taylor UUCP. */ - -#include "uucp.h" - -/* Return the first ocurrence of NEEDLE in HAYSTACK. */ -char * -strstr (haystack, needle) - const char *const haystack; - const char *const needle; -{ - register const char *const needle_end = strchr(needle, '\0'); - register const char *const haystack_end = strchr(haystack, '\0'); - register const size_t needle_len = needle_end - needle; - register const size_t needle_last = needle_len - 1; - register const char *begin; - - if (needle_len == 0) - return (char *) haystack_end; - if ((size_t) (haystack_end - haystack) < needle_len) - return NULL; - - for (begin = &haystack[needle_last]; begin < haystack_end; ++begin) - { - register const char *n = &needle[needle_last]; - register const char *h = begin; - do - if (*h != *n) - goto loop; - while (--n >= needle && --h >= haystack); - - return (char *) h; - loop:; - } - - return NULL; -} diff --git a/gnu/libexec/uucp/libuucp/strtol.c b/gnu/libexec/uucp/libuucp/strtol.c deleted file mode 100644 index 0c6b28c..0000000 --- a/gnu/libexec/uucp/libuucp/strtol.c +++ /dev/null @@ -1,175 +0,0 @@ -/* 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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. - -This file was modified slightly by Ian Lance Taylor, May 1992, for -Taylor UUCP. */ - -#include "uucp.h" - -#include <ctype.h> -#include <errno.h> - -#if HAVE_LIMITS_H -#include <limits.h> -#else -#define ULONG_MAX 4294967295 -#define LONG_MIN (- LONG_MAX - 1) -#define LONG_MAX 2147483647 -#endif - -#ifndef UNSIGNED -#define UNSIGNED 0 -#endif - -/* Convert NPTR to an `unsigned long int' or `long int' in base BASE. - If BASE is 0 the base is determined by the presence of a leading - zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. - If BASE is < 2 or > 36, it is reset to 10. - If ENDPTR is not NULL, a pointer to the character after the last - one converted is stored in *ENDPTR. */ -#if UNSIGNED -unsigned long int -#define strtol strtoul -#else -long int -#endif -strtol (nptr, endptr, base) - const char *nptr; - char **endptr; - int base; -{ - int negative; - register unsigned long int cutoff; - register unsigned int cutlim; - register unsigned long int i; - register const char *s; - register unsigned int c; - const char *save; - int overflow; - - if (base < 0 || base == 1 || base > 36) - base = 10; - - s = nptr; - - /* Skip white space. */ - while (isspace(BUCHAR (*s))) - ++s; - if (*s == '\0') - goto noconv; - - /* Check for a sign. */ - if (*s == '-') - { - negative = 1; - ++s; - } - else if (*s == '+') - { - negative = 0; - ++s; - } - else - negative = 0; - - if (base == 16 - && s[0] == '0' - && (s[1] == 'x' || s[1] == 'X')) - s += 2; - - /* If BASE is zero, figure it out ourselves. */ - if (base == 0) - if (*s == '0') - { - if (s[1] == 'x' || s[1] == 'X') - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; - - /* Save the pointer so we can check later if anything happened. */ - save = s; - - cutoff = ULONG_MAX / (unsigned long int) base; - cutlim = ULONG_MAX % (unsigned long int) base; - - overflow = 0; - i = 0; - for (c = BUCHAR (*s); c != '\0'; c = BUCHAR (*++s)) - { - if (isdigit(c)) - c -= '0'; - else if (islower(c)) - c = c - 'a' + 10; - else if (isupper(c)) - c = c - 'A' + 10; - else - break; - if (c >= base) - break; - /* Check for overflow. */ - if (i > cutoff || (i == cutoff && c > cutlim)) - overflow = 1; - else - { - i *= (unsigned long int) base; - i += c; - } - } - - /* Check if anything actually happened. */ - if (s == save) - goto noconv; - - /* Store in ENDPTR the address of one character - past the last character we converted. */ - if (endptr != NULL) - *endptr = (char *) s; - -#if !UNSIGNED - /* Check for a value that is within the range of - `unsigned long int', but outside the range of `long int'. */ - if (i > (negative ? - - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX)) - overflow = 1; -#endif - - if (overflow) - { - errno = ERANGE; -#if UNSIGNED - return ULONG_MAX; -#else - return negative ? LONG_MIN : LONG_MAX; -#endif - } - - /* Return the result of the appropriate sign. */ - return (negative ? - i : i); - - noconv: - /* There was no number to convert. */ - if (endptr != NULL) - *endptr = (char *) nptr; - return 0L; -} diff --git a/gnu/libexec/uucp/libuucp/strtou.c b/gnu/libexec/uucp/libuucp/strtou.c deleted file mode 100644 index d3c8189..0000000 --- a/gnu/libexec/uucp/libuucp/strtou.c +++ /dev/null @@ -1,21 +0,0 @@ -/* 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., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. */ - -#define UNSIGNED 1 - -#include "lib/strtol.c" diff --git a/gnu/libexec/uucp/sample/Makefile b/gnu/libexec/uucp/sample/Makefile deleted file mode 100644 index 82811b3..0000000 --- a/gnu/libexec/uucp/sample/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $FreeBSD$ - -FILES= call.sample config.sample dial.sample dialcode.sample passwd.sample \ - port.sample sys1.sample sys2.sample - -NOOBJ= noobj - -BINOWN= $(owner) -BINGRP= $(group) - -all clean cleandir depend lint tags: - -install: - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 440 ${FILES} \ - ${DESTDIR}/etc/uucp - -.include <bsd.prog.mk> diff --git a/gnu/libexec/uucp/sample/call.sample b/gnu/libexec/uucp/sample/call.sample deleted file mode 100644 index de4190c..0000000 --- a/gnu/libexec/uucp/sample/call.sample +++ /dev/null @@ -1,20 +0,0 @@ -# This is an example of call, the call out password file for Taylor -# UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# This file is used when the ``call-login'' or ``call-password'' -# commands are used in the sys file with a "*" argument (e.g., -# ``call-login *''). The system name is looked up in this file, and -# the login name and password are used. - -# The point of this is that the sys file may then be publically -# readable, while still concealing the login names and passwords used -# to connect to the remote system. - -# The format is just system-name login-name password. -uunet Uairs foobar diff --git a/gnu/libexec/uucp/sample/config.sample b/gnu/libexec/uucp/sample/config.sample deleted file mode 100644 index e7d683b..0000000 --- a/gnu/libexec/uucp/sample/config.sample +++ /dev/null @@ -1,88 +0,0 @@ -# This is an example of config, the main configuration file for Taylor -# UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# You need not use this file at all; all the important commands have -# defaults which will be used if this file can not be found. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# You must choose a UUCP name. If your system is going to be -# communicating with other systems outside your organization, the name -# must be unique in the entire world. The usual method is to pick a -# name, and then search the UUCP maps (in the newsgroup -# comp.mail.maps) to see whether it has already been taken. See the -# README posting in comp.mail.maps for more information. If the name -# of your system as returned by "uuname -n" or "hostname" is the name -# you want to use, you do not need to set the name in this file. -# Otherwise uncomment and edit the following line. -# nodename uucp # The UUCP name of this system - -# The default spool directory is set in policy.h (the default is -# /usr/spool/uucp). All UUCP jobs and status information are kept in -# the spool directory. If you wish to change it, use the spool -# command. -# spool /usr/spool/uucp # The UUCP spool directory - -# The default public directory is set in policy.h (the default is -# /usr/spool/uucppublic). Remote systems may refer to a file in this -# directory using "~/FILE". By default, the public directory is the -# only directory which remote systems may transfer files in and out -# of. If you wish to change the public directory, use the pubdir -# command. -# pubdir /usr/spool/uucppublic # The UUCP public directory - -# The names of the UUCP log files are set in policy.h. The default -# names depend on the logging option you have chosen. If -# HAVE_TAYLOR_LOGGING is set in policy.h, the default log file name is -# /usr/spool/uucp/Log, the default statistics file name is -# /usr/spool/uucp/Stats, and the default debugging file name is -# /usr/spool/uucp/Debug. These file names may be set by the following -# commands. -# logfile /usr/spool/uucp/Log # The UUCP log file -# statfile /usr/spool/uucp/Stats # The UUCP statistics file -# debugfile /usr/spool/uucp/Debug # The UUCP debugging file - -# uuxqt is the program which executes UUCP requests from other -# systems. Normally one is started after each run of uucico, the -# communications daemon. You may control the maximum number of uuxqt -# programs run at the same time with the following command. The -# default is to have no maximum. -# max-uuxqts 1 # The maximum number of uuxqts - -# There are several files that uucico uses. By default it looks for -# them in newconfigdir, as set in Makefile.in. You may name one or -# more of each type of file using the following commands. -# sysfile FILES # Default "sys" -# portfile FILES # Default "port" -# dialfile FILES # Default "dial" -# dialcodefile FILES # Default "dialcode" -# callfile FILES # Default "call" -# passwdfile FILES # Default "passwd" - -# The ``timetable'' command may be used to declare timetables. These -# may then be referred to in time strings in the other files. -# timetable Day Wk0905-1655 - -# The ``unknown'' command is followed by any command which may appear -# in a sys file. These commands are taken together to describe what -# is permitted to a system which is not listed in any sys file. If -# the ``unknown'' command, then unknown systems are not permitted to -# connect. - -# Here is an example which permits unknown systems to download files -# from /usr/spool/anonymous, and to upload them to -# /usr/spool/anonymous/upload. -# -# No commands may be executed (the list of permitted commands is empty) -# unknown commands -# The public directory is /usr/spool/anonymous -# unknown pubdir /usr/spool/anonymous -# Only files in the public directory may be sent; users may not download -# files from the upload directory -# unknown remote-send ~ !~/upload -# May only upload files into /usr/spool/anonymous/upload -# unknown remote-receive ~/upload diff --git a/gnu/libexec/uucp/sample/dial.sample b/gnu/libexec/uucp/sample/dial.sample deleted file mode 100644 index 4480ec5..0000000 --- a/gnu/libexec/uucp/sample/dial.sample +++ /dev/null @@ -1,41 +0,0 @@ -# $FreeBSD$ - -# This is an example of dial, the dialer configuration file for Taylor -# UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# All dialers named in the port (or sys) file must be described in the -# dial file. It is also possible to describe a dialer directly in the -# port (or sys) file. - -# This is a typical Hayes modem definition. -dialer hayes - -# The chat script used to dial the phone. -# This means: -# 1) expect nothing (i.e., continue with step 2) -# 2) send "ATZ", then a carriage return, then sleep for 1 to 2 -# seconds. The \c means to not send a final carriage return. -# 3) wait until the modem echoes "OK" -# 4) send "ATDT", then the telephone number (after translating any -# dialcodes). -# 5) wait until the modem echoes "CONNECT" -# 6) Wait a little more, if your modem give CONNECT before carrier up -chat "" ATZ\r\d\c OK ATDT\T CONNECT \p\c - -# If we get "BUSY" or "NO CARRIER" during the dial chat script we -# abort the dial immediately. -chat-fail BUSY -chat-fail ERROR -chat-fail NO\sDIALTONE -chat-fail NO\sCARRIER - -# When the call is over, we make sure we hangup the modem. -# You don't need this stuff, if you modem can handle DTR drop properly -complete \d\d+++\d\dATH\r\c -abort \d\d+++\d\dATH\r\c diff --git a/gnu/libexec/uucp/sample/dialcode.sample b/gnu/libexec/uucp/sample/dialcode.sample deleted file mode 100644 index 710a07b..0000000 --- a/gnu/libexec/uucp/sample/dialcode.sample +++ /dev/null @@ -1,19 +0,0 @@ -# This is an example of dialcode, the dialcode configuration file for -# Taylor UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# The dialcode file is used if \T is used in the dialer chat script -# and the telephone number begins with alphabetic characters. The -# alphabetic characters are looked up and translated in dialcode. - -# Here are a couple of sample dialcodes. -MA 617 -CA 415 - -# For example, if the phone number (from the sys file) is MA7389449, -# then the string sent to the modem will be 6177389449. diff --git a/gnu/libexec/uucp/sample/passwd.sample b/gnu/libexec/uucp/sample/passwd.sample deleted file mode 100644 index 2b04e13..0000000 --- a/gnu/libexec/uucp/sample/passwd.sample +++ /dev/null @@ -1,18 +0,0 @@ -# This is an example of passwd, the call in password file for Taylor -# UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# This file is used when uucico is invoked with the -l or -e argument. -# uucico will then prompt for a login name and password. The login -# name is looked up in this file to check the password (the system -# password file, /etc/passwd, is not checked). This permits uucico to -# completely take over a port, allowing UUCP access to remote systems -# but not permitting remote users to actually log in to the system. - -# The format is just login-name password. -Uairs foobar diff --git a/gnu/libexec/uucp/sample/port.sample b/gnu/libexec/uucp/sample/port.sample deleted file mode 100644 index 8e48186..0000000 --- a/gnu/libexec/uucp/sample/port.sample +++ /dev/null @@ -1,41 +0,0 @@ -# This is an example of port, the port configuration file for Taylor -# UUCP. To use it, you must compile the package with -# HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), copy -# this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# All ports named in the sys file must be described in a port file. -# It is also possible to describe the port directly in the sys file. - -# Commands that appears before the first ``port'' command are defaults -# for all ports that appear later in the file. In this case all ports -# will default to being modems (other possible types are direct, tcp -# and tli). -type modem - -# Now we describe two ports. - -# This is the name of the port. This name may be used in the sys file -# to select the port, or the sys file may just specify a baud rate in -# which case the first matching unlocked port will be used. -port port1 - -# This is the device name to open to dial out. -device /dev/ttyd0 - -# This is the dialer to use, as described in the dialer file. -dialer hayes - -# This is the baud rate to dial out at. -speed 2400 - -# Here is a second port. This is like the first, except that it uses -# a different device. It also permits a range of speeds, which is -# mainly useful if the system specifies a particular baud rate. -port port2 -device /dev/ttyd1 -dialer hayes -speed-range 2400 9600 diff --git a/gnu/libexec/uucp/sample/sys1.sample b/gnu/libexec/uucp/sample/sys1.sample deleted file mode 100644 index fa9e770..0000000 --- a/gnu/libexec/uucp/sample/sys1.sample +++ /dev/null @@ -1,44 +0,0 @@ -# This is an example of a sys file, the file(s) which describe remote -# systems for Taylor UUCP. To use it, you must compile the package -# with HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), -# copy this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# If you do not use the ``unknown'' command in the config file, then -# each system that you communicate with must be listed in a sys file. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# This is a sample sys file that might be used in a leaf system. A -# leaf system is one that only contacts one other system. sys2 -# provides another example. - -# The name of the remote system that we call. -system uunet - -# The login name and password are kept in the callout password file -# (by default this is the file "call" in newconfigdir). -call-login * -call-password * - -# We can send anything at any time. -time any - -# During the day we only accept grade 'Z' or above; at other times -# (not mentioned here) we accept all grades. uunet queues up news -# at grade 'd', which is lower than 'Z'. -call-timegrade Z Wk0755-2305,Su1655-2305 - -# The phone number to call. -phone 7389449 - -# uunet tends to be slow, so we increase the timeout -chat-timeout 120 - -# The port we use to dial out. -port serial - -# Increase the timeout and the number of retries. -protocol-parameter g timeout 20 -protocol-parameter g retries 10 diff --git a/gnu/libexec/uucp/sample/sys2.sample b/gnu/libexec/uucp/sample/sys2.sample deleted file mode 100644 index 856529a..0000000 --- a/gnu/libexec/uucp/sample/sys2.sample +++ /dev/null @@ -1,51 +0,0 @@ -# This is an example of a sys file, the file(s) which describe remote -# systems for Taylor UUCP. To use it, you must compile the package -# with HAVE_TAYLOR_CONFIG set to 1 in policy.h (that is the default), -# copy this file to newconfigdir as set in Makefile.in (the default is -# /usr/local/conf/uucp), and edit it as appropriate for your system. - -# If you do not use the ``unknown'' command in the config file, then -# each system that you communicate with must be listed in a sys file. - -# Everything after a '#' character is a comment. To uncomment any of -# the sample lines below, just delete the '#'. - -# This is a sample sys file that might be used by a system that -# contacts a couple of other systems, both of which are treated the -# same. sys1 provides another example. - -# Commands that appear before the first ``system'' commands are -# defaults for all systems listed in the file. - -# Get the login name and password to use from the call-out file. By -# default this is the file "call" in newconfigdir. -call-login * -call-password * - -# The systems must use a particular login -called-login Ulocal - -# Permit local users to send any world readable file -local-send / - -# Permit local uses to request into any world writable directory -local-receive / - -# Call at any time -time any - -# Use port1, then port2 -port port1 - -alternate - -port port2 - -# Now define the systems themselves. Because of all the defaults we -# used, there is very little to specify for the systems themselves. - -system comton -phone 5551212 - -system bugs -phone 5552424 diff --git a/gnu/libexec/uucp/tstuu.c b/gnu/libexec/uucp/tstuu.c deleted file mode 100644 index b220677..0000000 --- a/gnu/libexec/uucp/tstuu.c +++ /dev/null @@ -1,1603 +0,0 @@ -/* tstuu.c - Test the uucp package on a UNIX system. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char tstuu_rcsid[] = "$FreeBSD$"; -#endif - -#include "sysdep.h" -#include "system.h" -#include "getopt.h" - -#include <stdio.h> -#include <ctype.h> -#include <errno.h> - -#if HAVE_SYS_TIMES_H -#include <sys/times.h> -#endif - -#if HAVE_SYS_IOCTL_H -#include <sys/ioctl.h> -#endif - -#if HAVE_SELECT -#if HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#if HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -#endif - -#if HAVE_POLL -#if HAVE_STROPTS_H -#include <stropts.h> -#endif -#if HAVE_POLL_H -#include <poll.h> -#endif -#endif - -#if HAVE_FCNTL_H -#include <fcntl.h> -#else -#if HAVE_SYS_FILE_H -#include <sys/file.h> -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#if HAVE_TIME_H -#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME -#include <time.h> -#endif -#endif - -#if HAVE_SYS_WAIT_H -#include <sys/wait.h> -#endif - -#if HAVE_UNION_WAIT -typedef union wait wait_status; -#else -typedef int wait_status; -#endif - -#if HAVE_STREAMS_PTYS -#include <termio.h> -extern char *ptsname (); -#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) */ - -#if O_NDELAY == 0 && O_NONBLOCK == 0 - #error No way to do nonblocking I/O -#endif - -/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */ -#ifndef EAGAIN -#ifndef EWOULDBLOCK -#define EAGAIN (-1) -#define EWOULDBLOCK (-1) -#else /* defined (EWOULDBLOCK) */ -#define EAGAIN EWOULDBLOCK -#endif /* defined (EWOULDBLOCK) */ -#else /* defined (EAGAIN) */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif /* ! defined (EWOULDBLOCK) */ -#endif /* defined (EAGAIN) */ - -#ifndef ENODATA -#define ENODATA EAGAIN -#endif - -/* Make sure we have a CLK_TCK definition, even if it makes no sense. - This is in case TIMES_TICK is defined as CLK_TCK. */ -#ifndef CLK_TCK -#define CLK_TCK (60) -#endif - -/* Don't try too hard to get a TIMES_TICK value; it doesn't matter - that much. */ -#if TIMES_TICK == 0 -#undef TIMES_TICK -#define TIMES_TICK CLK_TCK -#endif - -#if TIMES_DECLARATION_OK -extern long times (); -#endif - -#ifndef SIGCHLD -#define SIGCHLD SIGCLD -#endif - -#if 1 -#define ZUUCICO_CMD "login uucp" -#define UUCICO_EXECL "/bin/login", "login", "uucp" -#else -#define ZUUCICO_CMD "su - nuucp" -#define UUCICO_EXECL "/bin/su", "su", "-", "nuucp" -#endif - -#if ! HAVE_SELECT && ! HAVE_POLL - #error You need select or poll -#endif - -#if ! HAVE_REMOVE -#undef remove -#define remove unlink -#endif - -/* Buffer chain to hold data read from a uucico. */ - -#define BUFCHARS (512) - -struct sbuf -{ - struct sbuf *qnext; - int cstart; - int cend; - char ab[BUFCHARS]; -}; - -/* Local functions. */ - -static void umake_file P((const char *zfile, int cextra)); -static void uprepare_test P((boolean fmake, int itest, - boolean fcall_uucico, - const char *zsys)); -static void ucheck_file P((const char *zfile, const char *zerr, - int cextra)); -static void ucheck_test P((int itest, boolean fcall_uucico)); -static RETSIGTYPE uchild P((int isig)); -static int cpshow P((char *z, int bchar)); -static void uchoose P((int *po1, int *po2)); -static long cread P((int o, struct sbuf **)); -static boolean fsend P((int o, int oslave, struct sbuf **)); -static boolean fwritable P((int o)); -static void xsystem P((const char *zcmd)); -static FILE *xfopen P((const char *zname, const char *zmode)); - -static char *zDebug; -static int iTest; -static boolean fCall_uucico; -static int iPercent; -static pid_t iPid1, iPid2; -static int cFrom1, cFrom2; -static char abLogout1[sizeof "tstout /dev/ptyp0"]; -static char abLogout2[sizeof "tstout /dev/ptyp0"]; -static char *zProtocols; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - const char *zcmd1, *zcmd2; - const char *zsys; - boolean fmake = TRUE; - int omaster1, oslave1, omaster2, oslave2; - char abpty1[sizeof "/dev/ptyp0"]; - char abpty2[sizeof "/dev/ptyp0"]; - struct sbuf *qbuf1, *qbuf2; - -#if ! HAVE_TAYLOR_CONFIG - fprintf (stderr, "%s: only works when compiled with HAVE_TAYLOR_CONFIG\n", - argv[0]); - exit (1); -#endif - - zcmd1 = NULL; - zcmd2 = NULL; - zsys = "test2"; - - while ((iopt = getopt (argc, argv, "c:np:s:t:ux:1:2:")) != EOF) - { - switch (iopt) - { - case 'c': - zProtocols = optarg; - break; - case 'n': - fmake = FALSE; - break; - case 'p': - iPercent = (int) strtol (optarg, (char **) NULL, 10); - srand ((unsigned int) ixsysdep_time ((long *) NULL)); - break; - case 's': - zsys = optarg; - break; - case 't': - iTest = (int) strtol (optarg, (char **) NULL, 10); - break; - case 'u': - fCall_uucico = TRUE; - break; - case 'x': - zDebug = optarg; - break; - case '1': - zcmd1 = optarg; - break; - case '2': - zcmd2 = optarg; - break; - default: - fprintf (stderr, - "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - fprintf (stderr, - "Usage: tstuu [-xn] [-t #] [-u] [-1 cmd] [-2 cmd]\n"); - exit (EXIT_FAILURE); - } - } - - if (fCall_uucico && zcmd2 == NULL) - zcmd2 = ZUUCICO_CMD; - - uprepare_test (fmake, iTest, fCall_uucico, zsys); - - (void) remove ("/usr/tmp/tstuu/spool1/core"); - (void) remove ("/usr/tmp/tstuu/spool2/core"); - - omaster1 = -1; - oslave1 = -1; - omaster2 = -1; - oslave2 = -1; - -#if ! HAVE_STREAMS_PTYS - - { - char *zptyname; - const char *zpty; - - zptyname = abpty1; - - for (zpty = "pqrs"; *zpty != '\0'; ++zpty) - { - int ipty; - - for (ipty = 0; ipty < 16; ipty++) - { - int om, os; - FILE *e; - - sprintf (zptyname, "/dev/pty%c%c", *zpty, - "0123456789abcdef"[ipty]); - om = open (zptyname, O_RDWR); - if (om < 0) - continue; - zptyname[5] = 't'; - os = open (zptyname, O_RDWR); - if (os < 0) - { - (void) close (om); - continue; - } - - if (omaster1 == -1) - { - omaster1 = om; - oslave1 = os; - - e = fopen ("/usr/tmp/tstuu/pty1", "w"); - if (e == NULL) - { - perror ("fopen"); - exit (EXIT_FAILURE); - } - fprintf (e, "%s", zptyname + 5); - if (fclose (e) != 0) - { - perror ("fclose"); - exit (EXIT_FAILURE); - } - - zptyname = abpty2; - } - else - { - omaster2 = om; - oslave2 = os; - - e = fopen ("/usr/tmp/tstuu/pty2", "w"); - if (e == NULL) - { - perror ("fopen"); - exit (EXIT_FAILURE); - } - fprintf (e, "%s", zptyname + 5); - if (fclose (e) != 0) - { - perror ("fclose"); - exit (EXIT_FAILURE); - } - break; - } - } - - if (omaster1 != -1 && omaster2 != -1) - break; - } - } - -#else /* HAVE_STREAMS_PTYS */ - - { - int ipty; - - for (ipty = 0; ipty < 2; ipty++) - { - int om, os; - FILE *e; - char *znam; - struct termio stio; - - om = open ((char *) "/dev/ptmx", O_RDWR); - if (om < 0) - break; - znam = ptsname (om); - if (znam == NULL) - break; - if (unlockpt (om) != 0 - || grantpt (om) != 0) - break; - - os = open (znam, O_RDWR); - if (os < 0) - { - (void) close (om); - om = -1; - break; - } - - if (ioctl (os, I_PUSH, "ptem") < 0 - || ioctl(os, I_PUSH, "ldterm") < 0) - { - perror ("ioctl"); - exit (EXIT_FAILURE); - } - - /* Can this really be right? */ - memset (&stio, 0, sizeof (stio)); - stio.c_cflag = B9600 | CS8 | CREAD | HUPCL; - - if (ioctl(os, TCSETA, &stio) < 0) - { - perror ("TCSETA"); - exit (EXIT_FAILURE); - } - - if (omaster1 == -1) - { - strcpy (abpty1, znam); - omaster1 = om; - oslave1 = os; - e = fopen ("/usr/tmp/tstuu/pty1", "w"); - if (e == NULL) - { - perror ("fopen"); - exit (EXIT_FAILURE); - } - fprintf (e, "%s", znam + 5); - if (fclose (e) != 0) - { - perror ("fclose"); - exit (EXIT_FAILURE); - } - } - else - { - strcpy (abpty2, znam); - omaster2 = om; - oslave2 = os; - e = fopen ("/usr/tmp/tstuu/pty2", "w"); - if (e == NULL) - { - perror ("fopen"); - exit (EXIT_FAILURE); - } - fprintf (e, "%s", znam + 5); - if (fclose (e) != 0) - { - perror ("fclose"); - exit (EXIT_FAILURE); - } - } - } - } - -#endif /* HAVE_STREAMS_PTYS */ - - if (omaster2 == -1) - { - fprintf (stderr, "No pseudo-terminals available\n"); - exit (EXIT_FAILURE); - } - - /* Make sure we can or these into an int for the select call. Most - systems could use 31 instead of 15, but it should never be a - problem. */ - if (omaster1 > 15 || omaster2 > 15) - { - fprintf (stderr, "File descriptors are too large\n"); - exit (EXIT_FAILURE); - } - - /* Prepare to log out the command if it is a login command. On - Ultrix 4.0 uucico can only be run from login for some reason. */ - - if (zcmd1 == NULL - || strncmp (zcmd1, "login", sizeof "login" - 1) != 0) - abLogout1[0] = '\0'; - else - sprintf (abLogout1, "tstout %s", abpty1); - - if (zcmd2 == NULL - || strncmp (zcmd2, "login", sizeof "login" - 1) != 0) - abLogout2[0] = '\0'; - else - sprintf (abLogout2, "tstout %s", abpty2); - - iPid1 = fork (); - if (iPid1 < 0) - { - perror ("fork"); - exit (EXIT_FAILURE); - } - else if (iPid1 == 0) - { - if (close (0) < 0 - || close (1) < 0 - || close (omaster1) < 0 - || close (omaster2) < 0 - || close (oslave2) < 0) - perror ("close"); - - if (dup2 (oslave1, 0) < 0 - || dup2 (oslave1, 1) < 0) - perror ("dup2"); - - if (close (oslave1) < 0) - perror ("close"); - - /* This is said to improve the tests on Linux. */ - sleep (3); - - if (zDebug != NULL) - fprintf (stderr, "About to exec first process\n"); - - if (zcmd1 != NULL) - exit (system ((char *) zcmd1)); - else - { - (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config1", - "-q", "-S", zsys, "-pstdin", (const char *) NULL); - perror ("execl failed"); - exit (EXIT_FAILURE); - } - } - - iPid2 = fork (); - if (iPid2 < 0) - { - perror ("fork"); - kill (iPid1, SIGTERM); - exit (EXIT_FAILURE); - } - else if (iPid2 == 0) - { - if (close (0) < 0 - || close (1) < 0 - || close (omaster1) < 0 - || close (oslave1) < 0 - || close (omaster2) < 0) - perror ("close"); - - if (dup2 (oslave2, 0) < 0 - || dup2 (oslave2, 1) < 0) - perror ("dup2"); - - if (close (oslave2) < 0) - perror ("close"); - - /* This is said to improve the tests on Linux. */ - sleep (5); - - if (zDebug != NULL) - fprintf (stderr, "About to exec second process\n"); - - if (fCall_uucico) - { - (void) execl (UUCICO_EXECL, (const char *) NULL); - perror ("execl failed"); - exit (EXIT_FAILURE); - } - else if (zcmd2 != NULL) - exit (system ((char *) zcmd2)); - else - { - (void) execl ("uucico", "uucico", "-I", "/usr/tmp/tstuu/Config2", - "-lq", (const char *)NULL); - perror ("execl failed"); - exit (EXIT_FAILURE); - } - } - - signal (SIGCHLD, uchild); - - if (fcntl (omaster1, F_SETFL, O_NDELAY | O_NONBLOCK) < 0 - && errno == EINVAL) - (void) fcntl (omaster1, F_SETFL, O_NONBLOCK); - if (fcntl (omaster2, F_SETFL, O_NDELAY | O_NONBLOCK) < 0 - && errno == EINVAL) - (void) fcntl (omaster2, F_SETFL, O_NONBLOCK); - - qbuf1 = NULL; - qbuf2 = NULL; - - while (TRUE) - { - int o1, o2; - boolean fcont; - - o1 = omaster1; - o2 = omaster2; - uchoose (&o1, &o2); - - if (o1 == -1 && o2 == -1) - { - if (zDebug != NULL) - fprintf (stderr, "Five second pause\n"); - continue; - } - - if (o1 != -1) - cFrom1 += cread (omaster1, &qbuf1); - - if (o2 != -1) - cFrom2 += cread (omaster2, &qbuf2); - - do - { - fcont = FALSE; - - if (qbuf1 != NULL - && fwritable (omaster2) - && fsend (omaster2, oslave2, &qbuf1)) - fcont = TRUE; - - if (qbuf2 != NULL - && fwritable (omaster1) - && fsend (omaster1, oslave1, &qbuf2)) - fcont = TRUE; - - if (! fcont - && (qbuf1 != NULL || qbuf2 != NULL)) - { - long cgot1, cgot2; - - cgot1 = cread (omaster1, &qbuf1); - cFrom1 += cgot1; - cgot2 = cread (omaster2, &qbuf2); - cFrom2 += cgot2; - fcont = TRUE; - } - } - while (fcont); - } - - /*NOTREACHED*/ -} - -/* When a child dies, kill them both. */ - -static RETSIGTYPE -uchild (isig) - int isig; -{ - struct tms sbase, s1, s2; - - signal (SIGCHLD, SIG_DFL); - - /* Give the processes a chance to die on their own. */ - sleep (2); - - (void) kill (iPid1, SIGTERM); - (void) kill (iPid2, SIGTERM); - - (void) times (&sbase); - -#if HAVE_WAITPID - (void) waitpid (iPid1, (pointer) NULL, 0); -#else /* ! HAVE_WAITPID */ -#if HAVE_WAIT4 - (void) wait4 (iPid1, (pointer) NULL, 0, (struct rusage *) NULL); -#else /* ! HAVE_WAIT4 */ - (void) wait ((wait_status *) NULL); -#endif /* ! HAVE_WAIT4 */ -#endif /* ! HAVE_WAITPID */ - - (void) times (&s1); - -#if HAVE_WAITPID - (void) waitpid (iPid2, (pointer) NULL, 0); -#else /* ! HAVE_WAITPID */ -#if HAVE_WAIT4 - (void) wait4 (iPid2, (wait_status *) NULL, 0, (struct rusage *) NULL); -#else /* ! HAVE_WAIT4 */ - (void) wait ((wait_status *) NULL); -#endif /* ! HAVE_WAIT4 */ -#endif /* ! HAVE_WAITPID */ - - (void) times (&s2); - - fprintf (stderr, - " First child: user: %g; system: %g\n", - (double) (s1.tms_cutime - sbase.tms_cutime) / (double) TIMES_TICK, - (double) (s1.tms_cstime - sbase.tms_cstime) / (double) TIMES_TICK); - fprintf (stderr, - "Second child: user: %g; system: %g\n", - (double) (s2.tms_cutime - s1.tms_cutime) / (double) TIMES_TICK, - (double) (s2.tms_cstime - s1.tms_cstime) / (double) TIMES_TICK); - - ucheck_test (iTest, fCall_uucico); - - if (abLogout1[0] != '\0') - { - if (zDebug != NULL) - fprintf (stderr, "Executing %s\n", abLogout1); - (void) system (abLogout1); - } - if (abLogout2[0] != '\0') - { - if (zDebug != NULL) - fprintf (stderr, "Executing %s\n", abLogout2); - (void) system (abLogout2); - } - - fprintf (stderr, "Wrote %d bytes from 1 to 2\n", cFrom1); - fprintf (stderr, "Wrote %d bytes from 2 to 1\n", cFrom2); - - if (access ("/usr/tmp/tstuu/spool1/core", R_OK) == 0) - fprintf (stderr, "core file 1 exists\n"); - if (access ("/usr/tmp/tstuu/spool2/core", R_OK) == 0) - fprintf (stderr, "core file 2 exists\n"); - - exit (EXIT_SUCCESS); -} - -/* Open a file without error. */ - -static FILE * -xfopen (zname, zmode) - const char *zname; - const char *zmode; -{ - FILE *eret; - - eret = fopen (zname, zmode); - if (eret == NULL) - { - perror (zname); - exit (EXIT_FAILURE); - } - return eret; -} - -/* Close a file without error. */ - -static void xfclose P((FILE *e)); - -static void -xfclose (e) - FILE *e; -{ - if (fclose (e) != 0) - { - perror ("fclose"); - exit (EXIT_FAILURE); - } -} - -/* Create a test file. */ - -static void -umake_file (z, c) - const char *z; - int c; -{ - int i; - FILE *e; - - e = xfopen (z, "w"); - - for (i = 0; i < 256; i++) - { - int i2; - - for (i2 = 0; i2 < 256; i2++) - putc (i, e); - } - - for (i = 0; i < c; i++) - putc (i, e); - - xfclose (e); -} - -/* Check a test file. */ - -static void -ucheck_file (z, zerr, c) - const char *z; - const char *zerr; - int c; -{ - int i; - FILE *e; - - e = xfopen (z, "r"); - - for (i = 0; i < 256; i++) - { - int i2; - - for (i2 = 0; i2 < 256; i2++) - { - int bread; - - bread = getc (e); - if (bread == EOF) - { - fprintf (stderr, - "%s: Unexpected EOF at position %d,%d\n", - zerr, i, i2); - xfclose (e); - return; - } - if (bread != i) - fprintf (stderr, - "%s: At position %d,%d got %d expected %d\n", - zerr, i, i2, bread, i); - } - } - - for (i = 0; i < c; i++) - { - int bread; - - bread = getc (e); - if (bread == EOF) - { - fprintf (stderr, "%s: Unexpected EOF at extra %d\n", zerr, i); - xfclose (e); - return; - } - if (bread != i) - fprintf (stderr, "%s: At extra %d got %d expected %d\n", - zerr, i, bread, i); - } - - if (getc (e) != EOF) - fprintf (stderr, "%s: File is too long", zerr); - - xfclose (e); -} - -/* Prepare all the configuration files for testing. */ - -static void -uprepare_test (fmake, itest, fcall_uucico, zsys) - boolean fmake; - int itest; - boolean fcall_uucico; - const char *zsys; -{ - FILE *e; - const char *zuucp1, *zuucp2; - const char *zuux1, *zuux2; - char ab[1000]; - const char *zfrom; - const char *zto; - -/* We must make /usr/tmp/tstuu world writeable or we won't be able to - receive files into it. */ - (void) umask (0); - -#ifndef S_IWOTH -#define S_IWOTH 02 -#endif - - if (mkdir ((char *) "/usr/tmp/tstuu", - IPUBLIC_DIRECTORY_MODE | S_IWOTH) != 0 - && errno != EEXIST) - { - perror ("mkdir"); - exit (EXIT_FAILURE); - } - - if (mkdir ((char *) "/usr/tmp/tstuu/spool1", IPUBLIC_DIRECTORY_MODE) != 0 - && errno != EEXIST) - { - perror ("mkdir"); - exit (EXIT_FAILURE); - } - - if (mkdir ((char *) "/usr/tmp/tstuu/spool2", IPUBLIC_DIRECTORY_MODE) != 0 - && errno != EEXIST) - { - perror ("mkdir"); - exit (EXIT_FAILURE); - } - - if (fmake) - { - e = xfopen ("/usr/tmp/tstuu/Config1", "w"); - - fprintf (e, "# First test configuration file\n"); - fprintf (e, "nodename test1\n"); - fprintf (e, "spool /usr/tmp/tstuu/spool1\n"); - fprintf (e, "lockdir /usr/tmp/tstuu/spool1\n"); - fprintf (e, "sysfile /usr/tmp/tstuu/System1\n"); - fprintf (e, "sysfile /usr/tmp/tstuu/System1.2\n"); - fprintf (e, "portfile /usr/tmp/tstuu/Port1\n"); - (void) remove ("/usr/tmp/tstuu/Log1"); -#if ! HAVE_HDB_LOGGING - fprintf (e, "logfile /usr/tmp/tstuu/Log1\n"); -#else - fprintf (e, "%s\n", "logfile /usr/tmp/tstuu/Log1/%s/%s"); -#endif - fprintf (e, "statfile /usr/tmp/tstuu/Stats1\n"); - fprintf (e, "debugfile /usr/tmp/tstuu/Debug1\n"); - fprintf (e, "callfile /usr/tmp/tstuu/Call1\n"); - fprintf (e, "pubdir /usr/tmp/tstuu\n"); -#if HAVE_V2_CONFIG - fprintf (e, "v2-files no\n"); -#endif -#if HAVE_HDB_CONFIG - fprintf (e, "hdb-files no\n"); -#endif - if (zDebug != NULL) - fprintf (e, "debug %s\n", zDebug); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/System1", "w"); - - fprintf (e, "# This file is ignored, to test multiple system files\n"); - fprintf (e, "time never\n"); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/System1.2", "w"); - - fprintf (e, "# First test system file\n"); - fprintf (e, "time any\n"); - fprintf (e, "port stdin\n"); - fprintf (e, "# That was the defaults\n"); - fprintf (e, "system %s\n", zsys); - if (! fcall_uucico) - { - FILE *eprog; - - eprog = xfopen ("/usr/tmp/tstuu/Chat1", "w"); - - /* Wait for the other side to open the port and flush input. */ - fprintf (eprog, "sleep 2\n"); - fprintf (eprog, - "echo password $1 speed $2 1>&2\n"); - fprintf (eprog, "echo test1\n"); - fprintf (eprog, "exit 0\n"); - - xfclose (eprog); - - if (chmod ("/usr/tmp/tstuu/Chat1", - S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) - { - perror ("chmod (/usr/tmp/tstuu/Chat1)"); - exit (EXIT_FAILURE); - } - - fprintf (e, "chat-program /usr/tmp/tstuu/Chat1 \\P \\S\n"); - - fprintf (e, "chat word: \\P\n"); - fprintf (e, "chat-fail login;\n"); - fprintf (e, "call-login *\n"); - fprintf (e, "call-password *\n"); - } - else - fprintf (e, "chat \"\"\n"); - fprintf (e, "call-transfer yes\n"); - fprintf (e, "commands cat\n"); - if (! fcall_uucico && iPercent == 0) - { - fprintf (e, "protocol-parameter g window 7\n"); - fprintf (e, "protocol-parameter g packet-size 4096\n"); - fprintf (e, "protocol-parameter j avoid \\377\n"); - } - if (zProtocols != NULL) - fprintf (e, "protocol %s\n", zProtocols); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/Port1", "w"); - - fprintf (e, "port stdin\n"); - fprintf (e, "type stdin\n"); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/Call1", "w"); - - fprintf (e, "Call out password file\n"); - fprintf (e, "%s test1 pass\\s1\n", zsys); - - xfclose (e); - - if (! fcall_uucico) - { - FILE *eprog; - - e = xfopen ("/usr/tmp/tstuu/Config2", "w"); - - fprintf (e, "# Second test configuration file\n"); - fprintf (e, "nodename test2\n"); - fprintf (e, "spool /usr/tmp/tstuu/spool2\n"); - fprintf (e, "lockdir /usr/tmp/tstuu/spool2\n"); - fprintf (e, "sysfile /usr/tmp/tstuu/System2\n"); - (void) remove ("/usr/tmp/tstuu/Log2"); -#if ! HAVE_HDB_LOGGING - fprintf (e, "logfile /usr/tmp/tstuu/Log2\n"); -#else - fprintf (e, "%s\n", "logfile /usr/tmp/tstuu/Log2/%s/%s"); -#endif - fprintf (e, "statfile /usr/tmp/tstuu/Stats2\n"); - fprintf (e, "debugfile /usr/tmp/tstuu/Debug2\n"); - fprintf (e, "passwdfile /usr/tmp/tstuu/Pass2\n"); - fprintf (e, "pubdir /usr/tmp/tstuu\n"); -#if HAVE_V2_CONFIG - fprintf (e, "v2-files no\n"); -#endif -#if HAVE_HDB_CONFIG - fprintf (e, "hdb-files no\n"); -#endif - if (zDebug != NULL) - fprintf (e, "debug %s\n", zDebug); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/System2", "w"); - - fprintf (e, "# Second test system file\n"); - fprintf (e, "system test1\n"); - fprintf (e, "called-login test1\n"); - fprintf (e, "request true\n"); - fprintf (e, "commands cat\n"); - if (zProtocols != NULL) - fprintf (e, "protocol %s\n", zProtocols); - - eprog = xfopen ("/usr/tmp/tstuu/Chat2", "w"); - - fprintf (eprog, - "echo port $1 1>&2\n"); - fprintf (eprog, "exit 0\n"); - - xfclose (eprog); - - if (chmod ("/usr/tmp/tstuu/Chat2", - S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) - { - perror ("chmod (/usr/tmp/tstuu/Chat2"); - exit (EXIT_FAILURE); - } - - fprintf (e, "called-chat-program /bin/sh /usr/tmp/tstuu/Chat2 \\Y\n"); - fprintf (e, "time any\n"); - - xfclose (e); - - e = xfopen ("/usr/tmp/tstuu/Pass2", "w"); - - fprintf (e, "# Call in password file\n"); - fprintf (e, "test1 pass\\s1\n"); - - xfclose (e); - } - } - - zuucp1 = "./uucp -I /usr/tmp/tstuu/Config1 -r"; - zuux1 = "./uux -I /usr/tmp/tstuu/Config1 -r"; - - if (fcall_uucico) - { - zuucp2 = "/usr/bin/uucp -r"; - zuux2 = "/usr/bin/uux -r"; - } - else - { - zuucp2 = "./uucp -I /usr/tmp/tstuu/Config2 -r"; - zuux2 = "./uux -I /usr/tmp/tstuu/Config2 -r"; - } - - /* Test transferring a file from the first system to the second. */ - if (itest == 0 || itest == 1) - { - zfrom = "/usr/tmp/tstuu/from1"; - if (fcall_uucico) - zto = "/usr/spool/uucppublic/to1"; - else - zto = "/usr/tmp/tstuu/to1"; - - (void) remove (zto); - umake_file (zfrom, 0); - - sprintf (ab, "%s %s %s!%s", zuucp1, zfrom, zsys, zto); - xsystem (ab); - } - - /* Test having the first system request a file from the second. */ - if (itest == 0 || itest == 2) - { - if (fcall_uucico) - zfrom = "/usr/spool/uucppublic/from2"; - else - zfrom = "/usr/tmp/tstuu/from2"; - zto = "/usr/tmp/tstuu/to2"; - - (void) remove (zto); - umake_file (zfrom, 3); - - sprintf (ab, "%s %s!%s %s", zuucp1, zsys, zfrom, zto); - xsystem (ab); - } - - /* Test having the second system send a file to the first. */ - if (itest == 0 || itest == 3) - { - if (fcall_uucico) - zfrom = "/usr/spool/uucppublic/from3"; - else - zfrom = "/usr/tmp/tstuu/from3"; - zto = "/usr/tmp/tstuu/to3"; - - (void) remove (zto); - umake_file (zfrom, 5); - - sprintf (ab, "%s -c \\~/from3 test1!~/to3", zuucp2); - xsystem (ab); - } - - /* Test having the second system request a file from the first. */ - if (itest == 0 || itest == 4) - { - zfrom = "/usr/tmp/tstuu/from4"; - if (fcall_uucico) - zto = "/usr/spool/uucppublic/to4"; - else - zto = "/usr/tmp/tstuu/to4"; - - (void) remove (zto); - umake_file (zfrom, 7); - - sprintf (ab, "%s test1!%s %s", zuucp2, zfrom, zto); - xsystem (ab); - } - - /* Test having the second system make an execution request. */ - if (itest == 0 || itest == 5) - { - zfrom = "/usr/tmp/tstuu/from5"; - if (fcall_uucico) - zto = "/usr/spool/uucppublic/to5"; - else - zto = "/usr/tmp/tstuu/to5"; - - (void) remove (zto); - umake_file (zfrom, 11); - - sprintf (ab, "%s test1!cat '<%s' '>%s'", zuux2, zfrom, zto); - xsystem (ab); - } - - /* Test having the first system request a wildcard. */ - if (itest == 0 || itest == 6) - { - const char *zfrom1, *zfrom2; - - if (fcall_uucico) - { - zfrom = "/usr/spool/uucppublic/to6\\*"; - zfrom1 = "/usr/spool/uucppublic/to6.1"; - zfrom2 = "/usr/spool/uucppublic/to6.2"; - } - else - { - zfrom = "/usr/tmp/tstuu/spool2/to6\\*"; - zfrom1 = "/usr/tmp/tstuu/spool2/to6.1"; - zfrom2 = "/usr/tmp/tstuu/spool2/to6.2"; - } - - umake_file (zfrom1, 100); - umake_file (zfrom2, 101); - (void) remove ("/usr/tmp/tstuu/to6.1"); - (void) remove ("/usr/tmp/tstuu/to6.2"); - - sprintf (ab, "%s %s!%s /usr/tmp/tstuu", zuucp1, zsys, zfrom); - xsystem (ab); - } - - /* Test having the second system request a wildcard. */ - if (itest == 0 || itest == 7) - { - const char *zto1, *zto2; - - if (fcall_uucico) - { - zto = "/usr/spool/uucppublic"; - zto1 = "/usr/spool/uucppublic/to7.1"; - zto2 = "/usr/spool/uucppublic/to7.2"; - } - else - { - zto = "/usr/tmp/tstuu"; - zto1 = "/usr/tmp/tstuu/to7.1"; - zto2 = "/usr/tmp/tstuu/to7.2"; - } - - umake_file ("/usr/tmp/tstuu/spool1/to7.1", 150); - umake_file ("/usr/tmp/tstuu/spool1/to7.2", 155); - (void) remove (zto1); - (void) remove (zto2); - - sprintf (ab, "%s test1!/usr/tmp/tstuu/spool1/to7.\\* %s", zuucp2, - zto); - xsystem (ab); - } - - /* Test an E command. This runs cat, discarding the output. */ - if ((itest == 0 || itest == 8) && ! fcall_uucico) - { - umake_file ("/usr/tmp/tstuu/from8", 30); - sprintf (ab, "%s - test2!cat < /usr/tmp/tstuu/from8", zuux1); - xsystem (ab); - } -} - -/* Try to make sure the file transfers were successful. */ - -static void -ucheck_test (itest, fcall_uucico) - int itest; - boolean fcall_uucico; -{ - if (itest == 0 || itest == 1) - { - if (fcall_uucico) - ucheck_file ("/usr/spool/uucppublic/to1", "test 1", 0); - else - ucheck_file ("/usr/tmp/tstuu/to1", "test 1", 0); - } - - if (itest == 0 || itest == 2) - ucheck_file ("/usr/tmp/tstuu/to2", "test 2", 3); - - if (itest == 0 || itest == 3) - ucheck_file ("/usr/tmp/tstuu/to3", "test 3", 5); - - if (itest == 0 || itest == 4) - { - if (fcall_uucico) - ucheck_file ("/usr/spool/uucppublic/to4", "test 4", 7); - else - ucheck_file ("/usr/tmp/tstuu/to4", "test 4", 7); - } - - if (itest == 0 || itest == 6) - { - ucheck_file ("/usr/tmp/tstuu/to6.1", "test 6.1", 100); - ucheck_file ("/usr/tmp/tstuu/to6.2", "test 6.2", 101); - } - - if (itest == 0 || itest == 7) - { - const char *zto1, *zto2; - - if (fcall_uucico) - { - zto1 = "/usr/spool/uucppublic/to7.1"; - zto2 = "/usr/spool/uucppublic/to7.2"; - } - else - { - zto1 = "/usr/tmp/tstuu/to7.1"; - zto2 = "/usr/tmp/tstuu/to7.2"; - } - - ucheck_file (zto1, "test 7.1", 150); - ucheck_file (zto2, "test 7.2", 155); - } -} - -/* A debugging routine used when displaying buffers. */ - -static int -cpshow (z, ichar) - char *z; - int ichar; -{ - if (isprint (BUCHAR (ichar)) && ichar != '\"') - { - *z = (char) ichar; - return 1; - } - - *z++ = '\\'; - - switch (ichar) - { - case '\n': - *z = 'n'; - return 2; - case '\r': - *z = 'r'; - return 2; - case '\"': - *z = '\"'; - return 2; - default: - sprintf (z, "%03o", (unsigned int)(ichar & 0xff)); - return strlen (z) + 1; - } -} - -/* Pick one of two file descriptors which is ready for reading, or - return in five seconds. If the argument is ready for reading, - leave it alone; otherwise set it to -1. */ - -static void -uchoose (po1, po2) - int *po1; - int *po2; -{ -#if HAVE_SELECT - - int iread; - struct timeval stime; - - iread = (1 << *po1) | (1 << *po2); - stime.tv_sec = 5; - stime.tv_usec = 0; - - if (select ((*po1 > *po2 ? *po1 : *po2) + 1, (pointer) &iread, - (pointer) NULL, (pointer) NULL, &stime) < 0) - { - perror ("select"); - uchild (SIGCHLD); - } - - if ((iread & (1 << *po1)) == 0) - *po1 = -1; - - if ((iread & (1 << *po2)) == 0) - *po2 = -1; - -#else /* ! HAVE_SELECT */ - -#if HAVE_POLL - - struct pollfd as[2]; - - as[0].fd = *po1; - as[0].events = POLLIN; - as[1].fd = *po2; - as[1].events = POLLIN; - - if (poll (as, 2, 5 * 1000) < 0) - { - perror ("poll"); - uchild (SIGCHLD); - } - - if ((as[0].revents & POLLIN) == 0) - *po1 = -1; - - if ((as[1].revents & POLLIN) == 0) - *po2 = -1; - -#endif /* HAVE_POLL */ -#endif /* ! HAVE_SELECT */ -} - -/* Read some data from a file descriptor. This keeps reading until - one of the reads gets no data. */ - -static long -cread (o, pqbuf) - int o; - struct sbuf **pqbuf; -{ - long ctotal; - - while (*pqbuf != NULL && (*pqbuf)->qnext != NULL) - pqbuf = &(*pqbuf)->qnext; - - ctotal = 0; - - while (TRUE) - { - int cgot; - - if (*pqbuf != NULL - && (*pqbuf)->cend >= sizeof (*pqbuf)->ab) - pqbuf = &(*pqbuf)->qnext; - - if (*pqbuf == NULL) - { - *pqbuf = (struct sbuf *) malloc (sizeof (struct sbuf)); - if (*pqbuf == NULL) - { - fprintf (stderr, "Out of memory\n"); - uchild (SIGCHLD); - } - (*pqbuf)->qnext = NULL; - (*pqbuf)->cstart = 0; - (*pqbuf)->cend = 0; - } - - cgot = read (o, (*pqbuf)->ab + (*pqbuf)->cend, - (sizeof (*pqbuf)->ab) - (*pqbuf)->cend); - if (cgot < 0) - { - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA) - cgot = 0; - else - { - perror ("read"); - uchild (SIGCHLD); - } - } - - if (cgot == 0) - return ctotal; - - ctotal += cgot; - - if (zDebug != NULL) - { - char abshow[325]; - char *zfrom; - char *zshow; - int i; - - zfrom = (*pqbuf)->ab + (*pqbuf)->cend; - zshow = abshow; - for (i = 0; i < cgot && i < 80; i++, zfrom++) - zshow += cpshow (zshow, *zfrom); - if (i < cgot) - { - *zshow++ = '.'; - *zshow++ = '.'; - *zshow++ = '.'; - } - *zshow = '\0'; - fprintf (stderr, "Read from %d: %d \"%s\"\n", o, cgot, abshow); - fflush (stderr); - } - - if (iPercent > 0) - { - int i; - int c; - - c = 0; - for (i = 0; i < cgot; i++) - { - if (rand () % 1000 < iPercent) - { - ++(*pqbuf)->ab[(*pqbuf)->cend + i]; - ++c; - } - } - if (zDebug != NULL && c > 0) - fprintf (stderr, "Clobbered %d bytes\n", c); - } - - (*pqbuf)->cend += cgot; - - if (ctotal > 256) - return ctotal; - } -} - -/* Write data to a file descriptor until one of the writes gets no - data. */ - -static boolean -fsend (o, oslave, pqbuf) - int o; - int oslave; - struct sbuf **pqbuf; -{ - long ctotal; - - ctotal = 0; - while (*pqbuf != NULL) - { - int cwrite, cwrote; - - if ((*pqbuf)->cstart >= (*pqbuf)->cend) - { - struct sbuf *qfree; - - qfree = *pqbuf; - *pqbuf = (*pqbuf)->qnext; - free ((pointer) qfree); - continue; - } - -#ifdef FIONREAD - { - long cunread; - - if (ioctl (oslave, FIONREAD, &cunread) < 0) - { - perror ("FIONREAD"); - uchild (SIGCHLD); - } - if (zDebug != NULL) - fprintf (stderr, "%ld unread\n", cunread); - cwrite = 256 - cunread; - if (cwrite <= 0) - break; - } -#else /* ! FIONREAD */ - if (! fwritable (o)) - break; - cwrite = 1; -#endif /* ! FIONREAD */ - - if (cwrite > (*pqbuf)->cend - (*pqbuf)->cstart) - cwrite = (*pqbuf)->cend - (*pqbuf)->cstart; - - cwrote = write (o, (*pqbuf)->ab + (*pqbuf)->cstart, cwrite); - if (cwrote < 0) - { - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENODATA) - cwrote = 0; - else - { - perror ("write"); - uchild (SIGCHLD); - } - } - - if (cwrote == 0) - break; - - ctotal += cwrote; - (*pqbuf)->cstart += cwrote; - } - - if (zDebug != NULL && ctotal > 0) - fprintf (stderr, "Wrote %ld to %d\n", ctotal, o); - - return ctotal > 0; -} - -/* Check whether a file descriptor can be written to. */ - -static boolean -fwritable (o) - int o; -{ -#if HAVE_SELECT - - int iwrite; - struct timeval stime; - int cfds; - - iwrite = 1 << o; - - stime.tv_sec = 0; - stime.tv_usec = 0; - - cfds = select (o + 1, (pointer) NULL, (pointer) &iwrite, - (pointer) NULL, &stime); - if (cfds < 0) - { - perror ("select"); - uchild (SIGCHLD); - } - - return cfds > 0; - -#else /* ! HAVE_SELECT */ - -#if HAVE_POLL - - struct pollfd s; - int cfds; - - s.fd = o; - s.events = POLLOUT; - - cfds = poll (&s, 1, 0); - if (cfds < 0) - { - perror ("poll"); - uchild (SIGCHLD); - } - - return cfds > 0; - -#endif /* HAVE_POLL */ -#endif /* ! HAVE_SELECT */ -} - -/* A version of the system command that checks for errors. */ - -static void -xsystem (zcmd) - const char *zcmd; -{ - int istat; - - istat = system ((char *) zcmd); - if (istat != 0) - { - fprintf (stderr, "Command failed with status %d\n", istat); - fprintf (stderr, "%s\n", zcmd); - exit (EXIT_FAILURE); - } -} diff --git a/gnu/libexec/uucp/uuchk/Makefile b/gnu/libexec/uucp/uuchk/Makefile deleted file mode 100644 index 4f5b3ce..0000000 --- a/gnu/libexec/uucp/uuchk/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# Makefile for uuchk -# $FreeBSD$ - -BINDIR= $(sbindir) - -PROG= uuchk -MAN= uuchk.8 -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -.include <bsd.prog.mk> diff --git a/gnu/libexec/uucp/uuchk/uuchk.8 b/gnu/libexec/uucp/uuchk/uuchk.8 deleted file mode 100644 index c5d348a..0000000 --- a/gnu/libexec/uucp/uuchk/uuchk.8 +++ /dev/null @@ -1,44 +0,0 @@ -.\" $FreeBSD$ -.TH uuchk 1 "Taylor UUCP 1.06" -.SH NAME -uuchk \- displays information from the UUCP configuration -.SH SYNOPSIS -.B uuchk -[-s system] [standard UUCP options] -.SH DESCRIPTION -The -.B uuchk -program reads the UUCP configuration files and displays -a rather lengthy description of what it finds. This is useful when -configuring UUCP to make certain that the UUCP package will do -what you expect it to do. -.SH OPTIONS -The following options may be given to -.B uuchk: -.TP 5 -.B \-s, \-\-system -Display the -configuration for just the specified system, rather than for all -systems. The -.B uuchk -program also supports the standard UUCP program -options. -.TP 5 -.B \-x type -.TP 5 -.B \-\-debug type -.TP 5 -.B \-I file -.TP 5 -.B \-\-config file -.TP 5 -.B \-v, \-\-version -.TP 5 -.B \-\-help -Standard UUCP options. -.SH SEE ALSO -uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. - diff --git a/gnu/libexec/uucp/uuchk/uuchk.c b/gnu/libexec/uucp/uuchk/uuchk.c deleted file mode 100644 index 38c241a..0000000 --- a/gnu/libexec/uucp/uuchk/uuchk.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* uuchk.c - Display what we think the permissions of systems are. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uuchk_rcsid[] = "$FreeBSD$"; -#endif - -#include "getopt.h" - -#include "uuconf.h" - -/* 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)); -static void ukshow_dialer P((struct uuconf_dialer *qdial)); -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 *)); -static struct uuconf_timespan *qcompress_span P((struct uuconf_timespan *)); -static void ukuuconf_error P((pointer puuconf, int iret)); - -/* Structure used to pass uuconf pointer into ikshow_port and also let - it record whether any ports were found. */ -struct sinfo -{ - /* The uuconf global pointer. */ - pointer puuconf; - /* The system. */ - const struct uuconf_system *qsys; - /* Whether any ports were seen. */ - boolean fgot; -}; - -/* Program name. */ -static const char *zKprogram; - -/* Long getopt options. */ -static const struct option asKlongopts[] = -{ - { "system", required_argument, NULL,'s' }, - { "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) - int argc; - char **argv; -{ - int iopt; - const char *zsystem = NULL; - const char *zconfig = NULL; - int iret; - pointer puuconf; - - zKprogram = argv[0]; - - while ((iopt = getopt_long (argc, argv, "I:s:vx:", asKlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 's': - /* Examine specific system. */ - zsystem = optarg; - break; - - case 'I': - /* Set the configuration file name. */ - zconfig = optarg; - break; - - case 'x': - /* Set the debugging level. There is actually no debugging - information for this program. */ - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 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 (); - /*NOTREACHED*/ - } - } - - if (optind != argc) - { - fprintf (stderr, "%s: too many arguments", zKprogram); - ukusage (); - } - - iret = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - - if (zsystem != NULL) - { - struct uuconf_system ssys; - - iret = uuconf_system_info (puuconf, zsystem, &ssys); - if (iret == UUCONF_NOT_FOUND) - { - fprintf (stderr, "%s: system not found\n", zsystem); - exit (EXIT_FAILURE); - } - else if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - - ukshow (&ssys, puuconf); - (void) uuconf_system_free (puuconf, &ssys); - } - else - { - const char *zstr; - int iint; - char **pzsystems; - - iret = uuconf_localname (puuconf, &zstr); - if (iret == UUCONF_SUCCESS) - printf ("Local node name %s\n", zstr); - else if (iret != UUCONF_NOT_FOUND) - ukuuconf_error (puuconf, iret); - - iret = uuconf_spooldir (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Spool directory %s\n", zstr); - - iret = uuconf_pubdir (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Public directory %s\n", zstr); - - iret = uuconf_lockdir (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Lock directory %s\n", zstr); - - iret = uuconf_logfile (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Log file %s\n", zstr); - - iret = uuconf_statsfile (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Statistics file %s\n", zstr); - - iret = uuconf_debugfile (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("Debug file %s\n", zstr); - - iret = uuconf_debuglevel (puuconf, &zstr); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - if (zstr != NULL) - printf ("Global debugging level %s\n", zstr); - - iret = uuconf_strip (puuconf, &iint); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - printf ("uucico -l will %sstrip login names and passwords\n", - (iint & UUCONF_STRIP_LOGIN) != 0 ? "" : "not "); - printf ("uucico will %sstrip UUCP protocol commands\n", - (iint & UUCONF_STRIP_PROTO) != 0 ? "" : "not "); - - iret = uuconf_maxuuxqts (puuconf, &iint); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - if (iint != 0) - printf ("Maximum number of uuxqt processes permitted %d\n", iint); - - iret = uuconf_runuuxqt (puuconf, &iint); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - if (iint > 0) - printf ("Start uuxqt every %d jobs\n", iint); - else - { - switch (iint) - { - case UUCONF_RUNUUXQT_NEVER: - printf ("Never start uuxqt\n"); - break; - case UUCONF_RUNUUXQT_ONCE: - printf ("Start uuxqt once per uucico invocation\n"); - break; - case UUCONF_RUNUUXQT_PERCALL: - printf ("Start uuxqt once per call\n"); - break; - default: - fprintf (stderr, "Illegal value from uuconf_runuuxqt\n"); - exit (EXIT_FAILURE); - break; - } - } - - iret = uuconf_system_names (puuconf, &pzsystems, FALSE); - 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; - - printf ("\n"); - iret = uuconf_system_info (puuconf, *pzsystems, &ssys); - if (iret != UUCONF_SUCCESS) - ukuuconf_error (puuconf, iret); - else - ukshow (&ssys, puuconf); - (void) uuconf_system_free (puuconf, &ssys); - ++pzsystems; - } - } - - exit (EXIT_SUCCESS); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void ukusage () -{ - fprintf (stderr, "Usage: %s [-s system] [-I 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, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [-s system] [-I file] [-v]\n", zKprogram); - printf (" -s,--system system: Only print configuration for named system\n"); - 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. */ - -static void -ukshow (qsys, puuconf) - const struct uuconf_system *qsys; - pointer puuconf; -{ - char **pz; - int i; - int iret; - boolean fanycall; - - printf ("System: %s", qsys->uuconf_zname); - if (qsys->uuconf_pzalias != NULL) - { - printf (" ("); - for (pz = qsys->uuconf_pzalias; *pz != NULL; pz++) - { - printf ("%s", *pz); - if (pz[1] != NULL) - printf (" "); - } - printf (")"); - } - printf ("\n"); - - fanycall = FALSE; - for (i = 0; qsys != NULL; qsys = qsys->uuconf_qalternate, i++) - { - boolean fcall, fcalled; - struct uuconf_timespan *qtime, *qspan; - - if (i != 0 || qsys->uuconf_qalternate != NULL) - { - printf ("Alternate %d", i); - if (qsys->uuconf_zalternate != NULL) - printf (" (%s)", qsys->uuconf_zalternate); - printf ("\n"); - } - - /* See if this alternate could be used when calling out. */ - fcall = qsys->uuconf_fcall; - if (qsys->uuconf_qtimegrade == NULL) - fcall = FALSE; - - /* See if this alternate could be used when calling in. */ - fcalled = qsys->uuconf_fcalled; - - if (! fcall && ! fcalled) - { - printf (" This alternate is never used\n"); - continue; - } - - if (fcall) - fanycall = TRUE; - - if (fcalled) - { - if (qsys->uuconf_zcalled_login != NULL - && strcmp (qsys->uuconf_zcalled_login, "ANY") != 0) - { - if (i == 0 && qsys->uuconf_qalternate == NULL) - printf (" Caller must log in as %s\n", - qsys->uuconf_zcalled_login); - else - printf (" When called using login name %s\n", - qsys->uuconf_zcalled_login); - } - else - printf (" When called using any login name\n"); - - if (qsys->uuconf_zlocalname != NULL) - printf (" Will use %s as name of local system\n", - qsys->uuconf_zlocalname); - } - - if (fcalled && qsys->uuconf_fcallback) - { - printf (" If called, will call back\n"); - fcalled = FALSE; - } - - if (fcall) - { - struct sinfo si; - - if (i == 0 && qsys->uuconf_qalternate == NULL) - printf (" Call out"); - else - printf (" This alternate applies when calling"); - - if (qsys->uuconf_zport != NULL || qsys->uuconf_qport != NULL) - { - printf (" using "); - if (qsys->uuconf_zport != NULL) - printf ("port %s", qsys->uuconf_zport); - else - printf ("a specially defined port"); - if (qsys->uuconf_ibaud != 0) - { - printf (" at speed %ld", qsys->uuconf_ibaud); - if (qsys->uuconf_ihighbaud != 0) - printf (" to %ld", qsys->uuconf_ihighbaud); - } - printf ("\n"); - } - else if (qsys->uuconf_ibaud != 0) - { - printf (" at speed %ld", qsys->uuconf_ibaud); - if (qsys->uuconf_ihighbaud != 0) - printf (" to %ld", qsys->uuconf_ihighbaud); - printf ("\n"); - } - else - printf (" using any port\n"); - - si.puuconf = puuconf; - si.qsys = qsys; - si.fgot = FALSE; - - if (qsys->uuconf_qport != NULL) - { - printf (" The port is defined as:\n"); - (void) ikshow_port (qsys->uuconf_qport, (pointer) &si); - } - else - { - struct uuconf_port sdummy; - - printf (" The possible ports are:\n"); - iret = uuconf_find_port (puuconf, qsys->uuconf_zport, - qsys->uuconf_ibaud, - qsys->uuconf_ihighbaud, - ikshow_port, (pointer) &si, - &sdummy); - if (iret != UUCONF_NOT_FOUND) - ukuuconf_error (puuconf, iret); - if (! si.fgot) - printf (" *** There are no matching ports\n"); - } - - if (qsys->uuconf_zphone != NULL) - { - if ((qsys->uuconf_zport != NULL - && strcmp (qsys->uuconf_zport, "TCP") == 0) - || (qsys->uuconf_qport != NULL - && (qsys->uuconf_qport->uuconf_ttype - == UUCONF_PORTTYPE_TCP - || qsys->uuconf_qport->uuconf_ttype - == UUCONF_PORTTYPE_TLI))) - printf (" Remote address %s\n", qsys->uuconf_zphone); - else - printf (" Phone number %s\n", qsys->uuconf_zphone); - } - - ukshow_chat (&qsys->uuconf_schat, " Chat"); - - if (qsys->uuconf_zcall_login != NULL - || qsys->uuconf_zcall_password != NULL) - { - char *zlogin, *zpass; - - 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 - { - if (zlogin != NULL) - { - printf (" Login name %s\n", zlogin); - free ((pointer) zlogin); - } - if (zpass != NULL) - { - printf (" Password %s\n", zpass); - free ((pointer) zpass); - } - } - } - - qtime = qcompress_span (qsys->uuconf_qtimegrade); - - for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext) - { - printf (" "); - ukshow_time (qspan); - printf (" may call if "); - if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW) - printf ("any work"); - else - printf ("work grade %c or higher", (char) qspan->uuconf_ival); - if (qspan->uuconf_cretry != 0) - printf (" (retry %d)", qspan->uuconf_cretry); - printf ("\n"); - } - - if (qsys->uuconf_cmax_retries > 0) - printf (" May retry the call up to %d times\n", - qsys->uuconf_cmax_retries); - - if (qsys->uuconf_qcalltimegrade != NULL) - { - boolean fprint, fother; - - qtime = qcompress_span (qsys->uuconf_qcalltimegrade); - fprint = FALSE; - fother = FALSE; - if (qtime->uuconf_istart != 0) - fother = TRUE; - for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext) - { - if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW) - { - fother = TRUE; - continue; - } - fprint = TRUE; - printf (" "); - ukshow_time (qspan); - printf (" may accept work grade %c or higher\n", - (char) qspan->uuconf_ival); - if (qspan->uuconf_qnext == NULL) - { - if (qspan->uuconf_iend != 7 * 24 * 60) - fother = TRUE; - } - else - { - if (qspan->uuconf_iend - != qspan->uuconf_qnext->uuconf_istart) - fother = TRUE; - } - } - if (fprint && fother) - printf (" (At other times may accept any work)\n"); - } - } - - if (fcalled) - { - if (qsys->uuconf_qcalledtimegrade != NULL) - { - boolean fprint, fother; - - qtime = qcompress_span (qsys->uuconf_qcalledtimegrade); - fprint = FALSE; - fother = FALSE; - if (qtime->uuconf_istart != 0) - fother = TRUE; - for (qspan = qtime; qspan != NULL; qspan = qspan->uuconf_qnext) - { - if ((char) qspan->uuconf_ival == UUCONF_GRADE_LOW) - { - fother = TRUE; - continue; - } - fprint = TRUE; - printf (" "); - ukshow_time (qspan); - printf (" will send work grade %c or higher\n", - (char) qspan->uuconf_ival); - if (qspan->uuconf_qnext == NULL) - { - if (qspan->uuconf_iend != 7 * 24 * 60) - fother = TRUE; - } - else - { - if (qspan->uuconf_iend - != qspan->uuconf_qnext->uuconf_istart) - fother = TRUE; - } - } - if (fprint && fother) - printf (" (At other times will send any work)\n"); - } - } - - if (fcall && qsys->uuconf_csuccess_wait != 0) - printf (" Will wait %d seconds after a successful call\n", - qsys->uuconf_csuccess_wait); - - if (qsys->uuconf_fsequence) - printf (" Sequence numbers are used\n"); - - if (fcalled) - ukshow_chat (&qsys->uuconf_scalled_chat, " When called, chat"); - - if (qsys->uuconf_zdebug != NULL) - printf (" Debugging level %s\n", qsys->uuconf_zdebug); - if (qsys->uuconf_zmax_remote_debug != NULL) - printf (" Max remote debugging level %s\n", - qsys->uuconf_zmax_remote_debug); - - if (fcall) - { - ukshow_size (qsys->uuconf_qcall_local_size, TRUE, TRUE); - ukshow_size (qsys->uuconf_qcall_remote_size, TRUE, FALSE); - } - if (fcalled) - { - ukshow_size (qsys->uuconf_qcalled_local_size, FALSE, TRUE); - ukshow_size (qsys->uuconf_qcalled_remote_size, FALSE, FALSE); - } - - if (fcall) - printf (" May %smake local requests when calling\n", - qsys->uuconf_fcall_transfer ? "" : "not "); - - if (fcalled) - printf (" May %smake local requests when called\n", - qsys->uuconf_fcalled_transfer ? "" : "not "); - - if (qsys->uuconf_fcall_transfer || qsys->uuconf_fcalled_transfer) - { - printf (" May send by local request:"); - for (pz = qsys->uuconf_pzlocal_send; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - if (! qsys->uuconf_fsend_request) - printf (" May not send files by remote request\n"); - else - { - printf (" May send by remote request:"); - for (pz = qsys->uuconf_pzremote_send; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - if (qsys->uuconf_fcall_transfer || qsys->uuconf_fcalled_transfer) - { - printf (" May accept by local request:"); - for (pz = qsys->uuconf_pzlocal_receive; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - if (! qsys->uuconf_frec_request) - printf (" May not receive files by remote request\n"); - else - { - printf (" May receive by remote request:"); - for (pz = qsys->uuconf_pzremote_receive; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - - printf (" May execute"); - for (pz = qsys->uuconf_pzcmds; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - - printf (" Execution path"); - for (pz = qsys->uuconf_pzpath; *pz != NULL; pz++) - printf (" %s" , *pz); - printf ("\n"); - - if (qsys->uuconf_cfree_space != 0) - printf (" Will leave %ld bytes available\n", qsys->uuconf_cfree_space); - - if (qsys->uuconf_zpubdir != NULL) - printf (" Public directory is %s\n", qsys->uuconf_zpubdir); - - if (qsys->uuconf_pzforward_from != NULL) - { - printf (" May forward from"); - for (pz = qsys->uuconf_pzforward_from; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - - if (qsys->uuconf_pzforward_to != NULL) - { - printf (" May forward to"); - for (pz = qsys->uuconf_pzforward_to; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - - if (qsys->uuconf_zprotocols != NULL) - printf (" Will use protocols %s\n", qsys->uuconf_zprotocols); - else - printf (" Will use any known protocol\n"); - - if (qsys->uuconf_qproto_params != NULL) - ukshow_proto_params (qsys->uuconf_qproto_params, 1); - } - - if (! fanycall) - printf (" Calls will never be placed to this system\n"); -} - -/* Show information about a port. */ - -/*ARGSUSED*/ -static int -ikshow_port (qport, pinfo) - struct uuconf_port *qport; - pointer 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; - - printf (" Port name %s\n", qport->uuconf_zname); - switch (qport->uuconf_ttype) - { - case UUCONF_PORTTYPE_STDIN: - printf (" Port type stdin\n"); - break; - case UUCONF_PORTTYPE_DIRECT: - printf (" Port type direct\n"); - 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); - if (qmodem->uuconf_ilowbaud != qmodem->uuconf_ihighbaud) - printf (" Speed range %ld to %ld\n", qmodem->uuconf_ilowbaud, - 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"); - ukshow_dialer (qmodem->uuconf_qdialer); - } - else if (qmodem->uuconf_pzdialer != NULL - && qmodem->uuconf_pzdialer[0] != NULL) - { - struct uuconf_dialer sdial; - int iret; - - /* This might be a single dialer name, or it might be a - sequence of dialer/token pairs. */ - - if (qmodem->uuconf_pzdialer[1] == NULL - || qmodem->uuconf_pzdialer[2] == NULL) - { - iret = uuconf_dialer_info (qi->puuconf, - qmodem->uuconf_pzdialer[0], - &sdial); - if (iret == UUCONF_NOT_FOUND) - printf (" *** No dialer %s\n", qmodem->uuconf_pzdialer[0]); - else if (iret != UUCONF_SUCCESS) - ukuuconf_error (qi->puuconf, iret); - else - { - printf (" Dialer %s\n", qmodem->uuconf_pzdialer[0]); - ukshow_dialer (&sdial); - if (qmodem->uuconf_pzdialer[1] != NULL) - printf (" Token %s\n", qmodem->uuconf_pzdialer[1]); - } - } - else - { - pz = qmodem->uuconf_pzdialer; - while (*pz != NULL) - { - iret = uuconf_dialer_info (qi->puuconf, *pz, &sdial); - if (iret == UUCONF_NOT_FOUND) - printf (" *** No dialer %s\n", *pz); - else if (iret != UUCONF_SUCCESS) - ukuuconf_error (qi->puuconf, iret); - else - { - printf (" Dialer %s\n", *pz); - ukshow_dialer (&sdial); - } - - ++pz; - if (*pz != NULL) - { - printf (" Token %s\n", *pz); - ++pz; - } - } - } - } - else - 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", 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; - printf (" Port type TLI%s\n", - 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"); - for (pz = qtli->uuconf_pzpush; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - if (qtli->uuconf_pzdialer != NULL - && qtli->uuconf_pzdialer[0] != NULL) - { - printf (" Dialer sequence"); - for (pz = qtli->uuconf_pzdialer; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - 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; - } - - if (qport->uuconf_zprotocols != NULL) - printf (" Will use protocols %s\n", qport->uuconf_zprotocols); - - 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); - - /* Return NOT_FOUND to force find_port to continue searching. */ - return UUCONF_NOT_FOUND; -} - -/* Show information about a dialer. */ - -static void -ukshow_dialer (q) - struct uuconf_dialer *q; -{ - ukshow_chat (&q->uuconf_schat, " Chat"); - printf (" Wait for dialtone %s\n", q->uuconf_zdialtone); - printf (" Pause while dialing %s\n", q->uuconf_zpause); - printf (" Carrier %savailable\n", q->uuconf_fcarrier ? "" : "not "); - if (q->uuconf_fcarrier) - printf (" Wait %d seconds for carrier\n", q->uuconf_ccarrier_wait); - if (q->uuconf_fdtr_toggle) - { - printf (" Toggle DTR"); - if (q->uuconf_fdtr_toggle_wait) - printf (" and wait"); - printf ("\n"); - } - 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); -} - -/* Show a chat script. */ - -static void -ukshow_chat (qchat, zhdr) - const struct uuconf_chat *qchat; - const char *zhdr; -{ - char **pz; - - if (qchat->uuconf_pzprogram != NULL) - { - printf ("%s program", zhdr); - for (pz = qchat->uuconf_pzprogram; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - - if (qchat->uuconf_pzchat != NULL) - { - - printf ("%s script", zhdr); - for (pz = qchat->uuconf_pzchat; *pz != NULL; pz++) - { - if ((*pz)[0] != '-' || pz == qchat->uuconf_pzchat) - printf (" "); - printf ("%s", *pz); - } - printf ("\n"); - printf ("%s script timeout %d\n", zhdr, qchat->uuconf_ctimeout); - if (qchat->uuconf_pzfail != NULL) - { - printf ("%s failure strings", zhdr); - for (pz = qchat->uuconf_pzfail; *pz != NULL; pz++) - printf (" %s", *pz); - printf ("\n"); - } - if (qchat->uuconf_fstrip) - printf ("%s script incoming bytes stripped to seven bits\n", zhdr); - } -} - -/* Show a size/time restriction. */ - -static void -ukshow_size (qspan, fcall, flocal) - struct uuconf_timespan *qspan; - boolean fcall; - boolean flocal; -{ - struct uuconf_timespan *q; - boolean fother; - - qspan = qcompress_span (qspan); - if (qspan == NULL) - return; - - printf (" If call%s the following applies to a %s request:\n", - fcall ? "ing" : "ed", flocal ? "local" : "remote"); - - fother = FALSE; - if (qspan->uuconf_istart >= 60) - fother = TRUE; - - for (q = qspan; q != NULL; q = q->uuconf_qnext) - { - printf (" "); - ukshow_time (q); - printf (" may transfer files %ld bytes or smaller\n", q->uuconf_ival); - if (q->uuconf_qnext == NULL) - { - if (q->uuconf_iend <= 6 * 24 * 60 + 23 * 60) - fother = TRUE; - } - else - { - if (q->uuconf_iend + 60 <= q->uuconf_qnext->uuconf_istart) - fother = TRUE; - } - } - - if (fother) - 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 -ukshow_proto_params (pas, cindent) - struct uuconf_proto_param *pas; - int cindent; -{ - struct uuconf_proto_param *q; - - for (q = pas; q->uuconf_bproto != '\0'; q++) - { - int i; - struct uuconf_proto_param_entry *qe; - - for (i = 0; i < cindent; i++) - printf (" "); - printf ("For protocol %c will use the following parameters\n", - q->uuconf_bproto); - for (qe = q->uuconf_qentries; qe->uuconf_cargs > 0; qe++) - { - int ia; - - for (i = 0; i < cindent; i++) - printf (" "); - for (ia = 0; ia < qe->uuconf_cargs; ia++) - printf (" %s", qe->uuconf_pzargs[ia]); - printf ("\n"); - } - } -} - -/* Display a time span. */ - -static void -ukshow_time (q) - const struct uuconf_timespan *q; -{ - int idaystart, idayend; - int ihourstart, ihourend; - int iminutestart, iminuteend; - const char * const zdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat\0Sun"; - - if (q->uuconf_istart == 0 && q->uuconf_iend == 7 * 24 * 60) - { - printf ("At any time"); - return; - } - - idaystart = q->uuconf_istart / (24 * 60); - ihourstart = (q->uuconf_istart % (24 * 60)) / 60; - iminutestart = q->uuconf_istart % 60; - idayend = q->uuconf_iend / (24 * 60); - ihourend = (q->uuconf_iend % (24 * 60)) / 60; - iminuteend = q->uuconf_iend % 60; - - if (idaystart == idayend) - printf ("%s from %02d:%02d to %02d:%02d", zdays + idaystart * 4, - ihourstart, iminutestart, ihourend, iminuteend); - else - printf ("From %s %02d:%02d to %s %02d:%02d", - zdays + idaystart * 4, ihourstart, iminutestart, - zdays + idayend * 4, ihourend, iminuteend); -} - -/* Compress a time span by merging any two adjacent spans with - identical values. This isn't necessary for uucico, but it looks - nicer when printed out. */ - -static struct uuconf_timespan * -qcompress_span (qlist) - struct uuconf_timespan *qlist; -{ - struct uuconf_timespan **pq; - - pq = &qlist; - while (*pq != NULL) - { - if ((*pq)->uuconf_qnext != NULL - && (*pq)->uuconf_iend == (*pq)->uuconf_qnext->uuconf_istart - && (*pq)->uuconf_ival == (*pq)->uuconf_qnext->uuconf_ival) - { - struct uuconf_timespan *qnext; - - qnext = (*pq)->uuconf_qnext; - (*pq)->uuconf_qnext = qnext->uuconf_qnext; - (*pq)->uuconf_iend = qnext->uuconf_iend; - } - else - pq = &(*pq)->uuconf_qnext; - } - - return qlist; -} - -/* Display a uuconf error and exit. */ - -static void -ukuuconf_error (puuconf, iret) - pointer puuconf; - int iret; -{ - char ab[512]; - - (void) uuconf_error_string (puuconf, iret, ab, sizeof ab); - if ((iret & UUCONF_ERROR_FILENAME) == 0) - fprintf (stderr, "%s: %s\n", zKprogram, ab); - else - fprintf (stderr, "%s:%s\n", zKprogram, ab); - exit (EXIT_FAILURE); -} diff --git a/gnu/libexec/uucp/uucico/Makefile b/gnu/libexec/uucp/uucico/Makefile deleted file mode 100644 index 1f91c87..0000000 --- a/gnu/libexec/uucp/uucico/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for uucico -# $FreeBSD$ - -BINDIR= $(libxdir) -BINOWN= $(owner) -BINGRP= dialer -BINMODE= 6555 - -PROG= uucico -SRCS= uucico.c trans.c send.c rec.c xcmd.c prot.c protg.c protf.c \ - prott.c prote.c proti.c protj.c proty.c protz.c time.c log.c \ - chat.c conn.c util.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" -DOWNER=\"$(owner)\" - -MAN= uucico.8 - -.include <bsd.prog.mk> -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uucico/prote.c b/gnu/libexec/uucp/uucico/prote.c deleted file mode 100644 index 6f70324..0000000 --- a/gnu/libexec/uucp/uucico/prote.c +++ /dev/null @@ -1,397 +0,0 @@ -/* prote.c - The 'e' protocol. - - Copyright (C) 1991, 1992, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char prote_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* This implementation is based on my implementation of the 't' - protocol, which is fairly similar. The main difference between the - protocols seems to be that 't' breaks the file into packets and - transmits the size of the packet with each packet, whereas 'e' - sends the size of the entire file and then sends all the data in a - single enormous packet. - - The 'e' protocol does no error checking whatsoever and thus - requires an end-to-end verified eight bit communication line, such - as is provided by TCP. Using it with a modem is inadvisable, since - errors can occur between the modem and the computer. */ - -/* The buffer size we use. */ -#define CEBUFSIZE (CRECBUFLEN / 2) - -/* The size of the initial file size message. */ -#define CEFRAMELEN (20) - -/* A pointer to the buffer we will use. */ -static char *zEbuf; - -/* True if we are receiving a file. */ -static boolean fEfile; - -/* The number of bytes we have left to send or receive. */ -static long cEbytes; - -/* The timeout we use. */ -static int cEtimeout = 120; - -struct uuconf_cmdtab asEproto_params[] = -{ - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cEtimeout, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local function. */ - -static boolean feprocess_data P((struct sdaemon *qdaemon, boolean *pfexit, - size_t *pcneed)); - -/* Start the protocol. */ - -boolean -festart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - *pzlog = NULL; - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_OFF)) - return FALSE; - zEbuf = (char *) xmalloc (CEBUFSIZE); - fEfile = FALSE; - usysdep_sleep (2); - return TRUE; -} - -/* Stop the protocol. */ - -/*ARGSUSED*/ -boolean -feshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - xfree ((pointer) zEbuf); - zEbuf = NULL; - cEtimeout = 120; - return TRUE; -} - -/* Send a command string. We send everything up to and including the - null byte. */ - -/*ARGSUSED*/ -boolean -fesendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fesendcmd: Sending command \"%s\"", z); - - return fsend_data (qdaemon->qconn, z, strlen (z) + 1, TRUE); -} - -/* Get space to be filled with data. We provide a buffer which has - 20 bytes at the start available to hold the length. */ - -/*ARGSUSED*/ -char * -zegetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = CEBUFSIZE; - return zEbuf; -} - -/* Send out some data. We are allowed to modify the 20 bytes - preceding the buffer. This allows us to send the entire block with - header bytes in a single call. */ - -/*ARGSIGNORED*/ -boolean -fesenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ -#if DEBUG > 0 - /* Keep track of the number of bytes we send out to make sure it all - adds up. */ - cEbytes -= cdata; - if (cEbytes < 0) - { - ulog (LOG_ERROR, "Protocol 'e' internal error"); - return FALSE; - } -#endif - - /* We pass FALSE to fsend_data since we don't expect the other side - to be sending us anything just now. */ - return fsend_data (qdaemon->qconn, zdata, cdata, FALSE); -} - -/* Process data and return the amount we need in *pfneed. */ - -static boolean -feprocess_data (qdaemon, pfexit, pcneed) - struct sdaemon *qdaemon; - boolean *pfexit; - size_t *pcneed; -{ - int cinbuf, cfirst, clen; - - *pfexit = FALSE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (! fEfile) - { - /* We are not receiving a file. Commands continue up to a null - byte. */ - while (cinbuf > 0) - { - char *pnull; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > cinbuf) - cfirst = cinbuf; - - pnull = memchr (abPrecbuf + iPrecstart, '\0', (size_t) cfirst); - if (pnull != NULL) - cfirst = pnull - (abPrecbuf + iPrecstart) + 1; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "feprocess_data: Got %d command bytes", - cfirst); - - if (! fgot_data (qdaemon, abPrecbuf + iPrecstart, - (size_t) cfirst, (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - } - - if (pcneed != NULL) - *pcneed = 1; - - return TRUE; - } - - /* Here we are receiving a file. We want cEbytes in total. If we - don't have cEbytes yet, we have to get it first. */ - - if (cEbytes == -1) - { - char ab[CEFRAMELEN + 1]; - - if (cinbuf < CEFRAMELEN) - { - if (pcneed != NULL) - *pcneed = CEFRAMELEN - cinbuf; - return TRUE; - } - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst >= CEFRAMELEN) - memcpy (ab, abPrecbuf + iPrecstart, (size_t) CEFRAMELEN); - else - { - memcpy (ab, abPrecbuf + iPrecstart, (size_t) cfirst); - memcpy (ab + cfirst, abPrecbuf, (size_t) CEFRAMELEN - cfirst); - } - - ab[CEFRAMELEN] = '\0'; - cEbytes = strtol (ab, (char **) NULL, 10); - - iPrecstart = (iPrecstart + CEFRAMELEN) % CRECBUFLEN; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (cEbytes == 0) - { - if (! fgot_data (qdaemon, abPrecbuf, (size_t) 0, - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - if (*pfexit) - return TRUE; - } - } - - /* Here we can read real data for the file. */ - - while (cinbuf > 0) - { - clen = cinbuf; - if ((long) clen > cEbytes) - clen = (int) cEbytes; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > clen) - cfirst = clen; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "feprocess_data: Got %d data bytes", - clen); - - if (! fgot_data (qdaemon, abPrecbuf + iPrecstart, - (size_t) cfirst, abPrecbuf, (size_t) (clen - cfirst), - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - cEbytes -= clen; - - if (cEbytes == 0) - { - if (! fgot_data (qdaemon, abPrecbuf, (size_t) 0, - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - if (*pfexit) - return TRUE; - } - - cinbuf -= clen; - } - - if (pcneed != NULL) - { - if (cEbytes > CRECBUFLEN / 2) - *pcneed = CRECBUFLEN / 2; - else - *pcneed = (int) cEbytes; - } - - return TRUE; -} - -/* Wait for data to come in and process it until we've reached the end - of a command or a file. */ - -boolean -fewait (qdaemon) - struct sdaemon *qdaemon; -{ - while (TRUE) - { - boolean fexit; - size_t cneed, crec; - - if (! feprocess_data (qdaemon, &fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - if (! freceive_data (qdaemon->qconn, cneed, &crec, cEtimeout, TRUE)) - return FALSE; - - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } -} - -/* File level routine, to handle transferring the amount of data and - to set fEfile correctly. */ - -boolean -fefile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled) - struct sdaemon *qdaemon; - struct stransfer *qtrans; - boolean fstart; - boolean fsend; - long cbytes; - boolean *pfhandled; -{ - *pfhandled = FALSE; - - if (fstart) - { - if (fsend) - { - char ab[CEFRAMELEN]; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "Protocol 'e' starting to send %ld bytes", - cbytes); - - bzero (ab, (size_t) CEFRAMELEN); - sprintf (ab, "%ld", cbytes); - if (! fsend_data (qdaemon->qconn, ab, (size_t) CEFRAMELEN, TRUE)) - return FALSE; - cEbytes = cbytes; - } - else - { - cEbytes = -1; - fEfile = TRUE; - } - } - else - { - if (! fsend) - fEfile = FALSE; -#if DEBUG > 0 - if (cEbytes != 0) - { - ulog (LOG_ERROR, - "Protocol 'e' internal error: %ld bytes left over", - cEbytes); - return FALSE; - } -#endif - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/uucico/protf.c b/gnu/libexec/uucp/uucico/protf.c deleted file mode 100644 index 4436a12..0000000 --- a/gnu/libexec/uucp/uucico/protf.c +++ /dev/null @@ -1,848 +0,0 @@ -/* protf.c - The 'f' protocol. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char protf_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* This implementation is based on code by Piet Beertema, CWI, - Amsterdam, Sep 1984. - - This code implements the 'f' protocol, which requires a - flow-controlled error-free seven-bit data path. It does check for - errors, but only at the end of each file transmission, so a noisy - line without error correcting modems will be unusable. - - The conversion to seven bit data is done as follows, where b - represents the character to convert: - - 0 <= b <= 037: 0172, b + 0100 (0100 to 0137) - 040 <= b <= 0171: b ( 040 to 0171) - 0172 <= b <= 0177: 0173, b - 0100 ( 072 to 077) - 0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137) - 0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171) - 0372 <= b <= 0377: 0176, b - 0300 ( 072 to 077) - - This causes all output bytes to be in the range 040 to 0176; these - are the printable ASCII characters. */ - -/* This structure is used to hold information when dealing with the - end of file acknowledgement. */ - -struct sfinfo -{ - /* The functions from the generic code. */ - boolean (*psendfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon)); - boolean (*precfn) P((struct stransfer *qtrans, struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); - /* The info pointer from the generic code. */ - pointer pinfo; - /* The character to send after receiving the checksum. */ - char bsend; -}; - -/* Internal functions. */ -static boolean ffprocess_data P((struct sdaemon *qdaemon, - boolean *pfexit, size_t *pcneed)); -static boolean ffawait_ack P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean ffawait_cksum P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean ffsend_ack P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); - -/* The size of the buffer we allocate to store outgoing data in. */ -#define CFBUFSIZE (256) - -/* The timeout to wait for data to arrive before giving up. */ -static int cFtimeout = 120; - -/* The maximum number of retries. */ -static int cFmaxretries = 2; - -/* The buffer we allocate for outgoing data. */ -static char *zFbuf; - -/* TRUE if we are receiving a file rather than a command. */ -static boolean fFfile; - -/* The checksum so far. */ -static unsigned int iFcheck; - -/* The last special byte (0172 to 0176) or 0 if none. */ -static char bFspecial; - -/* The number of times we have retried this file. */ -static int cFretries; - -/* Whether this file has been acknowledged. */ -static boolean fFacked; - -struct uuconf_cmdtab asFproto_params[] = -{ - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cFtimeout, NULL }, - { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cFmaxretries, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Statistics. */ - -/* The number of data bytes sent in files. */ -static long cFsent_data; - -/* The number of actual bytes sent in files. */ -static long cFsent_bytes; - -/* The number of data bytes received in files. */ -static long cFrec_data; - -/* The number of actual bytes received in files. */ -static long cFrec_bytes; - -/* The number of file retries when sending. */ -static long cFsend_retries; - -/* The number of file retries when receiving. */ -static long cFrec_retries; - -/* Start the protocol. */ - -boolean -ffstart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - *pzlog = NULL; - - cFsent_data = 0; - cFsent_bytes = 0; - cFrec_data = 0; - cFrec_bytes = 0; - cFsend_retries = 0; - cFrec_retries = 0; - - /* Use XON/XOFF handshaking. */ - if (! fconn_set (qdaemon->qconn, PARITYSETTING_DEFAULT, - STRIPSETTING_SEVENBITS, XONXOFF_ON)) - return FALSE; - - /* We sleep to allow the other side to reset the terminal; this is - what Mr. Beertema's code does. */ - usysdep_sleep (2); - - return TRUE; -} - -/* Shutdown the protocol. */ - -/*ARGSIGNORED*/ -boolean -ffshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - xfree ((pointer) zFbuf); - zFbuf = NULL; - ulog (LOG_NORMAL, - "Protocol 'f': sent %ld bytes for %ld, received %ld bytes for %ld", - cFsent_bytes, cFsent_data, cFrec_bytes, cFrec_data); - if (cFsend_retries != 0 || cFrec_retries != 0) - ulog (LOG_NORMAL, "Protocol 'f' file retries: %ld sending, %ld receiving", - cFsend_retries, cFrec_retries); - cFtimeout = 120; - cFmaxretries = 2; - return TRUE; -} - -/* Send a command string. We just send the string followed by a carriage - return. */ - -/*ARGSUSED*/ -boolean -ffsendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - size_t clen; - char *zalc; - boolean fret; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ffsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - zalc = zbufalc (clen + 2); - memcpy (zalc, z, clen); - zalc[clen] = '\r'; - zalc[clen + 1] = '\0'; - fret = fsend_data (qdaemon->qconn, zalc, clen + 1, TRUE); - ubuffree (zalc); - return fret; -} - -/* Get space to be filled with data. We allocate the space from the - heap. */ - -/*ARGSIGNORED*/ -char * -zfgetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = CFBUFSIZE; - if (zFbuf == NULL) - zFbuf = (char *) xmalloc (CFBUFSIZE); - return zFbuf; -} - -/* Send out a data packet. We have to encode the data into seven bits - and accumulate a checksum. */ - -/*ARGSIGNORED*/ -boolean -ffsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ - char ab[CFBUFSIZE * 2]; - char *ze; - register unsigned int itmpchk; - - cFsent_data += cdata; - - ze = ab; - itmpchk = iFcheck; - while (cdata-- > 0) - { - register int b; - - /* Rotate the checksum left. */ - if ((itmpchk & 0x8000) == 0) - itmpchk <<= 1; - else - { - itmpchk <<= 1; - ++itmpchk; - } - - /* Add the next byte into the checksum. */ - b = *zdata++ & 0xff; - itmpchk += b; - - /* Encode the byte. */ - if (b <= 0177) - { - if (b <= 037) - { - *ze++ = '\172'; - *ze++ = (char) (b + 0100); - } - else if (b <= 0171) - *ze++ = (char) b; - else - { - *ze++ = '\173'; - *ze++ = (char) (b - 0100); - } - } - else - { - if (b <= 0237) - { - *ze++ = '\174'; - *ze++ = (char) (b - 0100); - } - else if (b <= 0371) - { - *ze++ = '\175'; - *ze++ = (char) (b - 0200); - } - else - { - *ze++ = '\176'; - *ze++ = (char) (b - 0300); - } - } - } - - iFcheck = itmpchk; - - cFsent_bytes += ze - ab; - - /* Passing FALSE tells fsend_data not to bother looking for incoming - information, since we really don't expect any. */ - return fsend_data (qdaemon->qconn, ab, (size_t) (ze - ab), FALSE); -} - -/* Process data and return the amount of data we are looking for in - *pcneed. The 'f' protocol doesn't really reveal this, but when - transferring file we know that we need at least seven characters - for the checksum. */ - -static boolean -ffprocess_data (qdaemon, pfexit, pcneed) - struct sdaemon *qdaemon; - boolean *pfexit; - size_t *pcneed; -{ - int i; - register unsigned int itmpchk; - - *pfexit = FALSE; - if (pcneed != NULL) - *pcneed = 1; - - if (! fFfile) - { - /* A command continues until a '\r' character, which we turn - into '\0' before calling fgot_data. */ - while (iPrecstart != iPrecend) - { - 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; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ffprocess_data: Got %d command bytes", - i - iPrecstart + 1); - - abPrecbuf[i] = '\0'; - istart = iPrecstart; - iPrecstart = (i + 1) % CRECBUFLEN; - if (pcneed != NULL) - *pcneed = 0; - return fgot_data (qdaemon, abPrecbuf + istart, - (size_t) (i - istart + 1), - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit); - } - } - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ffprocess_data: Got %d command bytes", - i - iPrecstart); - - if (! fgot_data (qdaemon, abPrecbuf + iPrecstart, - (size_t) (i - iPrecstart), - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = i % CRECBUFLEN; - } - - return TRUE; - } - - /* Here the data is destined for a file, and we must decode it. */ - - itmpchk = iFcheck; - - while (iPrecstart != iPrecend) - { - char *zstart, *zto, *zfrom; - int c; - - zto = zfrom = zstart = abPrecbuf + iPrecstart; - - c = iPrecend - iPrecstart; - if (c < 0) - c = CRECBUFLEN - iPrecstart; - - while (c-- != 0) - { - int b; - - /* 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); - continue; - } - - /* Characters >= 0172 are always special characters. The - only legal pair of consecutive special characters - are 0176 0176 which immediately precede the four - digit checksum. */ - if (b >= 0172) - { - if (bFspecial != 0) - { - if (bFspecial != 0176 || b != 0176) - { - ulog (LOG_ERROR, "Illegal bytes %d %d", - bFspecial, b); - bFspecial = 0; - continue; - } - - /* Pass any initial data. */ - if (zto != zstart) - { - /* Don't count the checksum in the received bytes. */ - cFrec_bytes += zfrom - zstart - 2; - cFrec_data += zto - zstart; - if (! fgot_data (qdaemon, zstart, - (size_t) (zto - zstart), - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - } - - /* The next characters we want to read are the - checksum, so skip the second 0176. */ - iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN; - - iFcheck = itmpchk; - - /* Tell fgot_data that we've read the entire file by - passing 0 length data. This will wind up calling - fffile to verify the checksum. We set *pcneed to - 0 because we don't want to read any more data - from the port, since we may have already read the - checksum. */ - if (pcneed != NULL) - *pcneed = 0; - return fgot_data (qdaemon, (const char *) NULL, - (size_t) 0, (const char *) NULL, - (size_t) 0, -1, -1, (long) -1, - TRUE, pfexit); - } - - /* Here we have encountered a special character that - does not follow another special character. */ - bFspecial = (char) b; - } - else - { - int bnext; - - /* Here we have encountered a nonspecial character. */ - - switch (bFspecial) - { - default: - bnext = b; - break; - case 0172: - bnext = b - 0100; - break; - case 0173: - case 0174: - bnext = b + 0100; - break; - case 0175: - bnext = b + 0200; - break; - case 0176: - bnext = b + 0300; - break; - } - - *zto++ = (char) bnext; - bFspecial = 0; - - /* Rotate the checksum left. */ - if ((itmpchk & 0x8000) == 0) - itmpchk <<= 1; - else - { - itmpchk <<= 1; - ++itmpchk; - } - - /* Add the next byte into the checksum. */ - itmpchk += bnext; - } - } - - if (zto != zstart) - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ffprocess_data: Got %d bytes", - zto - zstart); - - cFrec_data += zto - zstart; - if (! fgot_data (qdaemon, zstart, (size_t) (zto - zstart), - (const char *) NULL, (size_t) 0, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - } - - cFrec_bytes += zfrom - zstart; - - iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN; - } - - iFcheck = itmpchk; - - if (pcneed != NULL) - { - /* At this point we may have seen the first 0176 in the checksum - but not the second. The checksum is at least seven - characters long (0176 0176 a b c d \r). This won't help - much, but reading seven characters is a lot better than - reading two, which is what I saw in a 2400 baud log file. */ - if (bFspecial == 0176) - *pcneed = 6; - else - *pcneed = 7; - } - - return TRUE; -} - -/* Wait for data to come in and process it until we've finished a - command or a file. */ - -boolean -ffwait (qdaemon) - struct sdaemon *qdaemon; -{ - while (TRUE) - { - boolean fexit; - size_t cneed, crec; - - if (! ffprocess_data (qdaemon, &fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - if (cneed > 0) - { - /* We really want to do something like get all available - characters, then sleep for half a second and get all - available characters again, and keep this up until we - don't get anything after sleeping. */ - if (! freceive_data (qdaemon->qconn, cneed, &crec, cFtimeout, TRUE)) - return FALSE; - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } - } -} - -/* File level operations. Reset the checksums when starting to send - or receive a file, and output the checksum when we've finished - sending a file. */ - -/*ARGSUSED*/ -boolean -fffile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled) - struct sdaemon *qdaemon; - struct stransfer *qtrans; - boolean fstart; - boolean fsend; - long cbytes; - boolean *pfhandled; -{ - DEBUG_MESSAGE3 (DEBUG_PROTO, "fffile: fstart %s; fsend %s; fFacked %s", - fstart ? "true" : "false", fsend ? "true" : "false", - fFacked ? "true" : "false"); - - *pfhandled = FALSE; - - if (fstart) - { - iFcheck = 0xffff; - cFretries = 0; - fFacked = FALSE; - if (! fsend) - { - bFspecial = 0; - fFfile = TRUE; - } - return TRUE; - } - else - { - struct sfinfo *qinfo; - - /* We need to handle the checksum and the acknowledgement. If - we get a successful ACK, we set fFacked to TRUE and call the - send or receive function by hand. This will wind up calling - here again, so if fFacked is TRUE we just return out and let - the send or receive function do whatever it does. This is a - bit of a hack. */ - if (fFacked) - { - fFacked = FALSE; - return TRUE; - } - - if (fsend) - { - char ab[sizeof "\176\176ABCD\r"]; - - /* Send the final checksum. */ - sprintf (ab, "\176\176%04x\r", iFcheck & 0xffff); - if (! fsend_data (qdaemon->qconn, ab, (size_t) 7, TRUE)) - return FALSE; - - /* Now wait for the acknowledgement. */ - fFfile = FALSE; - qinfo = (struct sfinfo *) xmalloc (sizeof (struct sfinfo)); - qinfo->psendfn = qtrans->psendfn; - qinfo->precfn = qtrans->precfn; - qinfo->pinfo = qtrans->pinfo; - qtrans->psendfn = NULL; - qtrans->precfn = ffawait_ack; - qtrans->pinfo = (pointer) qinfo; - qtrans->fcmd = TRUE; - - *pfhandled = TRUE; - - return fqueue_receive (qdaemon, qtrans); - } - else - { - /* Wait for the checksum. */ - fFfile = FALSE; - qinfo = (struct sfinfo *) xmalloc (sizeof (struct sfinfo)); - qinfo->psendfn = qtrans->psendfn; - qinfo->precfn = qtrans->precfn; - qinfo->pinfo = qtrans->pinfo; - qtrans->psendfn = NULL; - qtrans->precfn = ffawait_cksum; - qtrans->pinfo = (pointer) qinfo; - qtrans->fcmd = TRUE; - - *pfhandled = TRUE; - - return fqueue_receive (qdaemon, qtrans); - } - } -} - -/* Wait for the ack after sending a file and the checksum. */ - -static boolean -ffawait_ack (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo; - - qtrans->precfn = NULL; - - /* An R means to retry sending the file. */ - if (*zdata == 'R') - { - if (! ffileisopen (qtrans->e)) - { - ulog (LOG_ERROR, "Request to resent non-file"); - return FALSE; - } - - ++cFretries; - if (cFretries > cFmaxretries) - { - ulog (LOG_ERROR, "Too many retries"); - return FALSE; - } - - ulog (LOG_NORMAL, "Resending file"); - if (! ffilerewind (qtrans->e)) - { - ulog (LOG_ERROR, "rewind: %s", strerror (errno)); - return FALSE; - } - qtrans->ipos = (long) 0; - - iFcheck = 0xffff; - ++cFsend_retries; - - qtrans->psendfn = qinfo->psendfn; - qtrans->precfn = qinfo->precfn; - qtrans->pinfo = qinfo->pinfo; - xfree ((pointer) qinfo); - qtrans->fsendfile = TRUE; - - return fqueue_send (qdaemon, qtrans); - } - - if (*zdata != 'G') - { - DEBUG_MESSAGE1 (DEBUG_PROTO, "fffile: Got \"%s\"", zdata); - ulog (LOG_ERROR, "File send failed"); - return FALSE; - } - - qtrans->psendfn = qinfo->psendfn; - qtrans->precfn = qinfo->precfn; - qtrans->pinfo = qinfo->pinfo; - xfree ((pointer) qinfo); - - /* Now call the send function by hand after setting fFacked to TRUE. - Since fFacked is true fffile will simply return out, and the send - function can do whatever it what was going to do. */ - fFacked = TRUE; - return (*qtrans->psendfn) (qtrans, qdaemon); -} - -/* This function is called when the checksum arrives. */ - -/*ARGSUSED*/ -static boolean -ffawait_cksum (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo; - unsigned int icheck; - - qtrans->precfn = NULL; - - if (! isxdigit (zdata[0]) - || ! isxdigit (zdata[1]) - || ! isxdigit (zdata[2]) - || ! isxdigit (zdata[3]) - || zdata[4] != '\0') - { - ulog (LOG_ERROR, "Bad checksum format"); - xfree (qtrans->pinfo); - return FALSE; - } - - icheck = (unsigned int) strtol ((char *) zdata, (char **) NULL, 16); - - if (icheck != (iFcheck & 0xffff)) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "Checksum failed; calculated 0x%x, got 0x%x", - iFcheck & 0xffff, icheck); - - if (! ffileisopen (qtrans->e)) - { - ulog (LOG_ERROR, "Failed to get non-file"); - return FALSE; - } - - ++cFretries; - if (cFretries > cFmaxretries) - { - ulog (LOG_ERROR, "Too many retries"); - qinfo->bsend = 'Q'; - } - else - { - ulog (LOG_NORMAL, "File being resent"); - - /* This bit of code relies on the receive code setting - qtrans->s.ztemp to the full name of the temporary file - being used. */ - qtrans->e = esysdep_truncate (qtrans->e, qtrans->s.ztemp); - if (! ffileisopen (qtrans->e)) - return FALSE; - qtrans->ipos = (long) 0; - - iFcheck = 0xffff; - bFspecial = 0; - fFfile = TRUE; - ++cFrec_retries; - - /* Send an R to tell the other side to resend the file. */ - qinfo->bsend = 'R'; - } - } - else - { - /* Send a G to tell the other side the file was received - correctly. */ - qinfo->bsend = 'G'; - } - - qtrans->psendfn = ffsend_ack; - - return fqueue_send (qdaemon, qtrans); -} - -/* Send the acknowledgement, and then possible wait for the resent - file. */ - -static boolean -ffsend_ack (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct sfinfo *qinfo = (struct sfinfo *) qtrans->pinfo; - char ab[2]; - - ab[0] = qinfo->bsend; - ab[1] = '\0'; - if (! ffsendcmd (qdaemon, ab, 0, 0)) - return FALSE; - - qtrans->psendfn = qinfo->psendfn; - qtrans->precfn = qinfo->precfn; - qtrans->pinfo = qinfo->pinfo; - xfree ((pointer) qinfo); - - if (ab[0] == 'Q') - return FALSE; - if (ab[0] == 'R') - { - qtrans->frecfile = TRUE; - return fqueue_receive (qdaemon, qtrans); - } - - fFacked = TRUE; - return (*qtrans->precfn) (qtrans, qdaemon, (const char *) NULL, - (size_t) 0); -} diff --git a/gnu/libexec/uucp/uucico/protg.c b/gnu/libexec/uucp/uucico/protg.c deleted file mode 100644 index ea58917..0000000 --- a/gnu/libexec/uucp/uucico/protg.c +++ /dev/null @@ -1,1978 +0,0 @@ -/* protg.c - The 'g' protocol. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char protg_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* Each 'g' protocol packet begins with six bytes. They are: - - <DLE><k><c0><c1><C><x> - - <DLE> is the ASCII DLE character (^P or '\020'). - if 1 <= <k> <= 8, the packet is followed by 2 ** (k + 4) bytes of data; - if <k> == 9, these six bytes are a complete control packet; - other value of <k> are illegal. - <c0> is the low byte of a checksum. - <c1> is the high byte of a checksum. - <C> is a control byte (see below). - <x> is <k> ^ <c0> ^ <c1> ^ <C>. - - The control byte <C> is divided into three bitfields: - - t t x x x y y y - - The two bit field tt is the packet type. - The three bit field xxx is the control type for a control packet, or - the sequence number for a data packet. - The three bit field yyy is a value for a control packet, or the - sequence number of the last packet received for a data packet. - - For all successfully recieved packets, the control byte is stored - into iGpacket_control. */ - -/* Names for the bytes in the frame header. */ -#define IFRAME_DLE (0) -#define IFRAME_K (1) -#define IFRAME_CHECKLOW (2) -#define IFRAME_CHECKHIGH (3) -#define IFRAME_CONTROL (4) -#define IFRAME_XOR (5) - -/* Length of the frame header. */ -#define CFRAMELEN (6) - -/* Macros to break apart the control bytes. */ -#define CONTROL_TT(b) ((int)(((b) >> 6) & 03)) -#define CONTROL_XXX(b) ((int)(((b) >> 3) & 07)) -#define CONTROL_YYY(b) ((int)((b) & 07)) - -/* DLE value. */ -#define DLE ('\020') - -/* Get the length of a packet given a pointer to the header. */ -#define CPACKLEN(z) ((size_t) (1 << ((z)[IFRAME_K] + 4))) - -/* <k> field value for a control message. */ -#define KCONTROL (9) - -/* Get the next sequence number given a sequence number. */ -#define INEXTSEQ(i) ((i + 1) & 07) - -/* Compute i1 - i2 modulo 8. */ -#define CSEQDIFF(i1, i2) (((i1) + 8 - (i2)) & 07) - -/* Packet types. These are from the tt field. - CONTROL -- control packet - ALTCHAN -- alternate channel; not used by UUCP - DATA -- full data segment - SHORTDATA -- less than full data segment (all the bytes specified by - the packet length <k> are always transferred). Let <u> be the number - of bytes in the data segment not to be used. If <u> <= 0x7f, the first - byte of the data segment is <u> and the data follows. If <u> > 0x7f, - the first byte of the data segment is 0x80 | (<u> & 0x7f), the second - byte of the data segment is <u> >> 7, and the data follows. The - maximum possible data segment size is 2**12, so this handles all - possible cases. */ -#define CONTROL (0) -#define ALTCHAN (1) -#define DATA (2) -#define SHORTDATA (3) - -/* Control types. These are from the xxx field if the type (tt field) - is CONTROL. - - CLOSE -- close the connection - RJ -- reject; packet yyy last to be received correctly - SRJ -- selective reject; reject only packet yyy (not used by UUCP) - RR -- receiver ready; packet yyy received correctly - INITC -- third step of initialization; yyy holds window size - INITB -- second step of initialization; yyy holds maximum <k> value - 1 - INITA -- first step of initialization; yyy holds window size. - - The yyy value for RR is the same as the yyy value for an ordinary - data packet. */ -#define CLOSE (1) -#define RJ (2) -#define SRJ (3) -#define RR (4) -#define INITC (5) -#define INITB (6) -#define INITA (7) - -/* Maximum amount of data in a single packet. This is set by the <k> - field in the header; the amount of data in a packet is - 2 ** (<k> + 4). <k> ranges from 1 to 8. */ - -#define CMAXDATAINDEX (8) - -#define CMAXDATA (1 << (CMAXDATAINDEX + 4)) - -/* Maximum window size. */ -#define CMAXWINDOW (7) - -/* Defaults for the protocol parameters. These may all be changed by - using the ``protocol-parameter g'' command, so there is no - particular reason to change the values given here. */ - -/* The desired window size. This is what we tell the other system to - use. It must be between 1 and 7, and there's no reason to use less - than 7. Protocol parameter ``window''. */ -#define IWINDOW (7) - -/* The desired packet size. Many implementations only support 64 byte - packets. Protocol parameter ``packet-size''. */ -#define IPACKSIZE (64) - -/* The number of times to retry the exchange of INIT packets when - starting the protocol. Protocol parameter ``startup-retries''. */ -#define CSTARTUP_RETRIES (8) - -/* The timeout to use when waiting for an INIT packet when starting up - the protocol. Protocol parameter ``init-timeout''. */ -#define CEXCHANGE_INIT_TIMEOUT (10) - -/* The number of times to retry sending and waiting for a single INIT - packet when starting the protocol. This controls a single INIT - packet, while CSTARTUP_RETRIES controls how many times to try the - entire INIT sequence. Protocol parameter ``init-retries''. */ -#define CEXCHANGE_INIT_RETRIES (4) - -/* The timeout to use when waiting for a packet. Protocol parameter - ``timeout''. */ -#define CTIMEOUT (10) - -/* The number of times to retry waiting for a packet. Each time the - timeout fails we send a copy of our last data packet or a reject - message for the packet we expect from the other side, depending on - whether we are waiting for an acknowledgement or a data packet. - This is the number of times we try doing that and then waiting - again. Protocol parameter ``retries''. */ -#define CRETRIES (6) - -/* If we see more than this much unrecognized data, we drop the - connection. This must be larger than a single packet size, which - means it must be larger than 4096 (the largest possible packet - size). Protocol parameter ``garbage''. */ -#define CGARBAGE (10000) - -/* If we see more than this many protocol errors, we drop the - connection. Protocol parameter ``errors''. */ -#define CERRORS (100) - -/* Default decay rate. Each time we send or receive this many packets - succesfully, we decrement the error level by one (protocol - parameter ``error-decay''). */ -#define CERROR_DECAY (10) - -/* If this value is non-zero, it will be used as the remote window - size regardless of what the other side requested. This can be - useful for dealing with some particularly flawed packages. This - default value should always be 0, and protocol parameter - ``remote-window'' should be used for the affected systems. */ -#define IREMOTE_WINDOW (0) - -/* If this value is non-zero, it will be used as the packet size to - send to the remote system regardless of what it requested. It's - difficult to imagine any circumstances where you would want to set - this. Protocol parameter ``remote-packet-size''. */ -#define IREMOTE_PACKSIZE (0) - -/* Local variables. */ - -/* Next sequence number to send. */ -static int iGsendseq; - -/* Last sequence number that has been acked. */ -static int iGremote_ack; - -/* Last sequence number to be retransmitted. */ -static int iGretransmit_seq; - -/* Last sequence number we have received. */ -static int iGrecseq; - -/* Last sequence number we have acked. */ -static int iGlocal_ack; - -/* Window size to request (protocol parameter ``window''). */ -static int iGrequest_winsize = IWINDOW; - -/* Packet size to request (protocol parameter ``packet-size''). */ -static int iGrequest_packsize = IPACKSIZE; - -/* Remote window size (set during handshake). */ -static int iGremote_winsize; - -/* Forced remote window size (protocol parameter ``remote-window''). */ -static int iGforced_remote_winsize = IREMOTE_WINDOW; - -/* Remote segment size (set during handshake). This is one less than - the value in a packet header. */ -static int iGremote_segsize; - -/* Remote packet size (set based on iGremote_segsize). */ -static size_t iGremote_packsize; - -/* Forced remote packet size (protocol parameter - ``remote-packet-size''). */ -static int iGforced_remote_packsize = IREMOTE_PACKSIZE; - -/* Recieved control byte. */ -static int iGpacket_control; - -/* Number of times to retry the initial handshake. Protocol parameter - ``startup-retries''. */ -static int cGstartup_retries = CSTARTUP_RETRIES; - -/* Number of times to retry sending an initial control packet. - Protocol parameter ``init-retries''. */ -static int cGexchange_init_retries = CEXCHANGE_INIT_RETRIES; - -/* Timeout (seconds) for receiving an initial control packet. - Protocol parameter ``init-timeout''. */ -static int cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT; - -/* Timeout (seconds) for receiving a data packet. Protocol parameter - ``timeout''. */ -static int cGtimeout = CTIMEOUT; - -/* Maximum number of timeouts when receiving a data packet or - acknowledgement. Protocol parameter ``retries''. */ -static int cGretries = CRETRIES; - -/* Amount of garbage data we are prepared to see before giving up. - Protocol parameter ``garbage''. */ -static int cGgarbage_data = CGARBAGE; - -/* Maximum number of errors we are prepared to see before giving up. - Protocol parameter ``errors''. */ -static int cGmax_errors = CERRORS; - -/* Each time we receive this many packets succesfully, we decrement - the error level by one (protocol parameter ``error-decay''). */ -static int cGerror_decay = CERROR_DECAY; - -/* Whether to use shorter packets when possible. Protocol parameter - ``short-packets''. */ -static boolean fGshort_packets = TRUE; - -/* Protocol parameter commands. */ -struct uuconf_cmdtab asGproto_params[] = -{ - { "window", UUCONF_CMDTABTYPE_INT, (pointer) &iGrequest_winsize, NULL }, - { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iGrequest_packsize, - NULL }, - { "startup-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGstartup_retries, - NULL }, - { "init-timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cGexchange_init_timeout, - NULL }, - { "init-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGexchange_init_retries, - NULL }, - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cGtimeout, NULL }, - { "retries", UUCONF_CMDTABTYPE_INT, (pointer) &cGretries, NULL }, - { "garbage", UUCONF_CMDTABTYPE_INT, (pointer) &cGgarbage_data, NULL }, - { "errors", UUCONF_CMDTABTYPE_INT, (pointer) &cGmax_errors, NULL }, - { "error-decay", UUCONF_CMDTABTYPE_INT, (pointer) &cGerror_decay, NULL }, - { "remote-window", UUCONF_CMDTABTYPE_INT, - (pointer) &iGforced_remote_winsize, NULL }, - { "remote-packet-size", UUCONF_CMDTABTYPE_INT, - (pointer) &iGforced_remote_packsize, NULL }, - { "short-packets", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) &fGshort_packets, - NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Statistics. */ - -/* Number of packets we have sent. */ -static long cGsent_packets; - -/* Number of packets we have resent (these are not included in - cGsent_packets). */ -static long cGresent_packets; - -/* Number of packets we have delayed sending (these should not be - counted in cGresent_packets). */ -static long cGdelayed_packets; - -/* Number of packets we have received. */ -static long cGrec_packets; - -/* Number of packets rejected because the header was bad. */ -static long cGbad_hdr; - -/* Number of packets rejected because the checksum was bad. */ -static long cGbad_checksum; - -/* Number of packets received out of order. */ -static long cGbad_order; - -/* Number of packets rejected by receiver (number of RJ packets - 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; - -/* Each time we send an RJ, we can expect several out of order of - packets, because the other side will probably have sent a full - window by the time it sees the RJ. This variable keeps track of - the number of out of order packets we expect to see. We don't - count expected out of order packets against the error level. This - is reset to 0 when an in order packet is received. */ -static int cGexpect_bad_order; - -#if DEBUG > 1 -/* Control packet names used for debugging. */ -static const char * const azGcontrol[] = -{"?0?", "CLOSE", "RJ", "SRJ", "RR", "INITC", "INITB", "INITA"}; -#endif - -/* Local functions. */ -static boolean fgexchange_init P((struct sdaemon *qdaemon, int ictl, - int ival, int *piset)); -static boolean fgsend_control P((struct sdaemon *qdaemon, int ictl, - int ival)); -static char *zgadjust_ack P((int iseq)); -static boolean fgwait_for_packet P((struct sdaemon *qdaemon, - boolean freturncontrol, int ctimeout, - int cretries)); -static boolean fgsend_acks P((struct sdaemon *qdaemon)); -static boolean fggot_ack P((struct sdaemon *qdaemon, int iack)); -static boolean fgprocess_data P((struct sdaemon *qdaemon, boolean fdoacks, - boolean freturncontrol, - boolean *pfexit, size_t *pcneed, - boolean *pffound)); -static boolean fginit_sendbuffers P((boolean fallocate)); -static boolean fgcheck_errors P((struct sdaemon *qdaemon)); -static int igchecksum P((const char *zdata, size_t clen)); -static int igchecksum2 P((const char *zfirst, size_t cfirst, - const char *zsecond, size_t csecond)); - -/* Start the protocol. This requires a three way handshake. Both sides - must send and receive an INITA packet, an INITB packet, and an INITC - packet. The INITA and INITC packets contain the window size, and the - INITB packet contains the packet size. */ - -boolean -fgstart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - int iseg; - int i; - boolean fgota, fgotb; - - *pzlog = NULL; - - /* The 'g' protocol requires a full eight bit interface. */ - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_OFF)) - return FALSE; - - iGsendseq = 1; - iGremote_ack = 0; - iGretransmit_seq = -1; - iGrecseq = 0; - iGlocal_ack = 0; - cGsent_packets = 0; - cGresent_packets = 0; - cGdelayed_packets = 0; - cGrec_packets = 0; - cGbad_hdr = 0; - cGbad_checksum = 0; - cGbad_order = 0; - cGremote_rejects = 0; - cGremote_duprrs = 0; - cGerror_level = 0; - cGexpect_bad_order = 0; - - /* We must determine the segment size based on the packet size - which may have been modified by a protocol parameter command. - A segment size of 2^n is passed as n - 5. */ - i = iGrequest_packsize; - iseg = -1; - while (i > 0) - { - ++iseg; - i >>= 1; - } - iseg -= 5; - if (iseg < 0 || iseg > 7) - { - ulog (LOG_ERROR, "Illegal packet size %d for '%c' protocol", - iGrequest_packsize, qdaemon->qproto->bname); - 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++) - { - if (fgota) - { - if (! fgsend_control (qdaemon, INITA, iGrequest_winsize)) - return FALSE; - } - else - { - if (! fgexchange_init (qdaemon, INITA, iGrequest_winsize, - &iGremote_winsize)) - continue; - } - fgota = TRUE; - - if (fgotb) - { - if (! fgsend_control (qdaemon, INITB, iseg)) - return FALSE; - } - else - { - if (! fgexchange_init (qdaemon, INITB, iseg, &iGremote_segsize)) - continue; - } - fgotb = TRUE; - - if (! fgexchange_init (qdaemon, INITC, iGrequest_winsize, - &iGremote_winsize)) - continue; - - /* We have succesfully connected. Determine the remote packet - size. */ - iGremote_packsize = 1 << (iGremote_segsize + 5); - - /* If the user requested us to force specific remote window and - packet sizes, do so now. */ - if (iGforced_remote_winsize > 0 - && iGforced_remote_winsize <= CMAXWINDOW) - iGremote_winsize = iGforced_remote_winsize; - - if (iGforced_remote_packsize >= 32 - && iGforced_remote_packsize <= 4096) - { - /* Force the value to a power of two. */ - i = iGforced_remote_packsize; - iseg = -1; - while (i > 0) - { - ++iseg; - i >>= 1; - } - iGremote_packsize = 1 << iseg; - iGremote_segsize = iseg - 5; - } - - /* Set up packet buffers to use. We don't do this until we know - the maximum packet size we are going to send. */ - if (! fginit_sendbuffers (TRUE)) - return FALSE; - - *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) iGrequest_packsize, - (int) iGrequest_winsize); - - return TRUE; - } - - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgstart: Protocol startup failed"); - - return FALSE; -} - -/* The 'G' protocol is identical to the 'g' protocol, except that - short packets are never supported. */ - -boolean -fbiggstart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **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. - - A problem: - - We send INITA; it gets received - We receive INITA - We send INITB; it gets garbled - We receive INITB - - We have seen and sent INITB, so we start to send INITC. The other - side as sent INITB but not seen it, so it times out and resends - INITB. We will continue sending INITC and the other side will - continue sending INITB until both sides give up and start again - with INITA. - - It might seem as though if we are sending INITC and receive INITB, - we should resend our INITB, but this could cause infinite echoing - of INITB on a long-latency line. Rather than risk that, I have - implemented a fast drop-back procedure. If we are sending INITB and - receive INITC, the other side has gotten ahead of us. We immediately - fail and begin again with INITA. For the other side, if we are - sending INITC and see INITA, we also immediately fail back to INITA. - - Unfortunately, this doesn't work for the other case, in which we - are sending INITB but the other side has not yet seen INITA. As - far as I can see, if this happens we just have to wait until we - time out and resend INITA. */ - -static boolean -fgexchange_init (qdaemon, ictl, ival, piset) - struct sdaemon *qdaemon; - int ictl; - int ival; - int *piset; -{ - int i; - - /* The three-way handshake should be independent of who initializes - it, but it seems that some versions of uucico assume that the - caller sends first and the callee responds. This only matters if - we are the callee and the first packet is garbled. If we send a - packet, the other side will assume that we must have seen the - packet they sent and will never time out and send it again. - Therefore, if we are the callee we don't send a packet the first - time through the loop. This can still fail, but should usually - work, and, after all, if the initialization packets are received - correctly there will be no problem no matter what we do. */ - for (i = 0; i < cGexchange_init_retries; i++) - { - long itime; - int ctimeout; - - if (qdaemon->fcaller || i > 0) - { - if (! fgsend_control (qdaemon, ictl, ival)) - return FALSE; - } - - itime = ixsysdep_time ((long *) NULL); - ctimeout = cGexchange_init_timeout; - - do - { - long inewtime; - - /* We pass 0 as the retry count to fgwait_for_packet because - we want to handle retries here and because if it retried - it would send a packet, which would be bad. */ - if (! fgwait_for_packet (qdaemon, TRUE, ctimeout, 0)) - break; - - if (CONTROL_TT (iGpacket_control) == CONTROL) - { - if (CONTROL_XXX (iGpacket_control) == ictl) - { - *piset = CONTROL_YYY (iGpacket_control); - - /* If we didn't already send our initialization - packet, send it now. */ - if (! qdaemon->fcaller && i == 0) - { - if (! fgsend_control (qdaemon, ictl, ival)) - return FALSE; - } - - return TRUE; - } - - /* If the other side is farther along than we are, - we have lost a packet. Fail immediately back to - INITA (but don't fail if we are already doing INITA, - since that would count against cStart_retries more - than it should). */ - if (CONTROL_XXX (iGpacket_control) < ictl && ictl != INITA) - return FALSE; - - /* If we are sending INITC and we receive an INITA, the other - side has failed back (we know this because we have - seen an INITB from them). Fail back ourselves to - start the whole handshake over again. */ - if (CONTROL_XXX (iGpacket_control) == INITA && ictl == INITC) - return FALSE; - - /* As a special hack, if we are sending INITC and we - receive INITB, we update the segment size from the - packet. This permits a second INITB to override the - first one. It would be nice to do this in a cleaner - way. */ - if (CONTROL_XXX (iGpacket_control) == INITB && ictl == INITC) - iGremote_segsize = CONTROL_YYY (iGpacket_control); - } - - inewtime = ixsysdep_time ((long *) NULL); - ctimeout -= inewtime - itime; - } - while (ctimeout > 0); - } - - return FALSE; -} - -/* Shut down the protocol. */ - -boolean -fgshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - (void) fgsend_control (qdaemon, CLOSE, 0); - (void) fgsend_control (qdaemon, CLOSE, 0); - (void) fginit_sendbuffers (FALSE); - - /* The count of sent packets may not be accurate, because some of - them may have not been sent yet if the connection failed in the - middle (the ones that counted for cGdelayed_packets). I don't - think it's worth being precise. */ - ulog (LOG_NORMAL, - "Protocol '%c' packets: sent %ld, resent %ld, received %ld", - qdaemon->qproto->bname, cGsent_packets, - cGresent_packets - cGdelayed_packets, cGrec_packets); - if (cGbad_hdr != 0 - || cGbad_checksum != 0 - || cGbad_order != 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_duprrs + cGremote_rejects); - - /* Reset all the parameters to their default values, so that the - protocol parameters used for this connection do not affect the - next one. */ - iGrequest_winsize = IWINDOW; - iGrequest_packsize = IPACKSIZE; - cGstartup_retries = CSTARTUP_RETRIES; - cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT; - cGexchange_init_retries = CEXCHANGE_INIT_RETRIES; - cGtimeout = CTIMEOUT; - cGretries = CRETRIES; - cGgarbage_data = CGARBAGE; - cGmax_errors = CERRORS; - cGerror_decay = CERROR_DECAY; - iGforced_remote_winsize = IREMOTE_WINDOW; - iGforced_remote_packsize = IREMOTE_PACKSIZE; - fGshort_packets = TRUE; - - return TRUE; -} - -/* Send a command string. We send packets containing the string until - the entire string has been sent. Each packet is full. */ - -/*ARGSUSED*/ -boolean -fgsendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - size_t clen; - boolean fagain; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fgsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - - do - { - char *zpacket; - size_t cdummy; - - zpacket = zggetspace (qdaemon, &cdummy); - - if (clen < iGremote_packsize) - { - size_t csize; - - /* If the remote packet size is larger than 64 (the default, - which may indicate an older UUCP package), try to fit - this command into a smaller packet. We still always send - a complete packet, though. */ - if (iGremote_packsize <= 64 || ! fGshort_packets) - csize = iGremote_packsize; - else - { - csize = 32; - while (csize <= clen) - csize <<= 1; - } - - memcpy (zpacket, z, clen); - if (csize > clen) - bzero (zpacket + clen, csize - clen); - fagain = FALSE; - - if (! fgsenddata (qdaemon, zpacket, csize, 0, 0, (long) 0)) - return FALSE; - } - else - { - memcpy (zpacket, z, iGremote_packsize); - z += iGremote_packsize; - clen -= iGremote_packsize; - fagain = TRUE; - - if (! fgsenddata (qdaemon, zpacket, iGremote_packsize, - 0, 0, (long) 0)) - return FALSE; - } - } - while (fagain); - - return TRUE; -} - -/* We keep an array of buffers to retransmit as necessary. Rather - than waste static space on large buffer sizes, we allocate the - buffers once we know how large the other system expects them to be. - The sequence numbers used in the 'g' protocol are only three bits - long, so we allocate eight buffers and maintain a correspondence - between buffer index and sequence number. This always wastes some - buffer space, but it's easy to implement. - - We leave room at the front of the buffer for the frame header and - two additional bytes. The two extra bytes are used for short - packets, which essentially use a longer header and shorter data. - We do this to avoid moving the data. We zero out any unused bytes - before the frame, so we can locate the real header given a buffer - by finding the first non-zero byte (which will be one of the first - three bytes in the buffer). */ - -#define CSENDBUFFERS (CMAXWINDOW + 1) - -static char *azGsendbuffers[CSENDBUFFERS]; - -static boolean -fginit_sendbuffers (fallocate) - boolean fallocate; -{ - int i; - - /* Free up any remaining old buffers. */ - for (i = 0; i < CSENDBUFFERS; i++) - { - xfree ((pointer) azGsendbuffers[i]); - if (fallocate) - { - azGsendbuffers[i] = (char *) malloc (CFRAMELEN + 2 - + iGremote_packsize); - if (azGsendbuffers[i] == NULL) - return FALSE; - - /* This bzero might not seem necessary, since before we send - out each packet we zero out any non-data bytes. However, - if we receive an SRJ at the start of the conversation, we - will send out the packet before it has been set to - anything, thus sending the contents of our heap. We - avoid this by using bzero. */ - bzero (azGsendbuffers[i], CFRAMELEN + 2 + iGremote_packsize); - } - else - azGsendbuffers[i] = NULL; - } - return TRUE; -} - -/* Allocate a packet to send out. The return value of this function - must be filled in and passed to fgsenddata, or discarded. This - will ensure that the buffers and iGsendseq stay in synch. Set - *pclen to the amount of data to place in the buffer. */ - -/*ARGSUSED*/ -char * -zggetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = iGremote_packsize; - return azGsendbuffers[iGsendseq] + CFRAMELEN + 2; -} - -/* Send out a data packet. This computes the checksum, sets up the - header, and sends the packet out. The argument zdata should point - to the return value of zggetspace. */ - -/*ARGSIGNORED*/ -boolean -fgsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ - char *z; - int itt, iseg; - size_t csize; - int iclr1, iclr2; - unsigned short icheck; - - /* Set the initial length bytes. See the description at the definition - of SHORTDATA, above. */ - itt = DATA; - csize = iGremote_packsize; - iseg = iGremote_segsize + 1; - -#if DEBUG > 0 - if (cdata > csize) - ulog (LOG_FATAL, "fgsend_packet: Packet size too large"); -#endif - - iclr1 = -1; - iclr2 = -2; - if (cdata < csize) - { - /* If the remote packet size is larger than 64, the default, we - can assume they can handle a smaller packet as well, which - will be more efficient to send. */ - if (iGremote_packsize > 64 && fGshort_packets) - { - /* The packet size is 1 << (iseg + 4). */ - iseg = 1; - csize = 32; - while (csize < cdata) - { - csize <<= 1; - ++iseg; - } - } - - if (csize != cdata) - { - size_t cshort; - - /* We have to add bytes which indicate how short the packet - is. We do this by pushing the header backward, which we - can do because we allocated two extra bytes for this - purpose. */ - iclr2 = 0; - itt = SHORTDATA; - cshort = csize - cdata; - if (cshort <= 127) - { - --zdata; - zdata[0] = (char) cshort; - zdata[-1] = '\0'; - if (cshort > 1) - bzero (zdata + cdata + 1, cshort - 1); - } - else - { - zdata -= 2; - zdata[0] = (char) (0x80 | (cshort & 0x7f)); - zdata[1] = (char) (cshort >> 7); - bzero (zdata + cdata + 2, cshort - 2); - iclr1 = 0; - } - } - } - - z = zdata - CFRAMELEN; - - /* Zero out the preceding bytes, in case the last time this buffer - was used those bytes were used. We need to zero out the initial - bytes so that we can find the true start of the packet in - zgadjust_ack. */ - z[iclr1] = '\0'; - z[iclr2] = '\0'; - - z[IFRAME_DLE] = DLE; - z[IFRAME_K] = (char) iseg; - - icheck = (unsigned short) igchecksum (zdata, csize); - - /* We're just about ready to go. Wait until there is room in the - receiver's window for us to send the packet. We do this now so - that we send the correct value for the last packet received. - Note that if iGsendseq == iGremote_ack, this means that the - sequence numbers are actually 8 apart, since the packet could not - have been acknowledged before it was sent; this can happen when - the window size is 7. */ - while (iGsendseq == iGremote_ack - || CSEQDIFF (iGsendseq, iGremote_ack) > iGremote_winsize) - { - if (! fgwait_for_packet (qdaemon, TRUE, cGtimeout, cGretries)) - return FALSE; - } - - /* Ack all packets up to the next one, since the UUCP protocol - requires that all packets be acked in order. */ - while (CSEQDIFF (iGrecseq, iGlocal_ack) > 1) - { - iGlocal_ack = INEXTSEQ (iGlocal_ack); - if (! fgsend_control (qdaemon, RR, iGlocal_ack)) - return FALSE; - } - iGlocal_ack = iGrecseq; - - z[IFRAME_CONTROL] = (char) ((itt << 6) | (iGsendseq << 3) | iGrecseq); - - iGsendseq = INEXTSEQ (iGsendseq); - - icheck = ((unsigned short) - ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff)); - z[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - z[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW] - ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]); - - /* If we're waiting for acks of retransmitted packets, then don't - send this packet yet. The other side may not be ready for it - yet. Instead, code in fggot_ack will send the outstanding - packets when an ack is received. */ - ++cGsent_packets; - - if (iGretransmit_seq != -1) - { - ++cGdelayed_packets; - return TRUE; - } - - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fgsenddata: Sending packet %d (%d bytes)", - CONTROL_XXX (z[IFRAME_CONTROL]), cdata); - - return fsend_data (qdaemon->qconn, z, CFRAMELEN + csize, TRUE); -} - -/* Recompute the control byte and checksum of a packet so that it - includes the correct packet acknowledgement. This is called when a - packet is retransmitted to make sure the retransmission does not - confuse the other side. It returns a pointer to the start of the - packet, skipping the bytes that may be unused at the start of - azGsendbuffers[iseq]. */ - -static char * -zgadjust_ack (iseq) - int iseq; -{ - register char *z; - unsigned short icheck; - - z = azGsendbuffers[iseq]; - if (*z == '\0') - ++z; - if (*z == '\0') - ++z; - - /* If the received packet number is the same, there is nothing - to do. */ - if (CONTROL_YYY (z[IFRAME_CONTROL]) == iGrecseq) - return z; - - /* Get the old checksum. */ - icheck = (unsigned short) (((z[IFRAME_CHECKHIGH] & 0xff) << 8) - | (z[IFRAME_CHECKLOW] & 0xff)); - icheck = ((unsigned short) - (((0xaaaa - icheck) ^ (z[IFRAME_CONTROL] & 0xff)) & 0xffff)); - - /* Update the control byte. */ - z[IFRAME_CONTROL] = (char) ((z[IFRAME_CONTROL] &~ 07) | iGrecseq); - - /* Create the new checksum. */ - icheck = ((unsigned short) - ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff)); - z[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - z[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - /* Update the XOR byte. */ - z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW] - ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]); - - return z; -} - -/* Send a control packet. These are fairly simple to construct. It - seems reasonable to me that we should be able to send a control - packet at any time, even if the receive window is closed. In - particular, we don't want to delay when sending a CLOSE control - message. If I'm wrong, it can be changed easily enough. */ - -static boolean -fgsend_control (qdaemon, ixxx, iyyy) - struct sdaemon *qdaemon; - int ixxx; - int iyyy; -{ - char ab[CFRAMELEN]; - int ictl; - unsigned short icheck; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_PROTO) || - (FDEBUGGING (DEBUG_ABNORMAL) && ixxx != RR)) - ulog (LOG_DEBUG, "fgsend_control: Sending control %s %d", - azGcontrol[ixxx], iyyy); -#endif - - ab[IFRAME_DLE] = DLE; - ab[IFRAME_K] = KCONTROL; - - ictl = (CONTROL << 6) | (ixxx << 3) | iyyy; - icheck = (unsigned short) (0xaaaa - ictl); - ab[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - ab[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - ab[IFRAME_CONTROL] = (char) ictl; - - ab[IFRAME_XOR] = (char) (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]); - - return fsend_data (qdaemon->qconn, ab, (size_t) CFRAMELEN, TRUE); -} - -/* Wait for data to come in. This continues processing until a - complete file or command has been received. */ - -boolean -fgwait (qdaemon) - struct sdaemon *qdaemon; -{ - return fgwait_for_packet (qdaemon, FALSE, cGtimeout, cGretries); -} - -/* Get a packet. This is called when we have nothing to send, but - want to wait for a packet to come in. If freturncontrol is TRUE, - this will return after getting any control packet. Otherwise, it - will continue to receive packets until a complete file or a - complete command has been received. The timeout and the number of - retries are specified as arguments. The function returns FALSE if - an error occurs or if cretries timeouts of ctimeout seconds were - exceeded. */ - -static boolean -fgwait_for_packet (qdaemon, freturncontrol, ctimeout, cretries) - struct sdaemon *qdaemon; - boolean freturncontrol; - int ctimeout; - int cretries; -{ - int ctimeouts; - int cgarbage; - int cshort; - - ctimeouts = 0; - cgarbage = 0; - cshort = 0; - - while (TRUE) - { - boolean fexit; - size_t cneed; - boolean ffound; - size_t crec; - - if (! fgprocess_data (qdaemon, TRUE, freturncontrol, &fexit, - &cneed, &ffound)) - return FALSE; - - if (fexit) - return TRUE; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgwait_for_packet: Need %lu bytes", - (unsigned long) cneed); - - if (ffound) - { - ctimeouts = 0; - cgarbage = 0; - } - else - { - if (cgarbage > cGgarbage_data) - { - ulog (LOG_ERROR, "Too much unrecognized data"); - return FALSE; - } - } - - if (! freceive_data (qdaemon->qconn, cneed, &crec, ctimeout, TRUE)) - return FALSE; - - cgarbage += crec; - - if (crec != 0) - { - /* If we don't get enough data twice in a row, we may have - dropped some data and still be looking for the end of a - large packet. Incrementing iPrecstart will force - fgprocess_data to skip that packet and look through the - rest of the data. In some situations, this will be a - mistake. */ - if (crec >= cneed) - cshort = 0; - else - { - ++cshort; - if (cshort > 1) - { - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - cshort = 0; - } - } - } - else - { - /* The read timed out. If we have an unacknowledged packet, - send it again. Otherwise, send an RJ with the last - packet we received correctly. */ - ++ctimeouts; - if (ctimeouts > cretries) - { - if (cretries > 0) - ulog (LOG_ERROR, "Timed out waiting for packet"); - return FALSE; - } - - if (INEXTSEQ (iGremote_ack) != iGsendseq) - { - int inext; - char *zsend; - - inext = INEXTSEQ (iGremote_ack); - - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgwait_for_packet: Resending packet %d", - inext); - - ++cGresent_packets; - zsend = zgadjust_ack (inext); - if (! fsend_data (qdaemon->qconn, zsend, - CFRAMELEN + CPACKLEN (zsend), TRUE)) - return FALSE; - iGretransmit_seq = inext; - } - else - { - /* Send all pending acks first, to avoid confusing - the other side. */ - if (iGlocal_ack != iGrecseq) - { - if (! fgsend_acks (qdaemon)) - return FALSE; - } - if (! fgsend_control (qdaemon, RJ, iGrecseq)) - return FALSE; - } - } - } -} - -/* Send acks for all packets we haven't acked yet. */ - -static boolean -fgsend_acks (qdaemon) - struct sdaemon *qdaemon; -{ - while (iGlocal_ack != iGrecseq) - { - iGlocal_ack = INEXTSEQ (iGlocal_ack); - if (! fgsend_control (qdaemon, RR, iGlocal_ack)) - return FALSE; - } - return TRUE; -} - -/* Handle an ack of a packet. According to Hanrahan's paper, this - acknowledges all previous packets. If this is an ack for a - retransmitted packet, continue by resending up to two more packets - following the retransmitted one. This should recover quickly from - a line glitch, while avoiding the problem of continual - retransmission. */ - -static boolean -fggot_ack (qdaemon, iack) - struct sdaemon *qdaemon; - int iack; -{ - int inext; - char *zsend; - - /* We only decrement the error level if we are not retransmitting - packets. We want to catch a sudden downgrade in line quality as - fast as possible. */ - if (cGerror_level > 0 - && iGretransmit_seq == -1 - && cGsent_packets % cGerror_decay == 0) - --cGerror_level; - cGexpect_bad_order = 0; - - /* Each time packet 0 is acknowledged, we call uwindow_acked since a - new window has been acked. */ - if (iack < iGremote_ack) - uwindow_acked (qdaemon, FALSE); - - iGremote_ack = iack; - - if (iGretransmit_seq == -1) - return TRUE; - - inext = INEXTSEQ (iGretransmit_seq); - if (inext == iGsendseq) - iGretransmit_seq = -1; - else - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fggot_ack: Sending packet %d", inext); - - ++cGresent_packets; - zsend = zgadjust_ack (inext); - if (! fsend_data (qdaemon->qconn, zsend, CFRAMELEN + CPACKLEN (zsend), - TRUE)) - return FALSE; - inext = INEXTSEQ (inext); - if (inext == iGsendseq) - iGretransmit_seq = -1; - else - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fggot_ack: Sending packet %d", inext); - - ++cGresent_packets; - zsend = zgadjust_ack (inext); - if (! fsend_data (qdaemon->qconn, zsend, - CFRAMELEN + CPACKLEN (zsend), TRUE)) - return FALSE; - iGretransmit_seq = inext; - } - } - - return TRUE; -} - -/* See if we've received more than the permitted number of errors. If - we receive a bad packet, we can expect a window full (less one) of - out of order packets to follow, so we discount cGbad_order - accordingly. */ - -static boolean -fgcheck_errors (qdaemon) - struct sdaemon *qdaemon; -{ - if (cGerror_level > cGmax_errors && cGmax_errors >= 0) - { - ulog (LOG_ERROR, "Too many '%c' protocol errors", - qdaemon->qproto->bname); - return FALSE; - } - - return TRUE; -} - -/* Process the receive buffer into a data packet, if possible. All - control packets are handled here. When a data packet is received, - fgprocess_data calls fgot_data with the data; if that sets its - pfexit argument to TRUE fgprocess_data will set *pfexit to TRUE and - return TRUE. Also, if the freturncontrol argument is TRUE - fgprocess_data will set *pfexit to TRUE and return TRUE. Otherwise - fgprocess_data will continue trying to process data. If some error - occurs, fgprocess_data will return FALSE. If there is not enough - data to form a complete packet, then *pfexit will be set to FALSE, - *pcneed will be set to the number of bytes needed to form a - complete packet (unless pcneed is NULL) and fgprocess_data will - return TRUE. If this function found a data packet, and pffound is - not NULL, it will set *pffound to TRUE; this can be used to tell - valid data from an endless stream of garbage and control packets. - If fdoacks is TRUE, received packets will be acknowledged; - otherwise they must be acknowledged later. */ - -static boolean -fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound) - struct sdaemon *qdaemon; - boolean fdoacks; - boolean freturncontrol; - boolean *pfexit; - size_t *pcneed; - boolean *pffound; -{ - *pfexit = FALSE; - if (pffound != NULL) - *pffound = FALSE; - - while (iPrecstart != iPrecend) - { - char ab[CFRAMELEN]; - int i, iget, cwant; - unsigned short ihdrcheck, idatcheck; - const char *zfirst, *zsecond; - int cfirst, csecond; - boolean fduprr; - - /* Look for the DLE which must start a packet. */ - if (abPrecbuf[iPrecstart] != DLE) - { - char *zdle; - - cfirst = iPrecend - iPrecstart; - if (cfirst < 0) - cfirst = CRECBUFLEN - iPrecstart; - - zdle = memchr (abPrecbuf + iPrecstart, DLE, (size_t) cfirst); - - if (zdle == NULL) - { - iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN; - continue; - } - - /* We don't need % CRECBUFLEN here because zdle - (abPrecbuf - + iPrecstart) < cfirst <= CRECBUFLEN - iPrecstart. */ - iPrecstart += zdle - (abPrecbuf + iPrecstart); - } - - /* Get the first six bytes into ab. */ - for (i = 0, iget = iPrecstart; - i < CFRAMELEN && iget != iPrecend; - i++, iget = (iget + 1) % CRECBUFLEN) - ab[i] = abPrecbuf[iget]; - - /* If there aren't six bytes, there is no packet. */ - if (i < CFRAMELEN) - { - if (pcneed != NULL) - *pcneed = CFRAMELEN - i; - return TRUE; - } - - /* Make sure these six bytes start a packet. The check on - IFRAME_DLE is basically a debugging check, since the above - code should have ensured that it will never fail. If this is - not the start of a packet, bump iPrecstart and loop around to - look for another DLE. */ - if (ab[IFRAME_DLE] != DLE - || ab[IFRAME_K] < 1 - || ab[IFRAME_K] > 9 - || ab[IFRAME_XOR] != (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]) - || CONTROL_TT (ab[IFRAME_CONTROL]) == ALTCHAN) - { - ++cGbad_hdr; - ++cGerror_level; - - DEBUG_MESSAGE4 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: K %d TT %d XOR byte %d calc %d", - ab[IFRAME_K] & 0xff, - CONTROL_TT (ab[IFRAME_CONTROL]), - ab[IFRAME_XOR] & 0xff, - (ab[IFRAME_K] - ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] - ^ ab[IFRAME_CONTROL]) & 0xff); - - if (! fgcheck_errors (qdaemon)) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - /* The zfirst and cfirst pair point to the first set of data for - this packet; the zsecond and csecond point to the second set, - in case the packet wraps around the end of the buffer. */ - zfirst = abPrecbuf + iPrecstart + CFRAMELEN; - cfirst = 0; - zsecond = NULL; - csecond = 0; - - if (ab[IFRAME_K] == KCONTROL) - { - /* This is a control packet. It should not have any data. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - ++cGbad_hdr; - ++cGerror_level; - - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: control packet with data"); - - if (! fgcheck_errors (qdaemon)) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - idatcheck = (unsigned short) (0xaaaa - ab[IFRAME_CONTROL]); - cwant = 0; - } - else - { - int cinbuf; - unsigned short icheck; - - /* This is a data packet. It should not be type CONTROL. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL) - { - ++cGbad_hdr; - ++cGerror_level; - - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: data packet is type CONTROL"); - - if (! fgcheck_errors (qdaemon)) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - cinbuf -= CFRAMELEN; - - /* Make sure we have enough data. If we don't, wait for - more. */ - - cwant = (int) CPACKLEN (ab); - if (cinbuf < cwant) - { - if (pcneed != NULL) - *pcneed = cwant - cinbuf; - return TRUE; - } - - /* Set up the data pointers and compute the checksum. */ - if (iPrecend >= iPrecstart) - cfirst = cwant; - else - { - cfirst = CRECBUFLEN - (iPrecstart + CFRAMELEN); - if (cfirst >= cwant) - cfirst = cwant; - else if (cfirst > 0) - { - zsecond = abPrecbuf; - csecond = cwant - cfirst; - } - else - { - /* Here cfirst is non-positive, so subtracting from - abPrecbuf will actually skip the appropriate number - of bytes at the start of abPrecbuf. */ - zfirst = abPrecbuf - cfirst; - cfirst = cwant; - } - } - - if (csecond == 0) - icheck = (unsigned short) igchecksum (zfirst, (size_t) cfirst); - else - icheck = (unsigned short) igchecksum2 (zfirst, (size_t) cfirst, - zsecond, - (size_t) csecond); - - idatcheck = ((unsigned short) - (((0xaaaa - (icheck ^ (ab[IFRAME_CONTROL] & 0xff))) - & 0xffff))); - } - - ihdrcheck = (unsigned short) (((ab[IFRAME_CHECKHIGH] & 0xff) << 8) - | (ab[IFRAME_CHECKLOW] & 0xff)); - - if (ihdrcheck != idatcheck) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad checksum: header 0x%x, data 0x%x", - ihdrcheck, idatcheck); - - ++cGbad_checksum; - ++cGerror_level; - - if (! fgcheck_errors (qdaemon)) - return FALSE; - - /* If the checksum failed for a data packet, then if it was - the one we were expecting send an RJ, otherwise ignore - it. Previously if this code got the wrong packet number - it would send an RR, but that may confuse some Telebit - modems and it doesn't help in any case since the receiver - will probably just ignore the RR as a duplicate (that's - basically what this code does). If we totally missed the - packet we will time out and send an RJ in the function - fgwait_for_packet above. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - /* Make sure we've acked everything up to this point. */ - if (iGrecseq != iGlocal_ack) - { - if (! fgsend_acks (qdaemon)) - return FALSE; - } - - /* If this is the packet we wanted, tell the sender that - it failed. */ - if (CONTROL_XXX (ab[IFRAME_CONTROL]) == INEXTSEQ (iGrecseq)) - { - if (! fgsend_control (qdaemon, RJ, iGrecseq)) - return FALSE; - cGexpect_bad_order += iGrequest_winsize - 1; - } - } - - /* We can't skip the packet data after this, because if we - have lost incoming bytes the next DLE will be somewhere - in what we thought was the packet data. */ - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - /* We have a packet; remove the processed bytes from the receive - buffer. */ - iPrecstart = (iPrecstart + cwant + CFRAMELEN) % CRECBUFLEN; - - /* Store the control byte for the handshake routines. */ - iGpacket_control = ab[IFRAME_CONTROL] & 0xff; - - /* 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 and we've never seen an RJ, - we treat the RR as an RJ. */ - fduprr = FALSE; - 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 - && iGretransmit_seq == -1) - { - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Treating duplicate RR as RJ"); - fduprr = TRUE; - } - - /* Update the received sequence number from the yyy field of a - 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; - } - - /* If this isn't a control message, make sure we have received - the expected packet sequence number, acknowledge the packet - if it's the right one, and process the data. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - if (CONTROL_XXX (ab[IFRAME_CONTROL]) != INEXTSEQ (iGrecseq)) - { - /* We got the wrong packet number. */ - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Got packet %d; expected %d", - CONTROL_XXX (ab[IFRAME_CONTROL]), - INEXTSEQ (iGrecseq)); - - if (cGexpect_bad_order > 0) - --cGexpect_bad_order; - else - { - ++cGbad_order; - ++cGerror_level; - if (! fgcheck_errors (qdaemon)) - return FALSE; - } - - /* This code used to send an RR to encourage the other - side to get back in synch, but that may confuse some - Telebit modems and does little good in any case, - since the other side will probably just ignore it - anyhow (that's what this code does). */ - continue; - } - - /* We got the packet we expected. */ - ++cGrec_packets; - if (cGerror_level > 0 - && cGrec_packets % cGerror_decay == 0) - --cGerror_level; - cGexpect_bad_order = 0; - - iGrecseq = INEXTSEQ (iGrecseq); - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgprocess_data: Got packet %d", iGrecseq); - - /* Tell the caller that we found something. */ - if (pffound != NULL) - *pffound = TRUE; - - /* If we are supposed to do acknowledgements here, send back - an RR packet. */ - if (fdoacks) - { - if (! fgsend_acks (qdaemon)) - return FALSE; - } - - /* If this is a short data packet, adjust the data pointers - and lengths. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) == SHORTDATA) - { - int cshort, cmove; - - if ((zfirst[0] & 0x80) == 0) - { - cshort = zfirst[0] & 0xff; - cmove = 1; - } - else - { - int cbyte2; - - if (cfirst > 1) - cbyte2 = zfirst[1] & 0xff; - else - cbyte2 = zsecond[0] & 0xff; - cshort = (zfirst[0] & 0x7f) + (cbyte2 << 7); - cmove = 2; - } - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgprocess_data: Packet short by %d", - cshort); - - /* Adjust the start of the buffer for the bytes used - by the count. */ - if (cfirst > cmove) - { - zfirst += cmove; - cfirst -= cmove; - } - else - { - zfirst = zsecond + (cmove - cfirst); - cfirst = csecond - (cmove - cfirst); - csecond = 0; - } - - /* Adjust the length of the buffer for the bytes we are - not supposed to consider. */ - cshort -= cmove; - if (csecond >= cshort) - csecond -= cshort; - else - { - cfirst -= cshort - csecond; - csecond = 0; - } - -#if DEBUG > 0 - /* This should not happen, but just in case. */ - if (cfirst < 0) - cfirst = 0; -#endif - } - - if (! fgot_data (qdaemon, zfirst, (size_t) cfirst, - zsecond, (size_t) csecond, - -1, -1, (long) -1, - INEXTSEQ (iGremote_ack) == iGsendseq, - pfexit)) - return FALSE; - - /* If fgot_data told us that we were finished, get out. */ - if (*pfexit) - return TRUE; - - /* If we've been asked to return control packets, get out - now. */ - if (freturncontrol) - { - *pfexit = TRUE; - return TRUE; - } - - continue; - } - - /* Handle control messages here. */ -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_PROTO) - || (FDEBUGGING (DEBUG_ABNORMAL) - && CONTROL_XXX (ab[IFRAME_CONTROL]) != RR)) - ulog (LOG_DEBUG, "fgprocess_data: Got control %s %d", - azGcontrol[CONTROL_XXX (ab[IFRAME_CONTROL])], - CONTROL_YYY (ab[IFRAME_CONTROL])); -#endif - - switch (CONTROL_XXX (ab[IFRAME_CONTROL])) - { - case CLOSE: - /* The other side has closed the connection. */ - if (fLog_sighup) - { - ulog (LOG_ERROR, "Received unexpected CLOSE packet"); - (void) fgsend_control (qdaemon, CLOSE, 0); - } - return FALSE; - case RR: - /* Acknowledge receipt of a packet. This was already handled - above, unless we are treating it as RJ. */ - if (! fduprr) - break; - /* Fall through. */ - case RJ: - /* The other side dropped a packet. Begin retransmission with - the packet following the one acknowledged. We don't - retransmit the packets immediately, but instead wait - for the first one to be acked. This prevents us from - sending an entire window several times if we get several - RJ packets. */ - iGremote_ack = CONTROL_YYY (ab[IFRAME_CONTROL]); - iGretransmit_seq = INEXTSEQ (iGremote_ack); - if (iGretransmit_seq == iGsendseq) - iGretransmit_seq = -1; - else - { - char *zpack; - - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Remote reject: next %d resending %d", - iGsendseq, iGretransmit_seq); - - ++cGresent_packets; - if (fduprr) - ++cGremote_duprrs; - else - ++cGremote_rejects; - ++cGerror_level; - if (! fgcheck_errors (qdaemon)) - return FALSE; - zpack = zgadjust_ack (iGretransmit_seq); - if (! fsend_data (qdaemon->qconn, zpack, - CFRAMELEN + CPACKLEN (zpack), - TRUE)) - return FALSE; - } - break; - case SRJ: - /* Selectively reject a particular packet. This is not used - by UUCP, but it's easy to support. */ - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Selective reject of %d", - CONTROL_YYY (ab[IFRAME_CONTROL])); - { - char *zpack; - - ++cGresent_packets; - ++cGremote_rejects; - ++cGerror_level; - zpack = zgadjust_ack (CONTROL_YYY (ab[IFRAME_CONTROL])); - if (! fsend_data (qdaemon->qconn, zpack, - CFRAMELEN + CPACKLEN (zpack), - TRUE)) - return FALSE; - } - break; - case INITC: - case INITB: - case INITA: - /* Ignore attempts to reinitialize. */ - break; - } - - /* If we've been asked to return control packets, get out. */ - if (freturncontrol) - { - *pfexit = TRUE; - return TRUE; - } - - /* Loop around to look for the next packet, if any. */ - } - - /* There is no data left in the receive buffer. */ - if (pcneed != NULL) - *pcneed = CFRAMELEN; - return TRUE; -} - -/* Compute the 'g' protocol checksum. This is unfortunately rather - awkward. This is the most time consuming code in the entire - program. It's also not a great checksum, since it can be fooled - by some single bit errors. */ - -/* Sorry about this knavery, but it speeds up the VAX code - significantly. It would be better to rewrite the whole routine in - assembler. */ -#ifdef __GNUC__ -#ifdef __vax__ -#define VAX_ASM 1 -#endif -#endif - -#if VAX_ASM -#define ROTATE(i) \ - asm ("cvtwl %1,%0\n\trotl $1,%0,%0" : "=g" (i) : "g" (i)) -#else -#define ROTATE(i) i += i + ((i & 0x8000) >> 15) -#endif - -#define ITERATION \ - /* Rotate ichk1 left. */ \ - ROTATE (ichk1); \ - \ - /* The guts of the checksum. */ \ - b = BUCHAR (*z++); \ - if (b != 0) \ - { \ - ichk1 &= 0xffff; \ - ichk1 += b; \ - ichk2 += ichk1 ^ c; \ - if ((ichk1 >> 16) != 0) \ - ichk1 ^= ichk2; \ - } \ - else \ - { \ - ichk2 += ichk1 ^ c; \ - ichk1 ^= ichk2; \ - } \ - \ - --c - -static int -igchecksum (z, c) - register const char *z; - register size_t c; -{ - register unsigned long ichk1, ichk2; - - ichk1 = 0xffff; - ichk2 = 0; - - do - { - register unsigned int b; - - ITERATION; - ITERATION; - ITERATION; - ITERATION; - } - while (c > 0); - - return ichk1 & 0xffff; -} - -/* We use a separate function compute the checksum if the block is - split around the end of the receive buffer since it occurs much - less frequently and the checksum is already high up in the - profiles. These functions are almost identical, and this one - actually only has a few more instructions in the inner loop. */ - -static int -igchecksum2 (zfirst, cfirst, zsecond, csecond) - const char *zfirst; - size_t cfirst; - const char *zsecond; - size_t csecond; -{ - register unsigned long ichk1, ichk2; - register const char *z; - register size_t c; - - z = zfirst; - c = cfirst + csecond; - - ichk1 = 0xffff; - ichk2 = 0; - - do - { - register unsigned int b; - - ITERATION; - - /* If the first buffer has been finished, switch to the second. */ - --cfirst; - if (cfirst == 0) - z = zsecond; - } - while (c > 0); - - return ichk1 & 0xffff; -} diff --git a/gnu/libexec/uucp/uucico/proti.c b/gnu/libexec/uucp/uucico/proti.c deleted file mode 100644 index 4b4c5e3..0000000 --- a/gnu/libexec/uucp/uucico/proti.c +++ /dev/null @@ -1,1699 +0,0 @@ -/* proti.c - The 'i' protocol. - - Copyright (C) 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char proti_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* The 'i' protocol is a simple sliding window protocol, created by - me. It is in many ways similar to the 'g' protocol. Several ideas - are also taken from the paper ``A High-Throughput Message Transport - System'' by P. Lauder. I don't know where the paper was published, - but the author's e-mail address is piers@cs.su.oz.au. However, I - haven't adopted his main idea, which is to dispense with windows - entirely. This is because some links still do require flow control - and, more importantly, because I want to have a limit to the amount - of data I must be able to resend upon request. To reduce the costs - of window acknowledgements, I use a large window and only require - an ack at the halfway point. - - Each packet starts with a header containing the following - information: - - Intro byte 8 bits byte 1 - Packet number 5 bits byte 2 - Local channel 3 bits - Packet ack 5 bits byte 3 - Remote channel 3 bits - Packet type 3 bits bytes 4-5 - Direction 1 bit - Data length 12 bits - Header check 8 bits byte 6 - - If the data length is not 0, this is followed by the data and a 32 - bit CRC checksum. - - The following packet types are defined: - - SYNC Initialize the connection - DATA Data packet - ACK Simple acknowledgement with no data - NAK Negative acknowledgement; requests resend of single packet - SPOS Set file position - CLOSE Close the connection - */ - -/* The offsets of the bytes in the packet header. */ - -#define IHDR_INTRO (0) -#define IHDR_LOCAL (1) -#define IHDR_REMOTE (2) -#define IHDR_CONTENTS1 (3) -#define IHDR_CONTENTS2 (4) -#define IHDR_CHECK (5) - -/* Macros to set and extract values of IHDR_LOCAL and IHDR_REMOTE. */ -#define IHDRWIN_SET(iseq, ichan) (((iseq) << 3) | (ichan)) -#define IHDRWIN_GETSEQ(ival) (((ival) >> 3) & 0x1f) -#define IHDRWIN_GETCHAN(ival) ((ival) & 0x07) - -/* Macros to set and extract values of IHDR_CONTENTS fields. */ -#define IHDRCON_SET1(ttype, fcaller, cbytes) \ - (((ttype) << 5) | ((fcaller) ? (1 << 4) : 0) | (((cbytes) >> 8) & 0x0f)) -#define IHDRCON_SET2(ttype, fcaller, cbytes) ((cbytes) & 0xff) -#define THDRCON_GETTYPE(i1, i2) (((i1) >> 5) & 0x07) -#define FHDRCON_GETCALLER(i1, i2) (((i1) & (1 << 4)) != 0) -#define CHDRCON_GETBYTES(i1, i2) ((((i1) & 0x0f) << 8) | ((i2) & 0xff)) - -/* Macros for the IHDR_CHECK field. */ -#define IHDRCHECK_VAL(zhdr) \ - ((zhdr[IHDR_LOCAL] \ - ^ zhdr[IHDR_REMOTE] \ - ^ zhdr[IHDR_CONTENTS1] \ - ^ zhdr[IHDR_CONTENTS2]) \ - & 0xff) - -/* Length of the packet header. */ -#define CHDRLEN (6) - -/* Amount of space to skip between start of packet and actual data. - This is used to make the actual data longword aligned, to encourage - good performance when copying data into the buffer. */ -#define CHDRSKIPLEN (CHDRLEN + (sizeof (long) - CHDRLEN % sizeof (long))) - -/* Amount of space to skip between memory buffer and header. */ -#define CHDROFFSET (CHDRSKIPLEN - CHDRLEN) - -/* Length of the trailing checksum. */ -#define CCKSUMLEN (4) - -/* Macros to set and get the checksum. These multiply evaluate their - arguments. */ -#define ICKSUM_GET(z) \ - ((((((((unsigned long) ((z)[0] & 0xff)) << 8) \ - | (unsigned long) ((z)[1] & 0xff)) << 8) \ - | (unsigned long) ((z)[2] & 0xff)) << 8) \ - | (unsigned long) ((z)[3] & 0xff)) -#define UCKSUM_SET(z, i) \ - (void) ((z)[0] = (((i) >> 24) & 0xff), \ - (z)[1] = (((i) >> 16) & 0xff), \ - (z)[2] = (((i) >> 8) & 0xff), \ - (z)[3] = ((i) & 0xff)) - -/* The header introduction character. */ -#define IINTRO ('\007') - -/* The packet types. */ - -#define DATA (0) -#define SYNC (1) -#define ACK (2) -#define NAK (3) -#define SPOS (4) -#define CLOSE (5) - -/* Largest possible packet size. */ -#define IMAXPACKSIZE ((1 << 12) - 1) - -/* Largest possible sequence number (plus 1). */ -#define IMAXSEQ 32 - -/* Get the next sequence number given a sequence number. */ -#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). */ -#define CSEQDIFF(i1, i2) (((i1) + IMAXSEQ - (i2)) & (IMAXSEQ - 1)) - -/* Largest possible channel number (plus 1). */ -#define IMAXICHAN (8) - -/* Default packet size to request (protocol parameter - ``packet-size''). */ -#define IREQUEST_PACKSIZE (1024) - -/* Default window size to request (protocol parameter ``window''). */ -#define IREQUEST_WINSIZE (16) - -/* Default timeout to use when sending the SYNC packet (protocol - parameter ``sync-timeout''). */ -#define CSYNC_TIMEOUT (10) - -/* Default number of times to retry sending the SYNC packet (protocol - parameter ``sync-retries''). */ -#define CSYNC_RETRIES (6) - -/* Default timeout to use when waiting for a packet (protocol - parameter ``timeout''). */ -#define CTIMEOUT (10) - -/* Default number of times to retry sending a packet before giving up - (protocol parameter ``retries''). */ -#define CRETRIES (6) - -/* Default maximum level of errors to accept before giving up - (protocol parameter ``errors''). */ -#define CERRORS (100) - -/* Default decay rate. Each time we receive this many packets - succesfully, we decrement the error level by one (protocol - parameter ``error-decay''). */ -#define CERROR_DECAY (10) - -/* The default list of characters to avoid: XON and XOFF. This string - is processed as an escape sequence. This is 'j' protocol parameter - ``avoid''; it is defined in this file because the 'i' and 'j' - protocols share protocol parameters. */ -#define ZAVOID "\\021\\023" - -/* Local variables. */ - -/* Packet size to request (protocol parameter ``packet-size''). */ -static int iIrequest_packsize = IREQUEST_PACKSIZE; - -/* Window size to request (protocol parameter ``window''). */ -static int iIrequest_winsize = IREQUEST_WINSIZE; - -/* Remote packet size (set from SYNC packet or from - iIforced_remote_packsize). */ -static int iIremote_packsize; - -/* Size which buffers were allocated for. */ -static int iIalc_packsize; - -/* Forced remote packet size, used if non-zero (protocol parameter - ``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). */ -static int iIremote_winsize; - -/* Timeout to use when sending the SYNC packet (protocol - parameter ``sync-timeout''). */ -int cIsync_timeout = CSYNC_TIMEOUT; - -/* Number of times to retry sending the SYNC packet (protocol - parameter ``sync-retries''). */ -static int cIsync_retries = CSYNC_RETRIES; - -/* Timeout to use when waiting for a packet (protocol parameter - ``timeout''). */ -static int cItimeout = CTIMEOUT; - -/* Timeout to use when waiting for an acknowledgement to open up space - in the window. This is computed based on the window size and the - connection speed. */ -static int cIwindow_timeout = CTIMEOUT; - -/* Number of times to retry sending a packet before giving up - (protocol parameter ``retries''). */ -static int cIretries = CRETRIES; - -/* Maximum level of errors to accept before giving up (protocol - parameter ``errors''). */ -static int cIerrors = CERRORS; - -/* Each time we receive this many packets succesfully, we decrement - 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 - parameters. */ -const char *zJavoid_parameter = ZAVOID; - -/* Routine to use when sending data. This is a hook for the 'j' - protocol. */ -static boolean (*pfIsend) P((struct sconnection *qconn, const char *zsend, - size_t csend, boolean fdoread)); - -/* Routine to use to use when reading data. This is a hook for the - 'j' protocol. */ -static boolean (*pfIreceive) P((struct sconnection *qconn, size_t cneed, - size_t *pcrec, int ctimeout, - boolean freport)); - -/* Next sequence number to send. */ -static int iIsendseq; - -/* Last sequence number received. */ -static int iIrecseq; - -/* Last sequence number we have acknowledged. */ -static int iIlocal_ack; - -/* Last sequence number remote system has acknowledged. */ -static int iIremote_ack; - -/* File position we are sending from. */ -static long iIsendpos; - -/* File position we are receiving to. */ -static long iIrecpos; - -/* TRUE if closing the connection. */ -static boolean fIclosing; - -/* Array of sent packets indexed by packet number. */ -static char *azIsendbuffers[IMAXSEQ]; - -/* Array of received packets that we aren't ready to process yet, - indexed by packet number. */ -static char *azIrecbuffers[IMAXSEQ]; - -/* For each packet sequence number, record whether we sent a NAK for - the packet. */ -static boolean afInaked[IMAXSEQ]; - -/* Number of SYNC packets received (used only to detect whether one - was received). */ -static int cIsyncs; - -/* Number of packets sent. */ -static long cIsent_packets; - -/* Number of packets received. */ -static long cIreceived_packets; - -/* Number of packets resent. */ -static long cIresent_packets; - -/* Number of bad packet headers received. */ -static long cIbad_hdr; - -/* Number of out of order packets received. */ -static long cIbad_order; - -/* Number of bad checksums received. */ -static long cIbad_cksum; - -/* Number of packets rejected by remote system. */ -static long cIremote_rejects; - -/* Protocol parameter commands. */ - -struct uuconf_cmdtab asIproto_params[] = -{ - { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iIrequest_packsize, - NULL }, - { "window", UUCONF_CMDTABTYPE_INT, (pointer) &iIrequest_winsize, NULL }, - { "remote-packet-size", UUCONF_CMDTABTYPE_INT, - (pointer) &iIforced_remote_packsize, NULL }, - { "sync-timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_timeout, - NULL }, - { "sync-retries", UUCONF_CMDTABTYPE_INT, (pointer) &cIsync_retries, - NULL }, - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cItimeout, NULL }, - { "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. */ - { "avoid", UUCONF_CMDTABTYPE_STRING, (pointer) &zJavoid_parameter, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local functions. */ - -static boolean finak P((struct sdaemon *qdaemon, int iseq)); -static boolean firesend P((struct sdaemon *qdaemon)); -static boolean fiwindow_wait P((struct sdaemon *qdaemon)); -static boolean fiwait_for_packet P((struct sdaemon *qdaemon, - int ctimeout, int cretries, - boolean fone, boolean *ftimedout)); -static boolean ficheck_errors P((struct sdaemon *qdaemon)); -static boolean fiprocess_data P((struct sdaemon *qdaemon, - boolean *pfexit, boolean *pffound, - size_t *pcneed)); -static boolean fiprocess_packet P((struct sdaemon *qdaemon, - const char *zhdr, - const char *zfirst, int cfirst, - const char *zsecond, int csecond, - boolean *pfexit)); - -/* The 'i' protocol start routine. The work is done in a routine - which is also called by the 'j' protocol start routine. */ - -boolean -fistart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - return fijstart (qdaemon, pzlog, IMAXPACKSIZE, fsend_data, freceive_data); -} - -/* Start the protocol. This routine is called by both the 'i' and 'j' - protocol start routines. We keep transmitting a SYNC packet - containing the window and packet size we would like to receive - until we receive a SYNC packet from the remote system. The first - two bytes of the data contents of a SYNC packet are the maximum - packet size we want to receive (high byte, low byte), and the next - byte is the maximum window size we want to use. */ - -boolean -fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive) - struct sdaemon *qdaemon; - char **pzlog; - int imaxpacksize; - boolean (*pfsend) P((struct sconnection *qconn, const char *zsend, - size_t csend, boolean fdoread)); - boolean (*pfreceive) P((struct sconnection *qconn, size_t cneed, - size_t *pcrec, int ctimeout, boolean freport)); -{ - char ab[CHDRLEN + 4 + CCKSUMLEN]; - unsigned long icksum; - int ctries; - int csyncs; - long ibaud; - - *pzlog = NULL; - - pfIsend = pfsend; - pfIreceive = pfreceive; - - if (iIforced_remote_packsize <= 0 - || iIforced_remote_packsize > imaxpacksize) - iIforced_remote_packsize = 0; - else - iIremote_packsize = iIforced_remote_packsize; - iIalc_packsize = 0; - - iIsendseq = 1; - iIrecseq = 0; - iIlocal_ack = 0; - iIremote_ack = 0; - iIsendpos = 0; - iIrecpos = 0; - fIclosing = FALSE; - - cIsent_packets = 0; - cIreceived_packets = 0; - cIresent_packets = 0; - cIbad_hdr = 0; - cIbad_order = 0; - 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, 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; - 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. */ - csyncs = cIsyncs; - ctries = 0; - - while (TRUE) - { - boolean ftimedout; - - 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 + 4 + CCKSUMLEN, - TRUE)) - return FALSE; - - if (fiwait_for_packet (qdaemon, cIsync_timeout, 0, FALSE, - &ftimedout)) - { - if (csyncs != cIsyncs) - break; - } - else - { - if (! ftimedout) - return FALSE; - - ++ctries; - if (ctries > cIsync_retries) - { - ulog (LOG_ERROR, "Protocol startup failed"); - return FALSE; - } - } - } - - /* Calculate the window timeout. */ - ibaud = iconn_baud (qdaemon->qconn); - if (ibaud == 0) - cIwindow_timeout = cItimeout; - else - { - /* We expect to receive an ACK about halfway through each - window. In principle, an entire window might be sitting in a - modem buffer while we are waiting for an ACK. Therefore, the - minimum time we should wait for an ACK is - (1/2 window size) * (seconds / byte) + (roundtrip time) == - (1/2 window size) * (1 / (baud / 10)) + (roundtrip time) == - (1/2 window size) * (10 / baud) + (roundtrip time) == - (5 * (window size)) / baud + (roundtrip time) - - The window size is iIremote_packsize * iIremote_winsize. For - typical settings of packsize == 1024, winsize == 16, baud == - 9600, this equation works out to - (5 * 1024 * 16) / 9600 == 8 seconds - We then take cItimeout as the round trip time, which gives us - some flexibility. We get more flexibility because it is - quite likely that by the time we have finished sending out - the last packet in a window, the first one has already been - received by the remote system. */ - cIwindow_timeout = ((5 * iIremote_packsize * iIremote_winsize) / ibaud - + cItimeout); - } - - /* If we are the callee, bump both timeouts by one, to make it less - likely that both systems will timeout simultaneously. */ - if (! qdaemon->fcaller) - { - ++cItimeout; - ++cIwindow_timeout; - } - - /* We got a SYNC packet; set up packet buffers to use. */ - if (iIremote_packsize > imaxpacksize) - iIremote_packsize = imaxpacksize; - do - { - int iseq; - - for (iseq = 0; iseq < IMAXSEQ; iseq++) - { - azIrecbuffers[iseq] = NULL; - afInaked[iseq] = FALSE; - azIsendbuffers[iseq] = (char *) malloc (iIremote_packsize - + CHDRSKIPLEN - + CCKSUMLEN); - if (azIsendbuffers[iseq] == NULL) - { - int ifree; - - for (ifree = 0; ifree < iseq; ifree++) - free ((pointer) azIsendbuffers[ifree]); - break; - } - } - - if (iseq >= IMAXSEQ) - { - *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; - } - - iIremote_packsize >>= 1; - } - while (iIremote_packsize > 200); - - ulog (LOG_ERROR, - "'%c' protocol startup failed; insufficient memory for packets", - qdaemon->qproto->bname); - - return FALSE; -} - -/* Shut down the protocol. We can be fairly informal about this, - since we know that the upper level protocol has already exchanged - hangup messages. If we didn't know that, we would have to make - sure that all packets before the CLOSE had been received. */ - -boolean -fishutdown (qdaemon) - struct sdaemon *qdaemon; -{ - char *z; - size_t clen; - - fIclosing = TRUE; - - z = zigetspace (qdaemon, &clen) - CHDRLEN; - - z[IHDR_INTRO] = IINTRO; - z[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, 0); - z[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0); - iIlocal_ack = iIrecseq; - z[IHDR_CONTENTS1] = IHDRCON_SET1 (CLOSE, qdaemon->fcaller, 0); - z[IHDR_CONTENTS2] = IHDRCON_SET2 (CLOSE, qdaemon->fcaller, 0); - z[IHDR_CHECK] = IHDRCHECK_VAL (z); - - DEBUG_MESSAGE0 (DEBUG_PROTO, "fishutdown: Sending CLOSE"); - - if (! (*pfIsend) (qdaemon->qconn, z, CHDRLEN, FALSE)) - return FALSE; - - ulog (LOG_NORMAL, - "Protocol '%c' packets: sent %ld, resent %ld, received %ld", - qdaemon->qproto->bname, cIsent_packets, cIresent_packets, - cIreceived_packets); - if (cIbad_hdr != 0 - || cIbad_cksum != 0 - || cIbad_order != 0 - || cIremote_rejects != 0) - ulog (LOG_NORMAL, - "Errors: header %ld, checksum %ld, order %ld, remote rejects %ld", - cIbad_hdr, cIbad_cksum, cIbad_order, cIremote_rejects); - - /* Reset the protocol parameters to their default values. */ - iIrequest_packsize = IREQUEST_PACKSIZE; - iIrequest_winsize = IREQUEST_WINSIZE; - iIforced_remote_packsize = 0; - cIsync_timeout = CSYNC_TIMEOUT; - cIsync_retries = CSYNC_RETRIES; - cItimeout = CTIMEOUT; - cIwindow_timeout = CTIMEOUT; - cIretries = CRETRIES; - cIerrors = CERRORS; - cIerror_decay = CERROR_DECAY; - cIack_frequency = 0; - zJavoid_parameter = ZAVOID; - - return TRUE; -} - -/* Send a command string. These are just sent as normal packets, - ending in a packet containing a null byte. */ - -boolean -fisendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - size_t clen; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fisendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - - while (TRUE) - { - char *zpacket; - size_t csize; - - zpacket = zigetspace (qdaemon, &csize); - - if (clen < csize) - { - memcpy (zpacket, z, clen + 1); - return fisenddata (qdaemon, zpacket, clen + 1, ilocal, iremote, - (long) -1); - } - - memcpy (zpacket, z, csize); - z += csize; - clen -= csize; - - if (! fisenddata (qdaemon, zpacket, csize, ilocal, iremote, (long) -1)) - return FALSE; - } - /*NOTREACHED*/ -} - -/* Send a NAK. */ - -static boolean -finak (qdaemon, iseq) - struct sdaemon *qdaemon; - int iseq; -{ - char abnak[CHDRLEN]; - - abnak[IHDR_INTRO] = IINTRO; - abnak[IHDR_LOCAL] = IHDRWIN_SET (iseq, 0); - abnak[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0); - iIlocal_ack = iIrecseq; - abnak[IHDR_CONTENTS1] = IHDRCON_SET1 (NAK, qdaemon->fcaller, 0); - abnak[IHDR_CONTENTS2] = IHDRCON_SET2 (NAK, qdaemon->fcaller, 0); - abnak[IHDR_CHECK] = IHDRCHECK_VAL (abnak); - - afInaked[iseq] = TRUE; - - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "finak: Sending NAK %d", iseq); - - return (*pfIsend) (qdaemon->qconn, abnak, CHDRLEN, TRUE); -} - -/* Resend the latest packet the remote has not acknowledged. */ - -static boolean -firesend (qdaemon) - struct sdaemon *qdaemon; -{ - int iseq; - char *zhdr; - size_t clen; - - iseq = INEXTSEQ (iIremote_ack); - if (iseq == iIsendseq) - { - /* Everything has been ACKed and there is nothing to resend. */ - return TRUE; - } - - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "firesend: Resending packet %d", iseq); - - /* Update the received sequence number. */ - zhdr = azIsendbuffers[iseq] + CHDROFFSET; - if (IHDRWIN_GETSEQ (zhdr[IHDR_REMOTE]) != iIrecseq) - { - int iremote; - - iremote = IHDRWIN_GETCHAN (zhdr[IHDR_REMOTE]); - zhdr[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote); - zhdr[IHDR_CHECK] = IHDRCHECK_VAL (zhdr); - iIlocal_ack = iIrecseq; - } - - ++cIresent_packets; - - clen = CHDRCON_GETBYTES (zhdr[IHDR_CONTENTS1], - zhdr[IHDR_CONTENTS2]); - - return (*pfIsend) (qdaemon->qconn, zhdr, - CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0), - TRUE); -} - -/* Wait until there is an opening in the receive window of the remote - system. */ - -static boolean -fiwindow_wait (qdaemon) - struct sdaemon *qdaemon; -{ - /* iIsendseq is the sequence number we are sending, and iIremote_ack - is the last sequence number acknowledged by the remote. */ - while (CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize) - { - /* If a NAK is lost, it is possible for the other side to be - sending a stream of packets while we are waiting for an ACK. - This should be caught in fiprocess_data; if it is about to - send an ACK, but it has an unacknowledged packet to send, it - sends the entire packet. Hopefully that will trigger an ACK - or a NAK and get us going again. */ - DEBUG_MESSAGE0 (DEBUG_PROTO, "fiwindow_wait: Waiting for ACK"); - if (! fiwait_for_packet (qdaemon, cIwindow_timeout, cIretries, - TRUE, (boolean *) NULL)) - return FALSE; - } - - return TRUE; -} - -/* Get buffer space to use for packet data. We return a pointer to - the space to be used for the actual data, leaving room for the - header. */ - -/*ARGSUSED*/ -char * -zigetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = iIremote_packsize; - return azIsendbuffers[iIsendseq] + CHDRSKIPLEN; -} - -/* Send a data packet. The zdata argument will always point to value - returned by zigetspace, so we know that we have room before it for - the header information. */ - -boolean -fisenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ - char *zhdr; - unsigned long icksum; - boolean fret; - -#if DEBUG > 0 - if (ilocal < 0 || ilocal >= IMAXICHAN - || iremote < 0 || iremote >= IMAXICHAN) - ulog (LOG_FATAL, "fisenddata: ilocal %d iremote %d", ilocal, iremote); -#endif - - /* If we are changing the file position, we must send an SPOS - packet. */ - if (ipos != iIsendpos && ipos != (long) -1) - { - int inext; - char *zspos; - - /* We need to get a buffer to hold the SPOS packet, and it needs - to be next sequence number. However, the data we have been - given is currently in the next sequence number buffer. So we - shuffle the buffers around. */ - inext = INEXTSEQ (iIsendseq); - zspos = azIsendbuffers[inext]; - azIsendbuffers[inext] = zdata - CHDRSKIPLEN; - azIsendbuffers[iIsendseq] = zspos; - zspos += CHDROFFSET; - - zspos[IHDR_INTRO] = IINTRO; - zspos[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, 0); - zspos[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0); - iIlocal_ack = iIrecseq; - zspos[IHDR_CONTENTS1] = IHDRCON_SET1 (SPOS, qdaemon->fcaller, - CCKSUMLEN); - zspos[IHDR_CONTENTS2] = IHDRCON_SET2 (SPOS, qdaemon->fcaller, - CCKSUMLEN); - zspos[IHDR_CHECK] = IHDRCHECK_VAL (zspos); - UCKSUM_SET (zspos + CHDRLEN, (unsigned long) ipos); - icksum = icrc (zspos + CHDRLEN, CCKSUMLEN, ICRCINIT); - UCKSUM_SET (zspos + CHDRLEN + CCKSUMLEN, icksum); - - /* Wait for an opening in the window. */ - if (iIremote_winsize > 0 - && CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize) - { - if (! fiwindow_wait (qdaemon)) - return FALSE; - } - - DEBUG_MESSAGE1 (DEBUG_PROTO, "fisenddata: Sending SPOS %ld", - ipos); - - if (! (*pfIsend) (qdaemon->qconn, zspos, - CHDRLEN + CCKSUMLEN + CCKSUMLEN, TRUE)) - return FALSE; - - iIsendseq = INEXTSEQ (iIsendseq); - iIsendpos = ipos; - } - - zhdr = zdata - CHDRLEN; - zhdr[IHDR_INTRO] = IINTRO; - zhdr[IHDR_LOCAL] = IHDRWIN_SET (iIsendseq, ilocal); - zhdr[IHDR_CONTENTS1] = IHDRCON_SET1 (DATA, qdaemon->fcaller, cdata); - zhdr[IHDR_CONTENTS2] = IHDRCON_SET2 (DATA, qdaemon->fcaller, cdata); - - /* Compute and set the checksum. */ - if (cdata > 0) - { - icksum = icrc (zdata, cdata, ICRCINIT); - UCKSUM_SET (zdata + cdata, icksum); - } - - /* Wait until there is an opening in the window (we hope to not have - to wait here at all, actually; ideally the window should be large - enough to avoid a wait). */ - if (iIremote_winsize > 0 - && CSEQDIFF (iIsendseq, iIremote_ack) > iIremote_winsize) - { - if (! fiwindow_wait (qdaemon)) - return FALSE; - } - - /* We only fill in IHDR_REMOTE now, since only now do know the - correct value of iIrecseq. */ - zhdr[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, iremote); - iIlocal_ack = iIrecseq; - zhdr[IHDR_CHECK] = IHDRCHECK_VAL (zhdr); - - DEBUG_MESSAGE4 (DEBUG_PROTO, - "fisenddata: Sending packet %d size %d local %d remote %d", - iIsendseq, (int) cdata, ilocal, iremote); - - iIsendseq = INEXTSEQ (iIsendseq); - ++cIsent_packets; - - fret = (*pfIsend) (qdaemon->qconn, zhdr, - cdata + CHDRLEN + (cdata > 0 ? CCKSUMLEN : 0), - TRUE); - - iIsendpos += cdata; - - if (fret && iPrecstart != iPrecend) - { - boolean fexit; - - fret = fiprocess_data (qdaemon, &fexit, (boolean *) NULL, - (size_t *) NULL); - } - - return fret; -} - -/* Wait for data to come in. */ - -boolean -fiwait (qdaemon) - struct sdaemon *qdaemon; -{ - return fiwait_for_packet (qdaemon, cItimeout, cIretries, - FALSE, (boolean *) NULL); -} - -/* Wait for a packet. Either there is no data to send, or the remote - window is full. */ - -static boolean -fiwait_for_packet (qdaemon, ctimeout, cretries, fone, pftimedout) - struct sdaemon *qdaemon; - int ctimeout; - int cretries; - boolean fone; - boolean *pftimedout; -{ - int cshort; - int ctimeouts; - - if (pftimedout != NULL) - *pftimedout = FALSE; - - cshort = 0; - ctimeouts = 0; - - while (TRUE) - { - boolean fexit, ffound; - size_t cneed; - size_t crec; - - if (! fiprocess_data (qdaemon, &fexit, &ffound, &cneed)) - return FALSE; - - if (fexit || (fone && ffound)) - return TRUE; - - if (cneed == 0) - continue; - - DEBUG_MESSAGE1 (DEBUG_PROTO, "fiwait_for_packet: Need %d bytes", - (int) cneed); - - if (! (*pfIreceive) (qdaemon->qconn, cneed, &crec, ctimeout, TRUE)) - return FALSE; - - if (crec != 0) - { - /* If we didn't get enough data twice in a row, we may have - dropped some data and be waiting for the end of a large - packet. Incrementing iPrecstart will force - fiprocess_data to skip the current packet and try to find - the next one. */ - if (crec >= cneed) - cshort = 0; - else - { - ++cshort; - if (cshort > 1) - { - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - cshort = 0; - } - } - } - else - { - int i; - - /* We timed out on the read. */ - ++ctimeouts; - if (ctimeouts > cretries) - { - if (cretries > 0) - ulog (LOG_ERROR, "Timed out waiting for packet"); - if (pftimedout != NULL) - *pftimedout = TRUE; - return FALSE; - } - - /* Clear out the list of packets we have sent NAKs for. We - should have seen some sort of response by now. */ - for (i = 0; i < IMAXSEQ; i++) - afInaked[i] = FALSE; - - /* Send a NAK for the packet we want, and, if we have an - unacknowledged packet, send it again. */ - if (! finak (qdaemon, INEXTSEQ (iIrecseq)) - || ! firesend (qdaemon)) - return FALSE; - } - } - /*NOTREACHED*/ -} - -/* Make sure we haven't overflowed the permissible error level. */ - -static boolean -ficheck_errors (qdaemon) - struct sdaemon *qdaemon; -{ - if (cIerrors < 0) - return TRUE; - - if (((cIbad_order + cIbad_hdr + cIbad_cksum + cIremote_rejects) - - (cIreceived_packets / cIerror_decay)) - > cIerrors) - { - /* Try shrinking the packet size. */ - if (iIrequest_packsize > 400) - { - 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); - absync[IHDR_REMOTE] = IHDRWIN_SET (iIrecseq, 0); - iIlocal_ack = iIrecseq; - absync[IHDR_CONTENTS1] = IHDRCON_SET1 (SYNC, qdaemon->fcaller, 3); - absync[IHDR_CONTENTS2] = IHDRCON_SET2 (SYNC, qdaemon->fcaller, 3); - absync[IHDR_CHECK] = IHDRCHECK_VAL (absync); - absync[CHDRLEN + 0] = (iIrequest_packsize >> 8) & 0xff; - absync[CHDRLEN + 1] = iIrequest_packsize & 0xff; - absync[CHDRLEN + 2] = iIrequest_winsize; - icksum = icrc (absync + CHDRLEN, 3, ICRCINIT); - UCKSUM_SET (absync + CHDRLEN + 3, icksum); - - cIerrors *= 2; - - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "ficheck_errors: Sending SYNC packsize %d winsize %d", - iIrequest_packsize, iIrequest_winsize); - - return (*pfIsend) (qdaemon->qconn, absync, - CHDRLEN + 3 + CCKSUMLEN, TRUE); - } - - ulog (LOG_ERROR, "Too many '%c' protocol errors", - qdaemon->qproto->bname); - return FALSE; - } - - return TRUE; -} - -/* Process data waiting in the receive buffer, passing to the - fgot_data function. */ - -static boolean -fiprocess_data (qdaemon, pfexit, pffound, pcneed) - struct sdaemon *qdaemon; - boolean *pfexit; - boolean *pffound; - size_t *pcneed; -{ - boolean fbadhdr; - - if (pfexit != NULL) - *pfexit = FALSE; - if (pffound != NULL) - *pffound = FALSE; - - fbadhdr = FALSE; - - while (iPrecstart != iPrecend) - { - char ab[CHDRLEN]; - int cfirst, csecond; - char *zfirst, *zsecond; - int i; - int iget; - int ttype; - int iseq; - int csize; - int iack; - - /* If we're closing the connection, ignore any data remaining in - the input buffer. */ - if (fIclosing) - { - if (pfexit != NULL) - *pfexit = TRUE; - if (pcneed != NULL) - *pcneed = 0; - return TRUE; - } - - /* Look for the IINTRO character. */ - if (abPrecbuf[iPrecstart] != IINTRO) - { - char *zintro; - int cintro; - - cintro = iPrecend - iPrecstart; - if (cintro < 0) - cintro = CRECBUFLEN - iPrecstart; - - zintro = memchr (abPrecbuf + iPrecstart, IINTRO, (size_t) cintro); - - if (zintro == NULL) - { - iPrecstart = (iPrecstart + cintro) % CRECBUFLEN; - continue; - } - - /* We don't need % CRECBUFLEN here because zintro - (abPrecbuf - + iPrecstart) < cintro <= CRECBUFLEN - iPrecstart. */ - iPrecstart += zintro - (abPrecbuf + iPrecstart); - } - - /* Get the header into ab. */ - for (i = 0, iget = iPrecstart; - i < CHDRLEN && iget != iPrecend; - i++, iget = (iget + 1) % CRECBUFLEN) - ab[i] = abPrecbuf[iget]; - - if (i < CHDRLEN) - { - if (pcneed != NULL) - *pcneed = CHDRLEN - i; - return TRUE; - } - - if ((ab[IHDR_CHECK] & 0xff) != IHDRCHECK_VAL (ab) - || (FHDRCON_GETCALLER (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2]) - ? qdaemon->fcaller : ! qdaemon->fcaller)) - { - /* We only report a single bad header message per call, to - avoid generating many errors if we get many INTRO bytes - in a row. */ - if (! fbadhdr) - { - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Bad header"); - - ++cIbad_hdr; - if (! ficheck_errors (qdaemon)) - return FALSE; - - fbadhdr = TRUE; - } - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - zfirst = zsecond = NULL; - cfirst = csecond = 0; - - ttype = THDRCON_GETTYPE (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2]); - if (ttype == DATA || ttype == SPOS || ttype == CLOSE) - iseq = IHDRWIN_GETSEQ (ab[IHDR_LOCAL]); - else - iseq = -1; - csize = CHDRCON_GETBYTES (ab[IHDR_CONTENTS1], ab[IHDR_CONTENTS2]); - - if (iseq != -1) - { - /* Make sure this packet is in our receive window. The last - packet we have acked is iIlocal_ack. */ - if (iIrequest_winsize > 0 - && CSEQDIFF (iseq, iIlocal_ack) > iIrequest_winsize) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Out of order packet %d (ack %d)", - iseq, iIlocal_ack); - - ++cIbad_order; - if (! ficheck_errors (qdaemon)) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - - continue; - } - } - - if (csize > 0) - { - int cinbuf; - char abcksum[CCKSUMLEN]; - unsigned long ickdata; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - if (cinbuf < CHDRLEN + csize + CCKSUMLEN) - { - if (pcneed != NULL) - *pcneed = CHDRLEN + csize + CCKSUMLEN - cinbuf; - return TRUE; - } - - if (iPrecend > iPrecstart) - { - cfirst = csize; - zfirst = abPrecbuf + iPrecstart + CHDRLEN; - } - else - { - cfirst = CRECBUFLEN - (iPrecstart + CHDRLEN); - if (cfirst <= 0) - { - /* Here cfirst is non-positive, so subtracting from - abPrecbuf will actually skip the appropriate number - of bytes at the start of abPrecbuf. */ - zfirst = abPrecbuf - cfirst; - cfirst = csize; - } - else - { - if (cfirst >= csize) - cfirst = csize; - else - { - zsecond = abPrecbuf; - csecond = csize - cfirst; - } - zfirst = abPrecbuf + iPrecstart + CHDRLEN; - } - } - - /* Get the checksum into abcksum. */ - for (i = 0, iget = (iPrecstart + CHDRLEN + csize) % CRECBUFLEN; - i < CCKSUMLEN; - i++, iget = (iget + 1) % CRECBUFLEN) - abcksum[i] = abPrecbuf[iget]; - - ickdata = icrc (zfirst, (size_t) cfirst, ICRCINIT); - if (csecond > 0) - ickdata = icrc (zsecond, (size_t) csecond, ickdata); - - if (ICKSUM_GET (abcksum) != ickdata) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Bad checksum; data %lu, frame %lu", - ickdata, ICKSUM_GET (abcksum)); - - ++cIbad_cksum; - if (! ficheck_errors (qdaemon)) - return FALSE; - - /* If this sequence number is in our receive window, - send a NAK. iIrecseq is the last sequence number we - have succesfully received. */ - if (iseq != -1 - && iseq != iIrecseq - && (iIrequest_winsize <= 0 - || CSEQDIFF (iseq, iIrecseq) <= iIrequest_winsize) - && azIrecbuffers[iseq] == NULL) - { - if (! finak (qdaemon, iseq)) - return FALSE; - } - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - } - - /* Here we know that this is a valid packet, so we can adjust - iPrecstart accordingly. */ - if (csize == 0) - iPrecstart = (iPrecstart + CHDRLEN) % CRECBUFLEN; - else - { - iPrecstart = ((iPrecstart + CHDRLEN + csize + CCKSUMLEN) - % CRECBUFLEN); - ++cIreceived_packets; - } - - /* Get the ack from the packet, if appropriate. iIsendseq is - the next sequence number we are going to send, and - iIremote_ack is the last sequence number acknowledged by the - remote system. */ - iack = IHDRWIN_GETSEQ (ab[IHDR_REMOTE]); - if (iIremote_winsize > 0 - && iack != iIsendseq - && CSEQDIFF (iack, iIremote_ack) <= iIremote_winsize - && CSEQDIFF (iIsendseq, iack) <= iIremote_winsize) - { - /* Call uwindow_acked each time packet 0 is acked. */ - if (iack < iIremote_ack) - uwindow_acked (qdaemon, FALSE); - iIremote_ack = iack; - } - - if (iseq != -1) - { - /* 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. */ - if (iseq != INEXTSEQ (iIrecseq)) - { - if (iseq == iIrecseq - || (iIrequest_winsize > 0 - && CSEQDIFF (iseq, iIrecseq) > iIrequest_winsize)) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Ignoring out of order packet %d (recseq %d)", - iseq, iIrecseq); - continue; - } - else - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fiprocess_data: Saving unexpected packet %d (recseq %d)", - iseq, iIrecseq); - - if (azIrecbuffers[iseq] == NULL) - { - azIrecbuffers[iseq] = zbufalc ((size_t) (CHDRLEN - + csize)); - memcpy (azIrecbuffers[iseq], ab, CHDRLEN); - if (csize > 0) - { - memcpy (azIrecbuffers[iseq] + CHDRLEN, zfirst, - (size_t) cfirst); - if (csecond > 0) - memcpy (azIrecbuffers[iseq] + CHDRLEN + cfirst, - zsecond, (size_t) csecond); - } - } - } - - /* Send NAK's for each packet between the last one we - received and this one, avoiding any packets for which - we've already sent NAK's or which we've already - received. */ - for (i = INEXTSEQ (iIrecseq); - i != iseq; - i = INEXTSEQ (i)) - { - if (! afInaked[i] - && azIrecbuffers[i] == NULL) - { - if (! finak (qdaemon, i)) - return FALSE; - } - } - - continue; - } - - iIrecseq = iseq; - } - - if (pffound != NULL) - *pffound = TRUE; - - if (! fiprocess_packet (qdaemon, ab, zfirst, cfirst, zsecond, csecond, - pfexit)) - return FALSE; - - if (iseq != -1) - { - int inext; - - /* If we've already received the next packet(s), process - them. */ - inext = INEXTSEQ (iIrecseq); - while (azIrecbuffers[inext] != NULL) - { - char *z; - int c; - - z = azIrecbuffers[inext]; - c = CHDRCON_GETBYTES (z[IHDR_CONTENTS1], z[IHDR_CONTENTS2]); - iIrecseq = inext; - if (! fiprocess_packet (qdaemon, z, z + CHDRLEN, c, - (char *) NULL, 0, pfexit)) - return FALSE; - ubuffree (azIrecbuffers[inext]); - azIrecbuffers[inext] = NULL; - inext = INEXTSEQ (inext); - } - } - - /* If we have received half of our window size or more since the - last ACK, send one now. Sending an ACK for half the window - at a time should significantly cut the acknowledgement - traffic when only one side is sending. We should normally - not have to send an ACK if we have data to send, since each - packet sent will ACK the most recently received packet. - 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) >= cIack_frequency) - { - 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, "fiprocess_data: Sending ACK %d", - iIrecseq); - - if (! (*pfIsend) (qdaemon->qconn, aback, CHDRLEN, TRUE)) - return FALSE; - } - } - - if (pcneed != NULL) - *pcneed = CHDRLEN; - - return TRUE; -} - -/* Process a single packet. */ - -static boolean -fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit) - struct sdaemon *qdaemon; - const char *zhdr; - const char *zfirst; - int cfirst; - const char *zsecond; - int csecond; - boolean *pfexit; -{ - int ttype; - - ttype = THDRCON_GETTYPE (zhdr[IHDR_CONTENTS1], zhdr[IHDR_CONTENTS2]); - switch (ttype) - { - case DATA: - { - int iseq; - boolean fret; - - iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]); - 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]), - IHDRWIN_GETCHAN (zhdr[IHDR_LOCAL]), - iIrecpos, - INEXTSEQ (iIremote_ack) == iIsendseq, - pfexit); - iIrecpos += cfirst + csecond; - return fret; - } - - case SYNC: - { - int ipack, iwin, cchans; - - /* We accept a SYNC packet to adjust the packet and window - sizes at any time. */ - if (cfirst + csecond < 3) - { - ulog (LOG_ERROR, "Bad SYNC packet"); - return FALSE; - } - ipack = (zfirst[0] & 0xff) << 8; - if (cfirst > 1) - ipack |= zfirst[1] & 0xff; - else - ipack |= zsecond[0]; - if (cfirst > 2) - iwin = zfirst[2]; - else - iwin = zsecond[2 - cfirst]; - - /* 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; - iIremote_winsize = iwin; - - /* We increment a static variable to tell the initialization - code that a SYNC was received, and we set *pfexit to TRUE - to get out to the initialization code (this will do no harm - if we are called from elsewhere). */ - ++cIsyncs; - *pfexit = TRUE; - return TRUE; - } - - case ACK: - /* There is nothing to do here, since the ack was already - handled in fiprocess_data. */ - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fiprocess_packet: Got ACK %d", - IHDRWIN_GETSEQ (zhdr[IHDR_REMOTE])); - return TRUE; - - case NAK: - /* We must resend the requested packet. */ - { - int iseq; - char *zsend; - size_t clen; - - ++cIremote_rejects; - if (! ficheck_errors (qdaemon)) - return FALSE; - - iseq = IHDRWIN_GETSEQ (zhdr[IHDR_LOCAL]); - - /* 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) - { - 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, "fiprocess_packet: Sending ACK %d", - iIrecseq); - - return (*pfIsend) (qdaemon->qconn, aback, CHDRLEN, TRUE); - } - else - { - 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; - } - - 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; - - clen = CHDRCON_GETBYTES (zsend[IHDR_CONTENTS1], - zsend[IHDR_CONTENTS2]); - - return (*pfIsend) (qdaemon->qconn, zsend, - CHDRLEN + clen + (clen > 0 ? CCKSUMLEN : 0), - TRUE); - } - } - - case SPOS: - /* Set the file position. */ - { - char abpos[CCKSUMLEN]; - const char *zpos; - - if (cfirst >= CCKSUMLEN) - zpos = zfirst; - else - { - memcpy (abpos, zfirst, (size_t) cfirst); - memcpy (abpos + cfirst, zsecond, (size_t) (CCKSUMLEN - cfirst)); - zpos = abpos; - } - iIrecpos = (long) ICKSUM_GET (zpos); - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fiprocess_packet: Got SPOS %ld", iIrecpos); - return TRUE; - } - - case CLOSE: - { - boolean fexpected; - - fexpected = ! fLog_sighup || fIclosing; - if (! fexpected) - ulog (LOG_ERROR, "Received unexpected CLOSE packet"); - else - DEBUG_MESSAGE0 (DEBUG_PROTO, "fiprocess_packet: Got CLOSE packet"); - - fIclosing = TRUE; - *pfexit = TRUE; - return fexpected; - } - - default: - /* Just ignore unrecognized packet types, for future protocol - enhancements. */ - DEBUG_MESSAGE1 (DEBUG_PROTO, "fiprocess_packet: Got packet type %d", - ttype); - return TRUE; - } - /*NOTREACHED*/ -} diff --git a/gnu/libexec/uucp/uucico/protj.c b/gnu/libexec/uucp/uucico/protj.c deleted file mode 100644 index bb46f72..0000000 --- a/gnu/libexec/uucp/uucico/protj.c +++ /dev/null @@ -1,672 +0,0 @@ -/* protj.c - The 'j' protocol. - - Copyright (C) 1992, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char protj_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* The 'j' protocol. - - The 'j' protocol is a wrapper around the 'i' protocol, which avoids - the use of certain characters, such as XON and XOFF. - - Each 'j' protocol packet begins with a '^' character, followed by a - two byte encoded size giving the total number of bytes in the - packet. The first byte is HIGH, the second byte is LOW, and the - number of bytes is (HIGH - 32) * 64 + (LOW - 32), where 32 <= HIGH - < 127 and 32 <= LOW < 96 (i.e., HIGH and LOW are printable ASCII - characters). This is followed by a '=' character. The next two - bytes are the number of data bytes in the packet, using the same - encoding. This is followed by a '@' character, and then that - number of data bytes. The remaining bytes in the packet are - indices of bytes which must be transformed, followed by a trailing - '~' character. The indices are encoded in the following overly - complex format. - - Each byte index is two bytes long. The first byte in the index is - INDEX-HIGH and the second is INDEX-LOW. If 32 <= INDEX-HIGH < 126, - the byte index refers to the byte at position (INDEX-HIGH - 32) * - 32 + INDEX-LOW % 32 in the actual data, where 32 <= INDEX-LOW < - 127. If 32 <= INDEX-LOW < 64, then 128 must be added to the - indexed byte. If 64 <= INDEX-LOW < 96, then the indexed byte must - be exclusive or'red with 32. If 96 <= INDEX-LOW < 127, both - operations must be performed. If INDEX-HIGH == 126, then the byte - index refers to the byte at position (INDEX-LOW - 32) * 32 + 31, - where 32 <= INDEX-LOW < 126. 128 must be added to the byte, and it - must be exclusive or'red with 32. This unfortunately requires a - special test (when encoding INDEX-LOW must be checked for 127; when - decoding INDEX-HIGH must be checked for 126). It does, however, - permit the byte indices field to consist exclusively of printable - ASCII characters. - - The maximum value for a byte index is (125 - 32) * 32 + 31 == 3007, - so the is the maximum number of data bytes permitted. Since it is - convenient to have each 'j' protocol packet correspond to each 'i' - protocol packet, we restrict the 'i' protocol accordingly. - - Note that this encoding method assumes that we can send all - printable ASCII characters. */ - -/* The first byte of each packet. I just picked these values - randomly, trying to get characters that were perhaps slightly less - likely to appear in normal text. */ -#define FIRST '\136' - -/* The fourth byte of each packet. */ -#define FOURTH '\075' - -/* The seventh byte of each packet. */ -#define SEVENTH '\100' - -/* The trailing byte of each packet. */ -#define TRAILER '\176' - -/* The length of the header. */ -#define CHDRLEN (7) - -/* Get a number of bytes encoded in a two byte length at the start of - a packet. */ -#define CGETLENGTH(b1, b2) (((b1) - 32) * 64 + ((b2) - 32)) - -/* Set the high and low bytes of a two byte length at the start of a - packet. */ -#define ISETLENGTH_FIRST(i) ((i) / 64 + 32) -#define ISETLENGTH_SECOND(i) ((i) % 64 + 32) - -/* The maximum packet size we support, as determined by the byte - indices. */ -#define IMAXPACKSIZE ((125 - 32) * 32 + 31) - -/* Amount to offset the bytes in the byte index by. */ -#define INDEX_OFFSET (32) - -/* Maximum value of INDEX-LOW, before offsetting. */ -#define INDEX_MAX_LOW (32) - -/* Maximum value of INDEX-HIGH, before offsetting. */ -#define INDEX_MAX_HIGH (94) - -/* The set of characters to avoid. */ -static char *zJavoid; - -/* The number of characters to avoid. */ -static size_t cJavoid; - -/* A buffer used when sending data. */ -static char *zJbuf; - -/* The end of the undecoded data in abPrecbuf. */ -static int iJrecend; - -/* Local functions. */ -static boolean fjsend_data P((struct sconnection *qconn, const char *zsend, - size_t csend, boolean fdoread)); -static boolean fjreceive_data P((struct sconnection *qconn, size_t cneed, - size_t *pcrec, int ctimeout, - boolean freport)); -static boolean fjprocess_data P((size_t *pcneed)); - -/* Start the protocol. We first send over the list of characters to - avoid as an escape sequence, starting with FIRST and ending with - TRAILER. There is no error checking done on this string. */ - -boolean -fjstart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - size_t clen; - char *zsend; - int b; - size_t cbuf, cgot; - char *zbuf; - int i; - - /* Send the characters we want to avoid to the other side. */ - clen = strlen (zJavoid_parameter); - zsend = zbufalc (clen + 3); - zsend[0] = FIRST; - memcpy (zsend + 1, zJavoid_parameter, clen); - zsend[clen + 1] = TRAILER; - zsend[clen + 2] = '\0'; - if (! fsend_data (qdaemon->qconn, zsend, clen + 2, TRUE)) - { - ubuffree (zsend); - return FALSE; - } - ubuffree (zsend); - - /* Read the characters the other side wants to avoid. */ - while ((b = breceive_char (qdaemon->qconn, cIsync_timeout, TRUE)) - != FIRST) - { - if (b < 0) - { - if (b == -1) - ulog (LOG_ERROR, "Timed out in 'j' protocol startup"); - return FALSE; - } - } - - cbuf = 20; - zbuf = zbufalc (cbuf); - cgot = 0; - while ((b = breceive_char (qdaemon->qconn, cIsync_timeout, TRUE)) - != TRAILER) - { - if (b < 0) - { - ubuffree (zbuf); - if (b == -1) - ulog (LOG_ERROR, "Timed out in 'j' protocol startup"); - return FALSE; - } - if (cgot + 1 >= cbuf) - { - char *znew; - - cbuf += 20; - znew = zbufalc (cbuf); - memcpy (znew, zbuf, cgot); - ubuffree (zbuf); - zbuf = znew; - } - zbuf[cgot] = b; - ++cgot; - } - zbuf[cgot] = '\0'; - - /* Merge the local and remote avoid bytes into one list, translated - into bytes. */ - cgot = cescape (zbuf); - - clen = strlen (zJavoid_parameter); - zJavoid = zbufalc (clen + cgot + 1); - memcpy (zJavoid, zJavoid_parameter, clen + 1); - cJavoid = cescape (zJavoid); - - for (i = 0; i < cgot; i++) - { - if (memchr (zJavoid, zbuf[i], cJavoid) == NULL) - { - zJavoid[cJavoid] = zbuf[i]; - ++cJavoid; - } - } - - ubuffree (zbuf); - - /* We can't avoid ASCII printable characters, since the encoding - method assumes that they can always be sent. If it ever turns - out to be important, a different encoding method could be used, - perhaps keyed by a different FIRST character. */ - if (cJavoid == 0) - { - ulog (LOG_ERROR, "No characters to avoid in 'j' protocol"); - return FALSE; - } - for (i = 0; i < cJavoid; i++) - { - if (zJavoid[i] >= 32 && zJavoid[i] <= 126) - { - ulog (LOG_ERROR, "'j' protocol can't avoid character '\\%03o'", - zJavoid[i]); - return FALSE; - } - } - - /* If we are avoiding XON and XOFF, use XON/XOFF handshaking. */ - if (memchr (zJavoid, '\021', cJavoid) != NULL - && memchr (zJavoid, '\023', cJavoid) != NULL) - { - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_ON)) - return FALSE; - } - - /* Let the port settle. */ - usysdep_sleep (2); - - /* Allocate a buffer we use when sending data. We will probably - never actually need one this big; if this code is ported to a - computer with small amounts of memory, this should be changed to - increase the buffer size as needed. */ - zJbuf = zbufalc (CHDRLEN + IMAXPACKSIZE * 3 + 1); - zJbuf[0] = FIRST; - zJbuf[3] = FOURTH; - zJbuf[6] = SEVENTH; - - /* iJrecend is the end of the undecoded data, and iPrecend is the - end of the decoded data. At this point there is no decoded data, - and we must initialize the variables accordingly. */ - iJrecend = iPrecend; - iPrecend = iPrecstart; - - /* Now do the 'i' protocol startup. */ - return fijstart (qdaemon, pzlog, IMAXPACKSIZE, fjsend_data, - fjreceive_data); -} - -/* Shut down the protocol. */ - -boolean -fjshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - boolean fret; - - fret = fishutdown (qdaemon); - ubuffree (zJavoid); - ubuffree (zJbuf); - return fret; -} - -/* Encode a packet of data and send it. This copies the data, which - is a waste of time, but calling fsend_data three times (for the - header, the body, and the trailer) would waste even more time. */ - -static boolean -fjsend_data (qconn, zsend, csend, fdoread) - struct sconnection *qconn; - const char *zsend; - size_t csend; - boolean fdoread; -{ - char *zput, *zindex; - const char *zfrom, *zend; - char bfirst, bsecond; - int iprecendhold; - boolean fret; - - zput = zJbuf + CHDRLEN; - zindex = zput + csend; - zfrom = zsend; - zend = zsend + csend; - - /* Optimize for the common case of avoiding two characters. */ - bfirst = zJavoid[0]; - if (cJavoid <= 1) - bsecond = bfirst; - else - bsecond = zJavoid[1]; - while (zfrom < zend) - { - char b; - boolean f128, f32; - int i, ihigh, ilow; - - b = *zfrom++; - if (b != bfirst && b != bsecond) - { - int ca; - char *za; - - if (cJavoid <= 2) - { - *zput++ = b; - continue; - } - - ca = cJavoid - 2; - za = zJavoid + 2; - while (ca-- != 0) - if (*za++ == b) - break; - - if (ca < 0) - { - *zput++ = b; - continue; - } - } - - if ((b & 0x80) == 0) - f128 = FALSE; - else - { - b &=~ 0x80; - f128 = TRUE; - } - if (b >= 32 && b != 127) - f32 = FALSE; - else - { - b ^= 0x20; - f32 = TRUE; - } - - /* We must now put the byte index into the buffer. The byte - index is encoded similarly to the length of the actual data, - but the byte index also encodes the operations that must be - performed on the byte. The first byte in the index is the - most significant bits. If we only had to subtract 128 from - the byte, we use the second byte directly. If we had to xor - the byte with 32, we add 32 to the second byte index. If we - had to perform both operations, we add 64 to the second byte - index. However, if we had to perform both operations, and - the second byte index was 31, then after adding 64 and - offsetting by 32 we would come up with 127, which we are not - permitted to use. Therefore, in this special case we set the - first byte of the index to 126 and put the original first - byte into the second byte position instead. This is why we - could not permit the high byte of the length of the actual - data to be 126. We can get away with the switch because both - the value of the second byte index (31) and the operations to - perform (both) are known. */ - i = zput - (zJbuf + CHDRLEN); - ihigh = i / INDEX_MAX_LOW; - ilow = i % INDEX_MAX_LOW; - - if (f128 && ! f32) - ; - else if (f32 && ! f128) - ilow += INDEX_MAX_LOW; - else - { - /* Both operations had to be performed. */ - if (ilow != INDEX_MAX_LOW - 1) - ilow += 2 * INDEX_MAX_LOW; - else - { - ilow = ihigh; - ihigh = INDEX_MAX_HIGH; - } - } - - *zindex++ = ihigh + INDEX_OFFSET; - *zindex++ = ilow + INDEX_OFFSET; - *zput++ = b; - } - - *zindex++ = TRAILER; - - /* Set the lengths into the buffer. zJbuf[0,3,6] were set when - zJbuf was allocated, and are never changed thereafter. */ - zJbuf[1] = ISETLENGTH_FIRST (zindex - zJbuf); - zJbuf[2] = ISETLENGTH_SECOND (zindex - zJbuf); - zJbuf[4] = ISETLENGTH_FIRST (csend); - zJbuf[5] = ISETLENGTH_SECOND (csend); - - /* Send the data over the line. We must preserve iPrecend as - discussed in fjreceive_data. */ - iprecendhold = iPrecend; - iPrecend = iJrecend; - fret = fsend_data (qconn, zJbuf, (size_t) (zindex - zJbuf), fdoread); - iJrecend = iPrecend; - iPrecend = iprecendhold; - - /* Process any bytes that may have been placed in abPrecbuf. */ - if (fret && iPrecend != iJrecend) - { - if (! fjprocess_data ((size_t *) NULL)) - return FALSE; - } - - return fret; -} - -/* Receive and decode data. This is called by fiwait_for_packet. We - need to be able to return decoded data between iPrecstart and - iPrecend, while not losing any undecoded partial packets we may - have read. We use iJrecend as a pointer to the end of the - undecoded data, and set iPrecend for the decoded data. iPrecend - points to the start of the undecoded data. */ - -static boolean -fjreceive_data (qconn, cineed, pcrec, ctimeout, freport) - struct sconnection *qconn; - size_t cineed; - size_t *pcrec; - int ctimeout; - boolean freport; -{ - int iprecendstart; - size_t cjneed; - size_t crec; - int cnew; - - iprecendstart = iPrecend; - - /* Figure out how many bytes we need to decode the next packet. */ - if (! fjprocess_data (&cjneed)) - return FALSE; - - /* As we long as we read some data but don't have enough to decode a - packet, we try to read some more. We decrease the timeout each - time so that we will not wait forever if the connection starts - dribbling data. */ - do - { - int iprecendhold; - size_t cneed; - - if (cjneed > cineed) - cneed = cjneed; - else - cneed = cineed; - - /* We are setting iPrecend to the end of the decoded data for - the 'i' protocol. When we do the actual read, we have to set - it to the end of the undecoded data so that any undecoded - data we have received is not overwritten. */ - iprecendhold = iPrecend; - iPrecend = iJrecend; - if (! freceive_data (qconn, cneed, &crec, ctimeout, freport)) - return FALSE; - iJrecend = iPrecend; - iPrecend = iprecendhold; - - /* Process any data we have received. This will set iPrecend to - the end of the new decoded data. */ - if (! fjprocess_data (&cjneed)) - return FALSE; - - cnew = iPrecend - iprecendstart; - if (cnew < 0) - cnew += CRECBUFLEN; - - if (cnew > cineed) - cineed = 0; - else - cineed -= cnew; - - --ctimeout; - } - while (cnew == 0 && crec > 0 && ctimeout > 0); - - DEBUG_MESSAGE1 (DEBUG_PROTO, "fjreceive_data: Got %d decoded bytes", - cnew); - - *pcrec = cnew; - return TRUE; -} - -/* Decode the data in the buffer, optionally returning the number of - bytes needed to complete the next packet. */ - -static boolean -fjprocess_data (pcneed) - size_t *pcneed; -{ - int istart; - - istart = iPrecend; - while (istart != iJrecend) - { - int i, iget; - char ab[CHDRLEN]; - int cpacket, cdata, chave; - int iindex, iendindex; - - /* Find the next occurrence of FIRST. If we have to skip some - garbage bytes to get to it, zero them out (so they don't - confuse the 'i' protocol) and advance iPrecend. This will - save us from looking at them again. */ - if (abPrecbuf[istart] != FIRST) - { - int cintro; - char *zintro; - size_t cskipped; - - cintro = iJrecend - istart; - if (cintro < 0) - cintro = CRECBUFLEN - istart; - - zintro = memchr (abPrecbuf + istart, FIRST, (size_t) cintro); - if (zintro == NULL) - { - bzero (abPrecbuf + istart, (size_t) cintro); - istart = (istart + cintro) % CRECBUFLEN; - iPrecend = istart; - continue; - } - - cskipped = zintro - (abPrecbuf + istart); - bzero (abPrecbuf + istart, cskipped); - istart += cskipped; - iPrecend = istart; - } - - for (i = 0, iget = istart; - i < CHDRLEN && iget != iJrecend; - ++i, iget = (iget + 1) % CRECBUFLEN) - ab[i] = abPrecbuf[iget]; - - if (i < CHDRLEN) - { - if (pcneed != NULL) - *pcneed = CHDRLEN - i; - return TRUE; - } - - cpacket = CGETLENGTH (ab[1], ab[2]); - cdata = CGETLENGTH (ab[4], ab[5]); - - /* Make sure the header has the right magic characters, that the - data is not larger than the packet, and that we have an even - number of byte index characters. */ - if (ab[3] != FOURTH - || ab[6] != SEVENTH - || cdata > cpacket - CHDRLEN - 1 - || (cpacket - cdata - CHDRLEN - 1) % 2 == 1) - { - istart = (istart + 1) % CRECBUFLEN; - continue; - } - - chave = iJrecend - istart; - if (chave < 0) - chave += CRECBUFLEN; - - if (chave < cpacket) - { - if (pcneed != NULL) - *pcneed = cpacket - chave; - return TRUE; - } - - /* Figure out where the byte indices start and end. */ - iindex = (istart + CHDRLEN + cdata) % CRECBUFLEN; - iendindex = (istart + cpacket - 1) % CRECBUFLEN; - - /* Make sure the magic trailer character is there. */ - if (abPrecbuf[iendindex] != TRAILER) - { - istart = (istart + 1) % CRECBUFLEN; - continue; - } - - /* We have a packet to decode. The decoding process is simpler - than the encoding process, since all we have to do is examine - the byte indices. We zero out the byte indices as we go, so - that they will not confuse the 'i' protocol. */ - while (iindex != iendindex) - { - int ihigh, ilow; - boolean f32, f128; - int iset; - - ihigh = abPrecbuf[iindex] - INDEX_OFFSET; - abPrecbuf[iindex] = 0; - iindex = (iindex + 1) % CRECBUFLEN; - ilow = abPrecbuf[iindex] - INDEX_OFFSET; - abPrecbuf[iindex] = 0; - iindex = (iindex + 1) % CRECBUFLEN; - - /* Now we must undo the encoding, by adding 128 and xoring - with 32 as appropriate. Which to do is encoded in the - low byte, except that if the high byte is the special - value 126, then the low byte is actually the high byte - and both operations are performed. */ - f128 = TRUE; - f32 = TRUE; - if (ihigh == INDEX_MAX_HIGH) - iset = ilow * INDEX_MAX_LOW + INDEX_MAX_LOW - 1; - else - { - iset = ihigh * INDEX_MAX_LOW + ilow % INDEX_MAX_LOW; - if (ilow < INDEX_MAX_LOW) - f32 = FALSE; - else if (ilow < 2 * INDEX_MAX_LOW) - f128 = FALSE; - } - - /* Now iset is the index from the start of the data to the - byte to modify; adjust it to an index in abPrecbuf. */ - iset = (istart + CHDRLEN + iset) % CRECBUFLEN; - - if (f128) - abPrecbuf[iset] |= 0x80; - if (f32) - abPrecbuf[iset] ^= 0x20; - } - - /* Zero out the header and trailer to avoid confusing the 'i' - protocol, and update iPrecend to the end of decoded data. */ - for (i = 0, iget = istart; - i < CHDRLEN && iget != iJrecend; - ++i, iget = (iget + 1) % CRECBUFLEN) - abPrecbuf[iget] = 0; - abPrecbuf[iendindex] = 0; - iPrecend = (iendindex + 1) % CRECBUFLEN; - istart = iPrecend; - } - - if (pcneed != NULL) - *pcneed = CHDRLEN + 1; - return TRUE; -} diff --git a/gnu/libexec/uucp/uucico/prott.c b/gnu/libexec/uucp/uucico/prott.c deleted file mode 100644 index fe3b274..0000000 --- a/gnu/libexec/uucp/uucico/prott.c +++ /dev/null @@ -1,331 +0,0 @@ -/* prott.c - The 't' protocol. - - Copyright (C) 1991, 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char prott_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* This implementation is based on code written by Rick Adams. - - This code implements the 't' protocol, which does no error checking - whatsoever and thus requires an end-to-end verified eight bit - communication line, such as is provided by TCP. Using it with a - modem is unadvisable, since errors can occur between the modem and - the computer. */ - -/* The buffer size we use. */ -#define CTBUFSIZE (1024) - -/* The offset in the buffer to the data. */ -#define CTFRAMELEN (4) - -/* Commands are sent in multiples of this size. */ -#define CTPACKSIZE (512) - -/* A pointer to the buffer we will use. */ -static char *zTbuf; - -/* True if we are receiving a file. */ -static boolean fTfile; - -/* The timeout we use. */ -static int cTtimeout = 120; - -struct uuconf_cmdtab asTproto_params[] = -{ - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cTtimeout, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local function. */ - -static boolean ftprocess_data P((struct sdaemon *qdaemon, boolean *pfexit, - size_t *pcneed)); - -/* Start the protocol. */ - -boolean -ftstart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - *pzlog = NULL; - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_OFF)) - return FALSE; - zTbuf = (char *) xmalloc (CTBUFSIZE + CTFRAMELEN); - /* The first two bytes of the buffer are always zero. */ - zTbuf[0] = 0; - zTbuf[1] = 0; - fTfile = FALSE; - usysdep_sleep (2); - return TRUE; -} - -/* Stop the protocol. */ - -/*ARGSUSED*/ -boolean -ftshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - xfree ((pointer) zTbuf); - zTbuf = NULL; - cTtimeout = 120; - return TRUE; -} - -/* Send a command string. We send everything up to and including the - null byte. The number of bytes we send must be a multiple of - TPACKSIZE. */ - -/*ARGSUSED*/ -boolean -ftsendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - size_t clen, csend; - char *zalc; - boolean fret; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ftsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - - /* We need to send the smallest multiple of CTPACKSIZE which is - greater than clen (not equal to clen, since we need room for the - null byte). */ - csend = ((clen / CTPACKSIZE) + 1) * CTPACKSIZE; - - zalc = zbufalc (csend); - memcpy (zalc, z, clen); - if (csend > clen) - bzero (zalc + clen, csend - clen); - - fret = fsend_data (qdaemon->qconn, zalc, csend, TRUE); - ubuffree (zalc); - return fret; -} - -/* Get space to be filled with data. We provide a buffer which has - four bytes at the start available to hold the length. */ - -/*ARGSIGNORED*/ -char * -ztgetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = CTBUFSIZE; - return zTbuf + CTFRAMELEN; -} - -/* Send out some data. We are allowed to modify the four bytes - preceding the buffer. This allows us to send the entire block with - header bytes in a single call. */ - -/*ARGSIGNORED*/ -boolean -ftsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ - /* Here we do htonl by hand, since it doesn't exist everywhere. We - know that the amount of data cannot be greater than CTBUFSIZE, so - the first two bytes of this value will always be 0. They were - set to 0 in ftstart so we don't touch them here. This is useful - because we cannot portably right shift by 24 or 16, since we - might be dealing with sixteen bit integers. */ - zdata[-2] = (char) ((cdata >> 8) & 0xff); - zdata[-1] = (char) (cdata & 0xff); - - /* We pass FALSE to fsend_data since we don't expect the other side - to be sending us anything just now. */ - return fsend_data (qdaemon->qconn, zdata - CTFRAMELEN, cdata + CTFRAMELEN, - FALSE); -} - -/* Process data and return the amount we need in *pfneed. */ - -static boolean -ftprocess_data (qdaemon, pfexit, pcneed) - struct sdaemon *qdaemon; - boolean *pfexit; - size_t *pcneed; -{ - int cinbuf, cfirst, clen; - - *pfexit = FALSE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (! fTfile) - { - /* We are not receiving a file. Commands are read in chunks of - CTPACKSIZE. */ - while (cinbuf >= CTPACKSIZE) - { - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > CTPACKSIZE) - cfirst = CTPACKSIZE; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ftprocess_data: Got %d command bytes", - cfirst); - - if (! fgot_data (qdaemon, abPrecbuf + iPrecstart, - (size_t) cfirst, abPrecbuf, - (size_t) CTPACKSIZE - cfirst, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + CTPACKSIZE) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf -= CTPACKSIZE; - } - - if (pcneed != NULL) - *pcneed = CTPACKSIZE - cinbuf; - - return TRUE; - } - - /* Here we are receiving a file. The data comes in blocks. The - first four bytes contain the length, followed by that amount of - data. */ - - while (cinbuf >= CTFRAMELEN) - { - /* The length is stored in network byte order, MSB first. */ - - clen = (((((((abPrecbuf[iPrecstart] & 0xff) << 8) - + (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN] & 0xff)) << 8) - + (abPrecbuf[(iPrecstart + 2) % CRECBUFLEN] & 0xff)) << 8) - + (abPrecbuf[(iPrecstart + 3) % CRECBUFLEN] & 0xff)); - - if (cinbuf < clen + CTFRAMELEN) - { - if (pcneed != NULL) - *pcneed = clen + CTFRAMELEN - cinbuf; - return TRUE; - } - - iPrecstart = (iPrecstart + CTFRAMELEN) % CRECBUFLEN; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > clen) - cfirst = clen; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ftprocess_data: Got %d data bytes", - clen); - - if (! fgot_data (qdaemon, abPrecbuf + iPrecstart, - (size_t) cfirst, abPrecbuf, (size_t) (clen - cfirst), - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf -= clen + CTFRAMELEN; - } - - if (pcneed != NULL) - *pcneed = CTFRAMELEN - cinbuf; - - return TRUE; -} - -/* Wait for data to come in and process it until we've reached the end - of a command or a file. */ - -boolean -ftwait (qdaemon) - struct sdaemon *qdaemon; -{ - while (TRUE) - { - boolean fexit; - size_t cneed, crec; - - if (! ftprocess_data (qdaemon, &fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - if (! freceive_data (qdaemon->qconn, cneed, &crec, cTtimeout, TRUE)) - return FALSE; - - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } -} - -/* File level routine, to set fTfile correctly. */ - -/*ARGSUSED*/ -boolean -ftfile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled) - struct sdaemon *qdaemon; - struct stransfer *qtrans; - boolean fstart; - boolean fsend; - long cbytes; - boolean *pfhandled; -{ - *pfhandled = FALSE; - - if (! fsend) - fTfile = fstart; - - return TRUE; -} diff --git a/gnu/libexec/uucp/uucico/proty.c b/gnu/libexec/uucp/uucico/proty.c deleted file mode 100644 index 50e1f11..0000000 --- a/gnu/libexec/uucp/uucico/proty.c +++ /dev/null @@ -1,660 +0,0 @@ -/* proty.c - The 'y' protocol. - - Copyright (C) 1994, 1995 Jorge Cwik and 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char proty_id[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -/* The 'y' protocol, and this implementation, was written and designed - by Jorge Cwik <jorge@satlink.net>. Some of the routines, and the - coding style in general, were taken verbatim or adapted from other - Taylor UUCP modules. Mark Delany made the initial testings and - helped in portability issues. - - This protocol does not perform any kind of error correction or flow - control. It does do error checking. It does not require an end to - end reliable link. It is recommended for error-free (also called - semi-reliable) connections as provided by error correcting modems. - It needs an eight bit clean channel and some kind of flow control - at the lower layers, typically RTS/CTS hardware flow control. - - The flow of the file transmission is completely unidirectional. - There are no ACKs or NAKs outside file boundaries. This makes it - very suitable for half duplex modulations (like PEP) and - connections with very long delays, like multihop satellite links. */ - -/* This protocol uses 16 bit little-endian ints in the packet header. */ -#define FROMLITTLE(p) (((p)[0] & 0xff) + (((p)[1] & 0xff) << 8)) -#define TOLITTLE(p, i) ((p)[0] = (i) & 0xff, (p)[1] = ((i) >> 8) & 0xff) - -/* The buffer and packet size we use. */ -#define CYBUFSIZE (1024) -#define IYPACKSIZE (1024) - -/* The offset in the buffer to the data. */ -#define CYFRAMELEN (6) - -/* Offsets in a packet header. */ -#define YFRAME_SEQ_OFF (0) -#define YFRAME_LEN_OFF (2) -#define YFRAME_CTL_OFF (2) -#define YFRAME_CHK_OFF (4) - -/* Offsets in a packet header viewed as an array of shorts. */ -#define YFRAME_SEQ (0) -#define YFRAME_LEN (1) -#define YFRAME_CTL (1) -#define YFRAME_CHK (2) - -/* The default timeout. */ -#define CYTIMEOUT (60) - -/* Control packet types. */ -#define YPKT_ACK (0xFFFE) -#define YPKT_ERR (0xFFFD) -#define YPKT_BAD (0xFFFC) - -/* The protocol version number. */ -#define Y_VERSION (1) - -/* When the protocol starts up, it transmit the following information: - 1 byte version - 1 byte packet size - 2 byte flags (none currently defined) - Future revision may expand the structure as long as these members - keep their current offset. */ -#define Y_INIT_HDR_LEN (4) -#define Y_INIT_HDR_VERSION_OFF (0) -#define Y_INIT_HDR_PKTSIZE_OFF (1) -#define Y_INIT_HDR_FLAGS_OFF (2) - -/* The initialization length of the lowest accepted version. */ -#define MIN_Y_SYNC (4) - -/* Not strictly needed, but I would not want to accept a 32k sync pkt. */ -#define MAX_Y_SYNC IYPACKSIZE - -/* Local and remote packet sizes (we actually use the same value for - both). */ -static size_t iYlocal_packsize = IYPACKSIZE; -static size_t iYremote_packsize = IYPACKSIZE; - -/* Local and remote packet sequence numbers. */ -static unsigned short iYlocal_pktnum; -static unsigned short iYremote_pktnum; - -/* The timeout. */ -static int cYtimeout = CYTIMEOUT; - -/* Transmitter buffer. */ -static char *zYbuf; - -/* Protocol parameters. */ - -struct uuconf_cmdtab asYproto_params[] = -{ - { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cYtimeout, NULL }, - { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iYlocal_packsize, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local functions. */ - -static boolean fywait_for_packet P((struct sdaemon *qdaemon, - boolean *pfexit)); -static unsigned short iychecksum P((const char *z, size_t c)); -static unsigned short iychecksum2 P((const char *zfirst, size_t cfirst, - const char *zsecond, size_t csecond)); -static boolean fywait_for_header P((struct sdaemon *qdaemon, - unsigned short header[3], int timeout)); -static boolean fysend_pkt P((struct sdaemon *qdaemon, - const void *zdata, size_t cdata)); -static boolean fysend_control P((struct sdaemon *qdaemon, - int itype)); -static boolean fyread_data P((struct sdaemon *qdaemon, size_t clen, - int timeout)); - -/* Exchange sync packets at protocol startup. */ - -static boolean -fyxchg_syncs (qdaemon) - struct sdaemon *qdaemon; -{ - char inithdr[Y_INIT_HDR_LEN]; - unsigned short header[3]; - unsigned short ichk; - size_t clen, cfirst; - int rpktsize; - - /* Send our configuration. We could use only one array (for local - and remote). But this is safer in case the code changes and - depend on separate ones. */ - - inithdr[Y_INIT_HDR_VERSION_OFF] = Y_VERSION; - inithdr[Y_INIT_HDR_PKTSIZE_OFF] = iYlocal_packsize >> 8; - TOLITTLE (inithdr + Y_INIT_HDR_FLAGS_OFF, 0); - - if (! fysend_pkt (qdaemon, inithdr, Y_INIT_HDR_LEN)) - return FALSE; - - if (! fywait_for_header (qdaemon, header, cYtimeout)) - return FALSE; - - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fyxchg_syncs: Got sync header"); - clen = header[YFRAME_LEN]; - - if (clen < MIN_Y_SYNC || clen > MAX_Y_SYNC) - { - ulog (LOG_ERROR, "Bad 'y' protocol sync packet length"); - return FALSE; - } - - /* It may be better to integrate this code with fywait_for_packet. */ - if (! fyread_data (qdaemon, clen, cYtimeout)) - return FALSE; - - cfirst = CRECBUFLEN - iPrecstart; - ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst, - abPrecbuf, clen - cfirst); - - rpktsize = BUCHAR (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN]); - - /* Future versions of the protocol may need to check and react - according to the version number. */ - - if (rpktsize == 0 || header[YFRAME_CHK] != ichk) - { - ulog (LOG_ERROR, "Bad 'y' protocol sync packet"); - return FALSE; - } - - iYremote_packsize = rpktsize << 8; - - /* Some may want to do this different and in effect the protocol - support this. But I like the idea that the packet size would be - the same in both directions. This allows the caller to select - both packet sizes without changing the configuration at the - server. */ - if (iYremote_packsize > iYlocal_packsize) - iYremote_packsize = iYlocal_packsize; - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - return TRUE; -} - -/* Start the protocol. */ - -boolean -fystart (qdaemon, pzlog) - struct sdaemon *qdaemon; - char **pzlog; -{ - *pzlog = NULL; - - /* This should force, or at least enable if available, RTS/CTS - hardware flow control !! */ - - /* The 'y' protocol requires an eight bit clean link */ - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_OFF)) - return FALSE; - - iYlocal_pktnum = iYremote_pktnum = 0; - - /* Only multiple of 256 sizes are allowed */ - iYlocal_packsize &= ~0xff; - if (iYlocal_packsize < 256 || iYlocal_packsize > (16*1024)) - iYlocal_packsize = IYPACKSIZE; - - /* Exhange SYNC packets */ - if (! fyxchg_syncs (qdaemon)) - { - /* Restore defaults */ - cYtimeout = CYTIMEOUT; - iYlocal_packsize = IYPACKSIZE; - return FALSE; - } - - zYbuf = (char *) xmalloc (CYBUFSIZE + CYFRAMELEN); - return TRUE; -} - -/* Shutdown the protocol. */ - -boolean -fyshutdown (qdaemon) - struct sdaemon *qdaemon; -{ - xfree ((pointer) zYbuf); - zYbuf = NULL; - cYtimeout = CYTIMEOUT; - iYlocal_packsize = IYPACKSIZE; - return TRUE; -} - -/* Send a command string. We send packets containing the string until - the entire string has been sent, including the zero terminator. */ - -/*ARGSUSED*/ -boolean -fysendcmd (qdaemon, z, ilocal, iremote) - struct sdaemon *qdaemon; - const char *z; - int ilocal; - int iremote; -{ - size_t clen; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fysendcmd: Sending command \"%s\"", z); - - clen = strlen (z) + 1; - - while (clen > 0) - { - size_t csize; - - csize = clen; - if (csize > iYremote_packsize) - csize = iYremote_packsize; - - if (! fysend_pkt (qdaemon, z, csize)) - return FALSE; - - z += csize; - clen -= csize; - } - - return TRUE; -} - -/* Get space to be filled with data. We always use zYbuf, which was - allocated from the heap. */ - -char * -zygetspace (qdaemon, pclen) - struct sdaemon *qdaemon; - size_t *pclen; -{ - *pclen = iYremote_packsize; - return zYbuf + CYFRAMELEN; -} - -/* Send out a data packet. */ - -boolean -fysenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos) - struct sdaemon *qdaemon; - char *zdata; - size_t cdata; - int ilocal; - int iremote; - long ipos; -{ -#if DEBUG > 0 - if (cdata > iYremote_packsize) - ulog (LOG_FATAL, "fysend_packet: Packet size too large"); -#endif - - TOLITTLE (zYbuf + YFRAME_SEQ_OFF, iYlocal_pktnum); - ++iYlocal_pktnum; - TOLITTLE (zYbuf + YFRAME_LEN_OFF, cdata); - TOLITTLE (zYbuf + YFRAME_CHK_OFF, iychecksum (zdata, cdata)); - - /* We pass FALSE to fsend_data since we don't expect the other side - to be sending us anything just now. */ - return fsend_data (qdaemon->qconn, zYbuf, cdata + CYFRAMELEN, FALSE); -} - -/* Wait for data to come in and process it until we've finished a - command or a file. */ - -boolean -fywait (qdaemon) - struct sdaemon *qdaemon; -{ - boolean fexit = FALSE; - - while (! fexit) - { - if (! fywait_for_packet (qdaemon, &fexit)) - return FALSE; - } - return TRUE; -} - -/* File level routines - We could handle this inside the other public routines, - but this is cleaner and better for future expansions */ - -boolean -fyfile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled) - struct sdaemon *qdaemon; - struct stransfer *qtrans; - boolean fstart; - boolean fsend; - long cbytes; - boolean *pfhandled; -{ - unsigned short header[3]; - - *pfhandled = FALSE; - - if (! fstart) - { - if (fsend) - { - /* It is critical that the timeout here would be long - enough. We have just sent a full file without any kind - of flow control at the protocol level. The traffic may - be buffered in many places of the link, and the remote - may take a while until cathing up. */ - if (! fywait_for_header (qdaemon, header, cYtimeout * 2)) - return FALSE; - - if (header[YFRAME_CTL] != (unsigned short) YPKT_ACK) - { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fyfile: Error from remote: 0x%04X", header[1]); - ulog (LOG_ERROR, "Received 'y' protocol error from remote"); - return FALSE; - } - } - else - { - /* This is technically not requireed. But I've put this in - the protocol to allow easier expansions. */ - return fysend_control (qdaemon, YPKT_ACK); - } - } - - return TRUE; -} - -/* Send a control packet, not used during the normal file - transmission. */ - -static boolean -fysend_control (qdaemon, itype) - struct sdaemon *qdaemon; - int itype; -{ - char header[CYFRAMELEN]; - - TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum); - iYlocal_pktnum++; - TOLITTLE (header + YFRAME_CTL_OFF, itype); - TOLITTLE (header + YFRAME_CHK_OFF, 0); - - return fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE); -} - -/* Private function to send a packet. This one doesn't need the data - to be in the buffer provided by zygetspace. I've found it worth - for avoiding memory copies. Somebody may want to do it otherwise */ - -static boolean -fysend_pkt (qdaemon, zdata, cdata) - struct sdaemon *qdaemon; - const void *zdata; - size_t cdata; -{ - char header[CYFRAMELEN]; - - TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum); - iYlocal_pktnum++; - TOLITTLE (header + YFRAME_LEN_OFF, cdata); - TOLITTLE (header + YFRAME_CHK_OFF, iychecksum (zdata, cdata)); - - if (! fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE)) - return FALSE; - return fsend_data (qdaemon->qconn, zdata, cdata, FALSE); -} - -/* Wait until enough data arrived from the comm line. This protocol - doesn't need to perform any kind of action while waiting. */ - -static boolean -fyread_data (qdaemon, clen, timeout) - struct sdaemon *qdaemon; - size_t clen; - int timeout; -{ - int cinbuf; - size_t crec; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (cinbuf < clen) - { - if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec, - timeout, TRUE)) - return FALSE; - cinbuf += crec; - if (cinbuf < clen) - { - if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec, - timeout, TRUE)) - return FALSE; - } - cinbuf += crec; - if (cinbuf < clen) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } - - return TRUE; -} - -/* Receive a remote packet header, check for correct sequence number. */ - -static boolean -fywait_for_header (qdaemon, header, timeout) - struct sdaemon *qdaemon; - unsigned short header[3]; - int timeout; -{ - if (! fyread_data (qdaemon, CYFRAMELEN, timeout)) - return FALSE; - - /* Somebody may want to optimize this in a portable way. I'm not - sure it's worth, but the output by gcc for the portable construct - is so bad (even with optimization), that I couldn't resist. */ - - if (iPrecstart <= (CRECBUFLEN - CYFRAMELEN)) - { - header[0] = FROMLITTLE (abPrecbuf + iPrecstart); - header[1] = FROMLITTLE (abPrecbuf + iPrecstart + 2); - header[2] = FROMLITTLE (abPrecbuf + iPrecstart + 4); - } - else - { - register int i, j; - - for (i = j = 0; j < CYFRAMELEN; i++, j += 2) - { - header[i] = - (((abPrecbuf[(iPrecstart + j + 1) % CRECBUFLEN] & 0xff) << 8) - + (abPrecbuf[(iPrecstart + j) % CRECBUFLEN] & 0xff)); - } - } - - iPrecstart = (iPrecstart + CYFRAMELEN) % CRECBUFLEN; - - DEBUG_MESSAGE3 (DEBUG_UUCP_PROTO, - "fywait_for_header: Got header: 0x%04X, 0x%04X, 0x%04X", - header[0], header[1], header[2]); - - if (header[YFRAME_SEQ] != iYremote_pktnum++) - { - ulog (LOG_ERROR, "Incorrect 'y' packet sequence"); - fysend_control (qdaemon, YPKT_BAD); - return FALSE; - } - - return TRUE; -} - -/* Receive a remote data packet */ - -static boolean -fywait_for_packet (qdaemon, pfexit) - struct sdaemon *qdaemon; - boolean *pfexit; -{ - unsigned short header[3], ichk; - size_t clen, cfirst; - - if (! fywait_for_header (qdaemon, header, cYtimeout)) - return FALSE; - - clen = header[YFRAME_LEN]; - if (clen == 0 && pfexit != NULL) - { - /* I Suppose the pointers could be NULL ??? */ - return fgot_data (qdaemon, abPrecbuf, 0, abPrecbuf, 0, - -1, -1, (long) -1, TRUE, pfexit); - } - - if (clen & 0x8000) - { - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fywait_for_packet: Error from remote: 0x%04X", - header[YFRAME_CTL]); - ulog (LOG_ERROR, "Remote error packet"); - return FALSE; - } - - /* This is really not neccessary. But if this check is removed, - take in mind that the packet may be up to 32k long. */ - if (clen > iYlocal_packsize) - { - ulog (LOG_ERROR, "Packet too large"); - return FALSE; - } - - if (! fyread_data (qdaemon, clen, cYtimeout)) - return FALSE; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > clen) - cfirst = clen; - - if (cfirst == clen) - ichk = iychecksum (abPrecbuf + iPrecstart, clen); - else - ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst, - abPrecbuf, clen - cfirst); - if (header[YFRAME_CHK] != ichk) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fywait_for_packet: Bad checksum 0x%x != 0x%x", - header[YFRAME_CHK], ichk); - fysend_control (qdaemon, YPKT_ERR); - ulog (LOG_ERROR, "Checksum error"); - return FALSE; - } - - if (pfexit != NULL - && ! fgot_data (qdaemon, abPrecbuf + iPrecstart, cfirst, - abPrecbuf, clen - cfirst, - -1, -1, (long) -1, TRUE, pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - - return TRUE; -} - -/* Compute 16 bit checksum */ - -#ifdef __GNUC__ -#ifdef __i386__ -#define I386_ASM -#endif -#endif - -#ifdef I386_ASM -#define ROTATE(i) \ - asm ("rolw $1,%0" : "=g" (i) : "g" (i)) -#else -#define ROTATE(i) i += i + ((i & 0x8000) >> 15) -#endif - -static unsigned short -iychecksum (z, c) - register const char *z; - register size_t c; -{ - register unsigned short ichk; - - ichk = 0xffff; - - while (c-- > 0) - { - ROTATE (ichk); - ichk += BUCHAR (*z++); - } - - return ichk; -} - -static unsigned short -iychecksum2 (zfirst, cfirst, zsecond, csecond) - const char *zfirst; - size_t cfirst; - const char *zsecond; - size_t csecond; -{ - register unsigned short ichk; - register const char *z; - register size_t c; - - z = zfirst; - c = cfirst + csecond; - - ichk = 0xffff; - - while (c-- > 0) - { - ROTATE (ichk); - ichk += BUCHAR (*z++); - - /* If the first buffer has been finished, switch to the second. */ - if (--cfirst == 0) - z = zsecond; - } - - return ichk; -} diff --git a/gnu/libexec/uucp/uucico/protz.c b/gnu/libexec/uucp/uucico/protz.c deleted file mode 100644 index 305e250..0000000 --- a/gnu/libexec/uucp/uucico/protz.c +++ /dev/null @@ -1,2626 +0,0 @@ -/* protz.c Version 1.5, 92Apr24 */ -/* Modified by Ian Lance Taylor for Taylor UUCP 1.04 92Aug4. */ - -/* - * Doug Evans, dje@sspiff.UUCP or dje@ersys.edmonton.ab.ca - * - * This file provides the Zmodem protocol (by Chuck Forsberg) for - * Ian Taylor's UUCP package. - * - * It was originally developed to establish a uucp link between myself and my - * employer: Ivation Datasystems, Inc. of Ottawa. - * - * My thanks to Ivation for letting me release this to the public. Given that - * Zmodem is in the public domain, no additional copyrights have been added. - * - ***************************************************************************** - * - * It's been difficult fitting Zmodem into the UUCP world. I have been guided - * mostly by trying to plug it into Taylor UUCP. Where "the Zmodem way of doing - * things" conflicted with "the UUCP way of doing things", I have err'd on the - * side of UUCP. At the end of it all, I have achieved something that will plug - * into Taylor UUCP very easily, but some might argue that I have corrupted Z - * too much. At any rate, compatibility with sz/rz was sacrificed to achieve a - * clean UUCP protocol. Given that, I took the opportunity to start from - * scratch when defining protocol constants (EG: ZBIN). - * - * 1) I wasn't quite sure how to enhance Zmodem to handle send+receive in one - * session, so I added a 'g' protocol like initialization sequence. This - * also gets this stuff out of the way, in case we ever try to support - * full-duplex. - * - * Caller Callee - * ------ ------ - * ZINIT --> <-- ZINIT - * ZDATA (ZCRCF) --> <-- ZDATA (ZCRCF) - * ZACK --> <-- ZACK - * ZINITEND --> <-- ZINITEND - * - * ZINIT is a combination of ZRINIT and ZSINIT and is intended to exchange - * simple protocol information (flags) and the protocol version number. - * ZDATA is intended to include window size information as well as the - * "Myattn" string (although at the moment it doesn't contain anything). - * ZDATA may contain at most 1k bytes of data and is sent out as one ZCRCF - * packet. Two ack's (ZACK + ZINITEND) are needed to ensure both sides have - * received ZDATA. - * - * 2) I've hardcoded several protocol parameters, like 32 bit CRC's for data. - * Others are not supported (we don't need them). - * - * 3) ZHEX headers use 32 bit CRC's. - * - * 4) Zmodem sends the ZFILE message "in one chunk". If there are errors, the - * entire string is resent. I have continued this practice. All UUCP - * commands are sent "in one chunk". This can be changed down the road if - * necessary. - * - * 5) The ZEOF message has been replaced with a new ZCRCx value: ZCRCF. ZCRCF - * is identical to ZCRCW except that it indicates the end of the message. - * The protocol here is *not* a file transfer protocol. It is an end to end - * transport protocol (that preserves message boundaries). - * - * 6) Zmodem handles restarting a file transfer, but as best as I can tell UUCP - * does not. At least Taylor UUCP doesn't. And if UUCP does start handling - * file restart, can it be plugged into the existing Zmodem way with zero - * changes? Beats me. Therefore I have removed this part of the code. One - * can always put it back in if and when UUCP handles it. Ditto for other - * pieces of removed code: there's no point in overly complicating this code - * when supporting all the bells and whistles requires enhancements to UUCP - * itself. - * - * *** It is easier to put code back in in an upward compatible manner *** - * *** than it is to correct for misunderstood code or poorly merged *** - * *** (Zmodem vs UUCP) code. *** - * - * 7) For the character in the initial "protocol selection" sequence, I have - * chosen 'a'. I'm told 'z' is already in use for something that isn't - * Zmodem. It's entirely reasonable to believe that if Zmodem ever becomes a - * standard UUCP protocol, this won't be it (so I'll leave z/Z for them). - * Publicly, this is the 'a' protocol. Internally, it is refered to as 'z'. - * A little confusing, I know. Maybe in time I'll refer to it internally as - * 'a', or maybe in time this will be *the* 'z' protocol. - * - * 8) Since we are writing a transport protocol, which isn't supposed to know - * anything about what is being transfered or where it is coming from, the - * header data value has changed meaning. It no longer means "file position" - * but instead means "window position". It is a running counter of the bytes - * transfered. Each "message" begins on a 1k boundary so the count isn't a - * precise byte count. The counter wraps every 4 gigabytes, although this - * wrapping isn't supported yet. - * - * FIXME: At present the max data transfered per session is 4 gigabytes. - * - **************************************************************************** - * - * A typical message sequence is (master sending file to slave): - * - * Master Slave - * ------ ----- - * ZDATA (S, ZCRCF) --> - * <-- ZACK - * <-- ZDATA (SY, ZCRCF) - * ZACK --> - * ZDATA --> - * ... <-- ZACK/ZRPOS - * ZDATA (ZCRCF) --> - * <-- ZACK - * <-- ZDATA (CY, ZCRCF) - * ZACK --> - * - * A typical message sequence is (master receiving file from slave): - * - * Master Slave - * ------ ----- - * ZDATA (R, ZCRCF) --> - * <-- ZACK - * <-- ZDATA (RY, ZCRCF) - * ZACK --> - * <-- ZDATA - * ZACK/ZRPOS ... --> - * <-- ZDATA (ZCRCF) - * ZACK --> - * ZDATA (CY, ZCRCF) --> - * <-- ZACK - * - ***************************************************************************** - * - * Notes: - * 1) For future bidirectional concerns, keep packet types "unidirectional". - * Sender always uses: ZDATA, ZNAK - * Receiver always uses: ZRPOS, ZACK - * There is no intersection. - * - * I'm not sure if this is necessary or even useful, but it seems to be. - * - * 2) I use to store the byte count / 32 in the data header. This left 5 bits - * unused for future concerns. I removed this because of the following - * situation when sending a file: - * - * ZDATA (ZCRCG, xx bytes) - received ok - * ZDATA (ZCRCF, 0 bytes) - corrupted - * - * At this point the receiver would like to send back a ZRPOS with a value - * of the size of the file. However, it can't because the value is divided - * by 32, and it would have to round up to the next multiple of 32. This - * seemed a little ugly, so I went with using the entire header to store - * the byte count. - * - ***************************************************************************** - * - * Source version: - * - * 1.1,2,3 - * Protocol version 0 - * Early attempts, completely rewritten later. - * - * 1.4 Protocol version 1 - * Beta test sent to Ian for analysis 92Apr18. - * - * 1.5 Protocol version 1 - * Released 92Apr24. - * - ***************************************************************************** - * - * Protocol version: - * - * A version number is exchanged in the ZINIT message, so it is possible to - * correct or enhance the protocol, without breaking existing versions. - * The purpose of this section is to document these versions as they come out. - * Remember, this is the protocol version, not the source version. - * - * 0 Initial version. - * Zmodem controlled file transfer. This was more of a "plug Z - * into UUCP as is" port. - * - * 1 Complete rewrite. - * Made Z more of a transport protocol. UUCP now controls transfer and Z - * is on the same footing as the other UUCP protocols. - * Theoretically, there will be little pain when UUCP goes bidirectional. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char protz_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "trans.h" -#include "system.h" -#include "prot.h" - -#define ZPROTOCOL_VERSION 1 - -/* - * Control message characters ... - */ - -#define ZPAD '*' /* Padding character begins frames */ -#define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */ -#define ZBIN 'A' /* Binary frame indicator */ -#define ZHEX 'B' /* HEX frame indicator */ - -/* - * Frame types (see array "frametypes" in zm.c) ... - * - * Note that the numbers here have been reorganized, as we don't support - * all of them (nor do we need to). - * - * WARNING: The init sequence assumes ZINIT < ZDATA < ZACK < ZINITEND. - */ - -#define ZINIT 0 /* Init (contains protocol version, flags) */ -#define ZDATA 1 /* Data packet(s) follow */ -#define ZRPOS 2 /* Resume data trans at this position */ -#define ZACK 3 /* ACK to above */ -#define ZNAK 4 /* Last packet was garbled */ -#define Zreserved 5 /* reserved (for future concerns) */ -#define ZINITEND 6 /* end of init sequence */ -#define ZFIN 7 /* Finish session */ - -/* - * ZDLE sequences ... - * - * Note addition of ZCRCF: "end of message". - */ - -#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ -#define ZCRCG 'i' /* CRC next, frame continues nonstop */ -#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */ -#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ -#define ZCRCF 'l' /* CRC next, ZACK expected, end of message */ - -#define ZRUB0 'm' /* Translate to rubout 0177 */ -#define ZRUB1 'n' /* Translate to rubout 0377 */ - - -/* - * zdlread return values (internal) ... - * Other values are ZM_ERROR, ZM_TIMEOUT, ZM_RCDO. - */ - -#define GOTOR 0400 -#define GOTCRCE (ZCRCE | GOTOR) /* ZDLE-ZCRCE received */ -#define GOTCRCG (ZCRCG | GOTOR) /* ZDLE-ZCRCG received */ -#define GOTCRCQ (ZCRCQ | GOTOR) /* ZDLE-ZCRCQ received */ -#define GOTCRCW (ZCRCW | GOTOR) /* ZDLE-ZCRCW received */ -#define GOTCRCF (ZCRCF | GOTOR) /* ZDLE-ZCRCF received */ - -/* - * Byte positions within header array ... - */ - -#define ZF0 3 /* First flags byte */ -#define ZF1 2 -#define ZF2 1 -#define ZF3 0 - -#define ZP0 0 /* Low order 8 bits of position */ -#define ZP1 1 -#define ZP2 2 -#define ZP3 3 /* High order 8 bits of position */ - -/* - * Bit Masks for ZRQINIT flags byte ZF0 ... - */ - -#define TX_ESCCTL 1 /* Tx will escape control chars */ - -/* - * Possible errors when running ZMODEM ... - */ - -#define ZM_ERROR (-1) /* crc error, etc. */ -#define ZM_TIMEOUT (-2) -#define ZM_RCDO (-3) /* Carrier Lost */ - -/* - * ASCII characters ... - */ - -#define LF 012 -#define CR 015 -#define XON 021 -#define XOFF 023 - -#define XON_WAIT 10 /* seconds */ - -/* - * Packet sizes ... - * - * FIXME: CPACKETSIZE is hardcoded in a lot of places. - * It's not clear to me whether changing it's value would be a - * "good thing" or not. But of course that doesn't excuse the hardcoding. - */ - -#define CPACKETSIZE 1024 /* max packet size (data only) */ -#define CFRAMELEN 12 /* header size */ -#define CSUFFIXLEN 10 /* suffix at end of data packets */ -#define CEXCHANGE_INIT_RETRIES 4 - -/* The header CRC value. */ - -#if ANSI_C -#define IHDRCRC 0xDEBB20E3UL -#else -#define IHDRCRC ((unsigned long) 0xDEBB20E3L) -#endif - -/* packet buffer size */ -#define CPACKBUFSIZE (CFRAMELEN + 2 * CPACKETSIZE + CSUFFIXLEN + 42 /*slop*/) - -/* - * Data types ... - */ - -typedef unsigned char achdrval_t[4]; -typedef unsigned long hdrval_t; -typedef unsigned long winpos_t; - -/* - * Configurable parms ... - * - * FIXME: <cZrx_buf_len> isn't used yet. It may not be needed. - */ - -#define CTIMEOUT 10 -#define CRETRIES 10 -#define CSTARTUP_RETRIES 4 -#define CGARBAGE 2400 -#define CSEND_WINDOW 16384 -#define FESCAPE_CONTROL FALSE - -static int cZtimeout = CTIMEOUT; /* (seconds) */ -static int cZretries = CRETRIES; -static int cZstartup_retries = CSTARTUP_RETRIES; -static int cZmax_garbage = CGARBAGE; /* max garbage before header */ -static int cZtx_window = CSEND_WINDOW; /* our transmission window */ -static int cZrx_buf_len = 0; /* our reception buffer size */ -static boolean fZesc_ctl = FESCAPE_CONTROL; /* escape control chars */ - -struct uuconf_cmdtab asZproto_params[] = -{ - {"timeout", UUCONF_CMDTABTYPE_INT, (pointer) & cZtimeout, NULL}, - {"retries", UUCONF_CMDTABTYPE_INT, (pointer) & cZretries, NULL}, - {"startup-retries", UUCONF_CMDTABTYPE_INT, - (pointer) & cZstartup_retries, NULL}, - {"garbage", UUCONF_CMDTABTYPE_INT, (pointer) & cZmax_garbage, NULL}, - {"send-window", UUCONF_CMDTABTYPE_INT, (pointer) & cZtx_window, NULL}, - {"escape-control", UUCONF_CMDTABTYPE_BOOLEAN, (pointer) & fZesc_ctl, - NULL}, - {NULL, 0, NULL, NULL} -}; - -/* - * Variables for statistic gathering ... - * - * We use <wpZtxpos, wpZrxbytes> to record the number of "packets" - * sent/received. Packets is in double quotes because some of them aren't full. - */ - -static unsigned long cZheaders_sent; -static unsigned long cZheaders_received; -static unsigned long cZbytes_resent; -static unsigned long cZtimeouts; -static unsigned long cZerrors; - -/* - * Data buffers ... - */ - -static char *zZtx_buf; /* transmit buffer */ - -static char *zZtx_packet_buf; /* raw outgoing packet data */ -static char *zZrx_packet_buf; /* raw incoming packet data */ - -/* - * Transmitter state variables ... - */ - -static unsigned cZblklen; /* data length in sent/received packets */ -static unsigned cZtxwspac; /* spacing between ZCRCQ requests */ -/*static unsigned cZblklen_override;*//* override value for <cZblklen> */ -static unsigned cZtxwcnt; /* counter used to space ack requests */ -static unsigned cZrxwcnt; /* counter used to watch receiver's buf size */ -static winpos_t wpZtxstart; /* <wpZtxpos> when message started */ -static winpos_t wpZtxpos; /* transmitter position */ -static winpos_t wpZlastsync; /* last offset to which we got a ZRPOS */ -static winpos_t wpZlrxpos; /* receiver's last reported offset */ -static winpos_t wpZrxpos; /* receiver file position */ - -static int iZlast_tx_data_packet; /* type of last ZDATA packet (ZCRCx) */ -static int iZjunk_count; /* amount of garbage characters received */ -static int iZtleft; /* for dynamic packet resizing */ - -static int iZbeenhereb4; /* times we've been ZRPOS'd to same place */ - -/* - * Receiver state variables ... - */ - -static winpos_t wpZrxbytes; /* receiver byte count */ -static int iZlast_rx_data_packet; /* last successfully received ZCRCx packet */ - -/* - * Misc. globals ... - */ - -static char xon = XON; - -#ifdef DJE_TESTING -int uucptest = -1; -int uucptest2; -int uucptestseed; -#endif - -/* - * Kludge!!! - * See fzfinish_tx(). Basically the next two globals are used to record the - * fact that we got a ZDATA, but aren't quite ready to process it. - */ - -static int iZpkt_rcvd_kludge; /* -1 if not valid */ -static hdrval_t hvZpkt_hdrval_kludge; - -/* - * Packet types ... - */ - -static const char *azZframe_types[] = { - "Carrier Lost", /* -3 */ - "Timeout", /* -2 */ - "Error", /* -1 */ -#define FTOFFSET 3 - "ZINIT", - "ZDATA", - "ZRPOS", - "ZACK", - "ZNAK", - "Zreserved", - "ZINITEND", - "ZFIN", - "UNKNOWN!!!" -}; -#define FTNUMBER (sizeof(azZframe_types) / sizeof(char *)) - -#ifndef min -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif -#define ZZHEADER_NAME(itype) \ - azZframe_types[min((itype) + FTOFFSET, FTNUMBER - 1)] - -/* - * Local functions ... - */ - -static boolean fzsend_data P((struct sdaemon *qdaemon, char *zdata, - size_t cdata, boolean fendofmessage)); -static boolean fzprocess P((struct sdaemon *qdaemon)); -static boolean fzstart_proto P((struct sdaemon *qdaemon)); -static int izexchange_init P((struct sdaemon *qdaemon, int send_type, - achdrval_t send_val, achdrval_t recv_val)); -static boolean fzshutdown_proto P((struct sdaemon *qdaemon)); -static boolean fzstart_tx P((void)); -static boolean fzfinish_tx P((struct sdaemon *qdaemon, long *plredo)); -static boolean fzstart_rx P((void)); -static boolean fzfinish_rx P((struct sdaemon *qdaemon)); -static boolean fzsend_hdr P((struct sdaemon *qdaemon, int ipkttype, - int ihdrtype, hdrval_t hdrval, - boolean fcheckreceive)); -static boolean fzsend_data_packet P((struct sdaemon *qdaemon, char *zdata, - size_t cdata, int frameend, - boolean fcheckreceive)); -static int czbuild_header P((char *zresult, int ipkttype, int ihdrtype, - hdrval_t hdrval)); -static int czbuild_data_packet P((char *zresult, const char *zdata, - size_t cdata, int frameend)); -/* - * The rest of the functions do not follow Ian's naming style. I have left - * the names the same as the original zm source. Over time, they may change. - */ -static int izrecv_hdr P((struct sdaemon *qdaemon, achdrval_t hdr)); -static int zrbhdr32 P((struct sdaemon *qdaemon, achdrval_t hdr)); -static int zrhhdr P((struct sdaemon *qdaemon, achdrval_t hdr)); -static int zrdat32 P((struct sdaemon *qdaemon, char *buf, int length, - int *iprxcount)); -static int getinsync P((struct sdaemon *qdaemon, boolean flag)); -static char *zputhex P((char *p, int ch)); -static char *zputchar P((char *p, int ch)); -static int zgethex P((struct sdaemon *qdaemon)); -static int zdlread P((struct sdaemon *qdaemon)); -static int noxrd7 P((struct sdaemon *qdaemon)); -static int realreadchar P((struct sdaemon *qdaemon, int timeout)); -static boolean fzreceive_ready P((void)); -static void stohdr P((hdrval_t pos, achdrval_t hdr)); -static hdrval_t rclhdr P((achdrval_t hdr)); -static hdrval_t hvzencode_data_hdr P((winpos_t cbytes)); -static void zdecode_data_hdr P((hdrval_t hdrval, winpos_t *pcbytes)); -static winpos_t lzupdate_rxpos P((achdrval_t rx_hdr, winpos_t rxpos, - winpos_t lrxpos, winpos_t txpos)); - -/* - * This macro replaces readchar() because it achieves a noticable speed up. The - * readchar() function has been renamed realreadchar(). Thanks to Ian for - * running this stuff through a profiler to find this out. Ian suggests further - * speed ups may be obtained by doing a similar thing in zrdat32(). - */ - -/* Assign the next character to b. */ -#define READCHAR(qdaemon, b, i) \ - (iPrecstart != iPrecend \ - ? ((b) = BUCHAR (abPrecbuf[iPrecstart]), \ - iPrecstart = (iPrecstart + 1) % CRECBUFLEN) \ - : ((b) = realreadchar ((qdaemon), (i)))) - -/************************************************************************/ - - -/* - * Start the protocol ... - */ - -boolean -fzstart(qdaemon, pzlog) -struct sdaemon *qdaemon; -char **pzlog; -{ - *pzlog = zbufalc (sizeof "protocol 'a' starting: , , , , , " + 100); - sprintf (*pzlog, "protocol 'a' starting: %d, %d, %d, %d, %d, %d", - cZtimeout, cZretries, cZstartup_retries, - cZmax_garbage, cZtx_window, fZesc_ctl); - - if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE, - STRIPSETTING_EIGHTBITS, XONXOFF_OFF)) - return FALSE; - - /* - * For now, we place tight restrictions on the size of the transmit - * window. This might be relaxed in the future. If it is relaxed, - * some of these tests will stay, some will go. That is why it is - * coded like it is. - */ - - if (cZtx_window % 1024 != 0 || - cZtx_window < 4096 || cZtx_window > 65536 || - 65536 % cZtx_window != 0 - ) { - ulog (LOG_ERROR, - "fzstart: cZtx_window not one of 4096, 8192, 16384, 32768, 65536"); - return FALSE; - } - - zZtx_buf = (char *) xmalloc (CPACKETSIZE); - zZtx_packet_buf = (char *) xmalloc (CPACKBUFSIZE); - zZrx_packet_buf = (char *) xmalloc (CPACKBUFSIZE); - - iZlast_tx_data_packet = -1; - iZlast_rx_data_packet = -1; - - wpZtxpos = wpZlrxpos = wpZrxpos = wpZrxbytes = 0; - cZtxwspac = cZtx_window / 4; - - cZheaders_sent = cZheaders_received = cZbytes_resent = 0; - cZtimeouts = cZerrors = 0; - - iZpkt_rcvd_kludge = -1; - -#if 0 - /* - * We ensure <cZtx_window> is at least 4k, so the following is - * unnecessary. It can be put back in later if needed. - */ - if (cZblklen_override > cZtxwspac - || (!cZblklen_override && cZtxwspac < 1024)) - cZblklen_override = cZtxwspac; -#endif - -#ifdef DJE_TESTING - { - extern int uucptest,uucptest2,uucptestseed; - FILE *f; - - if (uucptest == -1) { - f = fopen ("/usr/local/src/bin/uucp/uucptest", "r"); - if (f != NULL) { - fscanf (f, "%d %d %d", - &uucptestseed, &uucptest, &uucptest2); - fclose (f); - } - srand (uucptestseed); - } - } -#endif - - /* - * Fire up the protocol (exchange init messages) ... - */ - - if (!fzstart_proto (qdaemon)) - return FALSE; - - return TRUE; -} - -/* - * Stop the protocol ... - */ - -boolean -fzshutdown(qdaemon) -struct sdaemon *qdaemon; -{ - (void) fzshutdown_proto (qdaemon); - - xfree ((pointer) zZtx_buf); - xfree ((pointer) zZtx_packet_buf); - xfree ((pointer) zZrx_packet_buf); - zZtx_buf = NULL; - zZtx_packet_buf = NULL; - zZrx_packet_buf = NULL; - - /* - * Print some informative statistics ... - * - * I use the word "messages" here instead of "headers" because the - * latter is jargonese. - */ - - ulog (LOG_NORMAL, - "Protocol 'a' messages: sent %lu, received %lu", - cZheaders_sent, cZheaders_received); - ulog (LOG_NORMAL, - "Protocol 'a' packets: sent %lu, received %lu", - wpZtxpos / 1024, wpZrxbytes / 1024); - if (cZbytes_resent != 0 || cZtimeouts != 0 || cZerrors != 0) - ulog (LOG_NORMAL, - "Protocol 'a' errors: bytes resent %lu, timeouts %lu, errors %lu", - cZbytes_resent, cZtimeouts, cZerrors); - - /* - * Reset all the parameters to their default values, so that the - * protocol parameters used for this connection do not affect the - * next one. - */ - - cZtimeout = CTIMEOUT; - cZretries = CRETRIES; - cZstartup_retries = CSTARTUP_RETRIES; - cZmax_garbage = CGARBAGE; - cZtx_window = CSEND_WINDOW; - fZesc_ctl = FESCAPE_CONTROL; - - cZheaders_sent = cZheaders_received = cZbytes_resent = 0; - cZtimeouts = cZerrors = 0; - - return TRUE; -} - -/* - * Send a command string ... - * We send everything up to and including the null byte. - * - * We assume the command will fit in the outgoing data buffer. - * FIXME: A valid assumption? - */ - -/*ARGSUSED*/ -boolean -fzsendcmd(qdaemon, z, ilocal, iremote) -struct sdaemon *qdaemon; -const char *z; -int ilocal; -int iremote; -{ - size_t n,clen; - long lredo; - char *zbuf; - - clen = strlen (z) + 1; - - DEBUG_MESSAGE1 (DEBUG_PROTO, "fzsendcmd: sending command %s", z); - - if (!fzstart_tx ()) /* must be called before zzgetspace() */ - return FALSE; - - if ((zbuf = zzgetspace (qdaemon, &n)) == NULL) - return FALSE; - -#if DEBUG > 0 - if (clen > n) - ulog (LOG_FATAL, "fzsendcmd: clen > n"); -#endif - - strcpy (zbuf, z); - - /* - * Send it out ... - */ - - do { - if (!fzsend_data (qdaemon, zbuf, clen, TRUE)) - return FALSE; - if (!fzfinish_tx (qdaemon, &lredo)) - return FALSE; - } while (lredo >= 0); - - return fzprocess (qdaemon); -} - -/* - * Allocate a packet to send out ... - * - * Note that 'z' has dynamic packet resizing and that <cZblklen> will range - * from 32 to 1024, in multiples of 2. - */ - -/*ARGSUSED*/ -char * -zzgetspace(qdaemon, pclen) -struct sdaemon *qdaemon; -size_t *pclen; -{ - *pclen = cZblklen; - return zZtx_buf; -} - -/* - * Send a block of data ... - * - * If (cdata == 0) then the end of the file has been reached. - */ - -/*ARGSUSED*/ -boolean -fzsenddata(qdaemon, zdata, cdata, ilocal, iremote, ipos) -struct sdaemon *qdaemon; -char *zdata; -size_t cdata; -int ilocal; -int iremote; -long ipos; -{ - DEBUG_MESSAGE1 (DEBUG_PROTO, "fzsenddata: %d bytes", cdata); - - if (! fzsend_data (qdaemon, zdata, cdata, cdata == 0)) - return FALSE; - return fzprocess (qdaemon); -} - -/* - * Send a block of data (command or file) ... - */ - -/* This should buffer the data internally. Until it does, it needs to - be able to reset the file position when it is called. This is - really ugly. */ -extern struct stransfer *qTsend; - -static boolean -fzsend_data(qdaemon, zdata, cdata, fendofmessage) -struct sdaemon *qdaemon; -char *zdata; -size_t cdata; -boolean fendofmessage; -{ - size_t n; - - if (iZlast_tx_data_packet == -1 || iZlast_tx_data_packet == ZCRCW) { - cZtxwcnt = cZrxwcnt = 0; - iZjunk_count = 0; - if (!fzsend_hdr (qdaemon, ZBIN, ZDATA, - hvzencode_data_hdr (wpZtxpos), TRUE)) - return FALSE; - } - - n = cdata; - - if (fendofmessage) - iZlast_tx_data_packet = ZCRCF; - else if (iZjunk_count > 3) - iZlast_tx_data_packet = ZCRCW; - else if (wpZtxpos == wpZlastsync) - iZlast_tx_data_packet = ZCRCW; - else if (cZrx_buf_len && (cZrxwcnt += n) >= cZrx_buf_len) - iZlast_tx_data_packet = ZCRCW; - else if ((cZtxwcnt += n) >= cZtxwspac) { - iZlast_tx_data_packet = ZCRCQ; - cZtxwcnt = 0; - } else - iZlast_tx_data_packet = ZCRCG; - - if (++iZtleft > 3) { - iZtleft = 0; - if (cZblklen < 1024) - cZblklen *= 2; -#if 0 /* <cZblklen_override> is currently unnecessary */ - if (cZblklen_override && cZblklen > cZblklen_override) - cZblklen = cZblklen_override; -#endif - if (cZblklen > 1024) - cZblklen = 1024; - if (cZrx_buf_len && cZblklen > cZrx_buf_len) - cZblklen = cZrx_buf_len; - } - -#if DEBUG > 1 - if (FDEBUGGING(DEBUG_PROTO)) { - const char *type; - - switch (iZlast_tx_data_packet) { - case ZCRCW: type = "ZCRCW"; break; - case ZCRCG: type = "ZCRCG"; break; - case ZCRCQ: type = "ZCRCQ"; break; - case ZCRCE: type = "ZCRCE"; break; - case ZCRCF: type = "ZCRCF"; break; - default : type = "UNKNOWN!!!"; break; - } - DEBUG_MESSAGE3 (DEBUG_PROTO, - "fzsend_data: %s, pos 0x%lx, %d bytes", - type, wpZtxpos, n); - } -#endif - - if (!fzsend_data_packet (qdaemon, zdata, n, iZlast_tx_data_packet, - TRUE)) - return FALSE; - - wpZtxpos += n; - - if (iZlast_tx_data_packet == ZCRCW) { - /* - * FIXME: Ideally this would be done in fzprocess. However, it - * is only called if there is data pending which there - * may not be yet. I could have patched fploop() a bit but - * for now, I've done it like this. - */ - switch (getinsync (qdaemon, FALSE)) { - case ZACK: - break; - case ZRPOS: - if (qTsend == NULL - || ! ffileisopen (qTsend->e)) { - ulog (LOG_ERROR, "Can't reset non-file"); - return FALSE; - } - iZlast_tx_data_packet = -1; /* trigger ZDATA */ - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fzsend_data: Seeking to %ld", - (long) (wpZrxpos - wpZtxstart)); - if (!ffileseek (qTsend->e, wpZrxpos - wpZtxstart)) { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - return FALSE; - } - break; - default: - return FALSE; - } - return TRUE; - } - - /* - * If we've reached the maximum transmit window size, let the - * receiver catch up ... - * - * I use (cZtx_window - 2048) to play it safe. - */ - - while (wpZtxpos - wpZlrxpos >= cZtx_window - 2048) { - if (iZlast_tx_data_packet != ZCRCQ) { - if (!fzsend_data_packet (qdaemon, zdata, (size_t) 0, - iZlast_tx_data_packet = ZCRCQ, - TRUE)) - return FALSE; - } - /* - * FIXME: I'd rather not call ffileseek() in this file. When we - * start buffering the outgoing data, the following - * ffileseek() will disappear. - */ - switch (getinsync (qdaemon, TRUE)) { - case ZACK: - break; - case ZRPOS: - if (qTsend == NULL - || ! ffileisopen (qTsend->e)) { - ulog (LOG_ERROR, "Can't reset non-file"); - return FALSE; - } - iZlast_tx_data_packet = -1; /* trigger ZDATA */ - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fzsend_data: Seeking to %ld", - (long) (wpZrxpos - wpZtxstart)); - if (!ffileseek (qTsend->e, wpZrxpos - wpZtxstart)) { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - return FALSE; - } - break; - default: - return FALSE; - } - } - - return TRUE; -} - -/* - * Process existing data ... - */ - -static boolean -fzprocess(qdaemon) -struct sdaemon *qdaemon; -{ - int c,ch; - - while (fzreceive_ready ()) { - READCHAR (qdaemon, ch, 1); - switch (ch) { - case ZPAD: - /* see if we're detecting ZRPOS packets quickly */ - DEBUG_MESSAGE0 (DEBUG_PROTO, - "fzprocess: possible ZRPOS packet"); - /* We just ate the ZPAD char that getinsync - expects, so put it back. */ - iPrecstart = ((iPrecstart + CRECBUFLEN - 1) - % CRECBUFLEN); - c = getinsync (qdaemon, TRUE); - if (c == ZACK) - break; - /* FIXME: sz does a TCFLSH here */ -#if 0 /* FIXME: Not sure if this is needed, or where to put it. */ - /* ZCRCE - dinna wanna starta ping-pong game */ - if (!fzsend_data_packet (qdaemon, zZtx_packet_buf, - 0, ZCRCE, TRUE)) - return FALSE; -#endif - if (c == ZRPOS) { - if (qTsend == NULL - || ! ffileisopen (qTsend->e)) { - ulog (LOG_ERROR, - "Attempt to back up non-file"); - return FALSE; - } - if (! ffileseek (qTsend->e, - wpZrxpos - wpZtxstart)) { - ulog (LOG_ERROR, - "seek: %s", strerror (errno)); - return FALSE; - } - iZlast_tx_data_packet = -1; /* trigger ZDATA */ - break; /* not returning is intentional */ - } - return FALSE; - case XOFF: - case XOFF | 0200: - READCHAR (qdaemon, ch, XON_WAIT); - break; - case CR: - break; - default: - iZjunk_count++; - break; - } - } - - return TRUE; -} - -/* - * Wait for data to come in. - * - * This continues processing until a complete file or command has been - * received. - */ - -boolean -fzwait(qdaemon) -struct sdaemon *qdaemon; -{ - int c,cerr,rxcount; - boolean fexit; - achdrval_t rx_hdr; - - if (!fzstart_rx ()) - return FALSE; - - cerr = cZretries; - - goto nxthdr; - - for (;;) { - if (!fzsend_hdr (qdaemon, ZHEX, ZRPOS, - hvzencode_data_hdr (wpZrxbytes), FALSE)) - return FALSE; -nxthdr: - c = izrecv_hdr (qdaemon, rx_hdr); - - switch (c) { - case ZM_TIMEOUT: - case ZNAK: - if (--cerr < 0) { - ulog (LOG_ERROR, "fzwait: retries exhausted"); - return FALSE; - } - continue; - case ZM_ERROR: - if (--cerr < 0) { - ulog (LOG_ERROR, "fzwait: retries exhausted"); - return FALSE; - } - /*fport_break ();*/ - continue; - case ZM_RCDO: - case ZFIN: - return FALSE; - case ZRPOS: - case ZACK: - goto nxthdr; /* ignore, partner is out of sync */ - case ZDATA: { - winpos_t rx_bytes; - - zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes); - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fzwait: bytes(us,them) 0x%lx,0x%lx", - wpZrxbytes, rx_bytes); - if (rx_bytes != wpZrxbytes) { - if (--cerr < 0) { - ulog (LOG_ERROR, - "fzwait: retries exhausted"); - return FALSE; - } - (void) zrdat32 (qdaemon, zZrx_packet_buf, - 1024, &rxcount); - /*fport_break ();*/ - /* - * FIXME: Seems to me we should ignore this one - * and go for a timeout, the theory being - * that the appropriate ZRPOS has already - * been sent. We're obviously out of sync. - * /dje 92Mar10 - */ - continue; /* goto nxthdr? */ - } -moredata: - /* - * Do not call fgot_data() with (rxcount == 0) if it's - * not ZCRCF. fgot_data() will erroneously think this - * is the end of the message. - */ - c = zrdat32 (qdaemon, zZrx_packet_buf, 1024, - &rxcount); -#if DEBUG > 1 - if (FDEBUGGING(DEBUG_PROTO)) { - const char *msg; - - if (c < 0) { - msg = ZZHEADER_NAME(c); - } else { - switch (c) { - case GOTCRCW: msg = "ZCRCW"; break; - case GOTCRCG: msg = "ZCRCG"; break; - case GOTCRCQ: msg = "ZCRCQ"; break; - case GOTCRCE: msg = "ZCRCE"; break; - case GOTCRCF: msg = "ZCRCF"; break; - default : msg = NULL; break; - } - } - if (msg != NULL) - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fzwait: zrdat32: %s, %d bytes", - msg, rxcount); - else - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fzwait: zrdat32: %d, %d bytes", - c, rxcount); - } -#endif - switch (c) { - case ZM_ERROR: /* CRC error */ - cZerrors++; - if (--cerr < 0) { - ulog (LOG_ERROR, - "fzwait: retries exhausted"); - return FALSE; - } - /*fport_break ();*/ - continue; - case ZM_TIMEOUT: - cZtimeouts++; - if (--cerr < 0) { - ulog (LOG_ERROR, - "fzwait: retries exhausted"); - return FALSE; - } - continue; - case ZM_RCDO: - return FALSE; - case GOTCRCW: - iZlast_rx_data_packet = ZCRCW; - cerr = cZretries; - if (rxcount != 0 - && !fgot_data (qdaemon, zZrx_packet_buf, - (size_t) rxcount, - (const char *) NULL, - (size_t) 0, - -1, -1, (long) -1, - TRUE, &fexit)) - return FALSE; - wpZrxbytes += rxcount; - if (!fzsend_hdr (qdaemon, ZHEX, ZACK, - hvzencode_data_hdr (wpZrxbytes), - FALSE)) - return FALSE; - if (! fsend_data (qdaemon->qconn, &xon, - (size_t) 1, FALSE)) - return FALSE; - goto nxthdr; - case GOTCRCQ: - iZlast_rx_data_packet = ZCRCQ; - cerr = cZretries; - if (rxcount != 0 - && !fgot_data (qdaemon, zZrx_packet_buf, - (size_t) rxcount, - (const char *) NULL, - (size_t) 0, - -1, -1, (long) -1, - TRUE, &fexit)) - return FALSE; - wpZrxbytes += rxcount; - if (!fzsend_hdr (qdaemon, ZHEX, ZACK, - hvzencode_data_hdr (wpZrxbytes), - FALSE)) - return FALSE; - goto moredata; - case GOTCRCG: - iZlast_rx_data_packet = ZCRCG; - cerr = cZretries; - if (rxcount != 0 - && !fgot_data (qdaemon, zZrx_packet_buf, - (size_t) rxcount, - (const char *) NULL, - (size_t) 0, - -1, -1, (long) -1, - TRUE, &fexit)) - return FALSE; - wpZrxbytes += rxcount; - goto moredata; - case GOTCRCE: - iZlast_rx_data_packet = ZCRCE; - cerr = cZretries; - if (rxcount != 0 - && !fgot_data (qdaemon, zZrx_packet_buf, - (size_t) rxcount, - (const char *) NULL, - (size_t) 0, - -1, -1, (long) -1, - TRUE, &fexit)) - return FALSE; - wpZrxbytes += rxcount; - goto nxthdr; - case GOTCRCF: - iZlast_rx_data_packet = ZCRCF; - /* - * fzfinish_rx() must be called before - * fgot_data() because fgot_data() will send - * out a UUCP-command but the sender won't be - * ready for it until it receives our final - * ZACK. - */ - cerr = cZretries; - wpZrxbytes += rxcount; - if (!fzfinish_rx (qdaemon)) - return FALSE; - if (!fgot_data (qdaemon, zZrx_packet_buf, - (size_t) rxcount, - (const char *) NULL, - (size_t) 0, -1, -1, - (long) -1, TRUE, &fexit)) - return FALSE; - /* - * FIXME: Examine <fexit>? - * Or maybe ensure it's TRUE? - */ - return TRUE; - } - return FALSE; - } - default: - ulog (LOG_FATAL, "fzwait: received header %s", - ZZHEADER_NAME(c)); - return FALSE; - } - } - - return TRUE; -} - -/* - * File level routine. Called when initiating/terminating file transfers. - * - * When starting to send a file: (TRUE, TRUE, cbytes) - * When starting to receive a file: (TRUE, FALSE, -1) - * When send EOF, check resend: (FALSE, TRUE, -1) - * When receive EOF, check re-receive: (FALSE, FALSE, -1) - */ - -boolean -fzfile(qdaemon, qtrans, fstart, fsend, cbytes, pfhandled) -struct sdaemon *qdaemon; -struct stransfer *qtrans; -boolean fstart; -boolean fsend; -long cbytes; -boolean *pfhandled; -{ - long iredo; - - *pfhandled = FALSE; - - DEBUG_MESSAGE2 (DEBUG_PROTO, "fzfile: fstart=%d, fsend=%d", fstart, - fsend); - - if (fsend) { - if (fstart) - return fzstart_tx (); - if (! fzfinish_tx (qdaemon, &iredo)) - return FALSE; - if (iredo >= 0) { - if (! ffileisopen (qtrans->e)) { - ulog (LOG_ERROR, - "Attempt to back up non-file"); - return FALSE; - } - if (! ffileseek (qtrans->e, iredo)) { - ulog (LOG_ERROR, - "seek: %s", strerror (errno)); - return FALSE; - } - *pfhandled = TRUE; - qtrans->fsendfile = TRUE; - return fqueue_send (qdaemon, qtrans); - } - } - - return TRUE; -} - -/****************************************************************************/ - - -#if 0 /* not used, we only use 32 bit crc's */ -/* - * crctab calculated by Mark G. Mendel, Network Systems Corporation - */ - -static unsigned short crctab[256] = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, - 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, - 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, - 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, - 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, - 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, - 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, - 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, - 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, - 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, - 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, - 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, - 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, - 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, - 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, - 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, - 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, - 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, - 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, - 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, - 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, - 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 -}; -#endif /* crctab */ - -/* - * Copyright (C) 1986 Gary S. Brown. You may use this program, or - * code or tables extracted from it, as desired without restriction. - */ - -/* First, the polynomial itself and its table of feedback terms. The */ -/* polynomial is */ -/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ -/* Note that we take it "backwards" and put the highest-order term in */ -/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */ -/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */ -/* the MSB being 1. */ - -/* Note that the usual hardware shift register implementation, which */ -/* is what we're using (we're merely optimizing it by doing eight-bit */ -/* chunks at a time) shifts bits into the lowest-order term. In our */ -/* implementation, that means shifting towards the right. Why do we */ -/* do it this way? Because the calculated CRC must be transmitted in */ -/* order from highest-order term to lowest-order term. UARTs transmit */ -/* characters in order from LSB to MSB. By storing the CRC this way, */ -/* we hand it to the UART in the order low-byte to high-byte; the UART */ -/* sends each low-bit to hight-bit; and the result is transmission bit */ -/* by bit from highest- to lowest-order term without requiring any bit */ -/* shuffling on our part. Reception works similarly. */ - -/* The feedback terms table consists of 256, 32-bit entries. Notes: */ -/* */ -/* The table can be generated at runtime if desired; code to do so */ -/* is shown later. It might not be obvious, but the feedback */ -/* terms simply represent the results of eight shift/xor opera- */ -/* tions for all combinations of data and CRC register values. */ -/* */ -/* The values must be right-shifted by eight bits by the "updcrc" */ -/* logic; the shift must be unsigned (bring in zeroes). On some */ -/* hardware you could probably optimize the shift in assembler by */ -/* using byte-swap instructions. */ - -static unsigned long crc_32_tab[] = { /* CRC polynomial 0xedb88320 */ - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, - 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, - 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, - 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, - 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, - 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, - 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, - 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, - 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, - 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, - 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, - 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, - 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, - 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, - 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, - 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, - 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, - 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, - 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, - 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, - 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, - 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, - 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, - 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, - 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, - 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, - 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, - 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, - 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, - 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, - 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, - 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, - 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, - 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, - 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, - 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, - 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, - 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, - 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, - 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, - 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, - 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, - 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, - 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, - 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, - 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, - 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, - 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, - 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, - 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, - 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, - 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL -}; - -/* - * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. - * NOTE: First argument must be in range 0 to 255. - * Second argument is referenced twice. - * - * Programmers may incorporate any or all code into their programs, - * giving proper credit within the source. Publication of the - * source routines is permitted so long as proper credit is given - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, - * Omen Technology. - */ - -#define updcrc(cp, crc) (crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) - -#define UPDC32(b, crc) \ - (crc_32_tab[((unsigned)(crc) ^ (unsigned)(b)) & 0xff] \ - ^ (((crc) >> 8) & 0x00ffffffL)) - -/****************************************************************************/ - -/* - * This section contains the guts of the Zmodem protocol. The intention - * is to leave as much of it alone as possible at the start. Overtime it - * will be cleaned up (EG: I'd like to clean up the naming of the globals). - * Also, Zmodem has a different coding style. Over time this will be converted - * to the Taylor UUCP coding style. - */ - -/* - * Start the protocol (exchange init packets) ... - * - * UUCP can transfer files in both directions in one session. Therefore the - * init sequence is a little different. - * - * 1) ZINIT packets are exchanged - * - contains protocol version and protocol flags - * 2) ZDATA packets are exchanged - * - is intended to contain various numeric and string information - * 3) ZACK packets are exchanged - * 4) ZINITEND packets are exchanged - */ - -static boolean -fzstart_proto(qdaemon) -struct sdaemon *qdaemon; -{ - int i; - achdrval_t tx_hdr,rx_hdr; - - for (i = 0; i < cZstartup_retries; i++) { - stohdr (0L, tx_hdr); - tx_hdr[ZF0] = ZPROTOCOL_VERSION; - if (fZesc_ctl) - tx_hdr[ZF1] |= TX_ESCCTL; - switch (izexchange_init (qdaemon, ZINIT, tx_hdr, rx_hdr)) { - case -1: return FALSE; - case 0: continue; - case 1: break; - } -#if 0 /* can't work, but kept for documentation */ - if (rx_hdr[ZF0] == 0) { - ulog (LOG_ERROR, "Old protocol version, init failed"); - return FALSE; - } -#endif - fZesc_ctl = fZesc_ctl || (rx_hdr[ZF1] & TX_ESCCTL) != 0; - - stohdr (0L, tx_hdr); - switch (izexchange_init (qdaemon, ZDATA, tx_hdr, rx_hdr)) { - case -1: return FALSE; - case 0: continue; - case 1: break; - } - - stohdr (0L, tx_hdr); - switch (izexchange_init (qdaemon, ZACK, tx_hdr, rx_hdr)) { - case -1: return FALSE; - case 0: continue; - case 1: break; - } - - stohdr (0L, tx_hdr); - switch (izexchange_init (qdaemon, ZINITEND, tx_hdr, rx_hdr)) { - case -1: return FALSE; - case 0: continue; - case 1: break; - } - - DEBUG_MESSAGE0 (DEBUG_PROTO, - "fzstart_proto: Protocol started"); - return TRUE; - - /* FIXME: see protg.c regarding sequencing here. */ - } - - ulog (LOG_ERROR, "Protocol init failed"); - return FALSE; -} - -/* - * Exchange init messages. This is based on 'g'. - * See the comments concerning fgexchange_init() in protg.c. - * - * We return 1 for success, 0 for restart, -1 for comm failure (terminate). - */ - -static int -izexchange_init(qdaemon, send_type, send_val, recv_val) -struct sdaemon *qdaemon; -int send_type; -achdrval_t send_val; -achdrval_t recv_val; -{ - int i,recv_type,count; - - for (i = 0; i < CEXCHANGE_INIT_RETRIES; i++) { - if (!fzsend_hdr (qdaemon, send_type == ZDATA ? ZBIN : ZHEX, - send_type, rclhdr (send_val), FALSE)) - return -1; - - /* - * The ZDATA packet is intended to contain the <Attn> string - * (eventually, if it's ever usable) and allow for anything - * else that will need to be thrown in. - */ - - if (send_type == ZDATA) { - count = czbuild_data_packet (zZtx_packet_buf, "", - (size_t) 1, ZCRCF); - if (!fsend_data (qdaemon->qconn, zZtx_packet_buf, - (size_t) count, FALSE)) - return -1; - } - - recv_type = izrecv_hdr (qdaemon, recv_val); - - switch (recv_type) { - case ZM_TIMEOUT: - case ZM_ERROR: - continue; - case ZM_RCDO: - case ZFIN: - return -1; - case ZINIT: - case ZACK: - case ZINITEND: - break; - case ZDATA: - if (zrdat32 (qdaemon, zZrx_packet_buf, 1024, &count) - == GOTCRCF) - break; - continue; - default: - continue; - } - - if (recv_type == send_type) - return 1; - - /* - * If the other side is farther along than we are, we have lost - * a packet. Fall immediately back to ZINIT (but don't fail - * if we are already doing ZINIT, since that would count - * against cStart_retries more than it should). - * - * FIXME: The ">" test is "<" in protg.c. Check who's right. - */ - - if (recv_type > send_type && send_type != ZINIT) - return 0; - - /* - * If we are sending ZINITEND and we receive an ZINIT, the - * other side has falled back (we know this because we have - * seen a ZINIT from them). Fall back ourselves to start - * the whole handshake over again. - */ - - if (recv_type == ZINIT && send_type == ZINITEND) - return 0; - } - - return 0; -} - -/* - * Shut down the protocol ... - */ - -static boolean -fzshutdown_proto(qdaemon) -struct sdaemon *qdaemon; -{ - (void) fzsend_hdr (qdaemon, ZHEX, ZFIN, 0L, FALSE); - return TRUE; -} - -/* - * Reset the transmitter side for sending a new message ... - */ - -static boolean -fzstart_tx() -{ - iZlast_tx_data_packet = -1; - - /* - * <wpZlastsync> is set to -1L to suppress ZCRCW request otherwise - * triggered by (wpZlastsync == wpZtxpos). - */ - - cZblklen = 1024; - wpZlastsync = -1L; - iZbeenhereb4 = 0; - iZtleft = 0; - iZjunk_count = 0; - - wpZtxpos = (wpZtxpos + 1024L) & ~1023L; /* next packet boundary */ - wpZlrxpos = wpZrxpos = wpZtxpos; - - wpZtxstart = wpZtxpos; /* so we can compute the "file offset" */ - - return TRUE; -} - -/* - * Finish the sending of a message ... - * - * Basically, we wait for some indication that the receiver received our last - * message. If the receiver tells us to restart from some point, we set - * *plredo to that point. - * - * FIXME: This function is a major kludge at the moment. It is taken from - * getinsync(). It is necessary because I don't yet buffer outgoing data. - * It will go away when we do (buffer outgoing data). - */ - -static boolean -fzfinish_tx(qdaemon, plredo) -struct sdaemon *qdaemon; -long *plredo; -{ - int c,cerr,ctimeouts; - achdrval_t rx_hdr; - winpos_t rx_bytes; - - *plredo = -1; - cerr = cZretries; - ctimeouts = 0; - - DEBUG_MESSAGE4 (DEBUG_PROTO, - "fzfinish_tx: txpos=0x%lx, rxpos=0x%lx, lrxpos=0x%lx, rxbytes=0x%lx", - wpZtxpos, wpZrxpos, wpZlrxpos, wpZrxbytes); - - for (;;) { - c = izrecv_hdr (qdaemon, rx_hdr); - - switch (c) { - case ZRPOS: - wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos, - wpZlrxpos, wpZtxpos); - /* - * If the receiver sends a ZRPOS for the 1k block after - * the one we're currently at, we lost the final ZACK. - * We cheat and ignore this ZRPOS. Remember: the theory - * is that this entire function will go away when we - * begin buffering the outgoing data. Of course, one - * can reword the protocol definition and say this - * isn't cheating at all. - */ - if (((wpZtxpos + 1024) & ~1023) == wpZrxpos) - return TRUE; - cZbytes_resent += wpZtxpos - wpZrxpos; - wpZlrxpos = wpZtxpos = wpZrxpos; - if (wpZlastsync == wpZrxpos) { - if (++iZbeenhereb4 > 4) - if (cZblklen > 32) - cZblklen /= 2; - /* FIXME: shouldn't we reset iZbeenhereb4? */ - } - wpZlastsync = wpZrxpos; - iZlast_tx_data_packet = ZCRCW; /* force a timeout */ - *plredo = wpZrxpos - wpZtxstart; - return TRUE; - case ZACK: - wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos, - wpZlrxpos, wpZtxpos); - wpZlrxpos = wpZrxpos; - if (wpZtxpos == wpZrxpos) /* the ACK we want? */ - return TRUE; - break; - case ZDATA: - /* - * We cheat here and take advantage of UUCP's current - * half duplex nature. If we get a ZDATA starting on - * the next 1k boundary, we lost the ZACK. We cheat and - * tuck it away so that izrecv_hdr() can later detect - * it. Remember: see above. - */ - zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes); - if (((wpZrxbytes + 1024L) & ~1023L) == rx_bytes) { - iZpkt_rcvd_kludge = ZDATA; - hvZpkt_hdrval_kludge = rclhdr (rx_hdr); - return TRUE; - } - break; /* ignore, out of sync (old) */ - case ZNAK: - /* - * We cheat here and take advantage of UUCP's current - * half duplex nature. If we get a ZNAK starting on - * the next 1k boundary, we lost the ZACK. We cheat and - * throw the ZNAK away. Remember: see above. - * - * On the other hand, if (rx_bytes == wpZrxbytes) then - * the other side is also in fzfinish_tx(). He must - * have lost our ZACK, so we send him another. - */ - zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes); - if (((wpZrxbytes + 1024L) & ~1023L) == rx_bytes) - return TRUE; - if (rx_bytes == wpZrxbytes) { - if (!fzsend_hdr (qdaemon, ZHEX, ZACK, - hvzencode_data_hdr (wpZrxbytes), - TRUE)) - return FALSE; - } - break; /* ignore, out of sync (old) */ - case ZFIN: - case ZM_RCDO: - return FALSE; - case ZM_TIMEOUT: - if (--cerr < 0) { - ulog (LOG_ERROR, - "fzfinish_tx: retries exhausted"); - return FALSE; - } - /* - * Normally the sender doesn't send NAK's for timeouts. - * We have to here because of the following scenario: - * - * - We send ZDATA/ZCRCF - * - They send ZACK (corrupted) - * - They send ZDATA/ZCRCF (corrupted) - * - * At this point, both sides are in fzfinish_tx(). - * We only send ZNAK every second timeout to increase - * our timeout delay vs. our partner. This tries to - * avoid ZRPOS and ZNAK "passing in transit". - */ - if (++ctimeouts % 2 == 0) - if (!fzsend_hdr (qdaemon, ZHEX, ZNAK, - hvzencode_data_hdr (wpZtxpos), - TRUE)) - return FALSE; - break; - case ZM_ERROR: - default: - if (--cerr < 0) { - ulog (LOG_ERROR, - "fzfinish_tx: retries exhausted"); - return FALSE; - } - if (!fzsend_hdr (qdaemon, ZHEX, ZNAK, - hvzencode_data_hdr (wpZtxpos), - TRUE)) - return FALSE; - break; - } - } -} - -/* - * Initialize the receiver ... - */ - -static boolean -fzstart_rx() -{ - wpZrxbytes = (wpZrxbytes + 1024L) & ~1023L; /* next packet boundary */ - - return TRUE; -} - -/* - * Terminate the receiver ... - * - * Acknowledge the last packet received. - */ - -static boolean -fzfinish_rx(qdaemon) -struct sdaemon *qdaemon; -{ - DEBUG_MESSAGE0 (DEBUG_PROTO, "fzfinish_rx: message/file received"); - - return fzsend_hdr (qdaemon, ZHEX, ZACK, - hvzencode_data_hdr (wpZrxbytes), FALSE); -} - -/* - * Send a Zmodem header to our partner ... - */ - -static boolean -fzsend_hdr(qdaemon, ipkttype, ihdrtype, hdrval, fcheckreceive) -struct sdaemon *qdaemon; -int ipkttype; -int ihdrtype; -hdrval_t hdrval; -boolean fcheckreceive; -{ - int cpacketlen; - - DEBUG_MESSAGE2 (DEBUG_PROTO, "fzsend_hdr: %s, data = 0x%lx", - ZZHEADER_NAME(ihdrtype), hdrval); - - cpacketlen = czbuild_header (zZtx_packet_buf, ipkttype, - ihdrtype, hdrval); - -#ifdef DJE_TESTING -#if 0 - if (ihdrtype == ZACK && rand () % 100 < uucptest2) { - cZheaders_sent++; - return TRUE; - } -#else - if (ihdrtype == ZACK || ihdrtype == ZDATA) { - boolean fresult; - int old; - extern int uucptest,uucptest2; - - old = uucptest; - uucptest = uucptest2; - cZheaders_sent++; - fresult = fsend_data (qdaemon->qconn, zZtx_packet_buf, - (size_t) cpacketlen, fcheckreceive); - uucptest = old; - return fresult; - } -#endif -#endif - cZheaders_sent++; - return fsend_data (qdaemon->qconn, zZtx_packet_buf, - (size_t) cpacketlen, fcheckreceive); -} - -/* - * Send a data packet to our partner ... - * <frameend> is one of ZCRCx. - */ - -static boolean -fzsend_data_packet(qdaemon, zdata, cdata, frameend, fcheckreceive) -struct sdaemon *qdaemon; -char *zdata; -size_t cdata; -int frameend; -boolean fcheckreceive; -{ - int cpacketlen; - - cpacketlen = czbuild_data_packet (zZtx_packet_buf, zdata, cdata, - frameend); - - return fsend_data (qdaemon->qconn, zZtx_packet_buf, - (size_t) cpacketlen, fcheckreceive); -} - -/* - * Build Zmodem headers ... - * - * Note that we use 32 bit CRC's for ZHEX headers. - * - * This function is a combination of zm fns: zsbhdr(), zsbh32(), and zshhdr(). - */ - -static int -czbuild_header(zresult, ipkttype, ihdrtype, hdrval) -char *zresult; -int ipkttype; -int ihdrtype; -hdrval_t hdrval; -{ - char *p; - int i; - unsigned long crc; - achdrval_t achdrval; - - p = zresult; - - switch (ipkttype) { - case ZBIN: - *p++ = ZPAD; - *p++ = ZDLE; - *p++ = ZBIN; - p = zputchar (p, ihdrtype); - crc = ICRCINIT; - crc = UPDC32 (ihdrtype, crc); - stohdr (hdrval, achdrval); - for (i = 0; i < 4; i++) { - p = zputchar (p, achdrval[i]); - crc = UPDC32 (achdrval[i], crc); - } - crc = ~crc; - for (i = 0; i < 4; i++) { - p = zputchar (p, (char) crc); - crc >>= 8; - } - break; - case ZHEX: /* build hex header */ - *p++ = ZPAD; - *p++ = ZPAD; - *p++ = ZDLE; - *p++ = ZHEX; - p = zputhex (p, ihdrtype); - crc = ICRCINIT; - crc = UPDC32 (ihdrtype, crc); - stohdr (hdrval, achdrval); - for (i = 0; i < 4; i++) { - p = zputhex (p, achdrval[i]); - crc = UPDC32 (achdrval[i], crc); - } - crc = ~crc; - for (i = 0; i < 4; i++) { - p = zputhex (p, (char) crc); - crc >>= 8; - } - *p++ = CR; - /* - * Uncork the remote in case a fake XOFF has stopped data flow. - */ - if (ihdrtype != ZFIN && ihdrtype != ZACK) /* FIXME: why? */ - *p++ = XON; - break; - default: - ulog (LOG_FATAL, "czbuild_header: ipkttype == %d", ipkttype); - break; - } - - return p - zresult; -} - -/* - * Build Zmodem data packets ... - * - * This function is zsdata() and zsda32() from the zm source. - */ - -static int -czbuild_data_packet(zresult, zdata, cdata, frameend) -char *zresult; -const char *zdata; -size_t cdata; -int frameend; -{ - char *p; - unsigned long crc; - - p = zresult; - - crc = ICRCINIT; - for ( ; cdata-- != 0; zdata++) { - char c; - - c = *zdata; - if (c & 0140) - *p++ = c; - else - p = zputchar (p, c); - crc = UPDC32 ((unsigned char) c, crc); - } - *p++ = ZDLE; - *p++ = frameend; - crc = UPDC32 (frameend, crc); - crc = ~crc; - for (cdata = 0; cdata < 4; cdata++) { - p = zputchar (p, (char) crc); - crc >>= 8; - } - if (frameend == ZCRCW || frameend == ZCRCE || frameend == ZCRCF) { - *p++ = CR; - *p++ = XON; - } - - return p - zresult; -} - -/* - * Read in a header ... - * - * This is function zgethdr() from the Zmodem source. - */ - -static int -izrecv_hdr(qdaemon, hdr) -struct sdaemon *qdaemon; -achdrval_t hdr; -{ - int c,cerr; - - /* - * Kludge alert! If another part of the program received a packet but - * wasn't ready to handle it, it is tucked away for us to handle now. - */ - - if (iZpkt_rcvd_kludge != -1) { - c = iZpkt_rcvd_kludge; - iZpkt_rcvd_kludge = -1; - stohdr (hvZpkt_hdrval_kludge, hdr); - DEBUG_MESSAGE2 (DEBUG_PROTO, - "izrecv_hdr: queued %s, data = 0x%lx", - ZZHEADER_NAME(c), rclhdr (hdr)); - cZheaders_received++; - return c; - } - - cerr = cZmax_garbage; /* Max bytes before start of frame */ - -again: - switch (c = noxrd7 (qdaemon)) { - case ZM_TIMEOUT: - case ZM_ERROR: - case ZM_RCDO: - goto fifi; - case ZPAD: /* This is what we want */ - break; - case CR: /* padding at end of previous header */ - default: - if (--cerr < 0) { - c = ZM_ERROR; - goto fifi; - } - goto again; - } - -splat: - switch (c = noxrd7 (qdaemon)) { - case ZPAD: - if (--cerr < 0) { - c = ZM_ERROR; - goto fifi; - } - goto splat; - case ZM_TIMEOUT: - case ZM_RCDO: - goto fifi; - case ZDLE: /* This is what we want */ - break; - default: - if (--cerr < 0) { - c = ZM_ERROR; - goto fifi; - } - goto again; - } - - switch (c = noxrd7 (qdaemon)) { - case ZM_TIMEOUT: - case ZM_RCDO: - goto fifi; - case ZBIN: - c = zrbhdr32 (qdaemon, hdr); - break; - case ZHEX: - c = zrhhdr (qdaemon, hdr); - break; - default: - if (--cerr < 0) { - c = ZM_ERROR; - goto fifi; - } - goto again; - } - -fifi: - switch (c) { - case ZM_TIMEOUT: - cZtimeouts++; - break; - case ZM_ERROR: - cZerrors++; - break; - case ZM_RCDO: - break; - default: - cZheaders_received++; - break; - } - DEBUG_MESSAGE2 (DEBUG_PROTO, "izrecv_hdr: %s, data = 0x%lx", - ZZHEADER_NAME(c), rclhdr (hdr)); - - return c; -} - -/* - * Receive a binary style header (type and position) with 32 bit FCS ... - */ - -static int -zrbhdr32(qdaemon, hdr) -struct sdaemon *qdaemon; -achdrval_t hdr; -{ - int c,i,type; - unsigned long crc; - - if ((c = zdlread (qdaemon)) & ~0377) - return c; - type = c; - crc = ICRCINIT; - crc = UPDC32 (c, crc); - - for (i = 0; i < 4; i++) { - if ((c = zdlread (qdaemon)) & ~0377) - return c; - crc = UPDC32 (c, crc); - hdr[i] = (char) c; - } - for (i = 0; i < 4; i++) { - if ((c = zdlread (qdaemon)) & ~0377) - return c; - crc = UPDC32 (c, crc); - } - if (crc != IHDRCRC) - return ZM_ERROR; - - return type; -} - -/* - * Receive a hex style header (type and position) ... - */ - -static int -zrhhdr(qdaemon, hdr) -struct sdaemon *qdaemon; -achdrval_t hdr; -{ - int c,i,type; - unsigned long crc; - - if ((c = zgethex (qdaemon)) < 0) - return c; - type = c; - crc = ICRCINIT; - crc = UPDC32 (c, crc); - - for (i = 0; i < 4; i++) { - if ((c = zgethex (qdaemon)) < 0) - return c; - crc = UPDC32 (c, crc); - hdr[i] = (char) c; - } - for (i = 0; i < 4; i++) { - if ((c = zgethex (qdaemon)) < 0) - return c; - crc = UPDC32 (c, crc); - } - if (crc != IHDRCRC) - return ZM_ERROR; - - return type; -} - -/* - * Receive a data packet ... - */ - -static int -zrdat32(qdaemon, buf, length, iprxcount) -struct sdaemon *qdaemon; -char *buf; -int length; -int *iprxcount; -{ - int c,d; - unsigned long crc; - char *end; - - crc = ICRCINIT; - *iprxcount = 0; - end = buf + length; - while (buf <= end) { - if ((c = zdlread (qdaemon)) & ~0377) { -crcfoo: - switch (c) { - case GOTCRCE: - case GOTCRCG: - case GOTCRCQ: - case GOTCRCW: - case GOTCRCF: - d = c; - c &= 0377; - crc = UPDC32 (c, crc); - if ((c = zdlread (qdaemon)) & ~0377) - goto crcfoo; - crc = UPDC32 (c, crc); - if ((c = zdlread (qdaemon)) & ~0377) - goto crcfoo; - crc = UPDC32 (c, crc); - if ((c = zdlread (qdaemon)) & ~0377) - goto crcfoo; - crc = UPDC32 (c, crc); - if ((c = zdlread (qdaemon)) & ~0377) - goto crcfoo; - crc = UPDC32 (c, crc); - if (crc != IHDRCRC) - return ZM_ERROR; - *iprxcount = length - (end - buf); - return d; - case ZM_TIMEOUT: - case ZM_RCDO: - return c; - default: - return ZM_ERROR; - } - } - *buf++ = (char) c; - crc = UPDC32 (c, crc); - } - - return ZM_ERROR; /* bad packet, too long */ -} - -/* - * Respond to receiver's complaint, get back in sync with receiver ... - */ - -static int -getinsync(qdaemon, flag) -struct sdaemon *qdaemon; -boolean flag; -{ - int c,cerr; - achdrval_t rx_hdr; - - cerr = cZretries; - - for (;;) { - c = izrecv_hdr (qdaemon, rx_hdr); - - switch (c) { - case ZRPOS: - wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos, - wpZlrxpos, wpZtxpos); - cZbytes_resent += wpZtxpos - wpZrxpos; - wpZlrxpos = wpZtxpos = wpZrxpos; - if (wpZlastsync == wpZrxpos) { - if (++iZbeenhereb4 > 4) - if (cZblklen > 32) - cZblklen /= 2; - /* FIXME: shouldn't we reset iZbeenhereb4? */ - } - wpZlastsync = wpZrxpos; - return ZRPOS; - case ZACK: - wpZrxpos = lzupdate_rxpos (rx_hdr, wpZrxpos, - wpZlrxpos, wpZtxpos); - wpZlrxpos = wpZrxpos; - if (flag || wpZtxpos == wpZrxpos) - return ZACK; - break; - case ZNAK: { - winpos_t rx_bytes; - /* - * Our partner is in fzfinish_tx() and is waiting - * for ZACK ... - */ - zdecode_data_hdr (rclhdr (rx_hdr), &rx_bytes); - if (rx_bytes == wpZrxbytes) { - if (!fzsend_hdr (qdaemon, ZHEX, ZACK, - hvzencode_data_hdr (wpZrxbytes), - TRUE)) - return FALSE; - } - break; - } - case ZFIN: - case ZM_RCDO: - return c; - case ZM_TIMEOUT: - if (--cerr < 0) { - ulog (LOG_ERROR, - "getinsync: retries exhausted"); - return ZM_ERROR; - } - break; /* sender doesn't send ZNAK for timeout */ - case ZM_ERROR: - default: - if (--cerr < 0) { - ulog (LOG_ERROR, - "getinsync: retries exhausted"); - return ZM_ERROR; - } - if (!fzsend_hdr (qdaemon, ZHEX, ZNAK, - hvzencode_data_hdr (wpZtxpos), - TRUE)) - return ZM_ERROR; - break; - } - } -} - -/* - * Send a byte as two hex digits ... - */ - -static char * -zputhex(p, ch) -char *p; -int ch; -{ - static char digits[] = "0123456789abcdef"; - - *p++ = digits[(ch & 0xF0) >> 4]; - *p++ = digits[ch & 0xF]; - return p; -} - -/* - * Send character c with ZMODEM escape sequence encoding ... - * - * Escape XON, XOFF. - * FIXME: Escape CR following @ (Telenet net escape) ... disabled for now - * Will need to put back references to <lastsent>. - */ - -static char * -zputchar(p, ch) -char *p; -int ch; -{ - char c = ch; - - /* Quick check for non control characters */ - - if (c & 0140) { - *p++ = c; - } else { - switch (c & 0377) { - case ZDLE: - *p++ = ZDLE; - *p++ = c ^ 0100; - break; - case CR: -#if 0 - if (!fZesc_ctl && (lastsent & 0177) != '@') - goto sendit; -#endif - /* fall through */ - case 020: /* ^P */ - case XON: - case XOFF: - *p++ = ZDLE; - c ^= 0100; -/*sendit:*/ - *p++ = c; - break; - default: - if (fZesc_ctl && !(c & 0140)) { - *p++ = ZDLE; - c ^= 0100; - } - *p++ = c; - break; - } - } - - return p; -} - -/* - * Decode two lower case hex digits into an 8 bit byte value ... - */ - -static int -zgethex(qdaemon) -struct sdaemon *qdaemon; -{ - int c,n; - - if ((c = noxrd7 (qdaemon)) < 0) - return c; - n = c - '0'; - if (n > 9) - n -= ('a' - ':'); - if (n & ~0xF) - return ZM_ERROR; - if ((c = noxrd7 (qdaemon)) < 0) - return c; - c -= '0'; - if (c > 9) - c -= ('a' - ':'); - if (c & ~0xF) - return ZM_ERROR; - c += (n << 4); - - return c; -} - -/* - * Read a byte, checking for ZMODEM escape encoding ... - */ - -static int -zdlread(qdaemon) -struct sdaemon *qdaemon; -{ - int c; - -again: - READCHAR (qdaemon, c, cZtimeout); - if (c < 0) - return c; - if (c & 0140) /* quick check for non control characters */ - return c; - switch (c) { - case ZDLE: - break; - case XON: - goto again; - case XOFF: - READCHAR (qdaemon, c, XON_WAIT); - goto again; - default: - if (fZesc_ctl && !(c & 0140)) - goto again; - return c; - } - -again2: - READCHAR (qdaemon, c, cZtimeout); - if (c < 0) - return c; - switch (c) { - case ZCRCE: - case ZCRCG: - case ZCRCQ: - case ZCRCW: - case ZCRCF: - return c | GOTOR; - case ZRUB0: /* FIXME: This is never generated. */ - return 0177; - case ZRUB1: /* FIXME: This is never generated. */ - return 0377; - case XON: - goto again2; - case XOFF: - READCHAR (qdaemon, c, XON_WAIT); - goto again2; - default: - if (fZesc_ctl && !(c & 0140)) - goto again2; /* FIXME: why again2? */ - if ((c & 0140) == 0100) - return c ^ 0100; - break; - } - - return ZM_ERROR; -} - -/* - * Read a character from the modem line with timeout ... - * Eat parity bit, XON and XOFF characters. - */ - -static int -noxrd7(qdaemon) -struct sdaemon *qdaemon; -{ - int c; - - for (;;) { - READCHAR (qdaemon, c, cZtimeout); - if (c < 0) - return c; - switch (c &= 0177) { - case XON: - continue; - case XOFF: - READCHAR (qdaemon, c, XON_WAIT); - continue; - case CR: - case ZDLE: - return c; - default: - if (fZesc_ctl && !(c & 0140)) - continue; - return c; - } - } -} - -/* - * Read a character from the receive buffer, or from the line if empty ... - * - * <timeout> is in seconds (maybe make it tenths of seconds like in Zmodem?) - */ - -static int -realreadchar(qdaemon, timeout) -struct sdaemon *qdaemon; -int timeout; -{ - int c; - - if ((c = breceive_char (qdaemon->qconn, timeout, TRUE)) >= 0) - return c; - - switch (c) { - case -1: - return ZM_TIMEOUT; - case -2: - return ZM_RCDO; - } - - ulog (LOG_FATAL, "realreadchar: breceive_char() returned %d", c); - return ZM_ERROR; -} - - -/* - * Check if the receive channel has any characters in it. - * - * At present we can only test the receive buffer. No mechanism is available - * to go to the hardware. This should not be a problem though, as long as all - * appropriate calls to fsend_data() set <fdoread> to TRUE. - */ - -static boolean -fzreceive_ready() -{ - return iPrecstart != iPrecend; -} - -/* - * Store integer value in an achdrval_t ... - */ - -static void -stohdr(val, hdr) -hdrval_t val; -achdrval_t hdr; -{ - hdr[ZP0] = (char) val; - hdr[ZP1] = (char) (val >> 8); - hdr[ZP2] = (char) (val >> 16); - hdr[ZP3] = (char) (val >> 24); -} - -/* - * Recover an integer from a header ... - */ - -static hdrval_t -rclhdr(hdr) -achdrval_t hdr; -{ - hdrval_t v; - - v = hdr[ZP3] & 0377; - v = (v << 8) | (hdr[ZP2] & 0377); - v = (v << 8) | (hdr[ZP1] & 0377); - v = (v << 8) | (hdr[ZP0] & 0377); - - return v; -} - -/* - * Encode a <hdrval_t> from the byte count ... - * - * We use to store the byte count / 32 and a message sequence number which - * made this function very useful. Don't remove it. - * FIXME: Well, maybe remove it later. - */ - -static hdrval_t -hvzencode_data_hdr(cbytes) -winpos_t cbytes; -{ - return (hdrval_t) cbytes; -} - -/* - * Decode a <hdrval_t> into a byte count ... - * - * We use to store the byte count / 32 and a message sequence number which - * made this function very useful. Don't remove it. - * FIXME: Well, maybe remove it later. - */ - -static void -zdecode_data_hdr(hdrval, pcbytes) -hdrval_t hdrval; -winpos_t *pcbytes; -{ - *pcbytes = hdrval; -} - -/* - * Update <wpZrxpos> from the received data header value ... - * - * FIXME: Here is where we'd handle wrapping around at 4 gigabytes. - */ - -static winpos_t -lzupdate_rxpos(rx_hdr, rxpos, lrxpos, txpos) -achdrval_t rx_hdr; -winpos_t rxpos,lrxpos,txpos; -{ - winpos_t rx_pktpos; - - zdecode_data_hdr (rclhdr (rx_hdr), &rx_pktpos); - - DEBUG_MESSAGE4 (DEBUG_PROTO, - "lzupdate_rxpos: rx_pktpos=0x%lx, rxpos=0x%lx, lrxpos=0x%lx, txpos=0x%lx", - rx_pktpos, rxpos, lrxpos, txpos); - - /* - * Check if <rx_pktpos> valid. It could be old. - */ - - if (rx_pktpos < wpZlrxpos - || rx_pktpos > ((wpZtxpos + 1024L) & ~1023L)) - return rxpos; - - return rx_pktpos; -} diff --git a/gnu/libexec/uucp/uucico/rec.c b/gnu/libexec/uucp/uucico/rec.c deleted file mode 100644 index 020ff21..0000000 --- a/gnu/libexec/uucp/uucico/rec.c +++ /dev/null @@ -1,1309 +0,0 @@ -/* rec.c - Routines to receive a file. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char rec_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "prot.h" -#include "trans.h" - -/* If the other side does not tell us the size of a file it wants to - send us, we assume it is this long. This is only used for free - space checking. */ -#define CASSUMED_FILE_SIZE (10240) - -/* We keep this information in the pinfo field of the stransfer - structure. */ -struct srecinfo -{ - /* Local user to send mail to (may be NULL). */ - char *zmail; - /* Full file name. */ - char *zfile; - /* Temporary file name. */ - char *ztemp; - /* TRUE if this is a spool directory file. */ - boolean fspool; - /* TRUE if this was a local request. */ - boolean flocal; - /* TRUE if the file has been completely received. */ - boolean freceived; - /* TRUE if remote request has been replied to. */ - boolean freplied; - /* TRUE if we moved the file to the final destination. */ - boolean fmoved; -}; - -/* This structure is kept in the pinfo field if we are refusing a - remote request. */ -struct srecfailinfo -{ - /* Reason for refusal. */ - enum tfailure twhy; - /* TRUE if we have sent the reason for refusal. */ - boolean fsent; - /* TRUE if we have seen the end of the file. */ - boolean freceived; -}; - -/* Local functions. */ - -static void urrec_free P((struct stransfer *qtrans)); -static boolean flocal_rec_fail P((struct stransfer *qtrans, - struct scmd *qcmd, - const struct uuconf_system *qsys, - const char *zwhy)); -static boolean flocal_rec_send_request P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean flocal_rec_await_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, - size_t cdata)); -static boolean fremote_send_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fremote_send_fail P((struct sdaemon *qdaemon, - struct scmd *qcmd, - enum tfailure twhy, - int iremote)); -static boolean fremote_send_fail_send P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fremote_discard P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean frec_file_end P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean frec_file_send_confirm P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); - -/* Free up a receive stransfer structure. */ - -static void -urrec_free (qtrans) - struct stransfer *qtrans; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - - if (qinfo != NULL) - { - ubuffree (qinfo->zmail); - ubuffree (qinfo->zfile); - ubuffree (qinfo->ztemp); - xfree (qtrans->pinfo); - } - - utransfree (qtrans); -} - -/* Set up a request for a file from the remote system. This may be - called before the remote system has been called. - - This is the order of function calls: - - flocal_rec_file_init --> fqueue_local - flocal_rec_send_request (send R ...) --> fqueue_receive - flocal_rec_await_reply (open file, call pffile) --> fqueue_receive - receive file - frec_file_end (close and move file, call pffile) --> fqueue_send - frec_file_send_confirm (send CY) - */ - -boolean -flocal_rec_file_init (qdaemon, qcmd) - struct sdaemon *qdaemon; - struct scmd *qcmd; -{ - const struct uuconf_system *qsys; - boolean fspool; - char *zfile; - struct srecinfo *qinfo; - struct stransfer *qtrans; - - qsys = qdaemon->qsys; - - /* Make sure we are permitted to transfer files. */ - if (qdaemon->fcaller - ? ! qsys->uuconf_fcall_transfer - : ! qsys->uuconf_fcalled_transfer) - { - /* This case will have been checked by uucp or uux, but it could - have changed. */ - if (! qsys->uuconf_fcall_transfer - && ! qsys->uuconf_fcalled_transfer) - return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys, - "not permitted to request files"); - return TRUE; - } - - fspool = fspool_file (qcmd->zto); - - if (fspool) - { - pointer puuconf; - int iuuconf; - const char *zlocalname; - struct uuconf_system slocalsys; - - /* Normal users are not allowed to request files to be received - into the spool directory. To support uux forwarding, we use - the special option '9'. This permits a file to be received - into the spool directory for the local system only without - the usual checking. This is only done for local requests, of - course. */ - if (qcmd->zto[0] != 'D' - || strchr (qcmd->zoptions, '9') == NULL) - return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys, - "not permitted to receive"); - - puuconf = qdaemon->puuconf; - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - iuuconf = uuconf_system_info (puuconf, zlocalname, &slocalsys); - if (iuuconf == UUCONF_NOT_FOUND) - { - iuuconf = uuconf_system_local (puuconf, &slocalsys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - slocalsys.uuconf_zname = (char *) zlocalname; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - zfile = zsysdep_spool_file_name (&slocalsys, qcmd->zto, qcmd->pseq); - - (void) uuconf_system_free (puuconf, &slocalsys); - - if (zfile == NULL) - return FALSE; - } - else - { - zfile = zsysdep_add_base (qcmd->zto, qcmd->zfrom); - if (zfile == NULL) - return FALSE; - - /* Check permissions. */ - if (! fin_directory_list (zfile, qsys->uuconf_pzlocal_receive, - qsys->uuconf_zpubdir, TRUE, - FALSE, qcmd->zuser)) - { - ubuffree (zfile); - return flocal_rec_fail ((struct stransfer *) NULL, qcmd, qsys, - "not permitted to receive"); - } - - /* The 'f' option means that directories should not - be created if they do not already exist. */ - if (strchr (qcmd->zoptions, 'f') == NULL) - { - if (! fsysdep_make_dirs (zfile, TRUE)) - { - ubuffree (zfile); - return flocal_rec_fail ((struct stransfer *) NULL, qcmd, - qsys, "cannot create directories"); - } - } - } - - qinfo = (struct srecinfo *) xmalloc (sizeof (struct srecinfo)); - if (strchr (qcmd->zoptions, 'm') == NULL) - qinfo->zmail = NULL; - else - qinfo->zmail = zbufcpy (qcmd->zuser); - qinfo->zfile = zfile; - qinfo->ztemp = NULL; - qinfo->fspool = fspool; - qinfo->flocal = TRUE; - qinfo->freceived = FALSE; - qinfo->freplied = TRUE; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = flocal_rec_send_request; - qtrans->pinfo = (pointer) qinfo; - - return fqueue_local (qdaemon, qtrans); -} - -/* Report an error for a local receive request. */ - -static boolean -flocal_rec_fail (qtrans, qcmd, qsys, zwhy) - struct stransfer *qtrans; - struct scmd *qcmd; - const struct uuconf_system *qsys; - const char *zwhy; -{ - if (zwhy != NULL) - { - ulog (LOG_ERROR, "%s: %s", qcmd->zfrom, zwhy); - (void) fmail_transfer (FALSE, qcmd->zuser, (const char *) NULL, zwhy, - qcmd->zfrom, qsys->uuconf_zname, - qcmd->zto, (const char *) NULL, - (const char *) NULL); - (void) fsysdep_did_work (qcmd->pseq); - } - if (qtrans != NULL) - urrec_free (qtrans); - return TRUE; -} - -/* This is called when we are ready to send the actual request to the - other system. */ - -static boolean -flocal_rec_send_request (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - long cbytes, cbytes2; - size_t clen; - char *zsend; - boolean fret; - - qinfo->ztemp = zsysdep_receive_temp (qdaemon->qsys, qinfo->zfile, - (const char *) NULL, - (qdaemon->qproto->frestart - && (qdaemon->ifeatures - & FEATURE_RESTART) != 0)); - if (qinfo->ztemp == NULL) - { - urrec_free (qtrans); - return FALSE; - } - - qtrans->fcmd = TRUE; - qtrans->precfn = flocal_rec_await_reply; - - if (! fqueue_receive (qdaemon, qtrans)) - return FALSE; - - /* Check the amount of free space available for both the temporary - file and the real file. */ - cbytes = csysdep_bytes_free (qinfo->ztemp); - cbytes2 = csysdep_bytes_free (qinfo->zfile); - if (cbytes < cbytes2) - cbytes = cbytes2; - if (cbytes != -1) - { - cbytes -= qdaemon->qsys->uuconf_cfree_space; - if (cbytes < 0) - cbytes = 0; - } - - if (qdaemon->clocal_size != -1 - && (cbytes == -1 || qdaemon->clocal_size < cbytes)) - cbytes = qdaemon->clocal_size; - - /* We send the string - R from to user options - - We put a dash in front of options. If we are talking to a - counterpart, we also send the maximum size file we are prepared - to accept, as returned by esysdep_open_receive. */ - clen = (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto) - + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) + 30); - zsend = zbufalc (clen); - if ((qdaemon->ifeatures & FEATURE_SIZES) == 0) - sprintf (zsend, "R %s %s %s -%s", qtrans->s.zfrom, qtrans->s.zto, - qtrans->s.zuser, qtrans->s.zoptions); - else if ((qdaemon->ifeatures & FEATURE_V103) == 0) - sprintf (zsend, "R %s %s %s -%s 0x%lx", qtrans->s.zfrom, qtrans->s.zto, - qtrans->s.zuser, qtrans->s.zoptions, (unsigned long) cbytes); - else - sprintf (zsend, "R %s %s %s -%s %ld", qtrans->s.zfrom, qtrans->s.zto, - qtrans->s.zuser, qtrans->s.zoptions, cbytes); - - fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal, - qtrans->iremote); - ubuffree (zsend); - - /* There is a potential space leak here: if pfsendcmd fails, we - might need to free qtrans. However, it is possible that by the - time pfsendcmd returns, a response will have been received which - led to the freeing of qtrans anyhow. One way to fix this would - be some sort of counter in qtrans to track allocations, but since - the space leak is small, and the conversation has failed anyhow, - it doesn't seem worth it. */ - - return fret; -} - -/* This is called when a reply is received for the request. */ - -/*ARGSUSED*/ -static boolean -flocal_rec_await_reply (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - const char *zlog; - char *zend; - - if (zdata[0] != 'R' - || (zdata[1] != 'Y' && zdata[1] != 'N')) - { - ulog (LOG_ERROR, "%s: bad response to receive request: \"%s\"", - qtrans->s.zfrom, zdata); - urrec_free (qtrans); - return FALSE; - } - - if (zdata[1] == 'N') - { - boolean fnever; - const char *zerr; - - fnever = TRUE; - if (zdata[2] == '2') - zerr = "no such file"; - else if (zdata[2] == '6') - { - /* We sent over the maximum file size we were prepared to - receive, and the remote system is telling us that the - file is larger than that. Try again later. It would be - better if we could know whether there will ever be enough - room. */ - zerr = "too large to receive now"; - fnever = FALSE; - } - else if (zdata[2] == '9') - { - /* Remote has run out of channels. */ - zerr = "too many channels for remote"; - fnever = FALSE; - - /* Drop one channel; using exactly one channel causes - slightly different behahaviour in a few places, so don't - decrement to one. */ - if (qdaemon->cchans > 2) - --qdaemon->cchans; - } - else - zerr = "unknown reason"; - - if (fnever) - return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys, zerr); - - ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr); - - urrec_free (qtrans); - - return TRUE; - } - - /* The mode should have been sent as "RY 0%o". If it wasn't, we use - 0666. */ - qtrans->s.imode = (unsigned int) strtol ((char *) (zdata + 2), - &zend, 8); - if (qtrans->s.imode == 0) - qtrans->s.imode = 0666; - - /* If there is an M after the mode, the remote has requested a - hangup. */ - if (*zend == 'M' && qdaemon->fmaster) - { - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "flocal_rec_await_reply: Remote has requested transfer of control"); - qdaemon->fhangup_requested = TRUE; - } - - /* Open the file to receive into. We just ignore any restart count, - since we have no way to tell it to the other side. SVR4 may have - some way to do this, but I don't know what it is. */ - qtrans->e = esysdep_open_receive (qdaemon->qsys, qinfo->zfile, - (const char *) NULL, qinfo->ztemp, - (long *) NULL); - if (! ffileisopen (qtrans->e)) - return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys, - "cannot open file"); - - if (qinfo->fspool) - zlog = qtrans->s.zto; - else - zlog = qinfo->zfile; - qtrans->zlog = zbufalc (sizeof "Receiving " + strlen (zlog)); - sprintf (qtrans->zlog, "Receiving %s", zlog); - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, FALSE, - (long) -1, &fhandled)) - { - (void) ffileclose (qtrans->e); - return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys, - (const char *) NULL); - } - if (fhandled) - return TRUE; - } - - qtrans->frecfile = TRUE; - qtrans->psendfn = frec_file_send_confirm; - qtrans->precfn = frec_file_end; - - return fqueue_receive (qdaemon, qtrans); -} - -/* Make sure there is still enough disk space available to receive a - file. */ - -boolean -frec_check_free (qtrans, cfree_space) - struct stransfer *qtrans; - long cfree_space; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - long cfree1, cfree2; - - cfree1 = csysdep_bytes_free (qinfo->ztemp); - cfree2 = csysdep_bytes_free (qinfo->zfile); - if (cfree1 < cfree2) - cfree1 = cfree2; - if (cfree1 != -1 && cfree1 < cfree_space) - { - ulog (LOG_ERROR, "%s: too big to receive now", qinfo->zfile); - return FALSE; - } - - return TRUE; -} - -/* A remote request to send a file to the local system, meaning that - we are going to receive a file. - - If we are using a protocol which does not support multiple - channels, the remote system will not start sending us the file - until it has received our confirmation. In that case, the order of - functions is as follows: - - fremote_send_file_init (open file) --> fqueue_remote - fremote_send_reply (send SY, call pffile) --> fqueue_receive - receive file - frec_file_end (close and move file, call pffile) --> fqueue_send - frec_file_send_confirm (send CY) - - If the protocol supports multiple channels, then the remote system - will start sending the file immediately after the send request. - That means that the data may come in before remote_send_reply is - called, so frec_file_end may be called before fremote_send_reply. - Note that this means the pffile entry points may be called in - reverse order for such a protocol. - - If the send request is rejected, via fremote_send_fail, and the - protocol supports multiple channels, we must accept and discard - data until a zero byte buffer is received from the other side, - indicating that it has received our rejection. - - This code also handles execution requests, which are very similar - to send requests. */ - -boolean -fremote_send_file_init (qdaemon, qcmd, iremote) - struct sdaemon *qdaemon; - struct scmd *qcmd; - int iremote; -{ - const struct uuconf_system *qsys; - boolean fspool; - char *zfile; - openfile_t e; - char *ztemp; - long cbytes, cbytes2; - long crestart; - struct srecinfo *qinfo; - struct stransfer *qtrans; - const char *zlog; - - qsys = qdaemon->qsys; - - if (! qsys->uuconf_frec_request) - { - ulog (LOG_ERROR, "%s: not permitted to receive files from remote", - qcmd->zfrom); - return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote); - } - - fspool = fspool_file (qcmd->zto); - - /* We don't accept remote command files. An execution request may - only send a simple data file. */ - if ((fspool && qcmd->zto[0] == 'C') - || (qcmd->bcmd == 'E' - && (! fspool || qcmd->zto[0] != 'D'))) - { - ulog (LOG_ERROR, "%s: not permitted to receive", qcmd->zfrom); - return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote); - } - - /* See if we have already received this file in a previous - conversation. */ - if (fsysdep_already_received (qsys, qcmd->zto, qcmd->ztemp)) - return fremote_send_fail (qdaemon, qcmd, FAILURE_RECEIVED, iremote); - - if (fspool) - { - zfile = zsysdep_spool_file_name (qsys, qcmd->zto, (pointer) NULL); - if (zfile == NULL) - return FALSE; - } - else - { - boolean fbadname; - - zfile = zsysdep_local_file (qcmd->zto, qsys->uuconf_zpubdir, - &fbadname); - if (zfile == NULL && fbadname) - { - ulog (LOG_ERROR, "%s: bad local file name", qcmd->zto); - return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote); - } - if (zfile != NULL) - { - char *zadd; - - zadd = zsysdep_add_base (zfile, qcmd->zfrom); - ubuffree (zfile); - zfile = zadd; - } - if (zfile == NULL) - return FALSE; - - /* Check permissions. */ - if (! fin_directory_list (zfile, qsys->uuconf_pzremote_receive, - qsys->uuconf_zpubdir, TRUE, - FALSE, (const char *) NULL)) - { - ulog (LOG_ERROR, "%s: not permitted to receive", zfile); - ubuffree (zfile); - return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote); - } - - if (strchr (qcmd->zoptions, 'f') == NULL) - { - if (! fsysdep_make_dirs (zfile, TRUE)) - { - ubuffree (zfile); - return fremote_send_fail (qdaemon, qcmd, FAILURE_OPEN, - iremote); - } - } - } - - ztemp = zsysdep_receive_temp (qsys, zfile, qcmd->ztemp, - (qdaemon->qproto->frestart - && (qdaemon->ifeatures - & FEATURE_RESTART) != 0)); - - /* Adjust the number of bytes we are prepared to receive according - to the amount of free space we are supposed to leave available - and the maximum file size we are permitted to transfer. */ - cbytes = csysdep_bytes_free (ztemp); - cbytes2 = csysdep_bytes_free (zfile); - if (cbytes < cbytes2) - cbytes = cbytes2; - - if (cbytes != -1) - { - cbytes -= qsys->uuconf_cfree_space; - if (cbytes < 0) - cbytes = 0; - } - - if (qdaemon->cremote_size != -1 - && (cbytes == -1 || qdaemon->cremote_size < cbytes)) - cbytes = qdaemon->cremote_size; - - /* If the number of bytes we are prepared to receive is less than - the file size, we must fail. If the remote did not tell us the - file size, arbitrarily assumed that it is 10240 bytes. */ - if (cbytes != -1) - { - long csize; - - csize = qcmd->cbytes; - if (csize == -1) - csize = CASSUMED_FILE_SIZE; - if (cbytes < csize) - { - ulog (LOG_ERROR, "%s: too big to receive", zfile); - ubuffree (ztemp); - ubuffree (zfile); - return fremote_send_fail (qdaemon, qcmd, FAILURE_SIZE, iremote); - } - } - - /* Open the file to receive into. This may find an old copy of the - file, which will be used for file restart if the other side - supports it. */ - crestart = -1; - e = esysdep_open_receive (qsys, zfile, qcmd->ztemp, ztemp, - ((qdaemon->qproto->frestart - && (qdaemon->ifeatures - & FEATURE_RESTART) != 0) - ? &crestart - : (long *) NULL)); - if (! ffileisopen (e)) - { - ubuffree (ztemp); - ubuffree (zfile); - return fremote_send_fail (qdaemon, qcmd, FAILURE_OPEN, iremote); - } - - if (crestart > 0) - { - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, - "fremote_send_file_init: Restarting receive from %ld", - crestart); - if (! ffileseek (e, crestart)) - { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - (void) ffileclose (e); - ubuffree (ztemp); - ubuffree (zfile); - return FALSE; - } - } - - qinfo = (struct srecinfo *) xmalloc (sizeof (struct srecinfo)); - if (strchr (qcmd->zoptions, 'n') == NULL) - qinfo->zmail = NULL; - else - qinfo->zmail = zbufcpy (qcmd->znotify); - qinfo->zfile = zfile; - qinfo->ztemp = ztemp; - qinfo->fspool = fspool; - qinfo->flocal = FALSE; - qinfo->freceived = FALSE; - qinfo->freplied = FALSE; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = fremote_send_reply; - qtrans->precfn = frec_file_end; - qtrans->iremote = iremote; - qtrans->pinfo = (pointer) qinfo; - qtrans->frecfile = TRUE; - qtrans->e = e; - if (crestart > 0) - qtrans->ipos = crestart; - - if (qcmd->bcmd == 'E') - zlog = qcmd->zcmd; - else - { - if (qinfo->fspool) - zlog = qcmd->zto; - else - zlog = qinfo->zfile; - } - qtrans->zlog = zbufalc (sizeof "Receiving ( bytes resume at )" - + strlen (zlog) + 50); - sprintf (qtrans->zlog, "Receiving %s", zlog); - if (crestart > 0 || qcmd->cbytes > 0) - { - strcat (qtrans->zlog, " ("); - if (qcmd->cbytes > 0) - { - sprintf (qtrans->zlog + strlen (qtrans->zlog), "%ld bytes", - qcmd->cbytes); - if (crestart > 0) - strcat (qtrans->zlog, " "); - } - if (crestart > 0) - sprintf (qtrans->zlog + strlen (qtrans->zlog), "resume at %ld", - crestart); - strcat (qtrans->zlog, ")"); - } - - return fqueue_remote (qdaemon, qtrans); -} - -/* Reply to a send request, and prepare to receive the file. */ - -static boolean -fremote_send_reply (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - boolean fret; - char ab[50]; - - /* If the file has been completely received, we just want to send - the final confirmation. Otherwise, we must wait for the file - first. */ - qtrans->psendfn = frec_file_send_confirm; - if (qinfo->freceived) - fret = fqueue_send (qdaemon, qtrans); - else - fret = fqueue_receive (qdaemon, qtrans); - if (! fret) - return FALSE; - - ab[0] = qtrans->s.bcmd; - ab[1] = 'Y'; - if (qtrans->ipos <= 0) - ab[2] = '\0'; - else - sprintf (ab + 2, " 0x%lx", (unsigned long) qtrans->ipos); - - qinfo->freplied = TRUE; - - if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, qtrans->ilocal, - qtrans->iremote)) - { - (void) ffileclose (qtrans->e); - (void) remove (qinfo->ztemp); - /* Should probably free qtrans here, but see the comment at the - end of flocal_rec_send_request. */ - return FALSE; - } - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, FALSE, - (long) -1, &fhandled)) - { - (void) ffileclose (qtrans->e); - (void) remove (qinfo->ztemp); - urrec_free (qtrans); - return FALSE; - } - } - - return TRUE; -} - -/* If we can't receive a file, queue up a response to the remote - system. */ - -static boolean -fremote_send_fail (qdaemon, qcmd, twhy, iremote) - struct sdaemon *qdaemon; - struct scmd *qcmd; - enum tfailure twhy; - int iremote; -{ - struct srecfailinfo *qinfo; - struct stransfer *qtrans; - - qinfo = (struct srecfailinfo *) xmalloc (sizeof (struct srecfailinfo)); - qinfo->twhy = twhy; - qinfo->fsent = FALSE; - - /* If the protocol does not support multiple channels (cchans <= 1), - then we have essentially already received the entire file. */ - qinfo->freceived = qdaemon->cchans <= 1; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = fremote_send_fail_send; - qtrans->precfn = fremote_discard; - qtrans->iremote = iremote; - qtrans->pinfo = (pointer) qinfo; - - return fqueue_remote (qdaemon, qtrans); -} - -/* Send a failure string for a send command to the remote system; - this is called when we are ready to reply to the command. */ - -static boolean -fremote_send_fail_send (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct srecfailinfo *qinfo = (struct srecfailinfo *) qtrans->pinfo; - char ab[4]; - int ilocal, iremote; - - ab[0] = qtrans->s.bcmd; - ab[1] = 'N'; - - switch (qinfo->twhy) - { - case FAILURE_PERM: - ab[2] = '2'; - break; - case FAILURE_OPEN: - ab[2] = '4'; - break; - case FAILURE_SIZE: - ab[2] = '6'; - break; - case FAILURE_RECEIVED: - /* Remember this file as though we successfully received it; - when the other side acknowledges our rejection, we know that - we no longer have to remember that we received this file. */ - usent_receive_ack (qdaemon, qtrans); - ab[2] = '8'; - break; - default: - ab[2] = '\0'; - break; - } - - ab[3] = '\0'; - - ilocal = qtrans->ilocal; - iremote = qtrans->iremote; - - /* Wait for the end of file marker if we haven't gotten it yet. */ - if (! qinfo->freceived) - { - qinfo->fsent = TRUE; - if (! fqueue_receive (qdaemon, qtrans)) - return FALSE; - } - else - { - xfree (qtrans->pinfo); - utransfree (qtrans); - } - - return (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, ilocal, iremote); -} - -/* Discard data until we reach the end of the file. This is used for - a protocol with multiple channels, since the remote system may - start sending the file before the confirmation is sent. If we - refuse the file, the remote system will get us back in synch by - sending an empty buffer, which is what we look for here. */ - -/*ARGSUSED*/ -static boolean -fremote_discard (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct srecfailinfo *qinfo = (struct srecfailinfo *) qtrans->pinfo; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, - "fremote_discard: Discarding %lu bytes", - (unsigned long) cdata); - - if (cdata != 0) - return TRUE; - - qinfo->freceived = TRUE; - - /* If we have already sent the denial, we are done. */ - if (qinfo->fsent) - { - xfree (qtrans->pinfo); - utransfree (qtrans); - } - - return TRUE; -} - -/* This is called when a file has been completely received. It sends - a response to the remote system. */ - -/*ARGSUSED*/ -static boolean -frec_file_end (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - char *zalc; - const char *zerr; - boolean fnever; - - DEBUG_MESSAGE3 (DEBUG_UUCP_PROTO, "frec_file_end: %s to %s (freplied %s)", - qtrans->s.zfrom, qtrans->s.zto, - qinfo->freplied ? "TRUE" : "FALSE"); - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, FALSE, FALSE, - (long) -1, &fhandled)) - { - (void) ffileclose (qtrans->e); - (void) remove (qinfo->ztemp); - urrec_free (qtrans); - return FALSE; - } - if (fhandled) - return TRUE; - } - - qinfo->freceived = TRUE; - - fnever = FALSE; - - zalc = NULL; - - if (! fsysdep_sync (qtrans->e, qtrans->s.zto)) - { - zerr = strerror (errno); - (void) ffileclose (qtrans->e); - (void) remove (qinfo->ztemp); - } - else if (! ffileclose (qtrans->e)) - { - zerr = strerror (errno); - ulog (LOG_ERROR, "%s: close: %s", qtrans->s.zto, zerr); - (void) remove (qinfo->ztemp); - } - else if (! fsysdep_move_file (qinfo->ztemp, qinfo->zfile, qinfo->fspool, - FALSE, ! qinfo->fspool, - (qinfo->flocal - ? qtrans->s.zuser - : (const char *) NULL))) - { - long cspace; - - /* Keep the temporary file if there is 1.5 times the amount of - required free space. This is just a random guess, to make an - unusual situtation potentially less painful. */ - cspace = csysdep_bytes_free (qinfo->ztemp); - if (cspace == -1) - cspace = FREE_SPACE_DELTA; - cspace -= (qdaemon->qsys->uuconf_cfree_space - + qdaemon->qsys->uuconf_cfree_space / 2); - if (cspace < 0) - { - (void) remove (qinfo->ztemp); - zerr = "could not move to final location"; - } - else - { - const char *az[20]; - int i; - - zalc = zbufalc (sizeof "could not move to final location (left as )" - + strlen (qinfo->ztemp)); - sprintf (zalc, "could not move to final location (left as %s)", - qinfo->ztemp); - zerr = zalc; - - i = 0; - az[i++] = "The file\n\t"; - az[i++] = qinfo->ztemp; - az[i++] = - "\nwas saved because the move to the final location failed.\n"; - az[i++] = "See the UUCP logs for more details.\n"; - az[i++] = "The file transfer was from\n\t"; - az[i++] = qdaemon->qsys->uuconf_zname; - az[i++] = "!"; - az[i++] = qtrans->s.zfrom; - az[i++] = "\nto\n\t"; - az[i++] = qtrans->s.zto; - az[i++] = "\nand was requested by\n\t"; - az[i++] = qtrans->s.zuser; - az[i++] = "\n"; - (void) fsysdep_mail (OWNER, "UUCP temporary file saved", i, az); - } - ulog (LOG_ERROR, "%s: %s", qinfo->zfile, zerr); - fnever = TRUE; - } - else - { - if (! qinfo->fspool) - { - unsigned int imode; - - /* Unless we can change the ownership of the file, the only - choice to make about these bits is whether to set the - execute bit or not. */ - if ((qtrans->s.imode & 0111) != 0) - imode = 0777; - else - imode = 0666; - (void) fsysdep_change_mode (qinfo->zfile, imode); - } - - zerr = NULL; - } - - ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname, - FALSE, qtrans->cbytes, qtrans->isecs, qtrans->imicros, - qdaemon->fcaller); - qdaemon->creceived += qtrans->cbytes; - - if (zerr == NULL) - { - if (qinfo->zmail != NULL && *qinfo->zmail != '\0') - (void) fmail_transfer (TRUE, qtrans->s.zuser, qinfo->zmail, - (const char *) NULL, - qtrans->s.zfrom, qdaemon->qsys->uuconf_zname, - qtrans->s.zto, (const char *) NULL, - (const char *) NULL); - - if (qtrans->s.pseq != NULL) - (void) fsysdep_did_work (qtrans->s.pseq); - - if (! qinfo->flocal) - { - /* Remember that we have received this file, so that if the - connection drops at this point we won't receive it again. - We could check the return value here, but if we return - FALSE we couldn't do anything but drop the connection, - which would hardly be reasonable. Instead we trust that - the administrator will notice and handle any error - messages, which are very unlikely to occur if everything - is set up correctly. */ - (void) fsysdep_remember_reception (qdaemon->qsys, qtrans->s.zto, - qtrans->s.ztemp); - } - } - else - { - /* If the transfer failed, we send mail if it was requested - locally and if it can never succeed. */ - if (qinfo->flocal && fnever) - { - (void) fmail_transfer (FALSE, qtrans->s.zuser, qinfo->zmail, - zerr, qtrans->s.zfrom, - qdaemon->qsys->uuconf_zname, - qtrans->s.zto, (const char *) NULL, - (const char *) NULL); - (void) fsysdep_did_work (qtrans->s.pseq); - } - } - - ubuffree (zalc); - - /* If this is an execution request, we must create the execution - file itself. */ - if (qtrans->s.bcmd == 'E' && zerr == NULL) - { - char *zxqt, *zxqtfile, *ztemp; - FILE *e; - boolean fbad; - - /* We get an execution file name by simply replacing the leading - D in the received file name with an X. This pretty much - always has to work since we can always receive a file name - starting with X, so the system dependent code must be - prepared to see one. */ - zxqt = zbufcpy (qtrans->s.zto); - zxqt[0] = 'X'; - zxqtfile = zsysdep_spool_file_name (qdaemon->qsys, zxqt, - (pointer) NULL); - ubuffree (zxqt); - - if (zxqtfile == NULL) - { - urrec_free (qtrans); - return FALSE; - } - - /* We have to write via a temporary file, because otherwise - uuxqt might pick up the file before we have finished writing - it. */ - e = NULL; - ztemp = zsysdep_receive_temp (qdaemon->qsys, zxqtfile, "D.0", - (qdaemon->qproto->frestart - && (qdaemon->ifeatures - & FEATURE_RESTART) != 0)); - if (ztemp != NULL) - e = esysdep_fopen (ztemp, FALSE, FALSE, TRUE); - - if (e == NULL) - { - ubuffree (zxqtfile); - ubuffree (ztemp); - urrec_free (qtrans); - return FALSE; - } - - fprintf (e, "U %s %s\n", qtrans->s.zuser, qdaemon->qsys->uuconf_zname); - fprintf (e, "F %s\n", qtrans->s.zto); - fprintf (e, "I %s\n", qtrans->s.zto); - if (strchr (qtrans->s.zoptions, 'N') != NULL) - fprintf (e, "N\n"); - if (strchr (qtrans->s.zoptions, 'Z') != NULL) - fprintf (e, "Z\n"); - if (strchr (qtrans->s.zoptions, 'R') != NULL) - fprintf (e, "R %s\n", qtrans->s.znotify); - if (strchr (qtrans->s.zoptions, 'e') != NULL) - fprintf (e, "e\n"); - fprintf (e, "C %s\n", qtrans->s.zcmd); - - fbad = FALSE; - - if (! fstdiosync (e, ztemp)) - { - (void) fclose (e); - (void) remove (ztemp); - fbad = TRUE; - } - - if (! fbad) - { - if (fclose (e) == EOF) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (ztemp); - fbad = TRUE; - } - } - - if (! fbad) - { - if (! fsysdep_move_file (ztemp, zxqtfile, TRUE, FALSE, FALSE, - (const char *) NULL)) - { - (void) remove (ztemp); - fbad = TRUE; - } - } - - ubuffree (zxqtfile); - ubuffree (ztemp); - - if (fbad) - { - urrec_free (qtrans); - return FALSE; - } - } - - /* See if we should spawn a uuxqt process. */ - if (zerr == NULL - && (qtrans->s.bcmd == 'E' - || (qinfo->fspool && qtrans->s.zto[0] == 'X'))) - { - ++qdaemon->cxfiles_received; - if (qdaemon->irunuuxqt > 0 - && qdaemon->cxfiles_received >= qdaemon->irunuuxqt) - { - if (fspawn_uuxqt (TRUE, qdaemon->qsys->uuconf_zname, - qdaemon->zconfig)) - qdaemon->cxfiles_received = 0; - } - } - - /* Prepare to send the completion string to the remote system. If - we have not yet replied to the remote send request, we leave the - transfer structure on the remote queue. Otherwise we add it to - the send queue. The psendfn field will already be set. */ - qinfo->fmoved = zerr == NULL; - if (qinfo->freplied) - return fqueue_send (qdaemon, qtrans); - - return TRUE; -} - -/* Send the final confirmation string to the remote system. */ - -static boolean -frec_file_send_confirm (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - const char *zsend; - int ilocal, iremote; - - if (! qinfo->fmoved) - zsend = "CN5"; - else if (! qdaemon->frequest_hangup) - zsend = "CY"; - else - { -#if DEBUG > 0 - if (qdaemon->fmaster) - ulog (LOG_FATAL, "frec_file_send_confirm: Can't happen"); -#endif - - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "frec_send_file_confirm: Requesting remote to transfer control"); - zsend = "CYM"; - } - - /* If that was a remote command, then, when the confirmation message - is acked, we no longer have to remember that we received that - file. */ - if (! qinfo->flocal && qinfo->fmoved) - usent_receive_ack (qdaemon, qtrans); - - ilocal = qtrans->ilocal; - iremote = qtrans->iremote; - - urrec_free (qtrans); - - return (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, ilocal, iremote); -} - -/* Discard a temporary file if it is not useful. A temporary file is - useful if it could be used to restart a receive. This is called if - the connection is lost. It is only called if qtrans->frecfile is - TRUE. */ - -boolean -frec_discard_temp (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ - struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo; - - if ((qdaemon->ifeatures & FEATURE_RESTART) == 0 - || qtrans->s.ztemp == NULL - || qtrans->s.ztemp[0] != 'D' - || strcmp (qtrans->s.ztemp, "D.0") == 0) - (void) remove (qinfo->ztemp); - return TRUE; -} diff --git a/gnu/libexec/uucp/uucico/send.c b/gnu/libexec/uucp/uucico/send.c deleted file mode 100644 index bbe34e5..0000000 --- a/gnu/libexec/uucp/uucico/send.c +++ /dev/null @@ -1,1387 +0,0 @@ -/* send.c - Routines to send a file. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char send_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "prot.h" -#include "trans.h" - -/* We keep this information in the pinfo field of the stransfer - structure. */ -struct ssendinfo -{ - /* Local user to send mail to (may be NULL). */ - char *zmail; - /* Full file name. */ - char *zfile; - /* Number of bytes in file. */ - long cbytes; - /* TRUE if this was a local request. */ - boolean flocal; - /* TRUE if this is a spool directory file. */ - boolean fspool; - /* TRUE if the file has been completely sent. */ - boolean fsent; - /* TRUE if the file send will never succeed; used by - flocal_send_cancelled. */ - boolean fnever; - /* Execution file for sending an unsupported E request. */ - char *zexec; - /* Confirmation command received in fsend_await_confirm. */ - char *zconfirm; -}; - -/* Local functions. */ - -static void usfree_send P((struct stransfer *qtrans)); -static boolean flocal_send_fail P((struct scmd *qcmd, - struct sdaemon *qdaemon, - const char *zwhy)); -static boolean flocal_send_request P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean flocal_send_await_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean flocal_send_cancelled P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean flocal_send_open_file P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fremote_rec_fail P((struct sdaemon *qdaemon, - enum tfailure twhy, int iremote)); -static boolean fremote_rec_fail_send P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fremote_rec_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fsend_file_end P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean fsend_await_confirm P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean fsend_exec_file_init P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static void usadd_exec_line P((char **pz, size_t *pcalc, size_t *pclen, - int bcmd, const char *z1, const char *z2)); -static boolean fsend_exec_file P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); - -/* Free up a send stransfer structure. */ - -static void -usfree_send (qtrans) - struct stransfer *qtrans; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - - if (qinfo != NULL) - { - ubuffree (qinfo->zmail); - ubuffree (qinfo->zfile); - ubuffree (qinfo->zexec); - ubuffree (qinfo->zconfirm); - xfree (qtrans->pinfo); - } - - utransfree (qtrans); -} - -/* Set up a local request to send a file. This may be called before - we have even tried to call the remote system. - - If we are using a traditional protocol, which doesn't support - channel numbers and doesn't permit the file to be sent until an - acknowledgement has been received, the sequence of function calls - looks like this: - - flocal_send_file_init --> fqueue_local - flocal_send_request (sends S request) --> fqueue_receive - flocal_send_await_reply (waits for SY) --> fqueue_send - flocal_send_open_file (opens file, calls pffile) --> fqueue_send - send file - fsend_file_end (calls pffile) --> fqueue_receive - fsend_await_confirm (waits for CY) - - If flocal_send_await_reply gets an SN, it deletes the request. If - the SY reply contains a file position at which to start sending, - flocal_send_await_reply sets qinfo->ipos. - - This gets more complex if the protocol supports channels. In that - case, we want to start sending the file data immediately, to avoid - the round trip delay between flocal_send_request and - flocal_send_await_reply. To do this, flocal_send_request calls - fqueue_send rather than fqueue_receive. The main execution - sequence looks like this: - - flocal_send_file_init --> fqueue_local - flocal_send_request (sends S request) --> fqueue_send - flocal_send_open_file (opens file, calls pffile) --> fqueue_send - send file - fsend_file_end (calls pffile) --> fqueue_receive - sometime: flocal_send_await_reply (waits for SY) - fsend_await_confirm (waits for CY) - - In this case flocal_send_await_reply must be run before - fsend_await_confirm; it may be run anytime after - flocal_send_request. - - If flocal_send_await_reply is called before the entire file has - been sent: if it gets an SN, it sets the file position to the end - and arranges to call flocal_send_cancelled. If it gets a file - position request, it must adjust the file position accordingly. - - If flocal_send_await_reply is called after the entire file has been - sent: if it gets an SN, it can simply delete the request. It can - ignore any file position request. - - If the request is not deleted, flocal_send_await_reply must arrange - for the next string to be passed to fsend_await_confirm. - Presumably fsend_await_confirm will only be called after the entire - file has been sent. - - Just to make things even more complex, these same routines support - sending execution requests, since that is much like sending a file. - For an execution request, the bcmd character will be E rather than - S. If an execution request is being sent to a system which does - not support them, it must be sent as two S requests instead. The - second one will be the execution file, but no actual file is - created; instead the zexec and znext fields in the ssendinfo - structure are used. So if the bcmd character is E, then if the - zexec field is NULL, the data file is being sent, otherwise the - fake execution file is being sent. */ - -boolean -flocal_send_file_init (qdaemon, qcmd) - struct sdaemon *qdaemon; - struct scmd *qcmd; -{ - const struct uuconf_system *qsys; - boolean fspool; - char *zfile; - long cbytes; - struct ssendinfo *qinfo; - struct stransfer *qtrans; - - qsys = qdaemon->qsys; - - if (qdaemon->fcaller - ? ! qsys->uuconf_fcall_transfer - : ! qsys->uuconf_fcalled_transfer) - { - /* uux or uucp should have already made sure that the transfer - is possible, but it might have changed since then. */ - if (! qsys->uuconf_fcall_transfer - && ! qsys->uuconf_fcalled_transfer) - return flocal_send_fail (qcmd, qdaemon, - "not permitted to transfer files"); - - /* We can't do the request now, but it may get done later. */ - return TRUE; - } - - /* The 'C' option means that the file has been copied to the spool - directory. */ - if (strchr (qcmd->zoptions, 'C') == NULL - && ! fspool_file (qcmd->zfrom)) - { - fspool = FALSE; - if (! fin_directory_list (qcmd->zfrom, - qsys->uuconf_pzlocal_send, - qsys->uuconf_zpubdir, TRUE, - TRUE, qcmd->zuser)) - return flocal_send_fail (qcmd, qdaemon, "not permitted to send"); - zfile = zbufcpy (qcmd->zfrom); - } - else - { - fspool = TRUE; - zfile = zsysdep_spool_file_name (qsys, qcmd->ztemp, qcmd->pseq); - if (zfile == NULL) - return FALSE; - } - - /* Make sure we meet any local size restrictions. The connection - may not have been opened at this point, so we can't check remote - size restrictions. */ - cbytes = csysdep_size (zfile); - if (cbytes < 0) - { - ubuffree (zfile); - if (cbytes != -1) - return flocal_send_fail (qcmd, qdaemon, "can not get size"); - /* A cbytes value of -1 means that the file does not exist. - This can happen legitimately if it has already been sent from - the spool directory. */ - if (! fspool) - return flocal_send_fail (qcmd, qdaemon, "does not exist"); - (void) fsysdep_did_work (qcmd->pseq); - return TRUE; - } - - if (qdaemon->clocal_size != -1 - && qdaemon->clocal_size < cbytes) - { - ubuffree (zfile); - - if (qdaemon->cmax_ever == -2) - { - long c1, c2; - - c1 = cmax_size_ever (qsys->uuconf_qcall_local_size); - c2 = cmax_size_ever (qsys->uuconf_qcalled_local_size); - if (c1 > c2) - qdaemon->cmax_ever = c1; - else - qdaemon->cmax_ever = c2; - } - - if (qdaemon->cmax_ever != -1 - && qdaemon->cmax_ever < qcmd->cbytes) - return flocal_send_fail (qcmd, qdaemon, "too large to send"); - - return TRUE; - } - - /* We are now prepared to send the command to the remote system. We - queue up a transfer request to send the command when we are - ready. */ - qinfo = (struct ssendinfo *) xmalloc (sizeof (struct ssendinfo)); - if (strchr (qcmd->zoptions, 'm') == NULL) - qinfo->zmail = NULL; - else - qinfo->zmail = zbufcpy (qcmd->zuser); - qinfo->zfile = zfile; - qinfo->cbytes = cbytes; - qinfo->flocal = strchr (qcmd->zuser, '!') == NULL; - qinfo->fspool = fspool; - qinfo->fsent = FALSE; - qinfo->zexec = NULL; - qinfo->zconfirm = NULL; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = flocal_send_request; - qtrans->pinfo = (pointer) qinfo; - - return fqueue_local (qdaemon, qtrans); -} - -/* Clean up after a failing local send request. If zwhy is not NULL, - this reports an error to the log file and to the user. */ - -static boolean -flocal_send_fail (qcmd, qdaemon, zwhy) - struct scmd *qcmd; - struct sdaemon *qdaemon; - const char *zwhy; -{ - if (zwhy != NULL) - { - const char *zfrom; - char *zfree; - const char *ztemp; - - if (qcmd->bcmd != 'E') - { - zfrom = qcmd->zfrom; - zfree = NULL; - } - else - { - zfree = zbufalc (strlen (qcmd->zfrom) - + sizeof " (execution of \"\")" - + strlen (qcmd->zcmd)); - sprintf (zfree, "%s (execution of \"%s\")", qcmd->zfrom, - qcmd->zcmd); - zfrom = zfree; - } - - ulog (LOG_ERROR, "%s: %s", zfrom, zwhy); - - /* We only save the temporary file if this is a request from the - local system; otherwise a remote system could launch a denial - of service attack by filling up the .Preserve directory - (local users have much simpler methods for this type of - denial of service attack, so there is little point to using a - more sophisticated scheme). */ - if (strchr (qcmd->zuser, '!') == NULL) - ztemp = zsysdep_save_temp_file (qcmd->pseq); - else - ztemp = NULL; - (void) fmail_transfer (FALSE, qcmd->zuser, (const char *) NULL, - zwhy, zfrom, (const char *) NULL, - qcmd->zto, qdaemon->qsys->uuconf_zname, ztemp); - - ubuffree (zfree); - } - - (void) fsysdep_did_work (qcmd->pseq); - - return TRUE; -} - -/* This is called when we are ready to send the request to the remote - system. We form the request and send it over. If the protocol - does not support multiple channels, we start waiting for the - response; otherwise we can start sending the file immediately. */ - -static boolean -flocal_send_request (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - char *zsend; - const char *znotify; - char absize[20]; - boolean fret; - - /* Make sure the file meets any remote size restrictions. */ - if (qdaemon->cmax_receive != -1 - && qdaemon->cmax_receive < qinfo->cbytes) - { - fret = flocal_send_fail (&qtrans->s, qdaemon, "too large for receiver"); - usfree_send (qtrans); - return fret; - } - - /* Make sure the file still exists--it may have been removed between - the conversation startup and now. After we have sent over the S - command we must give an error if we can't find the file. */ - if (! fsysdep_file_exists (qinfo->zfile)) - { - (void) fsysdep_did_work (qtrans->s.pseq); - usfree_send (qtrans); - return TRUE; - } - - /* If we are using a protocol which can make multiple channels, then - we can open and send the file whenever we are ready. This is - because we will be able to distinguish the response by the - channel it is directed to. This assumes that every protocol - which supports multiple channels also supports sending the file - position in mid-stream, since otherwise we would not be able to - restart files. */ - qtrans->fcmd = TRUE; - qtrans->psendfn = flocal_send_open_file; - qtrans->precfn = flocal_send_await_reply; - - if (qdaemon->cchans > 1) - fret = fqueue_send (qdaemon, qtrans); - else - fret = fqueue_receive (qdaemon, qtrans); - if (! fret) - return FALSE; - - /* Construct the notify string to send. If we are going to send a - size or an execution command, it must be non-empty. */ - znotify = qtrans->s.znotify; - if (znotify == NULL) - znotify = ""; - if ((qdaemon->ifeatures & FEATURE_SIZES) != 0 - || (qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) != 0)) - { - if (*znotify == '\0') - znotify = "\"\""; - } - else - { - /* We don't need a notify string. Some crufty UUCP code can't - handle a pair of double quotes. */ - if (strcmp (znotify, "\"\"") == 0) - znotify = ""; - } - - /* Construct the size string to send. */ - if ((qdaemon->ifeatures & FEATURE_SIZES) == 0 - && (qtrans->s.bcmd != 'E' - || (qdaemon->ifeatures & FEATURE_EXEC) == 0)) - absize[0] = '\0'; - else if ((qdaemon->ifeatures & FEATURE_V103) == 0) - sprintf (absize, "0x%lx", (unsigned long) qinfo->cbytes); - else - sprintf (absize, "%ld", qinfo->cbytes); - - zsend = zbufalc (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto) - + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) - + strlen (qtrans->s.ztemp) + strlen (znotify) - + strlen (absize) - + (qtrans->s.zcmd != NULL ? strlen (qtrans->s.zcmd) : 0) - + 50); - - /* If this an execution request and the other side supports - execution requests, we send an E command. Otherwise we send an S - command. The case of an execution request when we are sending - the fake execution file is handled just like an S request at this - point. */ - if (qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) != 0) - { - /* Send the string - E zfrom zto zuser zoptions ztemp imode znotify size zcmd - to the remote system. We put a '-' in front of the (possibly - empty) options and a '0' in front of the mode. */ - sprintf (zsend, "E %s %s %s -%s %s 0%o %s %s %s", qtrans->s.zfrom, - qtrans->s.zto, qtrans->s.zuser, qtrans->s.zoptions, - qtrans->s.ztemp, qtrans->s.imode, znotify, absize, - qtrans->s.zcmd); - } - else - { - const char *zoptions, *zdummy; - - /* Send the string - S zfrom zto zuser zoptions ztemp imode znotify - to the remote system. We put a '-' in front of the (possibly - empty) options and a '0' in front of the mode. If size - negotiation is supported, we also send the size; in this case - if znotify is empty we must send it as "". If this is really - an execution request, we have to simplify the options string - to remove the various execution options which may confuse the - remote system. SVR4 expects a string "dummy" between the - notify string and the size; I don't know why. */ - if (qtrans->s.bcmd != 'E') - zoptions = qtrans->s.zoptions; - else if (strchr (qtrans->s.zoptions, 'C') != NULL) - { - /* This should set zoptions to "C", but at least one UUCP - program gets confused by it. That means that it will - fail in certain cases, but I suppose we might as well - kowtow to compatibility. This shouldn't matter to any - other program, I hope. */ - zoptions = ""; - } - else - zoptions = "c"; - - if ((qdaemon->ifeatures & FEATURE_SVR4) != 0) - zdummy = " dummy "; - else - zdummy = " "; - - sprintf (zsend, "S %s %s %s -%s %s 0%o %s%s%s", qtrans->s.zfrom, - qtrans->s.zto, qtrans->s.zuser, zoptions, - qtrans->s.ztemp, qtrans->s.imode, znotify, zdummy, - absize); - } - - fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal, - qtrans->iremote); - ubuffree (zsend); - - /* If fret is FALSE, we should free qtrans here, but see the comment - at the end of flocal_rec_send_request. */ - - return fret; -} - -/* This is called when a reply is received for the send request. As - described at length above, if the protocol supports multiple - channels we may be in the middle of sending the file, or we may - even finished sending the file. */ - -static boolean -flocal_send_await_reply (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - char bcmd; - - if (qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) != 0) - bcmd = 'E'; - else - bcmd = 'S'; - if (zdata[0] != bcmd - || (zdata[1] != 'Y' && zdata[1] != 'N')) - { - ulog (LOG_ERROR, "%s: Bad response to %c request: \"%s\"", - qtrans->s.zfrom, bcmd, zdata); - usfree_send (qtrans); - return FALSE; - } - - if (zdata[1] == 'N') - { - const char *zerr; - boolean fnever; - - fnever = TRUE; - if (zdata[2] == '2') - zerr = "permission denied by remote"; - else if (zdata[2] == '4') - { - zerr = "remote cannot create work files"; - fnever = FALSE; - } - else if (zdata[2] == '6') - { - zerr = "too large for remote now"; - fnever = FALSE; - } - else if (zdata[2] == '7') - { - /* The file is too large to ever send. */ - zerr = "too large for remote"; - } - else if (zdata[2] == '8') - { - /* The file was already received by the remote system. This - is not an error, it just means that the ack from the - remote was lost in the previous conversation, and there - is no need to resend the file. */ - zerr = NULL; - } - else if (zdata[2] == '9') - { - /* Remote has run out of channels. */ - zerr = "too many channels for remote"; - fnever = FALSE; - - /* Drop one channel; using exactly one channel causes - slightly different behahaviour in a few places, so don't - decrement to one. */ - if (qdaemon->cchans > 2) - --qdaemon->cchans; - } - else - zerr = "unknown reason"; - - if (! fnever - || (qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) == 0 - && qinfo->zexec == NULL)) - { - if (qtrans->s.bcmd == 'E') - ulog (LOG_ERROR, "%s (execution of \"%s\"): %s", - qtrans->s.zfrom, qtrans->s.zcmd, zerr); - else - ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr); - } - else - { - if (! flocal_send_fail (&qtrans->s, qdaemon, zerr)) - return FALSE; - } - - /* If the protocol does not support multiple channels, we can - simply remove the transaction. Otherwise we must make sure - the remote side knows that we have finished sending the file - data. If we have already sent the entire file, there will be - no confusion. */ - if (qdaemon->cchans == 1 || qinfo->fsent) - { - /* If we are breaking a 'E' command into two 'S' commands, - and that was for the first 'S' command, we still have to - send the second one. */ - if (fnever - && qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) == 0 - && qinfo->zexec == NULL) - return fsend_exec_file_init (qtrans, qdaemon); - - usfree_send (qtrans); - return TRUE; - } - else - { - /* Seek to the end of the file so that the next read will - send end of file. We have to be careful here, because we - may have actually already sent end of file--we could be - being called because of data received while the end of - file block was sent. */ - if (! ffileseekend (qtrans->e)) - { - ulog (LOG_ERROR, "seek to end: %s", strerror (errno)); - usfree_send (qtrans); - return FALSE; - } - qtrans->psendfn = flocal_send_cancelled; - qtrans->precfn = NULL; - - qinfo->fnever = fnever; - - return fqueue_send (qdaemon, qtrans); - } - } - - /* A number following the SY or EY is the file position to start - sending from. If we are already sending the file, we must set - the position accordingly. */ - if (zdata[2] != '\0') - { - long cskip; - - cskip = strtol ((char *) (zdata + 2), (char **) NULL, 0); - if (cskip > 0 && qtrans->ipos < cskip) - { - if (qtrans->fsendfile && ! qinfo->fsent) - { - if (! ffileseek (qtrans->e, cskip)) - { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - usfree_send (qtrans); - return FALSE; - } - } - qtrans->ipos = cskip; - } - } - - /* Now queue up to send the file or to wait for the confirmation. - We already set psendfn at the end of flocal_send_request. If the - protocol supports multiple channels, we have already called - fqueue_send; calling it again would move the request in the - queue, which would make the log file a bit confusing. */ - qtrans->fcmd = TRUE; - qtrans->precfn = fsend_await_confirm; - if (qinfo->fsent) - return fqueue_receive (qdaemon, qtrans); - else if (qdaemon->cchans <= 1) - return fqueue_send (qdaemon, qtrans); - else - return TRUE; -} - -/* Open the file, if any, and prepare to send it. */ - -static boolean -flocal_send_open_file (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - const char *zuser; - - /* If this is not a fake execution file, open it. */ - if (qinfo->zexec == NULL) - { - /* If there is an ! in the user name, this is a remote request - queued up by fremote_xcmd_init. */ - zuser = qtrans->s.zuser; - if (strchr (zuser, '!') != NULL) - zuser = NULL; - - qtrans->e = esysdep_open_send (qdaemon->qsys, qinfo->zfile, - ! qinfo->fspool, zuser); - if (! ffileisopen (qtrans->e)) - { - (void) fmail_transfer (FALSE, qtrans->s.zuser, - (const char *) NULL, - "cannot open file", - qtrans->s.zfrom, (const char *) NULL, - qtrans->s.zto, - qdaemon->qsys->uuconf_zname, - (qinfo->flocal - ? zsysdep_save_temp_file (qtrans->s.pseq) - : (const char *) NULL)); - (void) fsysdep_did_work (qtrans->s.pseq); - usfree_send (qtrans); - - /* Unfortunately, there is no way to cancel a file send - after we've already put it in progress. So we have to - return FALSE to drop the connection. */ - return FALSE; - } - } - - /* If flocal_send_await_reply has received a reply with a file - position, it will have set qtrans->ipos to the position at which - to start. */ - if (qtrans->ipos > 0) - { - if (qinfo->zexec != NULL) - { - if (qtrans->ipos > qtrans->cbytes) - qtrans->ipos = qtrans->cbytes; - } - else - { - if (! ffileseek (qtrans->e, qtrans->ipos)) - { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - usfree_send (qtrans); - return FALSE; - } - } - } - - /* We don't bother to log sending the execution file. */ - if (qinfo->zexec == NULL) - { - const char *zsend; - char *zalc; - - if (qtrans->s.bcmd != 'E') - { - zsend = qtrans->s.zfrom; - zalc = NULL; - } - else - { - zalc = zbufalc (strlen (qtrans->s.zcmd) + sizeof " ()" - + strlen (qtrans->s.zfrom)); - sprintf (zalc, "%s (%s)", qtrans->s.zcmd, qtrans->s.zfrom); - zsend = zalc; - } - - qtrans->zlog = zbufalc (sizeof "Sending ( bytes resume at )" - + strlen (zsend) + 50); - sprintf (qtrans->zlog, "Sending %s (%ld bytes", zsend, qinfo->cbytes); - if (qtrans->ipos > 0) - sprintf (qtrans->zlog + strlen (qtrans->zlog), " resume at %ld", - qtrans->ipos); - strcat (qtrans->zlog, ")"); - - ubuffree (zalc); - } - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, TRUE, - qinfo->cbytes - qtrans->ipos, - &fhandled)) - { - usfree_send (qtrans); - return FALSE; - } - - if (fhandled) - return TRUE; - } - - if (qinfo->zexec != NULL) - qtrans->psendfn = fsend_exec_file; - else - { - qtrans->fsendfile = TRUE; - qtrans->psendfn = fsend_file_end; - } - - return fqueue_send (qdaemon, qtrans); -} - -/* Cancel a file send. This is only called for a protocol which - supports multiple channels. It is needed so that both systems - agree as to when a channel is no longer needed. */ - -static boolean -flocal_send_cancelled (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - - /* If we are breaking a 'E' command into two 'S' commands, and that - was for the first 'S' command, and the first 'S' command will - never be sent, we still have to send the second one. */ - if (qinfo->fnever - && qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) == 0 - && qinfo->zexec == NULL) - return fsend_exec_file_init (qtrans, qdaemon); - - usfree_send (qtrans); - return TRUE; -} - -/* A remote request to receive a file (meaning that we have to send a - file). The sequence of functions calls is as follows: - - fremote_rec_file_init (open file) --> fqueue_remote - fremote_rec_reply (send RY, call pffile) --> fqueue_send - send file - fsend_file_end (calls pffile) --> fqueue_receive - fsend_await_confirm (waits for CY) - */ - -boolean -fremote_rec_file_init (qdaemon, qcmd, iremote) - struct sdaemon *qdaemon; - struct scmd *qcmd; - int iremote; -{ - const struct uuconf_system *qsys; - char *zfile; - boolean fbadname; - long cbytes; - unsigned int imode; - openfile_t e; - struct ssendinfo *qinfo; - struct stransfer *qtrans; - - qsys = qdaemon->qsys; - - if (! qsys->uuconf_fsend_request) - { - ulog (LOG_ERROR, "%s: not permitted to send files to remote", - qcmd->zfrom); - return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote); - } - - if (fspool_file (qcmd->zfrom)) - { - ulog (LOG_ERROR, "%s: not permitted to send", qcmd->zfrom); - return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote); - } - - zfile = zsysdep_local_file (qcmd->zfrom, qsys->uuconf_zpubdir, &fbadname); - if (zfile == NULL && fbadname) - { - ulog (LOG_ERROR, "%s: bad local file name", qcmd->zfrom); - return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote); - } - if (zfile != NULL) - { - char *zbased; - - zbased = zsysdep_add_base (zfile, qcmd->zto); - ubuffree (zfile); - zfile = zbased; - } - if (zfile == NULL) - return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote); - - if (! fin_directory_list (zfile, qsys->uuconf_pzremote_send, - qsys->uuconf_zpubdir, TRUE, TRUE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "%s: not permitted to send", zfile); - ubuffree (zfile); - return fremote_rec_fail (qdaemon, FAILURE_PERM, iremote); - } - - /* If the file is larger than the amount of space the other side - reported, we can't send it. Should we adjust this check based on - the restart position? */ - cbytes = csysdep_size (zfile); - if (cbytes != -1 - && ((qcmd->cbytes != -1 && qcmd->cbytes < cbytes) - || (qdaemon->cremote_size != -1 - && qdaemon->cremote_size < cbytes) - || (qdaemon->cmax_receive != -1 - && qdaemon->cmax_receive < cbytes))) - { - ulog (LOG_ERROR, "%s: too large to send", zfile); - ubuffree (zfile); - return fremote_rec_fail (qdaemon, FAILURE_SIZE, iremote); - } - - imode = ixsysdep_file_mode (zfile); - - e = esysdep_open_send (qsys, zfile, TRUE, (const char *) NULL); - if (! ffileisopen (e)) - { - ubuffree (zfile); - return fremote_rec_fail (qdaemon, FAILURE_OPEN, iremote); - } - - /* If the remote requested that the file send start from a - particular position, arrange to do so. */ - if (qcmd->ipos > 0) - { - if (! ffileseek (e, qcmd->ipos)) - { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - ubuffree (zfile); - return FALSE; - } - } - - qinfo = (struct ssendinfo *) xmalloc (sizeof (struct ssendinfo)); - qinfo->zmail = NULL; - qinfo->zfile = zfile; - qinfo->cbytes = cbytes; - qinfo->flocal = FALSE; - qinfo->fspool = FALSE; - qinfo->fsent = FALSE; - qinfo->zexec = NULL; - qinfo->zconfirm = NULL; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = fremote_rec_reply; - qtrans->iremote = iremote; - qtrans->pinfo = (pointer) qinfo; - qtrans->e = e; - qtrans->ipos = qcmd->ipos; - qtrans->s.imode = imode; - - return fqueue_remote (qdaemon, qtrans); -} - -/* Reply to a receive request from the remote system, and prepare to - start sending the file. */ - -static boolean -fremote_rec_reply (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - char absend[50]; - - qtrans->fsendfile = TRUE; - qtrans->psendfn = fsend_file_end; - qtrans->fcmd = TRUE; - qtrans->precfn = fsend_await_confirm; - - if (! fqueue_send (qdaemon, qtrans)) - return FALSE; - - qtrans->zlog = zbufalc (sizeof "Sending ( bytes) " - + strlen (qtrans->s.zfrom) + 25); - sprintf (qtrans->zlog, "Sending %s (%ld bytes)", qtrans->s.zfrom, - qinfo->cbytes); - - /* We send the file size because SVR4 UUCP does. We don't look for - it. We send a trailing M if we want to request a hangup. We - send it both after the mode and at the end of the entire string; - I don't know where programs look for it. */ - if (qdaemon->frequest_hangup) - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "fremote_rec_reply: Requesting remote to transfer control"); - sprintf (absend, "RY 0%o%s 0x%lx%s", qtrans->s.imode, - qdaemon->frequest_hangup ? "M" : "", - (unsigned long) qinfo->cbytes, - qdaemon->frequest_hangup ? "M" : ""); - if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, absend, qtrans->ilocal, - qtrans->iremote)) - { - (void) ffileclose (qtrans->e); - /* Should probably free qtrans here, but see the comment at the - end of flocal_rec_send_request. */ - return FALSE; - } - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, TRUE, TRUE, - qinfo->cbytes, &fhandled)) - { - usfree_send (qtrans); - return FALSE; - } - } - - return TRUE; -} - -/* If we can't send a file as requested by the remote system, queue up - a failure reply which will be sent when possible. */ - -static boolean -fremote_rec_fail (qdaemon, twhy, iremote) - struct sdaemon *qdaemon; - enum tfailure twhy; - int iremote; -{ - enum tfailure *ptinfo; - struct stransfer *qtrans; - - ptinfo = (enum tfailure *) xmalloc (sizeof (enum tfailure)); - *ptinfo = twhy; - - qtrans = qtransalc ((struct scmd *) NULL); - qtrans->psendfn = fremote_rec_fail_send; - qtrans->iremote = iremote; - qtrans->pinfo = (pointer) ptinfo; - - return fqueue_remote (qdaemon, qtrans); -} - -/* Send a failure string for a receive command to the remote system; - this is called when we are ready to reply to the command. */ - -static boolean -fremote_rec_fail_send (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - enum tfailure *ptinfo = (enum tfailure *) qtrans->pinfo; - const char *z; - int ilocal, iremote; - - switch (*ptinfo) - { - case FAILURE_PERM: - case FAILURE_OPEN: - z = "RN2"; - break; - case FAILURE_SIZE: - z = "RN6"; - break; - default: - z = "RN"; - break; - } - - ilocal = qtrans->ilocal; - iremote = qtrans->iremote; - - xfree (qtrans->pinfo); - utransfree (qtrans); - - return (*qdaemon->qproto->pfsendcmd) (qdaemon, z, ilocal, iremote); -} - -/* This is called when the main loop has finished sending a file. It - prepares to wait for a response from the remote system. Note that - if this is a local request and the protocol supports multiple - channels, we may not even have received a confirmation of the send - request. */ - -static boolean -fsend_file_end (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - - if (qdaemon->qproto->pffile != NULL) - { - boolean fhandled; - - if (! (*qdaemon->qproto->pffile) (qdaemon, qtrans, FALSE, TRUE, - (long) -1, &fhandled)) - { - usfree_send (qtrans); - return FALSE; - } - - if (fhandled) - return TRUE; - } - - qinfo->fsent = TRUE; - - /* If zconfirm is set, then we have already received the - confirmation, and should call fsend_await_confirm directly. */ - if (qinfo->zconfirm != NULL) - return fsend_await_confirm (qtrans, qdaemon, qinfo->zconfirm, - strlen (qinfo->zconfirm) + 1); - - /* qtrans->precfn should have been set by a previous function. */ - return fqueue_receive (qdaemon, qtrans); -} - -/* Handle the confirmation string received after sending a file. */ - -/*ARGSUSED*/ -static boolean -fsend_await_confirm (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - boolean fnever; - const char *zerr; - - /* If fsent is FALSE, it means that we have received the - confirmation before fsend_file_end got called. To avoid - confusion, we save away the confirmation message, and let - fsend_file_end call us directly. If we did not do this, we would - have to fix a thorny race condition in floop, which wants to - refer to the qtrans structure after sending the end of the file. */ - if (! qinfo->fsent) - { - qinfo->zconfirm = zbufcpy (zdata); - return TRUE; - } - - if (qinfo->zexec == NULL) - (void) ffileclose (qtrans->e); - - fnever = FALSE; - if (zdata[0] != 'C' - || (zdata[1] != 'Y' && zdata[1] != 'N')) - { - zerr = "bad confirmation from remote"; - ulog (LOG_ERROR, "%s: %s \"%s\"", qtrans->s.zfrom, zerr, zdata); - } - else if (zdata[1] == 'N') - { - fnever = TRUE; - if (zdata[2] == '5') - { - zerr = "file could not be stored in final location"; - ulog (LOG_ERROR, "%s: %s", qtrans->s.zfrom, zerr); - } - else - { - zerr = "file send failed for unknown reason"; - ulog (LOG_ERROR, "%s: %s \"%s\"", qtrans->s.zfrom, zerr, zdata); - } - } - else - { - zerr = NULL; - - /* If we receive CYM, it means that the other side wants us to - hang up so that they can send us something. The - fhangup_requested field is checked in the main loop. */ - if (zdata[2] == 'M' && qdaemon->fmaster) - { - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "fsend_await_confirm: Remote has requested transfer of control"); - qdaemon->fhangup_requested = TRUE; - } - } - - ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname, - TRUE, qtrans->cbytes, qtrans->isecs, qtrans->imicros, - qdaemon->fcaller); - qdaemon->csent += qtrans->cbytes; - - if (zerr == NULL) - { - /* If this is an execution request, and the remote system - doesn't support execution requests, we have to set up the - fake execution file and loop around again. */ - if (qtrans->s.bcmd == 'E' - && (qdaemon->ifeatures & FEATURE_EXEC) == 0 - && qinfo->zexec == NULL) - return fsend_exec_file_init (qtrans, qdaemon); - - /* Send mail about the transfer if requested. */ - if (qinfo->zmail != NULL && *qinfo->zmail != '\0') - (void) fmail_transfer (TRUE, qtrans->s.zuser, qinfo->zmail, - (const char *) NULL, - qtrans->s.zfrom, (const char *) NULL, - qtrans->s.zto, qdaemon->qsys->uuconf_zname, - (const char *) NULL); - - if (qtrans->s.pseq != NULL) - (void) fsysdep_did_work (qtrans->s.pseq); - } - else - { - /* If the file send failed, we only try to save the file and - send mail if it was requested locally and it will never - succeed. We send mail to qinfo->zmail if set, otherwise to - qtrans->s.zuser. I hope this is reasonable. */ - if (fnever && qinfo->flocal) - { - (void) fmail_transfer (FALSE, qtrans->s.zuser, qinfo->zmail, - zerr, qtrans->s.zfrom, (const char *) NULL, - qtrans->s.zto, qdaemon->qsys->uuconf_zname, - zsysdep_save_temp_file (qtrans->s.pseq)); - (void) fsysdep_did_work (qtrans->s.pseq); - } - } - - usfree_send (qtrans); - - return TRUE; -} - -/* Prepare to send an execution file to a system which does not - support execution requests. We build the execution file in memory, - and then call flocal_send_request as though we were sending a real - file. Instead of sending a file, the code in flocal_send_open_file - will arrange to call fsend_exec_file which will send data out of - the buffer we have created. */ - -static boolean -fsend_exec_file_init (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - char *zxqtfile; - char abtname[CFILE_NAME_LEN]; - char abxname[CFILE_NAME_LEN]; - char *z; - size_t calc, clen; - - z = NULL; - calc = 0; - clen = 0; - - usadd_exec_line (&z, &calc, &clen, 'U', qtrans->s.zuser, - qdaemon->zlocalname); - usadd_exec_line (&z, &calc, &clen, 'F', qtrans->s.zto, ""); - usadd_exec_line (&z, &calc, &clen, 'I', qtrans->s.zto, ""); - if (strchr (qtrans->s.zoptions, 'N') != NULL) - usadd_exec_line (&z, &calc, &clen, 'N', "", ""); - if (strchr (qtrans->s.zoptions, 'Z') != NULL) - usadd_exec_line (&z, &calc, &clen, 'Z', "", ""); - if (strchr (qtrans->s.zoptions, 'R') != NULL) - usadd_exec_line (&z, &calc, &clen, 'R', qtrans->s.znotify, ""); - if (strchr (qtrans->s.zoptions, 'e') != NULL) - usadd_exec_line (&z, &calc, &clen, 'e', "", ""); - usadd_exec_line (&z, &calc, &clen, 'C', qtrans->s.zcmd, ""); - - qinfo->zexec = z; - qinfo->cbytes = clen; - - zxqtfile = zsysdep_data_file_name (qdaemon->qsys, qdaemon->zlocalname, - BDEFAULT_UUX_GRADE, TRUE, abtname, - (char *) NULL, abxname); - if (zxqtfile == NULL) - { - usfree_send (qtrans); - return FALSE; - } - ubuffree (zxqtfile); - - ubuffree ((char *) qtrans->s.zfrom); - qtrans->s.zfrom = zbufcpy (abtname); - ubuffree ((char *) qtrans->s.zto); - qtrans->s.zto = zbufcpy (abxname); - ubuffree ((char *) qtrans->s.zoptions); - qtrans->s.zoptions = zbufcpy ("C"); - ubuffree ((char *) qtrans->s.ztemp); - qtrans->s.ztemp = zbufcpy (abtname); - - qtrans->psendfn = flocal_send_request; - qtrans->precfn = NULL; - qtrans->ipos = 0; - qtrans->cbytes = 0; - qtrans->isecs = 0; - qtrans->imicros = 0; - qinfo->fsent = FALSE; - ubuffree (qinfo->zconfirm); - qinfo->zconfirm = NULL; - - return fqueue_send (qdaemon, qtrans); -} - -/* Add a line to the fake execution file. */ - -static void -usadd_exec_line (pz, pcalc, pclen, bcmd, z1, z2) - char **pz; - size_t *pcalc; - size_t *pclen; - int bcmd; - const char *z1; - const char *z2; -{ - size_t c1, c2; - char *znew; - - c1 = strlen (z1); - c2 = strlen (z2); - - if (*pclen + c1 + c2 + 4 >= *pcalc) - { - *pcalc += c1 + c2 + 100; - znew = zbufalc (*pcalc); - if (*pclen > 0) - { - memcpy (znew, *pz, *pclen); - ubuffree (*pz); - } - *pz = znew; - } - - znew = *pz + *pclen; - *znew++ = bcmd; - if (*z1 != '\0') - { - *znew++ = ' '; - memcpy (znew, z1, c1); - znew += c1; - if (*z2 != '\0') - { - *znew++ = ' '; - memcpy (znew, z2, c2); - znew += c2; - } - } - - /* In some bizarre non-Unix case we might have to worry about the - newline here. We don't know how a newline is normally written - out to a file, but whatever is written to a file is what we will - normally transfer. If that is not simply \n then this fake - execution file will not look like other execution files. */ - *znew++ = '\n'; - - *pclen = znew - *pz; -} - -/* This routine is called to send the contents of the fake execution - file. Normally file data is sent by the floop routine in trans.c, - but since we don't have an actual file we must do it here. This - routine sends the complete buffer, followed by a zero length - packet, and then calls fsend_file_end. */ - -static boolean -fsend_exec_file (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - struct ssendinfo *qinfo = (struct ssendinfo *) qtrans->pinfo; - char *zdata; - size_t cdata; - size_t csend; - - zdata = (*qdaemon->qproto->pzgetspace) (qdaemon, &cdata); - if (zdata == NULL) - { - usfree_send (qtrans); - return FALSE; - } - - csend = qinfo->cbytes - qtrans->ipos; - if (csend > cdata) - csend = cdata; - - memcpy (zdata, qinfo->zexec + qtrans->ipos, csend); - - if (! (*qdaemon->qproto->pfsenddata) (qdaemon, zdata, csend, - qtrans->ilocal, qtrans->iremote, - qtrans->ipos)) - { - usfree_send (qtrans); - return FALSE; - } - - qtrans->cbytes += csend; - qtrans->ipos += csend; - - if (csend == 0) - return fsend_file_end (qtrans, qdaemon); - - /* Leave the job on the send queue. */ - - return TRUE; -} diff --git a/gnu/libexec/uucp/uucico/time.c b/gnu/libexec/uucp/uucico/time.c deleted file mode 100644 index bdcb25f..0000000 --- a/gnu/libexec/uucp/uucico/time.c +++ /dev/null @@ -1,132 +0,0 @@ -/* time.c - Routines to deal with UUCP time spans. - - Copyright (C) 1991, 1992, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char time_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> - -#if TM_IN_SYS_TIME -#include <sys/time.h> -#else -#include <time.h> -#endif - -#include "uudefs.h" -#include "uuconf.h" - -/* External functions. */ -#ifndef time -extern time_t time (); -#endif -#ifndef localtime -extern struct tm *localtime (); -#endif - -/* See if the current time matches a time span. If it does, return - TRUE, set *pival to the value for the matching span, and set - *pcretry to the retry for the matching span. Otherwise return - FALSE. */ - -boolean -ftimespan_match (qspan, pival, pcretry) - const struct uuconf_timespan *qspan; - long *pival; - int *pcretry; -{ - time_t inow; - struct tm *qtm; - int itm; - const struct uuconf_timespan *q; - - if (qspan == NULL) - return FALSE; - - time (&inow); - qtm = localtime (&inow); - - /* Get the number of minutes since Sunday for the time. */ - itm = qtm->tm_wday * 24 * 60 + qtm->tm_hour * 60 + qtm->tm_min; - - for (q = qspan; q != NULL; q = q->uuconf_qnext) - { - if (q->uuconf_istart <= itm && itm <= q->uuconf_iend) - { - if (pival != NULL) - *pival = q->uuconf_ival; - if (pcretry != NULL) - *pcretry = q->uuconf_cretry; - return TRUE; - } - } - - return FALSE; -} - -/* Determine the maximum size that may ever be transferred, according - to a timesize span. This returns -1 if there is no limit. */ - -long -cmax_size_ever (qtimesize) - const struct uuconf_timespan *qtimesize; -{ - long imax; - const struct uuconf_timespan *q; - - if (qtimesize == NULL) - return -1; - - /* Look through the list of spans. If there is any gap larger than - 1 hour, we assume there are no restrictions. Otherwise we keep - track of the largest value we see. I picked 1 hour arbitrarily, - on the theory that a 1 hour span to transfer large files might - actually occur, and is probably not an accident. */ - if (qtimesize->uuconf_istart >= 60) - return -1; - - imax = -1; - - for (q = qtimesize; q != NULL; q = q->uuconf_qnext) - { - if (q->uuconf_qnext == NULL) - { - if (q->uuconf_iend <= 6 * 24 * 60 + 23 * 60) - return -1; - } - else - { - if (q->uuconf_iend + 60 <= q->uuconf_qnext->uuconf_istart) - return -1; - } - - if (imax < q->uuconf_ival) - imax = q->uuconf_ival; - } - - return imax; -} diff --git a/gnu/libexec/uucp/uucico/trans.c b/gnu/libexec/uucp/uucico/trans.c deleted file mode 100644 index e716571..0000000 --- a/gnu/libexec/uucp/uucico/trans.c +++ /dev/null @@ -1,1489 +0,0 @@ -/* trans.c - Routines to handle file transfers. - - Copyright (C) 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char trans_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "prot.h" -#include "system.h" -#include "trans.h" - -/* Local functions. */ - -static void utqueue P((struct stransfer **, struct stransfer *, - boolean fhead)); -static void utdequeue P((struct stransfer *)); -static void utchanalc P((struct sdaemon *qdaemon, struct stransfer *qtrans)); -__inline__ static struct stransfer *qtchan P((int ichan)); -__inline__ static void utchanfree P((struct stransfer *qtrans)); -static boolean fttime P((struct sdaemon *qdaemon, long *pisecs, - long *pimicros)); -static boolean fcheck_queue P((struct sdaemon *qdaemon)); -static boolean ftadd_cmd P((struct sdaemon *qdaemon, const char *z, - size_t cdata, int iremote, boolean flast)); -static boolean fremote_hangup_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean flocal_poll_file P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); - -/* Queue of transfer structures that are ready to start which have - been requested by the local system. These are only permitted to - start when the local system is the master. */ -static struct stransfer *qTlocal; - -/* Queue of transfer structures that are ready to start which have - been requested by the remote system. These are responses to - commands received from the remote system, and should be started as - soon as possible. */ -static struct stransfer *qTremote; - -/* Queue of transfer structures that have been started and want to - send information. This should be static, but the 'a' protocol - looks at it, at least for now. */ -struct stransfer *qTsend; - -/* Queue of transfer structures that have been started and are waiting - to receive information. */ -static struct stransfer *qTreceive; - -/* Queue of free transfer structures. */ -static struct stransfer *qTavail; - -/* Array of transfer structures indexed by local channel number. This - is maintained for local jobs. */ -static struct stransfer *aqTchan[IMAX_CHAN + 1]; - -/* Number of local channel numbers currently allocated. */ -static int cTchans; - -/* Next channel number to allocate. */ -static int iTchan; - -/* Array of transfer structures indexed by remote channel number. - This is maintained for remote jobs. */ -static struct stransfer *aqTremote[IMAX_CHAN + 1]; - -/* The transaction we are currently receiving. This is used to avoid - getting the time too frequently. */ -static struct stransfer *qTtiming_rec; - -/* The time from which to charge any received data. This is either - the last time we charged for received data, or the last time - something was put on the empty receive queue. */ -static long iTrecsecs; -static long iTrecmicros; - -/* The minimum amount of time, in seconds, to wait between times we - check the spool directory, if we are busy transferring data. If we - have nothing to do, we will check the spool directory regardless of - how long ago the last check was. This should probably be - configurable. */ -#define CCHECKWAIT (600) - -/* The time we last checked the spool directory for work. This is set - from the return value of ixsysdep_process_time, not ixsysdep_time, - for convenience in the routines which use it. */ -static long iTchecktime; - -/* The size of the command we have read so far in ftadd_cmd. */ -static size_t cTcmdlen; - -/* The structure we use when waiting for an acknowledgement of a - confirmed received file in fsent_receive_ack, and a list of those - structures. */ - -struct sreceive_ack -{ - struct sreceive_ack *qnext; - char *zto; - char *ztemp; - boolean fmarked; -}; - -static struct sreceive_ack *qTreceive_ack; - -/* Queue up a transfer structure before *pq. This puts it at the head - or the tail of the list headed by *pq. */ - -static void -utqueue (pq, q, fhead) - struct stransfer **pq; - struct stransfer *q; - boolean fhead; -{ - if (*pq == NULL) - { - *pq = q; - q->qprev = q->qnext = q; - } - else - { - q->qnext = *pq; - q->qprev = (*pq)->qprev; - q->qprev->qnext = q; - q->qnext->qprev = q; - if (fhead) - *pq = q; - } - q->pqqueue = pq; -} - -/* Dequeue a transfer structure. */ - -static void -utdequeue (q) - struct stransfer *q; -{ - if (q->pqqueue != NULL) - { - if (*(q->pqqueue) == q) - { - if (q->qnext == q) - *(q->pqqueue) = NULL; - else - *(q->pqqueue) = q->qnext; - } - q->pqqueue = NULL; - } - if (q->qprev != NULL) - q->qprev->qnext = q->qnext; - if (q->qnext != NULL) - q->qnext->qprev = q->qprev; - q->qprev = NULL; - q->qnext = NULL; -} - -/* Queue up a transfer structure requested by the local system. */ - -/*ARGSIGNORED*/ -boolean -fqueue_local (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ - utdequeue (qtrans); - utqueue (&qTlocal, qtrans, FALSE); - return TRUE; -} - -/* Queue up a transfer structure requested by the remote system. The - stransfer structure should have the iremote field set. We need to - record it, so that any subsequent data associated with this - channel can be routed to the right place. */ - -boolean -fqueue_remote (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fqueue_remote: Channel %d", - qtrans->iremote); - if (qtrans->iremote > 0) - aqTremote[qtrans->iremote] = qtrans; - utdequeue (qtrans); - utqueue (&qTremote, qtrans, FALSE); - return TRUE; -} - -/* Queue up a transfer with something to send. */ - -boolean -fqueue_send (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ -#if DEBUG > 0 - if (qtrans->psendfn == NULL) - ulog (LOG_FATAL, "fqueue_send: Bad call"); -#endif - utdequeue (qtrans); - - /* Sort the send queue to always send commands before files, and to - sort jobs by grade. */ - if (qTsend == NULL) - utqueue (&qTsend, qtrans, FALSE); - else - { - register struct stransfer *q; - boolean ffirst; - - ffirst = TRUE; - q = qTsend; - do - { - if (! qtrans->fsendfile && q->fsendfile) - break; - if ((! qtrans->fsendfile || q->fsendfile) - && UUCONF_GRADE_CMP (qtrans->s.bgrade, q->s.bgrade) < 0) - break; - - ffirst = FALSE; - q = q->qnext; - } - while (q != qTsend); - - qtrans->qnext = q; - qtrans->qprev = q->qprev; - q->qprev = qtrans; - qtrans->qprev->qnext = qtrans; - if (ffirst) - qTsend = qtrans; - qtrans->pqqueue = &qTsend; - } - - return TRUE; -} - -/* Queue up a transfer with something to receive. */ - -boolean -fqueue_receive (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ -#if DEBUG > 0 - if (qtrans->precfn == NULL) - ulog (LOG_FATAL, "fqueue_receive: Bad call"); -#endif - - /* If this is the only item on the receive queue, we do not want to - charge it for any time during which we have not been waiting for - anything, so update the receive timestamp. */ - if (qTreceive == NULL) - iTrecsecs = ixsysdep_process_time (&iTrecmicros); - - utdequeue (qtrans); - utqueue (&qTreceive, qtrans, FALSE); - - return TRUE; -} - -/* Get a new local channel number. */ - -static void -utchanalc (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ - do - { - ++iTchan; - if (iTchan > qdaemon->cchans) - iTchan = 1; - } - while (aqTchan[iTchan] != NULL); - - qtrans->ilocal = iTchan; - aqTchan[iTchan] = qtrans; - ++cTchans; -} - -/* Return the transfer for a channel number. */ - -__inline__ -static struct stransfer * -qtchan (ic) - int ic; -{ - return aqTchan[ic]; -} - -/* Clear the channel number for a transfer. */ - -__inline__ -static void -utchanfree (qt) - struct stransfer *qt; -{ - if (qt->ilocal != 0) - { - aqTchan[qt->ilocal] = NULL; - qt->ilocal = 0; - --cTchans; - } -} - -/* Allocate a new transfer structure. */ - -struct stransfer * -qtransalc (qcmd) - struct scmd *qcmd; -{ - register struct stransfer *q; - - q = qTavail; - if (q != NULL) - utdequeue (q); - else - q = (struct stransfer *) xmalloc (sizeof (struct stransfer)); - q->qnext = NULL; - q->qprev = NULL; - q->pqqueue = NULL; - q->psendfn = NULL; - q->precfn = NULL; - q->pinfo = NULL; - q->fsendfile = FALSE; - q->frecfile = FALSE; - q->e = EFILECLOSED; - q->ipos = 0; - q->fcmd = FALSE; - q->zcmd = NULL; - q->ccmd = 0; - q->ilocal = 0; - q->iremote = 0; - if (qcmd != NULL) - { - q->s = *qcmd; - q->s.zfrom = zbufcpy (qcmd->zfrom); - q->s.zto = zbufcpy (qcmd->zto); - q->s.zuser = zbufcpy (qcmd->zuser); - q->s.zoptions = zbufcpy (qcmd->zoptions); - q->s.ztemp = zbufcpy (qcmd->ztemp); - q->s.znotify = zbufcpy (qcmd->znotify); - q->s.zcmd = zbufcpy (qcmd->zcmd); - } - else - { - q->s.zfrom = NULL; - q->s.zto = NULL; - q->s.zuser = NULL; - q->s.zoptions = NULL; - q->s.ztemp = NULL; - q->s.znotify = NULL; - q->s.zcmd = NULL; - } - q->zlog = NULL; - q->isecs = 0; - q->imicros = 0; - q->cbytes = 0; - - return q; -} - -/* Free a transfer structure. This does not free any pinfo - information that may have been allocated. */ - -void -utransfree (q) - struct stransfer *q; -{ - ubuffree (q->zcmd); - ubuffree ((char *) q->s.zfrom); - ubuffree ((char *) q->s.zto); - ubuffree ((char *) q->s.zuser); - ubuffree ((char *) q->s.zoptions); - ubuffree ((char *) q->s.ztemp); - ubuffree ((char *) q->s.znotify); - ubuffree ((char *) q->s.zcmd); - - utchanfree (q); - if (q->iremote > 0) - { - aqTremote[q->iremote] = NULL; - q->iremote = 0; - } - -#if DEBUG > 0 - q->e = EFILECLOSED; - q->zcmd = NULL; - q->s.zfrom = NULL; - q->s.zto = NULL; - q->s.zuser = NULL; - q->s.zoptions = NULL; - q->s.ztemp = NULL; - q->s.znotify = NULL; - q->s.zcmd = NULL; - q->psendfn = NULL; - q->precfn = NULL; -#endif - - /* Avoid any possible confusion in the timing code. */ - if (qTtiming_rec == q) - qTtiming_rec = NULL; - - utdequeue (q); - utqueue (&qTavail, q, FALSE); -} - -/* Get the time. This is a wrapper around ixsysdep_process_time. If - enough time has elapsed since the last time we got the time, check - the work queue. */ - -static boolean -fttime (qdaemon, pisecs, pimicros) - struct sdaemon *qdaemon; - long *pisecs; - long *pimicros; -{ - *pisecs = ixsysdep_process_time (pimicros); - if (*pisecs - iTchecktime >= CCHECKWAIT) - { - if (! fcheck_queue (qdaemon)) - return FALSE; - } - return TRUE; -} - -/* Gather local commands and queue them up for later processing. Also - recompute time based control values. */ - -boolean -fqueue (qdaemon, pfany) - struct sdaemon *qdaemon; - boolean *pfany; -{ - const struct uuconf_system *qsys; - long ival; - int bgrade; - struct uuconf_timespan *qlocal_size, *qremote_size; - - if (pfany != NULL) - *pfany = FALSE; - - qsys = qdaemon->qsys; - - /* If we are not the caller, the grade will be set during the - initial handshake, although this may be overridden by the - calledtimegrade configuration option. */ - if (! qdaemon->fcaller) - { - if (! ftimespan_match (qsys->uuconf_qcalledtimegrade, &ival, - (int *) NULL)) - bgrade = qdaemon->bgrade; - else - bgrade = (char) ival; - } - else - { - if (! ftimespan_match (qsys->uuconf_qtimegrade, &ival, - (int *) NULL)) - bgrade = '\0'; - else - bgrade = (char) ival; - } - - /* Determine the maximum sizes we can send and receive. */ - if (qdaemon->fcaller) - { - qlocal_size = qsys->uuconf_qcall_local_size; - qremote_size = qsys->uuconf_qcall_remote_size; - } - else - { - qlocal_size = qsys->uuconf_qcalled_local_size; - qremote_size = qsys->uuconf_qcalled_remote_size; - } - - if (! ftimespan_match (qlocal_size, &qdaemon->clocal_size, (int *) NULL)) - qdaemon->clocal_size = (long) -1; - if (! ftimespan_match (qremote_size, &qdaemon->cremote_size, (int *) NULL)) - qdaemon->cremote_size = (long) -1; - - if (bgrade == '\0') - return TRUE; - - if (! fsysdep_get_work_init (qsys, bgrade)) - return FALSE; - - while (TRUE) - { - struct scmd s; - - if (! fsysdep_get_work (qsys, bgrade, &s)) - return FALSE; - - if (s.bcmd == 'H') - { - ulog_user ((const char *) NULL); - break; - } - - if (s.bcmd == 'P') - { - struct stransfer *qtrans; - - /* A poll file. */ - ulog_user ((const char *) NULL); - qtrans = qtransalc (&s); - qtrans->psendfn = flocal_poll_file; - if (! fqueue_local (qdaemon, qtrans)) - return FALSE; - continue; - } - - ulog_user (s.zuser); - - switch (s.bcmd) - { - case 'S': - case 'E': - if (! flocal_send_file_init (qdaemon, &s)) - return FALSE; - break; - case 'R': - if (! flocal_rec_file_init (qdaemon, &s)) - return FALSE; - break; - case 'X': - if (! flocal_xcmd_init (qdaemon, &s)) - return FALSE; - break; -#if DEBUG > 0 - default: - ulog (LOG_FATAL, "fqueue: Can't happen"); - break; -#endif - } - } - - if (pfany != NULL) - *pfany = qTlocal != NULL; - - iTchecktime = ixsysdep_process_time ((long *) NULL); - - return TRUE; -} - -/* Clear everything off the work queue. This is used when the call is - complete, or if the call is never made. */ - -void -uclear_queue (qdaemon) - struct sdaemon *qdaemon; -{ - int i; - - usysdep_get_work_free (qdaemon->qsys); - - qTlocal = NULL; - qTremote = NULL; - qTsend = NULL; - qTreceive = NULL; - cTchans = 0; - iTchan = 0; - qTtiming_rec = NULL; - cTcmdlen = 0; - qTreceive_ack = NULL; - for (i = 0; i < IMAX_CHAN + 1; i++) - { - aqTchan[i] = NULL; - aqTremote[i] = NULL; - } -} - -/* Recheck the work queue during a conversation. This is only called - if it's been more than CCHECKWAIT seconds since the last time the - queue was checked. */ - -static boolean -fcheck_queue (qdaemon) - struct sdaemon *qdaemon; -{ - /* Only check if we are the master, or if there are multiple - channels, or if we aren't already trying to get the other side to - hang up. Otherwise, there's nothing we can do with any new jobs - we might find. */ - if (qdaemon->fmaster - || qdaemon->cchans > 1 - || ! qdaemon->frequest_hangup) - { - boolean fany; - - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "fcheck_queue: Rechecking work queue"); - if (! fqueue (qdaemon, &fany)) - return FALSE; - - /* If we found something to do, and we're not the master, and we - don't have multiple channels to send new jobs over, try to - get the other side to hang up. */ - if (fany && ! qdaemon->fmaster && qdaemon->cchans <= 1) - qdaemon->frequest_hangup = TRUE; - } - - return TRUE; -} - -/* The main transfer loop. The uucico daemon spends essentially all - its time in this function. */ - -boolean -floop (qdaemon) - struct sdaemon *qdaemon; -{ - boolean fret; - - fret = TRUE; - - while (! qdaemon->fhangup) - { - register struct stransfer *q; - -#if DEBUG > 1 - /* If we're doing any debugging, close the log and debugging - files regularly. This will let people copy them off and - remove them while the conversation is in progresss. */ - if (iDebug != 0) - { - ulog_close (); - ustats_close (); - } -#endif - - if (qdaemon->fmaster) - { - boolean fhangup; - - /* We've managed to become the master, so we no longer want - to request a hangup. */ - qdaemon->frequest_hangup = FALSE; - - fhangup = FALSE; - - if (qdaemon->fhangup_requested - && qTsend == NULL) - { - /* The remote system has requested that we transfer - control by sending CYM after receiving a file. */ - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "floop: Transferring control at remote request"); - fhangup = TRUE; - } - else if (qTremote == NULL - && qTlocal == NULL - && qTsend == NULL - && qTreceive == NULL) - { - /* We don't have anything to do. Try to find some new - jobs. If we can't, transfer control. */ - if (! fqueue (qdaemon, (boolean *) NULL)) - { - fret = FALSE; - break; - } - if (qTlocal == NULL) - { - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, - "floop: No work for master"); - fhangup = TRUE; - } - } - - if (fhangup) - { - if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, "H", 0, 0)) - { - fret = FALSE; - break; - } - qdaemon->fmaster = FALSE; - } - } - - /* If we are no long the master, clear any requested hangup. We - may have already hung up before checking this variable in the - block above. */ - if (! qdaemon->fmaster) - qdaemon->fhangup_requested = FALSE; - - /* Immediately queue up any remote jobs. We don't need local - channel numbers for them, since we can disambiguate based on - the remote channel number. */ - while (qTremote != NULL) - { - q = qTremote; - utdequeue (q); - utqueue (&qTsend, q, TRUE); - } - - /* If we are the master, or if we have multiple channels, try to - queue up additional local jobs. */ - if (qdaemon->fmaster || qdaemon->cchans > 1) - { - while (qTlocal != NULL && cTchans < qdaemon->cchans) - { - /* We have room for an additional channel. */ - q = qTlocal; - if (! fqueue_send (qdaemon, q)) - { - fret = FALSE; - break; - } - utchanalc (qdaemon, q); - } - if (! fret) - break; - } - - q = qTsend; - - if (q == NULL) - { - ulog_user ((const char *) NULL); - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "floop: Waiting for data"); - if (! (*qdaemon->qproto->pfwait) (qdaemon)) - { - fret = FALSE; - break; - } - } - else - { - ulog_user (q->s.zuser); - - if (! q->fsendfile) - { - /* Technically, we should add the time required for this - call to q->isecs and q->imicros. In practice, the - amount of time required should be sufficiently small - that it can be safely disregarded. */ - if (! (*q->psendfn) (q, qdaemon)) - { - fret = FALSE; - break; - } - } - else - { - long isecs, imicros; - boolean fcharged; - long inextsecs = 0, inextmicros; - - if (! fttime (qdaemon, &isecs, &imicros)) - { - fret = FALSE; - break; - } - fcharged = FALSE; - - if (q->zlog != NULL) - { - ulog (LOG_NORMAL, "%s", q->zlog); - ubuffree (q->zlog); - q->zlog = NULL; - } - - /* We can read the file in a tight loop until we have a - command to send, or the file send has been cancelled, - or we have a remote job to deal with. We can - disregard any changes to qTlocal since we already - have something to send anyhow. */ - while (q == qTsend - && q->fsendfile - && qTremote == NULL) - { - char *zdata; - size_t cdata; - long ipos; - - zdata = (*qdaemon->qproto->pzgetspace) (qdaemon, &cdata); - if (zdata == NULL) - { - fret = FALSE; - break; - } - - if (ffileeof (q->e)) - cdata = 0; - else - { - cdata = cfileread (q->e, zdata, cdata); - if (ffileioerror (q->e, cdata)) - { - /* There is no way to report a file reading - error, so we just drop the connection. */ - ulog (LOG_ERROR, "read: %s", strerror (errno)); - fret = FALSE; - break; - } - } - - ipos = q->ipos; - q->ipos += cdata; - q->cbytes += cdata; - - if (! (*qdaemon->qproto->pfsenddata) (qdaemon, zdata, - cdata, q->ilocal, - q->iremote, ipos)) - { - fret = FALSE; - break; - } - - if (cdata == 0) - { - /* We must update the time now, because this - call may make an entry in the statistics - file. */ - inextsecs = ixsysdep_process_time (&inextmicros); - DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO, - "floop: Charging %ld to %c %s %s", - ((inextsecs - isecs) * 1000000 - + inextmicros - imicros), - q->s.bcmd, q->s.zfrom, q->s.zto); - q->isecs += inextsecs - isecs; - q->imicros += inextmicros - imicros; - fcharged = TRUE; - - q->fsendfile = FALSE; - - if (! (*q->psendfn) (q, qdaemon)) - fret = FALSE; - - break; - } - } - - if (! fret) - break; - - if (! fcharged) - { - inextsecs = ixsysdep_process_time (&inextmicros); - DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO, - "floop: Charging %ld to %c %s %s", - ((inextsecs - isecs) * 1000000 - + inextmicros - imicros), - q->s.bcmd, q->s.zfrom, q->s.zto); - q->isecs += inextsecs - isecs; - q->imicros += inextmicros - imicros; - } - - if (inextsecs - iTchecktime >= CCHECKWAIT) - { - if (! fcheck_queue (qdaemon)) - { - fret = FALSE; - break; - } - } - } - } - } - - ulog_user ((const char *) NULL); - - (void) (*qdaemon->qproto->pfshutdown) (qdaemon); - - if (fret) - uwindow_acked (qdaemon, TRUE); - else - ufailed (qdaemon); - - return fret; -} - -/* This is called by the protocol routines when they have received - some data. If pfexit is not NULL, *pfexit should be set to TRUE if - the protocol receive loop should exit back to the main floop - routine, above. It is only important to set *pfexit to TRUE if the - main loop called the pfwait entry point, so we need never set it to - TRUE if we just receive data for a file. This routine never sets - *pfexit to FALSE. */ - -boolean -fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos, - fallacked, pfexit) - struct sdaemon *qdaemon; - const char *zfirst; - size_t cfirst; - const char *zsecond; - size_t csecond; - int ilocal; - int iremote; - long ipos; - boolean fallacked; - boolean *pfexit; -{ - struct stransfer *q; - int cwrote; - boolean fret; - long isecs, imicros; - - if (fallacked && qTreceive_ack != NULL) - uwindow_acked (qdaemon, TRUE); - - /* Now we have to decide which transfer structure gets the data. If - ilocal is -1, it means that the protocol does not know where to - route the data. In that case we route it to the first transfer - that is waiting for data, or, if none, as a new command. If - ilocal is 0, we either select based on the remote channel number - or we have a new command. */ - if (ilocal == -1 && qTreceive != NULL) - q = qTreceive; - else if (ilocal == 0 && iremote > 0 && aqTremote[iremote] != NULL) - q = aqTremote[iremote]; - else if (ilocal <= 0) - { - const char *znull; - - ulog_user ((const char *) NULL); - - /* This data is part of a command. If there is no null - character in the data, this string will be continued by the - next packet. Otherwise this must be the last string in the - command, and we don't care about what comes after the null - byte. */ - znull = (const char *) memchr (zfirst, '\0', cfirst); - if (znull != NULL) - fret = ftadd_cmd (qdaemon, zfirst, (size_t) (znull - zfirst), - iremote, TRUE); - else - { - fret = ftadd_cmd (qdaemon, zfirst, cfirst, iremote, FALSE); - if (fret && csecond > 0) - { - znull = (const char *) memchr (zsecond, '\0', csecond); - if (znull != NULL) - fret = ftadd_cmd (qdaemon, zsecond, - (size_t) (znull - zsecond), iremote, TRUE); - else - fret = ftadd_cmd (qdaemon, zsecond, csecond, iremote, FALSE); - } - } - - if (pfexit != NULL && (qdaemon->fhangup || qTremote != NULL)) - *pfexit = TRUE; - - /* Time spent waiting for a new command is not charged to - anybody. */ - if (! fttime (qdaemon, &iTrecsecs, &iTrecmicros)) - fret = FALSE; - - return fret; - } - else - { - /* Get the transfer structure this data is intended for. */ - q = qtchan (ilocal); - } - -#if DEBUG > 0 - if (q == NULL || q->precfn == NULL) - { - ulog (LOG_ERROR, "Protocol error: %lu bytes remote %d local %d", - (unsigned long) (cfirst + csecond), - iremote, ilocal); - return FALSE; - } -#endif - - ulog_user (q->s.zuser); - - fret = TRUE; - - if (q->zlog != NULL && ! q->fsendfile) - { - ulog (LOG_NORMAL, "%s", q->zlog); - ubuffree (q->zlog); - q->zlog = NULL; - } - - if (cfirst == 0 || q->fcmd || ! q->frecfile || q != qTtiming_rec) - { - struct stransfer *qcharge; - - /* Either we are receiving some sort of command, or we are - receiving data for a transfer other than the one we are - currently timing. It we are currently timing a transfer, - charge any accumulated time to it. Otherwise, if we - currently have something to send, just forget about the - accumulated time (when using a bidirectional protocol, it's - very difficult to charge this time correctly). Otherwise, - charge it to whatever transfer receives it. */ - if (! fttime (qdaemon, &isecs, &imicros)) - fret = FALSE; - if (qTtiming_rec != NULL) - qcharge = qTtiming_rec; - else if (qTsend != NULL) - qcharge = NULL; - else - qcharge = q; - if (qcharge != NULL) - { - DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO, - "fgot_data: Charging %ld to %c %s %s", - ((isecs - iTrecsecs) * 1000000 - + imicros - iTrecmicros), - qcharge->s.bcmd, qcharge->s.zfrom, - qcharge->s.zto); - qcharge->isecs += isecs - iTrecsecs; - qcharge->imicros += imicros - iTrecmicros; - } - iTrecsecs = isecs; - iTrecmicros = imicros; - - /* If we received file data, start timing the new transfer. */ - if (cfirst == 0 || q->fcmd || ! q->frecfile) - qTtiming_rec = NULL; - else - qTtiming_rec = q; - } - - /* If we're receiving a command, then accumulate it up to the null - byte. */ - if (q->fcmd) - { - const char *znull; - - znull = NULL; - while (cfirst > 0) - { - size_t cnew; - char *znew; - - znull = (const char *) memchr (zfirst, '\0', cfirst); - if (znull != NULL) - cnew = znull - zfirst; - else - cnew = cfirst; - znew = zbufalc (q->ccmd + cnew + 1); - if (q->ccmd > 0) - memcpy (znew, q->zcmd, q->ccmd); - memcpy (znew + q->ccmd, zfirst, cnew); - znew[q->ccmd + cnew] = '\0'; - ubuffree (q->zcmd); - q->zcmd = znew; - q->ccmd += cnew; - - if (znull != NULL) - break; - - zfirst = zsecond; - cfirst = csecond; - csecond = 0; - } - - if (znull != NULL) - { - char *zcmd; - size_t ccmd; - - zcmd = q->zcmd; - ccmd = q->ccmd; - q->fcmd = FALSE; - q->zcmd = NULL; - q->ccmd = 0; - if (! (*q->precfn) (q, qdaemon, zcmd, ccmd + 1)) - fret = FALSE; - ubuffree (zcmd); - } - - if (pfexit != NULL - && (qdaemon->fhangup - || qdaemon->fmaster - || qTsend != NULL)) - *pfexit = TRUE; - } - else if (! q->frecfile || cfirst == 0) - { - /* We're either not receiving a file or the file transfer is - complete. */ - q->frecfile = FALSE; - if (! (*q->precfn) (q, qdaemon, zfirst, cfirst)) - fret = FALSE; - if (fret && csecond > 0) - return fgot_data (qdaemon, zsecond, csecond, - (const char *) NULL, (size_t) 0, - ilocal, iremote, ipos + (long) cfirst, - FALSE, pfexit); - if (pfexit != NULL - && (qdaemon->fhangup - || qdaemon->fmaster - || qTsend != NULL)) - *pfexit = TRUE; - } - else - { - if (ipos != -1 && ipos != q->ipos) - { - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, - "fgot_data: Seeking to %ld", ipos); - if (! ffileseek (q->e, ipos)) - { - ulog (LOG_ERROR, "seek: %s", strerror (errno)); - fret = FALSE; - } - q->ipos = ipos; - } - - if (fret) - { - while (cfirst > 0) - { - cwrote = cfilewrite (q->e, (char *) zfirst, cfirst); - if (cwrote == cfirst) - { -#if FREE_SPACE_DELTA > 0 - long cfree_space; - - /* Check that there is still enough space on the - disk. If there isn't, we drop the connection, - because we have no way to abort a file transfer - in progress. */ - cfree_space = qdaemon->qsys->uuconf_cfree_space; - if (cfree_space > 0 - && ((q->cbytes / FREE_SPACE_DELTA) - != (q->cbytes + cfirst) / FREE_SPACE_DELTA) - && ! frec_check_free (q, cfree_space)) - { - fret = FALSE; - break; - } -#endif - q->cbytes += cfirst; - q->ipos += cfirst; - } - else - { - if (ffileioerror (q->e, cwrote)) - ulog (LOG_ERROR, "write: %s", strerror (errno)); - else - ulog (LOG_ERROR, - "Wrote %d to file when trying to write %lu", - cwrote, (unsigned long) cfirst); - - /* Any write error is almost certainly a temporary - condition, or else UUCP would not be functioning - at all. If we continue to accept the file, we - will wind up rejecting it at the end (what else - could we do?) and the remote system will throw - away the request. We're better off just dropping - the connection, which is what happens when we - return FALSE, and trying again later. */ - fret = FALSE; - break; - } - - zfirst = zsecond; - cfirst = csecond; - csecond = 0; - } - } - - if (pfexit != NULL && qdaemon->fhangup) - *pfexit = TRUE; - } - - return fret; -} - -/* Accumulate a string into a command. If the command is complete, - start up a new transfer. */ - -static boolean -ftadd_cmd (qdaemon, z, clen, iremote, flast) - struct sdaemon *qdaemon; - const char *z; - size_t clen; - int iremote; - boolean flast; -{ - static char *zbuf; - static size_t cbuf; - size_t cneed; - struct scmd s; - - cneed = cTcmdlen + clen + 1; - if (cneed > cbuf) - { - zbuf = (char *) xrealloc ((pointer) zbuf, cneed); - cbuf = cneed; - } - - memcpy (zbuf + cTcmdlen, z, clen); - zbuf[cTcmdlen + clen] = '\0'; - - if (! flast) - { - cTcmdlen += clen; - return TRUE; - } - - /* Don't save this string for next time. */ - cTcmdlen = 0; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, - "ftadd_cmd: Got command \"%s\"", zbuf); - - if (! fparse_cmd (zbuf, &s) - || s.bcmd == 'P') - { - ulog (LOG_ERROR, "Received garbled command \"%s\"", zbuf); - return TRUE; - } - - /* Some systems seem to sometimes send garbage at the end of the - command. Avoid interpreting it as a size if sizes are not - supported. */ - if ((qdaemon->ifeatures & FEATURE_SIZES) == 0) - s.cbytes = -1; - - if (s.bcmd != 'H' && s.bcmd != 'Y' && s.bcmd != 'N') - ulog_user (s.zuser); - else - ulog_user ((const char *) NULL); - - switch (s.bcmd) - { - case 'S': - case 'E': - return fremote_send_file_init (qdaemon, &s, iremote); - case 'R': - return fremote_rec_file_init (qdaemon, &s, iremote); - case 'X': - return fremote_xcmd_init (qdaemon, &s, iremote); - case 'H': - /* This is a remote request for a hangup. We close the log - files so that they may be moved at this point. */ - ulog_close (); - ustats_close (); - { - struct stransfer *q; - - q = qtransalc ((struct scmd *) NULL); - q->psendfn = fremote_hangup_reply; - q->iremote = iremote; - q->s.bcmd = 'H'; - return fqueue_remote (qdaemon, q); - } - case 'N': - /* This means a hangup request is being denied; we just ignore - this and wait for further commands. */ - return TRUE; - case 'Y': - /* This is a remote confirmation of a hangup. We reconfirm. */ - if (qdaemon->fhangup) - return TRUE; -#if DEBUG > 0 - if (qdaemon->fmaster) - ulog (LOG_ERROR, "Got hangup reply as master"); -#endif - /* Don't check errors rigorously here, since the other side - might jump the gun and hang up. The fLog_sighup variable - will get set TRUE again when the port is closed. */ - fLog_sighup = FALSE; - (void) (*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, iremote); - qdaemon->fhangup = TRUE; - return TRUE; -#if DEBUG > 0 - default: - ulog (LOG_FATAL, "ftadd_cmd: Can't happen"); - return FALSE; -#endif - } -} - -/* The remote system is requesting a hang up. If we have something to - do, send an HN. Otherwise send two HY commands (the other side is - presumed to send an HY command between the first and second, but we - don't bother to wait for it) and hang up. */ - -static boolean -fremote_hangup_reply (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - boolean fret; - - utransfree (qtrans); - - if (qTremote == NULL - && qTlocal == NULL - && qTsend == NULL - && qTreceive == NULL) - { - if (! fqueue (qdaemon, (boolean *) NULL)) - return FALSE; - - if (qTlocal == NULL) - { - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fremote_hangup_reply: No work"); - fret = ((*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, 0) - && (*qdaemon->qproto->pfsendcmd) (qdaemon, "HY", 0, 0)); - qdaemon->fhangup = TRUE; - return fret; - } - } - - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fremote_hangup_reply: Found work"); - fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, "HN", 0, 0); - qdaemon->fmaster = TRUE; - return fret; -} - -/* As described in system.h, we need to keep track of which files have - been successfully received for which we do not know that the other - system has received our acknowledgement. This routine is called to - keep a list of such files. */ - -static struct sreceive_ack *qTfree_receive_ack; - -void -usent_receive_ack (qdaemon, qtrans) - struct sdaemon *qdaemon; - struct stransfer *qtrans; -{ - struct sreceive_ack *q; - - if (qTfree_receive_ack == NULL) - q = (struct sreceive_ack *) xmalloc (sizeof (struct sreceive_ack)); - else - { - q = qTfree_receive_ack; - qTfree_receive_ack = q->qnext; - } - - q->qnext = qTreceive_ack; - q->zto = zbufcpy (qtrans->s.zto); - q->ztemp = zbufcpy (qtrans->s.ztemp); - q->fmarked = FALSE; - - qTreceive_ack = q; -} - -/* This routine is called by the protocol code when either all - outstanding data has been acknowledged or one complete window has - passed. It may be called directly by the protocol, or it may be - called via fgot_data. If one complete window has passed, then all - unmarked receives are marked, and we know that all marked ones have - been acked. */ - -void -uwindow_acked (qdaemon, fallacked) - struct sdaemon *qdaemon; - boolean fallacked; -{ - register struct sreceive_ack **pq; - - pq = &qTreceive_ack; - while (*pq != NULL) - { - if (fallacked || (*pq)->fmarked) - { - struct sreceive_ack *q; - - q = *pq; - (void) fsysdep_forget_reception (qdaemon->qsys, q->zto, - q->ztemp); - ubuffree (q->zto); - ubuffree (q->ztemp); - *pq = q->qnext; - q->qnext = qTfree_receive_ack; - qTfree_receive_ack = q; - } - else - { - (*pq)->fmarked = TRUE; - pq = &(*pq)->qnext; - } - } -} - -/* This routine is called when an error occurred and we are crashing - out of the connection. It is used to report statistics on failed - transfers to the statistics file, and it also discards useless - temporary files for file receptions. Note that the number of bytes - we report as having been sent has little or nothing to do with the - number of bytes the remote site actually received. */ - -void -ufailed (qdaemon) - struct sdaemon *qdaemon; -{ - register struct stransfer *q; - - if (qTsend != NULL) - { - q = qTsend; - do - { - if ((q->fsendfile || q->frecfile) - && q->cbytes > 0) - { - ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname, - q->fsendfile, q->cbytes, q->isecs, q->imicros, - qdaemon->fcaller); - if (q->fsendfile) - qdaemon->csent += q->cbytes; - else - qdaemon->creceived += q->cbytes; - } - if (q->frecfile) - (void) frec_discard_temp (qdaemon, q); - q = q->qnext; - } - while (q != qTsend); - } - - if (qTreceive != NULL) - { - q = qTreceive; - do - { - if ((q->fsendfile || q->frecfile) - && q->cbytes > 0) - { - ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname, - q->fsendfile, q->cbytes, q->isecs, q->imicros, - qdaemon->fcaller); - if (q->fsendfile) - qdaemon->csent += q->cbytes; - else - qdaemon->creceived += q->cbytes; - } - if (q->frecfile) - (void) frec_discard_temp (qdaemon, q); - q = q->qnext; - } - while (q != qTreceive); - } -} - -/* When a local poll file is found, it is entered on the queue like - any other job. When it is pulled off the queue, this function is - called. It just calls fsysdep_did_work, which will remove the poll - file. This ensures that poll files are only removed if the system - is actually called. */ - -/*ARGSUSED*/ -static boolean -flocal_poll_file (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - boolean fret; - - fret = fsysdep_did_work (qtrans->s.pseq); - utransfree (qtrans); - return fret; -} diff --git a/gnu/libexec/uucp/uucico/uucico.8 b/gnu/libexec/uucp/uucico/uucico.8 deleted file mode 100644 index a87bc7a..0000000 --- a/gnu/libexec/uucp/uucico/uucico.8 +++ /dev/null @@ -1,292 +0,0 @@ -.\" $Id: uucico.8,v 1.18 1995/06/26 22:36:09 ian Rel $ -.\" $FreeBSD$ -.TH uucico 8 "Taylor UUCP 1.06" -.SH NAME -uucico \- UUCP file transfer daemon -.SH SYNOPSIS -.B uucico -[ options ] -.SH DESCRIPTION -The -.I uucico -daemon processes file transfer requests queued by -.I uucp -(1) and -.I uux -(1). It is started when -.I uucp -or -.I uux -is run (unless they are given the -.B \-r -option). It is also typically started periodically using -entries in the -.I crontab -table(s). - -When invoked with -.B \-r1, -.B \-\-master, -.B \-s, -.B \-\-system, -or -.B \-S, -the daemon will place a call to a remote system, running in master -mode. Otherwise the daemon will start in slave mode, accepting a call -from a remote system. Typically a special login name will be set up -for UUCP which automatically invokes -.I uucico -when a call is made. - -When -.I uucico -terminates, it invokes the -.I uuxqt -(8) daemon, unless the -.B \-q -or -.B \-\-nouuxqt -option is given; -.I uuxqt -(8) executes any work orders created by -.I uux -(1) on a remote system, and any work orders created locally which have -received remote files for which they were waiting. - -If a call fails, -.I uucico -will normally refuse to retry the -call until a certain (configurable) amount of time -has passed. This may be overriden by the -.B -f, -.B --force, -or -.B -S -option. - -The -.B \-l, -.B \-\-prompt, -.B \-e, -or -.B \-\-loop -options may be used to force -.I uucico -to produce its own prompts of "login: " and "Password:". When another -daemon calls in, it will see these prompts and log in as usual. The -login name and password will normally be checked against a separate -list kept specially for -.I uucico -rather than the -.I /etc/passwd -file; it is possible on some systems to direct -.I uucico -to use the -.I /etc/passwd -file. The -.B \-l -or -.B \--prompt -option will prompt once and then exit; in this mode the UUCP -administrator or the superuser may use the -.B \-u -or -.B \--login -option to force a login name, in which case -.I uucico -will not prompt for one. -The -.B \-e -or -.B \--loop -option will prompt again after the first session is over; in this mode -.I uucico -will permanently control a port. - -If -.I uucico -receives a SIGQUIT, SIGTERM or SIGPIPE signal, it will cleanly abort -any current conversation with a remote system and exit. If it -receives a SIGHUP signal it will abort any current conversation, but -will continue to place calls to (if invoked with -.B \-r1 -or -.B \-\-master) -and accept calls from (if invoked with -.B \-e -or -.B \-\-loop) -other systems. If it receives a -SIGINT signal it will finish the current conversation, but will not -place or accept any more calls. -.SH OPTIONS -The following options may be given to -.I uucico. -.TP 5 -.B \-r1, \-\-master -Start in master mode (call out to a system); implied by -.B \-s, -.B \-\-system, -or -.B \-S. -If no system is specified, call any system for which work is waiting -to be done. -.TP 5 -.B \-r0, \-\-slave -Start in slave mode. This is the default. -.TP 5 -.B \-s system, \-\-system system -Call the named system. -.TP 5 -.B \-S system -Call the named system, ignoring any required wait. This is equivalent -to -.B \-s system \-f. -.TP 5 -.B \-f, \-\-force -Ignore any required wait for any systems to be called. -.TP 5 -.B \-l, \-\-prompt -Prompt for login name and password using "login: " and "Password:". -This allows -.I uucico -to be easily run from -.I inetd -(8). The login name and password are checked against the UUCP -password file, which probably has no connection to the file -.I /etc/passwd. -The -.B \-\-login -option may be used to force a login name, in which cause -.I uucico -will only prompt for a password. -.TP 5 -.B \-p port, \-\-port port -Specify a port to call out on or to listen to. -.TP 5 -.B \-e, \-\-loop -Enter endless loop of login/password prompts and slave mode daemon -execution. The program will not stop by itself; you must use -.I kill -(1) to shut it down. -.TP 5 -.B \-w, \-\-wait -After calling out (to a particular system when -.B \-s, -.B \-\-system, -or -.B \-S -is specifed, or to all systems which have work when just -.B \-r1 -or -.B \-\-master -is specifed), begin an endless loop as with -.B \-\-loop. -.TP 5 -.B \-q, \-\-nouuxqt -Do not start the -.I uuxqt -(8) daemon when finished. -.TP 5 -.B \-c, \-\-quiet -If no calls are permitted at this time, then don't make the call, but -also do not put an error message in the log file and do not update the -system status (as reported by -.I uustat -(1)). This can be convenient for automated polling scripts, which may -want to simply attempt to call every system rather than worry about -which particular systems may be called at the moment. This option -also suppresses the log message indicating that there is no work to be -done. -.TP 5 -.B \-C, \-\-ifwork -Only call the system named by -.B \-s, -.B \-\-system -or -.B \-S -if there is work for that system. -.TP 5 -.B \-D, \-\-nodetach -Do not detach from the controlling terminal. Normally -.I uucico -detaches from the terminal before each call out to another system and -before invoking -.I uuxqt. -This option prevents this. -.TP 5 -.B \-u name, \-\-login name -Set the login name to use instead of that of the invoking user. This -option may only be used by the UUCP administrator or the superuser. -If used with -.B \-\-prompt, -this will cause -.I uucico -to prompt only for the password, not the login name. -.TP 5 -.B \-z, \-\-try-next -If a call fails after the remote system is reached, try the next -alternate rather than simply exiting. -.TP 5 -.B \-i type, \-\-stdin type -Set the type of port to use when using standard input. The only -support port type is TLI, and this is only available on machines which -support the TLI networking interface. Specifying -.B \-iTLI -causes -.I uucico -to use TLI calls to perform I/O. -.TP 5 -.B \-x type, \-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. - -Multiple types may be given, separated by commas, and the -.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 \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. - -The debugging output is sent to the debugging file, usually one of -/var/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or -/usr/spool/uucp/.Admin/audit.local. -.TP 5 -.B \-I file, \-\-config file -Set configuration file to use. This option may not be available, -depending upon how -.I uucico -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/etc/uucp/config - Configuration file. -.br -/etc/uucp/passwd - Default UUCP password file. -.br -/var/spool/uucp - -UUCP spool directory. -.br -/var/spool/uucp/Log - -UUCP log file. -.br -/var/spool/uucppublic - -Default UUCP public directory. -.br -/var/spool/uucp/Debug - -Debugging file. -.SH SEE ALSO -kill(1), uucp(1), uux(1), uustat(1), uuxqt(8) -.SH AUTHOR -Ian Lance Taylor -<ian@airs.com> diff --git a/gnu/libexec/uucp/uucico/uucico.c b/gnu/libexec/uucp/uucico/uucico.c deleted file mode 100644 index 63b7116..0000000 --- a/gnu/libexec/uucp/uucico/uucico.c +++ /dev/null @@ -1,3074 +0,0 @@ -/* uucico.c - This is the main UUCP communication program. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uucico_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> - -#if HAVE_LIMITS_H -#include <limits.h> -#else -#define LONG_MAX 2147483647L -#endif - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "conn.h" -#include "prot.h" -#include "trans.h" -#include "system.h" - -#if HAVE_ENCRYPTED_PASSWORDS -#ifndef crypt -extern char *crypt (); -#endif -#endif - -/* Coherent already had a different meaning for the -c option. What a - pain. */ -#ifdef __COHERENT__ -#define COHERENT_C_OPTION 1 -#else -#define COHERENT_C_OPTION 0 -#endif - -/* Define the known protocols. */ - -#define TCP_PROTO \ - (UUCONF_RELIABLE_ENDTOEND \ - | UUCONF_RELIABLE_RELIABLE \ - | UUCONF_RELIABLE_EIGHT) - -static const struct sprotocol asProtocols[] = -{ - { 't', TCP_PROTO, 1, TRUE, - asTproto_params, ftstart, ftshutdown, ftsendcmd, ztgetspace, - ftsenddata, ftwait, ftfile }, - { 'e', TCP_PROTO, 1, TRUE, - asEproto_params, festart, feshutdown, fesendcmd, zegetspace, - fesenddata, fewait, fefile }, - { 'i', UUCONF_RELIABLE_EIGHT, 7, TRUE, - asIproto_params, fistart, fishutdown, fisendcmd, zigetspace, - fisenddata, fiwait, NULL }, - { 'a', UUCONF_RELIABLE_EIGHT, 1, TRUE, - asZproto_params, fzstart, fzshutdown, fzsendcmd, zzgetspace, - fzsenddata, fzwait, fzfile }, - { 'g', UUCONF_RELIABLE_EIGHT, 1, TRUE, - asGproto_params, fgstart, fgshutdown, fgsendcmd, zggetspace, - fgsenddata, fgwait, NULL }, - { 'G', UUCONF_RELIABLE_EIGHT, 1, TRUE, - asGproto_params, fbiggstart, fgshutdown, fgsendcmd, zggetspace, - fgsenddata, fgwait, NULL }, - { 'j', UUCONF_RELIABLE_EIGHT, 7, TRUE, - asIproto_params, fjstart, fjshutdown, fisendcmd, zigetspace, - fisenddata, fiwait, NULL }, - { 'f', UUCONF_RELIABLE_RELIABLE, 1, FALSE, - asFproto_params, ffstart, ffshutdown, ffsendcmd, zfgetspace, - ffsenddata, ffwait, fffile }, - { 'v', UUCONF_RELIABLE_EIGHT, 1, TRUE, - asGproto_params, fvstart, fgshutdown, fgsendcmd, zggetspace, - fgsenddata, fgwait, NULL }, - { 'y', UUCONF_RELIABLE_RELIABLE | UUCONF_RELIABLE_EIGHT, 1, TRUE, - asYproto_params, fystart, fyshutdown, fysendcmd, zygetspace, - fysenddata, fywait, fyfile } -}; - -#define CPROTOCOLS (sizeof asProtocols / sizeof asProtocols[0]) - -/* Locked system. */ -static boolean fLocked_system; -static struct uuconf_system sLocked_system; - -/* Daemon structure holding information about the remote system (must - be global so the error handler can see it. */ -static struct sdaemon sDaemon; - -/* Open connection. */ -static struct sconnection *qConn; - -/* uuconf global pointer; need to close the connection after a fatal - error. */ -static pointer pUuconf; - -/* This structure is passed to iuport_lock via uuconf_find_port. */ -struct spass -{ - boolean fmatched; - boolean flocked; - struct sconnection *qconn; -}; - -/* Local functions. */ - -static void uusage P((void)); -static void uhelp P((void)); -static void uabort P((void)); -static boolean fcall P((pointer puuconf, const char *zconfig, boolean fuuxqt, - const struct uuconf_system *qsys, - struct uuconf_port *qport, boolean fifwork, - boolean fforce, boolean fdetach, - boolean fquiet, boolean ftrynext)); -static boolean fconn_call P((struct sdaemon *qdaemon, - struct uuconf_port *qport, - struct sstatus *qstat, int cretry, - boolean *pfcalled)); -static boolean fdo_call P((struct sdaemon *qdaemon, - struct sstatus *qstat, - const struct uuconf_dialer *qdialer, - boolean *pfcalled, enum tstatus_type *pterr)); -static int iuport_lock P((struct uuconf_port *qport, pointer pinfo)); -static boolean flogin_prompt P((pointer puuconf, const char *zconfig, - boolean fuuxqt, struct sconnection *qconn, - const char *zlogin, const char **pzsystem)); -static int icallin_cmp P((int iwhich, pointer pinfo, const char *zfile)); -static boolean faccept_call P((pointer puuconf, const char *zconfig, - boolean fuuxqt, const char *zlogin, - struct sconnection *qconn, - const char **pzsystem)); -static void uaccept_call_cleanup P((pointer puuconf, - struct uuconf_system *qfreesys, - struct uuconf_port *qport, - struct uuconf_port *qfreeport, - char *zloc)); -static void uapply_proto_params P((pointer puuconf, int bproto, - struct uuconf_cmdtab *qcmds, - struct uuconf_proto_param *pas)); -static boolean fsend_uucp_cmd P((struct sconnection *qconn, - const char *z)); -static char *zget_uucp_cmd P((struct sconnection *qconn, - boolean frequired, boolean fstrip)); -static char *zget_typed_line P((struct sconnection *qconn, - boolean fstrip)); - -/* Long getopt options. */ -static const struct option asLongopts[] = -{ - { "quiet", no_argument, NULL, 2 }, - { "ifwork", no_argument, NULL, 'C' }, - { "nodetach", no_argument, NULL, 'D' }, - { "loop", no_argument, NULL, 'e' }, - { "force", no_argument, NULL, 'f'}, - { "stdin", required_argument, NULL, 'i' }, - { "prompt", no_argument, NULL, 'l' }, - { "port", required_argument, NULL, 'p' }, - { "nouuxqt", no_argument, NULL, 'q' }, - { "master", no_argument, NULL, 3 }, - { "slave", no_argument, NULL, 4 }, - { "system", required_argument, NULL, 's' }, - { "login", required_argument, NULL, 'u' }, - { "wait", no_argument, NULL, 'w' }, - { "try-next", no_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) - int argc; - char **argv; -{ - /* -c: Whether to be quiet. */ - boolean fquiet = FALSE; - /* -C: Only call the system if there is work. */ - boolean fifwork = FALSE; - /* -D: don't detach from controlling terminal. */ - boolean fdetach = TRUE; - /* -e: Whether to do an endless loop of accepting calls. */ - boolean fendless = FALSE; - /* -f: Whether to force a call despite status of previous call. */ - boolean fforce = FALSE; - /* -i type: type of port to use for stdin. */ - enum uuconf_porttype tstdintype = UUCONF_PORTTYPE_STDIN; - /* -I file: configuration file name. */ - const char *zconfig = NULL; - /* -l: Whether to give a single login prompt. */ - boolean flogin = FALSE; - /* -P port: port to use; in master mode, call out on this port. In - slave mode, accept logins on this port. If port not specified, - then in master mode figure it out for each system, and in slave - mode use stdin and stdout. */ - const char *zport = NULL; - /* -q: Whether to start uuxqt when done. */ - boolean fuuxqt = TRUE; - /* -r1: Whether we are the master. */ - boolean fmaster = FALSE; - /* -s,-S system: system to call. */ - const char *zsystem = NULL; - /* -u: Login name to use. */ - const char *zlogin = NULL; - /* -w: Whether to wait for a call after doing one. */ - boolean fwait = FALSE; - /* -z: Try next alternate if call fails. */ - boolean ftrynext = FALSE; - const char *zopts; - int iopt; - struct uuconf_port *qport; - struct uuconf_port sport; - boolean fret = TRUE; - pointer puuconf; - int iuuconf; -#if DEBUG > 1 - int iholddebug; -#endif - - zProgram = argv[0]; - - /* When uucico is invoked by login, the first character of the - program will be a dash. We don't want that. */ - if (*zProgram == '-') - ++zProgram; - -#if COHERENT_C_OPTION - zopts = "c:CDefi:I:lp:qr:s:S:u:x:X:vwz"; -#else - zopts = "cCDefi:I:lp:qr:s:S:u:x:X:vwz"; -#endif - - while ((iopt = getopt_long (argc, argv, zopts, - asLongopts, (int *) NULL)) != EOF) - { -#if COHERENT_C_OPTION - if (iopt == 'c') - { - iopt = 's'; - fifwork = TRUE; - } -#endif - switch (iopt) - { - case 2: - case 'c': - /* Don't warn if a call is attempted at a bad time, and - don't print the "No work" message. */ - fquiet = TRUE; - break; - - case 'C': - fifwork = TRUE; - break; - - case 'D': - /* Don't detach from controlling terminal. */ - fdetach = FALSE; - break; - - case 'e': - /* Do an endless loop of accepting calls. */ - fendless = TRUE; - break; - - case 'f': - /* Force a call even if it hasn't been long enough since the last - failed call. */ - fforce = TRUE; - break; - - case 'i': - /* Type of port to use for standard input. Only TLI is - supported here, and only if HAVE_TLI is true. This - permits the Network Listener to tell uucico to use TLI - I/O calls. */ - if (strcasecmp (optarg, "tli") != 0) - fprintf (stderr, "%s: unsupported port type \"%s\"\n", - zProgram, optarg); - else - { -#if HAVE_TLI - tstdintype = UUCONF_PORTTYPE_TLI; -#else - fprintf (stderr, "%s: not compiled with TLI support\n", - zProgram); -#endif - } - break; - - case 'l': - /* Prompt for login name and password. */ - flogin = TRUE; - break; - - case 'p': - /* Port to use */ - zport = optarg; - break; - - case 'q': - /* Don't start uuxqt. */ - fuuxqt = FALSE; - break; - - case 'r': - /* Set mode: -r1 for master, -r0 for slave (default) */ - if (strcmp (optarg, "1") == 0) - fmaster = TRUE; - else if (strcmp (optarg, "0") == 0) - fmaster = FALSE; - else - uusage (); - break; - - case 's': - /* Set system name */ - zsystem = optarg; - fmaster = TRUE; - break; - - case 'S': - /* Set system name and force call like -f */ - zsystem = optarg; - fforce = TRUE; - fmaster = TRUE; - break; - - case 'u': - /* Some versions of uucpd invoke uucico with a -u argument - specifying the login name. If invoked by a privileged - user, we use it instead of the result of - zsysdep_login_name. */ - if (fsysdep_privileged ()) - zlogin = optarg; - else - fprintf (stderr, - "%s: ignoring command line login name: not a privileged user\n", - zProgram); - break; - - case 'w': - /* Call out and then wait for a call in */ - fwait = TRUE; - break; - - case 'z': - /* Try next alternate if call fails. */ - ftrynext = TRUE; - break; - - case 'I': - /* Set configuration file name (default is in sysdep.h). */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'x': - case 'X': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 4: - /* --slave. */ - fmaster = FALSE; - break; - - case 3: - /* --master. */ - fmaster = TRUE; - break; - - case 1: - /* --help. */ - uhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found, and flag value set. */ - break; - - default: - uusage (); - /*NOTREACHED*/ - } - } - - if (optind != argc) - uusage (); - - if (fwait && zport == NULL) - { - fprintf (stderr, "%s: -w requires -p", zProgram); - uusage (); - } - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - pUuconf = puuconf; - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - /* If a port was named, get its information. */ - if (zport == NULL) - qport = NULL; - else - { - iuuconf = uuconf_find_port (puuconf, zport, (long) 0, (long) 0, - (int (*) P((struct uuconf_port *, - pointer))) NULL, - (pointer) NULL, &sport); - if (iuuconf == UUCONF_NOT_FOUND) - ulog (LOG_FATAL, "%s: port not found", zport); - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - qport = &sport; - } - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (puuconf, INIT_SUID); - - ulog_to_file (puuconf, TRUE); - ulog_fatal_fn (uabort); - - if (fmaster) - { - if (zsystem != NULL) - { - /* A system was named. Call it. */ - iuuconf = uuconf_system_info (puuconf, zsystem, - &sLocked_system); - if (iuuconf == UUCONF_NOT_FOUND) - ulog (LOG_FATAL, "%s: System not found", zsystem); - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - /* Detach from the controlling terminal for the call. This - probably makes sense only on Unix. We want the modem - line to become the controlling terminal. */ - if (fdetach && - (qport == NULL - || qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN)) - usysdep_detach (); - - ulog_system (sLocked_system.uuconf_zname); - -#if DEBUG > 1 - iholddebug = iDebug; - if (sLocked_system.uuconf_zdebug != NULL) - iDebug |= idebug_parse (sLocked_system.uuconf_zdebug); -#endif - - if (! fsysdep_lock_system (&sLocked_system)) - { - ulog (LOG_ERROR, "System already locked"); - fret = FALSE; - } - else - { - fLocked_system = TRUE; - fret = fcall (puuconf, zconfig, fuuxqt, &sLocked_system, qport, - fifwork, fforce, fdetach, fquiet, ftrynext); - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - } -#if DEBUG > 1 - iDebug = iholddebug; -#endif - ulog_system ((const char *) NULL); - (void) uuconf_system_free (puuconf, &sLocked_system); - } - else - { - char **pznames, **pz; - int c, i; - boolean fdidone; - - /* Call all systems which have work to do. */ - fret = TRUE; - fdidone = FALSE; - - iuuconf = uuconf_system_names (puuconf, &pznames, 0); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - /* Randomize the order in which we call the systems. */ - c = 0; - for (pz = pznames; *pz != NULL; pz++) - c++; - - srand ((unsigned int) ixsysdep_time ((long *) NULL)); - for (i = c - 1; i > 0; i--) - { - int iuse; - char *zhold; - - iuse = rand () % (i + 1); - zhold = pznames[i]; - pznames[i] = pznames[iuse]; - pznames[iuse] = zhold; - } - - for (pz = pznames; *pz != NULL && ! FGOT_SIGNAL (); pz++) - { - iuuconf = uuconf_system_info (puuconf, *pz, - &sLocked_system); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - xfree ((pointer) *pz); - continue; - } - - if (fsysdep_has_work (&sLocked_system)) - { - fdidone = TRUE; - - /* Detach from the controlling terminal. On Unix - this means that we will wind up forking a new - process for each system we call. */ - if (fdetach - && (qport == NULL - || qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN)) - usysdep_detach (); - - ulog_system (sLocked_system.uuconf_zname); - -#if DEBUG > 1 - iholddebug = iDebug; - if (sLocked_system.uuconf_zdebug != NULL) - iDebug |= idebug_parse (sLocked_system.uuconf_zdebug); -#endif - - if (! fsysdep_lock_system (&sLocked_system)) - { - ulog (LOG_ERROR, "System already locked"); - fret = FALSE; - } - else - { - fLocked_system = TRUE; - if (! fcall (puuconf, zconfig, fuuxqt, &sLocked_system, - qport, TRUE, fforce, fdetach, fquiet, - ftrynext)) - fret = FALSE; - - /* Now ignore any SIGHUP that we got. */ - afSignal[INDEXSIG_SIGHUP] = FALSE; - - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - } -#if DEBUG > 1 - iDebug = iholddebug; -#endif - ulog_system ((const char *) NULL); - } - - (void) uuconf_system_free (puuconf, &sLocked_system); - xfree ((pointer) *pz); - } - - xfree ((pointer) pznames); - - if (! fdidone && ! fquiet) - ulog (LOG_NORMAL, "No work"); - } - - /* If requested, wait for calls after dialing out. */ - if (fwait) - { - fendless = TRUE; - fmaster = FALSE; - } - } - - if (! fmaster) - { - struct sconnection sconn; - boolean flocked; - - /* If a port was specified by name, we go into endless loop - mode. In this mode, we wait for calls and prompt them with - "login:" and "Password:", so that they think we are a regular - UNIX system. If we aren't in endless loop mode, we have been - called by some other system. If flogin is TRUE, we prompt - with "login:" and "Password:" a single time. */ - - fret = TRUE; - zsystem = NULL; - - if (! fconn_init (qport, &sconn, tstdintype)) - fret = FALSE; - - if (qport != NULL) - { - /* We are not using standard input. Detach from the - controlling terminal, so that the port we are about to - use becomes our controlling terminal. */ - if (fdetach - && qport->uuconf_ttype != UUCONF_PORTTYPE_STDIN) - usysdep_detach (); - } - - if (fconn_lock (&sconn, TRUE)) - flocked = TRUE; - else - { - flocked = FALSE; - ulog (LOG_ERROR, "%s: Port already locked", - qport->uuconf_zname); - fret = FALSE; - } - - if (fret) - { - if (! fconn_open (&sconn, (long) 0, (long) 0, TRUE)) - fret = FALSE; - qConn = &sconn; - } - - if (fret) - { - if (fendless) - { - while (! FGOT_SIGNAL () - && flogin_prompt (puuconf, zconfig, fuuxqt, &sconn, - (const char *) NULL, - (const char **) NULL)) - { - /* Close and reopen the port in between calls. */ - if (! fconn_close (&sconn, puuconf, - (struct uuconf_dialer *) NULL, - TRUE) - || ! fconn_open (&sconn, (long) 0, (long) 0, TRUE)) - break; - } - fret = FALSE; - } - else - { - if (flogin) - fret = flogin_prompt (puuconf, zconfig, fuuxqt, &sconn, - zlogin, &zsystem); - else - { -#if DEBUG > 1 - iholddebug = iDebug; -#endif - if (zlogin == NULL) - zlogin = zsysdep_login_name (); - fret = faccept_call (puuconf, zconfig, fuuxqt, zlogin, - &sconn, &zsystem); -#if DEBUG > 1 - iDebug = iholddebug; -#endif - } - } - } - - if (qConn != NULL) - { - if (! fconn_close (&sconn, puuconf, (struct uuconf_dialer *) NULL, - fret)) - fret = FALSE; - qConn = NULL; - } - - if (flocked) - (void) fconn_unlock (&sconn); - - uconn_free (&sconn); - } - - ulog_close (); - ustats_close (); - - /* If we got a SIGTERM, perhaps because the system is going down, - don't run uuxqt. We go ahead and run it for any other signal, - since I think they indicate more temporary conditions. */ - if (afSignal[INDEXSIG_SIGTERM]) - fuuxqt = FALSE; - - if (fuuxqt) - { - int irunuuxqt; - - iuuconf = uuconf_runuuxqt (puuconf, &irunuuxqt); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - else if (irunuuxqt == UUCONF_RUNUUXQT_ONCE) - { - /* Detach from the controlling terminal before starting up uuxqt, - so that it runs as a true daemon. */ - if (fdetach) - usysdep_detach (); - - if (! fspawn_uuxqt (FALSE, zsystem, zconfig)) - fret = FALSE; - } - } - - usysdep_exit (fret); - - /* Avoid complaints about not returning. */ - return 0; -} - -/* Print out a usage message and die. */ - -static void -uusage () -{ - fprintf (stderr, "Usage: %s [options]\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void -uhelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [options]\n", zProgram); - printf (" -s,-S,--system system: Call system (-S implies -f)\n"); - printf (" -f,--force: Force call despite system status\n"); - printf (" -r state: 1 for master, 0 for slave (default)\n"); - printf (" --master: Act as master\n"); - printf (" --slave: Act as slave (default)\n"); - printf (" -p,--port port: Specify port\n"); - printf (" -l,--prompt: prompt for login name and password\n"); - printf (" -e,--loop: Endless loop of login prompts and daemon execution\n"); - printf (" -w,--wait: After calling out, wait for incoming calls\n"); - printf (" -q,--nouuxqt: Don't start uuxqt when done\n"); - printf (" -c,--quiet: Don't log bad time or no work warnings\n"); - printf (" -C,--ifwork: Only call named system if there is work\n"); - printf (" -D,--nodetach: Don't detach from controlling terminal\n"); - printf (" -u,--login: Set login name (privileged users only)\n"); - printf (" -i,--stdin type: Type of standard input (only TLI supported)\n"); - printf (" -z,--try-next: If a call fails, try the next alternate\n"); - printf (" -x,-X,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} - -/* This function is called when a LOG_FATAL error occurs. */ - -static void -uabort () -{ - if (fLocked_system) - ufailed (&sDaemon); - - ulog_user ((const char *) NULL); - - if (qConn != NULL) - { - (void) fconn_close (qConn, pUuconf, (struct uuconf_dialer *) NULL, - FALSE); - (void) fconn_unlock (qConn); - uconn_free (qConn); - } - - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - - ulog_system ((const char *) NULL); - - ulog_close (); - ustats_close (); - - usysdep_exit (FALSE); -} - -/* The number of seconds in one day. We must cast to long for this - to be calculated correctly on a machine with 16 bit ints. */ -#define SECS_PER_DAY ((long) 24 * (long) 60 * (long) 60) - -/* Call another system, trying all the possible sets of calling - instructions. The qsys argument is the system to call. The qport - argument is the port to use, and may be NULL. If the fifwork - argument is TRUE, the call is only placed if there is work to be - done. If the fforce argument is TRUE, a call is forced even if not - enough time has passed since the last failed call. If the fquiet - argument is FALSE (the normal case), then a warning is given if - calls are not permitted at this time. */ - -static boolean -fcall (puuconf, zconfig, fuuxqt, qorigsys, qport, fifwork, fforce, fdetach, - fquiet, ftrynext) - pointer puuconf; - const char *zconfig; - boolean fuuxqt; - const struct uuconf_system *qorigsys; - struct uuconf_port *qport; - boolean fifwork; - boolean fforce; - boolean fdetach; - boolean fquiet; - boolean ftrynext; -{ - struct sstatus sstat; - long inow; - boolean fbadtime, fnevertime, ffoundwork; - const struct uuconf_system *qsys; - - if (! fsysdep_get_status (qorigsys, &sstat, (boolean *) NULL)) - return FALSE; - ubuffree (sstat.zstring); - - /* Make sure it's been long enough since the last failed call, and - that we haven't exceeded the maximum number of retries. Even if - we are over the limit on retries, we permit a call to be made if - 24 hours have passed. This 24 hour limit is still controlled by - the retry time. We ignore times in the future, presumably the - result of some sort of error. */ - inow = ixsysdep_time ((long *) NULL); - if (! fforce) - { - if (qorigsys->uuconf_cmax_retries > 0 - && sstat.cretries >= qorigsys->uuconf_cmax_retries - && sstat.ilast <= inow - && sstat.ilast + SECS_PER_DAY > inow) - { - ulog (LOG_ERROR, "Too many retries"); - return FALSE; - } - - if ((sstat.ttype == STATUS_COMPLETE - ? sstat.ilast + qorigsys->uuconf_csuccess_wait > inow - : sstat.ilast + sstat.cwait > inow) - && sstat.ilast <= inow) - { - ulog (LOG_NORMAL, "Retry time not reached"); - return FALSE; - } - } - - sDaemon.puuconf = puuconf; - sDaemon.zconfig = zconfig; - if (! fuuxqt) - sDaemon.irunuuxqt = UUCONF_RUNUUXQT_NEVER; - else - { - int iuuconf; - - iuuconf = uuconf_runuuxqt (puuconf, &sDaemon.irunuuxqt); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - } - - fbadtime = TRUE; - fnevertime = TRUE; - ffoundwork = FALSE; - - for (qsys = qorigsys; qsys != NULL; qsys = qsys->uuconf_qalternate) - { - int cretry; - boolean fany, fret, fcalled; - - if (FGOT_SIGNAL ()) - return FALSE; - - if (! qsys->uuconf_fcall || qsys->uuconf_qtimegrade == NULL) - continue; - - fnevertime = FALSE; - - /* Make sure this is a legal time to call. */ - if (! ftimespan_match (qsys->uuconf_qtimegrade, (long *) NULL, - &cretry)) - continue; - - fbadtime = FALSE; - - sDaemon.qsys = qsys; - sDaemon.zlocalname = NULL; - sDaemon.qconn = NULL; - sDaemon.qproto = NULL; - sDaemon.cchans = 1; - sDaemon.clocal_size = -1; - sDaemon.cremote_size = -1; - sDaemon.cmax_ever = -2; - sDaemon.cmax_receive = -1; - sDaemon.csent = 0; - sDaemon.creceived = 0; - sDaemon.cxfiles_received = 0; - sDaemon.ifeatures = 0; - sDaemon.frequest_hangup = FALSE; - sDaemon.fhangup_requested = FALSE; - sDaemon.fhangup = FALSE; - sDaemon.fmaster = TRUE; - sDaemon.fcaller = TRUE; - sDaemon.ireliable = 0; - sDaemon.bgrade = '\0'; - - /* Queue up any work there is to do. */ - if (! fqueue (&sDaemon, &fany)) - return FALSE; - - /* If we are only supposed to call if there is work, and there - isn't any work, check the next alternates. We can't give up - at this point because there might be some other alternates - with fewer restrictions on grade or file transfer size. */ - if (fifwork && ! fany) - { - uclear_queue (&sDaemon); - continue; - } - - ffoundwork = TRUE; - - fret = fconn_call (&sDaemon, qport, &sstat, cretry, &fcalled); - - uclear_queue (&sDaemon); - - if (fret) - return TRUE; - if (fcalled && ! ftrynext) - return FALSE; - - /* Now we have to dump that port so that we can aquire a new - one. On Unix this means that we will fork and get a new - process ID, so we must unlock and relock the system. */ - if (fdetach) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - usysdep_detach (); - if (! fsysdep_lock_system (&sLocked_system)) - return FALSE; - fLocked_system = TRUE; - } - } - - /* We only get here if no call succeeded. If fbadtime is TRUE it - was the wrong time for all the alternates. Otherwise, if - ffoundwork is FALSE there was no work for any of the alternates. - Otherwise, we attempted a call and fconn_call logged an error - message. */ - - if (fbadtime) - { - if (! fquiet) - ulog (LOG_NORMAL, "Wrong time to call"); - - /* Update the status, unless the system can never be called. If - the system can never be called, there is little point to - putting in a ``wrong time to call'' message. We don't change - the number of retries, although we do set the wait until the - next retry to 0. */ - if (! fnevertime) - { - sstat.ttype = STATUS_WRONG_TIME; - sstat.ilast = inow; - sstat.cwait = 0; - (void) fsysdep_set_status (qorigsys, &sstat); - } - } - else if (! ffoundwork) - { - if (! fquiet) - ulog (LOG_NORMAL, "No work"); - return TRUE; - } - - return FALSE; -} - -/* Find a port to use when calling a system, open a connection, and - dial the system. The actual call is done in fdo_call. This - routine is responsible for opening and closing the connection. */ - -static boolean -fconn_call (qdaemon, qport, qstat, cretry, pfcalled) - struct sdaemon *qdaemon; - struct uuconf_port *qport; - struct sstatus *qstat; - int cretry; - boolean *pfcalled; -{ - pointer puuconf; - const struct uuconf_system *qsys; - struct uuconf_port sport; - struct sconnection sconn; - enum tstatus_type terr; - boolean fret; - - puuconf = qdaemon->puuconf; - qsys = qdaemon->qsys; - - *pfcalled = FALSE; - - /* Ignore any SIGHUP signal we may have received up to this point. - This is needed on Unix because we may have gotten one from the - shell before we detached from the controlling terminal. */ - afSignal[INDEXSIG_SIGHUP] = FALSE; - - /* If no port was specified on the command line, use any port - defined for the system. To select the system port: 1) see if - port information was specified directly; 2) see if a port was - named; 3) get an available port given the baud rate. We don't - change the system status if a port is unavailable; i.e. we don't - force the system to wait for the retry time. */ - if (qport == NULL) - qport = qsys->uuconf_qport; - if (qport != NULL) - { - if (! fconn_init (qport, &sconn, UUCONF_PORTTYPE_UNKNOWN)) - return FALSE; - if (! fconn_lock (&sconn, FALSE)) - { - ulog (LOG_ERROR, "%s: Port already locked", - qport->uuconf_zname); - return FALSE; - } - } - else - { - struct spass s; - int iuuconf; - - s.fmatched = FALSE; - s.flocked = FALSE; - s.qconn = &sconn; - iuuconf = uuconf_find_port (puuconf, qsys->uuconf_zport, - qsys->uuconf_ibaud, - qsys->uuconf_ihighbaud, - iuport_lock, (pointer) &s, - &sport); - if (iuuconf == UUCONF_NOT_FOUND) - { - if (s.fmatched) - ulog (LOG_ERROR, "All matching ports in use"); - else - ulog (LOG_ERROR, "No matching ports"); - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - if (s.flocked) - { - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - } - return FALSE; - } - } - - if (! fconn_open (&sconn, qsys->uuconf_ibaud, qsys->uuconf_ihighbaud, - FALSE)) - { - terr = STATUS_PORT_FAILED; - fret = FALSE; - } - else - { - struct uuconf_dialer *qdialer; - struct uuconf_dialer sdialer; - enum tdialerfound tdialer; - - if (qsys->uuconf_zalternate == NULL) - ulog (LOG_NORMAL, "Calling system %s (port %s)", qsys->uuconf_zname, - zLdevice == NULL ? (char *) "unknown" : zLdevice); - else - ulog (LOG_NORMAL, "Calling system %s (alternate %s, port %s)", - qsys->uuconf_zname, qsys->uuconf_zalternate, - zLdevice == NULL ? (char *) "unknown" : zLdevice); - - qdialer = NULL; - - if (! fconn_dial (&sconn, puuconf, qsys, qsys->uuconf_zphone, - &sdialer, &tdialer)) - { - tdialer = DIALERFOUND_FALSE; - terr = STATUS_DIAL_FAILED; - fret = FALSE; - } - else - { - qdaemon->qconn = &sconn; - if (tdialer == DIALERFOUND_FALSE) - qdialer = NULL; - else - qdialer = &sdialer; - fret = fdo_call (qdaemon, qstat, qdialer, pfcalled, &terr); - } - - (void) fconn_close (&sconn, puuconf, qdialer, fret); - - if (tdialer == DIALERFOUND_FREE) - (void) uuconf_dialer_free (puuconf, &sdialer); - } - - if (! fret) - { - DEBUG_MESSAGE2 (DEBUG_HANDSHAKE, "Call failed: %d (%s)", - (int) terr, azStatus[(int) terr]); - qstat->ttype = terr; - qstat->cretries++; - qstat->ilast = ixsysdep_time ((long *) NULL); - if (cretry == 0) - qstat->cwait = CRETRY_WAIT (qstat->cretries); - else - qstat->cwait = cretry * 60; - (void) fsysdep_set_status (qsys, qstat); - } - - (void) fconn_unlock (&sconn); - uconn_free (&sconn); - - if (qport == NULL) - (void) uuconf_port_free (puuconf, &sport); - - return fret; -} - -/* Do the actual work of calling another system. The qsys argument is - the system to call, the qconn argument is the connection to use, - the qstat argument holds the current status of the ssystem, and the - qdialer argument holds the dialer being used (it may be NULL). If - we log in successfully, set *pfcalled to TRUE; this is used to - distinguish a failed dial from a failure during the call. If an - error occurs *pterr is set to the status type to record. */ - -static boolean -fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr) - struct sdaemon *qdaemon; - struct sstatus *qstat; - const struct uuconf_dialer *qdialer; - boolean *pfcalled; - enum tstatus_type *pterr; -{ - pointer puuconf; - const struct uuconf_system *qsys; - struct sconnection *qconn; - int iuuconf; - int istrip; - boolean fstrip; - const char *zport; - char *zstr; - long istart_time; - char *zlog; - - puuconf = qdaemon->puuconf; - qsys = qdaemon->qsys; - qconn = qdaemon->qconn; - - iuuconf = uuconf_strip (puuconf, &istrip); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - fstrip = (istrip & UUCONF_STRIP_PROTO) != 0; - - *pterr = STATUS_LOGIN_FAILED; - - if (qconn->qport == NULL) - zport = "unknown"; - else - zport = qconn->qport->uuconf_zname; - if (! fchat (qconn, puuconf, &qsys->uuconf_schat, qsys, - (const struct uuconf_dialer *) NULL, - (const char *) NULL, FALSE, zport, - iconn_baud (qconn))) - return FALSE; - - *pfcalled = TRUE; - istart_time = ixsysdep_time ((long *) NULL); - - *pterr = STATUS_HANDSHAKE_FAILED; - - /* We should now see "Shere" from the other system. Newer systems - send "Shere=foo" where foo is the remote name. */ - zstr = zget_uucp_cmd (qconn, TRUE, fstrip); - if (zstr == NULL) - return FALSE; - - if (strncmp (zstr, "Shere", 5) != 0) - { - ulog (LOG_ERROR, "Bad startup string (expected \"Shere\" got \"%s\")", - zstr); - ubuffree (zstr); - return FALSE; - } - - ulog (LOG_NORMAL, "Login successful"); - - qstat->ttype = STATUS_TALKING; - qstat->ilast = ixsysdep_time ((long *) NULL); - qstat->cretries = 0; - qstat->cwait = 0; - if (! fsysdep_set_status (qsys, qstat)) - return FALSE; - - if (zstr[5] == '=') - { - const char *zheresys; - size_t clen; - int icmp; - - /* Some UUCP packages only provide seven characters in the Shere - machine name. Others only provide fourteen. */ - zheresys = zstr + 6; - clen = strlen (zheresys); - if (clen == 7 || clen == 14) - icmp = strncmp (zheresys, qsys->uuconf_zname, clen); - else - icmp = strcmp (zheresys, qsys->uuconf_zname); - if (icmp != 0) - { - if (qsys->uuconf_pzalias != NULL) - { - char **pz; - - for (pz = qsys->uuconf_pzalias; *pz != NULL; pz++) - { - if (clen == 7 || clen == 14) - icmp = strncmp (zheresys, *pz, clen); - else - icmp = strcmp (zheresys, *pz); - if (icmp == 0) - break; - } - } - if (icmp != 0) - { - ulog (LOG_ERROR, "Called wrong system (%s)", zheresys); - ubuffree (zstr); - return FALSE; - } - } - } -#if DEBUG > 1 - else if (zstr[5] != '\0') - DEBUG_MESSAGE1 (DEBUG_HANDSHAKE, - "fdo_call: Strange Shere: %s", zstr); -#endif - - ubuffree (zstr); - - /* We now send "S" name switches, where name is our UUCP name. If - we are using sequence numbers with this system, we send a -Q - argument with the sequence number. If the call-timegrade command - was used, we send a -p argument and a -vgrade= argument with the - grade to send us (we send both argument to make it more likely - that one is recognized). We always send a -N (for new) switch - indicating what new features we support. */ - { - long ival; - char bgrade; - char *zsend; - boolean fret; - - /* Determine the grade we should request of the other system. A - '\0' means that no restrictions have been made. */ - if (! ftimespan_match (qsys->uuconf_qcalltimegrade, &ival, - (int *) NULL)) - bgrade = '\0'; - else - bgrade = (char) ival; - - /* Determine the name we will call ourselves. */ - if (qsys->uuconf_zlocalname != NULL) - qdaemon->zlocalname = qsys->uuconf_zlocalname; - else - { - iuuconf = uuconf_localname (puuconf, &qdaemon->zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - qdaemon->zlocalname = zsysdep_localname (); - if (qdaemon->zlocalname == NULL) - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - } - - zsend = zbufalc (strlen (qdaemon->zlocalname) + 70); - if (! qsys->uuconf_fsequence) - { - if (bgrade == '\0') - sprintf (zsend, "S%s -R -N0%o", qdaemon->zlocalname, - (unsigned int) (FEATURE_SIZES - | FEATURE_EXEC - | FEATURE_RESTART)); - else - sprintf (zsend, "S%s -p%c -vgrade=%c -R -N0%o", - qdaemon->zlocalname, bgrade, bgrade, - (unsigned int) (FEATURE_SIZES - | FEATURE_EXEC - | FEATURE_RESTART)); - } - else - { - long iseq; - - iseq = ixsysdep_get_sequence (qsys); - if (iseq < 0) - return FALSE; - if (bgrade == '\0') - sprintf (zsend, "S%s -Q%ld -R -N0%o", qdaemon->zlocalname, iseq, - (unsigned int) (FEATURE_SIZES - | FEATURE_EXEC - | FEATURE_RESTART)); - else - sprintf (zsend, "S%s -Q%ld -p%c -vgrade=%c -R -N0%o", - qdaemon->zlocalname, iseq, bgrade, bgrade, - (unsigned int) (FEATURE_SIZES - | FEATURE_EXEC - | FEATURE_RESTART)); - } - - fret = fsend_uucp_cmd (qconn, zsend); - ubuffree (zsend); - if (! fret) - return FALSE; - } - - /* Now we should see ROK or Rreason where reason gives a cryptic - reason for failure. If we are talking to a counterpart, we will - get back ROKN, possibly with a feature bitfield attached. */ - zstr = zget_uucp_cmd (qconn, TRUE, fstrip); - if (zstr == NULL) - return FALSE; - - if (zstr[0] != 'R') - { - ulog (LOG_ERROR, "Bad response to handshake string (%s)", - zstr); - ubuffree (zstr); - return FALSE; - } - - if (strncmp (zstr + 1, "OKN", sizeof "OKN" - 1) == 0) - { - if (zstr[sizeof "ROKN" - 1] == '\0') - qdaemon->ifeatures |= FEATURE_SIZES | FEATURE_V103; - else - qdaemon->ifeatures |= (int) strtol (zstr + sizeof "ROKN" - 1, - (char **) NULL, 0); - } - else if (strncmp (zstr + 1, "OK", sizeof "OK" - 1) == 0) - { - if (zstr[sizeof "ROK" - 1] != '\0') - { - char *zopt; - - /* SVR4 UUCP returns options following the ROK string. */ - zopt = zstr + sizeof "ROK" - 1; - while (*zopt != '\0') - { - char b; - long c; - char *zend; - - b = *zopt++; - if (isspace (b) || b != '-') - continue; - switch (*zopt) - { - case 'R': - qdaemon->ifeatures |= (FEATURE_RESTART - | FEATURE_SVR4 - | FEATURE_SIZES); - break; - case 'U': - c = strtol (zopt, &zend, 0); - if (c > 0 && c <= LONG_MAX / (long) 512) - qdaemon->cmax_receive = c * (long) 512; - zopt = zend; - break; - } - while (*zopt != '\0' && ! isspace (*zopt)) - ++zopt; - } - } - } - else if (strcmp (zstr + 1, "CB") == 0) - { - ulog (LOG_NORMAL, "Remote system will call back"); - qstat->ttype = STATUS_COMPLETE; - (void) fsysdep_set_status (qsys, qstat); - ubuffree (zstr); - return TRUE; - } - else - { - ulog (LOG_ERROR, "Handshake failed (%s)", zstr + 1); - ubuffree (zstr); - return FALSE; - } - - ubuffree (zstr); - - /* The slave should now send \020Pprotos\0 where protos is a list of - supported protocols. Each protocol is a single character. */ - zstr = zget_uucp_cmd (qconn, TRUE, fstrip); - if (zstr == NULL) - return FALSE; - - if (zstr[0] != 'P') - { - ulog (LOG_ERROR, "Bad protocol handshake (%s)", zstr); - ubuffree (zstr); - return FALSE; - } - - /* Determine the reliability characteristics of the connection by - combining information for the port and the dialer. If we have no - information, default to a reliable eight-bit full-duplex - connection. */ - if (qconn->qport != NULL - && (qconn->qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - qdaemon->ireliable = qconn->qport->uuconf_ireliable; - if (qdialer != NULL - && (qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - { - if (qdaemon->ireliable != 0) - qdaemon->ireliable &= qdialer->uuconf_ireliable; - else - qdaemon->ireliable = qdialer->uuconf_ireliable; - } - if (qdaemon->ireliable == 0) - qdaemon->ireliable = (UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX - | UUCONF_RELIABLE_SPECIFIED); - - /* Now decide which protocol to use. The system and the port may - have their own list of protocols. */ - { - int i; - char ab[5]; - - i = CPROTOCOLS; - if (qsys->uuconf_zprotocols != NULL - || (qconn->qport != NULL - && qconn->qport->uuconf_zprotocols != NULL)) - { - const char *zproto; - - if (qsys->uuconf_zprotocols != NULL) - zproto = qsys->uuconf_zprotocols; - else - zproto = qconn->qport->uuconf_zprotocols; - for (; *zproto != '\0'; zproto++) - { - if (strchr (zstr + 1, *zproto) != NULL) - { - for (i = 0; i < CPROTOCOLS; i++) - if (asProtocols[i].bname == *zproto) - break; - if (i < CPROTOCOLS) - break; - } - } - } - else - { - /* If neither the system nor the port specified a list of - protocols, we want only protocols that match the known - reliability of the dialer and the port. */ - for (i = 0; i < CPROTOCOLS; i++) - { - int ipr; - - ipr = asProtocols[i].ireliable; - if ((ipr & qdaemon->ireliable) != ipr) - continue; - if (strchr (zstr + 1, asProtocols[i].bname) != NULL) - break; - } - } - - ubuffree (zstr); - - if (i >= CPROTOCOLS) - { - (void) fsend_uucp_cmd (qconn, "UN"); - ulog (LOG_ERROR, "No mutually supported protocols"); - return FALSE; - } - - qdaemon->qproto = &asProtocols[i]; - - /* If we are using a half-duplex line, act as though we have only - a single channel; otherwise we might start a send and a receive - at the same time. */ - if ((qdaemon->ireliable & UUCONF_RELIABLE_FULLDUPLEX) == 0) - qdaemon->cchans = 1; - else - qdaemon->cchans = asProtocols[i].cchans; - - sprintf (ab, "U%c", qdaemon->qproto->bname); - if (! fsend_uucp_cmd (qconn, ab)) - return FALSE; - } - - /* Run any protocol parameter commands. */ - if (qdaemon->qproto->qcmds != NULL) - { - if (qsys->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, qdaemon->qproto->bname, - qdaemon->qproto->qcmds, - qsys->uuconf_qproto_params); - if (qconn->qport != NULL - && qconn->qport->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, qdaemon->qproto->bname, - qdaemon->qproto->qcmds, - qconn->qport->uuconf_qproto_params); - if (qdialer != NULL - && qdialer->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, qdaemon->qproto->bname, - qdaemon->qproto->qcmds, - qdialer->uuconf_qproto_params); - } - - /* Turn on the selected protocol. */ - if (! (*qdaemon->qproto->pfstart) (qdaemon, &zlog)) - return FALSE; - if (zlog == NULL) - { - zlog = zbufalc (sizeof "protocol ''" + 1); - sprintf (zlog, "protocol '%c'", qdaemon->qproto->bname); - } - ulog (LOG_NORMAL, "Handshake successful (%s)", zlog); - ubuffree (zlog); - - *pterr = STATUS_FAILED; - - { - boolean fret; - long iend_time; - - fret = floop (qdaemon); - - /* Now send the hangup message. As the caller, we send six O's - and expect to receive seven O's. We send the six O's twice to - help the other side. We don't worry about errors here. */ - if (fsend_uucp_cmd (qconn, "OOOOOO") - && fsend_uucp_cmd (qconn, "OOOOOO")) - { - int i, fdone; - - /* We look for the remote hangup string to ensure that the - modem has sent out our hangup string. This is only - necessary because some versions of UUCP complain if they - don't get the hangup string. The remote site should send 7 - O's, but some versions of UUCP only send 6. We look for - the string several times because supposedly some - implementations send some garbage after the last packet but - before the hangup string. */ - for (i = 0; i < 25; i++) - { - zstr = zget_uucp_cmd (qconn, FALSE, fstrip); - if (zstr == NULL) - break; - fdone = strstr (zstr, "OOOOOO") != NULL; - ubuffree (zstr); - if (fdone) - break; - } - } - - iend_time = ixsysdep_time ((long *) NULL); - - ulog (LOG_NORMAL, "Call complete (%ld seconds %ld bytes %ld bps)", - iend_time - istart_time, - qdaemon->csent + qdaemon->creceived, - (iend_time != istart_time - ? (qdaemon->csent + qdaemon->creceived) / (iend_time - istart_time) - : 0)); - - if (fret) - { - qstat->ttype = STATUS_COMPLETE; - qstat->ilast = iend_time; - (void) fsysdep_set_status (qsys, qstat); - } - - if (qdaemon->irunuuxqt == UUCONF_RUNUUXQT_PERCALL - || (qdaemon->irunuuxqt > 0 && qdaemon->cxfiles_received > 0)) - (void) fspawn_uuxqt (TRUE, qdaemon->qsys->uuconf_zname, - qdaemon->zconfig); - - return fret; - } -} - -/* This routine is called via uuconf_find_port when a matching port is - found. It tries to lock the port. If it fails, it returns - UUCONF_NOT_FOUND to force uuconf_find_port to continue searching - for the next matching port. */ - -static int -iuport_lock (qport, pinfo) - struct uuconf_port *qport; - pointer pinfo; -{ - struct spass *q = (struct spass *) pinfo; - - q->fmatched = TRUE; - - if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN)) - return UUCONF_NOT_FOUND; - else if (! fconn_lock (q->qconn, FALSE)) - { - uconn_free (q->qconn); - return UUCONF_NOT_FOUND; - } - else - { - q->flocked = TRUE; - return UUCONF_SUCCESS; - } -} - -/* The information structure used for the uuconf_callin comparison - function. */ - -struct scallin_info -{ - const char *zuser; - const char *zpass; -}; - -/* Prompt for a login name and a password, and run as the slave. */ - -static boolean -flogin_prompt (puuconf, zconfig, fuuxqt, qconn, zlogin, pzsystem) - pointer puuconf; - const char *zconfig; - boolean fuuxqt; - struct sconnection *qconn; - const char *zlogin; - const char **pzsystem; -{ - int iuuconf; - int istrip; - boolean fstrip; - char *zuser, *zpass; - boolean fret; - struct scallin_info s; - - if (pzsystem != NULL) - *pzsystem = NULL; - - DEBUG_MESSAGE0 (DEBUG_HANDSHAKE, "flogin_prompt: Waiting for login"); - - iuuconf = uuconf_strip (puuconf, &istrip); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - fstrip = (istrip & UUCONF_STRIP_LOGIN) != 0; - - zuser = NULL; - if (zlogin == NULL) - { - do - { - ubuffree (zuser); - if (! fconn_write (qconn, "login: ", sizeof "login: " - 1)) - return FALSE; - zuser = zget_typed_line (qconn, fstrip); - } - while (zuser != NULL && *zuser == '\0'); - - if (zuser == NULL) - return TRUE; - - zlogin = zuser; - } - - if (! fconn_write (qconn, "Password:", sizeof "Password:" - 1)) - { - ubuffree (zuser); - return FALSE; - } - - zpass = zget_typed_line (qconn, fstrip); - if (zpass == NULL) - { - ubuffree (zuser); - return TRUE; - } - - fret = TRUE; - - s.zuser = zlogin; - s.zpass = zpass; - iuuconf = uuconf_callin (puuconf, icallin_cmp, &s); - - ubuffree (zpass); - - if (iuuconf == UUCONF_NOT_FOUND) - ulog (LOG_ERROR, "Bad login"); - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - } - else - { -#if DEBUG > 1 - int iholddebug; -#endif - - /* We ignore the return value of faccept_call because we really - don't care whether the call succeeded or not. We are going - to reset the port anyhow. */ -#if DEBUG > 1 - iholddebug = iDebug; -#endif - (void) faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem); -#if DEBUG > 1 - iDebug = iholddebug; -#endif - } - - ubuffree (zuser); - - return fret; -} - -/* The comparison function which we pass to uuconf_callin. This - expands escape sequences in the login name, and either encrypts or - expands escape sequences in the password. */ - -static int -icallin_cmp (iwhich, pinfo, zfile) - int iwhich; - pointer pinfo; - const char *zfile; -{ - struct scallin_info *qinfo = (struct scallin_info *) pinfo; - char *zcopy; - int icmp; - -#if HAVE_ENCRYPTED_PASSWORDS - if (iwhich != 0) - return strcmp (crypt (qinfo->zpass, zfile), zfile) == 0; -#endif - - zcopy = zbufcpy (zfile); - (void) cescape (zcopy); - if (iwhich == 0) - icmp = strcmp (qinfo->zuser, zcopy); - else - icmp = strcmp (qinfo->zpass, zcopy); - ubuffree (zcopy); - return icmp == 0; -} - -/* Accept a call from a remote system. If pqsys is not NULL, *pqsys - will be set to the system that called in if known. */ - -static boolean -faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem) - pointer puuconf; - const char *zconfig; - boolean fuuxqt; - const char *zlogin; - struct sconnection *qconn; - const char **pzsystem; -{ - long istart_time; - int iuuconf; - int istrip; - boolean fstrip; - const char *zport; - struct uuconf_port *qport; - struct uuconf_port sport; - struct uuconf_dialer *qdialer; - struct uuconf_dialer sdialer; - boolean ftcp_port; - char *zsend, *zspace; - boolean fret; - char *zstr; - struct uuconf_system ssys; - const struct uuconf_system *qsys; - const struct uuconf_system *qany; - char *zloc; - struct sstatus sstat; - boolean fgotseq, fgotn; - int i; - char *zlog; - char *zgrade; - - if (pzsystem != NULL) - *pzsystem = NULL; - - ulog (LOG_NORMAL, "Incoming call (login %s port %s)", zlogin, - zLdevice == NULL ? (char *) "unknown" : zLdevice); - - istart_time = ixsysdep_time ((long *) NULL); - - iuuconf = uuconf_strip (puuconf, &istrip); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - (struct uuconf_port *) NULL, - &sport, (char *) NULL); - return FALSE; - } - fstrip = (istrip & UUCONF_STRIP_PROTO) != 0; - - /* Figure out protocol parameters determined by the port. If no - port was specified we're reading standard input, so try to get - the port name and read information from the port file. We only - use the port information to get protocol parameters; we don't - want to start treating the port as though it were a modem, for - example. */ - if (qconn->qport != NULL) - { - qport = qconn->qport; - zport = qport->uuconf_zname; - ftcp_port = FALSE; - } - else - { - zport = zsysdep_port_name (&ftcp_port); - if (zport == NULL) - { - qport = NULL; - zport = "unknown"; - } - else - { - iuuconf = uuconf_find_port (puuconf, zport, (long) 0, (long) 0, - (int (*) P((struct uuconf_port *, - pointer pinfo))) NULL, - (pointer) NULL, - &sport); - if (iuuconf == UUCONF_NOT_FOUND) - qport = NULL; - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - (struct uuconf_port *) NULL, - &sport, (char *) NULL); - return FALSE; - } - else - qport = &sport; - } - } - - /* If we've managed to figure out that this is a modem port, now try - to get protocol parameters from the dialer. */ - qdialer = NULL; - if (qport != NULL) - { - if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM) - { - if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL) - { - const char *zdialer; - - zdialer = qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0]; - iuuconf = uuconf_dialer_info (puuconf, zdialer, &sdialer); - if (iuuconf == UUCONF_SUCCESS) - qdialer = &sdialer; - } - else - qdialer = qport->uuconf_u.uuconf_smodem.uuconf_qdialer; - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TCP - || (qport->uuconf_ttype == UUCONF_PORTTYPE_TLI - && (qport->uuconf_ireliable - & UUCONF_RELIABLE_SPECIFIED) == 0)) - ftcp_port = TRUE; - } - - sDaemon.puuconf = puuconf; - sDaemon.zconfig = zconfig; - if (! fuuxqt) - sDaemon.irunuuxqt = UUCONF_RUNUUXQT_NEVER; - else - { - iuuconf = uuconf_runuuxqt (puuconf, &sDaemon.irunuuxqt); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - } - sDaemon.qsys = NULL; - sDaemon.zlocalname = NULL; - sDaemon.qconn = qconn; - sDaemon.qproto = NULL; - sDaemon.cchans = 1; - sDaemon.clocal_size = -1; - sDaemon.cremote_size = -1; - sDaemon.cmax_ever = -2; - sDaemon.cmax_receive = -1; - sDaemon.csent = 0; - sDaemon.creceived = 0; - sDaemon.cxfiles_received = 0; - sDaemon.ifeatures = 0; - sDaemon.frequest_hangup = FALSE; - sDaemon.fhangup_requested = FALSE; - sDaemon.fhangup = FALSE; - sDaemon.fmaster = FALSE; - sDaemon.fcaller = FALSE; - sDaemon.ireliable = 0; - sDaemon.bgrade = UUCONF_GRADE_LOW; - - /* Get the local name to use. If uuconf_login_localname returns a - value, it is not always freed up, although it should be. */ - iuuconf = uuconf_login_localname (puuconf, zlogin, &zloc); - if (iuuconf == UUCONF_SUCCESS) - sDaemon.zlocalname = zloc; - else if (iuuconf == UUCONF_NOT_FOUND) - { - sDaemon.zlocalname = zsysdep_localname (); - if (sDaemon.zlocalname == NULL) - { - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, (char *) NULL); - return FALSE; - } - } - else - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, (char *) NULL); - return FALSE; - } - - /* Tell the remote system who we are. */ - zsend = zbufalc (strlen (sDaemon.zlocalname) + sizeof "Shere="); - sprintf (zsend, "Shere=%s", sDaemon.zlocalname); - fret = fsend_uucp_cmd (qconn, zsend); - ubuffree (zsend); - if (! fret) - { - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - - zstr = zget_uucp_cmd (qconn, TRUE, fstrip); - if (zstr == NULL) - { - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - - if (zstr[0] != 'S') - { - ulog (LOG_ERROR, "Bad introduction string"); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - - zspace = strchr (zstr, ' '); - if (zspace != NULL) - *zspace = '\0'; - - iuuconf = uuconf_system_info (puuconf, zstr + 1, &ssys); - if (iuuconf == UUCONF_NOT_FOUND) - { - char *zscript; - - /* Run the remote.unknown script, if appropriate. */ - iuuconf = uuconf_remote_unknown (puuconf, &zscript); - if (iuuconf == UUCONF_SUCCESS) - { - if (! fsysdep_unknown_caller (zscript, zstr + 1)) - { - xfree ((pointer) zscript); - (void) fsend_uucp_cmd (qconn, "RYou are unknown to me"); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - xfree ((pointer) zscript); - } - else if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - - if (! funknown_system (puuconf, zstr + 1, &ssys)) - { - (void) fsend_uucp_cmd (qconn, "RYou are unknown to me"); - ulog (LOG_ERROR, "Call from unknown system %s", zstr + 1); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL, - qport, &sport, zloc); - return FALSE; - } - - qany = NULL; - for (qsys = &ssys; qsys != NULL; qsys = qsys->uuconf_qalternate) - { - if (! qsys->uuconf_fcalled) - continue; - - if (qsys->uuconf_zcalled_login == NULL - || strcmp (qsys->uuconf_zcalled_login, "ANY") == 0) - { - if (qany == NULL) - qany = qsys; - } - else if (strcmp (qsys->uuconf_zcalled_login, zlogin) == 0) - break; - } - - if (qsys == NULL && qany != NULL) - { - iuuconf = uuconf_validate (puuconf, qany, zlogin); - if (iuuconf == UUCONF_SUCCESS) - qsys = qany; - else if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - } - - if (qsys == NULL) - { - (void) fsend_uucp_cmd (qconn, "RLOGIN"); - ulog (LOG_ERROR, "System %s used wrong login name %s", - zstr + 1, zlogin); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - sDaemon.qsys = qsys; - - if (pzsystem != NULL) - *pzsystem = zbufcpy (qsys->uuconf_zname); - - ulog_system (qsys->uuconf_zname); - -#if DEBUG > 1 - if (qsys->uuconf_zdebug != NULL) - iDebug |= idebug_parse (qsys->uuconf_zdebug); -#endif - - /* See if we are supposed to call the system back. This will queue - up an empty command. It would be better to actually call back - directly at this point as well. */ - if (qsys->uuconf_fcallback) - { - (void) fsend_uucp_cmd (qconn, "RCB"); - ulog (LOG_NORMAL, "Will call back"); - - /* Clear any existing status. */ - sstat.ttype = STATUS_COMPLETE; - sstat.cretries = 0; - sstat.ilast = ixsysdep_time ((long *) NULL); - sstat.cwait = 0; - (void) fsysdep_set_status (qsys, &sstat); - - ubuffree (zsysdep_spool_commands (qsys, UUCONF_GRADE_HIGH, 0, - (const struct scmd *) NULL)); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return TRUE; - } - - /* We only permit one call at a time from a remote system. Lock it. */ - if (! fsysdep_lock_system (qsys)) - { - if (qsys->uuconf_fsequence) - { - /* At this point the calling system has already incremented - its sequence number, so we increment ours. This will - only cause a mismatch if the other system is not what it - says it is. */ - (void) ixsysdep_get_sequence (qsys); - } - (void) fsend_uucp_cmd (qconn, "RLCK"); - ulog (LOG_ERROR, "System already locked"); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - sLocked_system = *qsys; - fLocked_system = TRUE; - - /* Set the system status. We don't care what the status was before. - We also don't want to kill the conversation just because we can't - output the .Status file, so we ignore any errors. */ - sstat.ttype = STATUS_TALKING; - sstat.cretries = 0; - sstat.ilast = ixsysdep_time ((long *) NULL); - sstat.cwait = 0; - (void) fsysdep_set_status (qsys, &sstat); - - /* Check the arguments of the remote system, if any. */ - fgotseq = FALSE; - fgotn = FALSE; - if (zspace != NULL) - { - char **paz; - char **pzset; - - ++zspace; - - /* Break the introduction line up into arguments. */ - paz = (char **) xmalloc ((strlen (zspace) / 2 + 2) * sizeof (char *)); - pzset = paz; - *pzset++ = NULL; - while (TRUE) - { - while (*zspace != '\0' && isspace (BUCHAR (*zspace))) - ++zspace; - if (*zspace == '\0') - break; - *pzset++ = zspace; - ++zspace; - while (*zspace != '\0' && ! isspace (BUCHAR (*zspace))) - ++zspace; - if (*zspace == '\0') - break; - *zspace++ = '\0'; - } - - if (pzset != paz + 1) - { - int iopt; - - *pzset = NULL; - - /* We are going to use getopt to parse the arguments. We - must clear optind to force getopt to reinitialize, and - clear opterr to prevent getopt from printing an error - message. This approach assumes we are using the GNU - getopt, which is distributed with the program anyhow. */ - optind = 0; - opterr = 0; - - while ((iopt = getopt (pzset - paz, paz, - "N::p:Q:RU:v:x:")) != EOF) - { - long iseq; - long c; - char b; - int iwant; - - switch (iopt) - { - case 'N': - /* This is used to indicate support for Taylor UUCP - extensions. An plain -N mean support for size - negotiation. If -N is followed by a number (with - no intervening space), the number is a bit field - of feature flags as defined in trans.h. Note - that the argument may start with 0x for hex or 0 - for octal. */ - fgotn = TRUE; - if (optarg == NULL) - sDaemon.ifeatures |= FEATURE_SIZES | FEATURE_V103; - else - sDaemon.ifeatures |= (int) strtol (optarg, - (char **) NULL, - 0); - break; - - case 'p': - /* The argument is the lowest grade of work the - local system should send. */ - if (UUCONF_GRADE_LEGAL (optarg[0])) - sDaemon.bgrade = optarg[0]; - break; - - case 'Q': - /* The conversation sequence number. */ - iseq = strtol (optarg, (char **) NULL, 10); - if (qsys->uuconf_fsequence - && iseq != ixsysdep_get_sequence (qsys)) - { - (void) fsend_uucp_cmd (qconn, "RBADSEQ"); - ulog (LOG_ERROR, "Out of sequence call rejected"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - xfree ((pointer) paz); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, - zloc); - return FALSE; - } - fgotseq = TRUE; - break; - - case 'R': - /* The remote system supports file restart. */ - sDaemon.ifeatures |= FEATURE_RESTART; - break; - - case 'U': - /* The maximum file size the remote system is - prepared to received, in blocks where each block - is 512 bytes. */ - c = strtol (optarg, (char **) NULL, 0); - if (c > 0 && c < LONG_MAX / (long) 512) - sDaemon.cmax_receive = c * (long) 512; - break; - - case 'v': - /* -vgrade=X can be used to set the lowest grade of - work the local system should send. */ - if (strncmp (optarg, "grade=", sizeof "grade=" - 1) == 0) - { - b = optarg[sizeof "grade=" - 1]; - if (UUCONF_GRADE_LEGAL (b)) - sDaemon.bgrade = b; - } - break; - - case 'x': - iwant = (int) strtol (optarg, (char **) NULL, 10); -#if DEBUG > 1 - if (iwant <= 9) - iwant = (1 << iwant) - 1; - if (qsys->uuconf_zmax_remote_debug != NULL) - iwant &= idebug_parse (qsys->uuconf_zmax_remote_debug); - else - iwant &= DEBUG_ABNORMAL | DEBUG_CHAT | DEBUG_HANDSHAKE; - if ((iDebug | iwant) != iDebug) - { - iDebug |= iwant; - ulog (LOG_NORMAL, "Setting debugging mode to 0%o", - iDebug); - } -#endif - break; - - default: - break; - } - } - } - - xfree ((pointer) paz); - } - - ubuffree (zstr); - - if (qsys->uuconf_fsequence && ! fgotseq) - { - (void) fsend_uucp_cmd (qconn, "RBADSEQ"); - ulog (LOG_ERROR, "No sequence number (call rejected)"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - /* We recognized the system, and the sequence number (if any) was - OK. Send an ROK, and send a list of protocols. If we got the -N - switch, send ROKN to confirm it; if the -N switch was followed by - a feature bitfield, return our own feature bitfield. */ - { - char ab[20]; - const char *zreply; - - if (! fgotn) - { - if ((sDaemon.ifeatures & FEATURE_RESTART) == 0) - zreply = "ROK"; - else - { - /* We got -R without -N, so assume that this is SVR4 UUCP. - SVR4 UUCP expects ROK -R to signal support for file - restart. */ - sDaemon.ifeatures |= FEATURE_SVR4 | FEATURE_SIZES; - zreply = "ROK -R"; - } - } - else if ((sDaemon.ifeatures & FEATURE_V103) != 0) - zreply = "ROKN"; - else - { - sprintf (ab, "ROKN0%o", - (unsigned int) (FEATURE_SIZES - | FEATURE_EXEC - | FEATURE_RESTART)); - zreply = ab; - } - if (! fsend_uucp_cmd (qconn, zreply)) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - } - - /* Determine the reliability of the connection based on the - reliability of the port and the dialer. If we have no - information, default to a reliable eight-bit full-duplex - connection. */ - if (ftcp_port) - sDaemon.ireliable = (UUCONF_RELIABLE_SPECIFIED - | UUCONF_RELIABLE_ENDTOEND - | UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX); - else - { - if (qport != NULL - && (qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - sDaemon.ireliable = qport->uuconf_ireliable; - if (qdialer != NULL - && (qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - { - if (sDaemon.ireliable != 0) - sDaemon.ireliable &= qdialer->uuconf_ireliable; - else - sDaemon.ireliable = qdialer->uuconf_ireliable; - } - if (sDaemon.ireliable == 0) - sDaemon.ireliable = (UUCONF_RELIABLE_RELIABLE - | UUCONF_RELIABLE_EIGHT - | UUCONF_RELIABLE_FULLDUPLEX - | UUCONF_RELIABLE_SPECIFIED); - } - - if (qsys->uuconf_zprotocols != NULL || - (qport != NULL && qport->uuconf_zprotocols != NULL)) - { - const char *zprotos; - - if (qsys->uuconf_zprotocols != NULL) - zprotos = qsys->uuconf_zprotocols; - else - zprotos = qport->uuconf_zprotocols; - zsend = zbufalc (strlen (zprotos) + 2); - sprintf (zsend, "P%s", zprotos); - } - else - { - char *zset; - - zsend = zbufalc (CPROTOCOLS + 2); - zset = zsend; - *zset++ = 'P'; - - /* If the system did not specify a list of protocols, we want - only protocols that match the known reliability of the dialer - and the port. */ - for (i = 0; i < CPROTOCOLS; i++) - { - int ipr; - - ipr = asProtocols[i].ireliable; - if ((ipr & sDaemon.ireliable) != ipr) - continue; - *zset++ = asProtocols[i].bname; - } - *zset = '\0'; - } - - fret = fsend_uucp_cmd (qconn, zsend); - ubuffree (zsend); - if (! fret) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - /* The master will now send back the selected protocol. */ - zstr = zget_uucp_cmd (qconn, TRUE, fstrip); - if (zstr == NULL) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - if (zstr[0] != 'U') - { - ulog (LOG_ERROR, "Bad protocol response string"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - if (zstr[1] == 'N') - { - ulog (LOG_ERROR, "No supported protocol"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - ubuffree (zstr); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - for (i = 0; i < CPROTOCOLS; i++) - if (asProtocols[i].bname == zstr[1]) - break; - - ubuffree (zstr); - - if (i >= CPROTOCOLS) - { - ulog (LOG_ERROR, "No supported protocol"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - sDaemon.qproto = &asProtocols[i]; - - /* If we are using a half-duplex line, act as though we have only a - single channel; otherwise we might start a send and a receive at - the same time. */ - if ((sDaemon.ireliable & UUCONF_RELIABLE_FULLDUPLEX) == 0) - sDaemon.cchans = 1; - else - sDaemon.cchans = asProtocols[i].cchans; - - /* Run the chat script for when a call is received. */ - if (! fchat (qconn, puuconf, &qsys->uuconf_scalled_chat, qsys, - (const struct uuconf_dialer *) NULL, (const char *) NULL, - FALSE, zport, iconn_baud (qconn))) - { - sstat.ttype = STATUS_FAILED; - sstat.ilast = ixsysdep_time ((long *) NULL); - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - /* Run any protocol parameter commands. */ - if (sDaemon.qproto->qcmds != NULL) - { - if (qsys->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, sDaemon.qproto->bname, - sDaemon.qproto->qcmds, - qsys->uuconf_qproto_params); - if (qport != NULL - && qport->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, sDaemon.qproto->bname, - sDaemon.qproto->qcmds, - qport->uuconf_qproto_params); - if (qdialer != NULL - && qdialer->uuconf_qproto_params != NULL) - uapply_proto_params (puuconf, sDaemon.qproto->bname, - sDaemon.qproto->qcmds, - qdialer->uuconf_qproto_params); - } - - /* We don't need the dialer information any more. */ - if (qdialer == &sdialer) - (void) uuconf_dialer_free (puuconf, &sdialer); - - /* Turn on the selected protocol and get any jobs queued for the - system. */ - if (! (*sDaemon.qproto->pfstart) (&sDaemon, &zlog) - || ! fqueue (&sDaemon, (boolean *) NULL)) - { - uclear_queue (&sDaemon); - sstat.ttype = STATUS_FAILED; - sstat.ilast = ixsysdep_time ((long *) NULL); - (void) fsysdep_set_status (qsys, &sstat); - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - return FALSE; - } - - if (zlog == NULL) - { - zlog = zbufalc (sizeof "protocol ''" + 1); - sprintf (zlog, "protocol '%c'", sDaemon.qproto->bname); - } - - zgrade = zbufalc (sizeof "grade " + 1); - if (sDaemon.bgrade == UUCONF_GRADE_LOW) - *zgrade = '\0'; - else - sprintf (zgrade, "grade %c ", sDaemon.bgrade); - - /* If we are using HAVE_HDB_LOGGING, then the previous ``incoming - call'' message went to the general log, since we didn't know the - system name at that point. In that case, we repeat the port and - login names. */ -#if HAVE_HDB_LOGGING - ulog (LOG_NORMAL, "Handshake successful (login %s port %s %s%s)", - zlogin, - zLdevice == NULL ? "unknown" : zLdevice, - zgrade, zlog); -#else /* ! HAVE_HDB_LOGGING */ - ulog (LOG_NORMAL, "Handshake successful (%s%s)", zgrade, zlog); -#endif /* ! HAVE_HDB_LOGGING */ - - ubuffree (zlog); - ubuffree (zgrade); - - { - long iend_time; - - fret = floop (&sDaemon); - - /* Hangup. As the answerer, we send seven O's and expect to - receive six O's. We send the seven O's twice to help the other - side. We don't worry about errors here. */ - if (fsend_uucp_cmd (qconn, "OOOOOOO") - && fsend_uucp_cmd (qconn, "OOOOOOO")) - { - int fdone; - - /* We look for the remote hangup string to ensure that the - modem has sent out our hangup string. This is only - necessary because some versions of UUCP complain if they - don't get the hangup string. We look for the string - several times because supposedly some implementations send - some garbage after the last packet but before the hangup - string. */ - for (i = 0; i < 25; i++) - { - zstr = zget_uucp_cmd (qconn, FALSE, fstrip); - if (zstr == NULL) - break; - fdone = strstr (zstr, "OOOOOO") != NULL; - ubuffree (zstr); - if (fdone) - break; - } - } - - iend_time = ixsysdep_time ((long *) NULL); - - ulog (LOG_NORMAL, "Call complete (%ld seconds %ld bytes %ld bps)", - iend_time - istart_time, - sDaemon.csent + sDaemon.creceived, - (iend_time != istart_time - ? (sDaemon.csent + sDaemon.creceived) / (iend_time - istart_time) - : 0)); - - uclear_queue (&sDaemon); - - if (fret) - sstat.ttype = STATUS_COMPLETE; - else - sstat.ttype = STATUS_FAILED; - sstat.ilast = iend_time; - (void) fsysdep_set_status (qsys, &sstat); - - if (sDaemon.irunuuxqt == UUCONF_RUNUUXQT_PERCALL - || (sDaemon.irunuuxqt > 0 && sDaemon.cxfiles_received > 0)) - (void) fspawn_uuxqt (TRUE, qsys->uuconf_zname, zconfig); - - uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc); - - return fret; - } -} - -/* Clean up after faccept_call. */ - -static void -uaccept_call_cleanup (puuconf, qfreesys, qport, qfreeport, zloc) - pointer puuconf; - struct uuconf_system *qfreesys; - struct uuconf_port *qport; - struct uuconf_port *qfreeport; - char *zloc; -{ - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - if (qfreesys != NULL) - (void) uuconf_system_free (puuconf, qfreesys); - if (qport == qfreeport) - (void) uuconf_port_free (puuconf, qfreeport); - xfree ((pointer) zloc); - ulog_system ((const char *) NULL); -} - -/* Apply protocol parameters, once we know the protocol. */ - -static void -uapply_proto_params (puuconf, bproto, qcmds, pas) - pointer puuconf; - int bproto; - struct uuconf_cmdtab *qcmds; - struct uuconf_proto_param *pas; -{ - struct uuconf_proto_param *qp; - - for (qp = pas; qp->uuconf_bproto != '\0'; qp++) - { - if (qp->uuconf_bproto == bproto) - { - struct uuconf_proto_param_entry *qe; - - for (qe = qp->uuconf_qentries; qe->uuconf_cargs > 0; qe++) - { - int iuuconf; - - iuuconf = uuconf_cmd_args (puuconf, qe->uuconf_cargs, - qe->uuconf_pzargs, qcmds, - (pointer) NULL, - (uuconf_cmdtabfn) NULL, 0, - (pointer) NULL); - if (UUCONF_ERROR_VALUE (iuuconf) != UUCONF_SUCCESS) - { - ulog (LOG_ERROR, "Error in %c protocol parameters", - bproto); - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - } - } - - break; - } - } -} - -/* Send a string to the other system beginning with a DLE - character and terminated with a null byte. This is only - used when no protocol is in force. */ - -static boolean -fsend_uucp_cmd (qconn, z) - struct sconnection *qconn; - const char *z; -{ - size_t cwrite; - char *zalc; - boolean fret; - - DEBUG_MESSAGE1 (DEBUG_HANDSHAKE, "fsend_uucp_cmd: Sending \"%s\"", z); - - cwrite = strlen (z) + 2; - - zalc = zbufalc (cwrite); - zalc[0] = '\020'; - memcpy (zalc + 1, z, cwrite - 1); - - fret = fconn_write (qconn, zalc, cwrite); - ubuffree (zalc); - return fret; -} - -/* Get a UUCP command beginning with a DLE character and ending with a - null byte. This is only used when no protocol is in force. This - implementation has the potential of being seriously slow. It also - doesn't have any real error recovery. The frequired argument is - passed as TRUE if we need the string; we don't care that much if - we're closing down the connection anyhow. */ - -#define CTIMEOUT (120) -#define CSHORTTIMEOUT (10) -#define CINCREMENT (100) - -static char * -zget_uucp_cmd (qconn, frequired, fstrip) - struct sconnection *qconn; - boolean frequired; - boolean fstrip; -{ - char *zalc; - size_t calc; - size_t cgot; - boolean fintro; - long iendtime; - int ctimeout; -#if DEBUG > 1 - int cchars; - int iolddebug; -#endif - - iendtime = ixsysdep_time ((long *) NULL); - if (frequired) - iendtime += CTIMEOUT; - else - iendtime += CSHORTTIMEOUT; - -#if DEBUG > 1 - cchars = 0; - iolddebug = iDebug; - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \""); - iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT); - } -#endif - - zalc = NULL; - calc = 0; - cgot = 0; - fintro = FALSE; - while ((ctimeout = (int) (iendtime - ixsysdep_time ((long *) NULL))) > 0) - { - int b; - - b = breceive_char (qconn, ctimeout, frequired); - /* Now b == -1 on timeout, -2 on error. */ - if (b < 0) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\" (%s)", - b == -1 ? "timeout" : "error"); - iDebug = iolddebug; - } -#endif - if (b == -1 && frequired) - ulog (LOG_ERROR, "Timeout"); - ubuffree (zalc); - return NULL; - } - - /* Apparently some systems use parity on these strings, so we - optionally strip the parity bit. */ - if (fstrip) - b &= 0x7f; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - char ab[5]; - - ++cchars; - if (cchars > 60) - { - ulog (LOG_DEBUG_END, "\""); - ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \""); - cchars = 0; - } - (void) cdebug_char (ab, b); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } -#endif - - if (! fintro) - { - if (b == '\020') - fintro = TRUE; - continue; - } - - /* If we see another DLE, something has gone wrong; continue - as though this were the first one we saw. */ - if (b == '\020') - { - cgot = 0; - continue; - } - - /* Some systems send a trailing \n on the Shere line. As far as - I can tell this line can never contain a \n, so this - modification should be safe enough. */ - if (b == '\r' || b == '\n') - b = '\0'; - - if (cgot >= calc) - { - char *znew; - - calc += CINCREMENT; - znew = zbufalc (calc); - if (cgot > 0) - memcpy (znew, zalc, cgot); - ubuffree (zalc); - zalc = znew; - } - - zalc[cgot] = (char) b; - ++cgot; - - if (b == '\0') - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\""); - iDebug = iolddebug; - } -#endif - return zalc; - } - } - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\" (timeout)"); - iDebug = iolddebug; - } -#endif - - ubuffree (zalc); - - if (frequired) - ulog (LOG_ERROR, "Timeout"); - return NULL; -} - -/* Read a sequence of characters up to a newline or carriage return, - and return the line without the line terminating character. - Remember whether the last string we returned ended in \r; if it - did, ignore a leading \n to account for \r\n pairs. */ - -static char * -zget_typed_line (qconn, fstrip) - struct sconnection *qconn; - boolean fstrip; -{ - static boolean flastcr; - char *zalc; - size_t calc; - size_t cgot; - -#if DEBUG > 1 - int cchars; - int iolddebug; - - cchars = 0; - iolddebug = iDebug; - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_START, "zget_typed_line: Got \""); - iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT); - } -#endif - - zalc = NULL; - calc = 0; - cgot = 0; - while (TRUE) - { - int b; - - b = breceive_char (qconn, CTIMEOUT, FALSE); - - /* Now b == -1 on timeout, -2 on error. */ - - if (b == -2 || FGOT_SIGNAL ()) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_END, "\" (error)"); - iDebug = iolddebug; - } -#endif - ubuffree (zalc); - flastcr = FALSE; - return NULL; - } - - if (b == -1) - { - flastcr = FALSE; - continue; - } - - /* Optionally strip the parity bit. */ - if (fstrip) - b &= 0x7f; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - char ab[5]; - - ++cchars; - if (cchars > 60) - { - ulog (LOG_DEBUG_END, "\""); - ulog (LOG_DEBUG_START, "zget_typed_line: Got \""); - cchars = 0; - } - (void) cdebug_char (ab, b); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } -#endif - - if (b == '\n' && cgot == 0 && flastcr) - { - /* Ignore \n in \r\n pair. */ - flastcr = FALSE; - continue; - } - - flastcr = FALSE; - - if (cgot >= calc) - { - char *znew; - - calc += CINCREMENT; - znew = zbufalc (calc); - if (cgot > 0) - memcpy (znew, zalc, cgot); - ubuffree (zalc); - zalc = znew; - } - - if (b == '\n') - b = '\0'; - else if (b == '\r') - { - flastcr = TRUE; - b = '\0'; - } - - zalc[cgot] = (char) b; - ++cgot; - - if (b == '\0') - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_END, "\""); - iDebug = iolddebug; - } -#endif - return zalc; - } - } -} - -/* Spawn a uuxqt job. This probably belongs in some other file, but I - don't have a good place for it. */ - -boolean -fspawn_uuxqt (ffork, zsys, zconfig) - boolean ffork; - const char *zsys; - const char *zconfig; -{ - char *zsysarg; - char *zconfigarg; - boolean fret; - - if (zsys == NULL) - zsysarg = NULL; - else - { - zsysarg = zbufalc (sizeof "-s" + strlen (zsys)); - sprintf (zsysarg, "-s%s", zsys); - } - - if (zconfig == NULL) - zconfigarg = NULL; - else - { - zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig)); - sprintf (zconfigarg, "-I%s", zconfig); - if (zsysarg == NULL) - { - zsysarg = zconfigarg; - zconfigarg = NULL; - } - } - - fret = fsysdep_run (ffork, "uuxqt", zsysarg, zconfigarg); - - ubuffree (zsysarg); - ubuffree (zconfigarg); - - return fret; -} diff --git a/gnu/libexec/uucp/uucico/xcmd.c b/gnu/libexec/uucp/uucico/xcmd.c deleted file mode 100644 index f29bb5e..0000000 --- a/gnu/libexec/uucp/uucico/xcmd.c +++ /dev/null @@ -1,401 +0,0 @@ -/* xcmd.c - Routines to handle work requests. - - Copyright (C) 1991, 1992, 1993, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char xcmd_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "prot.h" -#include "trans.h" - -/* Local functions. */ - -static boolean flocal_xcmd_request P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); -static boolean flocal_xcmd_await_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon, - const char *zdata, size_t cdata)); -static boolean fremote_xcmd_reply P((struct stransfer *qtrans, - struct sdaemon *qdaemon)); - -/* Handle a local work request. We just set up the request for - transmission. */ - -boolean -flocal_xcmd_init (qdaemon, qcmd) - struct sdaemon *qdaemon; - struct scmd *qcmd; -{ - struct stransfer *qtrans; - - qtrans = qtransalc (qcmd); - qtrans->psendfn = flocal_xcmd_request; - - return fqueue_local (qdaemon, qtrans); -} - -/* Send the execution request to the remote system. */ - -static boolean -flocal_xcmd_request (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - size_t clen; - char *zsend; - boolean fret; - - ulog (LOG_NORMAL, "Requesting work: %s to %s", qtrans->s.zfrom, - qtrans->s.zto); - - - qtrans->fcmd = TRUE; - qtrans->precfn = flocal_xcmd_await_reply; - - if (! fqueue_receive (qdaemon, qtrans)) - return FALSE; - - /* We send the string - X from to user options - We put a dash in front of options. */ - clen = (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto) - + strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) + 7); - zsend = zbufalc (clen); - sprintf (zsend, "X %s %s %s -%s", qtrans->s.zfrom, qtrans->s.zto, - qtrans->s.zuser, qtrans->s.zoptions); - - fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal, - qtrans->iremote); - ubuffree (zsend); - - /* If fret is FALSE, we should free qtrans here, but see the comment - at the end of flocal_rec_send_request. */ - - return fret; -} - -/* Get a reply to an execution request from the remote system. */ - -/*ARGSUSED*/ -static boolean -flocal_xcmd_await_reply (qtrans, qdaemon, zdata, cdata) - struct stransfer *qtrans; - struct sdaemon *qdaemon; - const char *zdata; - size_t cdata; -{ - qtrans->precfn = NULL; - - if (zdata[0] != 'X' - || (zdata[1] != 'Y' && zdata[1] != 'N')) - { - ulog (LOG_ERROR, "Bad response to work request"); - utransfree (qtrans); - return FALSE; - } - - if (zdata[1] == 'N') - { - ulog (LOG_ERROR, "%s: work request denied", qtrans->s.zfrom); - (void) fmail_transfer (FALSE, qtrans->s.zuser, (const char *) NULL, - "work request denied", - qtrans->s.zfrom, qdaemon->qsys->uuconf_zname, - qtrans->s.zto, (const char *) NULL, - (const char *) NULL); - } - - (void) fsysdep_did_work (qtrans->s.pseq); - utransfree (qtrans); - - return TRUE; -} - -/* Handle a remote work request. This just queues up the requests for - later processing. */ - -boolean -fremote_xcmd_init (qdaemon, qcmd, iremote) - struct sdaemon *qdaemon; - struct scmd *qcmd; - int iremote; -{ - const struct uuconf_system *qsys; - const char *zexclam; - const struct uuconf_system *qdestsys; - struct uuconf_system sdestsys; - char *zdestfile; - boolean fmkdirs; - struct stransfer *qtrans; - char *zuser; - char aboptions[5]; - char *zfrom; - boolean fret; - char *zfile; - - ulog (LOG_NORMAL, "Work requested: %s to %s", qcmd->zfrom, - qcmd->zto); - - qsys = qdaemon->qsys; - - zexclam = strchr (qcmd->zto, '!'); - if (zexclam == NULL - || zexclam == qcmd->zto - || strncmp (qdaemon->zlocalname, qcmd->zto, - (size_t) (zexclam - qcmd->zto)) == 0) - { - const char *zconst; - - /* The files are supposed to be copied to the local system. */ - qdestsys = NULL; - if (zexclam == NULL) - zconst = qcmd->zto; - else - zconst = zexclam + 1; - - zdestfile = zsysdep_local_file (zconst, qsys->uuconf_zpubdir, - (boolean *) NULL); - if (zdestfile == NULL) - return FALSE; - - zuser = NULL; - fmkdirs = strchr (qcmd->zoptions, 'f') != NULL; - } - else - { - size_t clen; - char *zcopy; - int iuuconf; - char *zoptions; - - clen = zexclam - qcmd->zto; - zcopy = zbufalc (clen + 1); - memcpy (zcopy, qcmd->zto, clen); - zcopy[clen] = '\0'; - - iuuconf = uuconf_system_info (qdaemon->puuconf, zcopy, &sdestsys); - if (iuuconf == UUCONF_NOT_FOUND) - { - if (! funknown_system (qdaemon->puuconf, zcopy, &sdestsys)) - { - ulog (LOG_ERROR, "%s: System not found", zcopy); - ubuffree (zcopy); - qtrans = qtransalc (qcmd); - qtrans->psendfn = fremote_xcmd_reply; - qtrans->pinfo = (pointer) "XN"; - qtrans->iremote = iremote; - return fqueue_remote (qdaemon, qtrans); - } - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, qdaemon->puuconf, iuuconf); - ubuffree (zcopy); - return FALSE; - } - - ubuffree (zcopy); - - qdestsys = &sdestsys; - zdestfile = zbufcpy (zexclam + 1); - - zuser = zbufalc (strlen (qdestsys->uuconf_zname) - + strlen (qcmd->zuser) + sizeof "!"); - sprintf (zuser, "%s!%s", qdestsys->uuconf_zname, qcmd->zuser); - zoptions = aboptions; - *zoptions++ = 'C'; - if (strchr (qcmd->zoptions, 'd') != NULL) - *zoptions++ = 'd'; - if (strchr (qcmd->zoptions, 'm') != NULL) - *zoptions++ = 'm'; - *zoptions = '\0'; - fmkdirs = TRUE; - } - - /* At this point we prepare to confirm the remote request. We could - actually fork here and let the child spool up the requests. */ - qtrans = qtransalc (qcmd); - qtrans->psendfn = fremote_xcmd_reply; - qtrans->pinfo = (pointer) "XY"; - qtrans->iremote = iremote; - if (! fqueue_remote (qdaemon, qtrans)) - { - ubuffree (zdestfile); - ubuffree (zuser); - return FALSE; - } - - /* Now we have to process each source file. The source - specification may or may use wildcards. */ - zfrom = zsysdep_local_file (qcmd->zfrom, qsys->uuconf_zpubdir, - (boolean *) NULL); - if (zfrom == NULL) - { - ubuffree (zdestfile); - ubuffree (zuser); - return FALSE; - } - - if (! fsysdep_wildcard_start (zfrom)) - { - ubuffree (zfrom); - ubuffree (zdestfile); - ubuffree (zuser); - return FALSE; - } - - fret = TRUE; - - while ((zfile = zsysdep_wildcard (zfrom)) != NULL) - { - char *zto; - char abtname[CFILE_NAME_LEN]; - - if (! fsysdep_file_exists (zfile)) - { - ulog (LOG_ERROR, "%s: no such file", zfile); - continue; - } - - /* Make sure the remote system is permitted to read the - specified file. */ - if (! fin_directory_list (zfile, qsys->uuconf_pzremote_send, - qsys->uuconf_zpubdir, TRUE, TRUE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "%s: not permitted to send", zfile); - break; - } - - if (qdestsys != NULL) - { - /* We really should get the original grade here. */ - zto = zsysdep_data_file_name (qdestsys, qdaemon->zlocalname, - BDEFAULT_UUCP_GRADE, FALSE, - abtname, (char *) NULL, - (char *) NULL); - if (zto == NULL) - { - fret = FALSE; - break; - } - } - else - { - zto = zsysdep_add_base (zdestfile, zfile); - if (zto == NULL) - { - fret = FALSE; - break; - } - /* We only accept a local destination if the remote system - has the right to create files there. */ - if (! fin_directory_list (zto, qsys->uuconf_pzremote_receive, - qsys->uuconf_zpubdir, TRUE, FALSE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "%s: not permitted to receive", zto); - ubuffree (zto); - break; - } - } - - /* Copy the file either to the final destination or to the - spool directory. */ - if (! fcopy_file (zfile, zto, qdestsys == NULL, fmkdirs, FALSE)) - { - ubuffree (zto); - break; - } - - ubuffree (zto); - - /* If there is a destination system, queue it up. */ - if (qdestsys != NULL) - { - struct scmd ssend; - char *zjobid; - - ssend.bcmd = 'S'; - ssend.bgrade = BDEFAULT_UUCP_GRADE; - ssend.pseq = NULL; - ssend.zfrom = zfile; - ssend.zto = zdestfile; - ssend.zuser = zuser; - ssend.zoptions = aboptions; - ssend.ztemp = abtname; - ssend.imode = ixsysdep_file_mode (zfile); - ssend.znotify = ""; - ssend.cbytes = -1; - ssend.zcmd = NULL; - ssend.ipos = 0; - - zjobid = zsysdep_spool_commands (qdestsys, BDEFAULT_UUCP_GRADE, - 1, &ssend); - if (zjobid == NULL) - break; - ubuffree (zjobid); - } - - ubuffree (zfile); - } - - if (zfile != NULL) - ubuffree (zfile); - - (void) fsysdep_wildcard_end (); - - ubuffree (zdestfile); - if (qdestsys != NULL) - (void) uuconf_system_free (qdaemon->puuconf, &sdestsys); - - ubuffree (zfrom); - ubuffree (zuser); - - return fret; -} - -/* Reply to a remote work request. */ - -static boolean -fremote_xcmd_reply (qtrans, qdaemon) - struct stransfer *qtrans; - struct sdaemon *qdaemon; -{ - boolean fret; - - fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, - (const char *) qtrans->pinfo, - qtrans->ilocal, - qtrans->iremote); - utransfree (qtrans); - return fret; -} diff --git a/gnu/libexec/uucp/uuconv/Makefile b/gnu/libexec/uucp/uuconv/Makefile deleted file mode 100644 index 02df55c..0000000 --- a/gnu/libexec/uucp/uuconv/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for uuconv -# $FreeBSD$ - -BINDIR= $(sbindir) - -PROG= uuconv -SRCS= uuconv.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -I$(.CURDIR)/../libuuconf\ - -DVERSION=\"$(VERSION)\" - -.include <bsd.prog.mk> diff --git a/gnu/libexec/uucp/uuconv/uuconv.1 b/gnu/libexec/uucp/uuconv/uuconv.1 deleted file mode 100644 index 548dbdf..0000000 --- a/gnu/libexec/uucp/uuconv/uuconv.1 +++ /dev/null @@ -1,57 +0,0 @@ -.\" $FreeBSD$ -.TH uuconv 1 "Taylor UUCP 1.06" -.SH NAME -uuconv \- convert UUCP configuration files -.SH SYNOPSIS -.B uuconv -\-i type \-o type [-p program] [standard UUCP options] -.SH DESCRIPTION -The -.B uuconv -program can be used to convert UUCP configuration -files from one format to another. This can be useful for -administrators converting from an older UUCP package. Taylor UUCP -is able to read and use old configuration file formats, but some -new features can not be selected using the old formats. -.PP -The type of configuration file to read is specified -using the `-i' or `--input' options. The type of configuration file to -write is specified using the `-o' or `--output' options. -.PP -The supported configuration file types are `taylor', `v2', and -`hdb'. For a description of the `taylor' configuration files, see -*Note Configuration Files::. The other types of configuration files -are used by traditional UUCP packages, and are not described in this -manual. -.PP -An input configuration of type `v2' or `hdb' is read from a compiled -in directory (specified by `oldconfigdir' in `Makefile'). An input -configuration of type `taylor' is read from a compiled in directory by -default, but may be overridden with the standard `-I' or `--config' -options. -.PP -The output configuration is written to files in the directory in -which -.B uuconv -is run. -.PP -Some information in the input files may not be representable in the -desired output format, in which case -.B uuconv -will silently discard it. -The output of -.B uuconv -should be carefully checked before it is used. -The -.B uuchk(8) -program may be used for this purpose. -.PP -The `-p' or `--program' option may be used to convert specific `cu' -configuration information, rather than the default of only converting -the `uucp' configuration information. -.SH SEE ALSO -cu(1), uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. - diff --git a/gnu/libexec/uucp/uuconv/uuconv.c b/gnu/libexec/uucp/uuconv/uuconv.c deleted file mode 100644 index 701ea3d..0000000 --- a/gnu/libexec/uucp/uuconv/uuconv.c +++ /dev/null @@ -1,2106 +0,0 @@ -/* uuconv.c - Convert one type of UUCP configuration file to another. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucnfi.h" - -#if USE_RCS_ID -const char uuconv_rcsid[] = "$FreeBSD$"; -#endif - -#include "getopt.h" - -/* Local functions. */ - -static void uvusage P((void)); -static void uvhelp P((void)); -static void uvwrite_time P((FILE *e, struct uuconf_timespan *qtime)); -static void uvwrite_string P((FILE *e, const char *zarg, const char *zcmd)); -static void uvwrite_size P((FILE *e, struct uuconf_timespan *qsize, - const char *zcmd)); -static void uvwrite_boolean P((FILE *e, int iarg, const char *zcmd)); -static void uvwrite_string_array P((FILE *e, char **pz, const char *zcmd)); -static void uvwrite_chat_script P((FILE *e, char **pz)); -static void uvwrite_chat P((FILE *e, const struct uuconf_chat *qchat, - const struct uuconf_chat *qlast, - const char *zprefix, boolean fforce)); -static void uvwrite_proto_params P((FILE *e, - const struct uuconf_proto_param *qparam, - const char *zprefix)); -static void uvwrite_taylor_system P((FILE *e, - const struct uuconf_system *qsys)); -static void uvwrite_v2_system P((FILE *e, - const struct uuconf_system *qsys)); -static void uvwrite_hdb_system P((FILE *e, - const struct uuconf_system *qsys)); -static boolean fvperm_string_cmp P((const char *z1, const char *z2)); -static boolean fvperm_array_cmp P((const char **pz1, const char **pz2)); -static void uvadd_perm P((struct shpermissions *qadd)); -static void uvwrite_perms P((void)); -static void uvwrite_perm_array P((FILE *e, const char **pz, - const char *zcmd, size_t *pccol)); -static void uvwrite_perm_boolean P((FILE *e, int f, const char *zcmd, - size_t *pccol, boolean fsendfiles)); -static void uvwrite_perm_rw_array P((FILE *e, const char **pz, - const char *zcmd, size_t *pccol)); -static void uvwrite_perm_string P((FILE *e, const char *z, const char *zcmd, - size_t *pccol)); -static int ivwrite_taylor_port P((struct uuconf_port *qport, - pointer pinfo)); -static int ivwrite_v2_port P((struct uuconf_port *qport, pointer pinfo)); -static int ivwrite_hdb_port P((struct uuconf_port *qport, pointer pinfo)); -static void uvwrite_taylor_port P((FILE *e, struct uuconf_port *qport, - const char *zprefix)); -static void uvwrite_taylor_dialer P((FILE *e, struct uuconf_dialer *qdialer, - const char *zprefix)); -static void uvwrite_hdb_dialer P((FILE *e, struct uuconf_dialer *qdialer)); -static void uvuuconf_error P((pointer puuconf, int iret)); - -/* The program name. */ -const char *zProgram; - -/* A list of Permissions entries built when writing out HDB system - information. */ -static struct shpermissions *qVperms; - -/* Type of configuration file. */ -enum tconfig -{ - CONFIG_TAYLOR, - CONFIG_V2, - CONFIG_HDB -}; - -/* Long getopt options. */ -static const struct option asVlongopts[] = -{ - { "input", required_argument, NULL, 'i' }, - { "output", required_argument, NULL, 'o' }, - { "program", required_argument, NULL, 'p' }, - { "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) - int argc; - char **argv; -{ - /* -I: The configuration file name. */ - const char *zconfig = NULL; - /* -i: Input type. */ - const char *zinput = NULL; - /* -o: Output type. */ - const char *zoutput = NULL; - /* -p: Program name. */ - const char *zprogram = NULL; - int iopt; - enum tconfig tinput, toutput; - int iret; - pointer pinput; - - zProgram = argv[0]; - - while ((iopt = getopt_long (argc, argv, "i:I:o:p:vx:", asVlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'i': - /* Input type. */ - zinput = optarg; - break; - - case 'o': - /* Output type. */ - zoutput = optarg; - break; - - case 'p': - /* Program name. */ - zprogram = optarg; - break; - - case 'I': - /* Set the configuration file name. */ - zconfig = optarg; - break; - - case 'x': - /* Set the debugging level. */ - break; - - case 'v': - /* Print version and exit. */ - fprintf - (stderr, - "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - uvhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found, and flag value set. */ - break; - - default: - uvusage (); - break; - } - } - - if (optind != argc - || zinput == NULL - || zoutput == NULL) - uvusage (); - - if (strcasecmp (zinput, "taylor") == 0) - tinput = CONFIG_TAYLOR; - else if (strcasecmp (zinput, "v2") == 0) - tinput = CONFIG_V2; - else if (strcasecmp (zinput, "hdb") == 0) - tinput = CONFIG_HDB; - else - { - uvusage (); - tinput = CONFIG_TAYLOR; - } - - if (strcasecmp (zoutput, "taylor") == 0) - toutput = CONFIG_TAYLOR; - else if (strcasecmp (zoutput, "v2") == 0) - toutput = CONFIG_V2; - else if (strcasecmp (zoutput, "hdb") == 0) - toutput = CONFIG_HDB; - else - { - uvusage (); - toutput = CONFIG_TAYLOR; - } - - if (tinput == toutput) - uvusage (); - - iret = UUCONF_SUCCESS; - - /* Initialize the input. */ - pinput = NULL; - switch (tinput) - { - case CONFIG_TAYLOR: - iret = uuconf_taylor_init (&pinput, zprogram, zconfig); - break; - case CONFIG_V2: - iret = uuconf_v2_init (&pinput); - break; - case CONFIG_HDB: - iret = uuconf_hdb_init (&pinput, zprogram); - break; - } - if (iret != UUCONF_SUCCESS) - { - uvuuconf_error (pinput, iret); - exit (EXIT_FAILURE); - } - - { - char **pzsystems; - char *zsys; - char abtaylor[sizeof ZCURDIR + sizeof SYSFILE - 1]; - char abv2[sizeof ZCURDIR + sizeof V2_SYSTEMS - 1]; - char abhdb[sizeof ZCURDIR + sizeof HDB_SYSTEMS - 1]; - FILE *esys; - char **pz; - - /* Get the list of systems. */ - switch (tinput) - { - case CONFIG_TAYLOR: - iret = uuconf_taylor_system_names (pinput, &pzsystems, FALSE); - break; - case CONFIG_V2: - iret = uuconf_v2_system_names (pinput, &pzsystems, FALSE); - break; - case CONFIG_HDB: - iret = uuconf_hdb_system_names (pinput, &pzsystems, FALSE); - break; - } - if (iret != UUCONF_SUCCESS) - uvuuconf_error (pinput, iret); - else - { - /* Open the sys file for the output type. */ - switch (toutput) - { - default: - case CONFIG_TAYLOR: - sprintf (abtaylor, "%s%s", ZCURDIR, SYSFILE); - zsys = abtaylor; - break; - case CONFIG_V2: - sprintf (abv2, "%s%s", ZCURDIR, V2_SYSTEMS); - zsys = abv2; - break; - case CONFIG_HDB: - sprintf (abhdb, "%s%s", ZCURDIR, HDB_SYSTEMS); - zsys = abhdb; - break; - } - esys = fopen (zsys, "w"); - if (esys == NULL) - { - fprintf (stderr, "uuchk:%s: ", zsys); - perror ("fopen"); - exit (EXIT_FAILURE); - } - - fprintf (esys, "# %s file automatically generated by uuconv.\n", - zsys); - - /* Read and write each system. We cheat and call the internal - routines, so that we can easily detect default information and - not write it out. This isn't necessary, but it makes the output - smaller and simpler. */ - for (pz = pzsystems; *pz != NULL; pz++) - { - struct uuconf_system ssys; - - switch (tinput) - { - case CONFIG_TAYLOR: - iret = _uuconf_itaylor_system_internal (pinput, *pz, &ssys); - break; - case CONFIG_V2: - iret = _uuconf_iv2_system_internal (pinput, *pz, &ssys); - break; - case CONFIG_HDB: - iret = _uuconf_ihdb_system_internal (pinput, *pz, &ssys); - break; - } - if (iret != UUCONF_SUCCESS) - uvuuconf_error (pinput, iret); - else - { - switch (toutput) - { - case CONFIG_TAYLOR: - uvwrite_taylor_system (esys, &ssys); - break; - case CONFIG_V2: - uvwrite_v2_system (esys, &ssys); - break; - case CONFIG_HDB: - uvwrite_hdb_system (esys, &ssys); - break; - } - if (toutput != CONFIG_HDB) - (void) uuconf_system_free (pinput, &ssys); - } - } - - if (toutput == CONFIG_HDB) - uvwrite_perms (); - - if (ferror (esys) - || fclose (esys) == EOF) - { - fprintf (stderr, "uuchk:%s: error during output\n", zsys); - exit (EXIT_FAILURE); - } - } - } - - { - /* Open the port file for the output type. */ - char *zport; - char abtaylor[sizeof ZCURDIR + sizeof PORTFILE - 1]; - char abv2[sizeof ZCURDIR + sizeof V2_DEVICES - 1]; - char abhdb[sizeof ZCURDIR + sizeof HDB_DEVICES - 1]; - FILE *eport; - int (*piportfn) P((struct uuconf_port *, pointer)); - struct uuconf_port sport; - - switch (toutput) - { - default: - case CONFIG_TAYLOR: - sprintf (abtaylor, "%s%s", ZCURDIR, PORTFILE); - zport = abtaylor; - piportfn = ivwrite_taylor_port; - break; - case CONFIG_V2: - sprintf (abv2, "%s%s", ZCURDIR, V2_DEVICES); - zport = abv2; - piportfn = ivwrite_v2_port; - break; - case CONFIG_HDB: - sprintf (abhdb, "%s%s", ZCURDIR, HDB_DEVICES); - zport = abhdb; - piportfn = ivwrite_hdb_port; - break; - } - eport = fopen (zport, "w"); - if (eport == NULL) - { - fprintf (stderr, "uuchk:%s: ", zport); - perror ("fopen"); - exit (EXIT_FAILURE); - } - - fprintf (eport, "# %s file automatically generated by uuconv.\n", zport); - - switch (tinput) - { - case CONFIG_TAYLOR: - iret = uuconf_taylor_find_port (pinput, (const char *) NULL, 0L, - 0L, piportfn, (pointer) eport, - &sport); - break; - case CONFIG_V2: - iret = uuconf_v2_find_port (pinput, (const char *) NULL, 0L, 0L, - piportfn, (pointer) eport, &sport); - break; - case CONFIG_HDB: - iret = uuconf_hdb_find_port (pinput, (const char *) NULL, 0L, 0L, - piportfn, (pointer) eport, &sport); - break; - } - - if (iret != UUCONF_NOT_FOUND) - uvuuconf_error (pinput, iret); - - if (ferror (eport) - || fclose (eport) == EOF) - { - fprintf (stderr, "uuchk:%s: error during output\n", zport); - exit (EXIT_FAILURE); - } - } - - /* V2 configuration files don't support dialers. */ - if (tinput != CONFIG_V2 && toutput != CONFIG_V2) - { - char **pzdialers; - char *zdialer; - char abtaylor[sizeof ZCURDIR + sizeof DIALFILE - 1]; - char abhdb[sizeof ZCURDIR + sizeof HDB_DIALERS - 1]; - FILE *edialer; - char **pz; - - /* Get the list of dialers. */ - switch (tinput) - { - default: - case CONFIG_TAYLOR: - iret = uuconf_taylor_dialer_names (pinput, &pzdialers); - break; - case CONFIG_HDB: - iret = uuconf_hdb_dialer_names (pinput, &pzdialers); - break; - } - if (iret != UUCONF_SUCCESS) - uvuuconf_error (pinput, iret); - else - { - /* Open the sys file for the output type. */ - switch (toutput) - { - default: - case CONFIG_TAYLOR: - sprintf (abtaylor, "%s%s", ZCURDIR, DIALFILE); - zdialer = abtaylor; - break; - case CONFIG_HDB: - sprintf (abhdb, "%s%s", ZCURDIR, HDB_DIALERS); - zdialer = abhdb; - break; - } - edialer = fopen (zdialer, "w"); - if (edialer == NULL) - { - fprintf (stderr, "uuchk:%s: ", zdialer); - perror ("fopen"); - exit (EXIT_FAILURE); - } - - fprintf (edialer, "# %s file automatically generated by uuconv.\n", - zdialer); - - /* Read and write each dialer. */ - for (pz = pzdialers; *pz != NULL; pz++) - { - struct uuconf_dialer sdialer; - - switch (tinput) - { - default: - case CONFIG_TAYLOR: - iret = uuconf_taylor_dialer_info (pinput, *pz, &sdialer); - break; - case CONFIG_HDB: - iret = uuconf_hdb_dialer_info (pinput, *pz, &sdialer); - break; - } - if (iret != UUCONF_SUCCESS) - uvuuconf_error (pinput, iret); - else - { - switch (toutput) - { - default: - case CONFIG_TAYLOR: - fprintf (edialer, "# Start of dialer %s\n", - sdialer.uuconf_zname); - fprintf (edialer, "dialer %s\n", sdialer.uuconf_zname); - uvwrite_taylor_dialer (edialer, &sdialer, ""); - break; - case CONFIG_HDB: - uvwrite_hdb_dialer (edialer, &sdialer); - break; - } - (void) uuconf_dialer_free (pinput, &sdialer); - } - } - - if (ferror (edialer) - || fclose (edialer) == EOF) - { - fprintf (stderr, "uuchk:%s: error during output\n", zdialer); - exit (EXIT_FAILURE); - } - } - } - - exit (EXIT_SUCCESS); - - /* Avoid complaints about not returning. */ - return 0; -} - -/* Print out a usage message and die. */ - -static void -uvusage () -{ - fprintf (stderr, "Usage: %s -i input-type -o output-type [-p program]\n", - zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void -uvhelp () -{ - fprintf (stderr, - "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - fprintf (stderr, "Converts UUCP configuration files from one format to another.\n"); - fprintf (stderr, - "Usage: %s -i input -o output [-p program] [-I file]\n", zProgram); - fprintf (stderr, - " -i,--input input: Set input type (one of taylor, v2, hdb)\n"); - fprintf (stderr, - " -o,--output output: Set output type (one of taylor, v2, hdb)\n"); - fprintf (stderr, - " -p,--program program: Program to convert (e.g., uucp or cu)\n"); - fprintf (stderr, - " -I,--config file: Set Taylor UUCP configuration file to use\n"); - fprintf (stderr, - " -v,--version: Print version and exit\n"); - fprintf (stderr, - " --help: Print help and exit\n"); -} - -/* Write out a timespan. */ - -static void -uvwrite_time (e, qtime) - FILE *e; - struct uuconf_timespan *qtime; -{ - if (qtime == NULL) - { - fprintf (e, "Never"); - return; - } - - if (qtime->uuconf_istart == 0 && qtime->uuconf_iend == 7 * 24 * 60) - { - fprintf (e, "Any"); - return; - } - - for (; qtime != NULL; qtime = qtime->uuconf_qnext) - { - int idaystart, idayend; - int ihourstart, ihourend; - int iminutestart, iminuteend; - const char * const zdays = "Su\0Mo\0Tu\0We\0Th\0Fr\0Sa"; - - idaystart = qtime->uuconf_istart / (24 * 60); - ihourstart = (qtime->uuconf_istart % (24 * 60)) / 60; - iminutestart = qtime->uuconf_istart % 60; - if (qtime->uuconf_iend >= 7 * 24 * 60) - qtime->uuconf_iend = 7 * 24 * 60 - 1; - idayend = qtime->uuconf_iend / (24 * 60); - ihourend = (qtime->uuconf_iend % (24 * 60)) / 60; - iminuteend = qtime->uuconf_iend % 60; - if (ihourend == 0 && iminuteend == 0) - --idayend; - - if (idaystart == idayend) - fprintf (e, "%s%02d%02d-%02d%02d", zdays + idaystart * 3, - ihourstart, iminutestart, ihourend, iminuteend); - else - { - int i; - - fprintf (e, "%s%02d%02d-0000", zdays + idaystart * 3, - ihourstart, iminutestart); - for (i = idaystart + 1; i < idayend; i++) - fprintf (e, ",%s", zdays + i * 3); - if (ihourend != 0 || iminuteend != 0) - fprintf (e, ",%s0000-%02d%02d", zdays + idayend * 3, ihourend, - iminuteend); - } - - if (qtime->uuconf_qnext != NULL) - fprintf (e, ","); - } -} - -/* Some subroutines used when writing out Taylor UUCP configuration - files. */ - -/* Write a command with a string argument. */ - -static void -uvwrite_string (e, zarg, zcmd) - FILE *e; - const char *zarg; - const char *zcmd; -{ - if (zarg != (const char *) &_uuconf_unset) - fprintf (e, "%s %s\n", zcmd, zarg == NULL ? (const char *) "" : zarg); -} - -/* Write out a size restriction command. */ - -static void -uvwrite_size (e, qtime, zcmd) - FILE *e; - struct uuconf_timespan *qtime; - const char *zcmd; -{ - if (qtime != (struct uuconf_timespan *) &_uuconf_unset) - { - for (; qtime != NULL; qtime = qtime->uuconf_qnext) - { - fprintf (e, "%s %ld", zcmd, qtime->uuconf_ival); - uvwrite_time (e, qtime); - fprintf (e, "\n"); - } - } -} - -/* Write out a boolean argument with a string command. If the value - is less than zero, than it was uninitialized and we don't write - anything. */ - -static void -uvwrite_boolean (e, fval, zcmd) - FILE *e; - int fval; - const char *zcmd; -{ - if (fval >= 0) - fprintf (e, "%s %s\n", zcmd, fval > 0 ? "true" : "false"); -} - -/* Write out a string array as a single command. */ - -static void -uvwrite_string_array (e, pz, zcmd) - FILE *e; - char **pz; - const char *zcmd; -{ - if (pz != (char **) &_uuconf_unset) - { - fprintf (e, "%s", zcmd); - if (pz != NULL) - for (; *pz != NULL; pz++) - fprintf (e, " %s", *pz); - fprintf (e, "\n"); - } -} - -/* Write out a chat script. Don't separate subsend/subexpect strings - by spaces. */ - -static void -uvwrite_chat_script (e, pzarg) - FILE *e; - char **pzarg; -{ - char **pz; - - if (pzarg == NULL || pzarg == (char **) &_uuconf_unset) - return; - - for (pz = pzarg; *pz != NULL; pz++) - { - if ((*pz)[0] != '-' && pz != pzarg) - fprintf (e, " "); - fprintf (e, "%s", *pz); - } -} - -/* Write out chat information. If the qlast argument is not NULL, - then only values that are different from qlast should be written. - The fforce argument is used to get around a peculiar problem: if - the ``chat'' command is used with no arguments for a system, then - uuconf_pzchat will be NULL (not &_uuconf_unset) and the default - chat script will not be used. We must distinguish this case from - the ``chat'' command not appearing at all for a port or dialer, in - which case the value will again be NULL. In the former case we - must output a ``chat'' command, in the latter case we would prefer - not to. */ - -static void -uvwrite_chat (e, q, qlast, zprefix, fforce) - FILE *e; - const struct uuconf_chat *q; - const struct uuconf_chat *qlast; - const char *zprefix; - boolean fforce; -{ - char **pz; - char ab[100]; - - if (q->uuconf_pzchat != (char **) &_uuconf_unset - && (qlast == NULL - ? (fforce || q->uuconf_pzchat != NULL) - : qlast->uuconf_pzchat != q->uuconf_pzchat)) - { - fprintf (e, "%schat ", zprefix); - uvwrite_chat_script (e, q->uuconf_pzchat); - fprintf (e, "\n"); - } - - if (q->uuconf_pzprogram != (char **) &_uuconf_unset - && (qlast == NULL - ? q->uuconf_pzprogram != NULL - : qlast->uuconf_pzprogram != q->uuconf_pzprogram)) - { - sprintf (ab, "%schat-program", zprefix); - uvwrite_string_array (e, q->uuconf_pzprogram, ab); - } - - if (q->uuconf_ctimeout >= 0 - && (qlast == NULL - || qlast->uuconf_ctimeout != q->uuconf_ctimeout)) - fprintf (e, "%schat-timeout %d\n", zprefix, q->uuconf_ctimeout); - - if (q->uuconf_pzfail != NULL - && q->uuconf_pzfail != (char **) &_uuconf_unset - && (qlast == NULL - || qlast->uuconf_pzfail != q->uuconf_pzfail)) - for (pz = q->uuconf_pzfail; *pz != NULL; pz++) - fprintf (e, "%schat-fail %s\n", zprefix, *pz); - - if (qlast == NULL || qlast->uuconf_fstrip != q->uuconf_fstrip) - { - sprintf (ab, "%schat-strip", zprefix); - uvwrite_boolean (e, q->uuconf_fstrip, ab); - } -} - -/* Write out protocol parameters to a Taylor UUCP file. */ - -static void -uvwrite_proto_params (e, qparams, zprefix) - FILE *e; - const struct uuconf_proto_param *qparams; - const char *zprefix; -{ - const struct uuconf_proto_param *qp; - - if (qparams == NULL - || qparams == (struct uuconf_proto_param *) &_uuconf_unset) - return; - - for (qp = qparams; qp->uuconf_bproto != '\0'; qp++) - { - const struct uuconf_proto_param_entry *qe; - - for (qe = qp->uuconf_qentries; qe->uuconf_cargs > 0; qe++) - { - int i; - - fprintf (e, "%sprotocol-parameter %c", zprefix, qp->uuconf_bproto); - for (i = 0; i < qe->uuconf_cargs; i++) - fprintf (e, " %s", qe->uuconf_pzargs[i]); - fprintf (e, "\n"); - } - } -} - -/* Write out Taylor UUCP system information. */ - -static void -uvwrite_taylor_system (e, q) - FILE *e; - const struct uuconf_system *q; -{ - char **pz; - const struct uuconf_system *qlast; - - fprintf (e, "# Start of system %s\n", q->uuconf_zname); - - fprintf (e, "system %s\n", q->uuconf_zname); - if (q->uuconf_pzalias != NULL - && q->uuconf_pzalias != (char **) &_uuconf_unset) - for (pz = q->uuconf_pzalias; *pz != NULL; pz++) - uvwrite_string (e, *pz, "alias"); - - for (qlast = NULL; q != NULL; qlast = q, q = q->uuconf_qalternate) - { - struct uuconf_timespan *qtime; - - if (qlast != NULL) - { - fprintf (e, "alternate"); - if (q->uuconf_zalternate != (char *) &_uuconf_unset - && q->uuconf_zalternate != NULL) - fprintf (e, " %s", q->uuconf_zalternate); - fprintf (e, "\n"); - } - -#define CHANGED(x) (qlast == NULL || qlast->x != q->x) - - if (CHANGED (uuconf_qtimegrade) - && (q->uuconf_qtimegrade - != (struct uuconf_timespan *) &_uuconf_unset)) - { - if (q->uuconf_qtimegrade == NULL) - fprintf (e, "time never\n"); - else - { - for (qtime = q->uuconf_qtimegrade; - qtime != NULL; - qtime = qtime->uuconf_qnext) - { - if ((char) qtime->uuconf_ival == UUCONF_GRADE_LOW) - fprintf (e, "time "); - else - fprintf (e, "timegrade %c ", (char) qtime->uuconf_ival); - uvwrite_time (e, qtime); - if (qtime->uuconf_cretry != 0) - fprintf (e, " %d", qtime->uuconf_cretry); - fprintf (e, "\n"); - } - } - } - - if (CHANGED (uuconf_qcalltimegrade) - && (q->uuconf_qcalltimegrade - != (struct uuconf_timespan *) &_uuconf_unset)) - { - for (qtime = q->uuconf_qcalltimegrade; - qtime != NULL; - qtime = qtime->uuconf_qnext) - { - fprintf (e, "call-timegrade %c ", (char) qtime->uuconf_ival); - uvwrite_time (e, qtime); - fprintf (e, "\n"); - } - } - - if (CHANGED (uuconf_qcalledtimegrade) - && (q->uuconf_qcalledtimegrade - != (struct uuconf_timespan *) &_uuconf_unset)) - { - for (qtime = q->uuconf_qcalledtimegrade; - qtime != NULL; - qtime = qtime->uuconf_qnext) - { - fprintf (e, "called-timegrade %c ", (char) qtime->uuconf_ival); - uvwrite_time (e, qtime); - fprintf (e, "\n"); - } - } - - if (CHANGED (uuconf_qcall_local_size)) - uvwrite_size (e, q->uuconf_qcall_local_size, "call-local-size"); - - if (CHANGED (uuconf_qcall_remote_size)) - uvwrite_size (e, q->uuconf_qcall_remote_size, "call-remote-size"); - - if (CHANGED (uuconf_qcalled_local_size)) - uvwrite_size (e, q->uuconf_qcalled_local_size, "called-local-size"); - - if (CHANGED (uuconf_qcalled_remote_size)) - uvwrite_size (e, q->uuconf_qcalled_remote_size, "called-remote-size"); - - if (CHANGED (uuconf_ibaud) || CHANGED (uuconf_ihighbaud)) - { - if (q->uuconf_ibaud >= 0) - { - if (q->uuconf_ihighbaud > 0) - fprintf (e, "baud-range %ld %ld\n", q->uuconf_ibaud, - q->uuconf_ihighbaud); - else - fprintf (e, "baud %ld\n", q->uuconf_ibaud); - } - } - - if (CHANGED (uuconf_zport) || CHANGED (uuconf_qport)) - { - if (q->uuconf_zport != NULL - && q->uuconf_zport != (char *) &_uuconf_unset) - uvwrite_string (e, q->uuconf_zport, "port"); - else if (q->uuconf_qport != NULL - && (q->uuconf_qport - != (struct uuconf_port *) &_uuconf_unset)) - uvwrite_taylor_port (e, q->uuconf_qport, "port "); - } - - if (CHANGED (uuconf_zphone)) - { - const char *zcmd; - - if (q->uuconf_qport != NULL - && q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset - && (q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TCP - || q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TLI)) - zcmd = "address"; - else - zcmd = "phone"; - uvwrite_string (e, q->uuconf_zphone, zcmd); - } - - uvwrite_chat (e, &q->uuconf_schat, - (qlast == NULL - ? (struct uuconf_chat *) NULL - : &qlast->uuconf_schat), - "", TRUE); - - if (CHANGED (uuconf_zcall_login)) - uvwrite_string (e, q->uuconf_zcall_login, "call-login"); - - if (CHANGED (uuconf_zcall_password)) - uvwrite_string (e, q->uuconf_zcall_password, "call-password"); - - if (CHANGED (uuconf_zcalled_login)) - uvwrite_string (e, q->uuconf_zcalled_login, "called-login"); - - if (CHANGED (uuconf_fcallback)) - uvwrite_boolean (e, q->uuconf_fcallback, "callback"); - - if (CHANGED (uuconf_fsequence)) - uvwrite_boolean (e, q->uuconf_fsequence, "sequence"); - - if (CHANGED (uuconf_zprotocols)) - uvwrite_string (e, q->uuconf_zprotocols, "protocol"); - - if (CHANGED (uuconf_qproto_params)) - uvwrite_proto_params (e, q->uuconf_qproto_params, ""); - - uvwrite_chat (e, &q->uuconf_scalled_chat, - (qlast == NULL - ? (struct uuconf_chat *) NULL - : &qlast->uuconf_scalled_chat), - "called-", FALSE); - - if (CHANGED (uuconf_zdebug)) - uvwrite_string (e, q->uuconf_zdebug, "debug"); - - if (CHANGED (uuconf_zmax_remote_debug)) - uvwrite_string (e, q->uuconf_zmax_remote_debug, "max-remote-debug"); - - if ((CHANGED (uuconf_fsend_request) - || CHANGED (uuconf_frec_request)) - && (q->uuconf_fsend_request >= 0 - || q->uuconf_frec_request >= 0)) - { - if (q->uuconf_fsend_request >= 0 - && (q->uuconf_fsend_request > 0 - ? q->uuconf_frec_request > 0 - : q->uuconf_frec_request == 0)) - uvwrite_boolean (e, q->uuconf_fsend_request, "request"); - else - { - uvwrite_boolean (e, q->uuconf_fsend_request, "send-request"); - uvwrite_boolean (e, q->uuconf_frec_request, - "receive-request"); - } - } - - if ((CHANGED (uuconf_fcall_transfer) - || CHANGED (uuconf_fcalled_transfer)) - && (q->uuconf_fcall_transfer >= 0 - || q->uuconf_fcalled_transfer >= 0)) - { - if (q->uuconf_fcall_transfer >= 0 - && (q->uuconf_fcall_transfer > 0 - ? q->uuconf_fcalled_transfer > 0 - : q->uuconf_fcalled_transfer == 0)) - uvwrite_boolean (e, q->uuconf_fcall_transfer, "transfer"); - else - { - uvwrite_boolean (e, q->uuconf_fcall_transfer, "call-transfer"); - uvwrite_boolean (e, q->uuconf_fcalled_transfer, - "called-transfer"); - } - } - - if (CHANGED (uuconf_pzlocal_send)) - uvwrite_string_array (e, q->uuconf_pzlocal_send, "local-send"); - - if (CHANGED (uuconf_pzremote_send)) - uvwrite_string_array (e, q->uuconf_pzremote_send, "remote-send"); - - if (CHANGED (uuconf_pzlocal_receive)) - uvwrite_string_array (e, q->uuconf_pzlocal_receive, "local-receive"); - - if (CHANGED (uuconf_pzremote_receive)) - uvwrite_string_array (e, q->uuconf_pzremote_receive, - "remote-receive"); - - if (CHANGED (uuconf_pzpath)) - uvwrite_string_array (e, q->uuconf_pzpath, "command-path"); - - if (CHANGED (uuconf_pzcmds)) - uvwrite_string_array (e, q->uuconf_pzcmds, "commands"); - - if (CHANGED (uuconf_cfree_space) - && q->uuconf_cfree_space >= 0) - fprintf (e, "free-space %ld\n", q->uuconf_cfree_space); - - if (CHANGED (uuconf_pzforward_from)) - uvwrite_string_array (e, q->uuconf_pzforward_from, "forward-from"); - - if (CHANGED (uuconf_pzforward_to)) - uvwrite_string_array (e, q->uuconf_pzforward_to, "forward-to"); - - if (CHANGED (uuconf_zpubdir)) - uvwrite_string (e, q->uuconf_zpubdir, "pubdir"); - - if (CHANGED (uuconf_zlocalname)) - uvwrite_string (e, q->uuconf_zlocalname, "myname"); - } -} - -/* Write out V2 system information. */ - -static void -uvwrite_v2_system (e, q) - FILE *e; - const struct uuconf_system *q; -{ - for (; q != NULL; q = q->uuconf_qalternate) - { - fprintf (e, "%s", q->uuconf_zname); - - if (q->uuconf_qtimegrade != (struct uuconf_timespan *) &_uuconf_unset) - { - fprintf (e, " "); - uvwrite_time (e, q->uuconf_qtimegrade); - - if (q->uuconf_zport != (char *) &_uuconf_unset - || q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset) - { - struct uuconf_port *qp; - boolean ftcp; - - qp = q->uuconf_qport; - ftcp = (qp != (struct uuconf_port *) &_uuconf_unset - && qp != NULL - && qp->uuconf_ttype == UUCONF_PORTTYPE_TCP); - if (ftcp - || (q->uuconf_zport != NULL - && q->uuconf_zport != (char *) &_uuconf_unset)) - { - if (ftcp) - fprintf (e, " TCP"); - else - fprintf (e, " %s", q->uuconf_zport); - - if (ftcp || q->uuconf_ibaud >= 0) - { - fprintf (e, " "); - if (ftcp) - { - const char *zport; - - zport = qp->uuconf_u.uuconf_stcp.uuconf_zport; - if (zport == NULL) - zport = "uucp"; - fprintf (e, "%s", zport); - } - else - fprintf (e, "%ld", q->uuconf_ibaud); - - if (q->uuconf_zphone != (char *) &_uuconf_unset - && q->uuconf_zphone != NULL) - { - char **pzc; - - fprintf (e, " %s", q->uuconf_zphone); - pzc = q->uuconf_schat.uuconf_pzchat; - if (pzc != (char **) &_uuconf_unset - && pzc != NULL) - { - fprintf (e, " "); - uvwrite_chat_script (e, pzc); - } - } - } - } - } - } - - fprintf (e, "\n"); - - /* Here we should gather information to write out to USERFILE - and L.cmds, and perhaps some day we will. It's much more - likely to happen if somebody else does it, though. */ - } -} - -/* Write out HDB system information. */ - -static void -uvwrite_hdb_system (e, qsys) - FILE *e; - const struct uuconf_system *qsys; -{ - const struct uuconf_system *q; - struct shpermissions sperm; - char *azmachine[2]; - char *azlogname[2]; - - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - { - if (q->uuconf_fcall) - { - fprintf (e, "%s", q->uuconf_zname); - - if (q->uuconf_qtimegrade - != (struct uuconf_timespan *) &_uuconf_unset) - { - const char *zport; - - fprintf (e, " "); - uvwrite_time (e, q->uuconf_qtimegrade); - - zport = q->uuconf_zport; - if (q->uuconf_qport != NULL - && q->uuconf_qport != (struct uuconf_port *) &_uuconf_unset - && q->uuconf_qport->uuconf_ttype == UUCONF_PORTTYPE_TCP) - zport = "TCP"; - if (zport != NULL && zport != (char *) &_uuconf_unset) - { - fprintf (e, " %s", zport); - if (q->uuconf_zprotocols != (char *) &_uuconf_unset - && q->uuconf_zprotocols != NULL) - fprintf (e, ",%s", q->uuconf_zprotocols); - - if (q->uuconf_ibaud >= 0 - || q->uuconf_zphone != (char *) &_uuconf_unset) - { - fprintf (e, " "); - if (q->uuconf_ibaud < 0) - fprintf (e, "Any"); - else - { - fprintf (e, "%ld", q->uuconf_ibaud); - if (q->uuconf_ihighbaud >= 0) - fprintf (e, "-%ld", q->uuconf_ihighbaud); - } - - if (q->uuconf_zphone != (char *) &_uuconf_unset - && q->uuconf_zphone != NULL) - { - char **pzc; - - fprintf (e, " %s", q->uuconf_zphone); - pzc = q->uuconf_schat.uuconf_pzchat; - if (pzc != (char **) &_uuconf_unset - && pzc != NULL) - { - fprintf (e, " "); - uvwrite_chat_script (e, pzc); - } - } - } - } - } - - fprintf (e, "\n"); - } - } - - /* Build a Permissions entry for this system. There will be only - one MACHINE entry for a given system. */ - - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - if (q->uuconf_fcall) - break; - - if (q != NULL) - { - sperm.qnext = NULL; - sperm.pzlogname = NULL; - sperm.pzmachine = NULL; - sperm.frequest = -1; - sperm.fsendfiles = -1; - sperm.pzread = NULL; - sperm.pzwrite = NULL; - sperm.fcallback = -1; - sperm.pzcommands = NULL; - sperm.pzvalidate = NULL; - sperm.zmyname = NULL; - sperm.zpubdir = NULL; - sperm.pzalias = NULL; - - azmachine[0] = q->uuconf_zname; - azmachine[1] = NULL; - sperm.pzmachine = azmachine; - if (q->uuconf_fsend_request >= 0) - sperm.frequest = q->uuconf_fsend_request; - if (q->uuconf_pzremote_send != (char **) &_uuconf_unset - && q->uuconf_pzremote_send != NULL) - sperm.pzread = q->uuconf_pzremote_send; - if (q->uuconf_pzremote_receive != (char **) &_uuconf_unset - && q->uuconf_pzremote_receive != NULL) - sperm.pzwrite = q->uuconf_pzremote_receive; - if (q->uuconf_pzcmds != (char **) &_uuconf_unset - && q->uuconf_pzcmds != NULL) - sperm.pzcommands = q->uuconf_pzcmds; - if (q->uuconf_zlocalname != (char *) &_uuconf_unset - && q->uuconf_zlocalname != NULL) - sperm.zmyname = q->uuconf_zlocalname; - if (q->uuconf_zpubdir != (char *) &_uuconf_unset - && q->uuconf_zpubdir != NULL) - sperm.zpubdir = q->uuconf_zpubdir; - if (q->uuconf_pzalias != (char **) &_uuconf_unset - && q->uuconf_pzalias != NULL) - sperm.pzalias = q->uuconf_pzalias; - - if (q->uuconf_fcalled - && q->uuconf_zcalled_login != (char *) &_uuconf_unset - && q->uuconf_zcalled_login != NULL) - { - azlogname[0] = q->uuconf_zcalled_login; - azlogname[1] = NULL; - sperm.pzlogname = azlogname; - if (q->uuconf_fcalled_transfer >= 0) - sperm.fsendfiles = q->uuconf_fcalled_transfer; - if (q->uuconf_fcallback >= 0) - sperm.fcallback = q->uuconf_fcallback; - sperm.pzvalidate = azmachine; - } - - uvadd_perm (&sperm); - } - - /* Now add a Permissions entry for each alternative that is not used - for calling out. */ - for (q = qsys; q != NULL; q = q->uuconf_qalternate) - { - if (! q->uuconf_fcalled || q->uuconf_fcall) - continue; - - sperm.qnext = NULL; - sperm.pzlogname = NULL; - sperm.pzmachine = NULL; - sperm.frequest = -1; - sperm.fsendfiles = -1; - sperm.pzread = NULL; - sperm.pzwrite = NULL; - sperm.fcallback = -1; - sperm.pzcommands = NULL; - sperm.pzvalidate = NULL; - sperm.zmyname = NULL; - sperm.zpubdir = NULL; - sperm.pzalias = NULL; - - if (q->uuconf_zcalled_login != (char *) &_uuconf_unset - && q->uuconf_zcalled_login != NULL) - azlogname[0] = q->uuconf_zcalled_login; - else - azlogname[0] = (char *) "OTHER"; - azlogname[1] = NULL; - sperm.pzlogname = azlogname; - - if (q->uuconf_fsend_request >= 0) - sperm.frequest = q->uuconf_fsend_request; - if (q->uuconf_fcalled_transfer >= 0) - sperm.fsendfiles = q->uuconf_fcalled_transfer; - if (q->uuconf_pzremote_send != (char **) &_uuconf_unset - && q->uuconf_pzremote_send != NULL) - sperm.pzread = q->uuconf_pzremote_send; - if (q->uuconf_pzremote_receive != (char **) &_uuconf_unset - && q->uuconf_pzremote_receive != NULL) - sperm.pzwrite = q->uuconf_pzremote_receive; - if (q->uuconf_fcallback >= 0) - sperm.fcallback = q->uuconf_fcallback; - if (q->uuconf_zlocalname != (char *) &_uuconf_unset - && q->uuconf_zlocalname != NULL) - sperm.zmyname = q->uuconf_zlocalname; - if (q->uuconf_zpubdir != (char *) &_uuconf_unset - && q->uuconf_zpubdir != NULL) - sperm.zpubdir = q->uuconf_zpubdir; - - uvadd_perm (&sperm); - } -} - -/* Compare two strings from a Permissions entry, returning TRUE if - they are the same. */ - -static boolean -fvperm_string_cmp (z1, z2) - const char *z1; - const char *z2; -{ - if (z1 == NULL) - return z2 == NULL; - - if (z2 == NULL) - return FALSE; - - return strcmp (z1, z2) == 0; -} - -/* Compare two arrays of strings from a Permissions entry, returning - TRUE if they are the same. */ - -static boolean -fvperm_array_cmp (pz1, pz2) - const char **pz1; - const char **pz2; -{ - if (pz1 == NULL) - return pz2 == NULL; - - if (pz2 == NULL) - return FALSE; - - for (; *pz1 != NULL && *pz2 != NULL; pz1++, pz2++) - if (strcmp (*pz1, *pz2) != 0) - break; - - return *pz1 == NULL && *pz2 == NULL; -} - -/* Add a Permissions entry to a global list, combining entries where - possible. */ - -static void -uvadd_perm (qadd) - struct shpermissions *qadd; -{ - struct shpermissions *qlook; - struct shpermissions *qnew; - int iret; - - /* If there's no information, don't bother to add this entry. */ - if (qadd->pzlogname == NULL - && qadd->frequest < 0 - && qadd->fsendfiles < 0 - && qadd->pzread == NULL - && qadd->pzwrite == NULL - && qadd->fcallback < 0 - && qadd->pzcommands == NULL - && qadd->pzvalidate == NULL - && qadd->zmyname == NULL - && qadd->zpubdir == NULL - && qadd->pzalias == NULL) - return; - - for (qlook = qVperms; qlook != NULL; qlook = qlook->qnext) - { - /* See if we can merge qadd into qlook. */ - if (qadd->pzlogname == NULL - ? qlook->pzlogname != NULL - : qlook->pzlogname == NULL) - continue; - if (qadd->pzmachine == NULL - ? qlook->pzmachine != NULL - : qlook->pzmachine == NULL) - continue; - if (qadd->frequest != qlook->frequest - || qadd->fsendfiles != qlook->fsendfiles - || qadd->fcallback != qlook->fcallback) - continue; - if (! fvperm_string_cmp (qadd->zmyname, qlook->zmyname) - || ! fvperm_string_cmp (qadd->zpubdir, qlook->zpubdir)) - continue; - if (! fvperm_array_cmp ((const char **) qadd->pzread, - (const char **) qlook->pzread) - || ! fvperm_array_cmp ((const char **) qadd->pzwrite, - (const char **) qlook->pzwrite) - || ! fvperm_array_cmp ((const char **) qadd->pzcommands, - (const char **) qlook->pzcommands)) - continue; - - /* Merge qadd into qlook. */ - if (qadd->pzmachine != NULL) - { - iret = _uuconf_iadd_string ((struct sglobal *) NULL, - qadd->pzmachine[0], FALSE, - TRUE, &qlook->pzmachine, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - uvuuconf_error ((pointer) NULL, iret); - } - if (qadd->pzlogname != NULL) - { - iret = _uuconf_iadd_string ((struct sglobal *) NULL, - qadd->pzlogname[0], FALSE, - TRUE, &qlook->pzlogname, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - uvuuconf_error ((pointer) NULL, iret); - } - if (qadd->pzalias != NULL) - { - char **pz; - - for (pz = qadd->pzalias; *pz != NULL; pz++) - { - iret = _uuconf_iadd_string ((struct sglobal *) NULL, - *pz, FALSE, TRUE, - &qlook->pzalias, (pointer) NULL); - if (iret != UUCONF_SUCCESS) - uvuuconf_error ((pointer) NULL, iret); - } - } - - return; - } - - /* We must add qadd as a new entry on the list, which means we must - copy it into the heap. */ - - qnew = (struct shpermissions *) malloc (sizeof (struct shpermissions)); - if (qnew == NULL) - uvuuconf_error ((pointer) NULL, UUCONF_MALLOC_FAILED); - *qnew = *qadd; - if (qadd->pzmachine != NULL) - { - qnew->pzmachine = NULL; - iret = _uuconf_iadd_string ((struct sglobal *) NULL, - qadd->pzmachine[0], FALSE, - FALSE, &qnew->pzmachine, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - uvuuconf_error ((pointer) NULL, iret); - } - if (qadd->pzlogname != NULL) - { - qnew->pzlogname = NULL; - iret = _uuconf_iadd_string ((struct sglobal *) NULL, - qadd->pzlogname[0], FALSE, - FALSE, &qnew->pzlogname, - (pointer) NULL); - if (iret != UUCONF_SUCCESS) - uvuuconf_error ((pointer) NULL, iret); - } - if (qadd->pzvalidate != NULL) - qnew->pzvalidate = qnew->pzmachine; - - qnew->qnext = qVperms; - qVperms = qnew; -} - -/* Write out the Permissions entries. */ - -static void -uvwrite_perms () -{ - char ab[sizeof ZCURDIR + sizeof HDB_PERMISSIONS - 1]; - FILE *e; - struct shpermissions *q; - - sprintf (ab, "%s%s", ZCURDIR, HDB_PERMISSIONS); - e = fopen (ab, "w"); - if (e == NULL) - { - fprintf (stderr, "uuchk:%s: ", ab); - perror ("fopen"); - exit (EXIT_FAILURE); - } - - fprintf (e, "# Permissions file automatically generated by uuconv.\n"); - - for (q = qVperms; q != NULL; q = q->qnext) - { - size_t ccol; - - ccol = 0; - uvwrite_perm_array (e, (const char **) q->pzlogname, "LOGNAME", &ccol); - uvwrite_perm_array (e, (const char **) q->pzmachine, "MACHINE", &ccol); - uvwrite_perm_boolean (e, q->frequest, "REQUEST", &ccol, FALSE); - uvwrite_perm_boolean (e, q->fsendfiles, "SENDFILES", &ccol, TRUE); - uvwrite_perm_rw_array (e, (const char **) q->pzread, "READ", &ccol); - uvwrite_perm_rw_array (e, (const char **) q->pzwrite, "WRITE", &ccol); - uvwrite_perm_boolean (e, q->fcallback, "CALLBACK", &ccol, FALSE); - uvwrite_perm_array (e, (const char **) q->pzcommands, "COMMANDS", - &ccol); - uvwrite_perm_array (e, (const char **) q->pzvalidate, "VALIDATE", - &ccol); - uvwrite_perm_string (e, q->zmyname, "MYNAME", &ccol); - uvwrite_perm_string (e, q->zpubdir, "PUBDIR", &ccol); - uvwrite_perm_array (e, (const char **) q->pzalias, "ALIAS", &ccol); - - fprintf (e, "\n"); - } - - if (ferror (e) - || fclose (e) == EOF) - { - fprintf (stderr, "uuchk:%s: error during output\n", HDB_PERMISSIONS); - exit (EXIT_FAILURE); - } -} - -/* Write an array out to the Permissions file. */ - -static void -uvwrite_perm_array (e, pzarg, zcmd, pccol) - FILE *e; - const char **pzarg; - const char *zcmd; - size_t *pccol; -{ - size_t c; - const char **pz; - - if (pzarg == NULL) - return; - - c = strlen (zcmd) + 1; - - for (pz = pzarg; *pz != NULL; pz++) - c += strlen (*pz) + 1; - - if (*pccol > 20 && c + *pccol > 75) - { - fprintf (e, " \\\n"); - *pccol = c - 1; - } - else - { - if (*pccol != 0) - fprintf (e, " "); - *pccol += c; - } - - fprintf (e, "%s=", zcmd); - for (pz = pzarg; *pz != NULL; pz++) - { - if (pz != pzarg) - fprintf (e, ":"); - fprintf (e, "%s", *pz); - } -} - -/* Write a boolean value out to the Permissions file. This may be - either a yes/no boolean or a yes/call boolean (the latter is for - SENDFILES). */ - -static void -uvwrite_perm_boolean (e, f, zcmd, pccol, fsendfiles) - FILE *e; - int f; - const char *zcmd; - size_t *pccol; - boolean fsendfiles; -{ - const char *az[2]; - - if (f < 0) - return; - - if (f) - az[0] = "yes"; - else - az[0] = fsendfiles ? "call" : "no"; - az[1] = NULL; - - uvwrite_perm_array (e, az, zcmd, pccol); -} - -/* Write a set of READ or WRITE entries to the Permissions file. We - have to separate out all entries that start with '!'. */ - -static void -uvwrite_perm_rw_array (e, pzarg, zcmd, pccol) - FILE *e; - const char **pzarg; - const char *zcmd; - size_t *pccol; -{ - size_t c; - const char **pz, **pzcopy, **pzset; - - if (pzarg == NULL) - return; - - c = 0; - for (pz = pzarg; *pz != NULL; pz++) - c++; - - pzcopy = (const char **) malloc ((c + 1) * sizeof (char *)); - if (pzcopy == NULL) - uvuuconf_error ((pointer) NULL, UUCONF_MALLOC_FAILED); - - pzset = pzcopy; - for (pz = pzarg; *pz != NULL; pz++) - if ((*pz)[0] != '!') - *pzset++ = *pz; - *pzset = NULL; - - if (pzset != pzcopy) - uvwrite_perm_array (e, (const char **) pzcopy, zcmd, pccol); - - pzset = pzcopy; - for (pz = pzarg; *pz != NULL; pz++) - if ((*pz)[0] == '!') - *pzset++ = *pz; - *pzset = NULL; - - if (pzset != pzcopy) - { - char ab[20]; - - sprintf (ab, "NO%s", zcmd); - uvwrite_perm_array (e, (const char **) pzcopy, ab, pccol); - } -} - -/* Write a string out to the Permissions file. */ - -static void -uvwrite_perm_string (e, z, zcmd, pccol) - FILE *e; - const char *z; - const char *zcmd; - size_t *pccol; -{ - const char *az[2]; - - if (z == NULL) - return; - - az[0] = z; - az[1] = NULL; - - uvwrite_perm_array (e, az, zcmd, pccol); -} - -/* Write out a Taylor UUCP port. This is called via uuconf_find_port; - the pinfo argument is the port file. */ - -static int -ivwrite_taylor_port (qport, pinfo) - struct uuconf_port *qport; - pointer pinfo; -{ - FILE *e = (FILE *) pinfo; - - fprintf (e, "port %s\n", qport->uuconf_zname); - - uvwrite_taylor_port (e, qport, ""); - - /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking - for ports. */ - return UUCONF_NOT_FOUND; -} - -/* Write a port out to a Taylor UUCP configuration file. This doesn't - output the name, since it is called to output a specially defined - port in the sys file. */ - -static void -uvwrite_taylor_port (e, qport, zprefix) - FILE *e; - struct uuconf_port *qport; - const char *zprefix; -{ - const char *ztype; - char ab[100]; - - switch (qport->uuconf_ttype) - { - default: - case UUCONF_PORTTYPE_UNKNOWN: - fprintf (stderr, "uuconv: Bad port type\n"); - exit (EXIT_FAILURE); - break; - case UUCONF_PORTTYPE_STDIN: - ztype = "stdin"; - break; - case UUCONF_PORTTYPE_MODEM: - ztype = "modem"; - break; - case UUCONF_PORTTYPE_DIRECT: - ztype = "direct"; - break; - case UUCONF_PORTTYPE_TCP: - ztype = "tcp"; - break; - case UUCONF_PORTTYPE_TLI: - ztype = "tli"; - break; - case UUCONF_PORTTYPE_PIPE: - ztype = "pipe"; - break; - } - - fprintf (e, "%stype %s\n", zprefix, ztype); - - if (qport->uuconf_zprotocols != NULL) - fprintf (e, "%sprotocol %s\n", zprefix, qport->uuconf_zprotocols); - - if (qport->uuconf_qproto_params != NULL) - uvwrite_proto_params (e, qport->uuconf_qproto_params, zprefix); - - if ((qport->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - { - sprintf (ab, "%sseven-bit", zprefix); - uvwrite_boolean (e, - ((qport->uuconf_ireliable & UUCONF_RELIABLE_EIGHT) - == 0), - ab); - sprintf (ab, "%sreliable", zprefix); - uvwrite_boolean (e, - ((qport->uuconf_ireliable & UUCONF_RELIABLE_RELIABLE) - != 0), - ab); - sprintf (ab, "%shalf-duplex", zprefix); - uvwrite_boolean (e, - ((qport->uuconf_ireliable & UUCONF_RELIABLE_FULLDUPLEX) - == 0), - ab); - } - - if (qport->uuconf_zlockname != NULL) - fprintf (e, "%slockname %s\n", zprefix, qport->uuconf_zlockname); - - switch (qport->uuconf_ttype) - { - default: - break; - case UUCONF_PORTTYPE_MODEM: - { - struct uuconf_modem_port *qm; - - qm = &qport->uuconf_u.uuconf_smodem; - if (qm->uuconf_zdevice != NULL) - fprintf (e, "%sdevice %s\n", zprefix, qm->uuconf_zdevice); - if (qm->uuconf_zdial_device != NULL) - fprintf (e, "%sdial-device %s\n", zprefix, qm->uuconf_zdial_device); - if (qm->uuconf_ibaud != 0) - fprintf (e, "%sbaud %ld\n", zprefix, qm->uuconf_ibaud); - if (qm->uuconf_ilowbaud != 0) - fprintf (e, "%sbaud-range %ld %ld\n", zprefix, qm->uuconf_ilowbaud, - qm->uuconf_ihighbaud); - if (! qm->uuconf_fcarrier) - fprintf (e, "%scarrier false\n", zprefix); - if (! qm->uuconf_fhardflow) - fprintf (e, "%shardflow false\n", zprefix); - if (qm->uuconf_pzdialer != NULL) - { - if (qm->uuconf_pzdialer[1] == NULL) - fprintf (e, "%sdialer %s\n", zprefix, qm->uuconf_pzdialer[0]); - else - { - sprintf (ab, "%sdialer-sequence", zprefix); - uvwrite_string_array (e, qm->uuconf_pzdialer, ab); - } - } - if (qm->uuconf_qdialer != NULL) - { - sprintf (ab, "%sdialer ", zprefix); - uvwrite_taylor_dialer (e, qm->uuconf_qdialer, ab); - } - } - break; - case UUCONF_PORTTYPE_DIRECT: - { - struct uuconf_direct_port *qd; - - qd = &qport->uuconf_u.uuconf_sdirect; - if (qd->uuconf_zdevice != NULL) - fprintf (e, "%sdevice %s\n", zprefix, qd->uuconf_zdevice); - if (qd->uuconf_ibaud != 0) - fprintf (e, "%sbaud %ld\n", zprefix, qd->uuconf_ibaud); - if (qd->uuconf_fcarrier) - fprintf (e, "%scarrier true\n", zprefix); - if (! qd->uuconf_fhardflow) - fprintf (e, "%shardflow false\n", zprefix); - } - break; - case UUCONF_PORTTYPE_TCP: - if (qport->uuconf_u.uuconf_stcp.uuconf_zport != NULL) - fprintf (e, "%sservice %s\n", zprefix, - qport->uuconf_u.uuconf_stcp.uuconf_zport); - if (qport->uuconf_u.uuconf_stcp.uuconf_pzdialer != NULL) - { - sprintf (ab, "%sdialer-sequence", zprefix); - uvwrite_string_array (e, - qport->uuconf_u.uuconf_stcp.uuconf_pzdialer, - ab); - } - break; - case UUCONF_PORTTYPE_TLI: - { - struct uuconf_tli_port *qt; - - qt = &qport->uuconf_u.uuconf_stli; - if (qt->uuconf_zdevice != NULL) - fprintf (e, "%sdevice %s\n", zprefix, qt->uuconf_zdevice); - sprintf (ab, "%sstream", zprefix); - uvwrite_boolean (e, qt->uuconf_fstream, ab); - if (qt->uuconf_pzpush != NULL) - { - sprintf (ab, "%spush", zprefix); - uvwrite_string_array (e, qt->uuconf_pzpush, ab); - } - if (qt->uuconf_pzdialer != NULL) - { - sprintf (ab, "%sdialer-sequence", zprefix); - uvwrite_string_array (e, qt->uuconf_pzdialer, ab); - } - if (qt->uuconf_zservaddr != NULL) - fprintf (e, "%sserver-address %s\n", zprefix, - qt->uuconf_zservaddr); - } - break; - case UUCONF_PORTTYPE_PIPE: - { - struct uuconf_pipe_port *qp; - - qp = &qport->uuconf_u.uuconf_spipe; - if (qp->uuconf_pzcmd != NULL) - { - sprintf (ab, "%scommad", zprefix); - uvwrite_string_array (e, qp->uuconf_pzcmd, ab); - } - } - break; - } -} - -/* Write out a port to the V2 L-devices file. This is called via - uuconf_find_port. */ - -static int -ivwrite_v2_port (qport, pinfo) - struct uuconf_port *qport; - pointer pinfo; -{ - FILE *e = (FILE *) pinfo; - - if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT) - { - fprintf (e, "DIR %s - %ld direct", - qport->uuconf_u.uuconf_sdirect.uuconf_zdevice, - qport->uuconf_u.uuconf_sdirect.uuconf_ibaud); - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM) - { - fprintf (e, "%s %s ", qport->uuconf_zname, - qport->uuconf_u.uuconf_smodem.uuconf_zdevice); - if (qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL) - fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdial_device); - else - fprintf (e, "-"); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0L) - fprintf (e, "%ld-%ld", - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud, - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud); - else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0L) - fprintf (e, "%ld", qport->uuconf_u.uuconf_smodem.uuconf_ibaud); - else - fprintf (e, "Any"); - if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL) - fprintf (e, " %s", - qport->uuconf_u.uuconf_smodem.uuconf_pzdialer[0]); - } - else - { - fprintf (e, "# Ignoring port %s with unsupported type", - qport->uuconf_zname); - } - - fprintf (e, "\n"); - - /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking - for a port. */ - return UUCONF_NOT_FOUND; -} - -/* Write out a port to the HDB Devices file. This is called via - uuconf_find_port. */ - -static int -ivwrite_hdb_port (qport, pinfo) - struct uuconf_port *qport; - pointer pinfo; -{ - FILE *e = (FILE *) pinfo; - - if (qport->uuconf_ttype == UUCONF_PORTTYPE_DIRECT) - { - fprintf (e, "Direct"); - if (qport->uuconf_zprotocols != NULL) - fprintf (e, ",%s", qport->uuconf_zprotocols); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_sdirect.uuconf_zdevice != NULL) - fprintf (e, "%s", qport->uuconf_u.uuconf_sdirect.uuconf_zdevice); - else - fprintf (e, "%s", qport->uuconf_zname); - fprintf (e, " - %ld", qport->uuconf_u.uuconf_sdirect.uuconf_ibaud); - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_MODEM) - { - fprintf (e, "%s", qport->uuconf_zname); - if (qport->uuconf_zprotocols != NULL) - fprintf (e, ",%s", qport->uuconf_zprotocols); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_smodem.uuconf_zdevice != NULL) - fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdevice); - else - fprintf (e, "%s", qport->uuconf_zname); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_smodem.uuconf_zdial_device != NULL) - fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdial_device); - else - fprintf (e, "-"); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud != 0L) - fprintf (e, "%ld-%ld", - qport->uuconf_u.uuconf_smodem.uuconf_ilowbaud, - qport->uuconf_u.uuconf_smodem.uuconf_ihighbaud); - else if (qport->uuconf_u.uuconf_smodem.uuconf_ibaud != 0L) - fprintf (e, "%ld", qport->uuconf_u.uuconf_smodem.uuconf_ibaud); - else - fprintf (e, "Any"); - if (qport->uuconf_u.uuconf_smodem.uuconf_pzdialer != NULL) - { - char **pz; - - for (pz = qport->uuconf_u.uuconf_smodem.uuconf_pzdialer; - *pz != NULL; - pz++) - fprintf (e, " %s", *pz); - } - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TCP) - { - char **pz; - - fprintf (e, "TCP"); - if (qport->uuconf_zprotocols != NULL) - fprintf (e, ",%s", qport->uuconf_zprotocols); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_stcp.uuconf_zport == NULL) - fprintf (e, "uucp"); - else - fprintf (e, "%s", qport->uuconf_u.uuconf_stcp.uuconf_zport); - fprintf (e, " - -"); - pz = qport->uuconf_u.uuconf_stcp.uuconf_pzdialer; - if (pz != NULL) - for (; *pz != NULL; pz++) - fprintf (e, " %s", *pz); - } - else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TLI) - { - char **pz; - - fprintf (e, "%s", qport->uuconf_zname); - if (qport->uuconf_zprotocols != NULL) - fprintf (e, ",%s", qport->uuconf_zprotocols); - fprintf (e, " "); - if (qport->uuconf_u.uuconf_stli.uuconf_zdevice != NULL) - fprintf (e, "%s", qport->uuconf_u.uuconf_smodem.uuconf_zdevice); - else - fprintf (e, "-"); - fprintf (e, " - -"); - pz = qport->uuconf_u.uuconf_stli.uuconf_pzdialer; - if (pz == NULL - || *pz == NULL - || (strcmp (*pz, "TLI") != 0 - && strcmp (*pz, "TLIS") != 0)) - fprintf (e, " TLI%s \\D", - qport->uuconf_u.uuconf_stli.uuconf_fstream ? "S" : ""); - if (pz != NULL) - for (; *pz != NULL; pz++) - fprintf (e, " %s", *pz); - } - else - { - fprintf (e, "# Ignoring port %s with unsupported type", - qport->uuconf_zname); - } - - fprintf (e, "\n"); - - /* Return UUCONF_NOT_FOUND to force uuconf_find_port to keep looking - for a port. */ - return UUCONF_NOT_FOUND; -} - -/* Write a dialer out to a Taylor UUCP configuration file. This - doesn't output the name, since it is called to output a specially - defined dialer in the sys or port file. */ - -static void -uvwrite_taylor_dialer (e, qdialer, zprefix) - FILE *e; - struct uuconf_dialer *qdialer; - const char *zprefix; -{ - char ab[100]; - - /* Reset default values, so we don't output them unnecessarily. */ - if (qdialer->uuconf_schat.uuconf_ctimeout == 60) - qdialer->uuconf_schat.uuconf_ctimeout = -1; - if (qdialer->uuconf_schat.uuconf_fstrip) - qdialer->uuconf_schat.uuconf_fstrip = -1; - if (qdialer->uuconf_scomplete.uuconf_ctimeout == 60) - qdialer->uuconf_scomplete.uuconf_ctimeout = -1; - if (qdialer->uuconf_scomplete.uuconf_fstrip) - qdialer->uuconf_scomplete.uuconf_fstrip = -1; - if (qdialer->uuconf_sabort.uuconf_ctimeout == 60) - qdialer->uuconf_sabort.uuconf_ctimeout = -1; - if (qdialer->uuconf_sabort.uuconf_fstrip) - qdialer->uuconf_sabort.uuconf_fstrip = -1; - - uvwrite_chat (e, &qdialer->uuconf_schat, (struct uuconf_chat *) NULL, - zprefix, FALSE); - if (qdialer->uuconf_zdialtone != NULL - && strcmp (qdialer->uuconf_zdialtone, ",") != 0) - fprintf (e, "%sdialtone %s\n", zprefix, qdialer->uuconf_zdialtone); - if (qdialer->uuconf_zpause != NULL - && strcmp (qdialer->uuconf_zpause, ",") != 0) - fprintf (e, "%spause %s\n", zprefix, qdialer->uuconf_zpause); - if (! qdialer->uuconf_fcarrier) - fprintf (e, "%scarrier false\n", zprefix); - if (qdialer->uuconf_ccarrier_wait != 60) - fprintf (e, "%scarrier-wait %d\n", zprefix, - qdialer->uuconf_ccarrier_wait); - if (qdialer->uuconf_fdtr_toggle) - fprintf (e, "%sdtr-toggle %s %s\n", zprefix, - qdialer->uuconf_fdtr_toggle ? "true" : "false", - qdialer->uuconf_fdtr_toggle_wait ? "true" : "false"); - sprintf (ab, "%scomplete-", zprefix); - uvwrite_chat (e, &qdialer->uuconf_scomplete, (struct uuconf_chat *) NULL, - ab, FALSE); - sprintf (ab, "%sabort-", zprefix); - uvwrite_chat (e, &qdialer->uuconf_sabort, (struct uuconf_chat *) NULL, - ab, FALSE); - if (qdialer->uuconf_qproto_params != NULL) - uvwrite_proto_params (e, qdialer->uuconf_qproto_params, zprefix); - if ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_SPECIFIED) != 0) - { - sprintf (ab, "%sseven-bit", zprefix); - uvwrite_boolean (e, - ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_EIGHT) - == 0), - ab); - sprintf (ab, "%sreliable", zprefix); - uvwrite_boolean (e, - ((qdialer->uuconf_ireliable & UUCONF_RELIABLE_RELIABLE) - != 0), - ab); - sprintf (ab, "%shalf-duplex", zprefix); - uvwrite_boolean (e, - ((qdialer->uuconf_ireliable - & UUCONF_RELIABLE_FULLDUPLEX) == 0), - ab); - } -} - -/* Write a dialer out to an HDB configuration file. */ - -static void -uvwrite_hdb_dialer (e, qdialer) - FILE *e; - struct uuconf_dialer *qdialer; -{ - fprintf (e, "%s ", qdialer->uuconf_zname); - - if (qdialer->uuconf_zdialtone != NULL) - fprintf (e, "=%c", qdialer->uuconf_zdialtone[0]); - if (qdialer->uuconf_zpause != NULL) - fprintf (e, "-%c", qdialer->uuconf_zpause[0]); - - if (qdialer->uuconf_schat.uuconf_pzchat != NULL) - { - if (qdialer->uuconf_zdialtone == NULL - && qdialer->uuconf_zpause == NULL) - fprintf (e, "\"\""); - fprintf (e, " "); - uvwrite_chat_script (e, qdialer->uuconf_schat.uuconf_pzchat); - } - - fprintf (e, "\n"); -} - -/* Display a uuconf error and exit. */ - -static void -uvuuconf_error (puuconf, iret) - pointer puuconf; - int iret; -{ - char ab[512]; - - (void) uuconf_error_string (puuconf, iret, ab, sizeof ab); - if ((iret & UUCONF_ERROR_FILENAME) == 0) - fprintf (stderr, "uuconv: %s\n", ab); - else - fprintf (stderr, "uuconv:%s\n", ab); - if (UUCONF_ERROR_VALUE (iret) != UUCONF_FOPEN_FAILED) - exit (EXIT_FAILURE); -} diff --git a/gnu/libexec/uucp/uucp/Makefile b/gnu/libexec/uucp/uucp/Makefile deleted file mode 100644 index aef5933..0000000 --- a/gnu/libexec/uucp/uucp/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Makefile for uucp -# $FreeBSD$ - -PROG= uucp -SRCS= uucp.c util.c log.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -BINDIR= $(bindir) -BINOWN= $(owner) -BINMODE= 4555 -INSTALLFLAGS= -fschg - -.include <bsd.prog.mk> - -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uucp/uucp.1 b/gnu/libexec/uucp/uucp/uucp.1 deleted file mode 100644 index ab2457f..0000000 --- a/gnu/libexec/uucp/uucp/uucp.1 +++ /dev/null @@ -1,213 +0,0 @@ -.\" $Id: uucp.1,v 1.11 1995/06/26 21:34:49 ian Rel $ -.\" $FreeBSD$ -.TH uucp 1 "Taylor UUCP 1.06" -.SH NAME -uucp \- Unix to Unix copy -.SH SYNOPSIS -.B uucp -[ options ] source-file destination-file -.PP -.B uucp -[ options ] source-file... destination-directory -.SH DESCRIPTION -The -.I uucp -command copies files between systems. Each -.I file -argument is either a pathname on the local machine or is of the form -.IP -system!path -.LP -which is interpreted as being on a remote system. -In the first form, the contents of the first file are copied to the -second. In the second form, each source file is copied into the -destination directory. - -A file be transferred to or from -.I system2 -via -.I system1 -by using -.IP -system1!system2!path. -.LP - -Any pathname that does not begin with / or ~ will be appended to the -current directory (unless the -.B \-W -or -.B \--noexpand -option is used); this resulting path will not necessarily exist on a -remote system. A pathname beginning with a simple ~ starts at the -UUCP public directory; a pathname beginning with ~name starts at the -home directory of the named user. The ~ is interpreted on the -appropriate system. Note that some shells will interpret a simple ~ -to the local home directory before -.I uucp -sees it; to avoid this the ~ must be quoted. - -Shell metacharacters ? * [ ] are interpreted on the appropriate -system, assuming they are quoted to prevent the shell from -interpreting them first. - -The copy does not take place immediately, but is queued up for the -.I uucico -(8) daemon; the daemon is started immediately unless the -.B \-r -or -.B \-\-nouucico -switch is given. In any case, the next time the remote system is called the -file(s) will be copied. -.SH OPTIONS -The following options may be given to -.I uucp. -.TP 5 -.B \-c, \-\-nocopy -Do not copy local source files to the spool directory. If they are -removed before being processed by the -.I uucico -(8) daemon, the copy will fail. The files must be readable by the -.I uucico -(8) daemon, and by the invoking user. -.TP 5 -.B \-C, \-\-copy -Copy local source files to the spool directory. This is the default. -.TP 5 -.B \-d, \-\-directories -Create all necessary directories when doing the copy. This is the -default. -.TP 5 -.B \-f, \-\-nodirectories -If any necessary directories do not exist for the destination path, -abort the copy. -.TP 5 -.B \-R, \-\-recursive -If any of the source file names are directories, copy their contents -recursively to the destination (which must itself be a directory). -.TP 5 -.B \-g grade, \-\-grade grade -Set the grade of the file transfer command. Jobs of a higher grade -are executed first. Grades run 0 ... 9 A ... Z a ... z from high to -low. -.TP 5 -.B \-m, \-\-mail -Report completion or failure of the file transfer by -.I mail -(1). -.TP 5 -.B \-n user, \-\-notify user -Report completion or failure of the file transfer by -.I mail -(1) to the named -user on the remote system. -.TP 5 -.B \-r, \-\-nouucico -Do not start -.I uucico -(8) daemon immediately; merely queue up the file transfer for later -execution. -.TP 5 -.B \-j, \-\-jobid -Print jobid on standard output. The job may be -later cancelled by passing the jobid to the -.B \-k -switch of -.I uustat -(1). -It is possible for some complex operations to produce more than one -jobid, in which case each will be printed on a separate line. For -example -.br -.in +0.5i -.nf -uucp sys1!~user1/file1 sys2!~user2/file2 ~user3 -.fi -.in -0.5i -will generate two separate jobs, one for the system -.I sys1 -and one for the system -.I sys2. -.TP 5 -.B \-W, \-\-noexpand -Do not prepend remote relative path names with the current directory. -.TP 5 -.B \-t, \-\-uuto -This option is used by the -.I uuto -shell script. It causes -.I uucp -to interpret the final argument as -.I system!user. -The file(s) are sent to -.I ~/receive/USER/LOCAL -on the remote system, where -.I USER -is from the final argument and -.I LOCAL -is the local UUCP -system name. Also, -.I uucp -will act as though -.I \-\-notify user -were specified. -.TP 5 -.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, config, -spooldir and execute are meaningful for -.I uucp. - -Multiple types may be given, separated by commas, and the -.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 \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. -.TP 5 -.B \-I file, \-\-config file -Set configuration file to use. This option may not be available, -depending upon how -.I uucp -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/etc/uucp/config - Configuration file. -.br -/var/spool/uucp - -UUCP spool directory. -.br -/var/spool/uucp/Log - -UUCP log file. -.br -/var/spool/uucppublic - -Default UUCP public directory. -.SH SEE ALSO -mail(1), uux(1), uustat(1), uucico(8) -.SH BUGS -Some of the options are dependent on the capabilities of the -.I uucico -(8) daemon on the remote system. - -The -.I \-n -and -.I \-m -switches do not work when transferring a file from one remote system -to another. - -File modes are not preserved, except for the execute bit. The -resulting file is owned by the uucp user. -.SH AUTHOR -Ian Lance Taylor -<ian@airs.com> diff --git a/gnu/libexec/uucp/uucp/uucp.c b/gnu/libexec/uucp/uucp/uucp.c deleted file mode 100644 index 080ad0f..0000000 --- a/gnu/libexec/uucp/uucp/uucp.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* uucp.c - Prepare to copy a file to or from a remote system. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uucp_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Local functions. */ - -static void ucusage P((void)); -static void uchelp P((void)); -static void ucdirfile P((const char *zdir, const char *zfile, - pointer pinfo)); -static void uccopy P((const char *zfile, const char *zdest)); -static void ucadd_cmd P((const struct uuconf_system *qsys, - const struct scmd *qcmd, const char *zlog)); -static void ucspool_cmds P((boolean fjobid)); -static const char *zcone_system P((boolean *pfany)); -static void ucrecord_file P((const char *zfile)); -static void ucabort P((void)); - -/* Long getopt options. */ -static const struct option asClongopts[] = -{ - { "copy", no_argument, NULL, 'C' }, - { "nocopy", no_argument, NULL, 'c' }, - { "directories", no_argument, NULL, 'd' }, - { "nodirectories", no_argument, NULL, 'f' }, - { "grade", required_argument, NULL, 'g' }, - { "jobid", no_argument, NULL, 'j' }, - { "mail", no_argument, NULL, 'm' }, - { "notify", required_argument, NULL, 'n' }, - { "nouucico", no_argument, NULL, 'r' }, - { "recursive", no_argument, NULL, 'R' }, - { "status", required_argument, NULL, 's' }, - { "uuto", no_argument, NULL, 't' }, - { "user", required_argument, NULL, 'u' }, - { "noexpand", no_argument, NULL, 'w' }, - { "config", required_argument, NULL, 'I' }, - { "debug", required_argument, NULL, 'x' }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 1 }, - { NULL, 0, NULL, 0 } -}; - -/* Local variables. There are a bunch of these, mostly set by the - options and the last (the destination) argument. These have file - scope so that they may be easily passed into uccopy; they could for - the most part also be wrapped up in a structure and passed in. */ - -/* The uuconf global pointer. */ -static pointer pCuuconf; - -/* TRUE if source files should be copied to the spool directory. */ -static boolean fCcopy = TRUE; - -/* Grade to use. */ -static char bCgrade = BDEFAULT_UUCP_GRADE; - -/* Whether to send mail to the requesting user when the copy is - complete. */ -static boolean fCmail = FALSE; - -/* User to notify on remote system. */ -static const char *zCnotify = ""; - -/* TRUE if remote files should be prefixed with the current working - directory. */ -static boolean fCexpand = TRUE; - -/* TRUE if necessary directories should be created on the destination - system. */ -static boolean fCmkdirs = TRUE; - -/* Local name. */ -static const char *zClocalname; - -/* User name. */ -static const char *zCuser = NULL; - -/* TRUE if this is a remote request. */ -static boolean fCremote = FALSE; - -/* TRUE if the destination is this system. */ -static boolean fClocaldest; - -/* Destination system. */ -static struct uuconf_system sCdestsys; - -/* Systems to forward to, if not NULL. */ -static char *zCforward; - -/* Options to use when sending a file. */ -static char abCsend_options[20]; - -/* Options to use when receiving a file. */ -static char abCrec_options[20]; - -/* TRUE if the current file being copied from is in the cwd. */ -static boolean fCneeds_cwd; - -/* The main program. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -j: output job id. */ - boolean fjobid = FALSE; - /* -r: don't start uucico when finished. */ - boolean fuucico = TRUE; - /* -R: copy directories recursively. */ - boolean frecursive = FALSE; - /* -s: report status to named file. */ - const char *zstatus_file = NULL; - /* -t: emulate uuto. */ - boolean fuuto = FALSE; - int iopt; - pointer puuconf; - int iuuconf; - int i; - boolean fgetcwd; - struct uuconf_system slocalsys; - char *zexclam; - char *zdestfile; - const char *zdestsys; - char *zoptions; - boolean fexit; - - zProgram = argv[0]; - - while ((iopt = getopt_long (argc, argv, "cCdfg:I:jmn:prRs:tu:Wvx:", - asClongopts, (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'c': - /* Do not copy local files to spool directory. */ - fCcopy = FALSE; - break; - - case 'p': - case 'C': - /* Copy local files to spool directory. */ - fCcopy = TRUE; - break; - - case 'd': - /* Create directories if necessary. */ - fCmkdirs = TRUE; - break; - - case 'f': - /* Do not create directories if they don't exist. */ - fCmkdirs = FALSE; - break; - - case 'g': - /* Set job grade. */ - bCgrade = optarg[0]; - break; - - case 'I': - /* Name configuration file. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'j': - /* Output job id. */ - fjobid = TRUE; - break; - - case 'm': - /* Mail to requesting user. */ - fCmail = TRUE; - break; - - case 'n': - /* Notify remote user. */ - zCnotify = optarg; - break; - - case 'r': - /* Don't start uucico when finished. */ - fuucico = FALSE; - break; - - case 'R': - /* Copy directories recursively. */ - frecursive = TRUE; - break; - - case 's': - /* Report status to named file. */ - zstatus_file = optarg; - break; - - case 't': - /* Emulate uuto. */ - fuuto = TRUE; - break; - - case 'u': - /* Set user name. */ - zCuser = optarg; - break; - - case 'W': - /* Expand only local file names. */ - fCexpand = FALSE; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - uchelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - ucusage (); - /*NOTREACHED*/ - } - } - - if (! UUCONF_GRADE_LEGAL (bCgrade) - || ((bCgrade < '0' || bCgrade > '9') - && (bCgrade < 'a' || bCgrade > 'z') - && (bCgrade < 'A' || bCgrade > 'Z'))) - { - ulog (LOG_ERROR, "Ignoring illegal grade"); - bCgrade = BDEFAULT_UUCP_GRADE; - } - - /* The user name must contain a '!', which is treated as a remote - name, to avoid spoofing of other users (there is no advantage to - spoofing remote users, except to send them random bits of mail, - which you can do anyhow). */ - if (zCuser != NULL) - { - if (strchr (zCuser, '!') != NULL) - fCremote = TRUE; - else - { - ulog (LOG_ERROR, "Ignoring local user name"); - zCuser = NULL; - } - } - - if (argc - optind < 2) - ucusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - pCuuconf = puuconf; - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - /* See if we are going to need to know the current directory. We - just check each argument to see whether it's an absolute - pathname. We actually aren't going to need the cwd if fCexpand - is FALSE and the file is remote, but so what. */ - fgetcwd = FALSE; - for (i = optind; i < argc; i++) - { - zexclam = strrchr (argv[i], '!'); - if (zexclam == NULL) - zexclam = argv[i]; - else - ++zexclam; - if (fsysdep_needs_cwd (zexclam)) - { - fgetcwd = TRUE; - break; - } - } - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (puuconf, INIT_SUID | (fgetcwd ? INIT_GETCWD : 0)); - - ulog_fatal_fn (ucabort); - - if (zCuser == NULL) - zCuser = zsysdep_login_name (); - - iuuconf = uuconf_localname (puuconf, &zClocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zClocalname = zsysdep_localname (); - if (zClocalname == NULL) - exit (EXIT_FAILURE); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - /* Get the local system information. */ - iuuconf = uuconf_system_info (puuconf, zClocalname, &slocalsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - iuuconf = uuconf_system_local (puuconf, &slocalsys); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - slocalsys.uuconf_zname = (char *) zClocalname; - } - - /* If we are emulating uuto, translate the destination argument, and - notify the destination user. This had better not turn into - something that requires the current directory, or we may have - passed INIT_GETCWD incorrectly. */ - if (fuuto) - { - if (*zCnotify == '\0') - { - zexclam = strrchr (argv[argc - 1], '!'); - if (zexclam == NULL) - ucusage (); - zCnotify = zexclam + 1; - } - argv[argc - 1] = zsysdep_uuto (argv[argc - 1], zClocalname); - if (argv[argc - 1] == NULL) - ucusage (); - } - - /* Set up the file transfer options. */ - zoptions = abCsend_options; - if (fCcopy) - *zoptions++ = 'C'; - else - *zoptions++ = 'c'; - if (fCmkdirs) - *zoptions++ = 'd'; - else - *zoptions++ = 'f'; - if (fCmail) - *zoptions++ = 'm'; - if (*zCnotify != '\0') - *zoptions++ = 'n'; - *zoptions = '\0'; - - zoptions = abCrec_options; - if (fCmkdirs) - *zoptions++ = 'd'; - else - *zoptions++ = 'f'; - if (fCmail) - *zoptions++ = 'm'; - *zoptions = '\0'; - - argv[argc - 1] = zremove_local_sys (&slocalsys, argv[argc - 1]); - - zexclam = strchr (argv[argc - 1], '!'); - if (zexclam == NULL) - { - zdestsys = zClocalname; - zdestfile = argv[argc - 1]; - fClocaldest = TRUE; - } - else - { - size_t clen; - char *zcopy; - - clen = zexclam - argv[argc - 1]; - zcopy = zbufalc (clen + 1); - memcpy (zcopy, argv[argc - 1], clen); - zcopy[clen] = '\0'; - zdestsys = zcopy; - - zdestfile = zexclam + 1; - - fClocaldest = FALSE; - } - - iuuconf = uuconf_system_info (puuconf, zdestsys, &sCdestsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (fClocaldest) - { - iuuconf = uuconf_system_local (puuconf, &sCdestsys); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - sCdestsys.uuconf_zname = (char *) zClocalname; - } - else - { - if (! funknown_system (puuconf, zdestsys, &sCdestsys)) - ulog (LOG_FATAL, "%s: System not found", zdestsys); - } - } - - /* Here zdestfile is the destination file name following the - destination system name (if any); it may contain other systems to - forward the files through. Isolate the file from the list of - systems. */ - zexclam = strrchr (zdestfile, '!'); - if (zexclam == NULL) - zCforward = NULL; - else - { - size_t clen; - -#if DEBUG > 0 - if (fClocaldest) - ulog (LOG_FATAL, "Can't happen"); -#endif - clen = zexclam - zdestfile; - zCforward = zbufalc (clen + 1); - memcpy (zCforward, zdestfile, clen); - zCforward[clen] = '\0'; - zdestfile = zexclam + 1; - } - - /* Turn the destination into an absolute path, unless it is on a - remote system and -W was used. */ - if (fClocaldest) - zdestfile = zsysdep_local_file_cwd (zdestfile, sCdestsys.uuconf_zpubdir, - (boolean *) NULL); - else if (fCexpand) - zdestfile = zsysdep_add_cwd (zdestfile); - if (zdestfile == NULL) - { - ulog_close (); - usysdep_exit (FALSE); - } - - /* Process each source argument. */ - for (i = optind; i < argc - 1 && ! FGOT_SIGNAL (); i++) - { - boolean flocal; - char *zfrom; - - fCneeds_cwd = FALSE; - - argv[i] = zremove_local_sys (&slocalsys, argv[i]); - - if (strchr (argv[i], '!') != NULL) - { - flocal = FALSE; - zfrom = zbufcpy (argv[i]); - } - else - { - /* This is a local file. Make sure we get it out of the - original directory. We don't support local wildcards, - leaving that to the shell. */ - flocal = TRUE; - if (fsysdep_needs_cwd (argv[i])) - fCneeds_cwd = TRUE; - zfrom = zsysdep_local_file_cwd (argv[i], - sCdestsys.uuconf_zpubdir, - (boolean *) NULL); - if (zfrom == NULL) - ucabort (); - } - - if (! flocal || ! fsysdep_directory (zfrom)) - uccopy (zfrom, zdestfile); - else - { - char *zbase, *zindir; - - if (! frecursive) - ulog (LOG_FATAL, "%s: directory without -R", zfrom); - - zbase = zsysdep_base_name (zfrom); - if (zbase == NULL) - ucabort (); - zindir = zsysdep_in_dir (zdestfile, zbase); - ubuffree (zbase); - if (zindir == NULL) - ucabort (); - usysdep_walk_tree (zfrom, ucdirfile, zindir); - ubuffree (zindir); - } - - ubuffree (zfrom); - } - - /* See if we got an interrupt, presumably from the user. */ - if (FGOT_SIGNAL ()) - ucabort (); - - /* Now push out the actual commands, making log entries for them. */ - ulog_to_file (puuconf, TRUE); - ulog_user (zCuser); - - ucspool_cmds (fjobid); - - ulog_close (); - - if (! fuucico) - fexit = TRUE; - else - { - const char *zsys; - boolean fany; - - zsys = zcone_system (&fany); - - if (zsys == NULL && ! fany) - fexit = TRUE; - else - { - const char *zarg; - char *zconfigarg; - - if (zsys == NULL) - zarg = "-r1"; - else - { - char *z; - - z = zbufalc (sizeof "-Cs" + strlen (zsys)); - sprintf (z, "-Cs%s", zsys); - zarg = z; - } - - if (zconfig == NULL) - zconfigarg = NULL; - else - { - zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig)); - sprintf (zconfigarg, "-I%s", zconfig); - } - - fexit = fsysdep_run (FALSE, "uucico", zarg, zconfigarg); - } - } - - usysdep_exit (fexit); - - /* Avoid error about not returning. */ - return 0; -} - -/* Print usage message and die. */ - -static void -ucusage () -{ - fprintf (stderr, - "Usage: %s [options] file1 [file2 ...] dest\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print help message. */ - -static void -uchelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [options] file1 [file2 ...] dest\n", zProgram); - printf (" -c,--nocopy: Do not copy local files to spool directory\n"); - printf (" -C,-p,--copy: Copy local files to spool directory (default)\n"); - printf (" -d,--directories: Create necessary directories (default)\n"); - printf (" -f,--nodirectories: Do not create directories (fail if they do not exist)\n"); - printf (" -g,--grade grade: Set job grade (must be alphabetic)\n"); - printf (" -m,--mail: Report status of copy by mail\n"); - printf (" -n,--notify user: Report status of copy by mail to remote user\n"); - printf (" -R,--recursive: Copy directories recursively\n"); - printf (" -r,--nouucico: Do not start uucico daemon\n"); - printf (" -s,--status file: Report completion status to file\n"); - printf (" -j,--jobid: Report job id\n"); - printf (" -W,--noexpand: Do not add current directory to remote filenames\n"); - printf (" -t,--uuto: Emulate uuto\n"); - printf (" -u,--usage name: Set user name\n"); - printf (" -x,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} - -/* This is called for each file in a directory heirarchy. */ - -static void -ucdirfile (zfull, zrelative, pinfo) - const char *zfull; - const char *zrelative; - pointer pinfo; -{ - const char *zdestfile = (const char *) pinfo; - char *zto; - - zto = zsysdep_in_dir (zdestfile, zrelative); - if (zto == NULL) - ucabort (); - - uccopy (zfull, zto); - - ubuffree (zto); -} - -/* Handle the copying of one regular file. The zdest argument is the - destination file; if we are recursively copying a directory, it - will be extended by any subdirectory names. Note that zdest is an - absolute path. */ - -static void -uccopy (zfile, zdest) - const char *zfile; - const char *zdest; -{ - struct scmd s; - char *zexclam; - char *zto; - - zexclam = strchr (zfile, '!'); - - if (zexclam == NULL) - { - openfile_t efrom; - - /* Copy from a local file. Make sure the user has access to - this file, since we are running setuid. */ - if (! fsysdep_access (zfile)) - ucabort (); - - /* If this copy is being requested by a remote system, we may - transfer the file if it needs the current working directory - (meaning, I hope, that it is in the execution directory) or - it is on the permitted transfer list. Note that unlike most - of the other checks, this one is not double-checked by - uucico. */ - if (fCremote - && ! fCneeds_cwd - && ! fin_directory_list (zfile, sCdestsys.uuconf_pzremote_send, - sCdestsys.uuconf_zpubdir, TRUE, - TRUE, (const char *) NULL)) - ulog (LOG_FATAL, "Not permitted to send %s", zfile); - - if (fClocaldest) - { - boolean fok; - - /* Copy one local file to another. */ - - /* Check that we have permission to receive into the desired - directory. */ - if (fCremote) - fok = fin_directory_list (zdest, - sCdestsys.uuconf_pzremote_receive, - sCdestsys.uuconf_zpubdir, TRUE, - FALSE, (const char *) NULL); - else - fok = fin_directory_list (zdest, - sCdestsys.uuconf_pzlocal_receive, - sCdestsys.uuconf_zpubdir, TRUE, - FALSE, zCuser); - if (! fok) - ulog (LOG_FATAL, "Not permitted to receive to %s", zdest); - - zto = zsysdep_add_base (zdest, zfile); - if (zto == NULL) - ucabort (); - - efrom = esysdep_user_fopen (zfile, TRUE, TRUE); - if (! ffileisopen (efrom)) - ucabort (); - if (! fcopy_open_file (efrom, zto, FALSE, fCmkdirs, TRUE)) - ucabort (); - (void) ffileclose (efrom); - ubuffree (zto); - } - else - { - const char *zloc; - char abtname[CFILE_NAME_LEN]; - unsigned int imode; - char *ztemp; - - /* Copy a local file to a remote file. We may have to - copy the local file to the spool directory. */ - imode = ixsysdep_file_mode (zfile); - if (imode == 0) - ucabort (); - - zloc = sCdestsys.uuconf_zlocalname; - if (zloc == NULL) - zloc = zClocalname; - - ztemp = zsysdep_data_file_name (&sCdestsys, zloc, bCgrade, - FALSE, abtname, (char *) NULL, - (char *) NULL); - if (ztemp == NULL) - ucabort (); - - if (! fCcopy) - { - /* If we are copying the file, we don't actually use the - temporary file; we still want to get a name for the - other system to use as a key for file restart. */ - ubuffree (ztemp); - - /* Make sure the daemon will be permitted to send - this file. */ - if (! fsysdep_daemon_access (zfile)) - ucabort (); - if (! fin_directory_list (zfile, sCdestsys.uuconf_pzlocal_send, - sCdestsys.uuconf_zpubdir, TRUE, TRUE, - (fCremote - ? (const char *) NULL - : zCuser))) - ulog (LOG_FATAL, - "Daemon not permitted to send %s (suggest --copy)", - zfile); - } - else - { - efrom = esysdep_user_fopen (zfile, TRUE, TRUE); - if (! ffileisopen (efrom)) - ucabort (); - ucrecord_file (ztemp); - if (! fcopy_open_file (efrom, ztemp, FALSE, TRUE, TRUE)) - ucabort (); - (void) ffileclose (efrom); - } - - if (zCforward == NULL) - { - /* We're not forwarding. Just send the file. */ - s.bcmd = 'S'; - s.bgrade = bCgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (zfile); - s.zto = zbufcpy (zdest); - s.zuser = zCuser; - s.zoptions = abCsend_options; - s.ztemp = zbufcpy (abtname); - s.imode = imode; - s.znotify = zCnotify; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ucadd_cmd (&sCdestsys, &s, (const char *) NULL); - } - else - { - char *zbase; - char *zxqt; - char abxtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - char abxname[CFILE_NAME_LEN]; - FILE *e; - char *zlog; - - /* We want to forward this file through sCdestsys to - some other system(s). We set up a remote execution - of uucp on sCdestsys to forward the file along. */ - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - ucabort (); - - zxqt = zsysdep_data_file_name (&sCdestsys, zloc, bCgrade, - TRUE, abxtname, abdname, - abxname); - if (zxqt == NULL) - ucabort (); - e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE); - if (e == NULL) - ucabort (); - ucrecord_file (zxqt); - - fprintf (e, "U %s %s\n", zCuser, zloc); - fprintf (e, "F %s %s\n", abdname, zbase); - fprintf (e, "C uucp -C"); - if (fCmkdirs) - fprintf (e, " -d"); - else - fprintf (e, " -f"); - fprintf (e, " -g %c", bCgrade); - if (fCmail) - fprintf (e, " -m"); - if (*zCnotify != '\0') - fprintf (e, " -n %s", zCnotify); - if (! fCexpand) - fprintf (e, " -W"); - fprintf (e, " %s %s!%s\n", zbase, zCforward, zdest); - - ubuffree (zbase); - - if (! fstdiosync (e, zxqt)) - ulog (LOG_FATAL, "fsync failed"); - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - /* Send the execution file. */ - s.bcmd = 'S'; - s.bgrade = bCgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (abxtname); - s.zto = zbufcpy (abxname); - s.zuser = zCuser; - s.zoptions = "C"; - s.ztemp = s.zfrom; - s.imode = 0666; - s.znotify = NULL; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - zlog = zbufalc (sizeof "Queuing uucp !" + strlen (zfile) - + strlen (zCforward) + strlen (zdest)); - sprintf (zlog, "Queuing uucp %s %s!%s", zfile, zCforward, - zdest); - - ucadd_cmd (&sCdestsys, &s, zlog); - - /* Send the data file. */ - s.bcmd = 'S'; - s.bgrade = bCgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (zfile); - s.zto = zbufcpy (abdname); - s.zuser = zCuser; - s.zoptions = fCcopy ? "C" : "c"; - s.ztemp = zbufcpy (abtname); - s.imode = 0666; - s.znotify = NULL; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ucadd_cmd (&sCdestsys, &s, ""); - } - } - } - else - { - char *zfrom; - char *zforward; - size_t clen; - char *zcopy; - struct uuconf_system *qfromsys; - int iuuconf; - const char *zloc; - - /* Copy from a remote file. Get the file name after any systems - we may need to forward the file from. */ - zfrom = strrchr (zfile, '!'); - if (zfrom == zexclam) - zforward = NULL; - else - { - clen = zfrom - zexclam - 1; - zforward = zbufalc (clen + 1); - memcpy (zforward, zexclam + 1, clen); - zforward[clen] = '\0'; - } - - ++zfrom; - if (fCexpand) - { - /* Add the current directory to the filename if it's not - already there. */ - zfrom = zsysdep_add_cwd (zfrom); - if (zfrom == NULL) - ucabort (); - } - - /* Read the system information. */ - clen = zexclam - zfile; - zcopy = zbufalc (clen + 1); - memcpy (zcopy, zfile, clen); - zcopy[clen] = '\0'; - - qfromsys = ((struct uuconf_system *) - xmalloc (sizeof (struct uuconf_system))); - - iuuconf = uuconf_system_info (pCuuconf, zcopy, qfromsys); - if (iuuconf == UUCONF_NOT_FOUND) - { - if (! funknown_system (pCuuconf, zcopy, qfromsys)) - ulog (LOG_FATAL, "%s: System not found", zcopy); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, pCuuconf, iuuconf); - ubuffree (zcopy); - - zloc = qfromsys->uuconf_zlocalname; - if (zloc == NULL) - zloc = zClocalname; - - if (zforward == NULL && fClocaldest) - { - boolean fok; - - /* The file is to come directly from qfromsys to the local - system. */ - - /* Check that we have permission to receive into the desired - directory. If we don't have permission, uucico will - fail. */ - if (fCremote) - fok = fin_directory_list (zdest, - qfromsys->uuconf_pzremote_receive, - qfromsys->uuconf_zpubdir, TRUE, - FALSE, (const char *) NULL); - else - fok = fin_directory_list (zdest, - qfromsys->uuconf_pzlocal_receive, - qfromsys->uuconf_zpubdir, TRUE, - FALSE, zCuser); - if (! fok) - ulog (LOG_FATAL, "Not permitted to receive to %s", zdest); - - /* If the remote filespec is wildcarded, we must generate an - 'X' request. We currently check for Unix shell - wildcards. Note that it should do no harm to mistake a - non-wildcard for a wildcard. */ - if (zfrom[strcspn (zfrom, "*?[")] != '\0') - { - s.bcmd = 'X'; - zto = zbufalc (strlen (zloc) + strlen (zdest) + sizeof "!"); - sprintf (zto, "%s!%s", zloc, zdest); - } - else - { - s.bcmd = 'R'; - zto = zbufcpy (zdest); - } - - s.bgrade = bCgrade; - s.pseq = NULL; - s.zfrom = zfrom; - s.zto = zto; - s.zuser = zCuser; - s.zoptions = abCrec_options; - s.ztemp = ""; - s.imode = 0; - s.znotify = ""; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ucadd_cmd (qfromsys, &s, (const char *) NULL); - } - else - { - char *zxqt; - char abtname[CFILE_NAME_LEN]; - char abxname[CFILE_NAME_LEN]; - FILE *e; - char *zcmd; - char *zlog; - - /* The file either comes from some other system through - qfromsys or is intended for some other system. Send an - execution request to qfromsys to handle everything. */ - zxqt = zsysdep_data_file_name (qfromsys, zloc, bCgrade, TRUE, - abtname, (char *) NULL, - abxname); - if (zxqt == NULL) - ucabort (); - e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE); - if (e == NULL) - ucabort (); - ucrecord_file (zxqt); - - fprintf (e, "U %s %s\n", zCuser, zloc); - fprintf (e, "C uucp -C"); - if (fCmkdirs) - fprintf (e, " -d"); - else - fprintf (e, " -f"); - fprintf (e, " -g %c", bCgrade); - if (fCmail) - fprintf (e, " -m"); - if (*zCnotify != '\0') - fprintf (e, " -n %s", zCnotify); - if (! fCexpand) - fprintf (e, " -W"); - - clen = (strlen (zfrom) + strlen (zloc) - + strlen (sCdestsys.uuconf_zname) + strlen (zdest)); - if (zforward != NULL) - clen += strlen (zforward); - if (zCforward != NULL) - clen += strlen (zCforward); - zcmd = zbufalc (sizeof "! !!!" + clen); - *zcmd = '\0'; - if (zforward != NULL) - sprintf (zcmd + strlen (zcmd), "%s!", zforward); - sprintf (zcmd + strlen (zcmd), "%s %s!", zfrom, zloc); - if (! fClocaldest) - sprintf (zcmd + strlen (zcmd), "%s!", sCdestsys.uuconf_zname); - if (zCforward != NULL) - sprintf (zcmd + strlen (zcmd), "%s!", zCforward); - sprintf (zcmd + strlen (zcmd), "%s", zdest); - - fprintf (e, " %s\n", zcmd); - - if (! fstdiosync (e, zxqt)) - ulog (LOG_FATAL, "fsync failed"); - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - /* Send the execution file. */ - s.bcmd = 'S'; - s.bgrade = bCgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (abtname); - s.zto = zbufcpy (abxname); - s.zuser = zCuser; - s.zoptions = "C"; - s.ztemp = s.zfrom; - s.imode = 0666; - s.znotify = NULL; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - zlog = zbufalc (sizeof "Queueing uucp " + strlen (zcmd)); - sprintf (zlog, "Queueing uucp %s", zcmd); - - ucadd_cmd (qfromsys, &s, zlog); - - ubuffree (zcmd); - ubuffree (zforward); - } - } -} - -/* We keep a list of jobs for each system. */ - -struct sjob -{ - struct sjob *qnext; - const struct uuconf_system *qsys; - int ccmds; - struct scmd *pascmds; - const char **pazlogs; -}; - -static struct sjob *qCjobs; - -static void -ucadd_cmd (qsys, qcmd, zlog) - const struct uuconf_system *qsys; - const struct scmd *qcmd; - const char *zlog; -{ - struct sjob *qjob; - - if (! qsys->uuconf_fcall_transfer - && ! qsys->uuconf_fcalled_transfer) - ulog (LOG_FATAL, "Not permitted to transfer files to or from %s", - qsys->uuconf_zname); - - for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext) - if (strcmp (qjob->qsys->uuconf_zname, qsys->uuconf_zname) == 0) - break; - - if (qjob == NULL) - { - qjob = (struct sjob *) xmalloc (sizeof (struct sjob)); - qjob->qnext = qCjobs; - qjob->qsys = qsys; - qjob->ccmds = 0; - qjob->pascmds = NULL; - qjob->pazlogs = NULL; - qCjobs = qjob; - } - - qjob->pascmds = ((struct scmd *) - xrealloc ((pointer) qjob->pascmds, - (qjob->ccmds + 1) * sizeof (struct scmd))); - qjob->pascmds[qjob->ccmds] = *qcmd; - qjob->pazlogs = ((const char **) - xrealloc ((pointer) qjob->pazlogs, - (qjob->ccmds + 1) * sizeof (const char *))); - qjob->pazlogs[qjob->ccmds] = zlog; - ++qjob->ccmds; -} - -static void -ucspool_cmds (fjobid) - boolean fjobid; -{ - struct sjob *qjob; - char *zjobid; - - for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext) - { - ulog_system (qjob->qsys->uuconf_zname); - zjobid = zsysdep_spool_commands (qjob->qsys, bCgrade, qjob->ccmds, - qjob->pascmds); - if (zjobid != NULL) - { - int i; - struct scmd *qcmd; - const char **pz; - - for (i = 0, qcmd = qjob->pascmds, pz = qjob->pazlogs; - i < qjob->ccmds; - i++, qcmd++, pz++) - { - if (*pz != NULL) - { - if (**pz != '\0') - ulog (LOG_NORMAL, "%s", *pz); - } - else if (qcmd->bcmd == 'S') - ulog (LOG_NORMAL, "Queuing send of %s to %s", - qcmd->zfrom, qcmd->zto); - else if (qcmd->bcmd == 'R') - ulog (LOG_NORMAL, "Queuing request of %s to %s", - qcmd->zfrom, qcmd->zto); - else - { - const char *zto; - - zto = strrchr (qcmd->zto, '!'); - if (zto != NULL) - ++zto; - else - zto = qcmd->zto; - ulog (LOG_NORMAL, "Queuing request of %s to %s", - qcmd->zfrom, zto); - } - } - - if (fjobid) - printf ("%s\n", zjobid); - - ubuffree (zjobid); - } - } -} - -/* Return the system name for which we have created commands, or NULL - if we've created commands for more than one system. Set *pfany to - FALSE if we didn't create work for any system. */ - -static const char * -zcone_system (pfany) - boolean *pfany; -{ - if (qCjobs == NULL) - { - *pfany = FALSE; - return NULL; - } - - *pfany = TRUE; - - if (qCjobs->qnext == NULL) - return qCjobs->qsys->uuconf_zname; - else - return NULL; -} - -/* Keep track of all files we have created so that we can delete them - if we get a signal. The argument will be on the heap. */ - -static int cCfiles; -static const char **pCaz; - -static void -ucrecord_file (zfile) - const char *zfile; -{ - pCaz = (const char **) xrealloc ((pointer) pCaz, - (cCfiles + 1) * sizeof (const char *)); - pCaz[cCfiles] = zfile; - ++cCfiles; -} - -/* Delete all the files we have recorded and exit. */ - -static void -ucabort () -{ - int i; - - for (i = 0; i < cCfiles; i++) - (void) remove (pCaz[i]); - ulog_close (); - usysdep_exit (FALSE); -} diff --git a/gnu/libexec/uucp/uulog/Makefile b/gnu/libexec/uucp/uulog/Makefile deleted file mode 100644 index 9724cd5..0000000 --- a/gnu/libexec/uucp/uulog/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for uulog -# $FreeBSD$ - -BINDIR= $(bindir) - -PROG= uulog -SRCS= uulog.c log.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -.include <bsd.prog.mk> -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uulog/uulog.1 b/gnu/libexec/uucp/uulog/uulog.1 deleted file mode 100644 index d93ff61..0000000 --- a/gnu/libexec/uucp/uulog/uulog.1 +++ /dev/null @@ -1,84 +0,0 @@ -.\" $FreeBSD$ -.TH uulog 1 "Taylor UUCP 1.06" -.SH NAME -uulog \- display UUCP log entries -.SH SYNOPSIS -.B uulog -[-#] [-n lines] [-sf system] [-u user] [-DSF] [--lines lines] -[--system system] [--user user] [--debuglog] [--statslog] -[--follow] [--follow=system] [standard UUCP options] -.SH DESCRIPTION -The -.B uulog -program can be used to display entries in the UUCP log -file. It can select the entries for a particular system or a -particular user. You can use it to see what has happened to your -queued jobs in the past. -.SH OPTIONS -The following options may be given to -.B uulog. -.TP 5 -.B \-#, \-n lines, \-\-lines lines -Here `#' is a number; e.g., `-10'. The specified number of lines -is displayed from the end of the log file. The default is to -display the entire log file, unless the `-f', `-F', or `--follow' -options are used, in which case the default is to display 10 lines. -.TP 5 -.B \-s system, \-\-system system -Display only log entries pertaining to the specified system. -.TP 5 -.B \-u user, \-\-user user -Display only log entries pertaining to the specified user. -.TP 5 -.B \-D, \-\-debuglog -Display the debugging log file. -.TP 5 -.B \-S, \-\-statslog -Display the statistics log file. -.B \-F, \-\-follow -Keep displaying the log file forever, printing new lines as they -are appended to the log file. -.TP 5 -.B \-f system, \-\-follow=system -Keep displaying the log file forever, displaying only log entries -pertaining to the specified system. -.TP 5 -.B \-X type -.TP 5 -.B \-\-debug type -.TP 5 -.B \-I file -.TP 5 -.B \-\-config file -.TP 5 -.B \-v, \-\-version -.TP 5 -.B \-\-help -Standard UUCP options. -Note that -.B uulog -specifies the debugging type using `-X' rather than the usual `-x'. -.PP -The operation of -.B uulog -depends to some degree upon the type of log -files generated by the UUCP programs. This is a compile time option. -If the UUCP programs have been compiled to use HDB style log files, -.B uulog -changes in the following ways: -.PP -The new options `-x' and `--uuxqtlog' may be used to list the -.B uuxqt -log file. -.PP -It is no longer possible to omit all arguments: one of `-s', -`--system', `-f', `--follow=system', `-D', `--debuglog', `-S', -`--statslog', `-x', or `--uuxqtlog' must be used. -.PP -The option `--system ANY' may be used to list log file entries -which do not pertain to any particular system. -.SH SEE ALSO -uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. diff --git a/gnu/libexec/uucp/uulog/uulog.c b/gnu/libexec/uucp/uulog/uulog.c deleted file mode 100644 index 440289e..0000000 --- a/gnu/libexec/uucp/uulog/uulog.c +++ /dev/null @@ -1,492 +0,0 @@ -/* uulog.c - Display the UUCP log file. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uulog_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* This is a pretty bad implementation of uulog, which I don't think - is a very useful program anyhow. It only takes a single -s and/or - -u switch. When using HAVE_HDB_LOGGING it requires a system. */ - -/* Local functions. */ - -static void ulusage P((void)); -static void ulhelp P((void)); - -/* Long getopt options. */ -static const struct option asLlongopts[] = -{ - { "debuglog", no_argument, NULL, 'D' }, - { "follow", optional_argument, NULL, 2 }, - { "lines", required_argument, NULL, 'n' }, - { "system", required_argument, NULL, 's' }, - { "statslog", no_argument, NULL, 'S' }, - { "user", required_argument, NULL, 'u' }, - { "uuxqtlog", no_argument, NULL, 'x' }, - { "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) - int argc; - char **argv; -{ - /* -D: display Debug file */ - boolean fdebug = FALSE; - /* -f: keep displaying lines forever. */ - boolean fforever = FALSE; - /* -n lines: number of lines to display. */ - int cshow = 0; - /* -s: system name. */ - const char *zsystem = NULL; - /* -S: display Stats file */ - boolean fstats = FALSE; - /* -u: user name. */ - const char *zuser = NULL; - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -x: display uuxqt log file. */ - boolean fuuxqt = FALSE; - int i; - int iopt; - pointer puuconf; - int iuuconf; - const char *zlogfile; - const char *zstatsfile; - const char *zdebugfile; - const char *zfile; - FILE *e; - char **pzshow = NULL; - int ishow = 0; - size_t csystem = 0; - size_t cuser = 0; - char *zline; - size_t cline; - - zProgram = argv[0]; - - /* Look for a straight number argument, and convert it to -n before - passing the arguments to getopt. */ - for (i = 0; i < argc; i++) - { - if (argv[i][0] == '-' && isdigit (argv[i][1])) - { - size_t clen; - char *znew; - - clen = strlen (argv[i]); - znew = zbufalc (clen + 2); - znew[0] = '-'; - znew[1] = 'n'; - memcpy (znew + 2, argv[i] + 1, clen); - argv[i] = znew; - } - } - - while ((iopt = getopt_long (argc, argv, "Df:FI:n:s:Su:vxX:", asLlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'D': - /* Show debugging file. */ - fdebug = TRUE; - break; - - case 'f': - /* Keep displaying lines forever for a particular system. */ - fforever = TRUE; - zsystem = optarg; - if (cshow == 0) - cshow = 10; - break; - - case 'F': - /* Keep displaying lines forever. */ - fforever = TRUE; - if (cshow == 0) - cshow = 10; - break; - - case 'I': - /* Configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'n': - /* Number of lines to display. */ - cshow = (int) strtol (optarg, (char **) NULL, 10); - break; - - case 's': - /* System name. */ - zsystem = optarg; - break; - - case 'S': - /* Show statistics file. */ - fstats = TRUE; - break; - - case 'u': - /* User name. */ - zuser = optarg; - break; - - case 'x': - /* Display uuxqt log file. */ - fuuxqt = TRUE; - break; - - case 'X': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 2: - /* --follow. */ - fforever = TRUE; - if (cshow == 0) - cshow = 10; - if (optarg != NULL) - zsystem = optarg; - break; - - case 1: - /* --help. */ - ulhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - ulusage (); - /*NOTREACHED*/ - } - } - - if (optind != argc || (fstats && fdebug)) - ulusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - iuuconf = uuconf_logfile (puuconf, &zlogfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - iuuconf = uuconf_statsfile (puuconf, &zstatsfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - iuuconf = uuconf_debugfile (puuconf, &zdebugfile); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - usysdep_initialize (puuconf, INIT_NOCHDIR); - - if (zsystem != NULL) - { -#if HAVE_HDB_LOGGING - if (strcmp (zsystem, "ANY") != 0) -#endif - { - struct uuconf_system ssys; - - /* Canonicalize the system name. If we can't find the - system information, just use whatever we were given so - that people can check on systems that logged in - anonymously. */ - iuuconf = uuconf_system_info (puuconf, zsystem, &ssys); - if (iuuconf == UUCONF_SUCCESS) - { - zsystem = zbufcpy (ssys.uuconf_zname); - (void) uuconf_system_free (puuconf, &ssys); - } - } - } - - if (fstats) - zfile = zstatsfile; - else if (fdebug) - zfile = zdebugfile; - else - { -#if ! HAVE_HDB_LOGGING - zfile = zlogfile; -#else - const char *zprogram; - char *zalc; - - /* We need a system to find a HDB log file. */ - if (zsystem == NULL) - ulog (LOG_FATAL, - "system name (-s argument) required for HDB format log files"); - - if (fuuxqt) - zprogram = "uuxqt"; - else - zprogram = "uucico"; - - zalc = zbufalc (strlen (zlogfile) - + strlen (zprogram) - + strlen (zsystem) - + 1); - sprintf (zalc, zlogfile, zprogram, zsystem); - zfile = zalc; - - if (! fsysdep_file_exists (zfile)) - ulog (LOG_FATAL, "no log file available for system %s", zsystem); - - if (strcmp (zsystem, "ANY") == 0) - zsystem = NULL; -#endif - } - - e = fopen (zfile, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - usysdep_exit (FALSE); - } - - if (cshow > 0) - { - pzshow = (char **) xmalloc (cshow * sizeof (char *)); - for (ishow = 0; ishow < cshow; ishow++) - pzshow[ishow] = NULL; - ishow = 0; - } - - /* Read the log file and output the appropriate lines. */ - if (zsystem != NULL) - csystem = strlen (zsystem); - - if (zuser != NULL) - cuser = strlen (zuser); - - zline = NULL; - cline = 0; - - while (TRUE) - { - while (getline (&zline, &cline, e) > 0) - { - char *zluser, *zlsys, *znext; - size_t cluser, clsys; - - /* Skip any leading whitespace (not that there should be - any). */ - znext = zline + strspn (zline, " \t"); - - if (! fstats) - { -#if ! HAVE_TAYLOR_LOGGING - /* The user name is the first field on the line. */ - zluser = znext; - cluser = strcspn (znext, " \t"); -#endif - - /* Skip the first field. */ - znext += strcspn (znext, " \t"); - znext += strspn (znext, " \t"); - - /* The system is the second field on the line. */ - zlsys = znext; - clsys = strcspn (znext, " \t"); - - /* Skip the second field. */ - znext += clsys; - znext += strspn (znext, " \t"); - -#if HAVE_TAYLOR_LOGGING - /* The user is the third field on the line. */ - zluser = znext; - cluser = strcspn (znext, " \t"); -#endif - } - else - { -#if ! HAVE_HDB_LOGGING - /* The user name is the first field on the line, and the - system name is the second. */ - zluser = znext; - cluser = strcspn (znext, " \t"); - znext += cluser; - znext += strspn (znext, " \t"); - zlsys = znext; - clsys = strcspn (znext, " \t"); -#else - /* The first field is system!user. */ - zlsys = znext; - clsys = strcspn (znext, "!"); - znext += clsys + 1; - zluser = znext; - cluser = strcspn (znext, " \t"); -#endif - } - - /* See if we should print this line. */ - if (zsystem != NULL - && (csystem != clsys - || strncmp (zsystem, zlsys, clsys) != 0)) - continue; - - if (zuser != NULL - && (cuser != cluser - || strncmp (zuser, zluser, cluser) != 0)) - continue; - - /* Output the line, or save it if we are outputting only a - particular number of lines. */ - if (cshow <= 0) - printf ("%s", zline); - else - { - ubuffree ((pointer) pzshow[ishow]); - pzshow[ishow] = zbufcpy (zline); - ishow = (ishow + 1) % cshow; - } - } - - /* Output the number of lines requested by the -n option. */ - if (cshow > 0) - { - for (i = 0; i < cshow; i++) - { - if (pzshow[ishow] != NULL) - printf ("%s", pzshow[ishow]); - ishow = (ishow + 1) % cshow; - } - } - - /* If -f was not specified, or an error occurred while reading - the file, get out. */ - if (! fforever || ferror (e)) - break; - - clearerr (e); - cshow = 0; - - /* Sleep 1 second before going around the loop again. */ - usysdep_sleep (1); - } - - (void) fclose (e); - - ulog_close (); - - usysdep_exit (TRUE); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ulusage () -{ - fprintf (stderr, - "Usage: %s [-n #] [-sf system] [-u user] [-xDSF] [-I file] [-X debug]\n", - zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void -ulhelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); -#if HAVE_HDB_LOGGING - printf ("Usage: %s [-n #] [-sf system] [-u user] [-xDS] [-I file] [-X debug]\n", - zProgram); -#else - printf ("Usage: %s [-n #] [-sf system] [-u user] [-DSF] [-I file] [-X debug]\n", - zProgram); -#endif - printf (" -n,--lines: show given number of lines from end of log\n"); - printf (" -s,--system: print entries for named system\n"); - printf (" -f system,--follow=system: follow entries for named system\n"); - printf (" -u,--user user: print entries for named user\n"); -#if HAVE_HDB_LOGGING - printf (" -x,--uuxqt: print uuxqt log rather than uucico log\n"); -#else - printf (" -F,--follow: follow entries for any system\n"); -#endif - printf (" -S,--statslog: show statistics file\n"); - printf (" -D,--debuglog: show debugging file\n"); - printf (" -X,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} diff --git a/gnu/libexec/uucp/uuname/Makefile b/gnu/libexec/uucp/uuname/Makefile deleted file mode 100644 index f30b10f..0000000 --- a/gnu/libexec/uucp/uuname/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Makefile for uuname -# $FreeBSD$ - -PROG= uuname -SRCS= uuname.c log.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -BINDIR= $(bindir) -BINOWN= $(owner) -BINMODE= 4555 -INSTALLFLAGS= -fschg - -.include <bsd.prog.mk> - -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uuname/uuname.1 b/gnu/libexec/uucp/uuname/uuname.1 deleted file mode 100644 index f90d94b..0000000 --- a/gnu/libexec/uucp/uuname/uuname.1 +++ /dev/null @@ -1,45 +0,0 @@ -.\" $FreeBSD$ -.TH uuname 1 "Taylor UUCP 1.06" -.SH NAME -uuname \- list known remote UUCP sites -.SH SYNOPSIS -.B uuname -[-a] [-l] [standard UUCP options] -.SH DESCRIPTION -The -.B uuname -program by default lists all the remote systems your -system knows about. You can also use it to get the name of your -local system. It is mostly useful for shell scripts. -.SH OPTIONS -The following options may be given to -.B uuname. -.TP 5 -.B \-a, \-\-aliases -List all aliases for remote systems, as well as their canonical -names. Aliases may be specified in the -.I sys -file. -.TP 5 -.B \-l, \-\-local -Print the UUCP name of the local system, rather than listing the -names of all the remote systems. -.TP 5 -.B \-x type -.TP 5 -.B \-\-debug type -.TP 5 -.B \-I file -.TP 5 -.B \-\-config file -.TP 5 -.B \-v, \-\-version -.TP 5 -.B \-\-help -Standard UUCP options. -.SH SEE ALSO -uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. - diff --git a/gnu/libexec/uucp/uuname/uuname.c b/gnu/libexec/uucp/uuname/uuname.c deleted file mode 100644 index 8500c33..0000000 --- a/gnu/libexec/uucp/uuname/uuname.c +++ /dev/null @@ -1,202 +0,0 @@ -/* uuname.c - List the names of known remote UUCP sites. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uuname_rcsid[] = "$FreeBSD$"; -#endif - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Local functions. */ - -static void unusage P((void)); -static void unhelp P((void)); - -/* Long getopt options. */ -static const struct option asNlongopts[] = -{ - { "aliases", no_argument, NULL, 'a' }, - { "local", no_argument, NULL, 'l' }, - { "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) - int argc; - char **argv; -{ - /* -a: display aliases. */ - boolean falias = FALSE; - /* -l: if true, output local node name. */ - boolean flocal = FALSE; - /* -I: configuration file name. */ - const char *zconfig = NULL; - int iopt; - pointer puuconf; - int iuuconf; - - zProgram = argv[0]; - - while ((iopt = getopt_long (argc, argv, "alI:vx:", asNlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'a': - /* Display aliases. */ - falias = TRUE; - break; - - case 'l': - /* Output local node name. */ - flocal = TRUE; - break; - - case 'I': - /* Configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - unhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - unusage (); - /*NOTREACHED*/ - } - } - - if (optind != argc) - unusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - usysdep_initialize (puuconf, INIT_SUID | INIT_NOCHDIR); - - if (flocal) - { - const char *zlocalname; - - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - usysdep_exit (FALSE); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - printf ("%s\n", zlocalname); - } - else - { - char **pznames, **pz; - - iuuconf = uuconf_system_names (puuconf, &pznames, falias); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - for (pz = pznames; *pz != NULL; pz++) - printf ("%s\n", *pz); - } - - usysdep_exit (TRUE); - - /* Avoid warnings about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -unusage () -{ - fprintf (stderr, - "Usage: %s [-a] [-l] [-I file]\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void unhelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [-a] [-l] [-I file]\n", zProgram); - printf (" -a,--aliases: display aliases\n"); - printf (" -l,--local: print local name\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} diff --git a/gnu/libexec/uucp/uupick/Makefile b/gnu/libexec/uucp/uupick/Makefile deleted file mode 100644 index 60216b8..0000000 --- a/gnu/libexec/uucp/uupick/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for uupick -# $FreeBSD$ - -BINDIR= $(bindir) - -PROG= uupick -SRCS= uupick.c log.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -.include <bsd.prog.mk> -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uupick/uupick.1 b/gnu/libexec/uucp/uupick/uupick.1 deleted file mode 100644 index 3e3162e..0000000 --- a/gnu/libexec/uucp/uupick/uupick.1 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $FreeBSD$ -.TH uupick 1 "Taylor UUCP 1.06" -.SH NAME -uupick \- retrieve files transferred by uuto -.SH SYNOPSIS -.B uupick -[\-s] [standard UUCP options] -.SH DESCRIPTION -The -.B uupick -program is used to conveniently retrieve files -transferred by the -.B uuto(1) -program. -For each file transferred by -.B uuto(1), -.B uupick -will display the -source system, the file name, and whether the name refers to a regular -file or a directory. It will then wait for the user to specify an -action to take. One of the following commands must be entered: -.TP 5 -.I q -Quit out of -.B uupick. -.TP 5 -.I RETURN -Skip the file. -.TP 5 -.I m [directory] -Move the file or directory to the specified directory. If no -directory is specified, the file is moved to the current directory. -.TP 5 -.I a [directory] -Move all files from this system to the specified directory. If no -directory is specified, the files are moved to the current -directory. -.TP 5 -.I p -List the file on standard output. -.TP 5 -.I d -Delete the file. -.TP 5 -.I ! [command] -Execute `command' as a shell escape. -.SH OPTIONS -The following options may be given to -.B uupick. -.TP 5 -.B \-s, \-\-system system -This option may be used to restrict -.B uupick -to only present files transferred from a particular system. -.TP 5 -.B \-x type -.TP 5 -.B \-\-debug type -.TP 5 -.B \-I file -.TP 5 -.B \-\-config file -.TP 5 -.B \-v, \-\-version -.TP 5 -.B \-\-help -Standard UUCP options. -.SH SEE ALSO -uucp(1), uuto(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. diff --git a/gnu/libexec/uucp/uupick/uupick.c b/gnu/libexec/uucp/uupick/uupick.c deleted file mode 100644 index b6d208a..0000000 --- a/gnu/libexec/uucp/uupick/uupick.c +++ /dev/null @@ -1,369 +0,0 @@ -/* uupick.c - Get files stored in the public directory by uucp -t. - - Copyright (C) 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uupick_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Local functions. */ - -static void upmovedir P((const char *zfull, const char *zrelative, - pointer pinfo)); -static void upmove P((const char *zfrom, const char *zto)); - -/* Long getopt options. */ -static const struct option asPlongopts[] = -{ - { "system", required_argument, NULL, 's' }, - { "config", required_argument, NULL, 'I' }, - { "debug", required_argument, NULL, 'x' }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 1 }, - { NULL, 0, NULL, 0 } -}; - -/* Local functions. */ - -static void upusage P((void)); -static void uphelp P((void)); - -int -main (argc, argv) - int argc; - char **argv; -{ - /* -s: system name. */ - const char *zsystem = NULL; - /* -I: configuration file name. */ - const char *zconfig = NULL; - int iopt; - pointer puuconf; - int iuuconf; - const char *zpubdir; - char *zfile, *zfrom, *zfull; - char *zallsys; - char ab[1000]; - boolean fquit; - - zProgram = "uupick"; - - while ((iopt = getopt_long (argc, argv, "I:s:vx:", asPlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 's': - /* System name to get files from. */ - zsystem = optarg; - break; - - case 'I': - /* Name configuration file. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - fprintf - (stderr, - "%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - uphelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - upusage (); - /*NOTREACHED*/ - } - } - - if (argc != optind) - upusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - usysdep_initialize (puuconf, INIT_GETCWD | INIT_NOCHDIR); - - zpubdir = NULL; - if (zsystem != NULL) - { - struct uuconf_system ssys; - - /* Get the public directory for the system. If we can't find - the system information, just use the standard public - directory, since uupick is not setuid. */ - iuuconf = uuconf_system_info (puuconf, zsystem, &ssys); - if (iuuconf == UUCONF_SUCCESS) - { - zpubdir = zbufcpy (ssys.uuconf_zpubdir); - (void) uuconf_system_free (puuconf, &ssys); - } - } - if (zpubdir == NULL) - { - iuuconf = uuconf_pubdir (puuconf, &zpubdir); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - } - - if (! fsysdep_uupick_init (zsystem, zpubdir)) - usysdep_exit (FALSE); - - zallsys = NULL; - fquit = FALSE; - - while (! fquit - && ((zfile = zsysdep_uupick (zsystem, zpubdir, &zfrom, &zfull)) - != NULL)) - { - boolean fdir; - char *zto, *zlocal; - FILE *e; - boolean fcontinue; - - fdir = fsysdep_directory (zfull); - - do - { - boolean fbadname; - - fcontinue = FALSE; - - if (zallsys == NULL - || strcmp (zallsys, zfrom) != 0) - { - if (zallsys != NULL) - { - ubuffree (zallsys); - zallsys = NULL; - } - - printf ("from %s: %s %s ?\n", zfrom, fdir ? "dir" : "file", - zfile); - - if (fgets (ab, sizeof ab, stdin) == NULL) - break; - } - - if (ab[0] == 'q') - { - fquit = TRUE; - break; - } - - switch (ab[0]) - { - case '\n': - break; - - case 'd': - if (fdir) - (void) fsysdep_rmdir (zfull); - else - { - if (remove (zfull) != 0) - ulog (LOG_ERROR, "remove (%s): %s", zfull, - strerror(errno)); - } - break; - - case 'm': - case 'a': - zto = ab + 1 + strspn (ab + 1, " \t"); - zto[strcspn (zto, " \t\n")] = '\0'; - zlocal = zsysdep_uupick_local_file (zto, &fbadname); - if (zlocal == NULL) - { - if (! fbadname) - usysdep_exit (FALSE); - ulog (LOG_ERROR, "%s: bad local file name", zto); - fcontinue = TRUE; - break; - } - zto = zsysdep_in_dir (zlocal, zfile); - ubuffree (zlocal); - if (zto == NULL) - usysdep_exit (FALSE); - if (! fdir) - upmove (zfull, zto); - else - { - usysdep_walk_tree (zfull, upmovedir, (pointer) zto); - (void) fsysdep_rmdir (zfull); - } - ubuffree (zto); - - if (ab[0] == 'a') - { - zallsys = zbufcpy (zfrom); - ab[0] = 'm'; - } - - break; - - case 'p': - if (fdir) - ulog (LOG_ERROR, "Can't print directory"); - else - { - e = fopen (zfull, "r"); - if (e == NULL) - ulog (LOG_ERROR, "fopen (%s): %s", zfull, - strerror (errno)); - else - { - while (fgets (ab, sizeof ab, e) != NULL) - (void) fputs (ab, stdout); - (void) fclose (e); - } - } - fcontinue = TRUE; - break; - - case '!': - (void) system (ab + 1); - fcontinue = TRUE; - break; - - default: - printf ("uupick commands:\n"); - printf ("q: quit\n"); - printf ("<return>: skip file\n"); - printf ("m [dir]: move file to directory\n"); - printf ("a [dir]: move all files from this system to directory\n"); - printf ("p: list file to stdout\n"); - printf ("d: delete file\n"); - printf ("! command: shell escape\n"); - fcontinue = TRUE; - break; - } - } - while (fcontinue); - - ubuffree (zfull); - ubuffree (zfrom); - ubuffree (zfile); - } - - (void) fsysdep_uupick_free (zsystem, zpubdir); - - usysdep_exit (TRUE); - - /* Avoid error about not returning. */ - return 0; -} - -/* Print usage message and die. */ - -static void -upusage () -{ - fprintf (stderr, - "Usage: %s [-s system] [-I config] [-x debug]\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print help message. */ - -static void -uphelp () -{ - fprintf (stderr, - "Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - fprintf (stderr, - " -s,--system system: Only consider files from named system\n"); - fprintf (stderr, - " -x,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - fprintf (stderr, - " -v,--version: Print version and exit\n"); - fprintf (stderr, - " --help: Print help and exit\n"); -} - -/* This routine is called by usysdep_walk_tree when moving the - contents of an entire directory. */ - -static void -upmovedir (zfull, zrelative, pinfo) - const char *zfull; - const char *zrelative; - pointer pinfo; -{ - const char *ztodir = (const char *) pinfo; - char *zto; - - zto = zsysdep_in_dir (ztodir, zrelative); - if (zto == NULL) - usysdep_exit (FALSE); - upmove (zfull, zto); - ubuffree (zto); -} - -/* Move a file. */ - -static void -upmove (zfrom, zto) - const char *zfrom; - const char *zto; -{ - (void) fsysdep_move_file (zfrom, zto, TRUE, TRUE, FALSE, - (const char *) NULL); -} diff --git a/gnu/libexec/uucp/uusched/Makefile b/gnu/libexec/uucp/uusched/Makefile deleted file mode 100644 index ae643b0..0000000 --- a/gnu/libexec/uucp/uusched/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for uusched -# $FreeBSD$ - -SCRIPTS= uusched -MAN= uusched.8 -CLEANFILES+= $(SCRIPTS) - -BINDIR= $(bindir) - -uusched: uusched.in - sed -e "s|@SBINDIR@|$(libxdir)|g" \ - $(.ALLSRC) > $(.TARGET) - -.include <bsd.prog.mk> diff --git a/gnu/libexec/uucp/uusched/uusched.8 b/gnu/libexec/uucp/uusched/uusched.8 deleted file mode 100644 index 91a74ed..0000000 --- a/gnu/libexec/uucp/uusched/uusched.8 +++ /dev/null @@ -1,24 +0,0 @@ -.\" $FreeBSD$ -.TH uusched 8 "Taylor UUCP 1.06" -.SH NAME -uusched \- UUCP file transfer daemon -.SH SYNOPSIS -.B uusched -[uucico options] -.SH DESCRIPTION -The -.B uusched -program is actually just a shell script which invokes -the -.B uucico(8) -daemon. It is provided for backward compatibility. It -causes -uucico(8) to call all systems for which there is work. Any -option which may be given to uucico(8) may also be given to -.B uusched -.SH SEE ALSO -uucico(8), uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. - diff --git a/gnu/libexec/uucp/uusched/uusched.in b/gnu/libexec/uucp/uusched/uusched.in deleted file mode 100644 index 5acb86a..0000000 --- a/gnu/libexec/uucp/uusched/uusched.in +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# uusched -# Call all systems which have work in a random order -# -# Copyright (C) 1992, 1993 Ian Lance Taylor -# -# Please feel free do whatever you like with this exciting shell -# script. -# -# This is pretty trivial, since all the functionality was moved into -# uucico itself. -# -exec @SBINDIR@/uucico -r1 $* diff --git a/gnu/libexec/uucp/uustat/Makefile b/gnu/libexec/uucp/uustat/Makefile deleted file mode 100644 index 650fe22..0000000 --- a/gnu/libexec/uucp/uustat/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for uustat -# $FreeBSD$ - -PROG= uustat -SRCS= uustat.c util.c log.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DOWNER=\"$(owner)\"\ - -DVERSION=\"$(VERSION)\" - -BINDIR= $(bindir) -BINOWN= $(owner) -BINGRP= dialer -BINMODE= 6555 - -INSTALLFLAGS= -fschg - -.include <bsd.prog.mk> - -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uustat/uustat.1 b/gnu/libexec/uucp/uustat/uustat.1 deleted file mode 100644 index a9c709c..0000000 --- a/gnu/libexec/uucp/uustat/uustat.1 +++ /dev/null @@ -1,552 +0,0 @@ -.\" $Id: uustat.1,v 1.12 1995/06/26 20:34:30 ian Rel $ -.\" $FreeBSD$ -.TH uustat 1 "Taylor UUCP 1.06" -.SH NAME -uustat \- UUCP status inquiry and control -.SH SYNOPSIS -.B uustat \-a -.PP -.B uustat \-\-all -.PP -.B uustat -[ -.B \-eKRiMNQ ] [ -.B \-sS -system ] [ -.B \-uU -user ] [ -.B \-cC -command ] [ -.B \-oy -hours ] [ -.B \-B -lines ] [ -.B \-\-executions -] [ -.B \-\-kill-all -] [ -.B \-\-rejuvenate-all -] [ -.B \-\-prompt -] [ -.B \-\-mail -] [ -.B \-\-notify -] [ -.B \-\-no-list -] [ -.B \-\-system -system ] [ -.B \-\-not-system -system ] [ -.B \-\-user -user ] [ -.B \-\-not-user -user ] [ -.B \-\-command -command ] [ -.B \-\-not-command -command ] [ -.B \-\-older-than -hours ] [ -.B \-\-younger-than -hours ] [ -.B \-\-mail-lines -lines ] -.PP -.B uustat -[ -.B \-kr -jobid ] [ -.B \-\-kill -jobid ] [ -.B \-\-rejuvenate -jobid ] -.PP -.B uustat \-q [ -.B \-sS -system ] [ -.B \-oy -hours ] [ -.B \-\-system -system ] [ -.B \-\-not-system -system ] [ -.B \-\-older-than -hours ] [ -.B \-\-younger-than -hours ] -.PP -.B uustat \-\-list [ -.B \-sS -system ] [ -.B \-oy -hours ] [ -.B \-\-system -system ] [ -.B \-\-not-system -system ] [ -.B \-\-older-than -hours ] [ -.B \-\-younger-than -hours ] -.PP -.B uustat \-m -.PP -.B uustat \-\-status -.PP -.B uustat \-p -.PP -.B uustat \-\-ps -.SH DESCRIPTION -The -.I uustat -command can display various types of status information about the UUCP -system. It can also be used to cancel or rejuvenate requests made by -.I uucp -(1) or -.I uux -(1). - -By default -.I uustat -displays all jobs queued up for the invoking user, as if given the -.B \-\-user -option with the appropriate argument. - -If any of the -.B \-a, -.B \-\-all, -.B \-e, -.B \-\-executions, -.B \-s, -.B \-\-system, -.B \-S, -.B \-\-not-system, -.B \-u, -.B \-\-user, -.B \-U, -.B \-\-not-user, -.B \-c, -.B \-\-command, -.B \-C, -.B \-\-not-command, -.B \-o, -.B \-\-older-than, -.B \-y, -.B \-\-younger-than -options are given, then all jobs which match the combined -specifications are displayed. - -The -.B \-K -or -.B \-\-kill-all -option may be used to kill off a selected group of jobs, such as all -jobs more than 7 days old. -.SH OPTIONS -The following options may be given to -.I uustat. -.TP 5 -.B \-a, \-\-all -List all queued file transfer requests. -.TP 5 -.B \-e, \-\-executions -List queued execution requests rather than queued file transfer -requests. Queued execution requests are processed by -.I uuxqt -(8) rather than -.I uucico -(8). Queued execution requests may be waiting for some file to be -transferred from a remote system. They are created by an invocation -of -.I uux -(1). -.TP 5 -.B \-s system, \-\-system system -List all jobs queued up for the named system. These options may be -specified multiple times, in which case all jobs for all the systems -will be listed. If used with -.B \-\-list -only the systems named will be listed. -.TP 5 -.B \-S system, \-\-not-system system -List all jobs queued for systems other than the one named. These -options may be specified multiple times, in which case no jobs from -any of the specified systems will be listed. If used with -.B \-\-list -only the systems not named will be listed. These options may not be -used with -.B \-s -or -.B \-\-system. -.TP 5 -.B \-u user, \-\-user user -List all jobs queued up for the named user. These options may be -specified multiple times, in which case all jobs for all the users -will be listed. -.TP 5 -.B \-U user, \-\-not-user user -List all jobs queued up for users other than the one named. These -options may be specified multiple times, in which case no jobs from -any of the specified users will be listed. These options may not be -used with -.B \-u -or -.B \-\-user. -.TP 5 -.B \-c command, \-\-command command -List all jobs requesting the execution of the named command. If -.B command -is -.I ALL -this will list all jobs requesting the execution of some command (as -opposed to simply requesting a file transfer). These options may be -specified multiple times, in which case all jobs requesting any of the -commands will be listed. -.TP 5 -.B \-C command, \-\-not-command command -List all jobs requesting execution of some command other than the -named command, or, if -.B command -is -.I ALL, -list all jobs that simply request a file transfer (as opposed to -requesting the execution of some command). These options may be -specified multiple times, in which case no job requesting one of the -specified commands will be listed. These options may not be used with -.B \-c -or -.B \-\-command. -.TP 5 -.B \-o hours, \-\-older-than hours -List all queued jobs older than the given number of hours. If used -with -.B \-\-list -only systems whose oldest job is older than the given number of hours -will be listed. -.TP 5 -.B \-y hours, \-\-younger-than hours -List all queued jobs younger than the given number of hours. If used -with -.B \-\-list -only systems whose oldest job is younger than the given number of -hours will be listed. -.TP 5 -.B \-k jobid, \-\-kill jobid -Kill the named job. The job id is shown by the default output format, -as well as by the -.B \-j -or -.B \-\-jobid -option to -.I uucp -(1) or -.I uux -(1). A job may only be killed by the user who created the job, or by -the UUCP administrator or the superuser. The -.B \-k -or -.B \-\-kill -options may be used multiple times on the command line to kill several -jobs. -.TP 5 -.B \-r jobid, \-\-rejuvenate jobid -Rejuvenate the named job. This will mark it as having been invoked at -the current time, affecting the output of the -.B \-o, -.B \-\-older-than, -.B \-y, -or -.B \-\-younger-than -options and preserving it from any automated cleanup daemon. The job -id is shown by the default output format, as well as by the -.B \-j -or -.B \-\-jobid -options to -.I uucp -(1) or -.I uux -(1). A job may only be rejuvenated by the user who created the job, -or by the UUCP administrator or the superuser. The -.B \-r -or -.B \-\-rejuvenate -options may be used multiple times on the command line to rejuvenate -several jobs. -.TP 5 -.B \-q, \-\-list -Display the status of commands, executions and conversations for all -remote systems for which commands or executions are queued. The -.B \-s, -.B \-\-system, -.B \-S, -.B \-\-not-system, -.B \-o, -.B \-\-older-than, -.B \-y, -and -.B \-\-younger-than -options may be used to restrict the systems which are listed. Systems -for which no commands or executions are queued will never be listed. -.TP 5 -.B \-m, \-\-status -Display the status of conversations for all remote systems. -.TP 5 -.B \-p, \-\-ps -Display the status of all processes holding UUCP locks on systems or -ports. -.TP 5 -.B \-i, \-\-prompt -For each listed job, prompt whether to kill the job or not. If the -first character of the input line is -.I y -or -.I Y -the job will be killed. -.TP 5 -.B \-K, \-\-kill-all -Automatically kill each listed job. This can be useful for automatic -cleanup scripts, in conjunction with the -.B \-\-mail -and -.B \-\-notify -options. -.TP 5 -.B \-R, \-\-rejuvenate-all -Automatically rejuvenate each listed job. This may not be used with -.B \-\-kill-all. -.TP 5 -.B \-M, \-\-mail -For each listed job, send mail to the UUCP administrator. If the job -is killed (due to -.B \-\-kill-all -or -.B \-\-prompt -with an affirmative response) the mail will indicate that. A comment -specified by the -.B \-\-comment -option may be included. If the job is an execution, the initial -portion of its standard input will be included in the mail message; -the number of lines to include may be set with the -.B \-\-mail-lines -option (the default is 100). If the standard input contains null -characters, it is assumed to be a binary file and is not included. -.TP 5 -.B \-N, \-\-notify -For each listed job, send mail to the user who requested the job. The -mail is identical to that sent by the -.B \-M -or -.B \-\-mail -options. -.TP 5 -.B \-W comment, \-\-comment comment -Specify a comment to be included in mail sent with the -.B \-M, -.B \-\-mail, -.B \-N, -or -.B \-\-notify -options. -.TP 5 -.B \-B lines, \-\-mail-lines lines -When the -.B \-M, -.B \-\-mail, -.B \-N, -or -.B \-\-notify -options are used to send mail about an execution with standard input, -this option controls the number of lines of standard input to include -in the message. The default is 100. -.TP 5 -.B \-Q, \-\-no-list -Do not actually list the job, but only take any actions indicated by -the -.B \-i, -.B \-\-prompt, -.B \-K, -.B \-\-kill-all, -.B \-M, -.B \-\-mail, -.B \-N -or -.B \-\-notify -options. -.TP 5 -.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, config, -spooldir and execute are meaningful for -.I uustat. - -Multiple types may be given, separated by commas, and the -.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 \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. -.TP 5 -.B \-I file, \-\-config file -Set configuration file to use. This option may not be available, -depending upon how -.I uustat -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH EXAMPLES -.br -.nf -uustat --all -.fi -Display status of all jobs. A sample output line is as follows: -.br -.in +0.5i -.nf -bugsA027h bugs ian 04-01 13:50 Executing rmail ian@airs.com (sending 1283 bytes) -.fi -.in -0.5i -The format is -.br -.in +0.5i -.nf -jobid system user queue-date command (size) -.fi -.in -0.5i -The jobid may be passed to the -.B \-\-kill -or -.B \-\-rejuvenate -options. -The size indicates how much data is to be transferred to the remote -system, and is absent for a file receive request. -The -.B \-\-system, -.B \-\-not-system, -.B \-\-user, -.B \-\-not-user, -.B \-\-command, -.B \-\-not-command, -.B \-\-older-than, -and -.B \-\-younger-than -options may be used to control which jobs are listed. - -.br -.nf -uustat --executions -.fi -Display status of queued up execution requests. A sample output line -is as follows: -.br -.in +0.5i -.nf -bugs bugs!ian 05-20 12:51 rmail ian -.fi -.in -0.5i -The format is -.br -.in +0.5i -.nf -system requestor queue-date command -.fi -.in -0.5i -The -.B \-\-system, -.B \-\-not-system, -.B \-\-user, -.B \-\-not-user, -.B \-\-command, -.B \-\-not-command, -.B \-\-older-than, -and -.B \-\-younger-than -options may be used to control which requests are listed. - -.br -.nf -uustat --list -.fi -Display status for all systems with queued up commands. A sample -output line is as follows: -.br -.in +0.5i -.nf -bugs 4C (1 hour) 0X (0 secs) 04-01 14:45 Dial failed -.fi -.in -0.5i -This indicates the system, the number of queued commands, the age of -the oldest queued command, the number of queued local executions, the -age of the oldest queued execution, the date of the last conversation, -and the status of that conversation. - -.br -.nf -uustat --status -.fi -Display conversation status for all remote systems. A sample output -line is as follows: -.br -.in +0.5i -.nf -bugs 04-01 15:51 Conversation complete -.fi -.in -0.5i -This indicates the system, the date of the last conversation, and the -status of that conversation. If the last conversation failed, -.I uustat -will indicate how many attempts have been made to call the system. If -the retry period is currently preventing calls to that system, -.I uustat -also displays the time when the next call will be permitted. - -.br -.nf -uustat --ps -.fi -Display the status of all processes holding UUCP locks. The output -format is system dependent, as -.I uustat -simply invokes -.I ps -(1) on each process holding a lock. - -.br -.in +0.5i -.nf -uustat --command rmail --older-than 168 --kill-all --no-list --mail --notify --comment "Queued for over 1 week" -.fi -.in -0.5i -This will kill all -.I rmail -commands that have been queued up waiting for delivery for over 1 week -(168 hours). For each such command, mail will be sent both to the -UUCP administrator and to the user who requested the rmail execution. -The mail message sent will include the string given by the -.B \-\-comment -option. The -.B \-\-no-list -option prevents any of the jobs from being listed on the terminal, so -any output from the program will be error messages. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/etc/uucp/config - Configuration file. -.br -/var/spool/uucp - -UUCP spool directory. -.SH SEE ALSO -ps(1), rmail(8), uucp(1), uux(1), uucico(8), uuxqt(8) -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com) diff --git a/gnu/libexec/uucp/uustat/uustat.c b/gnu/libexec/uucp/uustat/uustat.c deleted file mode 100644 index 9ca16bb..0000000 --- a/gnu/libexec/uucp/uustat/uustat.c +++ /dev/null @@ -1,2441 +0,0 @@ -/* uustat.c - UUCP status program - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uustat_rcsid[] = "$FreeBSD$"; -#endif - -#include <ctype.h> -#include <errno.h> - -#if TM_IN_SYS_TIME -#include <sys/time.h> -#else -#include <time.h> -#endif - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* The uustat program permits various listings and manipulations of - files in the spool directory. This implementation supports the - following switches: - - -a list all jobs - -Blines number of lines of standard input to mail - -ccommand list only executions of specified command - -Ccommand list only jobs other than executions of specified command - -e list execute jobs rather than command requests - -i ask user whether to kill each listed job - -Ifile set configuration file name - -kjobid kill job with specified ID - -K kill each listed job - -m report status for all remote machines - -M mail uucp about each job killed with -K - -N mail requestor about each job killed with -K - -ohour report jobs older than specified number of hours - -p do "ps -flp" on all processes holding lock files (Unix specific) - -q list number of jobs for all systems - -Q don't list jobs, just do -K processing - -rjobid rejuvenate job with specified ID - -ssystem report on all jobs for specified system - -Ssystem report on all jobs other than for specified system - -uuser report on all jobs for specified user - -Uuser report on all jobs other than for specified user - -Wcomment comment to include in mail messages - -xdebug set debugging level - -yhour report jobs younger than specified number of hours */ - -/* What to do with a job that matches the selection criteria; these - values may be or'red together. */ -#define JOB_SHOW (01) -#define JOB_INQUIRE (02) -#define JOB_KILL (04) -#define JOB_REJUVENATE (010) -#define JOB_MAIL (020) -#define JOB_NOTIFY (040) - -/* This structure is used to accumulate all the lines in a single - command file, so that they can all be displayed at once and so that - executions can be displayed reasonably. */ - -struct scmdlist -{ - struct scmdlist *qnext; - struct scmd s; - long itime; -}; - -/* Local functions. */ - -static void ususage P((void)); -static void ushelp P((void)); -static boolean fsxqt_file_read P((pointer puuconf, FILE *)); -static void usxqt_file_free P((void)); -static int isxqt_cmd P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int isxqt_file P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int isxqt_user P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static boolean fsworkfiles P((pointer puuconf, int icmd, int csystems, - char **pazsystems, boolean fnotsystems, - int cusers, char **pazusers, - boolean fnotusers, long iold, long iyoung, - int ccommands, char **pazcommands, - boolean fnotcommands, const char *zcomment, - int cstdin)); -static boolean fsworkfiles_system P((pointer puuconf,int icmd, - const struct uuconf_system *qsys, - int cusers, char **pazusers, - boolean fnotusers, long iold, - long iyoung, int ccommands, - char **pazcommands, - boolean fnotcommands, - const char *zcomment, int cstdin)); -static boolean fsworkfile_show P((pointer puuconf, int icmd, - const struct uuconf_system *qsys, - const struct scmd *qcmd, - long itime, int ccommands, - char **pazcommands, boolean fnotcommands, - const char *zcomment, int cstdin)); -static void usworkfile_header P((const struct uuconf_system *qsys, - const struct scmd *qcmd, - const char *zjobid, - long itime, boolean ffirst)); -static boolean fsexecutions P((pointer puuconf, int icmd, int csystems, - char **pazsystems, boolean fnotsystems, - int cusers, char **pazusers, - boolean fnotusers, long iold, long iyoung, - int ccommands, char **pazcommands, - boolean fnotcommands, const char *zcomment, - int cstdin)); -static boolean fsnotify P((pointer puuconf, int icmd, const char *zcomment, - int cstdin, boolean fkilled, const char *zcmd, - struct scmdlist *qcmd, const char *zid, - long itime, const char *zuser, - const struct uuconf_system *qsys, - const char *zstdin, pointer pstdinseq, - const char *zrequestor)); -static boolean fsquery P((pointer puuconf, int csystems, - char **pazsystems, boolean fnotsystems, - long iold, long iyoung)); -static int csunits_show P((long idiff)); -static boolean fsmachines P((void)); - -/* Long getopt options. */ -static const struct option asSlongopts[] = -{ - { "all", no_argument, NULL, 'a' }, - { "mail-lines", required_argument, NULL, 'B' }, - { "command", required_argument, NULL, 'c' }, - { "not-command", required_argument, NULL, 'C' }, - { "executions", no_argument, NULL, 'e' }, - { "prompt", no_argument, NULL, 'i' }, - { "kill", required_argument, NULL, 'k' }, - { "kill-all", no_argument, NULL, 'K' }, - { "status", no_argument, NULL, 'm' }, - { "mail", no_argument, NULL, 'M' }, - { "notify", no_argument, NULL, 'N' }, - { "older-than", required_argument, NULL, 'o' }, - { "ps", no_argument, NULL, 'p' }, - { "list", no_argument, NULL, 'q' }, - { "no-list", no_argument, NULL, 'Q' }, - { "rejuvenate", required_argument, NULL, 'r' }, - { "rejuvenate-all", no_argument, NULL, 'R' }, - { "system", required_argument, NULL, 's' }, - { "not-system", required_argument, NULL, 'S' }, - { "user", required_argument, NULL, 'u' }, - { "not-user", required_argument, NULL, 'U' }, - { "comment", required_argument, NULL, 'W' }, - { "younger-than", required_argument, NULL, 'y' }, - { "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) - int argc; - char **argv; -{ - /* -a: list all jobs. */ - boolean fall = FALSE; - /* -B lines: number of lines of standard input to mail. */ - int cstdin = 100; - /* -c,-C command: list only specified command. */ - int ccommands = 0; - char **pazcommands = NULL; - boolean fnotcommands = FALSE; - /* -e: list execute jobs. */ - boolean fexecute = FALSE; - /* -k jobid: kill specified job. */ - int ckills = 0; - char **pazkills = NULL; - /* -m: report machine status. */ - boolean fmachine = FALSE; - /* -o hour: report jobs older than given number of hours. */ - int ioldhours = -1; - /* -p: report status of jobs holding lock files. */ - boolean fps = FALSE; - /* -q: list number of jobs for each system. */ - boolean fquery = FALSE; - /* -r jobid: rejuvenate specified job. */ - int crejuvs = 0; - char **pazrejuvs = NULL; - /* -s,-S system: list all jobs for specified system. */ - int csystems = 0; - char **pazsystems = NULL; - boolean fnotsystems = FALSE; - /* -u,-U user: list all jobs for specified user. */ - int cusers = 0; - char **pazusers = NULL; - boolean fnotusers = FALSE; - /* -W comment: comment to include in mail messages. */ - const char *zcomment = NULL; - /* -y hour: report jobs younger than given number of hours. */ - int iyounghours = -1; - /* -I file: set configuration file. */ - const char *zconfig = NULL; - /* -Q, -i, -K, -M, -N: what to do with each job. */ - int icmd = JOB_SHOW; - int ccmds; - int iopt; - pointer puuconf; - int iuuconf; - long iold; - long iyoung; - const char *azoneuser[1]; - boolean fret; - - zProgram = argv[0]; - - while ((iopt = getopt_long (argc, argv, - "aB:c:C:eiI:k:KmMNo:pqQr:Rs:S:u:U:vW:x:y:", - asSlongopts, (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'a': - /* List all jobs. */ - fall = TRUE; - break; - - case 'B': - /* Number of lines of standard input to mail. */ - cstdin = (int) strtol (optarg, (char **) NULL, 10); - break; - - case 'C': - /* List jobs for other than specified command. */ - fnotcommands = TRUE; - /* Fall through. */ - case 'c': - /* List specified command. */ - ++ccommands; - pazcommands = (char **) xrealloc ((pointer) pazcommands, - ccommands * sizeof (char *)); - pazcommands[ccommands - 1] = optarg; - break; - - case 'e': - /* List execute jobs. */ - fexecute = TRUE; - break; - - case 'i': - /* Prompt the user whether to kill each job. */ - icmd |= JOB_INQUIRE; - break; - - case 'I': - /* Set configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'k': - /* Kill specified job. */ - ++ckills; - pazkills = (char **) xrealloc ((pointer) pazkills, - ckills * sizeof (char *)); - pazkills[ckills - 1] = optarg; - break; - - case 'K': - /* Kill each listed job. */ - icmd |= JOB_KILL; - break; - - case 'm': - /* Report machine status. */ - fmachine = TRUE; - break; - - case 'M': - /* Mail to uucp action taken on each job. */ - icmd |= JOB_MAIL; - break; - - case 'N': - /* Mail to requestor action taken on each job. */ - icmd |= JOB_NOTIFY; - break; - - case 'o': - /* Report old jobs. */ - ioldhours = (int) strtol (optarg, (char **) NULL, 10); - break; - - case 'p': - /* Get status of processes holding locks. */ - fps = TRUE; - break; - - case 'q': - /* List number of jobs for each system. */ - fquery = TRUE; - break; - - case 'Q': - /* Don't list jobs, just do -K processing. */ - icmd &=~ JOB_SHOW; - break; - - case 'r': - /* Rejuvenate specified job. */ - ++crejuvs; - pazrejuvs = (char **) xrealloc ((pointer) pazrejuvs, - crejuvs * sizeof (char *)); - pazrejuvs[crejuvs - 1] = optarg; - break; - - case 'R': - /* Rejuvenate each listed job. */ - icmd |= JOB_REJUVENATE; - break; - - case 'S': - /* List jobs for other than specified system. */ - fnotsystems = TRUE; - /* Fall through. */ - case 's': - /* List jobs for specified system. */ - ++csystems; - pazsystems = (char **) xrealloc ((pointer) pazsystems, - csystems * sizeof (char *)); - pazsystems[csystems - 1] = optarg; - break; - - case 'U': - /* List jobs for other than specified user. */ - fnotusers = TRUE; - /* Fall through. */ - case 'u': - /* List jobs for specified user. */ - ++cusers; - pazusers = (char **) xrealloc ((pointer) pazusers, - cusers * sizeof (char *)); - pazusers[cusers - 1] = optarg; - break; - - case 'W': - /* Comment to include in mail messages. */ - zcomment = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'y': - /* List jobs younger than given number of hours. */ - iyounghours = (int) strtol (optarg, (char **) NULL, 10); - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - ushelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - ususage (); - /*NOTREACHED*/ - } - } - - if (optind != argc) - ususage (); - - /* To avoid confusion, most options are only permitted by - themselves. This restriction might be removed later, but it is - imposed by most implementations. We do permit any combination of - -c, -s, -u, -o and -y, and any combination of -k and -r. */ - ccmds = 0; - if (fall) - ++ccmds; - if (ckills > 0 || crejuvs > 0) - ++ccmds; - if (fmachine) - ++ccmds; - if (fps) - ++ccmds; - if (fexecute || fquery || csystems > 0 || cusers > 0 || ioldhours != -1 - || iyounghours != -1 || ccommands > 0) - ++ccmds; - if (fexecute && fquery) - ++ccmds; - - if (ccmds > 1) - { - fprintf (stderr, "%s: too many options\n", zProgram); - ususage (); - } - - if ((icmd & JOB_KILL) != 0 - && (icmd & JOB_REJUVENATE) != 0) - { - fprintf (stderr, "%s: can not both rejuvenate and kill jobs\n", - zProgram); - ususage (); - } - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - usysdep_initialize (puuconf, INIT_SUID); - - /* If no commands were specified, we list all commands for the given - user. */ - if (ccmds == 0) - { - cusers = 1; - azoneuser[0] = zsysdep_login_name (); - pazusers = (char **) azoneuser; - } - - /* Canonicalize the system names. */ - if (csystems > 0) - { - int i; - - for (i = 0; i < csystems; i++) - { - struct uuconf_system ssys; - - iuuconf = uuconf_system_info (puuconf, pazsystems[i], &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf == UUCONF_NOT_FOUND) - ulog (LOG_FATAL, "%s: System not found", pazsystems[i]); - else - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - } - if (strcmp (pazsystems[i], ssys.uuconf_zname) != 0) - pazsystems[i] = zbufcpy (ssys.uuconf_zname); - (void) uuconf_system_free (puuconf, &ssys); - } - } - - if (ioldhours == -1) - iold = (long) -1; - else - { - iold = (ixsysdep_time ((long *) NULL) - - (long) ioldhours * (long) 60 * (long) 60); - if (iold < 0L) - iold = 0L; - } - if (iyounghours == -1) - iyoung = (long) -1; - else - { - iyoung = (ixsysdep_time ((long *) NULL) - - (long) iyounghours * (long) 60 * (long) 60); - if (iyoung < 0L) - iyoung = 0L; - } - - if (! fexecute - && ! fquery - && (fall - || csystems > 0 - || cusers > 0 - || ioldhours != -1 - || iyounghours != -1 - || ccommands > 0)) - fret = fsworkfiles (puuconf, icmd, csystems, pazsystems, fnotsystems, - cusers, pazusers, fnotusers, iold, iyoung, - ccommands, pazcommands, fnotcommands, zcomment, - cstdin); - else if (fexecute) - fret = fsexecutions (puuconf, icmd, csystems, pazsystems, fnotsystems, - cusers, pazusers, fnotusers, iold, iyoung, - ccommands, pazcommands, fnotcommands, zcomment, - cstdin); - else if (icmd != JOB_SHOW) - { - ulog (LOG_ERROR, - "-i, -K, -M, -N, -Q, -R not supported with -k, -m, -p, -q, -r"); - ususage (); - fret = FALSE; - } - else if (fquery) - { - if (cusers > 0 || ccommands > 0) - { - ulog (LOG_ERROR, "-u, -c not supported with -q"); - ususage (); - fret = FALSE; - } - else - fret = fsquery (puuconf, csystems, pazsystems, fnotsystems, - iold, iyoung); - } - else if (fmachine) - fret = fsmachines (); - else if (ckills > 0 || crejuvs > 0) - { - int i; - - fret = TRUE; - for (i = 0; i < ckills; i++) - if (! fsysdep_kill_job (puuconf, pazkills[i])) - fret = FALSE; - - for (i = 0; i < crejuvs; i++) - if (! fsysdep_rejuvenate_job (puuconf, pazrejuvs[i])) - fret = FALSE; - } - else if (fps) - fret = fsysdep_lock_status (); - else - { -#if DEBUG > 0 - ulog (LOG_FATAL, "Can't happen"); -#endif - fret = FALSE; - } - - ulog_close (); - - usysdep_exit (fret); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ususage () -{ - fprintf (stderr, "Usage: %s [options]\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Print a help message. */ - -static void -ushelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [options]\n", zProgram); - printf (" -a,--all: list all UUCP jobs\n"); - printf (" -B,--mail-lines num: number of lines to return in -M or -N mail message\n"); - printf (" -c,--command command: list requests for named command\n"); - printf (" -C,--not-command command: list requests for other than named command\n"); - printf (" -e,--executions: list queued executions rather than job requests\n"); - printf (" -i,--prompt: prompt for whether to kill each listed job\n"); - printf (" -k,--kill job: kill specified UUCP job\n"); - printf (" -K,--kill-all: kill each listed job\n"); - printf (" -m,--status: report status for all remote machines\n"); - printf (" -M,--mail: mail report on each listed job to UUCP administrator\n"); - printf (" -N,--notify: mail report on each listed job to requestor\n"); - printf (" -o,--older-than hours: list all jobs older than given number of hours\n"); - printf (" -p,--ps: show status of all processes holding UUCP locks\n"); - printf (" -q,--list: list number of jobs for each system\n"); - printf (" -Q,--no-list: don't list jobs, just take actions (-i, -K, -M, -N)\n"); - printf (" -r,--rejuvenate job: rejuvenate specified UUCP job\n"); - printf (" -R,--rejuvenate-all: rejuvenate each listed job\n"); - printf (" -s,--system system: list all jobs for specified system\n"); - printf (" -S,--not-system system: list all jobs for other than specified system\n"); - printf (" -u,--user user: list all jobs for specified user\n"); - printf (" -U,--not-user user: list all jobs for other than specified user\n"); - printf (" -W,--comment comment: comment to include in mail messages\n"); - printf (" -y,--younger-than hours: list all jobs younger than given number of hours\n"); - printf (" -x,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} - -/* We need to be able to read information from an execution file. */ - -/* The user name extracted from an execution file. */ -static char *zSxqt_user; - -/* The system name from an execution file. */ -static char *zSxqt_system; - -/* Address of requesting user (who to send mail to). */ -static const char *zSxqt_requestor; - -/* The command (no arguments) from an execution file. */ -static char *zSxqt_prog; - -/* The full command line from an execution file. */ -static char *zSxqt_cmd; - -/* Number of files associated with an execution file. */ -static int cSxqt_files; - -/* Names of files associated with execution file. */ -static char **pazSxqt_files; - -/* Standard input file name. */ -static const char *zSxqt_stdin; - -/* A command table used to dispatch an execution file. */ -static const struct uuconf_cmdtab asSxqt_cmds[] = -{ - { "C", UUCONF_CMDTABTYPE_FN | 0, NULL, isxqt_cmd }, - { "I", UUCONF_CMDTABTYPE_STRING, (pointer) &zSxqt_stdin, NULL }, - { "F", UUCONF_CMDTABTYPE_FN | 0, NULL, isxqt_file }, - { "R", UUCONF_CMDTABTYPE_STRING, (pointer) &zSxqt_requestor, NULL }, - { "U", UUCONF_CMDTABTYPE_FN | 3, NULL, isxqt_user }, - { NULL, 0, NULL, NULL } -}; - -/* Read an execution file, setting the above variables. */ - -static boolean -fsxqt_file_read (puuconf, e) - pointer puuconf; - FILE *e; -{ - int iuuconf; - boolean fret; - - zSxqt_user = NULL; - zSxqt_system = NULL; - zSxqt_stdin = NULL; - zSxqt_requestor = NULL; - zSxqt_prog = NULL; - zSxqt_cmd = NULL; - cSxqt_files = 0; - pazSxqt_files = NULL; - - iuuconf = uuconf_cmd_file (puuconf, e, asSxqt_cmds, (pointer) NULL, - (uuconf_cmdtabfn) NULL, - UUCONF_CMDTABFLAG_CASE, (pointer) NULL); - if (iuuconf == UUCONF_SUCCESS) - fret = TRUE; - else - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - } - - if (zSxqt_user == NULL) - zSxqt_user = zbufcpy ("*unknown*"); - if (zSxqt_system == NULL) - zSxqt_system = zbufcpy ("*unknown*"); - if (zSxqt_prog == NULL) - { - zSxqt_prog = zbufcpy ("*none*"); - zSxqt_cmd = zbufcpy ("*none*"); - } - - return fret; -} - -/* Free up the information read from an execution file. */ - -static void -usxqt_file_free () -{ - int i; - - ubuffree (zSxqt_user); - zSxqt_user = NULL; - ubuffree (zSxqt_system); - zSxqt_system = NULL; - ubuffree (zSxqt_prog); - zSxqt_prog = NULL; - ubuffree (zSxqt_cmd); - zSxqt_cmd = NULL; - for (i = 0; i < cSxqt_files; i++) - ubuffree (pazSxqt_files[i]); - cSxqt_files = 0; - xfree ((pointer) pazSxqt_files); - pazSxqt_files = NULL; - zSxqt_stdin = NULL; - zSxqt_requestor = NULL; -} - -/* Get the command from an execution file. */ - -/*ARGSUSED*/ -static int -isxqt_cmd (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - size_t clen; - int i; - - if (argc <= 1) - return UUCONF_CMDTABRET_CONTINUE; - - zSxqt_prog = zbufcpy (argv[1]); - - clen = 0; - for (i = 1; i < argc; i++) - clen += strlen (argv[i]) + 1; - - zSxqt_cmd = zbufalc (clen); - zSxqt_cmd[0] = '\0'; - for (i = 1; i < argc - 1; i++) - { - strcat (zSxqt_cmd, argv[i]); - strcat (zSxqt_cmd, " "); - } - strcat (zSxqt_cmd, argv[i]); - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Get the associated files from an execution file. */ - -/*ARGSUSED*/ -static int -isxqt_file (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - if (argc != 2 && argc != 3) - return UUCONF_CMDTABRET_CONTINUE; - - /* If this file is not in the spool directory, just ignore it. */ - if (! fspool_file (argv[1])) - return UUCONF_CMDTABRET_CONTINUE; - - ++cSxqt_files; - pazSxqt_files = (char **) xrealloc ((pointer) pazSxqt_files, - cSxqt_files * sizeof (char *)); - - pazSxqt_files[cSxqt_files - 1] = zbufcpy (argv[1]); - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Get the requesting user and system from an execution file. */ - -/*ARGSUSED*/ -static int -isxqt_user (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - zSxqt_user = zbufcpy (argv[1]); - zSxqt_system = zbufcpy (argv[2]); - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle various possible requests to look at work files. */ - -static boolean -fsworkfiles (puuconf, icmd, csystems, pazsystems, fnotsystems, cusers, - pazusers, fnotusers, iold, iyoung, ccommands, pazcommands, - fnotcommands, zcomment, cstdin) - pointer puuconf; - int icmd; - int csystems; - char **pazsystems; - boolean fnotsystems; - int cusers; - char **pazusers; - boolean fnotusers; - long iold; - long iyoung; - int ccommands; - char **pazcommands; - boolean fnotcommands; - const char *zcomment; - int cstdin; -{ - boolean fret; - int i; - int iuuconf; - struct uuconf_system ssys; - - fret = TRUE; - - if (csystems > 0 && ! fnotsystems) - { - for (i = 0; i < csystems; i++) - { - iuuconf = uuconf_system_info (puuconf, pazsystems[i], &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf == UUCONF_NOT_FOUND) - ulog (LOG_ERROR, "%s: System not found", pazsystems[i]); - else - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - continue; - } - - if (! fsworkfiles_system (puuconf, icmd, &ssys, cusers, pazusers, - fnotusers, iold, iyoung, ccommands, - pazcommands, fnotcommands, zcomment, - cstdin)) - fret = FALSE; - - (void) uuconf_system_free (puuconf, &ssys); - } - } - else - { - char **pznames, **pz; - - iuuconf = uuconf_system_names (puuconf, &pznames, 0); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - for (pz = pznames; *pz != NULL; pz++) - { - if (csystems > 0) - { - for (i = 0; i < csystems; i++) - if (strcmp (*pz, pazsystems[i]) == 0) - break; - if (i < csystems) - continue; - } - - iuuconf = uuconf_system_info (puuconf, *pz, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - continue; - } - - if (! fsworkfiles_system (puuconf, icmd, &ssys, cusers, pazusers, - fnotusers, iold, iyoung, ccommands, - pazcommands, fnotcommands, zcomment, - cstdin)) - fret = FALSE; - - (void) uuconf_system_free (puuconf, &ssys); - xfree ((pointer) *pz); - } - xfree ((pointer) pznames); - } - - return fret; -} - -/* Look at the work files for a particular system. */ - -static boolean -fsworkfiles_system (puuconf, icmd, qsys, cusers, pazusers, fnotusers, iold, - iyoung, ccommands, pazcommands, fnotcommands, zcomment, - cstdin) - pointer puuconf; - int icmd; - const struct uuconf_system *qsys; - int cusers; - char **pazusers; - boolean fnotusers; - long iold; - long iyoung; - int ccommands; - char **pazcommands; - boolean fnotcommands; - const char *zcomment; - int cstdin; -{ - boolean fret; - - if (! fsysdep_get_work_init (qsys, UUCONF_GRADE_LOW)) - return FALSE; - - while (TRUE) - { - struct scmd s; - long itime; - - if (! fsysdep_get_work (qsys, UUCONF_GRADE_LOW, &s)) - { - usysdep_get_work_free (qsys); - return FALSE; - } - if (s.bcmd == 'H') - break; - - if (cusers > 0) - { - boolean fmatch; - int i; - - fmatch = fnotusers; - for (i = 0; i < cusers; i++) - { - if (s.zuser != NULL - && strcmp (pazusers[i], s.zuser) == 0) - { - fmatch = ! fmatch; - break; - } - } - if (! fmatch) - continue; - } - - itime = ixsysdep_work_time (qsys, s.pseq); - - if (iold != (long) -1 && itime > iold) - continue; - - if (iyoung != (long) -1 && itime < iyoung) - continue; - - if (! fsworkfile_show (puuconf, icmd, qsys, &s, itime, ccommands, - pazcommands, fnotcommands, zcomment, cstdin)) - { - usysdep_get_work_free (qsys); - return FALSE; - } - } - - fret = fsworkfile_show (puuconf, icmd, qsys, (const struct scmd *) NULL, - 0L, ccommands, pazcommands, fnotcommands, zcomment, - cstdin); - - usysdep_get_work_free (qsys); - - return fret; -} - -/* Show a single workfile. This is actually called once for each line - in the workfile, so we accumulate the lines and show them all at - once. This lets us show an execution in a useful fashion. */ - -static boolean -fsworkfile_show (puuconf, icmd, qsys, qcmd, itime, ccommands, pazcommands, - fnotcommands, zcomment, cstdin) - pointer puuconf; - int icmd; - const struct uuconf_system *qsys; - const struct scmd *qcmd; - long itime; - int ccommands; - char **pazcommands; - boolean fnotcommands; - const char *zcomment; - int cstdin; -{ - static struct scmdlist *qlist; - static char *zlistid; - char *zid; - - if (qcmd == NULL) - zid = NULL; - else - { - zid = zsysdep_jobid (qsys, qcmd->pseq); - if (zid == NULL) - return FALSE; - } - - /* If this is the same jobid as the list, put it on the end. */ - - if (qcmd != NULL - && qlist != NULL - && strcmp (zlistid, zid) == 0) - { - struct scmdlist *qnew, **pq; - - ubuffree (zid); - qnew = (struct scmdlist *) xmalloc (sizeof (struct scmdlist)); - qnew->qnext = NULL; - qnew->s = *qcmd; - qnew->itime = itime; - for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext) - ; - *pq = qnew; - return TRUE; - } - - /* Here we have found a different job ID, so we print the scmd - structures that we have accumulated. We look for the special - case of an execution (an E command, or one of the destination - files begins with X.). We could be more clever about other - situations as well. */ - if (qlist != NULL) - { - boolean fmatch; - const char *zprog, *zcmd, *zrequestor, *zstdin; - char *zfree; - struct scmdlist *qxqt; - FILE *exqt = NULL; - struct scmdlist *qfree; - - fmatch = FALSE; - zprog = zcmd = zrequestor = zstdin = NULL; - zfree = NULL; - - for (qxqt = qlist; qxqt != NULL; qxqt = qxqt->qnext) - { - if (qxqt->s.bcmd == 'E') - break; - if (qxqt->s.bcmd == 'S' - && qxqt->s.zto[0] == 'X' - && qxqt->s.zto[1] == '.' - && fspool_file (qxqt->s.zfrom)) - { - char *zxqt; - - /* Open the file now, so that, if it does not exist, we - can still report sensibly (the qxqt == NULL case) on - any other files that may exist. */ - - zxqt = zsysdep_spool_file_name (qsys, qxqt->s.zfrom, - qxqt->s.pseq); - if (zxqt == NULL) - return FALSE; - - exqt = fopen (zxqt, "r"); - - ubuffree (zxqt); - - if (exqt != NULL) - break; - } - } - - if (qxqt == NULL) - { - if (ccommands == 0 - || (fnotcommands - && strcmp (pazcommands[0], "ALL") == 0)) - { - /* Show all the lines in a regular work file. */ - fmatch = TRUE; - - if ((icmd & JOB_SHOW) != 0) - { - struct scmdlist *qshow; - - for (qshow = qlist; qshow != NULL; qshow = qshow->qnext) - { - char *zfile; - long cbytes; - - usworkfile_header (qsys, &qshow->s, zlistid, - qshow->itime, qshow == qlist); - - switch (qshow->s.bcmd) - { - case 'S': - if (strchr (qshow->s.zoptions, 'C') != NULL - || fspool_file (qshow->s.zfrom)) - zfile = zsysdep_spool_file_name (qsys, - qshow->s.ztemp, - qshow->s.pseq); - else - zfile = zbufcpy (qshow->s.zfrom); - if (zfile == NULL) - cbytes = -1; - else - cbytes = csysdep_size (zfile); - if (cbytes >= 0) - printf ("Sending %s (%ld bytes) to %s", - qshow->s.zfrom, cbytes, qshow->s.zto); - ubuffree (zfile); - break; - case 'R': - printf ("Requesting %s to %s", qshow->s.zfrom, - qshow->s.zto); - break; - case 'X': - printf ("Requesting %s to %s", qshow->s.zfrom, - qshow->s.zto); - break; - case 'P': - printf ("(poll file)"); - break; -#if DEBUG > 0 - default: - printf ("Bad line %d", qshow->s.bcmd); - break; -#endif - } - - printf ("\n"); - } - } - } - } - else - { - long csize; - struct scmdlist *qsize; - - /* Show the command for an execution file. */ - if (qxqt->s.bcmd == 'E') - { - zfree = zbufcpy (qxqt->s.zcmd); - zfree[strcspn (zfree, " \t")] = '\0'; - zprog = zfree; - zcmd = qxqt->s.zcmd; - if (strchr (qxqt->s.zoptions, 'R') != NULL) - zrequestor = qxqt->s.znotify; - } - else - { - if (! fsxqt_file_read (puuconf, exqt)) - { - (void) fclose (exqt); - return FALSE; - } - - (void) fclose (exqt); - - zprog = zSxqt_prog; - zcmd = zSxqt_cmd; - zrequestor = zSxqt_requestor; - } - - csize = 0L; - for (qsize = qlist; qsize != NULL; qsize = qsize->qnext) - { - if (qsize->s.bcmd == 'S' || qsize->s.bcmd == 'E') - { - char *zfile; - - if (strchr (qsize->s.zoptions, 'C') != NULL - || fspool_file (qsize->s.zfrom)) - zfile = zsysdep_spool_file_name (qsys, qsize->s.ztemp, - qsize->s.pseq); - else - zfile = zbufcpy (qsize->s.zfrom); - if (zfile != NULL) - { - long cbytes; - - cbytes = csysdep_size (zfile); - if (cbytes > 0) - csize += cbytes; - ubuffree (zfile); - } - } - } - - if (ccommands == 0) - fmatch = TRUE; - else - { - int i; - - fmatch = fnotcommands; - for (i = 0; i < ccommands; i++) - { - if (strcmp (pazcommands[i], "ALL") == 0 - || strcmp (pazcommands[i], zprog) == 0) - { - fmatch = ! fmatch; - break; - } - } - } - - /* To get the name of the standard input file on this system - we have to look through the list of file transfers to - find the right one on the remote system. */ - if (fmatch) - { - struct scmdlist *qstdin; - - if (qxqt->s.bcmd == 'E') - qstdin = qxqt; - else if (zSxqt_stdin != NULL) - { - for (qstdin = qlist; - qstdin != NULL; - qstdin = qstdin->qnext) - if (qstdin->s.bcmd == 'S' - && strcmp (qstdin->s.zto, zSxqt_stdin) == 0) - break; - } - else - qstdin = NULL; - - if (qstdin != NULL) - { - if (strchr (qstdin->s.zoptions, 'C') != NULL - || fspool_file (qstdin->s.zfrom)) - zstdin = qstdin->s.ztemp; - else - zstdin = qstdin->s.zfrom; - } - } - - if (fmatch && (icmd & JOB_SHOW) != 0) - { - usworkfile_header (qsys, &qxqt->s, zlistid, qxqt->itime, - TRUE); - printf ("Executing %s (sending %ld bytes)\n", zcmd, csize); - } - } - - if (fmatch) - { - boolean fkill_or_rejuv; - - fkill_or_rejuv = FALSE; - if ((icmd & JOB_INQUIRE) != 0) - { - int b; - - /* Ask stdin whether this job should be killed. */ - fprintf (stderr, "%s: %s %s? ", - zProgram, - (icmd & JOB_REJUVENATE) != 0 ? "Rejuvenate" : "Kill", - zlistid); - (void) fflush (stderr); - b = getchar (); - fkill_or_rejuv = b == 'y' || b == 'Y'; - while (b != EOF && b != '\n') - b = getchar (); - } - else if ((icmd & JOB_KILL) != 0 - || (icmd & JOB_REJUVENATE) != 0) - fkill_or_rejuv = TRUE; - - if (fkill_or_rejuv - && (qlist->s.zuser == NULL - || strcmp (zsysdep_login_name (), qlist->s.zuser) != 0) - && ! fsysdep_privileged ()) - ulog (LOG_ERROR, "%s: Not submitted by you", zlistid); - else - { - if ((icmd & (JOB_MAIL | JOB_NOTIFY)) != 0) - { - if (! fsnotify (puuconf, icmd, zcomment, cstdin, - (fkill_or_rejuv && - (icmd & JOB_REJUVENATE) == 0), - zcmd, qlist, zlistid, qlist->itime, - qlist->s.zuser, qsys, zstdin, - qlist->s.pseq, zrequestor)) - return FALSE; - } - - if (fkill_or_rejuv) - { - if ((icmd & JOB_REJUVENATE) == 0) - { - if (! fsysdep_kill_job (puuconf, zlistid)) - return FALSE; - } - else - { - if (! fsysdep_rejuvenate_job (puuconf, zlistid)) - return FALSE; - } - } - } - } - - if (qxqt != NULL) - { - if (qxqt->s.bcmd == 'E') - ubuffree (zfree); - else - usxqt_file_free (); - } - - /* Free up the list of entries. */ - qfree = qlist; - while (qfree != NULL) - { - struct scmdlist *qnext; - - qnext = qfree->qnext; - xfree ((pointer) qfree); - qfree = qnext; - } - - ubuffree (zlistid); - - qlist = NULL; - zlistid = NULL; - } - - /* Start a new list with the entry we just got. */ - if (qcmd != NULL) - { - qlist = (struct scmdlist *) xmalloc (sizeof (struct scmdlist)); - qlist->qnext = NULL; - qlist->s = *qcmd; - qlist->itime = itime; - zlistid = zid; - } - - return TRUE; -} - -/* Show the header of the line describing a workfile. */ - -static void -usworkfile_header (qsys, qcmd, zjobid, itime, ffirst) - const struct uuconf_system *qsys; - const struct scmd *qcmd; - const char *zjobid; - long itime; - boolean ffirst; -{ - const char *zshowid; - struct tm stime; - - if (ffirst) - zshowid = zjobid; - else - zshowid = "-"; - - printf ("%s %s %s ", zshowid, qsys->uuconf_zname, - qcmd->zuser != NULL ? qcmd->zuser : OWNER); - - usysdep_localtime (itime, &stime); - printf ("%02d-%02d %02d:%02d ", - stime.tm_mon + 1, stime.tm_mday, stime.tm_hour, stime.tm_min); -} - -/* List queued executions that have not been processed by uuxqt for - one reason or another. */ - -static boolean -fsexecutions (puuconf, icmd, csystems, pazsystems, fnotsystems, cusers, - pazusers, fnotusers, iold, iyoung, ccommands, pazcommands, - fnotcommands, zcomment, cstdin) - pointer puuconf; - int icmd; - int csystems; - char **pazsystems; - boolean fnotsystems; - int cusers; - char **pazusers; - boolean fnotusers; - long iold; - long iyoung; - int ccommands; - char **pazcommands; - boolean fnotcommands; - const char *zcomment; - int cstdin; -{ - const char *zlocalname; - int iuuconf; - char *zfile; - char *zsystem; - boolean ferr; - - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - if (! fsysdep_get_xqt_init ((const char *) NULL)) - return FALSE; - - while ((zfile = zsysdep_get_xqt ((const char *) NULL, &zsystem, &ferr)) - != NULL) - { - boolean fmatch; - int i; - long itime; - FILE *e; - - if (csystems > 0) - { - fmatch = fnotsystems; - for (i = 0; i < csystems; i++) - { - if (strcmp (pazsystems[i], zsystem) == 0) - { - fmatch = ! fmatch; - break; - } - } - if (! fmatch) - { - ubuffree (zfile); - ubuffree (zsystem); - continue; - } - } - - itime = ixsysdep_file_time (zfile); - - if ((iold != (long) -1 && itime > iold) - || (iyoung != (long) -1 && itime < iyoung)) - { - ubuffree (zfile); - ubuffree (zsystem); - continue; - } - - /* We need to read the execution file before we can check the - user name. */ - e = fopen (zfile, "r"); - if (e == NULL) - { - /* Probably uucico just deleted the file. */ - continue; - } - if (! fsxqt_file_read (puuconf, e)) - { - (void) fclose (e); - ubuffree (zfile); - ubuffree (zsystem); - continue; - } - (void) fclose (e); - - if (cusers == 0) - fmatch = TRUE; - else - { - fmatch = fnotusers; - for (i = 0; i < cusers; i++) - { - if (strcmp (zSxqt_user, pazusers[i]) == 0 - || (zSxqt_requestor != NULL - && strcmp (zSxqt_requestor, pazusers[i]) == 0)) - { - fmatch = ! fmatch; - break; - } - } - } - - if (fmatch && ccommands > 0) - { - fmatch = fnotcommands; - for (i = 0; i < ccommands; i++) - { - if (strcmp (pazcommands[i], "ALL") == 0 - || strcmp (pazcommands[i], zSxqt_prog) == 0) - { - fmatch = ! fmatch; - break; - } - } - } - - if (fmatch) - { - boolean fbad, fkill_or_rejuv; - struct uuconf_system ssys; - - fbad = FALSE; - - if ((icmd & JOB_SHOW) != 0) - { - struct tm stime; - - printf ("%s %s!", zsystem, zSxqt_system); - if (zSxqt_requestor != NULL) - printf ("%s", zSxqt_requestor); - else - printf ("%s", zSxqt_user); - - usysdep_localtime (itime, &stime); - printf (" %02d-%02d %02d:%02d ", - stime.tm_mon + 1, stime.tm_mday, stime.tm_hour, - stime.tm_min); - - printf ("%s\n", zSxqt_cmd); - } - - fkill_or_rejuv = FALSE; - if ((icmd & JOB_INQUIRE) != 0) - { - int b; - - /* Ask stdin whether this job should be killed. */ - fprintf (stderr, "%s: %s %s? ", - zProgram, - (icmd & JOB_REJUVENATE) != 0 ? "Rejuvenate" : "Kill", - zSxqt_cmd); - (void) fflush (stderr); - b = getchar (); - fkill_or_rejuv = b == 'y' || b == 'Y'; - while (b != EOF && b != '\n') - b = getchar (); - } - else if ((icmd & JOB_KILL) != 0 - || (icmd & JOB_REJUVENATE) != 0) - fkill_or_rejuv = TRUE; - - if (fkill_or_rejuv) - { - if ((strcmp (zSxqt_user, zsysdep_login_name ()) != 0 - || strcmp (zsystem, zlocalname) != 0) - && ! fsysdep_privileged ()) - { - ulog (LOG_ERROR, "Job not submitted by you\n"); - fbad = TRUE; - } - } - - if (! fbad) - { - iuuconf = uuconf_system_info (puuconf, zsystem, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fbad = TRUE; - } - else if (strcmp (zsystem, zlocalname) == 0) - { - iuuconf = uuconf_system_local (puuconf, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fbad = TRUE; - } - ssys.uuconf_zname = (char *) zlocalname; - } - else if (! funknown_system (puuconf, zsystem, &ssys)) - { - ulog (LOG_ERROR, "Job for unknown system %s", - zsystem); - fbad = TRUE; - } - } - } - - if (! fbad && (icmd & (JOB_MAIL | JOB_NOTIFY)) != 0) - { - if (! fsnotify (puuconf, icmd, zcomment, cstdin, - fkill_or_rejuv && (icmd & JOB_REJUVENATE) == 0, - zSxqt_cmd, (struct scmdlist *) NULL, - (const char *) NULL, itime, zSxqt_user, &ssys, - zSxqt_stdin, (pointer) NULL, zSxqt_requestor)) - { - ferr = TRUE; - usxqt_file_free (); - ubuffree (zfile); - ubuffree (zsystem); - break; - } - } - - if (! fbad && fkill_or_rejuv) - { - for (i = 0; i < cSxqt_files; i++) - { - char *z; - - z = zsysdep_spool_file_name (&ssys, pazSxqt_files[i], - (pointer) NULL); - if (z != NULL) - { - if ((icmd & JOB_REJUVENATE) != 0) - (void) fsysdep_touch_file (z); - else - (void) remove (z); - ubuffree (z); - } - } - if ((icmd & JOB_REJUVENATE) != 0) - (void) fsysdep_touch_file (zfile); - else - { - if (remove (zfile) != 0) - ulog (LOG_ERROR, "remove (%s): %s", zfile, - strerror (errno)); - } - } - - if (! fbad) - (void) uuconf_system_free (puuconf, &ssys); - } - - usxqt_file_free (); - ubuffree (zfile); - ubuffree (zsystem); - } - - usysdep_get_xqt_free ((const char *) NULL); - - return ferr; -} - -/* When a job is killed, send mail to the appropriate people. */ - -static boolean -fsnotify (puuconf, icmd, zcomment, cstdin, fkilled, zcmd, qcmd, zid, itime, - zuser, qsys, zstdin, pstdinseq, zrequestor) - pointer puuconf; - int icmd; - const char *zcomment; - int cstdin; - boolean fkilled; - const char *zcmd; - struct scmdlist *qcmd; - const char *zid; - long itime; - const char *zuser; - const struct uuconf_system *qsys; - const char *zstdin; - pointer pstdinseq; - const char *zrequestor; -{ - const char **pz; - int cgot; - int i, istdin; - struct tm stime; - char ab[sizeof "1991-12-31 12:00:00"]; - const char *zsubject; - boolean fret; - - pz = (const char **) xmalloc (20 * sizeof (const char *)); - cgot = 20; - - i = 0; - if (zid == NULL) - pz[i++] = "A UUCP execution request"; - else - { - pz[i++] = "UUCP job\n\t"; - pz[i++] = zid; - pz[i++] = "\nfor system\n\t"; - pz[i++] = qsys->uuconf_zname; - } - pz[i++] = "\nrequested by\n\t"; - pz[i++] = zuser != NULL ? zuser : OWNER; - if (zid == NULL) - { - pz[i++] = "\non system\n\t"; - pz[i++] = qsys->uuconf_zname; - } - pz[i++] = "\n"; - - if (fkilled) - pz[i++] = "has been killed.\n"; - - if (zcomment != NULL) - { - pz[i++] = zcomment; - pz[i++] = "\n"; - } - - pz[i++] = "The job was queued at "; - usysdep_localtime (itime, &stime); - sprintf (ab, "%04d-%02d-%02d %02d:%02d:%02d", - stime.tm_year + 1900, stime.tm_mon + 1, stime.tm_mday, - stime.tm_hour, stime.tm_min, stime.tm_sec); - pz[i++] = ab; - pz[i++] = ".\nIt "; - - if (fkilled) - pz[i++] = "was\n"; - else - pz[i++] = "is\n"; - - if (zcmd != NULL) - { - pz[i++] = "\t"; - pz[i++] = zcmd; - } - else - { - struct scmdlist *qshow; - - for (qshow = qcmd; qshow != NULL; qshow = qshow->qnext) - { - if (i + 10 > cgot) - { - cgot += 20; - pz = (const char **) xrealloc ((pointer) pz, - cgot * sizeof (const char *)); - } - - switch (qshow->s.bcmd) - { - case 'S': - pz[i++] = "\tsend "; - break; - default: - case 'R': - case 'X': - pz[i++] = "\trequest "; - break; - case 'P': - pz[i++] = "\tpoll "; - break; -#if DEBUG > 0 - case 'E': - ulog (LOG_FATAL, "fsnotify: Can't happen"); - break; -#endif - } - if (qshow->s.zfrom != NULL && qshow->s.zto != NULL) - { - pz[i++] = qshow->s.zfrom; - pz[i++] = " to "; - pz[i++] = qshow->s.zto; - } - } - } - - istdin = i; - if (cstdin > 0 && zstdin != NULL) - { - boolean fspool; - char *zfile; - FILE *e; - - fspool = fspool_file (zstdin); - if (fspool) - zfile = zsysdep_spool_file_name (qsys, zstdin, pstdinseq); - else - zfile = zsysdep_local_file (zstdin, qsys->uuconf_zpubdir, - (boolean *) NULL); - - if (zfile != NULL - && (fspool - || fin_directory_list (zfile, qsys->uuconf_pzremote_send, - qsys->uuconf_zpubdir, TRUE, TRUE, - (const char *) NULL))) - { - e = fopen (zfile, "r"); - if (e != NULL) - { - int clines, clen; - char *zline; - size_t cline; - - pz[i++] = "\n"; - istdin = i; - - clines = 0; - - zline = NULL; - cline = 0; - while ((clen = getline (&zline, &cline, e)) > 0) - { - if (memchr (zline, '\0', (size_t) clen) != NULL) - { - int ifree; - - /* A null character means this is probably a - binary file. */ - for (ifree = istdin; ifree < i; ifree++) - ubuffree ((char *) pz[ifree]); - i = istdin - 1; - break; - } - ++clines; - if (clines > cstdin) - break; - if (i >= cgot) - { - cgot += 20; - pz = (const char **) xrealloc ((pointer) pz, - (cgot - * sizeof (char *))); - } - if (strncmp (zline, "From ", sizeof "From " - 1) != 0) - pz[i++] = zbufcpy (zline); - else - { - char *zalc; - - /* Escape "From " at the start of a line. This - should really be the responsibility of the - mail transfer agent. On some systems, - though, the mail transfer agent does not do - it, but user mail programs expect it. We - help them out here, since it doesn't matter - much--we're already truncating the message - anyhow. */ - zalc = zbufalc (strlen (zline) + 2); - zalc[0] = '>'; - strcpy (zalc + 1, zline); - pz[i++] = zalc; - } - } - xfree ((pointer) zline); - (void) fclose (e); - } - } - - ubuffree (zfile); - } - - if (fkilled) - zsubject = "UUCP job killed"; - else - zsubject = "UUCP notification"; - - fret = TRUE; - - if ((icmd & JOB_MAIL) != 0) - { - if (! fsysdep_mail (OWNER, zsubject, i, pz)) - fret = FALSE; - } - - if ((icmd & JOB_NOTIFY) != 0 - && (zrequestor != NULL || zuser != NULL)) - { - const char *zmail; - char *zfree; - - if (zrequestor != NULL) - zmail = zrequestor; - else - zmail = zuser; - - zfree = NULL; - - if (zid == NULL) - { - int iuuconf; - const char *zloc; - - /* This is an execution request, which may be from another - system. If it is, we must prepend that system name to - the user name extracted from the X. file. */ - iuuconf = uuconf_localname (puuconf, &zloc); - if (iuuconf == UUCONF_NOT_FOUND) - { - zloc = zsysdep_localname (); - if (zloc == NULL) - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - if (strcmp (qsys->uuconf_zname, zloc) != 0 -#if HAVE_INTERNET_MAIL - && strchr (zmail, '@') == NULL -#endif - ) - { - zfree = zbufalc (strlen (qsys->uuconf_zname) - + strlen (zmail) - + sizeof "!"); - sprintf (zfree, "%s!%s", qsys->uuconf_zname, zmail); - zmail = zfree; - } - } - - if (! fsysdep_mail (zmail, zsubject, i, pz)) - fret = FALSE; - - ubuffree (zfree); - } - - while (istdin < i) - { - ubuffree ((char *) pz[istdin]); - istdin++; - } - - xfree ((pointer) pz); - - return fret; -} - -/* Handle the -q option. For each remote system this lists the number - of jobs queued, the number of executions queued, and the current - call status. We get the executions all at once, because they are - not accessed by system. They could be, but it is possible to have - executions pending for an unknown system, so special handling would - still be required. */ - -struct sxqtlist -{ - struct sxqtlist *qnext; - char *zsystem; - int cxqts; - long ifirst; -}; - -/* These local functions need the definition of sxqtlist for the - prototype. */ - -static boolean fsquery_system P((const struct uuconf_system *qsys, - struct sxqtlist **pq, - long inow, const char *zlocalname, - int csystems, char **pazsystems, - boolean fnotsystems, long iold, long iyoung)); -static boolean fsquery_show P((const struct uuconf_system *qsys, int cwork, - long ifirstwork, struct sxqtlist *qxqt, - long inow, const char *zlocalname, - int csystems, char **pazsystems, - boolean fnotsystems, long iold, long iyoung)); - -static boolean -fsquery (puuconf, csystems, pazsystems, fnotsystems, iold, iyoung) - pointer puuconf; - int csystems; - char **pazsystems; - boolean fnotsystems; - long iold; - long iyoung; -{ - int iuuconf; - const char *zlocalname; - struct sxqtlist *qlist; - char *zfile, *zsystem; - boolean ferr; - long inow; - char **pznames, **pz; - boolean fret; - - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - return FALSE; - } - else if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - /* Get a count of all the execution files. */ - if (! fsysdep_get_xqt_init ((const char *) NULL)) - return FALSE; - - qlist = NULL; - while ((zfile = zsysdep_get_xqt ((const char *) NULL, &zsystem, &ferr)) - != NULL) - { - struct sxqtlist *qlook; - - for (qlook = qlist; qlook != NULL; qlook = qlook->qnext) - if (strcmp (zsystem, qlook->zsystem) == 0) - break; - - if (qlook != NULL) - { - long itime; - - ubuffree (zsystem); - ++qlook->cxqts; - itime = ixsysdep_file_time (zfile); - if (itime < qlook->ifirst) - qlook->ifirst = itime; - } - else - { - struct sxqtlist *qnew; - - qnew = (struct sxqtlist *) xmalloc (sizeof (struct sxqtlist)); - qnew->qnext = qlist; - qnew->zsystem = zsystem; - qnew->cxqts = 1; - qnew->ifirst = ixsysdep_file_time (zfile); - qlist = qnew; - } - - ubuffree (zfile); - } - - usysdep_get_xqt_free ((const char *) NULL); - - if (ferr) - return FALSE; - - inow = ixsysdep_time ((long *) NULL); - - /* Show the information for each system. */ - iuuconf = uuconf_system_names (puuconf, &pznames, 0); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - return FALSE; - } - - fret = TRUE; - - for (pz = pznames; *pz != NULL; pz++) - { - struct uuconf_system ssys; - - iuuconf = uuconf_system_info (puuconf, *pz, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - continue; - } - - if (! fsquery_system (&ssys, &qlist, inow, zlocalname, csystems, - pazsystems, fnotsystems, iold, iyoung)) - fret = FALSE; - - (void) uuconf_system_free (puuconf, &ssys); - xfree ((pointer) *pz); - } - - /* Check for the local system in the list of execution files. */ - if (qlist != NULL) - { - struct sxqtlist **pq; - - for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext) - { - if (strcmp ((*pq)->zsystem, zlocalname) == 0) - { - struct uuconf_system ssys; - struct sxqtlist *qfree; - - iuuconf = uuconf_system_info (puuconf, zlocalname, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - break; - } - - iuuconf = uuconf_system_local (puuconf, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - fret = FALSE; - break; - } - ssys.uuconf_zname = (char *) zlocalname; - } - - if (! fsquery_show (&ssys, 0, 0L, *pq, inow, zlocalname, - csystems, pazsystems, fnotsystems, - iold, iyoung)) - fret = FALSE; - (void) uuconf_system_free (puuconf, &ssys); - qfree = *pq; - *pq = qfree->qnext; - ubuffree (qfree->zsystem); - xfree ((pointer) qfree); - break; - } - } - } - - /* Print out information for any unknown systems for which we have - execution files. */ - while (qlist != NULL) - { - struct uuconf_system ssys; - struct sxqtlist *qnext; - - if (! funknown_system (puuconf, qlist->zsystem, &ssys)) - { - ulog (LOG_ERROR, "Executions queued up for unknown systems"); - fret = FALSE; - break; - } - - if (! fsquery_show (&ssys, 0, 0L, qlist, inow, zlocalname, - csystems, pazsystems, fnotsystems, iold, iyoung)) - fret = FALSE; - (void) uuconf_system_free (puuconf, &ssys); - qnext = qlist->qnext; - ubuffree (qlist->zsystem); - xfree ((pointer) qlist); - qlist = qnext; - } - - return fret; -} - -/* Query a single known system. */ - -static boolean -fsquery_system (qsys, pq, inow, zlocalname, csystems, pazsystems, - fnotsystems, iold, iyoung) - const struct uuconf_system *qsys; - struct sxqtlist **pq; - long inow; - const char *zlocalname; - int csystems; - char **pazsystems; - boolean fnotsystems; - long iold; - long iyoung; -{ - int cwork; - long ifirstwork; - char *zid; - boolean fret; - - if (! fsysdep_get_work_init (qsys, UUCONF_GRADE_LOW)) - return FALSE; - - cwork = 0; - ifirstwork = 0L; - zid = NULL; - while (TRUE) - { - struct scmd s; - long itime; - char *zthisid; - - if (! fsysdep_get_work (qsys, UUCONF_GRADE_LOW, &s)) - return FALSE; - if (s.bcmd == 'H') - break; - - zthisid = zsysdep_jobid (qsys, s.pseq); - if (zid != NULL && strcmp (zid, zthisid) == 0) - ubuffree (zthisid); - else - { - ++cwork; - ubuffree (zid); - zid = zthisid; - } - - itime = ixsysdep_work_time (qsys, s.pseq); - if (ifirstwork == 0L || ifirstwork > itime) - ifirstwork = itime; - } - - usysdep_get_work_free (qsys); - ubuffree (zid); - - /* Find the execution information, if any. */ - while (*pq != NULL) - { - if (strcmp ((*pq)->zsystem, qsys->uuconf_zname) == 0) - break; - pq = &(*pq)->qnext; - } - - /* If there are no commands and no executions, don't print any - information for this system. */ - if (cwork == 0 && *pq == NULL) - return TRUE; - - fret = fsquery_show (qsys, cwork, ifirstwork, *pq, inow, - zlocalname, csystems, pazsystems, fnotsystems, - iold, iyoung); - - if (*pq != NULL) - { - struct sxqtlist *qfree; - - qfree = *pq; - *pq = qfree->qnext; - ubuffree (qfree->zsystem); - xfree ((pointer) qfree); - } - - return fret; -} - -/* Print out the query information for a single system. We handle the - local system specially. */ - -static boolean -fsquery_show (qsys, cwork, ifirstwork, qxqt, inow, zlocalname, - csystems, pazsystems, fnotsystems, iold, iyoung) - const struct uuconf_system *qsys; - int cwork; - long ifirstwork; - struct sxqtlist *qxqt; - long inow; - const char *zlocalname; - int csystems; - char **pazsystems; - boolean fnotsystems; - long iold; - long iyoung; -{ - boolean flocal; - struct sstatus sstat; - boolean fnostatus; - struct tm stime; - int cpad; - - /* Make sure this is one of the systems we are printing. */ - if (csystems > 0) - { - boolean fmatch; - int i; - - fmatch = fnotsystems; - for (i = 0; i < csystems; i++) - { - if (strcmp (pazsystems[i], qsys->uuconf_zname) == 0) - { - fmatch = ! fmatch; - break; - } - } - if (! fmatch) - return TRUE; - } - - /* Make sure the commands are within the time bounds. */ - if ((iold != (long) -1 - && (cwork == 0 || ifirstwork > iold) - && (qxqt == NULL || qxqt->ifirst > iold)) - || (iyoung != (long) -1 - && (cwork == 0 || ifirstwork < iyoung) - && (qxqt == NULL || qxqt->ifirst < iyoung))) - return TRUE; - - flocal = strcmp (qsys->uuconf_zname, zlocalname) == 0; - - if (! flocal) - { - if (! fsysdep_get_status (qsys, &sstat, &fnostatus)) - return FALSE; - } - - printf ("%-10s %3dC (", qsys->uuconf_zname, cwork); - - if (cwork == 0) - { - printf ("0 secs"); - cpad = 3; - } - else - cpad = csunits_show (inow - ifirstwork); - - printf (") "); - while (cpad-- != 0) - printf (" "); - - if (qxqt == NULL) - printf (" 0X (0 secs) "); - else - { - printf ("%3dX (", qxqt->cxqts); - cpad = csunits_show (inow - qxqt->ifirst); - printf (")"); - while (cpad-- != 0) - printf (" "); - } - - if (flocal || fnostatus) - { - printf ("\n"); - if (! flocal) - ubuffree (sstat.zstring); - return TRUE; - } - - usysdep_localtime (sstat.ilast, &stime); - - printf (" %02d-%02d %02d:%02d ", - stime.tm_mon + 1,stime.tm_mday, stime.tm_hour, stime.tm_min); - - if (sstat.zstring == NULL) - printf ("%s\n", azStatus[(int) sstat.ttype]); - else - { - printf ("%s\n", sstat.zstring); - ubuffree (sstat.zstring); - } - - return TRUE; -} - -/* Print a time difference in the largest applicable units. */ - -static int -csunits_show (idiff) - long idiff; -{ - const char *zunit; - long iunits; - int cpad; - - if (idiff > (long) 24 * (long) 60 * (long) 60) - { - iunits = idiff / ((long) 24 * (long) 60 * (long) 60); - zunit = "day"; - cpad = 4; - } - else if (idiff > (long) 60 * 60) - { - iunits = idiff / (long) (60 * 60); - zunit = "hour"; - cpad = 3; - } - else if (idiff > (long) 60) - { - iunits = idiff / (long) 60; - zunit = "min"; - cpad = 4; - } - else - { - iunits = idiff; - zunit = "sec"; - cpad = 4; - } - - printf ("%ld %s%s", iunits, zunit, iunits == 1 ? "" : "s"); - - if (iunits != 1) - --cpad; - if (iunits > 99) - --cpad; - if (iunits > 9) - --cpad; - return cpad; -} - -/* Give a list of all status entries for all machines that we have - status entries for. We need to get a list of status entries in a - system dependent fashion, since we may have status for unknown - systems. */ - -static boolean -fsmachines () -{ - pointer phold; - char *zsystem; - boolean ferr; - struct sstatus sstat; - - if (! fsysdep_all_status_init (&phold)) - return FALSE; - - while ((zsystem = zsysdep_all_status (phold, &ferr, &sstat)) != NULL) - { - struct tm stime; - - usysdep_localtime (sstat.ilast, &stime); - printf ("%-14s %02d-%02d %02d:%02d ", zsystem, - stime.tm_mon + 1, stime.tm_mday, stime.tm_hour, - stime.tm_min); - if (sstat.zstring == NULL) - printf ("%s", azStatus[(int) sstat.ttype]); - else - { - printf ("%s", sstat.zstring); - ubuffree (sstat.zstring); - } - ubuffree (zsystem); - if (sstat.ttype != STATUS_TALKING - && sstat.cwait > 0) - { - printf (" (%d %s", sstat.cretries, - sstat.cretries == 1 ? "try" : "tries"); - if (sstat.ilast + sstat.cwait > ixsysdep_time ((long *) NULL)) - { - usysdep_localtime (sstat.ilast + sstat.cwait, &stime); - printf (", next after %02d-%02d %02d:%02d", - stime.tm_mon + 1, stime.tm_mday, stime.tm_hour, - stime.tm_min); - } - printf (")"); - } - printf ("\n"); - } - - usysdep_all_status_free (phold); - - return ! ferr; -} diff --git a/gnu/libexec/uucp/uuto/Makefile b/gnu/libexec/uucp/uuto/Makefile deleted file mode 100644 index 2682611..0000000 --- a/gnu/libexec/uucp/uuto/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for uuto -# $FreeBSD$ - -SCRIPTS= uuto -MAN= uuto.1 -CLEANFILES+= $(SCRIPTS) - -BINDIR= $(bindir) - -uuto: uuto.in - sed -e "s|@BINDIR@|$(bindir)|g" \ - $(.ALLSRC) > $(.TARGET) - -.include <bsd.prog.mk> diff --git a/gnu/libexec/uucp/uuto/uuto.1 b/gnu/libexec/uucp/uuto/uuto.1 deleted file mode 100644 index a98a02e..0000000 --- a/gnu/libexec/uucp/uuto/uuto.1 +++ /dev/null @@ -1,41 +0,0 @@ -.\" $FreeBSD$ -.\" based on the uucp texinfo documentation -.TH uuto 1 "Taylor UUCP 1.06" -.SH NAME -uuto \- send files to a user on a remote system. -.SH SYNOPSIS -.B uuto -[uucp options] files... system!user -.SH DESCRIPTION -The -.B uuto -program may be used to conveniently send files to a -particular user on a remote system. It will arrange for mail to be sent -to the remote user when the files arrive on the remote system, and he or -she may easily retrieve the files using the -.B uupick -program. Note that -.B uuto -does not provide any -security--any user on the remote system can examine the files. -.PP -The last argument specifies the system and user name to which to send -the files. The other arguments are the files or directories to be sent. -.PP -The -.B uuto -program is actually just a trivial shell script which -invokes the -.B uucp -program with the appropriate arguments. Any option -which may be given to -.B uucp -may also be given to -.B uuto. -.SH SEE ALSO -uucp(1) -.SH AUTHOR -Ian Lance Taylor (ian@airs.com). -This Manpage based on the Taylor UUCP 1.06 Texinfo documentation. - - diff --git a/gnu/libexec/uucp/uuto/uuto.in b/gnu/libexec/uucp/uuto/uuto.in deleted file mode 100644 index 26a0dc7..0000000 --- a/gnu/libexec/uucp/uuto/uuto.in +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# uuto -# Send files to a user on another system. -# -# Copyright (C) 1992, 1993 Ian Lance Taylor -# -# Please feel free do whatever you like with this exciting shell -# script. -# -# This is pretty trivial, since all the functionality was moved into -# uucp itself. The -t means to interpret the final argument as -# system!user, the -R means to copy directories recursively, and the -# -c means to not copy the files to the spool directory (may be -# overriden by -C or -p). -# -exec @BINDIR@/uucp -t -R -c $* diff --git a/gnu/libexec/uucp/uux/Makefile b/gnu/libexec/uucp/uux/Makefile deleted file mode 100644 index 89c246b..0000000 --- a/gnu/libexec/uucp/uux/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Makefile for uux -# $FreeBSD$ - -PROG= uux -SRCS= uux.c util.c log.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" - -BINDIR= $(bindir) -BINOWN= $(owner) -BINMODE= 4555 -INSTALLFLAGS= -fschg - -.include <bsd.prog.mk> - -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uux/uux.1 b/gnu/libexec/uucp/uux/uux.1 deleted file mode 100644 index f5ad13c..0000000 --- a/gnu/libexec/uucp/uux/uux.1 +++ /dev/null @@ -1,256 +0,0 @@ -.\" $Id: uux.1,v 1.12 1995/06/27 02:21:14 ian Rel $ -.\" $FreeBSD$ -.TH uux 1 "Taylor UUCP 1.06" -.SH NAME -uux \- Remote command execution over UUCP -.SH SYNOPSIS -.B uux -[ options ] command -.SH DESCRIPTION -The -.I uux -command is used to execute a command on a remote system, or to execute -a command on the local system using files from remote systems. -The command -is not executed immediately; the request is queued until the -.I uucico -(8) daemon calls the system and executes it. The daemon is -started automatically unless one of the -.B \-r -or -.B \-\-nouucico -options is given. - -The actual command execution is done by the -.I uuxqt -(8) daemon. - -File arguments can be gathered from remote systems to the execution -system, as can standard input. Standard output may be directed to a -file on a remote system. - -The command name may be preceded by a system name followed by an -exclamation point if it is to be executed on a remote system. An -empty system name is taken as the local system. - -Each argument that contains an exclamation point is treated as naming -a file. The system which the file is on is before the exclamation -point, and the pathname on that system follows it. An empty system -name is taken as the local system; this must be used to transfer a -file to a command being executed on a remote system. If the path is -not absolute, it will be appended to the current working directory on -the local system; the result may not be meaningful on the remote -system. A pathname may begin with ~/, in which case it is relative to -the UUCP public directory (usually /var/spool/uucppublic) on the -appropriate system. A pathname may begin with ~name/, in which case -it is relative to the home directory of the named user on the -appropriate system. - -Standard input and output may be redirected as usual; the pathnames -used may contain exclamation points to indicate that they are on -remote systems. Note that the redirection characters must be quoted -so that they are passed to -.I uux -rather than interpreted by the shell. Append redirection (>>) does -not work. - -All specified files are gathered together into a single directory -before execution of the command begins. This means that each file -must have a distinct base name. For example, -.br -.in +0.5i -.nf -uux 'sys1!diff sys2!~user1/foo sys3!~user2/foo >!foo.diff' -.fi -.in -0.5i -will fail because both files will be copied to sys1 and stored under -the name foo. - -Arguments may be quoted by parentheses to avoid interpretation of -exclamation points. This is useful when executing the -.I uucp -command on a remote system. - -A request to execute an empty command (e.g., -.I uux sys!) -will create a poll file for the specified system. -.SH OPTIONS -The following options may be given to -.I uux. -.TP 5 -.B \-, \-p, \-\-stdin -Read standard input and use it as the standard input for the command -to be executed. -.TP 5 -.B \-c, \-\-nocopy -Do not copy local files to the spool directory. This is the default. -If they are -removed before being processed by the -.I uucico -(8) daemon, the copy will fail. The files must be readable by the -.I uucico -(8) daemon, -as well as the by the invoker of -.I uux. -.TP 5 -.B \-C, \-\-copy -Copy local files to the spool directory. -.TP 5 -.B \-l, \-\-link -Link local files into the spool directory. If a file can not be -linked because it is on a different device, it will be copied unless -one of the -.B \-c -or -.B \-\-nocopy -options also appears (in other words, use of -.B \-\-link -switches the default from -.B \-\-nocopy -to -.B \-\-copy). -If the files are changed before being processed by the -.I uucico -(8) daemon, the changed versions will be used. The files must be -readable by the -.I uucico -(8) daemon, as well as by the invoker of -.I uux. -.TP 5 -.B \-g grade, \-\-grade grade -Set the grade of the file transfer command. Jobs of a higher grade -are executed first. Grades run 0 ... 9 A ... Z a ... z from high to -low. -.TP 5 -.B \-n, \-\-notification=no -Do not send mail about the status of the job, even if it fails. -.TP 5 -.B \-z, \-\-notification=error -Send mail about the status of the job if an error occurs. For many -.I uuxqt -daemons, including the Taylor UUCP -.I uuxqt, -this is the default action; for those, -.B \-\-notification=error -will have no effect. However, some -.I uuxqt -daemons will send mail if the job succeeds unless the -.B \-\-notification=error -option is used, and some other -.I uuxqt -daemons will not send mail if the job fails unless the -.B \-\-notification=error -option is used. -.TP 5 -.B \-r, \-\-nouucico -Do not start the -.I uucico -(8) daemon immediately; merely queue up the execution request for later -processing. -.TP 5 -.B \-j, \-\-jobid -Print jobids on standard output. A jobid will be generated for each -file copy operation required to perform the operation. These file -copies may be cancelled by passing the jobid to the -.B \-\-kill -switch of -.I uustat -(1), which will make the execution impossible to complete. -.TP 5 -.B \-a address, \-\-requestor address -Report job status to the specified e-mail address. -.TP 5 -.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, config, -spooldir and execute are meaningful for -.I uux. - -Multiple types may be given, separated by commas, and the -.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 \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. -.TP 5 -.B \-I file, \-\-config file -Set configuration file to use. This option may not be available, -depending upon how -.I uux -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH EXAMPLES -.br -.nf -uux -z - sys1!rmail user1 -.fi -Execute the command ``rmail user1'' on the system sys1, giving it as -standard input whatever is given to -.I uux -as standard input. If a failure occurs, send a message using -.I mail -(1). - -.br -.nf -uux 'diff -c sys1!~user1/file1 sys2!~user2/file2 >!file.diff' -.fi -Fetch the two named files from system sys1 and system sys2 and execute -.I diff -putting the result in file.diff in the current directory. The current -directory must be writable by the -.I uuxqt -(8) daemon for this to work. - -.br -.nf -uux 'sys1!uucp ~user1/file1 (sys2!~user2/file2)' -.fi -Execute -.I uucp -on the system sys1 copying file1 (on system sys1) to sys2. This -illustrates the use of parentheses for quoting. -.SH RESTRICTIONS -The remote system may not permit you to execute certain commands. -Many remote systems only permit the execution of -.I rmail -and -.I rnews. - -Some of the options are dependent on the capabilities of the -.I uuxqt -(8) daemon on the remote system. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/etc/uucp/config - Configuration file. -.br -/var/spool/uucp - -UUCP spool directory. -.br -/var/spool/uucp/Log - -UUCP log file. -.br -/var/spool/uucppublic - -Default UUCP public directory. -.SH SEE ALSO -mail(1), uustat(1), uucp(1), uucico(8), uuxqt(8) -.SH BUGS -Files can not be referenced across multiple systems. - -Too many jobids are output by -.B \-\-jobid, -and there is no good way to cancel a local execution requiring remote -files. -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com) diff --git a/gnu/libexec/uucp/uux/uux.c b/gnu/libexec/uucp/uux/uux.c deleted file mode 100644 index 069e9d6..0000000 --- a/gnu/libexec/uucp/uux/uux.c +++ /dev/null @@ -1,1626 +0,0 @@ -/* uux.c - Prepare to execute a command on a remote system. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uux_rcsid[] = "$FreeBSD$"; -#endif - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" -#include "sysdep.h" -#include "getopt.h" - -#include <ctype.h> -#include <errno.h> - -/* These character lists should, perhaps, be in sysdep.h. */ - -/* This is the list of shell metacharacters that we check for. If one - of these is present, we request uuxqt to execute the command with - /bin/sh. Otherwise we let it execute using execve. */ - -#define ZSHELLCHARS "\"'`*?[;&()|<>\\$" - -/* This is the list of word separators. We break filename arguments - at these characters. */ -#define ZSHELLSEPS ";&*|<> \t" - -/* This is the list of word separators without the redirection - operators. */ -#define ZSHELLNONREDIRSEPS ";&*| \t" - -/* Whether this execution is occurring on the local system. */ -static boolean fXxqtlocal; - -/* The execution system. */ -static struct uuconf_system sXxqtsys; - -/* The name of local system from the point of view of the execution - system. */ -static const char *zXxqtloc; - -/* The job grade to use. */ -static char bXgrade = BDEFAULT_UUX_GRADE; - -/* The temporary file name of the execute file. */ -static char abXxqt_tname[CFILE_NAME_LEN]; - -/* The name of the execute file on the remote system. */ -static char abXxqt_xname[CFILE_NAME_LEN]; - -/* The execute file we are creating. */ -static FILE *eXxqt_file; - -/* A list of commands to be spooled. */ -static struct scmd *pasXcmds; -static int cXcmds; - -/* A file to close if we're forced to exit. */ -static FILE *eXclose; - -/* A list of file names which will match the file names which appear - in the uucico logs. */ -static char *zXnames; - -/* Local functions. */ -static void uxusage P((void)); -static void uxhelp P((void)); -static void uxadd_xqt_line P((int bchar, const char *z1, const char *z2)); -static void uxadd_send_file P((const char *zfrom, const char *zto, - const char *zoptions, const char *ztemp, - const char *zforward)); -static void uxcopy_stdin P((FILE *e)); -static void uxrecord_file P((const char *zfile)); -static void uxabort P((void)); -static void uxadd_name P((const char *)); - -/* Long getopt options. */ -static const struct option asXlongopts[] = -{ - { "requestor", required_argument, NULL, 'a' }, - { "return-stdin", no_argument, NULL, 'b' }, - { "nocopy", no_argument, NULL, 'c' }, - { "copy", no_argument, NULL, 'C' }, - { "grade", required_argument, NULL, 'g' }, - { "jobid", no_argument, NULL, 'j' }, - { "link", no_argument, NULL, 'l' }, - { "notification", required_argument, NULL, 2 }, - { "stdin", no_argument, NULL, 'p' }, - { "nouucico", no_argument, NULL, 'r' }, - { "status", required_argument, NULL, 's' }, - { "noexpand", no_argument, NULL, 'W' }, - { "config", required_argument, NULL, 'I' }, - { "debug", required_argument, NULL, 'x' }, - { "version", no_argument, NULL, 'v' }, - { "help", no_argument, NULL, 1 }, - { NULL, 0, NULL, 0 } -}; - -/* The main routine. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - /* -a: requestor address for status reports. */ - const char *zrequestor = NULL; - /* -b: if true, return standard input on error. */ - boolean fretstdin = FALSE; - /* -c,-C: if true, copy to spool directory. */ - boolean fcopy = FALSE; - /* -c: set if -c appears explicitly; if it and -l appear, then if the - link fails we don't copy the file. */ - boolean fdontcopy = FALSE; - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -j: output job id. */ - boolean fjobid = FALSE; - /* -l: link file to spool directory. */ - boolean flink = FALSE; - /* -n: do not notify upon command completion. */ - boolean fno_ack = FALSE; - /* -p: read standard input for command standard input. */ - boolean fread_stdin = FALSE; - /* -r: do not start uucico when finished. */ - boolean fuucico = TRUE; - /* -s: report status to named file. */ - const char *zstatus_file = NULL; - /* -W: only expand local file names. */ - boolean fexpand = TRUE; - /* -z: report status only on error. */ - boolean ferror_ack = FALSE; - int iopt; - pointer puuconf; - int iuuconf; - const char *zlocalname; - int i; - size_t clen; - char *zargs; - char *zarg; - char *zcmd; - const char *zsys; - char *zexclam; - boolean fgetcwd; - const char *zuser; - char *zforward; - char **pzargs; - int calloc_args; - int cargs; - const char *zinput_from; - const char *zinput_to; - const char *zinput_temp; - boolean finputcopied; - char *zcall_system; - boolean fcall_any; - struct uuconf_system slocalsys; - boolean fneedshell; - char *zfullcmd; - boolean fpoll; - char aboptions[10]; - boolean fexit; - - zProgram = argv[0]; - - /* We need to be able to read a single - as an option, which getopt - won't do. We handle this by using getopt to scan the argument - list multiple times, replacing any single "-" with "-p". */ - opterr = 0; - while (1) - { - while (getopt_long (argc, argv, "+a:bcCg:I:jlnprs:Wvx:z", - asXlongopts, (int *) NULL) != EOF) - ; - if (optind >= argc || strcmp (argv[optind], "-") != 0) - break; - argv[optind] = zbufcpy ("-p"); - optind = 0; - } - opterr = 1; - optind = 0; - - /* The leading + in the getopt string means to stop processing - options as soon as a non-option argument is seen. */ - while ((iopt = getopt_long (argc, argv, "+a:bcCg:I:jlnprs:Wvx:z", - asXlongopts, (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'a': - /* Set requestor name: mail address to which status reports - should be sent. */ - zrequestor = optarg; - break; - - case 'b': - /* Return standard input on error. */ - fretstdin = TRUE; - break; - - case 'c': - /* Do not copy local files to spool directory. */ - fcopy = FALSE; - fdontcopy = TRUE; - break; - - case 'C': - /* Copy local files to spool directory. */ - fcopy = TRUE; - break; - - case 'I': - /* Configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 'j': - /* Output jobid. */ - fjobid = TRUE; - break; - - case 'g': - /* Set job grade. */ - bXgrade = optarg[0]; - break; - - case 'l': - /* Link file to spool directory. */ - flink = TRUE; - break; - - case 'n': - /* Do not notify upon command completion. */ - fno_ack = TRUE; - break; - - case 'p': - /* Read standard input for command standard input. */ - fread_stdin = TRUE; - break; - - case 'r': - /* Do not start uucico when finished. */ - fuucico = FALSE; - break; - - case 's': - /* Report status to named file. */ - zstatus_file = optarg; - break; - - case 'W': - /* Only expand local file names. */ - fexpand = FALSE; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'z': - /* Report status only on error. */ - ferror_ack = TRUE; - break; - - case 2: - /* --notify={true,false,error}. */ - if (*optarg == 't' - || *optarg == 'T' - || *optarg == 'y' - || *optarg == 'Y' - || *optarg == 'e' - || *optarg == 'E') - { - ferror_ack = TRUE; - fno_ack = FALSE; - } - else if (*optarg == 'f' - || *optarg == 'F' - || *optarg == 'n' - || *optarg == 'N') - { - ferror_ack = FALSE; - fno_ack = TRUE; - } - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - uxhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - uxusage (); - break; - } - } - - if (! UUCONF_GRADE_LEGAL (bXgrade) - || ((bXgrade < '0' || bXgrade > '9') - && (bXgrade < 'a' || bXgrade > 'z') - && (bXgrade < 'A' || bXgrade > 'Z'))) - { - ulog (LOG_ERROR, "Ignoring illegal grade"); - bXgrade = BDEFAULT_UUX_GRADE; - } - - if (optind == argc) - uxusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - /* The command and files arguments could be quoted in any number of - ways, so we split them apart ourselves. We do this before - calling usysdep_initialize because we want to set fgetcwd - correctly. */ - clen = 1; - for (i = optind; i < argc; i++) - clen += strlen (argv[i]) + 1; - - zargs = zbufalc (clen); - *zargs = '\0'; - for (i = optind; i < argc; i++) - { - strcat (zargs, argv[i]); - strcat (zargs, " "); - } - - /* The first argument is the command to execute. */ - clen = strcspn (zargs, ZSHELLSEPS); - zcmd = zbufalc (clen + 1); - strncpy (zcmd, zargs, clen); - zcmd[clen] = '\0'; - zargs += clen; - - /* Split the arguments out into an array. We break the arguments - into alternating sequences of characters not in ZSHELLSEPS - and characters in ZSHELLSEPS. We remove whitespace. We - separate the redirection characters '>' and '<' into their - own arguments to make them easier to process below. */ - calloc_args = 10; - pzargs = (char **) xmalloc (calloc_args * sizeof (char *)); - cargs = 0; - - for (zarg = strtok (zargs, " \t"); - zarg != NULL; - zarg = strtok ((char *) NULL, " \t")) - { - while (*zarg != '\0') - { - if (cargs + 1 >= calloc_args) - { - calloc_args += 10; - pzargs = (char **) xrealloc ((pointer) pzargs, - calloc_args * sizeof (char *)); - } - - if (*zarg == '(') - clen = strlen (zarg); - else - clen = strcspn (zarg, ZSHELLSEPS); - if (clen > 0) - { - pzargs[cargs] = zbufalc (clen + 1); - memcpy (pzargs[cargs], zarg, clen); - pzargs[cargs][clen] = '\0'; - ++cargs; - zarg += clen; - } - - /* We deliberately separate '>' and '<' out. */ - if (*zarg != '\0') - { - clen = strspn (zarg, ZSHELLNONREDIRSEPS); - if (clen == 0) - clen = 1; - pzargs[cargs] = zbufalc (clen + 1); - memcpy (pzargs[cargs], zarg, clen); - pzargs[cargs][clen] = '\0'; - ++cargs; - zarg += clen; - } - } - } - - /* Now look through the arguments to see if we are going to need the - current working directory. We don't try to make a precise - determination, just a conservative one. The basic idea is that - we don't want to get the cwd for 'foo!rmail - user' (note that we - don't examine the command itself). */ - fgetcwd = FALSE; - for (i = 0; i < cargs; i++) - { - if (pzargs[i][0] == '(') - continue; - zexclam = strrchr (pzargs[i], '!'); - if (zexclam != NULL && fsysdep_needs_cwd (zexclam + 1)) - { - fgetcwd = TRUE; - break; - } - if ((pzargs[i][0] == '<' || pzargs[i][0] == '>') - && i + 1 < cargs - && strchr (pzargs[i + 1], '!') == NULL - && fsysdep_needs_cwd (pzargs[i + 1])) - { - fgetcwd = TRUE; - break; - } - } - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (puuconf, INIT_SUID | (fgetcwd ? INIT_GETCWD : 0)); - - ulog_fatal_fn (uxabort); - - zuser = zsysdep_login_name (); - - /* Get the local system name. */ - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - exit (EXIT_FAILURE); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - /* Get the local system information. */ - iuuconf = uuconf_system_info (puuconf, zlocalname, &slocalsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - iuuconf = uuconf_system_local (puuconf, &slocalsys); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - slocalsys.uuconf_zname = (char *) zlocalname; - } - - /* Figure out which system the command is to be executed on. */ - zcmd = zremove_local_sys (&slocalsys, zcmd); - zexclam = strchr (zcmd, '!'); - if (zexclam == NULL) - { - zsys = zlocalname; - fXxqtlocal = TRUE; - zforward = NULL; - } - else - { - *zexclam = '\0'; - zsys = zcmd; - zcmd = zexclam + 1; - fXxqtlocal = FALSE; - - /* See if we must forward this command through other systems - (e.g. uux a!b!cmd). */ - zexclam = strrchr (zcmd, '!'); - if (zexclam == NULL) - zforward = NULL; - else - { - clen = zexclam - zcmd; - zforward = zbufalc (clen); - memcpy (zforward, zcmd, clen); - zforward[clen] = '\0'; - zcmd = zexclam + 1; - } - } - - if (fXxqtlocal) - sXxqtsys = slocalsys; - else - { - iuuconf = uuconf_system_info (puuconf, zsys, &sXxqtsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (! funknown_system (puuconf, zsys, &sXxqtsys)) - ulog (LOG_FATAL, "%s: System not found", zsys); - } - } - - /* Get the local name the remote system know us as. */ - zXxqtloc = sXxqtsys.uuconf_zlocalname; - if (zXxqtloc == NULL) - zXxqtloc = zlocalname; - - /* Look through the arguments. Any argument containing an - exclamation point character is interpreted as a file name, and is - sent to the appropriate system. */ - zinput_from = NULL; - zinput_to = NULL; - zinput_temp = NULL; - finputcopied = FALSE; - zcall_system = NULL; - fcall_any = FALSE; - - for (i = 0; i < cargs; i++) - { - const char *zsystem; - char *zfile; - char *zforw; - boolean finput, foutput; - boolean flocal, fonxqt; - - /* Check for a parenthesized argument; remove the parentheses - and otherwise ignore it (this is how an exclamation point is - quoted). */ - if (pzargs[i][0] == '(') - { - clen = strlen (pzargs[i]); - if (pzargs[i][clen - 1] != ')') - ulog (LOG_ERROR, "Mismatched parentheses"); - else - pzargs[i][clen - 1] = '\0'; - ++pzargs[i]; - continue; - } - - /* Check whether we are doing a redirection. */ - finput = FALSE; - foutput = FALSE; - if (i + 1 < cargs) - { - if (pzargs[i][0] == '<') - finput = TRUE; - else if (pzargs[i][0] == '>') - foutput = TRUE; - if (finput || foutput) - { - pzargs[i] = NULL; - i++; - } - } - - zexclam = strchr (pzargs[i], '!'); - - /* If there is no exclamation point and no redirection, this - argument is left untouched. */ - if (zexclam == NULL && ! finput && ! foutput) - continue; - - if (zexclam != NULL) - { - pzargs[i] = zremove_local_sys (&slocalsys, pzargs[i]); - zexclam = strchr (pzargs[i], '!'); - } - - /* Get the system name and file name for this file. */ - if (zexclam == NULL) - { - zsystem = zlocalname; - zfile = pzargs[i]; - flocal = TRUE; - zforw = NULL; - } - else - { - *zexclam = '\0'; - zsystem = pzargs[i]; - zfile = zexclam + 1; - flocal = FALSE; - zexclam = strrchr (zfile, '!'); - if (zexclam == NULL) - zforw = NULL; - else - { - *zexclam = '\0'; - zforw = zfile; - zfile = zexclam + 1; - } - } - - /* Check if the file is already on the execution system. */ - if (flocal) - fonxqt = fXxqtlocal; - else if (fXxqtlocal) - fonxqt = FALSE; - else if (zforward == NULL ? zforw != NULL : zforw == NULL) - fonxqt = FALSE; - else if (zforward != NULL - && zforw != NULL - && strcmp (zforward, zforw) != 0) - fonxqt = FALSE; - else if (strcmp (zsystem, sXxqtsys.uuconf_zname) == 0) - fonxqt = TRUE; - else if (sXxqtsys.uuconf_pzalias == NULL) - fonxqt = FALSE; - else - { - char **pzal; - - fonxqt = FALSE; - for (pzal = sXxqtsys.uuconf_pzalias; *pzal != NULL; pzal++) - { - if (strcmp (zsystem, *pzal) == 0) - { - fonxqt = TRUE; - break; - } - } - } - - /* Turn the file into an absolute path. */ - if (flocal) - zfile = zsysdep_local_file_cwd (zfile, sXxqtsys.uuconf_zpubdir, - (boolean *) NULL); - else if (fexpand) - zfile = zsysdep_add_cwd (zfile); - if (zfile == NULL) - uxabort (); - - /* Check for output redirection. */ - if (foutput) - { - if (flocal) - { - if (! fin_directory_list (zfile, - sXxqtsys.uuconf_pzremote_receive, - sXxqtsys.uuconf_zpubdir, TRUE, - FALSE, (const char *) NULL)) - ulog (LOG_FATAL, "Not permitted to create %s", zfile); - } - - /* There are various cases of output redirection. - - uux cmd >out: The command is executed on the local - system, and the output file is placed on the local - system (fonxqt is TRUE). - - uux cmd >a!out: The command is executed on the local - system, and the output file is sent to a. - - uux a!cmd >out: The command is executed on a, and the - output file is returned to the local system (flocal - is TRUE). - - uux a!cmd >a!out: The command is executed on a, and the - output file is left on a (fonxqt is TRUE). - - uux a!cmd >b!out: The command is executed on a, and the - output file is sent to b; traditionally, I believe - that b is relative to a, rather than to the local - system. However, this essentially contradicts the - previous two cases, in which the output file is - relative to the local system. - - Now, the cases that we don't handle. - - uux cmd >a!b!out: The command is executed on the local - system, and the output file is sent to b via a. This - requires the local uuxqt to support forwarding of the - output file. - - uux a!b!cmd >out: The command is executed on b, which is - reached via a. Probably the output file is intended - for the local system, in which case the uuxqt on b - must support forwarding of the output file. - - uux a!b!cmd >c!out: Is c relative to b or to the local - system? If it's relative to b this is easy to - handle. Otherwise, we must arrange for the file to - be sent back to the local system and for the local - system to send it on to c. - - There are many variations of the last case. It's not at - all clear to me how they should be handled. */ - if (zforward != NULL || zforw != NULL) - ulog (LOG_FATAL, "May not forward standard output"); - - if (fonxqt) - uxadd_xqt_line ('O', zfile, (const char *) NULL); - else if (flocal) - uxadd_xqt_line ('O', zfile, zXxqtloc); - else - uxadd_xqt_line ('O', zfile, zsystem); - pzargs[i] = NULL; - continue; - } - - if (finput) - { - if (fread_stdin) - ulog (LOG_FATAL, "Standard input specified twice"); - pzargs[i] = NULL; - } - - if (flocal) - { - char *zuse; - char *zdata; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - - /* It's a local file. If requested by -C, copy the file to - the spool directory. If requested by -l, link the file - to the spool directory; if the link fails, we copy the - file, unless -c was explictly used. If the execution is - occurring on the local system, we force the copy as well, - because otherwise we would have to have some way to tell - uuxqt not to move the file. If the file is being shipped - to another system, we must set up a transfer request. - First make sure the user has legitimate access, since we - are running setuid. */ - if (! fsysdep_access (zfile)) - uxabort (); - - zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, FALSE, - abtname, abdname, (char *) NULL); - if (zdata == NULL) - uxabort (); - - if (fcopy || flink || fXxqtlocal) - { - boolean fdid; - - uxrecord_file (zdata); - - fdid = FALSE; - if (flink) - { - boolean fworked; - - if (! fsysdep_link (zfile, zdata, &fworked)) - uxabort (); - - if (fworked) - fdid = TRUE; - else if (fdontcopy) - ulog (LOG_FATAL, "%s: Can't link to spool directory", - zfile); - } - - if (! fdid) - { - openfile_t efile; - - efile = esysdep_user_fopen (zfile, TRUE, TRUE); - if (! ffileisopen (efile)) - uxabort (); - if (! fcopy_open_file (efile, zdata, FALSE, TRUE, TRUE)) - uxabort (); - (void) ffileclose (efile); - } - - zuse = abtname; - } - else - { - /* We don't actually use the spool file name, but we - need a name to use as the destination. */ - ubuffree (zdata); - /* Make sure the daemon can access the file. */ - if (! fsysdep_daemon_access (zfile)) - uxabort (); - if (! fin_directory_list (zfile, sXxqtsys.uuconf_pzlocal_send, - sXxqtsys.uuconf_zpubdir, TRUE, - TRUE, zuser)) - ulog (LOG_FATAL, "Not permitted to send from %s", - zfile); - - zuse = zfile; - } - - if (fXxqtlocal) - { - if (finput) - uxadd_xqt_line ('I', zuse, (char *) NULL); - else - pzargs[i] = zuse; - } - else - { - finputcopied = fcopy || flink; - - if (finput) - { - zinput_from = zuse; - zinput_to = zbufcpy (abdname); - zinput_temp = zbufcpy (abtname); - } - else - { - char *zbase; - - uxadd_send_file (zuse, abdname, - finputcopied ? "C" : "c", - abtname, zforward); - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - uxabort (); - uxadd_xqt_line ('F', abdname, zbase); - pzargs[i] = zbase; - } - } - } - else if (fonxqt) - { - /* The file is already on the system where the command is to - be executed. */ - if (finput) - uxadd_xqt_line ('I', zfile, (const char *) NULL); - else - pzargs[i] = zfile; - } - else - { - struct uuconf_system sfromsys; - char abtname[CFILE_NAME_LEN]; - struct scmd s; - char *zjobid; - - /* We need to request a remote file. */ - iuuconf = uuconf_system_info (puuconf, zsystem, &sfromsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (! funknown_system (puuconf, zsystem, &sfromsys)) - ulog (LOG_FATAL, "%s: System not found", zsystem); - } - - if (fonxqt) - { - /* The file is already on the system where the command is to - be executed. */ - if (finput) - uxadd_xqt_line ('I', zfile, (const char *) NULL); - else - pzargs[i] = zfile; - } - else - { - char *zdata; - - if (! sfromsys.uuconf_fcall_transfer - && ! sfromsys.uuconf_fcalled_transfer) - ulog (LOG_FATAL, - "Not permitted to transfer files to or from %s", - sfromsys.uuconf_zname); - - if (zforw != NULL) - { - /* This is ``uux cmd a!b!file''. To make this work, - we would have to be able to set up a request to a - to fetch file from b and send it to us. But it - turns out that that will not work, because when a - sends us the file we will put it in a's spool - directory, not the local system spool directory. - So we won't have any way to find it. This is not - a conceptual problem, and it could doubtless be - solved. Please feel free to solve it and send me - the solution. */ - ulog (LOG_FATAL, "File forwarding not supported"); - } - - /* We must request the file from the remote system to - this one. */ - zdata = zsysdep_data_file_name (&slocalsys, zXxqtloc, bXgrade, - FALSE, abtname, (char *) NULL, - (char *) NULL); - if (zdata == NULL) - uxabort (); - ubuffree (zdata); - - /* Request the file. The special option '9' is a signal - to uucico that it's OK to receive a file into the - spool directory; normally such requests are rejected. - This privilege is easy to abuse. */ - s.bcmd = 'R'; - s.bgrade = bXgrade; - s.pseq = NULL; - s.zfrom = zfile; - s.zto = zbufcpy (abtname); - s.zuser = zuser; - s.zoptions = "9"; - s.ztemp = ""; - s.imode = 0600; - s.znotify = ""; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - zjobid = zsysdep_spool_commands (&sfromsys, bXgrade, 1, &s); - if (zjobid == NULL) - uxabort (); - - if (fjobid) - printf ("%s\n", zjobid); - - ubuffree (zjobid); - - if (fcall_any) - { - ubuffree (zcall_system); - zcall_system = NULL; - } - else - { - fcall_any = TRUE; - zcall_system = zbufcpy (sfromsys.uuconf_zname); - } - - if (fXxqtlocal) - { - /* Tell the command execution to wait until the file - has been received, and tell it the real file - name. */ - if (finput) - { - uxadd_xqt_line ('F', abtname, (char *) NULL); - uxadd_xqt_line ('I', abtname, (char *) NULL); - } - else - { - char *zbase; - - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - uxabort (); - uxadd_xqt_line ('F', abtname, zbase); - pzargs[i] = zbase; - } - } - else - { - char abxtname[CFILE_NAME_LEN]; - char *zbase; - char *zxqt; - FILE *e; - - /* Now we must arrange to forward the file on to the - execution system. We need to get a name to give - the file on the execution system (abxtname). */ - zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, - bXgrade, TRUE, abxtname, - (char *) NULL, - (char *) NULL); - if (zdata == NULL) - uxabort (); - ubuffree (zdata); - - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - uxabort (); - - zxqt = zsysdep_xqt_file_name (); - if (zxqt == NULL) - uxabort (); - e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE); - if (e == NULL) - uxabort (); - uxrecord_file (zxqt); - - fprintf (e, "U %s %s\n", zsysdep_login_name (), - zlocalname); - fprintf (e, "F %s %s\n", abtname, zbase); - fprintf (e, "C uucp -C -W -d -g %c %s %s!", bXgrade, - zbase, sXxqtsys.uuconf_zname); - if (zforward != NULL) - fprintf (e, "%s!", zforward); - fprintf (e, "%s\n", abxtname); - - if (! fstdiosync (e, zxqt)) - ulog (LOG_FATAL, "fsync failed"); - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - if (finput) - { - uxadd_xqt_line ('F', abxtname, (char *) NULL); - uxadd_xqt_line ('I', abxtname, (char *) NULL); - ubuffree (zbase); - } - else - { - uxadd_xqt_line ('F', abxtname, zbase); - pzargs[i] = zbase; - } - } - } - - (void) uuconf_system_free (puuconf, &sfromsys); - } - } - - /* If standard input is to be read from the stdin of uux, we read it - here into a temporary file and send it to the execute system. */ - if (fread_stdin) - { - char *zdata; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - FILE *e; - - zdata = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, FALSE, - abtname, abdname, (char *) NULL); - if (zdata == NULL) - uxabort (); - - e = esysdep_fopen (zdata, FALSE, FALSE, TRUE); - if (e == NULL) - uxabort (); - - eXclose = e; - uxrecord_file (zdata); - - uxcopy_stdin (e); - - if (! fstdiosync (e, zdata)) - ulog (LOG_FATAL, "fsync failed"); - eXclose = NULL; - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - if (fXxqtlocal) - uxadd_xqt_line ('I', abtname, (const char *) NULL); - else - { - zinput_from = zbufcpy (abtname); - zinput_to = zbufcpy (abdname); - zinput_temp = zinput_from; - finputcopied = TRUE; - } - } - - /* If we are returning standard input, or we're putting the status - in a file, we can't use an E command. */ - if (fretstdin) - uxadd_xqt_line ('B', (const char *) NULL, (const char *) NULL); - - if (zstatus_file != NULL) - uxadd_xqt_line ('M', zstatus_file, (const char *) NULL); - - /* Get the complete command line, and decide whether the command - needs to be executed by the shell. */ - fneedshell = FALSE; - - if (zcmd[strcspn (zcmd, ZSHELLCHARS)] != '\0') - fneedshell = TRUE; - - clen = strlen (zcmd) + 1; - for (i = 0; i < cargs; i++) - { - if (pzargs[i] != NULL) - { - clen += strlen (pzargs[i]) + 1; - if (pzargs[i][strcspn (pzargs[i], ZSHELLCHARS)] != '\0') - fneedshell = TRUE; - } - } - - zfullcmd = zbufalc (clen); - - strcpy (zfullcmd, zcmd); - for (i = 0; i < cargs; i++) - { - if (pzargs[i] != NULL) - { - strcat (zfullcmd, " "); - strcat (zfullcmd, pzargs[i]); - } - } - - fpoll = FALSE; - - /* If we haven't written anything to the execution file yet, and we - have a standard input file, and we're not forwarding, then every - other option can be handled in an E command. */ - if (eXxqt_file == NULL && zinput_from != NULL && zforward == NULL) - { - struct scmd s; - char *zoptions; - - /* Set up an E command. */ - s.bcmd = 'E'; - s.bgrade = bXgrade; - s.pseq = NULL; - s.zuser = zuser; - s.zfrom = zinput_from; - s.zto = zinput_to; - s.zoptions = aboptions; - zoptions = aboptions; - *zoptions++ = finputcopied ? 'C' : 'c'; - if (fno_ack) - *zoptions++ = 'N'; - if (ferror_ack) - *zoptions++ = 'Z'; - if (zrequestor != NULL) - *zoptions++ = 'R'; - if (fneedshell) - *zoptions++ = 'e'; - *zoptions = '\0'; - s.ztemp = zinput_temp; - s.imode = 0666; - if (zrequestor == NULL) - zrequestor = "\"\""; - s.znotify = zrequestor; - s.cbytes = -1; - s.zcmd = zfullcmd; - s.ipos = 0; - - ++cXcmds; - pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds, - cXcmds * sizeof (struct scmd)); - pasXcmds[cXcmds - 1] = s; - - uxadd_name (zinput_from); - } - else if (*zfullcmd == '\0' - && eXxqt_file == NULL - && zinput_from == NULL - && cXcmds == 0) - { - /* As a special case, if we are asked to execute an empty - command, we create a poll file instead. */ - fpoll = TRUE; - } - else - { - /* Finish up the execute file. */ - uxadd_xqt_line ('U', zuser, zXxqtloc); - if (zinput_from != NULL) - { - uxadd_xqt_line ('F', zinput_to, (char *) NULL); - uxadd_xqt_line ('I', zinput_to, (char *) NULL); - uxadd_send_file (zinput_from, zinput_to, - finputcopied ? "C" : "c", - zinput_temp, zforward); - } - if (fno_ack) - uxadd_xqt_line ('N', (const char *) NULL, (const char *) NULL); - if (ferror_ack) - uxadd_xqt_line ('Z', (const char *) NULL, (const char *) NULL); - if (zrequestor != NULL) - uxadd_xqt_line ('R', zrequestor, (const char *) NULL); - if (fneedshell) - uxadd_xqt_line ('e', (const char *) NULL, (const char *) NULL); - uxadd_xqt_line ('C', zfullcmd, (const char *) NULL); - if (! fstdiosync (eXxqt_file, "execution file")) - ulog (LOG_FATAL, "fsync failed"); - if (fclose (eXxqt_file) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - eXxqt_file = NULL; - - /* If the execution is to occur on another system, we must now - arrange to copy the execute file to this system. */ - if (! fXxqtlocal) - uxadd_send_file (abXxqt_tname, abXxqt_xname, "C", abXxqt_tname, - zforward); - } - - /* If we got a signal, get out before spooling anything. */ - if (FGOT_SIGNAL ()) - uxabort (); - - /* From here on in, it's too late. We don't call uxabort. */ - if (cXcmds > 0 || fpoll) - { - char *zjobid; - - if (! fpoll - && ! sXxqtsys.uuconf_fcall_transfer - && ! sXxqtsys.uuconf_fcalled_transfer) - ulog (LOG_FATAL, "Not permitted to transfer files to or from %s", - sXxqtsys.uuconf_zname); - - zjobid = zsysdep_spool_commands (&sXxqtsys, bXgrade, cXcmds, pasXcmds); - if (zjobid == NULL) - { - ulog_close (); - usysdep_exit (FALSE); - } - - if (fjobid) - printf ("%s\n", zjobid); - - ubuffree (zjobid); - - if (fcall_any) - { - ubuffree (zcall_system); - zcall_system = NULL; - } - else - { - fcall_any = TRUE; - zcall_system = zbufcpy (sXxqtsys.uuconf_zname); - } - } - - if (! fpoll) - { - /* If all that worked, make a log file entry. All log file - reports up to this point went to stderr. */ - ulog_to_file (puuconf, TRUE); - ulog_system (sXxqtsys.uuconf_zname); - ulog_user (zuser); - - if (zXnames == NULL) - ulog (LOG_NORMAL, "Queuing %s", zfullcmd); - else - ulog (LOG_NORMAL, "Queuing %s (%s)", zfullcmd, zXnames); - - ulog_close (); - } - - if (! fuucico - || (zcall_system == NULL && ! fcall_any)) - { - if (! fXxqtlocal || ! fuucico) - fexit = TRUE; - else - { - char *zconfigarg; - - if (zconfig == NULL) - zconfigarg = NULL; - else - { - zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig)); - sprintf (zconfigarg, "-I%s", zconfig); - } - - fexit = fsysdep_run (FALSE, "uuxqt", zconfigarg, - (const char *) NULL); - } - } - else - { - const char *zcicoarg; - char *zconfigarg; - - if (zcall_system == NULL) - zcicoarg = "-r1"; - else - { - char *z; - - z = zbufalc (sizeof "-Cs" + strlen (zcall_system)); - sprintf (z, "-Cs%s", zcall_system); - zcicoarg = z; - } - - if (zconfig == NULL) - zconfigarg = NULL; - else - { - zconfigarg = zbufalc (sizeof "-I" + strlen (zconfig)); - sprintf (zconfigarg, "-I%s", zconfig); - } - - fexit = fsysdep_run (FALSE, "uucico", zcicoarg, zconfigarg); - } - - usysdep_exit (fexit); - - /* Avoid error about not returning a value. */ - return 0; -} - -/* Report command usage. */ - -static void -uxhelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [options] [-] command\n", zProgram); - printf (" -,-p,--stdin: Read standard input for standard input of command\n"); - printf (" -c,--nocopy: Do not copy local files to spool directory (default)\n"); - printf (" -C,--copy: Copy local files to spool directory\n"); - printf (" -l,--link: link local files to spool directory\n"); - printf (" -g,--grade grade: Set job grade (must be alphabetic)\n"); - printf (" -n,--notification=no: Do not report completion status\n"); - printf (" -z,--notification=error: Report completion status only on error\n"); - printf (" -r,--nouucico: Do not start uucico daemon\n"); - printf (" -a,--requestor address: Address to mail status report to\n"); - printf (" -b,--return-stdin: Return standard input with status report\n"); - printf (" -s,--status file: Report completion status to file\n"); - printf (" -j,--jobid: Report job id\n"); - printf (" -x,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} - -static void -uxusage () -{ - fprintf (stderr, - "Usage: %s [options] [-] command\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* Add a line to the execute file. */ - -static void -uxadd_xqt_line (bchar, z1, z2) - int bchar; - const char *z1; - const char *z2; -{ - if (eXxqt_file == NULL) - { - const char *zxqt_name; - - if (fXxqtlocal) - zxqt_name = zsysdep_xqt_file_name (); - else - zxqt_name = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, TRUE, - abXxqt_tname, (char *) NULL, - abXxqt_xname); - if (zxqt_name == NULL) - uxabort (); - - uxrecord_file (zxqt_name); - - eXxqt_file = esysdep_fopen (zxqt_name, FALSE, FALSE, TRUE); - if (eXxqt_file == NULL) - uxabort (); - } - - if (z1 == NULL) - fprintf (eXxqt_file, "%c\n", bchar); - else if (z2 == NULL) - fprintf (eXxqt_file, "%c %s\n", bchar, z1); - else - fprintf (eXxqt_file, "%c %s %s\n", bchar, z1, z2); -} - -/* Add a file to be sent to the execute system. */ - -static void -uxadd_send_file (zfrom, zto, zoptions, ztemp, zforward) - const char *zfrom; - const char *zto; - const char *zoptions; - const char *ztemp; - const char *zforward; -{ - struct scmd s; - - if (zforward != NULL) - { - char *zbase; - char *zxqt; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - char abxname[CFILE_NAME_LEN]; - FILE *e; - - /* We want to forward this file through the first execution - system to other systems. We set up a remote execution of - uucp to forward the file. */ - zbase = zsysdep_base_name (zfrom); - if (zbase == NULL) - uxabort (); - - zxqt = zsysdep_data_file_name (&sXxqtsys, zXxqtloc, bXgrade, TRUE, - abtname, abdname, abxname); - if (zxqt == NULL) - uxabort (); - e = esysdep_fopen (zxqt, FALSE, FALSE, TRUE); - if (e == NULL) - uxabort (); - uxrecord_file (zxqt); - - fprintf (e, "U %s %s\n", zsysdep_login_name (), zXxqtloc); - fprintf (e, "F %s %s\n", abdname, zbase); - fprintf (e, "C uucp -C -W -d -g %c %s %s!%s\n", - bXgrade, zbase, zforward, zto); - - ubuffree (zbase); - - if (! fstdiosync (e, zxqt)) - ulog (LOG_FATAL, "fsync failed"); - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - /* Send the execution file. */ - s.bcmd = 'S'; - s.bgrade = bXgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (abtname); - s.zto = zbufcpy (abxname); - s.zuser = zsysdep_login_name (); - s.zoptions = "C"; - s.ztemp = s.zfrom; - s.imode = 0666; - s.znotify = NULL; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ++cXcmds; - pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds, - cXcmds * sizeof (struct scmd)); - pasXcmds[cXcmds - 1] = s; - - uxadd_name (abtname); - - /* Send the data file to abdname where the execution file will - expect it. */ - zto = abdname; - } - - s.bcmd = 'S'; - s.bgrade = bXgrade; - s.pseq = NULL; - s.zfrom = zbufcpy (zfrom); - s.zto = zbufcpy (zto); - s.zuser = zsysdep_login_name (); - s.zoptions = zbufcpy (zoptions); - s.ztemp = zbufcpy (ztemp); - s.imode = 0666; - s.znotify = ""; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ++cXcmds; - pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds, - cXcmds * sizeof (struct scmd)); - pasXcmds[cXcmds - 1] = s; - - uxadd_name (zfrom); -} - -/* Copy stdin to a file. This is a separate function because it may - call setjmp. */ - -static void -uxcopy_stdin (e) - FILE *e; -{ - CATCH_PROTECT size_t cread; - char ab[1024]; - - do - { - size_t cwrite; - - /* I want to use fread here, but there is a bug in some versions - of SVR4 which causes fread to return less than a complete - buffer even if EOF has not been reached. This is not online - time, so speed is not critical, but it's still quite annoying - to have to use an inefficient algorithm. */ - cread = 0; - if (fsysdep_catch ()) - { - usysdep_start_catch (); - - while (cread < sizeof (ab)) - { - int b; - - if (FGOT_SIGNAL ()) - uxabort (); - - /* There's an unimportant race here. If the user hits - ^C between the FGOT_SIGNAL we just did and the time - we enter getchar, we won't know about the signal - (unless we're doing a longjmp, but we normally - aren't). It's not a big problem, because the user - can just hit ^C again. */ - b = getchar (); - if (b == EOF) - break; - ab[cread] = b; - ++cread; - } - } - - usysdep_end_catch (); - - if (FGOT_SIGNAL ()) - uxabort (); - - if (cread > 0) - { - cwrite = fwrite (ab, sizeof (char), cread, e); - if (cwrite != cread) - ulog (LOG_FATAL, "fwrite: Wrote %d when attempted %d", - (int) cwrite, (int) cread); - } - } - while (cread == sizeof ab); -} - -/* Keep track of all files we have created so that we can delete them - if we get a signal. The argument will be on the heap. */ - -static int cXfiles; -static const char **pXaz; - -static void -uxrecord_file (zfile) - const char *zfile; -{ - pXaz = (const char **) xrealloc ((pointer) pXaz, - (cXfiles + 1) * sizeof (const char *)); - pXaz[cXfiles] = zfile; - ++cXfiles; -} - -/* Delete all the files we have recorded and exit. */ - -static void -uxabort () -{ - int i; - - if (eXxqt_file != NULL) - (void) fclose (eXxqt_file); - if (eXclose != NULL) - (void) fclose (eXclose); - for (i = 0; i < cXfiles; i++) - (void) remove (pXaz[i]); - ulog_close (); - usysdep_exit (FALSE); -} - -/* Add a name to the list of file names we are going to log. We log - all the file names which will appear in the uucico log file. This - permits people to associate the file send in the uucico log with - the uux entry which created the file. Normally only one file name - will appear. */ - -static void -uxadd_name (z) - const char *z; -{ - if (zXnames == NULL) - zXnames = zbufcpy (z); - else - { - size_t cold, cadd; - char *znew; - - cold = strlen (zXnames); - cadd = strlen (z); - znew = zbufalc (cold + 2 + cadd); - memcpy (znew, zXnames, cold); - znew[cold] = ' '; - memcpy (znew + cold + 1, z, cadd + 1); - ubuffree (zXnames); - zXnames = znew; - } -} diff --git a/gnu/libexec/uucp/uuxqt/Makefile b/gnu/libexec/uucp/uuxqt/Makefile deleted file mode 100644 index d1dafe7..0000000 --- a/gnu/libexec/uucp/uuxqt/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Makefile for uuxqt -# $FreeBSD$ - -BINDIR= $(libxdir) -BINOWN= $(owner) -BINGRP= $(group) -BINMODE= 6550 - -PROG= uuxqt -SRCS= uuxqt.c util.c log.c copy.c -LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP) -CFLAGS+= -I$(.CURDIR)/../common_sources\ - -DVERSION=\"$(VERSION)\" -DOWNER=\"$(owner)\" - -MAN= uuxqt.8 - -.include <bsd.prog.mk> -.PATH: $(.CURDIR)/../common_sources diff --git a/gnu/libexec/uucp/uuxqt/uuxqt.8 b/gnu/libexec/uucp/uuxqt/uuxqt.8 deleted file mode 100644 index 68e2e8f..0000000 --- a/gnu/libexec/uucp/uuxqt/uuxqt.8 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $Id: uuxqt.8,v 1.8 1995/06/26 22:38:55 ian Rel $ -.\" $FreeBSD$ -.TH uuxqt 8 "Taylor UUCP 1.06" -.SH NAME -uuxqt \- UUCP execution daemon -.SH SYNOPSIS -.B uuxqt -[ options ] -.SH DESCRIPTION -The -.I uuxqt -daemon executes commands requested by -.I uux -(1) from either the local system or from remote systems. -It is started automatically by the -.I uucico -(8) daemon (unless -.I uucico -(8) is given the -.B \-q -or -.B \-\-nouuxqt -option). - -There is normally no need to run this command, since it will be -invoked by -.I uucico -(8). However, it can be used to provide greater control over the -processing of the work queue. - -Multiple invocations of -.I uuxqt -may be run at once, as controlled by the -.I max-uuxqts -configuration command. -.SH OPTIONS -The following options may be given to -.I uuxqt. -.TP 5 -.B \-c command, \-\-command command -Only execute requests for the specified command. For example: -.br -.in +0.5i -.nf -uuxqt --command rmail -.fi -.in -0.5i -.TP 5 -.B \-s system, \-\-system system -Only execute requests originating from the specified system. -.TP 5 -.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, config, -spooldir and execute are meaningful for -.I uuxqt. - -Multiple types may be given, separated by commas, and the -.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 \-\-debug 2 -is equivalent to -.B \-\-debug abnormal,chat. - -The debugging output is sent to the debugging file, usually one of -/var/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or -/usr/spool/uucp/.Admin/audit.local. -.TP 5 -.B \-I file, \-\-config -Set configuration file to use. This option may not be available, -depending upon how -.I uuxqt -was compiled. -.TP 5 -.B \-v, \-\-version -Report version information and exit. -.TP 5 -.B \-\-help -Print a help message and exit. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/etc/uucp/config - Configuration file. -.br -/var/spool/uucp - -UUCP spool directory. -.br -/var/spool/uucp/Log - -UUCP log file. -.br -/var/spool/uucppublic - -Default UUCP public directory. -.br -/var/spool/uucp/Debug - -Debugging file. -.SH SEE ALSO -uucp(1), uux(1), uucico(8) -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com) diff --git a/gnu/libexec/uucp/uuxqt/uuxqt.c b/gnu/libexec/uucp/uuxqt/uuxqt.c deleted file mode 100644 index 31bcee2..0000000 --- a/gnu/libexec/uucp/uuxqt/uuxqt.c +++ /dev/null @@ -1,1766 +0,0 @@ -/* uuxqt.c - Run uux commands. - - Copyright (C) 1991, 1992, 1993, 1994, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. - */ - -#include "uucp.h" - -#if USE_RCS_ID -const char uuxqt_rcsid[] = "$FreeBSD$"; -#endif - -#include <errno.h> -#include <ctype.h> - -#include "getopt.h" - -#include "uudefs.h" -#include "uuconf.h" -#include "system.h" - -/* Static variables used to unlock things if we get a fatal error. */ -static int iQlock_seq = -1; -static const char *zQunlock_cmd; -static const char *zQunlock_file; -static boolean fQunlock_directory; -int cQmaxuuxqts; - -/* Static variables to free in uqcleanup. */ -static char *zQoutput; -static char *zQmail; - -/* Local functions. */ -static void uqusage P((void)); -static void uqhelp P((void)); -static void uqabort P((void)); -static void uqdo_xqt_file P((pointer puuconf, const char *zfile, - const char *zbase, - const struct uuconf_system *qsys, - const char *zlocalname, - const char *zcmd, boolean *pfprocessed)); -static void uqcleanup P((const char *zfile, int iflags)); -static int isave_files P((const struct uuconf_system *, const char *zmail, - const char *zfile, int iclean)); -static boolean fqforward P((const char *zfile, char **pzallowed, - const char *zlog, const char *zmail)); - -/* Long getopt options. */ -static const struct option asQlongopts[] = -{ - { "command", required_argument, 0, 'c' }, - { "system", required_argument, 0, 's' }, - { "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) - int argc; - char **argv; -{ - /* The type of command to execute (NULL for any type). */ - const char *zcmd = NULL; - /* The configuration file name. */ - const char *zconfig = NULL; - /* The system to execute commands for. */ - const char *zdosys = NULL; - int iopt; - pointer puuconf; - int iuuconf; - const char *zlocalname; - boolean fany; - char *z, *zgetsys; - boolean ferr; - boolean fsys; - struct uuconf_system ssys; - - zProgram = argv[0]; - - while ((iopt = getopt_long (argc, argv, "c:I:s:vx:", asQlongopts, - (int *) NULL)) != EOF) - { - switch (iopt) - { - case 'c': - /* Set the type of command to execute. */ - zcmd = optarg; - break; - - case 'I': - /* Set the configuration file name. */ - if (fsysdep_other_config (optarg)) - zconfig = optarg; - break; - - case 's': - zdosys = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set the debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'v': - /* Print version and exit. */ - printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - zProgram, VERSION); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 1: - /* --help. */ - uqhelp (); - exit (EXIT_SUCCESS); - /*NOTREACHED*/ - - case 0: - /* Long option found and flag set. */ - break; - - default: - uqusage (); - break; - } - } - - if (optind != argc) - uqusage (); - - iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#if DEBUG > 1 - { - const char *zdebug; - - iuuconf = uuconf_debuglevel (puuconf, &zdebug); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - if (zdebug != NULL) - iDebug |= idebug_parse (zdebug); - } -#endif - - iuuconf = uuconf_maxuuxqts (puuconf, &cQmaxuuxqts); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (puuconf, INIT_SUID); - - ulog_to_file (puuconf, TRUE); - ulog_fatal_fn (uqabort); - - iuuconf = uuconf_localname (puuconf, &zlocalname); - if (iuuconf == UUCONF_NOT_FOUND) - { - zlocalname = zsysdep_localname (); - if (zlocalname == NULL) - exit (EXIT_FAILURE); - } - else if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - fsys = FALSE; - - /* If we were given a system name, canonicalize it. */ - if (zdosys != NULL) - { - iuuconf = uuconf_system_info (puuconf, zdosys, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - - if (strcmp (zdosys, zlocalname) == 0) - { - iuuconf = uuconf_system_local (puuconf, &ssys); - if (iuuconf != UUCONF_SUCCESS) - ulog_uuconf (LOG_FATAL, puuconf, iuuconf); - ssys.uuconf_zname = (char *) zlocalname; - } - else - { - if (! funknown_system (puuconf, zdosys, &ssys)) - ulog (LOG_FATAL, "%s: system not found", zdosys); - } - } - - zdosys = zbufcpy (ssys.uuconf_zname); - fsys = TRUE; - } - - /* Limit the number of uuxqt processes, and make sure we're the only - uuxqt daemon running for this command. */ - iQlock_seq = ixsysdep_lock_uuxqt (zcmd, cQmaxuuxqts); - if (iQlock_seq < 0) - { - ulog_close (); - usysdep_exit (TRUE); - } - zQunlock_cmd = zcmd; - - /* Keep scanning the execute files until we don't process any of - them. */ - do - { - fany = FALSE; - - /* Look for each execute file, and run it. */ - - if (! fsysdep_get_xqt_init (zdosys)) - { - ulog_close (); - usysdep_exit (FALSE); - } - - while ((z = zsysdep_get_xqt (zdosys, &zgetsys, &ferr)) != NULL) - { - const char *zloc; - boolean fprocessed; - char *zbase; - - /* Get the system information for the system returned by - zsysdep_get_xqt. */ - if (! fsys || strcmp (ssys.uuconf_zname, zgetsys) != 0) - { - if (fsys) - (void) uuconf_system_free (puuconf, &ssys); - - iuuconf = uuconf_system_info (puuconf, zgetsys, - &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (z); - ubuffree (zgetsys); - continue; - } - else if (strcmp (zgetsys, zlocalname) == 0) - { - iuuconf = uuconf_system_local (puuconf, &ssys); - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - ubuffree (z); - ubuffree (zgetsys); - continue; - } - ssys.uuconf_zname = (char *) zlocalname; - } - else - { - if (! funknown_system (puuconf, zgetsys, &ssys)) - { - ulog (LOG_ERROR, - "%s: Execute file for unknown system %s", - z, zgetsys); - (void) remove (z); - ubuffree (z); - ubuffree (zgetsys); - continue; - } - } - } - - fsys = TRUE; - } - - /* If we've received a signal, get out of the loop. */ - if (FGOT_SIGNAL ()) - { - ubuffree (z); - ubuffree (zgetsys); - break; - } - - /* Make sure we are supposed to be executing jobs for this - system. */ - if (zdosys != NULL && strcmp (zdosys, ssys.uuconf_zname) != 0) - { - ubuffree (z); - ubuffree (zgetsys); - continue; - } - - zloc = ssys.uuconf_zlocalname; - if (zloc == NULL) - zloc = zlocalname; - - ulog_system (ssys.uuconf_zname); - zbase = zsysdep_base_name (z); - uqdo_xqt_file (puuconf, z, zbase, &ssys, zloc, zcmd, &fprocessed); - ubuffree (zbase); - ulog_system ((const char *) NULL); - ulog_user ((const char *) NULL); - - if (fprocessed) - fany = TRUE; - ubuffree (z); - ubuffree (zgetsys); - } - - usysdep_get_xqt_free (zdosys); - } - while (fany && ! FGOT_SIGNAL ()); - - (void) fsysdep_unlock_uuxqt (iQlock_seq, zcmd, cQmaxuuxqts); - iQlock_seq = -1; - - ulog_close (); - - if (FGOT_SIGNAL ()) - ferr = TRUE; - - usysdep_exit (! ferr); - - /* Avoid errors about not returning a value. */ - return 0; -} - -static void -uqhelp () -{ - printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n", - VERSION); - printf ("Usage: %s [-c,--command cmd] [-s,--system system]\n", zProgram); - printf (" -c,--command cmd: Set type of command to execute\n"); - printf (" -s,--system system: Execute commands only for named system\n"); - printf (" -x,--debug debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - printf (" -I,--config file: Set configuration file to use\n"); -#endif /* HAVE_TAYLOR_CONFIG */ - printf (" -v,--version: Print version and exit\n"); - printf (" --help: Print help and exit\n"); -} - -static void -uqusage () -{ - fprintf (stderr, - "Usage: %s [-c,--command cmd] [-s,--system system]\n", zProgram); - fprintf (stderr, "Use %s --help for help\n", zProgram); - exit (EXIT_FAILURE); -} - -/* This is the abort function called when we get a fatal error. */ - -static void -uqabort () -{ -#if ! HAVE_HDB_LOGGING - /* When using HDB logging, it's a pain to have no system name. */ - ulog_system ((const char *) NULL); -#endif - - ulog_user ((const char *) NULL); - - if (fQunlock_directory) - (void) fsysdep_unlock_uuxqt_dir (iQlock_seq); - - if (zQunlock_file != NULL) - (void) fsysdep_unlock_uuxqt_file (zQunlock_file); - - if (iQlock_seq >= 0) - (void) fsysdep_unlock_uuxqt (iQlock_seq, zQunlock_cmd, cQmaxuuxqts); - - ulog_close (); - - usysdep_exit (FALSE); -} - -/* An execute file is a series of lines. The first character of each - line is a command. The following commands are defined: - - C command-line - I standard-input - O standard-output [ system ] - F required-file filename-to-use - R requestor-address - U user system - Z (acknowledge if command failed; default) - N (no acknowledgement on failure) - n (acknowledge if command succeeded) - B (return command input on error) - e (process with sh) - E (process with exec) - M status-file - # comment - - Unrecognized commands are ignored. We actually do not recognize - the Z command, since it requests default behaviour. We always send - mail on failure, unless the N command appears. We never send mail - on success, unless the n command appears. - - This code does not currently support the B or M commands. */ - -/* Command arguments. */ -static char **azQargs; -/* Command as a complete string. */ -static char *zQcmd; -/* Standard input file name. */ -static char *zQinput; -/* Standard output file name. */ -static char *zQoutfile; -/* Standard output system. */ -static char *zQoutsys; -/* Number of required files. */ -static int cQfiles; -/* Names of required files. */ -static char **azQfiles; -/* Names required files should be renamed to (NULL if original is OK). */ -static char **azQfiles_to; -/* Requestor address (this is where mail should be sent). */ -static char *zQrequestor; -/* User name. */ -static const char *zQuser; -/* System name. */ -static const char *zQsystem; -/* This is set by the N flag, meaning that no acknowledgement should - be mailed on failure. */ -static boolean fQno_ack; -/* This is set by the n flag, meaning that acknowledgement should be - mailed if the command succeeded. */ -static boolean fQsuccess_ack; -/* This is set by the B flag, meaning that command input should be - mailed to the requestor if an error occurred. */ -static boolean fQsend_input; -/* This is set by the E flag, meaning that exec should be used to - execute the command. */ -static boolean fQuse_exec; -/* The status should be copied to this file on the requesting host. */ -static const char *zQstatus_file; -#if ALLOW_SH_EXECUTION -/* This is set by the e flag, meaning that sh should be used to - execute the command. */ -static boolean fQuse_sh; -#endif /* ALLOW_SH_EXECUTION */ - -static int iqcmd P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int iqout P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int iqfile P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int iqrequestor P((pointer puuconf, int argc, char **argv, - pointer pvar, pointer pinfo)); -static int iquser P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); -static int iqset P((pointer puuconf, int argc, char **argv, pointer pvar, - pointer pinfo)); - -/* We are lax about the number of arguments the functions accept, - because there is a lot of variation in what other (buggy) UUCP - packages generate. Unused arguments are ignored. */ - -static const struct uuconf_cmdtab asQcmds[] = -{ - { "C", UUCONF_CMDTABTYPE_FN | 0, NULL, iqcmd }, - { "I", UUCONF_CMDTABTYPE_STRING, (pointer) &zQinput, NULL }, - { "O", UUCONF_CMDTABTYPE_FN | 0, NULL, iqout }, - { "F", UUCONF_CMDTABTYPE_FN | 0, NULL, iqfile }, - { "R", UUCONF_CMDTABTYPE_FN | 0, NULL, iqrequestor }, - { "U", UUCONF_CMDTABTYPE_FN | 0, NULL, iquser }, - { "N", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQno_ack, iqset }, - { "n", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQsuccess_ack, iqset }, - { "B", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQsend_input, iqset }, -#if ALLOW_SH_EXECUTION - { "e", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQuse_sh, iqset }, -#endif - { "E", UUCONF_CMDTABTYPE_FN | 0, (pointer) &fQuse_exec, iqset }, - { "M", UUCONF_CMDTABTYPE_STRING, (pointer) &zQstatus_file, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Handle the C command: store off the arguments. */ - -/*ARGSUSED*/ -static int -iqcmd (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - int i; - size_t clen; - - if (argc <= 1) - return UUCONF_CMDTABRET_CONTINUE; - - azQargs = (char **) xmalloc (argc * sizeof (char *)); - clen = 0; - for (i = 1; i < argc; i++) - { - azQargs[i - 1] = zbufcpy (argv[i]); - clen += strlen (argv[i]) + 1; - } - azQargs[i - 1] = NULL; - - zQcmd = (char *) xmalloc (clen); - zQcmd[0] = '\0'; - for (i = 1; i < argc - 1; i++) - { - strcat (zQcmd, argv[i]); - strcat (zQcmd, " "); - } - strcat (zQcmd, argv[i]); - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the O command, which may have one or two arguments. */ - -/*ARGSUSED*/ -static int -iqout (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - if (argc > 1) - zQoutfile = zbufcpy (argv[1]); - if (argc > 2) - zQoutsys = zbufcpy (argv[2]); - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the F command, which may have one or two arguments. */ - -/*ARGSUSED*/ -static int -iqfile (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - if (argc < 2) - return UUCONF_CMDTABRET_CONTINUE; - - /* If this file is not in the spool directory, just ignore it. */ - if (! fspool_file (argv[1])) - return UUCONF_CMDTABRET_CONTINUE; - - ++cQfiles; - azQfiles = (char **) xrealloc ((pointer) azQfiles, - cQfiles * sizeof (char *)); - azQfiles_to = (char **) xrealloc ((pointer) azQfiles_to, - cQfiles * sizeof (char *)); - - azQfiles[cQfiles - 1] = zbufcpy (argv[1]); - if (argc > 2) - azQfiles_to[cQfiles - 1] = zbufcpy (argv[2]); - else - azQfiles_to[cQfiles - 1] = NULL; - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the R command, which may have one or two arguments. */ - -/*ARGSUSED*/ -static int -iqrequestor (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - /* We normally have a single argument, which is the ``requestor'' - address, to which we should send any success or error messages. - Apparently the DOS program UUPC sends two arguments, which are - the username and the host. */ - if (argc == 2) - zQrequestor = zbufcpy (argv[1]); - else if (argc > 2) - { - zQrequestor = zbufalc (strlen (argv[1]) + strlen (argv[2]) - + sizeof "!"); - sprintf (zQrequestor, "%s!%s", argv[2], argv[1]); - } - - return UUCONF_CMDTABRET_CONTINUE; -} - -/* Handle the U command, which takes two arguments. */ - -/*ARGSUSED*/ -static int -iquser (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - if (argc > 1) - zQuser = argv[1]; - if (argc > 2) - zQsystem = argv[2]; - return UUCONF_CMDTABRET_KEEP; -} - -/* Handle various commands which just set boolean variables. */ - -/*ARGSUSED*/ -static int -iqset (puuconf, argc, argv, pvar, pinfo) - pointer puuconf; - int argc; - char **argv; - pointer pvar; - pointer pinfo; -{ - boolean *pf = (boolean *) pvar; - - *pf = TRUE; - return UUCONF_CMDTABRET_CONTINUE; -} - -/* The execution processing does a lot of things that have to be - cleaned up. Rather than try to add the appropriate statements - to each return point, we keep a set of flags indicating what - has to be cleaned up. The actual clean up is done by the - function uqcleanup. */ -#define REMOVE_FILE (01) -#define REMOVE_NEEDED (02) -#define FREE_QINPUT (04) -#define REMOVE_QINPUT (010) -#define FREE_OUTPUT (020) -#define FREE_MAIL (040) - -/* Process an execute file. The zfile argument is the name of the - execute file. The zbase argument is the base name of zfile. The - qsys argument describes the system it came from. The zcmd argument - is the name of the command we are executing (from the -c option) or - NULL if any command is OK. This sets *pfprocessed to TRUE if the - file is ready to be executed. */ - -static void -uqdo_xqt_file (puuconf, zfile, zbase, qsys, zlocalname, zcmd, pfprocessed) - pointer puuconf; - const char *zfile; - const char *zbase; - const struct uuconf_system *qsys; - const char *zlocalname; - const char *zcmd; - boolean *pfprocessed; -{ - char *zabsolute; - boolean ferr; - FILE *e; - int iuuconf; - int i; - int iclean; - const char *zmail; - char *zoutput; - char *zinput; - boolean fbadname; - char abtemp[CFILE_NAME_LEN]; - char abdata[CFILE_NAME_LEN]; - char *zerror; - struct uuconf_system soutsys; - const struct uuconf_system *qoutsys; - boolean fshell; - size_t clen; - char *zfullcmd; - boolean ftemp; - - *pfprocessed = FALSE; - - e = fopen (zfile, "r"); - if (e == NULL) - return; - - azQargs = NULL; - zQcmd = NULL; - zQinput = NULL; - zQoutfile = NULL; - zQoutsys = NULL; - cQfiles = 0; - azQfiles = NULL; - azQfiles_to = NULL; - zQrequestor = NULL; - zQuser = NULL; - zQsystem = NULL; - fQno_ack = FALSE; - fQsuccess_ack = FALSE; - fQsend_input = FALSE; - fQuse_exec = FALSE; - zQstatus_file = NULL; -#if ALLOW_SH_EXECUTION - fQuse_sh = FALSE; -#endif - - iuuconf = uuconf_cmd_file (puuconf, e, asQcmds, (pointer) zbase, - (uuconf_cmdtabfn) NULL, - (UUCONF_CMDTABFLAG_CASE - | UUCONF_CMDTABFLAG_NOCOMMENTS), - (pointer) NULL); - (void) fclose (e); - - if (iuuconf != UUCONF_SUCCESS) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - - /* If we got a non-transient error, we notify the administrator. - We can't bounce it back to the original requestor, because we - don't know how to read the file to figure out who it is (it - would probably be possible to read the file and work it out, - but it doesn't seem worth it for such an unlikely error). */ - if (UUCONF_ERROR_VALUE (iuuconf) == UUCONF_SYNTAX_ERROR - || UUCONF_ERROR_VALUE (iuuconf) == UUCONF_UNKNOWN_COMMAND) - { - const char *az[20]; - char *znew; - - i = 0; - az[i++] = "The execution file\n\t"; - az[i++] = zfile; - az[i++] = "\nfor system\n\t"; - az[i++] = qsys->uuconf_zname; - az[i++] = "\nwas corrupt. "; - znew = zsysdep_save_corrupt_file (zfile); - if (znew == NULL) - { - az[i++] = "The file could not be preserved.\n"; - (void) remove (zfile); - } - else - { - az[i++] = "It has been moved to\n\t"; - az[i++] = znew; - az[i++] = "\n"; - } - (void) fsysdep_mail (OWNER, "Corrupt execution file", i, az); - ubuffree (znew); - } - - return; - } - - iclean = 0; - - if (azQargs == NULL) - { - ulog (LOG_ERROR, "%s: No command given", zbase); - uqcleanup (zfile, iclean | REMOVE_FILE); - return; - } - - if (zcmd != NULL) - { - if (strcmp (zcmd, azQargs[0]) != 0) - { - uqcleanup (zfile, iclean); - return; - } - } - else - { - /* If there is a lock file for this particular command already, - it means that some other uuxqt is supposed to handle it. */ - if (fsysdep_uuxqt_locked (azQargs[0])) - { - uqcleanup (zfile, iclean); - return; - } - } - - /* Lock this particular file. */ - if (! fsysdep_lock_uuxqt_file (zfile)) - { - uqcleanup (zfile, iclean); - return; - } - - zQunlock_file = zfile; - - /* Now that we have the file locked, make sure it still exists. - Otherwise another uuxqt could have just finished processing it - and removed the lock file. */ - if (! fsysdep_file_exists (zfile)) - { - uqcleanup (zfile, iclean); - return; - } - - if (zQuser != NULL) - ulog_user (zQuser); - else if (zQrequestor != NULL) - ulog_user (zQrequestor); - else - ulog_user ("unknown"); - - /* zQsystem, if it is set, comes from the execution file, which - means that we do not trust it. We only retain it if - qsys->uuconf_zname is a prefix of it, since that can happen with - a job from an anonymous system on certain spool directory types, - and is unlikely to cause any trouble anyhow. */ - if (zQsystem == NULL - || strncmp (zQsystem, qsys->uuconf_zname, - strlen (qsys->uuconf_zname)) != 0) - zQsystem = qsys->uuconf_zname; - - /* Make sure that all the required files exist, and get their - full names in the spool directory. */ - for (i = 0; i < cQfiles; i++) - { - char *zreal; - - zreal = zsysdep_spool_file_name (qsys, azQfiles[i], (pointer) NULL); - if (zreal == NULL) - { - uqcleanup (zfile, iclean); - return; - } - if (! fsysdep_file_exists (zreal)) - { - uqcleanup (zfile, iclean); - return; - } - ubuffree (azQfiles[i]); - azQfiles[i] = zbufcpy (zreal); - ubuffree (zreal); - } - - /* Lock the execution directory. */ - if (! fsysdep_lock_uuxqt_dir (iQlock_seq)) - { - ulog (LOG_ERROR, "Could not lock execute directory"); - uqcleanup (zfile, iclean); - return; - } - fQunlock_directory = TRUE; - - iclean |= REMOVE_FILE | REMOVE_NEEDED; - *pfprocessed = TRUE; - - /* Get the address to mail results to. Prepend the system from - which the execute file originated, since mail addresses are - relative to it. */ - zmail = NULL; - if (zQrequestor != NULL) - zmail = zQrequestor; - else if (zQuser != NULL) - zmail = zQuser; - if (zmail != NULL -#if HAVE_INTERNET_MAIL - && strchr (zmail, '@') == NULL -#endif - && strcmp (zQsystem, zlocalname) != 0) - { - char *zset; - - zset = zbufalc (strlen (zQsystem) + strlen (zmail) + 2); - sprintf (zset, "%s!%s", zQsystem, zmail); - zmail = zset; - zQmail = zset; - iclean |= FREE_MAIL; - } - - /* The command "uucp" is handled specially. We make sure that the - appropriate forwarding is permitted, and we add a -u argument to - specify the user. */ - if (strcmp (azQargs[0], "uucp") == 0) - { - char *zfrom, *zto; - boolean fmany; - char **azargs; - const char *zuser; - - zfrom = NULL; - zto = NULL; - fmany = FALSE; - - /* Skip all the options, and get the from and to specs. We - don't permit multiple arguments. */ - for (i = 1; azQargs[i] != NULL; i++) - { - if (azQargs[i][0] == '-') - { - char *zopts; - - for (zopts = azQargs[i] + 1; *zopts != '\0'; zopts++) - { - /* The -g, -n, and -s options take an argument. */ - if (*zopts == 'g' || *zopts == 'n' || *zopts == 's') - { - if (zopts[1] == '\0') - ++i; - break; - } - /* The -I, -u and -x options are not permitted. */ - if (*zopts == 'I' || *zopts == 'u' || *zopts == 'x') - { - *zopts = 'r'; - if (zopts[1] != '\0') - zopts[1] = '\0'; - else - { - ++i; - azQargs[i] = zbufcpy ("-r"); - } - break; - } - } - } - else if (zfrom == NULL) - zfrom = azQargs[i]; - else if (zto == NULL) - zto = azQargs[i]; - else - { - fmany = TRUE; - break; - } - } - - /* Add the -u argument. This is required to let uucp do the - correct permissions checking on the file transfer. */ - for (i = 0; azQargs[i] != NULL; i++) - ; - azargs = (char **) xmalloc ((i + 2) * sizeof (char *)); - azargs[0] = azQargs[0]; - zuser = zQuser; - if (zuser == NULL) - zuser = "uucp"; - azargs[1] = zbufalc (strlen (zQsystem) + strlen (zuser) - + sizeof "-u!"); - sprintf (azargs[1], "-u%s!%s", zQsystem, zuser); - memcpy (azargs + 2, azQargs + 1, i * sizeof (char *)); - xfree ((pointer) azQargs); - azQargs = azargs; - - /* Find the uucp binary. */ - zabsolute = zsysdep_find_command ("uucp", qsys->uuconf_pzcmds, - qsys->uuconf_pzpath, &ferr); - if (zabsolute == NULL && ! ferr) - { - const char *azcmds[2]; - - /* If "uucp" is not a permitted command, then the forwarding - entries must be set. */ - if (! fqforward (zfrom, qsys->uuconf_pzforward_from, "from", zmail) - || ! fqforward (zto, qsys->uuconf_pzforward_to, "to", zmail)) - { - uqcleanup (zfile, iclean); - return; - } - - /* If "uucp" is not a permitted command, then only uucp - requests with a single source are permitted, since that - is all that will be generated by uucp or uux. */ - if (fmany) - { - ulog (LOG_ERROR, "Bad uucp request %s", zQcmd); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because it was an"; - az[i++] = " unsupported uucp request.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - - azcmds[0] = "uucp"; - azcmds[1] = NULL; - zabsolute = zsysdep_find_command ("uucp", (char **) azcmds, - qsys->uuconf_pzpath, &ferr); - } - if (zabsolute == NULL) - { - if (! ferr) - ulog (LOG_ERROR, "Can't find uucp executable"); - - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - } - else - { - /* Get the pathname to execute. */ - zabsolute = zsysdep_find_command (azQargs[0], qsys->uuconf_pzcmds, - qsys->uuconf_pzpath, - &ferr); - if (zabsolute == NULL) - { - if (ferr) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - /* Not permitted. Send mail to requestor. */ - ulog (LOG_ERROR, "Not permitted to execute %s", - azQargs[0]); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are not"; - az[i++] = " permitted to execute\n\t"; - az[i++] = azQargs[0]; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - iclean = isave_files (qsys, zmail, zfile, iclean); - - uqcleanup (zfile, iclean); - return; - } - } - - ubuffree (azQargs[0]); - azQargs[0] = zabsolute; - - for (i = 1; azQargs[i] != NULL; i++) - { - char *zlocal; - - zlocal = zsysdep_xqt_local_file (qsys, azQargs[i]); - if (zlocal != NULL) - { - ubuffree (azQargs[i]); - azQargs[i] = zlocal; - } - } - -#if ! ALLOW_FILENAME_ARGUMENTS - - /* Check all the arguments to make sure they don't try to specify - files they are not permitted to access. */ - for (i = 1; azQargs[i] != NULL; i++) - { - if (! fsysdep_xqt_check_file (qsys, azQargs[i])) - { - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - const char *zfailed; - - zfailed = azQargs[i]; - i = 0; - az[i++] = "Your execution request failed because you are not"; - az[i++] = " permitted to refer to file\n\t"; - az[i++] = zfailed; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - iclean = isave_files (qsys, zmail, zfile, iclean); - - uqcleanup (zfile, iclean); - return; - } - } - -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - - ulog (LOG_NORMAL, "Executing %s (%s)", zbase, zQcmd); - - if (zQinput != NULL) - { - boolean fspool; - char *zreal; - - fspool = fspool_file (zQinput); - if (! fspool) - zreal = zsysdep_local_file (zQinput, qsys->uuconf_zpubdir, &fbadname); - else - { - zreal = zsysdep_spool_file_name (qsys, zQinput, (pointer) NULL); - fbadname = FALSE; - } - if (zreal == NULL && ! fbadname) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - if (zreal != NULL) - { - zQinput = zreal; - iclean |= FREE_QINPUT; - if (fspool) - iclean |= REMOVE_QINPUT; - } - - if (zreal == NULL - || (! fspool - && ! fin_directory_list (zQinput, qsys->uuconf_pzremote_send, - qsys->uuconf_zpubdir, TRUE, TRUE, - (const char *) NULL))) - { - ulog (LOG_ERROR, "Not permitted to read %s", zQinput); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are"; - az[i++] = " not permitted to read\n\t"; - az[i++] = zQinput; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - } - - zoutput = NULL; - if (zQoutfile == NULL) - qoutsys = NULL; - else if (zQoutsys != NULL - && strcmp (zQoutsys, zlocalname) != 0) - { - char *zdata; - - /* The output file is destined for some other system, so we must - use a temporary file to catch standard output. */ - if (strcmp (zQoutsys, qsys->uuconf_zname) == 0) - qoutsys = qsys; - else - { - iuuconf = uuconf_system_info (puuconf, zQoutsys, &soutsys); - if (iuuconf != UUCONF_SUCCESS) - { - if (iuuconf != UUCONF_NOT_FOUND) - { - ulog_uuconf (LOG_ERROR, puuconf, iuuconf); - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - if (! funknown_system (puuconf, zQoutsys, &soutsys)) - { - ulog (LOG_ERROR, - "Can't send standard output to unknown system %s", - zQoutsys); - /* We don't send mail to unknown systems, either. - Maybe we should. */ - uqcleanup (zfile, iclean); - return; - } - } - - qoutsys = &soutsys; - } - - zdata = zsysdep_data_file_name (qoutsys, zlocalname, - BDEFAULT_UUX_GRADE, FALSE, abtemp, - abdata, (char *) NULL); - if (zdata == NULL) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - zoutput = zdata; - zQoutput = zoutput; - iclean |= FREE_OUTPUT; - } - else - { - boolean fok; - - qoutsys = NULL; - - /* If we permitted the standard output to be redirected into - the spool directory, people could set up phony commands. */ - if (fspool_file (zQoutfile)) - fok = FALSE; - else - { - zoutput = zsysdep_local_file (zQoutfile, qsys->uuconf_zpubdir, - &fbadname); - if (zoutput == NULL) - { - if (! fbadname) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - fok = FALSE; - } - else - { - ubuffree (zQoutfile); - zQoutfile = zoutput; - - /* Make sure it's OK to receive this file. */ - fok = fin_directory_list (zQoutfile, - qsys->uuconf_pzremote_receive, - qsys->uuconf_zpubdir, TRUE, FALSE, - (const char *) NULL); - } - } - - if (! fok) - { - ulog (LOG_ERROR, "Not permitted to write to %s", zQoutfile); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are"; - az[i++] = " not permitted to write to\n\t"; - az[i++] = zQoutfile; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - } - - /* Move the required files to the execution directory if necessary. */ - zinput = zQinput; - if (! fsysdep_move_uuxqt_files (cQfiles, (const char **) azQfiles, - (const char **) azQfiles_to, - TRUE, iQlock_seq, &zinput)) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - if (zQinput != NULL && strcmp (zQinput, zinput) != 0) - { - if ((iclean & FREE_QINPUT) != 0) - ubuffree (zQinput); - zQinput = zinput; - iclean |= FREE_QINPUT; - } - -#if ALLOW_SH_EXECUTION - fshell = fQuse_sh; -#else - fshell = FALSE; -#endif - - /* Get a shell command which uses the full path of the command to - execute. */ - clen = 0; - for (i = 0; azQargs[i] != NULL; i++) - clen += strlen (azQargs[i]) + 1; - zfullcmd = zbufalc (clen); - strcpy (zfullcmd, azQargs[0]); - for (i = 1; azQargs[i] != NULL; i++) - { - strcat (zfullcmd, " "); - strcat (zfullcmd, azQargs[i]); - } - - if (! fsysdep_execute (qsys, - zQuser == NULL ? (const char *) "uucp" : zQuser, - (const char **) azQargs, zfullcmd, zQinput, - zoutput, fshell, iQlock_seq, &zerror, &ftemp)) - { - ubuffree (zfullcmd); - - (void) fsysdep_move_uuxqt_files (cQfiles, (const char **) azQfiles, - (const char **) azQfiles_to, - FALSE, iQlock_seq, - (char **) NULL); - - if (ftemp) - { - ulog (LOG_NORMAL, "Will retry later (%s)", zbase); - if (zoutput != NULL) - (void) remove (zoutput); - if (zerror != NULL) - { - (void) remove (zerror); - ubuffree (zerror); - } - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - ulog (LOG_NORMAL, "Execution failed (%s)", zbase); - - if (zmail != NULL && ! fQno_ack) - { - const char **pz; - int cgot; - FILE *eerr; - int istart; - - cgot = 20; - pz = (const char **) xmalloc (cgot * sizeof (const char *)); - i = 0; - pz[i++] = "Execution request failed:\n\t"; - pz[i++] = zQcmd; - pz[i++] = "\n"; - - if (zerror == NULL) - eerr = NULL; - else - eerr = fopen (zerror, "r"); - if (eerr == NULL) - { - pz[i++] = "There was no output on standard error\n"; - istart = i; - } - else - { - char *zline; - size_t cline; - - pz[i++] = "Standard error output was:\n"; - istart = i; - - zline = NULL; - cline = 0; - while (getline (&zline, &cline, eerr) > 0) - { - if (i >= cgot) - { - cgot += 20; - pz = ((const char **) - xrealloc ((pointer) pz, - cgot * sizeof (const char *))); - } - pz[i++] = zbufcpy (zline); - } - - (void) fclose (eerr); - xfree ((pointer) zline); - } - - (void) fsysdep_mail (zmail, "Execution failed", i, pz); - - for (; istart < i; istart++) - ubuffree ((char *) pz[istart]); - xfree ((pointer) pz); - } - - if (qoutsys != NULL) - (void) remove (zoutput); - - iclean = isave_files (qsys, zmail, zfile, iclean); - } - else - { - ubuffree (zfullcmd); - - if (zmail != NULL && fQsuccess_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "\nExecution request succeeded:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution succeded", i, az); - } - - /* Now we may have to uucp the output to some other machine. */ - - if (qoutsys != NULL) - { - struct scmd s; - - /* Fill in the command structure. */ - - s.bcmd = 'S'; - s.bgrade = BDEFAULT_UUX_GRADE; - s.pseq = NULL; - s.zfrom = abtemp; - s.zto = zQoutfile; - if (zQuser != NULL) - s.zuser = zQuser; - else - s.zuser = "uucp"; - if (zmail != NULL && fQsuccess_ack) - s.zoptions = "Cn"; - else - s.zoptions = "C"; - s.ztemp = abtemp; - s.imode = 0666; - if (zmail != NULL && fQsuccess_ack) - s.znotify = zmail; - else - s.znotify = ""; - s.cbytes = -1; - s.zcmd = NULL; - s.ipos = 0; - - ubuffree (zsysdep_spool_commands (qoutsys, BDEFAULT_UUX_GRADE, - 1, &s)); - } - } - - if (zerror != NULL) - { - (void) remove (zerror); - ubuffree (zerror); - } - - uqcleanup (zfile, iclean); -} - -/* If we have enough disk space, save the data files so that the UUCP - administrator can examine them. Send a mail message listing the - saved files. */ - -static int -isave_files (qsys, zmail, zfile, iclean) - const struct uuconf_system *qsys; - const char *zmail; - const char *zfile; - int iclean; -{ - long cspace; - char *zsavecmd; - char **pzsave; - int c; - int ifile; - char *zsaveinput; - const char **pz; - int i; - - /* Save the files if there is 1.5 times the amount of required free - space. */ - cspace = csysdep_bytes_free (zfile); - if (cspace == -1) - cspace = FREE_SPACE_DELTA; - cspace -= qsys->uuconf_cfree_space + qsys->uuconf_cfree_space / 2; - if (cspace < 0) - return iclean; - - zsavecmd = zsysdep_save_failed_file (zfile); - if (zsavecmd == NULL) - return iclean; - - c = 1; - - pzsave = (char **) xmalloc (cQfiles * sizeof (char *)); - for (ifile = 0; ifile < cQfiles; ifile++) - { - if (azQfiles[ifile] != NULL) - { - ++c; - pzsave[ifile] = zsysdep_save_failed_file (azQfiles[ifile]); - if (pzsave[ifile] == NULL) - { - ubuffree (zsavecmd); - for (i = 0; i < ifile; i++) - if (azQfiles[i] != NULL) - ubuffree (pzsave[i]); - xfree ((pointer) pzsave); - return iclean; - } - } - } - - zsaveinput = NULL; - if ((iclean & REMOVE_QINPUT) != 0 - && fsysdep_file_exists (zQinput)) - { - zsaveinput = zsysdep_save_failed_file (zQinput); - if (zsaveinput == NULL) - { - ubuffree (zsavecmd); - for (i = 0; i < cQfiles; i++) - if (azQfiles[i] != NULL) - ubuffree (pzsave[i]); - xfree ((pointer) pzsave); - return iclean; - } - } - - pz = (const char **) xmalloc ((20 + 2 * cQfiles) * sizeof (char *)); - i = 0; - - pz[i++] = "A UUCP execution request failed:\n\t"; - pz[i++] = zQcmd; - if (zmail != NULL) - { - pz[i++] = "\nThe request was made by\n\t"; - pz[i++] = zmail; - } - else - { - pz[i++] = "\nThe request came from system\n\t"; - pz[i++] = qsys->uuconf_zname; - } - if (c == 1 && zsaveinput == NULL) - pz[i++] = "\nThe following file has been saved:\n\t"; - else - pz[i++] = "\nThe following files have been saved:\n\t"; - pz[i++] = zsavecmd; - for (ifile = 0; ifile < cQfiles; ifile++) - { - if (azQfiles[ifile] != NULL) - { - pz[i++] = "\n\t"; - pz[i++] = pzsave[ifile]; - } - } - if (zsaveinput != NULL) - { - pz[i++] = "\n\t"; - pz[i++] = zsaveinput; - } - pz[i++] = "\n"; - - (void) fsysdep_mail (OWNER, - "UUCP execution files saved after failure", - i, pz); - - xfree ((pointer) pz); - - ubuffree (zsavecmd); - for (ifile = 0; ifile < cQfiles; ifile++) - if (azQfiles[ifile] != NULL) - ubuffree (pzsave[ifile]); - xfree ((pointer) pzsave); - ubuffree (zsaveinput); - - return iclean &~ (REMOVE_FILE | REMOVE_NEEDED); -} - -/* Clean up the results of uqdo_xqt_file. */ - -static void -uqcleanup (zfile, iflags) - const char *zfile; - int iflags; -{ - int i; - - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "uqcleanup: %s, %d", zfile, iflags); - - if (zQunlock_file != NULL) - { - (void) fsysdep_unlock_uuxqt_file (zQunlock_file); - zQunlock_file = NULL; - } - - if ((iflags & REMOVE_FILE) != 0) - (void) remove (zfile); - - if ((iflags & REMOVE_NEEDED) != 0) - { - for (i = 0; i < cQfiles; i++) - { - if (azQfiles[i] != NULL) - (void) remove (azQfiles[i]); - } - if ((iflags & REMOVE_QINPUT) != 0) - (void) remove (zQinput); - } - - if ((iflags & FREE_QINPUT) != 0) - ubuffree (zQinput); - - if ((iflags & FREE_OUTPUT) != 0) - ubuffree (zQoutput); - if ((iflags & FREE_MAIL) != 0) - ubuffree (zQmail); - - if (fQunlock_directory) - { - (void) fsysdep_unlock_uuxqt_dir (iQlock_seq); - fQunlock_directory = FALSE; - } - - for (i = 0; i < cQfiles; i++) - { - ubuffree (azQfiles[i]); - ubuffree (azQfiles_to[i]); - } - - ubuffree (zQoutfile); - ubuffree (zQoutsys); - ubuffree (zQrequestor); - - if (azQargs != NULL) - { - for (i = 0; azQargs[i] != NULL; i++) - ubuffree (azQargs[i]); - xfree ((pointer) azQargs); - azQargs = NULL; - } - - xfree ((pointer) zQcmd); - zQcmd = NULL; - - xfree ((pointer) azQfiles); - azQfiles = NULL; - - xfree ((pointer) azQfiles_to); - azQfiles_to = NULL; -} - -/* Check whether forwarding is permitted. */ - -static boolean -fqforward (zfile, pzallowed, zlog, zmail) - const char *zfile; - char **pzallowed; - const char *zlog; - const char *zmail; -{ - const char *zexclam; - - zexclam = strchr (zfile, '!'); - if (zexclam != NULL) - { - size_t clen; - char *zsys; - boolean fret; - - clen = zexclam - zfile; - zsys = zbufalc (clen + 1); - memcpy (zsys, zfile, clen); - zsys[clen] = '\0'; - - fret = FALSE; - if (pzallowed != NULL) - { - char **pz; - - for (pz = pzallowed; *pz != NULL; pz++) - { - if (strcmp (*pz, "ANY") == 0 - || strcmp (*pz, zsys) == 0) - { - fret = TRUE; - break; - } - } - } - - if (! fret) - { - ulog (LOG_ERROR, "Not permitted to forward %s %s (%s)", - zlog, zsys, zQcmd); - - if (zmail != NULL && ! fQno_ack) - { - int i; - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are"; - az[i++] = " not permitted to forward files\n"; - az[i++] = zlog; - az[i++] = " the system\n\t"; - az[i++] = zsys; - az[i++] = "\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - } - - ubuffree (zsys); - - return fret; - } - - return TRUE; -} |