aboutsummaryrefslogtreecommitdiffstats
path: root/gnu/libexec/uucp/libunix
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/libexec/uucp/libunix')
-rw-r--r--gnu/libexec/uucp/libunix/MANIFEST5
-rw-r--r--gnu/libexec/uucp/libunix/Makefile21
-rw-r--r--gnu/libexec/uucp/libunix/app3.c5
-rw-r--r--gnu/libexec/uucp/libunix/app4.c5
-rw-r--r--gnu/libexec/uucp/libunix/cohtty.c21
-rw-r--r--gnu/libexec/uucp/libunix/corrup.c33
-rw-r--r--gnu/libexec/uucp/libunix/cusub.c64
-rw-r--r--gnu/libexec/uucp/libunix/cwd.c7
-rw-r--r--gnu/libexec/uucp/libunix/detach.c10
-rw-r--r--gnu/libexec/uucp/libunix/dirent.c2
-rw-r--r--gnu/libexec/uucp/libunix/dup2.c2
-rw-r--r--gnu/libexec/uucp/libunix/epopen.c4
-rw-r--r--gnu/libexec/uucp/libunix/filnam.c6
-rw-r--r--gnu/libexec/uucp/libunix/fsusg.c128
-rw-r--r--gnu/libexec/uucp/libunix/ftw.c12
-rw-r--r--gnu/libexec/uucp/libunix/indir.c2
-rw-r--r--gnu/libexec/uucp/libunix/init.c28
-rw-r--r--gnu/libexec/uucp/libunix/iswait.c2
-rw-r--r--gnu/libexec/uucp/libunix/jobid.c2
-rw-r--r--gnu/libexec/uucp/libunix/lcksys.c39
-rw-r--r--gnu/libexec/uucp/libunix/locfil.c12
-rw-r--r--gnu/libexec/uucp/libunix/lock.c279
-rw-r--r--gnu/libexec/uucp/libunix/loctim.c4
-rw-r--r--gnu/libexec/uucp/libunix/mail.c52
-rw-r--r--gnu/libexec/uucp/libunix/mkdir.c2
-rw-r--r--gnu/libexec/uucp/libunix/mkdirs.c20
-rw-r--r--gnu/libexec/uucp/libunix/move.c24
-rw-r--r--gnu/libexec/uucp/libunix/opensr.c24
-rw-r--r--gnu/libexec/uucp/libunix/pause.c10
-rw-r--r--gnu/libexec/uucp/libunix/picksb.c14
-rw-r--r--gnu/libexec/uucp/libunix/pipe.c294
-rw-r--r--gnu/libexec/uucp/libunix/priv.c24
-rw-r--r--gnu/libexec/uucp/libunix/proctm.c6
-rw-r--r--gnu/libexec/uucp/libunix/recep.c12
-rw-r--r--gnu/libexec/uucp/libunix/run.c52
-rw-r--r--gnu/libexec/uucp/libunix/seq.c4
-rw-r--r--gnu/libexec/uucp/libunix/serial.c666
-rw-r--r--gnu/libexec/uucp/libunix/signal.c2
-rw-r--r--gnu/libexec/uucp/libunix/sindir.c5
-rw-r--r--gnu/libexec/uucp/libunix/sleep.c12
-rw-r--r--gnu/libexec/uucp/libunix/spawn.c55
-rw-r--r--gnu/libexec/uucp/libunix/splcmd.c44
-rw-r--r--gnu/libexec/uucp/libunix/spool.c43
-rw-r--r--gnu/libexec/uucp/libunix/srmdir.c6
-rw-r--r--gnu/libexec/uucp/libunix/statsb.c126
-rw-r--r--gnu/libexec/uucp/libunix/status.c6
-rw-r--r--gnu/libexec/uucp/libunix/strerr.c2
-rw-r--r--gnu/libexec/uucp/libunix/tmpfil.c5
-rw-r--r--gnu/libexec/uucp/libunix/uacces.c2
-rw-r--r--gnu/libexec/uucp/libunix/ufopen.c2
-rw-r--r--gnu/libexec/uucp/libunix/walk.c5
-rw-r--r--gnu/libexec/uucp/libunix/wldcrd.c7
-rw-r--r--gnu/libexec/uucp/libunix/work.c92
-rw-r--r--gnu/libexec/uucp/libunix/xqtfil.c11
-rw-r--r--gnu/libexec/uucp/libunix/xqtsub.c32
55 files changed, 1815 insertions, 539 deletions
diff --git a/gnu/libexec/uucp/libunix/MANIFEST b/gnu/libexec/uucp/libunix/MANIFEST
index d64e79922046..c57f466fc988 100644
--- a/gnu/libexec/uucp/libunix/MANIFEST
+++ b/gnu/libexec/uucp/libunix/MANIFEST
@@ -8,8 +8,9 @@ basnam.c
bytfre.c
chmod.c
cohtty.c
-cwd.c
+corrup.c
cusub.c
+cwd.c
detach.c
dirent.c
dup2.c
@@ -40,7 +41,9 @@ move.c
opensr.c
pause.c
picksb.c
+pipe.c
portnm.c
+priv.c
proctm.c
recep.c
remove.c
diff --git a/gnu/libexec/uucp/libunix/Makefile b/gnu/libexec/uucp/libunix/Makefile
index 3a6750b17164..103c99d62e8b 100644
--- a/gnu/libexec/uucp/libunix/Makefile
+++ b/gnu/libexec/uucp/libunix/Makefile
@@ -1,16 +1,17 @@
# This subdirectory contains Unix specific support functions.
-# $Id: Makefile,v 1.1 1993/08/05 18:23:34 conklin Exp $
+# $Id: Makefile,v 1.2 1994/05/07 18:10:03 ache Exp $
LIB= unix
-SRCS= access.c addbas.c app3.c app4.c basnam.c bytfre.c cwd.c \
- chmod.c cohtty.c cusub.c detach.c efopen.c epopen.c exists.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 portnm.c \
- proctm.c recep.c run.c seq.c serial.c signal.c sindir.c size.c \
- sleep.c spawn.c splcmd.c splnam.c spool.c srmdir.c statsb.c \
- status.c time.c tmpfil.c trunc.c uacces.c ufopen.c ultspl.c \
- unknwn.c uuto.c walk.c wldcrd.c work.c xqtfil.c xqtsub.c ftw.c
+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 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 time.c tmpfil.c trunc.c uacces.c \
+ ufopen.c ultspl.c unknwn.c uuto.c walk.c wldcrd.c work.c \
+ xqtfil.c xqtsub.c ftw.c
CFLAGS+= -I$(.CURDIR)/../common_sources \
-DOWNER=\"$(owner)\" -DSBINDIR=\"$(sbindir)\"
diff --git a/gnu/libexec/uucp/libunix/app3.c b/gnu/libexec/uucp/libunix/app3.c
index 5c0b58938515..f3c3555a363d 100644
--- a/gnu/libexec/uucp/libunix/app3.c
+++ b/gnu/libexec/uucp/libunix/app3.c
@@ -19,7 +19,10 @@ zsappend3 (zdir1, zdir2, zfile)
cdir2 = strlen (zdir2);
cfile = strlen (zfile);
zret = zbufalc (cdir1 + cdir2 + cfile + 3);
- memcpy (zret, zdir1, cdir1);
+ if (cdir1 == 1 && *zdir1 == '/')
+ cdir1 = 0;
+ else
+ memcpy (zret, zdir1, cdir1);
memcpy (zret + cdir1 + 1, zdir2, cdir2);
memcpy (zret + cdir1 + cdir2 + 2, zfile, cfile);
zret[cdir1] = '/';
diff --git a/gnu/libexec/uucp/libunix/app4.c b/gnu/libexec/uucp/libunix/app4.c
index a3b3787f68fd..d3a243fd7285 100644
--- a/gnu/libexec/uucp/libunix/app4.c
+++ b/gnu/libexec/uucp/libunix/app4.c
@@ -21,7 +21,10 @@ zsappend4 (zdir1, zdir2, zdir3, zfile)
cdir3 = strlen (zdir3);
cfile = strlen (zfile);
zret = zbufalc (cdir1 + cdir2 + cdir3 + cfile + 4);
- memcpy (zret, zdir1, cdir1);
+ if (cdir1 == 1 && *zdir1 == '/')
+ cdir1 = 0;
+ else
+ memcpy (zret, zdir1, cdir1);
memcpy (zret + cdir1 + 1, zdir2, cdir2);
memcpy (zret + cdir1 + cdir2 + 2, zdir3, cdir3);
memcpy (zret + cdir1 + cdir2 + cdir3 + 3, zfile, cfile);
diff --git a/gnu/libexec/uucp/libunix/cohtty.c b/gnu/libexec/uucp/libunix/cohtty.c
index a7aec1cae338..5a52df91e57c 100644
--- a/gnu/libexec/uucp/libunix/cohtty.c
+++ b/gnu/libexec/uucp/libunix/cohtty.c
@@ -37,6 +37,19 @@
* reset the serial device to see if the device needs to be re-enabled.
*/
+/* May 10, 1993: This function will always return true for the following
+ * reasons:
+ * 1) lock files have already been dealt with
+ * 2) if someone else already has the port open, uucico should fail anyways
+ * 3) Coherent's disable command return can return '0' or '1', but will
+ * succeed in any event.
+ * 4) It doesn't matter if there is a ttys entry for the port in question.
+ * /etc/ttys generally only lists devices that MAY be enabled for logins.
+ * If a device will never be used for logins, then there may not be a
+ * ttys entry, in which case, disable won't be called anyways.
+ * ---bob@mwc.com
+ */
+
boolean
fscoherent_disable_tty (zdevice, pzenable)
const char *zdevice;
@@ -130,14 +143,14 @@ char enable_device[16]; /* this will hold our device name
+ strlen (enable_device));
sprintf(*pzenable,"/dev/%s", enable_device);
/* ulog(LOG_NORMAL,"Enable string is {%s}",*pzenable); */
- return(x==0? TRUE : FALSE); /* disable either failed
- or succeded */
+ return TRUE;
}else{
- return FALSE; /* device in tty entry not enabled */
+ /* device not enabled */
+ return TRUE;
}
}
}
- return FALSE; /* no ttys entry found */
+ return TRUE; /* no ttys entry found */
}
/* The following is COHERENT 4.0 specific. It is used to test for any
diff --git a/gnu/libexec/uucp/libunix/corrup.c b/gnu/libexec/uucp/libunix/corrup.c
new file mode 100644
index 000000000000..87f19e668894
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/corrup.c
@@ -0,0 +1,33 @@
+/* corrup.c
+ Save a file in the .Corrupt directory. */
+
+#include "uucp.h"
+
+#include "sysdep.h"
+#include "uudefs.h"
+#include "system.h"
+
+char *
+zsysdep_save_corrupt_file (zfile)
+ const char *zfile;
+{
+ const char *zslash;
+ char *zto;
+
+ zslash = strrchr (zfile, '/');
+ if (zslash == NULL)
+ zslash = zfile;
+ else
+ ++zslash;
+
+ zto = zsappend3 (zSspooldir, CORRUPTDIR, zslash);
+
+ if (! fsysdep_move_file (zfile, zto, TRUE, FALSE, FALSE,
+ (const char *) NULL))
+ {
+ ubuffree (zto);
+ return NULL;
+ }
+
+ return zto;
+}
diff --git a/gnu/libexec/uucp/libunix/cusub.c b/gnu/libexec/uucp/libunix/cusub.c
index d1110fd5c7b4..6505a07ac639 100644
--- a/gnu/libexec/uucp/libunix/cusub.c
+++ b/gnu/libexec/uucp/libunix/cusub.c
@@ -1,7 +1,7 @@
/* cusub.c
System dependent routines for cu.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char cusub_rcsid[] = "$Id: cusub.c,v 1.1 1993/08/05 18:23:44 conklin Exp $";
+const char cusub_rcsid[] = "$Id: cusub.c,v 1.2 1994/05/07 18:10:14 ache Exp $";
#endif
#include "uudefs.h"
@@ -37,8 +37,40 @@ const char cusub_rcsid[] = "$Id: cusub.c,v 1.1 1993/08/05 18:23:44 conklin Exp $
#include "conn.h"
#include "prot.h"
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#else
+#if HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#endif
+
+/* Get definitions for both O_NONBLOCK and O_NDELAY. */
+#ifndef O_NDELAY
+#ifdef FNDELAY
+#define O_NDELAY FNDELAY
+#else /* ! defined (FNDELAY) */
+#define O_NDELAY 0
+#endif /* ! defined (FNDELAY) */
+#endif /* ! defined (O_NDELAY) */
+
+#ifndef O_NONBLOCK
+#ifdef FNBLOCK
+#define O_NONBLOCK FNBLOCK
+#else /* ! defined (FNBLOCK) */
+#define O_NONBLOCK 0
+#endif /* ! defined (FNBLOCK) */
+#endif /* ! defined (O_NONBLOCK) */
+
#include <errno.h>
+/* 4.2 systems don't define SIGUSR2. This should work for them. On
+ systems which are missing SIGUSR1, or SIGURG, you must find two
+ signals which you can safely use. */
+#ifndef SIGUSR2
+#define SIGUSR2 SIGURG
+#endif
+
/* Get definitions for EAGAIN, EWOULDBLOCK and ENODATA. */
#ifndef EAGAIN
#ifndef EWOULDBLOCK
@@ -69,6 +101,7 @@ static char bStstp;
static const char *zsport_line P((const struct uuconf_port *qport));
static void uscu_child P((struct sconnection *qconn, int opipe));
+static RETSIGTYPE uscu_child_handler P((int isig));
static RETSIGTYPE uscu_alarm P((int isig));
static int cscu_escape P((char *pbcmd, const char *zlocalname));
static RETSIGTYPE uscu_alarm_kill P((int isig));
@@ -97,6 +130,7 @@ zsport_line (qport)
break;
case UUCONF_PORTTYPE_TCP:
case UUCONF_PORTTYPE_TLI:
+ case UUCONF_PORTTYPE_PIPE:
return NULL;
}
@@ -556,7 +590,9 @@ uscu_child (qconn, opipe)
CATCH_PROTECT int cwrite;
CATCH_PROTECT char abbuf[1024];
- /* It would be nice if we could just use fsserial_read, but that
+ fgot = FALSE;
+
+ /* It would be nice if we could just use fsysdep_conn_read, but that
will log signals that we don't want logged. There should be a
generic way to extract the file descriptor from the port. */
if (qconn->qport == NULL)
@@ -571,8 +607,12 @@ uscu_child (qconn, opipe)
oport = -1;
break;
#endif
+ case UUCONF_PORTTYPE_PIPE:
+ /* A read of 0 on a pipe always means EOF (see below). */
+ fgot = TRUE;
+ /* Fall through. */
case UUCONF_PORTTYPE_STDIN:
- oport = 0;
+ oport = ((struct ssysdep_conn *) qconn->psysdep)->ord;
break;
case UUCONF_PORTTYPE_MODEM:
case UUCONF_PORTTYPE_DIRECT:
@@ -583,6 +623,10 @@ uscu_child (qconn, opipe)
}
}
+ /* Force the descriptor into blocking mode. */
+ (void) fcntl (oport, F_SETFL,
+ fcntl (oport, F_GETFL, 0) &~ (O_NDELAY | O_NONBLOCK));
+
usset_signal (SIGUSR1, uscu_child_handler, TRUE, (boolean *) NULL);
usset_signal (SIGUSR2, uscu_child_handler, TRUE, (boolean *) NULL);
usset_signal (SIGINT, SIG_IGN, TRUE, (boolean *) NULL);
@@ -591,7 +635,6 @@ uscu_child (qconn, opipe)
usset_signal (SIGTERM, uscu_child_handler, TRUE, (boolean *) NULL);
fstopped = FALSE;
- fgot = FALSE;
iSchild_sig = 0;
cwrite = 0;
@@ -792,7 +835,7 @@ fsysdep_terminal_raw (flocalecho)
sSterm_new.c_lflag &=~ (ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHONL);
else
sSterm_new.c_lflag &=~ (ICANON | ISIG);
- sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL);
+ sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY);
sSterm_new.c_oflag &=~ (OPOST);
sSterm_new.c_cc[VMIN] = 1;
sSterm_new.c_cc[VTIME] = 0;
@@ -808,7 +851,7 @@ fsysdep_terminal_raw (flocalecho)
(ICANON | IEXTEN | ISIG | ECHO | ECHOE | ECHOK | ECHONL);
else
sSterm_new.c_lflag &=~ (ICANON | IEXTEN | ISIG);
- sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL);
+ sSterm_new.c_iflag &=~ (INLCR | IGNCR | ICRNL | IXON | IXOFF);
sSterm_new.c_oflag &=~ (OPOST);
sSterm_new.c_cc[VMIN] = 1;
sSterm_new.c_cc[VTIME] = 0;
@@ -1094,8 +1137,9 @@ fsysdep_shell (qconn, zcmd, tcmd)
oread = owrite = -1;
break;
case UUCONF_PORTTYPE_STDIN:
- oread = 0;
- owrite = 1;
+ case UUCONF_PORTTYPE_PIPE:
+ oread = ((struct ssysdep_conn *) qconn->psysdep)->ord;
+ owrite = ((struct ssysdep_conn *) qconn->psysdep)->owr;
break;
case UUCONF_PORTTYPE_MODEM:
case UUCONF_PORTTYPE_DIRECT:
diff --git a/gnu/libexec/uucp/libunix/cwd.c b/gnu/libexec/uucp/libunix/cwd.c
index 433025db6c3a..71d05d11f545 100644
--- a/gnu/libexec/uucp/libunix/cwd.c
+++ b/gnu/libexec/uucp/libunix/cwd.c
@@ -24,14 +24,17 @@ fsysdep_needs_cwd (zfile)
consistent with other UUCP packages. */
char *
-zsysdep_local_file_cwd (zfile, zpubdir)
+zsysdep_local_file_cwd (zfile, zpubdir, pfbadname)
const char *zfile;
const char *zpubdir;
+ boolean *pfbadname;
{
+ if (pfbadname != NULL)
+ *pfbadname = FALSE;
if (*zfile == '/')
return zbufcpy (zfile);
else if (*zfile == '~')
- return zsysdep_local_file (zfile, zpubdir);
+ return zsysdep_local_file (zfile, zpubdir, pfbadname);
else
return zsysdep_add_cwd (zfile);
}
diff --git a/gnu/libexec/uucp/libunix/detach.c b/gnu/libexec/uucp/libunix/detach.c
index 73144da001d4..9b505af499cc 100644
--- a/gnu/libexec/uucp/libunix/detach.c
+++ b/gnu/libexec/uucp/libunix/detach.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -100,11 +100,15 @@ usysdep_detach ()
while (getppid () != 1)
sleep (1);
- ulog_id (getpid ());
+ ipid = getpid ();
+ ulog_id (ipid);
/* Restore SIGHUP catcher if it wasn't being ignored. */
if (! fignored)
usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL);
+
+ DEBUG_MESSAGE2 (DEBUG_PORT, "Forked; old PID %ld, new pid %ld",
+ (long) igrp, (long) ipid);
}
#if ! HAVE_SETSID && HAVE_TIOCNOTTY
@@ -146,7 +150,7 @@ usysdep_detach ()
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_SETPGRP
+#if HAVE_BSD_PGRP
if (setpgrp (0, 0) < 0)
#else
if (setpgrp () < 0)
diff --git a/gnu/libexec/uucp/libunix/dirent.c b/gnu/libexec/uucp/libunix/dirent.c
index 83db496cabbd..c7e467ec1b1a 100644
--- a/gnu/libexec/uucp/libunix/dirent.c
+++ b/gnu/libexec/uucp/libunix/dirent.c
@@ -21,7 +21,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/dup2.c b/gnu/libexec/uucp/libunix/dup2.c
index 6a7359fe92e8..d1454205125b 100644
--- a/gnu/libexec/uucp/libunix/dup2.c
+++ b/gnu/libexec/uucp/libunix/dup2.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/epopen.c b/gnu/libexec/uucp/libunix/epopen.c
index dec1b3999d64..8c1f5cd0d854 100644
--- a/gnu/libexec/uucp/libunix/epopen.c
+++ b/gnu/libexec/uucp/libunix/epopen.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -56,7 +56,7 @@ espopen (pazargs, frd, pipid)
}
aidescs[2] = SPAWN_NULL;
- ipid = ixsspawn (pazargs, aidescs, FALSE, FALSE,
+ ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE,
(const char *) NULL, FALSE, TRUE,
(const char *) NULL, (const char *) NULL,
(const char *) NULL);
diff --git a/gnu/libexec/uucp/libunix/filnam.c b/gnu/libexec/uucp/libunix/filnam.c
index 62054767b89a..0b234c06dcca 100644
--- a/gnu/libexec/uucp/libunix/filnam.c
+++ b/gnu/libexec/uucp/libunix/filnam.c
@@ -1,7 +1,7 @@
/* filnam.c
Get names to use for UUCP files.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -62,7 +62,7 @@ extern off_t lseek ();
#endif
#define ZCHARS \
- "0123456789ABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
/* Local functions. */
diff --git a/gnu/libexec/uucp/libunix/fsusg.c b/gnu/libexec/uucp/libunix/fsusg.c
index e2b40a8ad5a5..116ab88fc187 100644
--- a/gnu/libexec/uucp/libunix/fsusg.c
+++ b/gnu/libexec/uucp/libunix/fsusg.c
@@ -1,5 +1,5 @@
/* fsusage.c -- return space usage of mounted filesystems
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,11 +19,10 @@
for use with Taylor UUCP. */
#include "uucp.h"
+#include "uudefs.h"
#include "sysdep.h"
#include "fsusg.h"
-int statfs ();
-
#if STAT_STATFS2_BSIZE
#ifndef _IBMR2 /* 4.3BSD, SunOS 4, HP-UX, AIX PS/2. */
#include <sys/vfs.h>
@@ -52,16 +51,19 @@ int statfs ();
#endif
#endif
-#ifdef _AIX
-#ifdef _I386 /* AIX PS/2. */
+#if STAT_DUSTAT /* AIX PS/2. */
#include <sys/stat.h>
#include <sys/dustat.h>
#endif
-#endif
#if STAT_STATVFS /* SVR4. */
#include <sys/statvfs.h>
-int statvfs ();
+#endif
+
+#if STAT_DISK_SPACE /* QNX. */
+#include <sys/disk.h>
+#include <fcntl.h>
+#include <errno.h>
#endif
#define STAT_NONE 0
@@ -71,7 +73,9 @@ int statvfs ();
#if ! STAT_STATFS2_FSIZE
#if ! STAT_STATFS2_FS_DATA
#if ! STAT_STATFS4
+#if ! STAT_DUSTAT
#if ! STAT_USTAT
+#if ! STAT_DISK_SPACE
#undef STAT_NONE
#define STAT_NONE 1
#endif
@@ -80,9 +84,13 @@ int statvfs ();
#endif
#endif
#endif
+#endif
+#endif
#if ! STAT_NONE
+static long adjust_blocks P((long blocks, int fromsize, int tosize));
+
/* Return the number of TOSIZE-byte blocks used by
BLOCKS FROMSIZE-byte blocks, rounding up. */
@@ -121,7 +129,7 @@ get_fs_usage (path, disk, fsp)
if (statfs (path, &fsd) != 1)
return -1;
-#define convert_blocks(b) adjust_blocks ((b), 1024, 512)
+#define convert_blocks(b) adjust_blocks ((long) (b), 1024, 512)
fsp->fsu_blocks = convert_blocks (fsd.fd_req.btot);
fsp->fsu_bfree = convert_blocks (fsd.fd_req.bfree);
fsp->fsu_bavail = convert_blocks (fsd.fd_req.bfreen);
@@ -129,7 +137,7 @@ get_fs_usage (path, disk, fsp)
fsp->fsu_ffree = fsd.fd_req.gfree;
#endif
-#if STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX. */
+#if STAT_STATFS2_BSIZE || STAT_DUSTAT /* 4.3BSD, SunOS 4, HP-UX, AIX. */
struct statfs fsd;
if (statfs (path, &fsd) < 0)
@@ -169,23 +177,94 @@ get_fs_usage (path, disk, fsp)
adjust_blocks ((b), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
#endif
+#if STAT_DISK_SPACE /* QNX. */
+ int o;
+ int iret;
+ long cfree_blocks, ctotal_blocks;
+ char *zpath;
+ char *zslash;
+
+ zpath = zbufcpy (path);
+ while ((o = open (zpath, O_RDONLY, 0)) == -1
+ && errno == ENOENT)
+ {
+ /* The named file doesn't exist, so we can't open it. Try the
+ directory containing it. */
+ if ((strcmp ("/", zpath) == 0)
+ || (strcmp (zpath, ".") == 0)
+ || (strcmp (zpath, "") == 0)
+ /* QNX peculiarity: "//2" means root on node 2 */
+ || ((strncmp (zpath, "//", 2) == 0)
+ && (strchr (zpath + 2, '/') == NULL)))
+ {
+ /* We can't shorten this! */
+ break;
+ }
+
+ /* Shorten the pathname by one component and try again. */
+ zslash = strrchr (zpath, '/');
+ if (zslash == NULL)
+ {
+ /* Try the current directory. We can open directories. */
+ zpath[0] = '.';
+ zpath[1] = '\0';
+ }
+ else if (zslash == zpath)
+ {
+ /* Try the root directory. */
+ zpath[0] = '/';
+ zpath[1] = '\0';
+ }
+ else
+ {
+ /* Chop off last path component. */
+ zslash[0] = '\0';
+ }
+ }
+ if (o == -1)
+ {
+ ulog (LOG_ERROR, "get_fs_usage: open (%s) failed: %s", zpath,
+ strerror (errno));
+ ubuffree (zpath);
+ return -1;
+ }
+ ubuffree (zpath);
+
+ iret = disk_space (o, &cfree_blocks, &ctotal_blocks);
+ (void) close (o);
+ if (iret == -1)
+ {
+ ulog (LOG_ERROR, "get_fs_usage: disk_space failed: %s",
+ strerror (errno));
+ return -1;
+ }
+
+ fsp->fsu_blocks = ctotal_blocks;
+ fsp->fsu_bfree = cfree_blocks;
+ fsp->fsu_bavail = cfree_blocks;
+
+ /* QNX has no limit on the number of inodes. Most inodes are stored
+ directly in the directory entry. */
+ fsp->fsu_files = -1;
+ fsp->fsu_ffree = -1;
+#endif /* STAT_DISK_SPACE */
+
#if STAT_USTAT
- {
- struct stat sstat;
- struct ustat s;
+ struct stat sstat;
+ struct ustat s;
- if (stat (path, &sstat) < 0
- || ustat (sstat.st_dev, &s) < 0)
- return -1;
- fsp->fsu_blocks = -1;
- fsp->fsu_bfree = f_tfree;
- fsp->fsu_bavail = f_tfree;
- fsp->fsu_files = -1;
- fsp->fsu_ffree = -1;
- }
+ if (stat (path, &sstat) < 0
+ || ustat (sstat.st_dev, &s) < 0)
+ return -1;
+ fsp->fsu_blocks = -1;
+ fsp->fsu_bfree = s.f_tfree;
+ fsp->fsu_bavail = s.f_tfree;
+ fsp->fsu_files = -1;
+ fsp->fsu_ffree = -1;
#endif
#if ! STAT_STATFS2_FS_DATA /* ! Ultrix */
+#if ! STAT_DISK_SPACE
#if ! STAT_USTAT
#if ! STAT_NONE
fsp->fsu_blocks = convert_blocks (fsd.f_blocks);
@@ -196,12 +275,12 @@ get_fs_usage (path, disk, fsp)
#endif
#endif
#endif
+#endif
return 0;
}
-#ifdef _AIX
-#ifdef _I386
+#if STAT_DUSTAT
/* AIX PS/2 does not supply statfs. */
int
@@ -227,5 +306,4 @@ statfs (path, fsb)
fsb->f_fsid.val[1] = fsd.du_pckno;
return 0;
}
-#endif
-#endif /* _AIX && _I386 */
+#endif /* STAT_DUSTAT */
diff --git a/gnu/libexec/uucp/libunix/ftw.c b/gnu/libexec/uucp/libunix/ftw.c
index c3372b53ca48..c7af06e04f02 100644
--- a/gnu/libexec/uucp/libunix/ftw.c
+++ b/gnu/libexec/uucp/libunix/ftw.c
@@ -17,7 +17,7 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
-Modified by Ian Lanc Taylor for Taylor UUCP, June 1992. */
+Modified by Ian Lance Taylor for Taylor UUCP, June 1992, and October 1993. */
#include "uucp.h"
@@ -63,7 +63,7 @@ ftw_dir (dirs, level, descriptors, dir, len, func)
int descriptors;
char *dir;
size_t len;
- int (*func) P((const char *file, const struct stat *status, int flag));
+ int (*func) P((const char *file, struct stat *status, int flag));
{
int got;
struct dirent *entry;
@@ -177,7 +177,7 @@ ftw_dir (dirs, level, descriptors, dir, len, func)
int
ftw (dir, func, descriptors)
const char *dir;
- int (*func) P((const char *file, const struct stat *status, int flag));
+ int (*func) P((const char *file, struct stat *status, int flag));
int descriptors;
{
DIR **dirs;
@@ -234,7 +234,11 @@ ftw (dir, func, descriptors)
if (flag == FTW_D)
{
if (ret == 0)
- ret = ftw_dir (dirs, 0, descriptors, buf, len, func);
+ {
+ if (len == 1 && *buf == '/')
+ len = 0;
+ ret = ftw_dir (dirs, 0, descriptors, buf, len, func);
+ }
if (dirs[0] != NULL)
{
int save;
diff --git a/gnu/libexec/uucp/libunix/indir.c b/gnu/libexec/uucp/libunix/indir.c
index 2484ec23f85d..de1df702cc53 100644
--- a/gnu/libexec/uucp/libunix/indir.c
+++ b/gnu/libexec/uucp/libunix/indir.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/init.c b/gnu/libexec/uucp/libunix/init.c
index d4a137762813..95822db11684 100644
--- a/gnu/libexec/uucp/libunix/init.c
+++ b/gnu/libexec/uucp/libunix/init.c
@@ -1,7 +1,7 @@
/* init.c
Initialize the system dependent routines.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -153,35 +153,39 @@ usysdep_initialize (puuconf,iflags)
pointer puuconf;
int iflags;
{
- int cdescs;
- int o;
int iuuconf;
char *z;
struct passwd *q;
ulog_id (getpid ());
- /* Close everything but stdin, stdout and stderr. */
+ if ((iflags & INIT_NOCLOSE) == 0)
+ {
+ int cdescs;
+ int o;
+
+ /* Close everything but stdin, stdout and stderr. */
#if HAVE_GETDTABLESIZE
- cdescs = getdtablesize ();
+ cdescs = getdtablesize ();
#else
#if HAVE_SYSCONF
- cdescs = sysconf (_SC_OPEN_MAX);
+ cdescs = sysconf (_SC_OPEN_MAX);
#else
#ifdef OPEN_MAX
- cdescs = OPEN_MAX;
+ cdescs = OPEN_MAX;
#else
#ifdef NOFILE
- cdescs = NOFILE;
+ cdescs = NOFILE;
#else
- cdescs = 20;
+ cdescs = 20;
#endif /* ! defined (NOFILE) */
#endif /* ! defined (OPEN_MAX) */
#endif /* ! HAVE_SYSCONF */
#endif /* ! HAVE_GETDTABLESIZE */
- for (o = 3; o < cdescs; o++)
- (void) close (o);
+ for (o = 3; o < cdescs; o++)
+ (void) close (o);
+ }
/* Make sure stdin, stdout and stderr are open. */
if (fcntl (0, F_GETFD, 0) < 0
diff --git a/gnu/libexec/uucp/libunix/iswait.c b/gnu/libexec/uucp/libunix/iswait.c
index d2610aa1f8bd..aa855151c926 100644
--- a/gnu/libexec/uucp/libunix/iswait.c
+++ b/gnu/libexec/uucp/libunix/iswait.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/jobid.c b/gnu/libexec/uucp/libunix/jobid.c
index 7f22f1d37d75..c8b21cbcf21f 100644
--- a/gnu/libexec/uucp/libunix/jobid.c
+++ b/gnu/libexec/uucp/libunix/jobid.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/lcksys.c b/gnu/libexec/uucp/libunix/lcksys.c
index 4ece16afe7b5..c1b0efaa3b9e 100644
--- a/gnu/libexec/uucp/libunix/lcksys.c
+++ b/gnu/libexec/uucp/libunix/lcksys.c
@@ -8,20 +8,32 @@
#include "sysdep.h"
#include "system.h"
+/* Get the name of a system lock file. */
+
+static char *zssys_lock_name P((const struct uuconf_system *qsys, char *z));
+
+#define LOCKNAMELEN (sizeof "LCK..12345678")
+
+static char *
+zssys_lock_name (qsys, z)
+ const struct uuconf_system *qsys;
+ char *z;
+{
+ strcpy (z, "LCK..");
+ strncpy (z + sizeof "LCK.." - 1, qsys->uuconf_zname, 8);
+ z[sizeof "LCK.." - 1 + 8] = '\0';
+ return z;
+}
+
/* Lock a remote system. */
boolean
fsysdep_lock_system (qsys)
const struct uuconf_system *qsys;
{
- char *z;
- boolean fret;
-
- z = zbufalc (strlen (qsys->uuconf_zname) + sizeof "LCK..");
- sprintf (z, "LCK..%.8s", qsys->uuconf_zname);
- fret = fsdo_lock (z, FALSE, (boolean *) NULL);
- ubuffree (z);
- return fret;
+ char ab[LOCKNAMELEN];
+
+ return fsdo_lock (zssys_lock_name (qsys, ab), FALSE, (boolean *) NULL);
}
/* Unlock a remote system. */
@@ -30,12 +42,7 @@ boolean
fsysdep_unlock_system (qsys)
const struct uuconf_system *qsys;
{
- char *z;
- boolean fret;
-
- z = zbufalc (strlen (qsys->uuconf_zname) + sizeof "LCK..");
- sprintf (z, "LCK..%.8s", qsys->uuconf_zname);
- fret = fsdo_unlock (z, FALSE);
- ubuffree (z);
- return fret;
+ char ab[LOCKNAMELEN];
+
+ return fsdo_unlock (zssys_lock_name (qsys, ab), FALSE);
}
diff --git a/gnu/libexec/uucp/libunix/locfil.c b/gnu/libexec/uucp/libunix/locfil.c
index 0e05af9bcee9..1c4db66520a6 100644
--- a/gnu/libexec/uucp/libunix/locfil.c
+++ b/gnu/libexec/uucp/libunix/locfil.c
@@ -1,7 +1,7 @@
/* locfil.c
Expand a file name on the local system.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -41,12 +41,16 @@ extern struct passwd *getpwnam ();
and moving any other type of file into the public directory. */
char *
-zsysdep_local_file (zfile, zpubdir)
+zsysdep_local_file (zfile, zpubdir, pfbadname)
const char *zfile;
const char *zpubdir;
+ boolean *pfbadname;
{
const char *zdir;
+ if (pfbadname != NULL)
+ *pfbadname = FALSE;
+
if (*zfile == '/')
return zbufcpy (zfile);
@@ -79,6 +83,8 @@ zsysdep_local_file (zfile, zpubdir)
{
ulog (LOG_ERROR, "User %s not found", zcopy);
ubuffree (zcopy);
+ if (pfbadname != NULL)
+ *pfbadname = TRUE;
return NULL;
}
ubuffree (zcopy);
diff --git a/gnu/libexec/uucp/libunix/lock.c b/gnu/libexec/uucp/libunix/lock.c
index d823213017b6..4011534291d7 100644
--- a/gnu/libexec/uucp/libunix/lock.c
+++ b/gnu/libexec/uucp/libunix/lock.c
@@ -1,7 +1,7 @@
/* lock.c
Lock and unlock a file name.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/05 18:24:06 conklin Exp $";
+const char lock_rcsid[] = "$Id: lock.c,v 1.2 1994/05/07 18:10:40 ache Exp $";
#endif
#include "uudefs.h"
@@ -43,6 +43,19 @@ const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/05 18:24:06 conklin Exp $";
#endif
#endif
+#if TM_IN_SYS_TIME
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+
+#if HAVE_QNX_LOCKFILES
+#include <sys/kernel.h>
+#include <sys/psinfo.h>
+#include <sys/seginfo.h>
+#include <sys/vc.h>
+#endif
+
#ifndef O_RDONLY
#define O_RDONLY 0
#define O_WRONLY 1
@@ -56,6 +69,15 @@ const char lock_rcsid[] = "$Id: lock.c,v 1.1 1993/08/05 18:24:06 conklin Exp $";
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
+
+#ifndef localtime
+extern struct tm *localtime ();
+#endif
+
+#if HAVE_QNX_LOCKFILES
+static boolean fsqnx_stale P((unsigned long ipid, unsigned long inme,
+ unsigned long inid, boolean *pferr));
+#endif
/* Lock something. If the fspooldir argument is TRUE, the argument is
a file name relative to the spool directory; otherwise the argument
@@ -73,13 +95,19 @@ fsdo_lock (zlock, fspooldir, pferr)
size_t cslash;
pid_t ime;
char *ztempfile;
- char abtempfile[sizeof "TMP1234567890"];
+ char abtempfile[sizeof "TMP12345678901234567890"];
int o;
+#if HAVE_QNX_LOCKFILES
+ nid_t inme;
+ char ab[23];
+ char *zend;
+#else
#if HAVE_V2_LOCKFILES
int i;
#else
char ab[12];
#endif
+#endif
int cwrote;
const char *zerr;
boolean fret;
@@ -99,6 +127,9 @@ fsdo_lock (zlock, fspooldir, pferr)
}
ime = getpid ();
+#if HAVE_QNX_LOCKFILES
+ inme = getnid ();
+#endif
/* We do the actual lock by creating a file and then linking it to
the final file name we want. This avoids race conditions due to
@@ -114,7 +145,12 @@ fsdo_lock (zlock, fspooldir, pferr)
else
cslash = zslash - zpath + 1;
+#if HAVE_QNX_LOCKFILES
+ sprintf (abtempfile, "TMP%010lx%010lx", (unsigned long) ime,
+ (unsigned long) inme);
+#else
sprintf (abtempfile, "TMP%010lx", (unsigned long) ime);
+#endif
ztempfile = zbufalc (cslash + sizeof abtempfile);
memcpy (ztempfile, zpath, cslash);
memcpy (ztempfile + cslash, abtempfile, sizeof abtempfile);
@@ -141,13 +177,18 @@ fsdo_lock (zlock, fspooldir, pferr)
}
}
+#if HAVE_QNX_LOCKFILES
+ sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inid);
+ cwrote = write (o, ab, strlen (ab));
+#else
#if HAVE_V2_LOCKFILES
- i = ime;
+ i = (int) ime;
cwrote = write (o, &i, sizeof i);
#else
- sprintf (ab, "%10d\n", (int) ime);
+ sprintf (ab, "%10ld\n", (long) ime);
cwrote = write (o, ab, strlen (ab));
#endif
+#endif
zerr = NULL;
if (cwrote < 0)
@@ -177,8 +218,13 @@ fsdo_lock (zlock, fspooldir, pferr)
while (link (ztempfile, zpath) != 0)
{
int cgot;
- int ipid;
+ pid_t ipid;
boolean freadonly;
+ struct stat st;
+ char abtime[sizeof "1991-12-31 12:00:00"];
+#if HAVE_QNX_LOCKFILES
+ nid_t inid;
+#endif
fret = FALSE;
@@ -228,11 +274,17 @@ fsdo_lock (zlock, fspooldir, pferr)
break;
}
+#if HAVE_QNX_LOCKFILES
+ ab[cgot] = '\0';
+ ipid = (pid_t) strtol (ab, &zend, 10);
+ inid = (nid_t) strtol (zend, (char **) NULL, 10);
+#else
#if HAVE_V2_LOCKFILES
- ipid = i;
+ ipid = (pid_t) i;
#else
ab[cgot] = '\0';
- ipid = strtol (ab, (char **) NULL, 10);
+ ipid = (pid_t) strtol (ab, (char **) NULL, 10);
+#endif
#endif
/* On NFS, the link might have actually succeeded even though we
@@ -247,18 +299,49 @@ fsdo_lock (zlock, fspooldir, pferr)
going to worry about this possibility. */
if (ipid == ime)
{
- fret = TRUE;
- break;
+#if HAVE_QNX_LOCKFILES
+ if (inid == inme)
+#endif
+ {
+ fret = TRUE;
+ break;
+ }
}
+#if HAVE_QNX_LOCKFILES
+ if (! fsqnx_stale ((unsigned long) ipid, (unsigned long) inme,
+ (unsigned long) inid, pferr))
+ break;
+#else
/* If the process still exists, we will get EPERM rather than
ESRCH. We then return FALSE to indicate that we cannot make
the lock. */
if (kill (ipid, 0) == 0 || errno == EPERM)
break;
+#endif
- ulog (LOG_ERROR, "Found stale lock %s held by process %d",
- zpath, ipid);
+ if (fstat (o, &st) < 0)
+ strcpy (abtime, "unknown");
+ else
+ {
+ time_t itm;
+ struct tm *q;
+
+ itm = (time_t) st.st_mtime;
+ q = localtime (&itm);
+ sprintf (abtime, "%04d-%02d-%02d %02d:%02d:%02d",
+ q->tm_year + 1900, q->tm_mon + 1, q->tm_mday, q->tm_hour,
+ q->tm_min, q->tm_sec);
+ }
+
+#if HAVE_QNX_LOCKFILES
+ ulog (LOG_ERROR,
+ "Stale lock %s held by process %ld on node %ld created %s",
+ zpath, (long) ipid, (long) inid, abtime);
+#else
+ ulog (LOG_ERROR, "Stale lock %s held by process %ld created %s",
+ zpath, (long) ipid, abtime);
+#endif
/* This is a stale lock, created by a process that no longer
exists.
@@ -317,6 +400,7 @@ fsdo_lock (zlock, fspooldir, pferr)
(void) close (o);
o = -1;
(void) remove (zpath);
+ fret = TRUE;
continue;
}
@@ -326,13 +410,18 @@ fsdo_lock (zlock, fspooldir, pferr)
break;
}
+#if HAVE_QNX_LOCKFILES
+ sprintf (ab, "%10ld %10ld\n", (long) ime, (long) inid);
+ cwrote = write (o, ab, strlen (ab));
+#else
#if HAVE_V2_LOCKFILES
- i = ime;
+ i = (int) ime;
cwrote = write (o, &i, sizeof i);
#else
- sprintf (ab, "%10d\n", (int) ime);
+ sprintf (ab, "%10ld\n", (long) ime);
cwrote = write (o, ab, strlen (ab));
#endif
+#endif
if (cwrote < 0)
{
@@ -360,52 +449,63 @@ fsdo_lock (zlock, fspooldir, pferr)
break;
}
+#if HAVE_QNX_LOCKFILES
+ ab[cgot] = '\0';
+ ipid = (pid_t) strtol (ab, &zend, 10);
+ inid = (nid_t) strtol (zend, (char **) NULL, 10);
+#else
#if HAVE_V2_LOCKFILES
- ipid = i;
+ ipid = (pid_t) i;
#else
ab[cgot] = '\0';
- ipid = strtol (ab, (char **) NULL, 10);
+ ipid = (pid_t) strtol (ab, (char **) NULL, 10);
+#endif
#endif
if (ipid == ime)
{
- struct stat sfile, sdescriptor;
-
- /* It looks like we have the lock. Do the final stat
- check. */
- if (stat ((char *) zpath, &sfile) < 0)
- {
- if (errno != ENOENT)
- {
- zerr = "stat";
- break;
- }
- /* Loop around and try again. */
- }
- else
+#if HAVE_QNX_LOCKFILES
+ if (inid == inme)
+#endif
{
- if (fstat (o, &sdescriptor) < 0)
+ struct stat sfile, sdescriptor;
+
+ /* It looks like we have the lock. Do the final stat
+ check. */
+ if (stat ((char *) zpath, &sfile) < 0)
{
- zerr = "fstat";
- break;
+ if (errno != ENOENT)
+ {
+ zerr = "stat";
+ break;
+ }
+ /* Loop around and try again. */
}
-
- if (sfile.st_ino == sdescriptor.st_ino
- && sfile.st_dev == sdescriptor.st_dev)
+ else
{
- /* Close the file before assuming we've succeeded to
- pick up any trailing errors. */
- if (close (o) < 0)
+ if (fstat (o, &sdescriptor) < 0)
{
- zerr = "close";
+ zerr = "fstat";
break;
}
- o = -1;
-
- /* We have the lock. */
- fret = TRUE;
- break;
+ if (sfile.st_ino == sdescriptor.st_ino
+ && sfile.st_dev == sdescriptor.st_dev)
+ {
+ /* Close the file before assuming we've
+ succeeded to pick up any trailing errors. */
+ if (close (o) < 0)
+ {
+ zerr = "close";
+ break;
+ }
+
+ o = -1;
+
+ /* We have the lock. */
+ fret = TRUE;
+ break;
+ }
}
}
}
@@ -475,3 +575,90 @@ fsdo_unlock (zlock, fspooldir)
return FALSE;
}
}
+
+#if HAVE_QNX_LOCKFILES
+
+/* Return TRUE if the lock is stale. */
+
+static boolean
+fsqnx_stale (ipid, inme, inid, pferr)
+ unsigned long ipid;
+ unsigned long inme;
+ unsigned long inid;
+ boolean *pferr;
+{
+ /* A virtual process ID. This virtual process ID, which will exist
+ on the local node, will represent the process ID of the process
+ manager process (Proc) on the remote node. */
+ pid_t ivid;
+ /* The return value of the qnx_psinfo function. This is either a
+ process ID which might or might not be the same as the process
+ being looked for, or -1 to indicate no process found. */
+ pid_t ifound_pid;
+ /* This holds the actual result of qnx_psinfo. We will ignore
+ almost all the fields since we're just checking for existence. */
+ struct _psinfo spsdata;
+
+ /* Establish connection with a remote process manager if necessary. */
+ if (inid != inme)
+ {
+ ivid = qnx_vc_attach (inid /* remote node ID */,
+ PROC_PID /* pid of process manager */,
+ 1000 /* initial buffer size */,
+ 0 /* flags */);
+ if (ivid < 0)
+ {
+ ulog (LOG_ERROR, "qnx_vc_attach (%lu, PROC_PID): %s",
+ inid, strerror (errno));
+ if (pferr != NULL)
+ *pferr = TRUE;
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Use the local pid of the local process manager. */
+ ivid = PROC_PID;
+ }
+
+ /* Request the process information. */
+ ifound_pid = qnx_psinfo (ivid /* process manager handling request */,
+ ipid /* get info on this process */,
+ &spsdata /* put info in this struct */,
+ 0 /* unused */,
+ (struct _seginfo *) NULL /* unused */);
+
+ /* Deallocate the virtual connection before continuing. */
+ {
+ int isaved_errno = errno;
+ if (qnx_vc_detach (ivid) < 0)
+ ulog (LOG_ERROR, "qnx_vd_detach (%ld): %s", (long) ivid,
+ strerror (errno));
+ errno = isaved_errno;
+ }
+
+ /* If the returned pid matches then the process still holds the lock. */
+ if ((ifound_pid == ipid) && (spsdata.pid == ipid))
+ return FALSE;
+
+ /* If the returned pid is positive and doesn't match, then the
+ process doesn't exist and the lock is stale. Continue. */
+
+ /* If the returned pid is negative (-1) and errno is EINVAL (or ESRCH
+ in older versions of QNX), then the process doesn't exist and the
+ lock is stale. Continue. */
+
+ /* Check for impossible errors. */
+ if ((ifound_pid < 0) && (errno != ESRCH) && (errno != EINVAL))
+ {
+ ulog (LOG_ERROR, "qnx_psinfo (%ld, %ld): %s", (long) ivid,
+ (long) ipid, strerror (errno));
+ /* Since we don't know what the hell this means, and we don't
+ want our system to freeze, we treat this case as a stale
+ lock. Continue on. */
+ }
+
+ return TRUE;
+}
+
+#endif /* HAVE_QNX_LOCKFILES */
diff --git a/gnu/libexec/uucp/libunix/loctim.c b/gnu/libexec/uucp/libunix/loctim.c
index da5f32e2d273..7f1f87aa671c 100644
--- a/gnu/libexec/uucp/libunix/loctim.c
+++ b/gnu/libexec/uucp/libunix/loctim.c
@@ -3,7 +3,9 @@
#include "uucp.h"
-#if HAVE_TIME_H
+#if TM_IN_SYS_TIME
+#include <sys/time.h>
+#else
#include <time.h>
#endif
diff --git a/gnu/libexec/uucp/libunix/mail.c b/gnu/libexec/uucp/libunix/mail.c
index 74c1aa95adc6..e1fbaa92afee 100644
--- a/gnu/libexec/uucp/libunix/mail.c
+++ b/gnu/libexec/uucp/libunix/mail.c
@@ -1,7 +1,7 @@
/* mail.c
Send mail to a user.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -48,17 +48,47 @@ fsysdep_mail (zto, zsubject, cstrs, paz)
int cstrs;
const char **paz;
{
- const char *az[3];
+ char **pazargs;
+ char *zcopy, *ztok;
+ size_t cargs, iarg;
FILE *e;
pid_t ipid;
time_t itime;
int i;
- az[0] = MAIL_PROGRAM;
- az[1] = zto;
- az[2] = NULL;
+ /* Parse MAIL_PROGRAM into an array of arguments. */
+ zcopy = zbufcpy (MAIL_PROGRAM);
+
+ cargs = 0;
+ for (ztok = strtok (zcopy, " \t");
+ ztok != NULL;
+ ztok = strtok ((char *) NULL, " \t"))
+ ++cargs;
+
+ pazargs = (char **) xmalloc ((cargs + 4) * sizeof (char *));
+
+ memcpy (zcopy, MAIL_PROGRAM, sizeof MAIL_PROGRAM);
+ for (ztok = strtok (zcopy, " \t"), iarg = 0;
+ ztok != NULL;
+ ztok = strtok ((char *) NULL, " \t"), ++iarg)
+ pazargs[iarg] = ztok;
+
+#if ! MAIL_PROGRAM_SUBJECT_BODY
+ pazargs[iarg++] = (char *) "-s";
+ pazargs[iarg++] = (char *) zsubject;
+#endif
+
+#if ! MAIL_PROGRAM_TO_BODY
+ pazargs[iarg++] = (char *) zto;
+#endif
+
+ pazargs[iarg] = NULL;
+
+ e = espopen ((const char **) pazargs, FALSE, &ipid);
+
+ ubuffree (zcopy);
+ xfree ((pointer) pazargs);
- e = espopen (az, FALSE, &ipid);
if (e == NULL)
{
ulog (LOG_ERROR, "espopen (%s): %s", MAIL_PROGRAM,
@@ -66,10 +96,16 @@ fsysdep_mail (zto, zsubject, cstrs, paz)
return FALSE;
}
- fprintf (e, "Subject: %s\n", zsubject);
+#if MAIL_PROGRAM_TO_BODY
fprintf (e, "To: %s\n", zto);
+#endif
+#if MAIL_PROGRAM_SUBJECT_BODY
+ fprintf (e, "Subject: %s\n", zsubject);
+#endif
+#if MAIL_PROGRAM_TO_BODY || MAIL_PROGRAM_SUBJECT_BODY
fprintf (e, "\n");
+#endif
(void) time (&itime);
/* Remember that ctime includes a \n, so this skips a line. */
diff --git a/gnu/libexec/uucp/libunix/mkdir.c b/gnu/libexec/uucp/libunix/mkdir.c
index f59ad5dfd6e6..2546cbff1e46 100644
--- a/gnu/libexec/uucp/libunix/mkdir.c
+++ b/gnu/libexec/uucp/libunix/mkdir.c
@@ -38,7 +38,7 @@ mkdir (zdir, imode)
aidescs[1] = SPAWN_NULL;
aidescs[2] = SPAWN_NULL;
- ipid = ixsspawn (azargs, aidescs, FALSE, FALSE, (const char *) NULL,
+ ipid = ixsspawn (azargs, aidescs, TRUE, FALSE, (const char *) NULL,
TRUE, FALSE, (const char *) NULL,
(const char *) NULL, (const char *) NULL);
diff --git a/gnu/libexec/uucp/libunix/mkdirs.c b/gnu/libexec/uucp/libunix/mkdirs.c
index a4e0b67bb8c3..9b5b23ffd7b1 100644
--- a/gnu/libexec/uucp/libunix/mkdirs.c
+++ b/gnu/libexec/uucp/libunix/mkdirs.c
@@ -29,17 +29,19 @@ fsysdep_make_dirs (zfile, fpublic)
if (*z == '/' && z != zcopy)
{
*z = '\0';
- if (! fsysdep_directory (zcopy))
+ if (mkdir (zcopy, imode) != 0
+ && errno != EEXIST
+ && (errno != EACCES || ! fsysdep_directory (zcopy)))
{
- if (mkdir (zcopy, imode) != 0)
- {
- ulog (LOG_ERROR, "mkdir (%s): %s", zcopy,
- strerror (errno));
- ubuffree (zcopy);
- return FALSE;
- }
+ ulog (LOG_ERROR, "mkdir (%s): %s", zcopy,
+ strerror (errno));
+ ubuffree (zcopy);
+ return FALSE;
}
- *z = '/';
+ *z = '/'; /* replace '/' in its place */
+ /* now skips over multiple '/' in name */
+ while ( (*(z + 1)) && (*(z + 1)) == '/')
+ z++;
}
}
diff --git a/gnu/libexec/uucp/libunix/move.c b/gnu/libexec/uucp/libunix/move.c
index ccfe6d4d728d..3345bbfa04dc 100644
--- a/gnu/libexec/uucp/libunix/move.c
+++ b/gnu/libexec/uucp/libunix/move.c
@@ -1,7 +1,7 @@
/* move.c
Move a file.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -77,14 +77,12 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
if (stat (zcopy, &s) != 0)
{
ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno));
- (void) remove (zorig);
ubuffree (zcopy);
return FALSE;
}
if (! fsuser_access (&s, W_OK, zuser))
{
ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES));
- (void) remove (zorig);
ubuffree (zcopy);
return FALSE;
}
@@ -107,10 +105,7 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
if (fmkdirs && errno == ENOENT)
{
if (! fsysdep_make_dirs (zto, fpublic))
- {
- (void) remove (zorig);
- return FALSE;
- }
+ return FALSE;
if (rename (zorig, zto) == 0)
return TRUE;
}
@@ -127,7 +122,6 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
{
ulog (LOG_ERROR, "rename (%s, %s): %s", zorig, zto,
strerror (errno));
- (void) remove (zorig);
return FALSE;
}
@@ -135,7 +129,6 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
if (stat ((char *) zorig, &s) < 0)
{
ulog (LOG_ERROR, "stat (%s): %s", zorig, strerror (errno));
- (void) remove (zorig);
return FALSE;
}
@@ -148,26 +141,19 @@ fsysdep_move_file (zorig, zto, fmkdirs, fpublic, fcheck, zuser)
if (fmkdirs && errno == ENOENT)
{
if (! fsysdep_make_dirs (zto, fpublic))
- {
- (void) remove (zorig);
- return FALSE;
- }
+ return FALSE;
o = creat ((char *) zto, s.st_mode);
}
if (o < 0)
{
ulog (LOG_ERROR, "creat (%s): %s", zto, strerror (errno));
- (void) remove (zorig);
return FALSE;
}
}
(void) close (o);
if (! fcopy_file (zorig, zto, fpublic, fmkdirs))
- {
- (void) remove (zorig);
- return FALSE;
- }
+ return FALSE;
if (remove (zorig) != 0)
ulog (LOG_ERROR, "remove (%s): %s", zorig, strerror (errno));
diff --git a/gnu/libexec/uucp/libunix/opensr.c b/gnu/libexec/uucp/libunix/opensr.c
index 3a8ca7a8b8ac..15cd5cd13601 100644
--- a/gnu/libexec/uucp/libunix/opensr.c
+++ b/gnu/libexec/uucp/libunix/opensr.c
@@ -1,7 +1,7 @@
/* opensr.c
Open files for sending and receiving.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -131,16 +131,18 @@ esysdep_open_send (qsys, zfile, fcheck, zuser)
}
/* Get a temporary file name to receive into. We use the ztemp
- argument to pick the file name, so that we relocate the file if the
+ argument to pick the file name, so that we restart the file if the
transmission is aborted. */
char *
-zsysdep_receive_temp (qsys, zto, ztemp)
+zsysdep_receive_temp (qsys, zto, ztemp, frestart)
const struct uuconf_system *qsys;
const char *zto;
const char *ztemp;
+ boolean frestart;
{
- if (ztemp != NULL
+ if (frestart
+ && ztemp != NULL
&& *ztemp == 'D'
&& strcmp (ztemp, "D.0") != 0)
return zsappend3 (".Temp", qsys->uuconf_zname, ztemp);
@@ -148,6 +150,10 @@ zsysdep_receive_temp (qsys, zto, ztemp)
return zstemp_file (qsys);
}
+/* The number of seconds in one week. We must cast to long for this
+ to be calculated correctly on a machine with 16 bit ints. */
+#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60)
+
/* Open a temporary file to receive into. This should, perhaps, check
that we have write permission on the receiving directory, but it
doesn't. */
@@ -168,8 +174,10 @@ esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart)
that case, we may have already received some portion of this
file. */
o = -1;
- *pcrestart = -1;
- if (ztemp != NULL
+ if (pcrestart != NULL)
+ *pcrestart = -1;
+ if (pcrestart != NULL
+ && ztemp != NULL
&& *ztemp == 'D'
&& strcmp (ztemp, "D.0") != 0)
{
@@ -185,7 +193,7 @@ esysdep_open_receive (qsys, zto, ztemp, zreceive, pcrestart)
restarted, and they know about this issue, they can touch
it to bring it up to date. */
if (fstat (o, &s) < 0
- || s.st_mtime + 7 * 24 * 60 * 60 < time ((time_t *) NULL))
+ || s.st_mtime + SECS_PER_WEEK < time ((time_t *) NULL))
{
(void) close (o);
o = -1;
diff --git a/gnu/libexec/uucp/libunix/pause.c b/gnu/libexec/uucp/libunix/pause.c
index e774e0897bf2..8155db327260 100644
--- a/gnu/libexec/uucp/libunix/pause.c
+++ b/gnu/libexec/uucp/libunix/pause.c
@@ -29,7 +29,9 @@
#endif
#if HAVE_SELECT
+#if HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@@ -53,7 +55,7 @@ struct pollfd
#endif /* HAVE_POLL */
#if HAVE_TIME_H
-#if HAVE_SYS_TIME_AND_TIME_H || ! USE_SELECT_TIMER
+#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME
#include <time.h>
#endif
#endif
@@ -87,10 +89,10 @@ usysdep_pause ()
s.tv_sec = 0;
s.tv_usec = 500 * (long) 1000;
select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s);
-#endif /* USE_SELECT_TIMER */
+#endif /* HAVE_SELECT */
#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP
-#if ! USE_SELECT_TIMER && ! HAVE_POLL
+#if ! HAVE_SELECT && ! HAVE_POLL
sleep (1);
-#endif /* ! USE_SELECT_TIMER && ! HAVE_POLL */
+#endif /* ! HAVE_SELECT && ! HAVE_POLL */
#endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */
}
diff --git a/gnu/libexec/uucp/libunix/picksb.c b/gnu/libexec/uucp/libunix/picksb.c
index 4d8cc4b2f3b6..a1afd1b8ae59 100644
--- a/gnu/libexec/uucp/libunix/picksb.c
+++ b/gnu/libexec/uucp/libunix/picksb.c
@@ -1,7 +1,7 @@
/* picksb.c
System dependent routines for uupick.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char picksb_rcsid[] = "$Id: picksb.c,v 1.1 1993/08/05 18:24:15 conklin Exp $";
+const char picksb_rcsid[] = "$Id: picksb.c,v 1.2 1994/05/07 18:10:54 ache Exp $";
#endif
#include "uudefs.h"
@@ -203,18 +203,22 @@ fsysdep_uupick_free (zsystem, zpubdir)
/* Expand a local file name for uupick. */
char *
-zsysdep_uupick_local_file (zfile)
+zsysdep_uupick_local_file (zfile, pfbadname)
const char *zfile;
+ boolean *pfbadname;
{
struct passwd *q;
+ if (pfbadname != NULL)
+ *pfbadname = FALSE;
+
/* If this does not start with a simple ~, pass it to
zsysdep_local_file_cwd; as it happens, zsysdep_local_file_cwd
only uses the zpubdir argument if the file starts with a simple
~, so it doesn't really matter what we pass for zpubdir. */
if (zfile[0] != '~'
|| (zfile[1] != '/' && zfile[1] != '\0'))
- return zsysdep_local_file_cwd (zfile, (const char *) NULL);
+ return zsysdep_local_file_cwd (zfile, (const char *) NULL, pfbadname);
q = getpwuid (getuid ());
if (q == NULL)
diff --git a/gnu/libexec/uucp/libunix/pipe.c b/gnu/libexec/uucp/libunix/pipe.c
new file mode 100644
index 000000000000..80e9e7f61bd4
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/pipe.c
@@ -0,0 +1,294 @@
+/* pipe.c
+ The pipe port communication routines for Unix.
+ Contributed by Marc Boucher <marc@CAM.ORG>.
+
+ Copyright (C) 1993 Ian Lance Taylor
+
+ This file is part of the Taylor UUCP package.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ The author of the program may be contacted at ian@airs.com or
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ */
+
+#include "uucp.h"
+
+#if USE_RCS_ID
+const char pipe_rcsid[] = "$Id: pipe.c,v 1.1 1994/05/07 18:10:56 ache Exp $";
+#endif
+
+#include "uudefs.h"
+#include "uuconf.h"
+#include "system.h"
+#include "conn.h"
+#include "sysdep.h"
+
+#include <errno.h>
+
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#else
+#if HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#endif
+
+/* Local functions. */
+
+static void uspipe_free P((struct sconnection *qconn));
+static boolean fspipe_open P((struct sconnection *qconn, long ibaud,
+ boolean fwait));
+static boolean fspipe_close P((struct sconnection *qconn,
+ pointer puuconf,
+ struct uuconf_dialer *qdialer,
+ boolean fsuccess));
+static boolean fspipe_dial P((struct sconnection *qconn, pointer puuconf,
+ const struct uuconf_system *qsys,
+ const char *zphone,
+ struct uuconf_dialer *qdialer,
+ enum tdialerfound *ptdialer));
+
+/* The command table for standard input ports. */
+
+static const struct sconncmds spipecmds =
+{
+ uspipe_free,
+ NULL, /* pflock */
+ NULL, /* pfunlock */
+ fspipe_open,
+ fspipe_close,
+ fspipe_dial,
+ fsdouble_read,
+ fsdouble_write,
+ fsysdep_conn_io,
+ NULL, /* pfbreak */
+ NULL, /* pfset */
+ NULL, /* pfcarrier */
+ fsdouble_chat,
+ NULL /* pibaud */
+};
+
+/* Initialize a pipe connection. */
+
+boolean
+fsysdep_pipe_init (qconn)
+ struct sconnection *qconn;
+{
+ struct ssysdep_conn *q;
+
+ q = (struct ssysdep_conn *) xmalloc (sizeof (struct ssysdep_conn));
+ q->o = -1;
+ q->ord = -1;
+ q->owr = -1;
+ q->zdevice = NULL;
+ q->iflags = -1;
+ q->iwr_flags = -1;
+ q->fterminal = FALSE;
+ q->ftli = FALSE;
+ q->ibaud = 0;
+ q->ipid = -1;
+ qconn->psysdep = (pointer) q;
+ qconn->qcmds = &spipecmds;
+ return TRUE;
+}
+
+static void
+uspipe_free (qconn)
+ struct sconnection *qconn;
+{
+ xfree (qconn->psysdep);
+}
+
+/* Open a pipe port. */
+
+/*ARGSUSED*/
+static boolean
+fspipe_open (qconn, ibaud, fwait)
+ struct sconnection *qconn;
+ long ibaud;
+ boolean fwait;
+{
+ /* We don't do incoming waits on pipes. */
+ if (fwait)
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Close a pipe port. */
+
+/*ARGSUSED*/
+static boolean
+fspipe_close (qconn, puuconf, qdialer, fsuccess)
+ struct sconnection *qconn;
+ pointer puuconf;
+ struct uuconf_dialer *qdialer;
+ boolean fsuccess;
+{
+ struct ssysdep_conn *qsysdep;
+ boolean fret;
+
+ qsysdep = (struct ssysdep_conn *) qconn->psysdep;
+ fret = TRUE;
+
+ /* Close our sides of the pipe. */
+ if (qsysdep->ord >= 0 && close (qsysdep->ord) < 0)
+ {
+ ulog (LOG_ERROR, "fspipe_close: close read fd: %s", strerror (errno));
+ fret = FALSE;
+ }
+ if (qsysdep->owr != qsysdep->ord
+ && qsysdep->owr >= 0
+ && close (qsysdep->owr) < 0)
+ {
+ ulog (LOG_ERROR, "fspipe_close: close write fd: %s", strerror (errno));
+ fret = FALSE;
+ }
+ qsysdep->ord = -1;
+ qsysdep->owr = -1;
+
+ /* Kill dangling child process. */
+ if (qsysdep->ipid >= 0)
+ {
+ if (kill (qsysdep->ipid, SIGHUP) == 0)
+ usysdep_sleep (2);
+#ifdef SIGPIPE
+ if (kill (qsysdep->ipid, SIGPIPE) == 0)
+ usysdep_sleep (2);
+#endif
+ if (kill (qsysdep->ipid, SIGKILL) < 0 && errno == EPERM)
+ {
+ ulog (LOG_ERROR, "fspipe_close: Cannot kill child pid %lu: %s",
+ (unsigned long) qsysdep->ipid, strerror (errno));
+ fret = FALSE;
+ }
+ else
+ (void) ixswait ((unsigned long) qsysdep->ipid, (const char *) NULL);
+ }
+ qsysdep->ipid = -1;
+ return fret;
+}
+
+/* Dial out on a pipe port, so to speak: launch connection program
+ under us. The code alternates q->o between q->ord and q->owr as
+ appropriate. It is always q->ord before any call to fsblock. */
+
+/*ARGSUSED*/
+static boolean
+fspipe_dial (qconn, puuconf, qsys, zphone, qdialer, ptdialer)
+ struct sconnection *qconn;
+ pointer puuconf;
+ const struct uuconf_system *qsys;
+ const char *zphone;
+ struct uuconf_dialer *qdialer;
+ enum tdialerfound *ptdialer;
+{
+ struct ssysdep_conn *q;
+ int aidescs[3];
+ const char **pzprog;
+
+ q = (struct ssysdep_conn *) qconn->psysdep;
+
+ *ptdialer = DIALERFOUND_FALSE;
+
+ pzprog = (const char **) qconn->qport->uuconf_u.uuconf_spipe.uuconf_pzcmd;
+
+ if (pzprog == NULL)
+ {
+ ulog (LOG_ERROR, "No command for pipe connection");
+ return FALSE;
+ }
+
+ aidescs[0] = SPAWN_WRITE_PIPE;
+ aidescs[1] = SPAWN_READ_PIPE;
+ aidescs[2] = SPAWN_NULL;
+
+ /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the
+ responsibility of security on the connection program. */
+ q->ipid = ixsspawn (pzprog, aidescs, TRUE, TRUE, (const char *) NULL,
+ FALSE, TRUE, (const char *) NULL,
+ (const char *) NULL, (const char *) NULL);
+ if (q->ipid < 0)
+ {
+ ulog (LOG_ERROR, "ixsspawn (%s): %s", pzprog[0], strerror (errno));
+ return FALSE;
+ }
+
+ q->owr = aidescs[0];
+ q->ord = aidescs[1];
+ q->o = q->ord;
+
+ q->iflags = fcntl (q->ord, F_GETFL, 0);
+ q->iwr_flags = fcntl (q->owr, F_GETFL, 0);
+ if (q->iflags < 0 || q->iwr_flags < 0)
+ {
+ ulog (LOG_ERROR, "fspipe_dial: fcntl: %s", strerror (errno));
+ (void) fspipe_close (qconn, puuconf, qdialer, FALSE);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#if 0
+
+/* Marc Boucher's contributed code used an alarm to avoid waiting too
+ long when closing the pipe. However, I believe that it is not
+ possible for the kernel to sleep when closing a pipe; it is only
+ possible when closing a device. Therefore, I have removed the
+ code, but am preserving it in case I am wrong. To reenable it, the
+ two calls to close in fspipe_close should be changed to call
+ fspipe_alarmclose. */
+
+static RETSIGTYPE
+usalarm (isig)
+ int isig;
+{
+#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET
+ (void) signal (isig, usalarm);
+#endif
+
+#if HAVE_RESTARTABLE_SYSCALLS
+ longjmp (sSjmp_buf, 1);
+#endif
+}
+
+static int
+fspipe_alarmclose (fd)
+ int fd;
+{
+ int iret = -1;
+ int ierrno = 0;
+
+ if (fsysdep_catch ())
+ {
+ usysdep_start_catch ();
+ usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL);
+ (void) alarm (30);
+
+ iret = close (fd);
+ ierrno = errno;
+ }
+
+ usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL);
+ (void) alarm (0);
+ usysdep_end_catch ();
+
+ errno = ierrno;
+ return iret;
+}
+
+#endif /* 0 */
diff --git a/gnu/libexec/uucp/libunix/priv.c b/gnu/libexec/uucp/libunix/priv.c
new file mode 100644
index 000000000000..207bd3dbbb9d
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/priv.c
@@ -0,0 +1,24 @@
+/* priv.c
+ See if a user is privileged. */
+
+#include "uucp.h"
+
+#include "sysdep.h"
+#include "system.h"
+
+/* See whether the user is privileged (for example, only privileged
+ users are permitted to kill arbitrary jobs with uustat). This is
+ true only for root and uucp. We check for uucp by seeing if the
+ real user ID and the effective user ID are the same; this works
+ because we should be suid to uucp, so our effective user ID will
+ always be uucp while our real user ID will be whoever ran the
+ program. */
+
+boolean
+fsysdep_privileged ()
+{
+ uid_t iuid;
+
+ iuid = getuid ();
+ return iuid == 0 || iuid == geteuid ();
+}
diff --git a/gnu/libexec/uucp/libunix/proctm.c b/gnu/libexec/uucp/libunix/proctm.c
index 55cf96f0c972..b9b6eb9e4afc 100644
--- a/gnu/libexec/uucp/libunix/proctm.c
+++ b/gnu/libexec/uucp/libunix/proctm.c
@@ -1,7 +1,7 @@
/* proctm.c
Get the time spent in the process.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -48,7 +48,7 @@
#define HAVE_FTIME 0
#endif
-#if HAVE_TIME_H && (HAVE_SYS_TIME_AND_TIME_H || ! HAVE_GETTIMEOFDAY)
+#if HAVE_TIME_H && (TIME_WITH_SYS_TIME || ! HAVE_GETTIMEOFDAY)
#include <time.h>
#endif
diff --git a/gnu/libexec/uucp/libunix/recep.c b/gnu/libexec/uucp/libunix/recep.c
index 84a211a7a946..152fd0d0ba1f 100644
--- a/gnu/libexec/uucp/libunix/recep.c
+++ b/gnu/libexec/uucp/libunix/recep.c
@@ -1,7 +1,7 @@
/* recep.c
See whether a file has already been received.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -103,7 +103,7 @@ fsysdep_remember_reception (qsys, zto, ztemp)
{
if (errno == ENOENT)
{
- if (fsysdep_make_dirs (zfile, TRUE))
+ if (fsysdep_make_dirs (zfile, FALSE))
{
ubuffree (zfile);
return FALSE;
@@ -133,6 +133,10 @@ fsysdep_remember_reception (qsys, zto, ztemp)
return TRUE;
}
+/* The number of seconds in one week. We must cast to long for this
+ to be calculated correctly on a machine with 16 bit ints. */
+#define SECS_PER_WEEK ((long) 7 * (long) 24 * (long) 60 * (long) 60)
+
/* See if we have already received a file. Note that don't delete the
marker file here, because we need to know that the sending system
has received our denial first. This function returns TRUE if the
@@ -161,7 +165,7 @@ fsysdep_already_received (qsys, zto, ztemp)
}
/* Ignore the file (return FALSE) if it is over one week old. */
- fret = s.st_mtime + 7 * 24 * 60 * 60 >= time ((time_t *) NULL);
+ fret = s.st_mtime + SECS_PER_WEEK >= time ((time_t *) NULL);
if (fret)
DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, "fsysdep_already_received: Found %s",
diff --git a/gnu/libexec/uucp/libunix/run.c b/gnu/libexec/uucp/libunix/run.c
index e21919628372..af9b078d3bd9 100644
--- a/gnu/libexec/uucp/libunix/run.c
+++ b/gnu/libexec/uucp/libunix/run.c
@@ -1,7 +1,7 @@
/* run.c
Run a program.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -31,13 +31,11 @@
#include <errno.h>
-/* Start up a new program and end the current one. We don't have to
- worry about SIGHUP because the current process is either not a
- process group leader (uucp, uux) or it does not have a controlling
- terminal (uucico). */
+/* Start up a new program. */
boolean
-fsysdep_run (zprogram, zarg1, zarg2)
+fsysdep_run (ffork, zprogram, zarg1, zarg2)
+ boolean ffork;
const char *zprogram;
const char *zarg1;
const char *zarg2;
@@ -47,6 +45,40 @@ fsysdep_run (zprogram, zarg1, zarg2)
int aidescs[3];
pid_t ipid;
+ /* If we are supposed to fork, fork and then spawn so that we don't
+ have to worry about zombie processes. */
+ if (ffork)
+ {
+ ipid = ixsfork ();
+ if (ipid < 0)
+ {
+ ulog (LOG_ERROR, "fork: %s", strerror (errno));
+ return FALSE;
+ }
+
+ if (ipid != 0)
+ {
+ /* This is the parent. Wait for the child we just forked to
+ exit (below) and return. */
+ (void) ixswait ((unsigned long) ipid, (const char *) NULL);
+
+ /* Force the log files to be reopened in case the child just
+ output any error messages and stdio doesn't handle
+ appending correctly. */
+ ulog_close ();
+
+ return TRUE;
+ }
+
+ /* This is the child. Detach from the terminal to avoid any
+ unexpected SIGHUP signals. At this point we are definitely
+ not a process group leader, so usysdep_detach will not fork
+ again. */
+ usysdep_detach ();
+
+ /* Now spawn the program and then exit. */
+ }
+
zlib = zbufalc (sizeof SBINDIR + sizeof "/" + strlen (zprogram));
sprintf (zlib, "%s/%s", SBINDIR, zprogram);
@@ -65,11 +97,17 @@ fsysdep_run (zprogram, zarg1, zarg2)
FALSE, TRUE, (const char *) NULL,
(const char *) NULL, (const char *) NULL);
ubuffree (zlib);
+
if (ipid < 0)
{
ulog (LOG_ERROR, "ixsspawn: %s", strerror (errno));
+ if (ffork)
+ _exit (EXIT_FAILURE);
return FALSE;
}
+ if (ffork)
+ _exit (EXIT_SUCCESS);
+
return TRUE;
}
diff --git a/gnu/libexec/uucp/libunix/seq.c b/gnu/libexec/uucp/libunix/seq.c
index 2e01233022a9..5188510b6128 100644
--- a/gnu/libexec/uucp/libunix/seq.c
+++ b/gnu/libexec/uucp/libunix/seq.c
@@ -1,7 +1,7 @@
/* seq.c
Get and increment the conversation sequence number for a system.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c
index cee90fcc7bb3..cfa28d075a07 100644
--- a/gnu/libexec/uucp/libunix/serial.c
+++ b/gnu/libexec/uucp/libunix/serial.c
@@ -1,7 +1,7 @@
/* serial.c
The serial port communication routines for Unix.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char serial_rcsid[] = "$Id: serial.c,v 1.3 1994/02/07 23:47:51 ache Exp $";
+const char serial_rcsid[] = "$Id: serial.c,v 1.4 1994/05/07 18:11:09 ache Exp $";
#endif
#include "uudefs.h"
@@ -78,19 +78,21 @@ const char serial_rcsid[] = "$Id: serial.c,v 1.3 1994/02/07 23:47:51 ache Exp $"
#define FD_CLOEXEC 1
#endif
-#if HAVE_SYS_IOCTL_H
+#if HAVE_SYS_IOCTL_H || HAVE_TXADDCD
#include <sys/ioctl.h>
#endif
#if HAVE_BSD_TTY
+#if HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#endif
#if HAVE_TIME_H
-#if HAVE_SYS_TIME_AND_TIME_H || ! HAVE_BSD_TTY
+#if ! HAVE_SYS_TIME_H || ! HAVE_BSD_TTY || TIME_WITH_SYS_TIME
#include <time.h>
#endif
#endif
@@ -117,6 +119,10 @@ const char serial_rcsid[] = "$Id: serial.c,v 1.3 1994/02/07 23:47:51 ache Exp $"
#endif /* ! MAJOR_IN_MKDEV && ! MAJOR_IN_SYSMACROS */
#endif /* HAVE_SVR4_LOCKFILES */
+#if HAVE_DEV_INFO
+#include <sys/dev.h>
+#endif
+
/* Get definitions for both O_NONBLOCK and O_NDELAY. */
#ifndef O_NDELAY
#ifdef FNDELAY
@@ -180,38 +186,46 @@ extern int t_nerr;
/* Determine bits to clear for the various terminal control fields for
HAVE_SYSV_TERMIO and HAVE_POSIX_TERMIOS. */
+
+/* These fields are defined on some systems, and I am told that it
+ does not hurt to clear them, and it sometimes helps. */
+#ifndef IMAXBEL
+#define IMAXBEL 0
+#endif
+
+#ifndef PENDIN
+#define PENDIN 0
+#endif
+
#if HAVE_SYSV_TERMIO
#define ICLEAR_IFLAG (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK \
| ISTRIP | INLCR | IGNCR | ICRNL | IUCLC \
- | IXON | IXANY | IXOFF)
+ | IXON | IXANY | IXOFF | IMAXBEL)
#define ICLEAR_OFLAG (OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET \
| OFILL | OFDEL | NLDLY | CRDLY | TABDLY | BSDLY \
| VTDLY | FFDLY)
-#define ICLEAR_CFLAG (CBAUD | CLOCAL | CSIZE | PARENB | PARODD)
+#define ICLEAR_CFLAG (CBAUD | CSIZE | PARENB | PARODD)
#define ISET_CFLAG (CS8 | CREAD | HUPCL)
#define ICLEAR_LFLAG (ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK \
- | ECHONL | NOFLSH)
+ | ECHONL | NOFLSH | PENDIN)
#endif
#if HAVE_POSIX_TERMIOS
-#ifdef IMAXBEL
-#define CI_ADD1 IMAXBEL
-#else
-#define CI_ADD1 0
-#endif
#define ICLEAR_IFLAG (BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR \
| INLCR | INPCK | ISTRIP | IXOFF | IXON \
- | PARMRK | CI_ADD1)
+ | PARMRK | IMAXBEL)
#define ICLEAR_OFLAG (OPOST)
-#define ICLEAR_CFLAG (CLOCAL | CSIZE | PARENB | PARODD)
+#define ICLEAR_CFLAG (CSIZE | PARENB | PARODD)
#define ISET_CFLAG (CS8 | CREAD | HUPCL)
-#ifdef PENDIN
-#define CL_ADD1 PENDIN
-#else
-#define CL_ADD1 0
-#endif
#define ICLEAR_LFLAG (ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN \
- | ISIG | NOFLSH | TOSTOP | CL_ADD1)
+ | ISIG | NOFLSH | TOSTOP | PENDIN)
#endif
+
+enum tclocal_setting
+{
+ SET_CLOCAL,
+ CLEAR_CLOCAL,
+ IGNORE_CLOCAL
+};
/* Local functions. */
@@ -226,7 +240,7 @@ static boolean fsserial_lock P((struct sconnection *qconn,
boolean fin));
static boolean fsserial_unlock P((struct sconnection *qconn));
static boolean fsserial_open P((struct sconnection *qconn, long ibaud,
- boolean fwait));
+ boolean fwait, enum tclocal_setting tlocal));
static boolean fsstdin_open P((struct sconnection *qconn, long ibaud,
boolean fwait));
static boolean fsmodem_open P((struct sconnection *qconn, long ibaud,
@@ -247,13 +261,6 @@ static boolean fsdirect_close P((struct sconnection *qconn,
pointer puuconf,
struct uuconf_dialer *qdialer,
boolean fsuccess));
-static boolean fsserial_reset P((struct sconnection *qconn));
-static boolean fsstdin_reset P((struct sconnection *qconn));
-static boolean fsstdin_read P((struct sconnection *qconn,
- char *zbuf, size_t *pclen, size_t cmin,
- int ctimeout, boolean freport));
-static boolean fsstdin_write P((struct sconnection *qconn,
- const char *zwrite, size_t cwrite));
static boolean fsserial_break P((struct sconnection *qconn));
static boolean fsstdin_break P((struct sconnection *qconn));
static boolean fsserial_set P((struct sconnection *qconn,
@@ -266,9 +273,9 @@ static boolean fsstdin_set P((struct sconnection *qconn,
enum txonxoffsetting txonxoff));
static boolean fsmodem_carrier P((struct sconnection *qconn,
boolean fcarrier));
+static boolean fsserial_hardflow P((struct sconnection *qconn,
+ boolean fhardflow));
static boolean fsrun_chat P((int oread, int owrite, char **pzprog));
-static boolean fsstdin_chat P((struct sconnection *qconn,
- char **pzprog));
static long isserial_baud P((struct sconnection *qconn));
/* The command table for standard input ports. */
@@ -280,15 +287,14 @@ static const struct sconncmds sstdincmds =
NULL, /* pfunlock */
fsstdin_open,
fsstdin_close,
- fsstdin_reset,
NULL, /* pfdial */
- fsstdin_read,
- fsstdin_write,
+ fsdouble_read,
+ fsdouble_write,
fsysdep_conn_io,
fsstdin_break,
fsstdin_set,
NULL, /* pfcarrier */
- fsstdin_chat,
+ fsdouble_chat,
isserial_baud
};
@@ -301,7 +307,6 @@ static const struct sconncmds smodemcmds =
fsserial_unlock,
fsmodem_open,
fsmodem_close,
- fsserial_reset,
fmodem_dial,
fsysdep_conn_read,
fsysdep_conn_write,
@@ -322,7 +327,6 @@ static const struct sconncmds sdirectcmds =
fsserial_unlock,
fsdirect_open,
fsdirect_close,
- fsserial_reset,
NULL, /* pfdial */
fsysdep_conn_read,
fsysdep_conn_write,
@@ -499,6 +503,8 @@ fsserial_init (qconn, qcmds, zdevice)
q->zdevice[sizeof "/dev/" + clen - 1] = '\0';
}
q->o = -1;
+ q->ord = -1;
+ q->owr = -1;
q->ftli = FALSE;
qconn->psysdep = (pointer) q;
qconn->qcmds = qcmds;
@@ -548,6 +554,12 @@ usserial_free (qconn)
qconn->psysdep = NULL;
}
+#if HAVE_SEQUENT_LOCKFILES
+#define LCK_TEMPLATE "LCK..tty"
+#else
+#define LCK_TEMPLATE "LCK.."
+#endif
+
/* This routine is used for both locking and unlocking. It is the
only routine which knows how to translate a device name into the
name of a lock file. If it can't figure out a name, it does
@@ -571,6 +583,39 @@ fsserial_lockfile (flok, qconn)
zalc = NULL;
if (z == NULL)
{
+#if HAVE_QNX_LOCKFILES
+ {
+ nid_t idevice_nid;
+ char abdevice_nid[13]; /* length of long, a period, and a NUL */
+ size_t cdevice_nid;
+ const char *zbase;
+ size_t clen;
+
+ /* If the node ID is explicitly specified as part of the
+ pathname to the device, use that. Otherwise, presume the
+ device is local to the current node. */
+ if (qsysdep->zdevice[0] == '/' && qsysdep->zdevice[1] == '/')
+ idevice_nid = (nid_t) strtol (qsysdep->zdevice + 2,
+ (char **) NULL, 10);
+ else
+ idevice_nid = getnid ();
+
+ sprintf (abdevice_nid, "%ld.", (long) idevice_nid);
+ cdevice_nid = strlen (abdevice_nid);
+
+ zbase = strrchr (qsysdep->zdevice, '/') + 1;
+ clen = strlen (zbase);
+
+ zalc = zbufalc (sizeof LCK_TEMPLATE + cdevice_nid + clen);
+
+ memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1);
+ memcpy (zalc + sizeof LCK_TEMPLATE - 1, abdevice_nid, cdevice_nid);
+ memcpy (zalc + sizeof LCK_TEMPLATE - 1 + cdevice_nid,
+ zbase, clen + 1);
+
+ z = zalc;
+ }
+#else /* ! HAVE_QNX_LOCKFILES */
#if ! HAVE_SVR4_LOCKFILES
{
const char *zbase;
@@ -578,22 +623,21 @@ fsserial_lockfile (flok, qconn)
zbase = strrchr (qsysdep->zdevice, '/') + 1;
clen = strlen (zbase);
- zalc = zbufalc (sizeof "LCK.." + clen);
- memcpy (zalc, "LCK..", sizeof "LCK.." - 1);
- memcpy (zalc + sizeof "LCK.." - 1, zbase, clen + 1);
+ zalc = zbufalc (sizeof LCK_TEMPLATE + clen);
+ memcpy (zalc, LCK_TEMPLATE, sizeof LCK_TEMPLATE - 1);
+ memcpy (zalc + sizeof LCK_TEMPLATE - 1, zbase, clen + 1);
#if HAVE_SCO_LOCKFILES
{
char *zl;
- for (zl = zalc + sizeof "LCK.." - 1; *zl != '\0'; zl++)
+ for (zl = zalc + sizeof LCK_TEMPLATE - 1; *zl != '\0'; zl++)
if (isupper (*zl))
*zl = tolower (*zl);
}
#endif
z = zalc;
}
-#else /* ! HAVE_SVR4_LOCKFILES */
-#if HAVE_SVR4_LOCKFILES
+#else /* HAVE_SVR4_LOCKFILES */
{
struct stat s;
@@ -608,10 +652,8 @@ fsserial_lockfile (flok, qconn)
major (s.st_rdev), minor (s.st_rdev));
z = zalc;
}
-#else /* ! HAVE_SVR4_LOCKFILES */
- z = strrchr (qsysdep->zdevice, '/') + 1;
-#endif /* ! HAVE_SVR4_LOCKFILES */
-#endif /* ! HAVE_SVR4_LOCKFILES */
+#endif /* HAVE_SVR4_LOCKFILES */
+#endif /* ! HAVE_QNX_LOCKFILES */
}
if (flok)
@@ -624,13 +666,15 @@ fsserial_lockfile (flok, qconn)
{
if (flok)
{
- if (lockttyexist (z))
+ if (lockttyexist (z + sizeof LCK_TEMPLATE - 1))
{
- ulog (LOG_NORMAL, "%s: port already locked", z+5);
+ ulog (LOG_NORMAL, "%s: port already locked",
+ z + sizeof LCK_TEMPLATE - 1);
fret = FALSE;
}
else
- fret = !(fscoherent_disable_tty (z, &qsysdep->zenable));
+ fret = fscoherent_disable_tty (z + sizeof LCK_TEMPLATE - 1,
+ &qsysdep->zenable);
}
else
{
@@ -689,7 +733,7 @@ fsserial_lock (qconn, fin)
if (! fsserial_lockfile (TRUE, qconn))
return FALSE;
-#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL
+#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL || HAVE_DEV_INFO
/* Open the line and try to mark it in use. */
{
struct ssysdep_conn *qsysdep;
@@ -740,6 +784,38 @@ fsserial_lock (qconn, fin)
}
#endif
+#if HAVE_DEV_INFO
+ /* QNX programs "lock" a serial port by simply opening it and
+ checking if some other program also has the port open. If the
+ count of openers is greater than one, the program presumes the
+ port is "locked" and backs off. This isn't really "locking" of
+ course, but it pretty much seems to work. This can result in
+ dropping incoming connections if an outgoing connection is
+ started at exactly the same time. It would probably be better
+ to stop using the lock files at all for this case, but that
+ would involve more complex changes to the code, and I'm afraid
+ I would break something. -- Joe Wells <jbw@cs.bu.edu> */
+ {
+ struct _dev_info_entry sdevinfo;
+
+ if (dev_info (qsysdep->o, &sdevinfo) == -1)
+ {
+ ulog (LOG_ERROR, "dev_info: %s", strerror (errno));
+ sdevinfo.open_count = 2; /* force presumption of "locked" */
+ }
+ if (sdevinfo.open_count != 1)
+ {
+#ifdef TIOCNOTTY
+ (void) ioctl (qsysdep->o, TIOCNOTTY, (char *) NULL);
+#endif /* TIOCNOTTY */
+ (void) close (qsysdep->o);
+ qsysdep->o = -1;
+ (void) fsserial_lockfile (FALSE, qconn);
+ return FALSE;
+ }
+ }
+#endif /* HAVE_DEV_INFO */
+
if (fcntl (qsysdep->o, F_SETFD,
fcntl (qsysdep->o, F_GETFD, 0) | FD_CLOEXEC) < 0)
{
@@ -752,11 +828,6 @@ fsserial_lock (qconn, fin)
(void) fsserial_lockfile (FALSE, qconn);
return FALSE;
}
-
-#ifdef TIOCSCTTY
- /* On BSD 4.4, make it our controlling terminal. */
- (void) ioctl (qsysdep->o, TIOCSCTTY, 0);
-#endif
}
#endif /* HAVE_TIOCSINUSE || HAVE_TIOCEXCL */
@@ -796,8 +867,7 @@ fsserial_unlock (qconn)
return fret;
}
-/* Open a serial line. This sets the terminal settings. We begin in
- seven bit mode and let the protocol change if necessary. */
+/* A table to map baud rates into index numbers. */
#if HAVE_POSIX_TERMIOS
typedef speed_t baud_code;
@@ -858,11 +928,18 @@ static struct sbaud_table
static int cSmin;
#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
+/* Open a serial line. This sets the terminal settings. We begin in
+ seven bit mode and let the protocol change if necessary. If fwait
+ is FALSE we open the terminal in non-blocking mode. If flocal is
+ TRUE we set CLOCAL on the terminal when using termio[s]; this is
+ supposedly required on some versions of BSD/386. */
+
static boolean
-fsserial_open (qconn, ibaud, fwait)
+fsserial_open (qconn, ibaud, fwait, tlocal)
struct sconnection *qconn;
long ibaud;
boolean fwait;
+ enum tclocal_setting tlocal;
{
struct ssysdep_conn *q;
baud_code ib;
@@ -870,7 +947,19 @@ fsserial_open (qconn, ibaud, fwait)
q = (struct ssysdep_conn *) qconn->psysdep;
if (q->zdevice != NULL)
- ulog_device (strrchr (q->zdevice, '/') + 1);
+ {
+#if LOG_DEVICE_PREFIX
+ ulog_device (q->zdevice);
+#else
+ const char *z;
+
+ if (strncmp (q->zdevice, "/dev/", sizeof "/dev/" - 1) == 0)
+ z = q->zdevice + sizeof "/dev/" - 1;
+ else
+ z = q->zdevice;
+ ulog_device (z);
+#endif
+ }
else
{
const char *zport;
@@ -945,7 +1034,7 @@ fsserial_open (qconn, ibaud, fwait)
ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
return FALSE;
}
- q->istdout_flags = -1;
+ q->iwr_flags = -1;
if (! fgetterminfo (q->o, &q->sorig))
{
@@ -1025,13 +1114,11 @@ fsserial_open (qconn, ibaud, fwait)
q->snew.c_iflag &=~ ICLEAR_IFLAG;
q->snew.c_oflag &=~ ICLEAR_OFLAG;
q->snew.c_cflag &=~ ICLEAR_CFLAG;
- if (!fwait)
- q->snew.c_cflag |= CLOCAL;
- q->snew.c_cflag |= (ib | ISET_CFLAG);
+ q->snew.c_cflag |= ib | ISET_CFLAG;
q->snew.c_lflag &=~ ICLEAR_LFLAG;
cSmin = 1;
q->snew.c_cc[VMIN] = cSmin;
- q->snew.c_cc[VTIME] = 0;
+ q->snew.c_cc[VTIME] = 1;
#ifdef TCFLSH
/* Flush pending input. */
@@ -1048,13 +1135,11 @@ fsserial_open (qconn, ibaud, fwait)
q->snew.c_iflag &=~ ICLEAR_IFLAG;
q->snew.c_oflag &=~ ICLEAR_OFLAG;
q->snew.c_cflag &=~ ICLEAR_CFLAG;
- if (!fwait)
- q->snew.c_cflag |= CLOCAL;
q->snew.c_cflag |= ISET_CFLAG;
q->snew.c_lflag &=~ ICLEAR_LFLAG;
cSmin = 1;
q->snew.c_cc[VMIN] = cSmin;
- q->snew.c_cc[VTIME] = 0;
+ q->snew.c_cc[VTIME] = 1;
(void) cfsetospeed (&q->snew, ib);
(void) cfsetispeed (&q->snew, ib);
@@ -1064,6 +1149,20 @@ fsserial_open (qconn, ibaud, fwait)
#endif /* HAVE_POSIX_TERMIOS */
+#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
+ switch (tlocal)
+ {
+ case SET_CLOCAL:
+ q->snew.c_cflag |= CLOCAL;
+ break;
+ case CLEAR_CLOCAL:
+ q->snew.c_cflag &=~ CLOCAL;
+ break;
+ case IGNORE_CLOCAL:
+ break;
+ }
+#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
+
if (! fsetterminfo (q->o, &q->snew))
{
ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno));
@@ -1098,8 +1197,9 @@ fsserial_open (qconn, ibaud, fwait)
return TRUE;
}
-/* Open a standard input port. The code alternates q->o between 0 and
- 1 as appropriate. It is always 0 before any call to fsblock. */
+/* Open a standard input port. The code alternates q->o between
+ q->ord and q->owr as appropriate. It is always q->ord before any
+ call to fsblock. */
static boolean
fsstdin_open (qconn, ibaud, fwait)
@@ -1110,11 +1210,14 @@ fsstdin_open (qconn, ibaud, fwait)
struct ssysdep_conn *q;
q = (struct ssysdep_conn *) qconn->psysdep;
- q->o = 0;
- if (! fsserial_open (qconn, ibaud, fwait))
+ q->ord = 0;
+ q->owr = 1;
+
+ q->o = q->ord;
+ if (! fsserial_open (qconn, ibaud, fwait, IGNORE_CLOCAL))
return FALSE;
- q->istdout_flags = fcntl (1, F_GETFL, 0);
- if (q->istdout_flags < 0)
+ q->iwr_flags = fcntl (q->owr, F_GETFL, 0);
+ if (q->iwr_flags < 0)
{
ulog (LOG_ERROR, "fcntl: %s", strerror (errno));
return FALSE;
@@ -1130,9 +1233,26 @@ fsmodem_open (qconn, ibaud, fwait)
long ibaud;
boolean fwait;
{
+ struct uuconf_modem_port *qm;
+
+ qm = &qconn->qport->uuconf_u.uuconf_smodem;
if (ibaud == (long) 0)
- ibaud = qconn->qport->uuconf_u.uuconf_smodem.uuconf_ibaud;
- return fsserial_open (qconn, ibaud, fwait);
+ ibaud = qm->uuconf_ibaud;
+
+ if (! fsserial_open (qconn, ibaud, fwait,
+ fwait ? CLEAR_CLOCAL : SET_CLOCAL))
+ return FALSE;
+
+ /* If we are waiting for carrier, then turn on hardware flow
+ control. We don't turn on hardware flow control when dialing
+ out, because some modems don't assert the necessary signals until
+ they see carrier. Instead, we turn on hardware flow control in
+ fsmodem_carrier. */
+ if (fwait
+ && ! fsserial_hardflow (qconn, qm->uuconf_fhardflow))
+ return FALSE;
+
+ return TRUE;
}
/* Open a direct port. */
@@ -1143,9 +1263,18 @@ fsdirect_open (qconn, ibaud, fwait)
long ibaud;
boolean fwait;
{
+ struct uuconf_direct_port *qd;
+
+ qd = &qconn->qport->uuconf_u.uuconf_sdirect;
if (ibaud == (long) 0)
- ibaud = qconn->qport->uuconf_u.uuconf_sdirect.uuconf_ibaud;
- return fsserial_open (qconn, ibaud, fwait);
+ ibaud = qd->uuconf_ibaud;
+ if (! fsserial_open (qconn, ibaud, fwait,
+ qd->uuconf_fcarrier ? CLEAR_CLOCAL : SET_CLOCAL))
+ return FALSE;
+
+ /* Always turn on hardware flow control for a direct port when it is
+ opened. There is no other sensible time to turn it on. */
+ return fsserial_hardflow (qconn, qd->uuconf_fhardflow);
}
/* Change the blocking status of the port. We keep track of the
@@ -1188,14 +1317,14 @@ fsblock (qs, fblock)
qs->iflags = iwant;
- if (qs->istdout_flags >= 0)
+ if (qs->iwr_flags >= 0 && qs->ord != qs->owr)
{
if (fblock)
- iwant = qs->istdout_flags &~ (O_NDELAY | O_NONBLOCK);
+ iwant = qs->iwr_flags &~ (O_NDELAY | O_NONBLOCK);
else
- iwant = qs->istdout_flags | iSunblock;
+ iwant = qs->iwr_flags | iSunblock;
- if (fcntl (1, F_SETFL, iwant) < 0)
+ if (fcntl (qs->owr, F_SETFL, iwant) < 0)
{
/* We don't bother to fix up iSunblock here, since we
succeeded above. */
@@ -1203,7 +1332,7 @@ fsblock (qs, fblock)
return FALSE;
}
- qs->istdout_flags = iwant;
+ qs->iwr_flags = iwant;
}
return TRUE;
@@ -1274,9 +1403,9 @@ fsstdin_close (qconn, puuconf, qdialer, fsuccess)
struct ssysdep_conn *qsysdep;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- (void) close (1);
+ (void) close (qsysdep->owr);
(void) close (2);
- qsysdep->o = 0;
+ qsysdep->o = qsysdep->ord;
return fsserial_close (qsysdep);
}
@@ -1442,68 +1571,6 @@ fsdirect_close (qconn, puuconf, qdialer, fsuccess)
return fsserial_close ((struct ssysdep_conn *) qconn->psysdep);
}
-/* Reset a serial port by hanging up. */
-
-static boolean
-fsserial_reset (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *q;
- sterminal sbaud;
-
- q = (struct ssysdep_conn *) qconn->psysdep;
-
- if (! q->fterminal)
- return TRUE;
-
- sbaud = q->snew;
-
-#if HAVE_BSD_TTY
- sbaud.stty.sg_ispeed = B0;
- sbaud.stty.sg_ospeed = B0;
-#endif
-#if HAVE_SYSV_TERMIO
- sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0;
-#endif
-#if HAVE_POSIX_TERMIOS
- if (cfsetospeed (&sbaud, B0) < 0)
- {
- ulog (LOG_ERROR, "Can't set baud rate: %s", strerror (errno));
- return FALSE;
- }
-#endif
-
- if (! fsetterminfodrain (q->o, &sbaud))
- {
- ulog (LOG_ERROR, "Can't hangup terminal: %s", strerror (errno));
- return FALSE;
- }
-
- /* Give the terminal a chance to settle. */
- sleep (2);
-
- if (! fsetterminfo (q->o, &q->snew))
- {
- ulog (LOG_ERROR, "Can't reopen terminal: %s", strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Reset a standard input port. */
-
-static boolean
-fsstdin_reset (qconn)
- struct sconnection *qconn;
-{
- struct ssysdep_conn *qsysdep;
-
- qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = 0;
- return fsserial_reset (qconn);
-}
-
/* Begin dialing out on a modem port. This opens the dialer device if
there is one. */
@@ -1536,7 +1603,27 @@ fsysdep_modem_begin_dial (qconn, qdial)
sleep (2);
(void) ioctl (qsysdep->o, TIOCSDTR, 0);
#else /* ! defined (TIOCCDTR) */
- (void) fconn_reset (qconn);
+ if (qsysdep->fterminal)
+ {
+ sterminal sbaud;
+
+ sbaud = qsysdep->snew;
+
+#if HAVE_BSD_TTY
+ sbaud.stty.sg_ispeed = B0;
+ sbaud.stty.sg_ospeed = B0;
+#endif
+#if HAVE_SYSV_TERMIO
+ sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0;
+#endif
+#if HAVE_POSIX_TERMIOS
+ (void) cfsetospeed (&sbaud, B0);
+#endif
+
+ (void) fsetterminfodrain (qsysdep->o, &sbaud);
+ sleep (2);
+ (void) fsetterminfo (qsysdep->o, &qsysdep->snew);
+ }
#endif /* ! defined (TIOCCDTR) */
if (qdial->uuconf_fdtr_toggle_wait)
@@ -1598,15 +1685,17 @@ fsmodem_carrier (qconn, fcarrier)
boolean fcarrier;
{
register struct ssysdep_conn *q;
+ struct uuconf_modem_port *qm;
q = (struct ssysdep_conn *) qconn->psysdep;
if (! q->fterminal)
return TRUE;
+ qm = &qconn->qport->uuconf_u.uuconf_smodem;
if (fcarrier)
{
- if (qconn->qport->uuconf_u.uuconf_smodem.uuconf_fcarrier)
+ if (qm->uuconf_fcarrier)
{
#ifdef TIOCCAR
/* Tell the modem to pay attention to carrier. */
@@ -1619,18 +1708,18 @@ fsmodem_carrier (qconn, fcarrier)
#if HAVE_BSD_TTY
#ifdef LNOMDM
- /* IS68K Unix uses a local LNOMDM bit. */
- {
- int iparam;
-
- iparam = LNOMDM;
- if (ioctl (q->o, TIOCLBIC, &iparam) < 0)
+ /* IS68K Unix uses a local LNOMDM bit. */
{
- ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s",
- strerror (errno));
- return FALSE;
+ int iparam;
+
+ iparam = LNOMDM;
+ if (ioctl (q->o, TIOCLBIC, &iparam) < 0)
+ {
+ ulog (LOG_ERROR, "ioctl (TIOCLBIC, LNOMDM): %s",
+ strerror (errno));
+ return FALSE;
+ }
}
- }
#endif /* LNOMDM */
#endif /* HAVE_BSD_TTY */
@@ -1644,9 +1733,20 @@ fsmodem_carrier (qconn, fcarrier)
}
#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
}
+
+ /* Turn on hardware flow control after turning on carrier. We
+ don't do it until now because some modems don't assert the
+ right signals until they see carrier. */
+ if (! fsserial_hardflow (qconn, qm->uuconf_fhardflow))
+ return FALSE;
}
else
{
+ /* Turn off any hardware flow control before turning off
+ carrier. */
+ if (! fsserial_hardflow (qconn, FALSE))
+ return FALSE;
+
#ifdef TIOCNCAR
/* Tell the modem to ignore carrier. */
if (ioctl (q->o, TIOCNCAR, 0) < 0)
@@ -1714,6 +1814,104 @@ fsmodem_carrier (qconn, fcarrier)
return TRUE;
}
+/* Tell the port to use hardware flow control. There is no standard
+ mechanism for controlling this. This implementation supports
+ CRTSCTS on SunOS, RTS/CTSFLOW on 386(ish) unix, CTSCD on the 3b1,
+ and TXADDCD/TXDELCD on AIX. If you know how to do it on other
+ systems, please implement it and send me the patches. */
+
+static boolean
+fsserial_hardflow (qconn, fhardflow)
+ struct sconnection *qconn;
+ boolean fhardflow;
+{
+ register struct ssysdep_conn *q;
+
+ q = (struct ssysdep_conn *) qconn->psysdep;
+
+ if (! q->fterminal)
+ return TRUE;
+
+ /* Don't do anything if we don't know what to do. */
+#if HAVE_BSD_TTY
+#define HAVE_HARDFLOW 0
+#endif
+#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
+#if ! HAVE_TXADDCD
+#ifndef CRTSFL
+#ifndef CRTSCTS
+#ifndef CTSCD
+#define HAVE_HARDFLOW 0
+#endif
+#endif
+#endif
+#endif
+#endif
+
+#ifndef HAVE_HARDFLOW
+#define HAVE_HARDFLOW 1
+#endif
+
+#if HAVE_HARDFLOW
+ if (fhardflow)
+ {
+#if HAVE_TXADDCD
+ /* The return value does not reliably indicate whether this
+ actually succeeded. */
+ (void) ioctl (q->o, TXADDCD, "rts");
+#else /* ! HAVE_TXADDCD */
+#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
+#ifdef CRTSFL
+ q->snew.c_cflag |= CRTSFL;
+ q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW);
+#endif /* defined (CRTSFL) */
+#ifdef CRTSCTS
+ q->snew.c_cflag |= CRTSCTS;
+#endif /* defined (CRTSCTS) */
+#ifdef CTSCD
+ q->snew.c_cflag |= CTSCD;
+#endif /* defined (CTSCD) */
+#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
+ if (! fsetterminfo (q->o, &q->snew))
+ {
+ ulog (LOG_ERROR, "Can't enable hardware flow control: %s",
+ strerror (errno));
+ return FALSE;
+ }
+#endif /* ! HAVE_TXADDCD */
+ }
+ else
+ {
+#if HAVE_TXADDCD
+ /* The return value does not reliably indicate whether this
+ actually succeeded. */
+ (void) ioctl (q->o, TXDELCD, "rts");
+#else /* ! HAVE_TXADDCD */
+#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS
+#ifdef CRTSFL
+ q->snew.c_cflag &=~ CRTSFL;
+ q->snew.c_cflag &=~ (RTSFLOW | CTSFLOW);
+#endif /* defined (CRTSFL) */
+#ifdef CRTSCTS
+ q->snew.c_cflag &=~ CRTSCTS;
+#endif /* defined (CRTSCTS) */
+#ifdef CTSCD
+ q->snew.c_cflag &=~ CTSCD;
+#endif /* defined (CTSCD) */
+#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */
+ if (! fsetterminfo (q->o, &q->snew))
+ {
+ ulog (LOG_ERROR, "Can't disable hardware flow control: %s",
+ strerror (errno));
+ return FALSE;
+ }
+#endif /* ! HAVE_TXADDCD */
+ }
+#endif /* HAVE_HARDFLOW */
+
+ return TRUE;
+}
+
/* Finish dialing out on a modem by closing any dialer device and waiting
for carrier. */
@@ -1795,7 +1993,50 @@ fsysdep_modem_end_dial (qconn, qdial)
return FALSE;
}
-#endif /* TIOCWONLINE */
+#else /* ! defined (TIOCWONLINE) */
+
+ /* Try to open the port again without using O_NDELAY. In
+ principle, the open should delay until carrier is available.
+ This may not work on some systems, so we just ignore any
+ errors. */
+ {
+ int onew;
+
+ onew = open (q->zdevice, O_RDWR);
+ if (onew >= 0)
+ {
+ boolean fbad;
+ int iflags;
+
+ fbad = FALSE;
+
+ if (fcntl (onew, F_SETFD,
+ fcntl (onew, F_GETFD, 0) | FD_CLOEXEC) < 0)
+ fbad = TRUE;
+
+ if (! fbad)
+ {
+ iflags = fcntl (onew, F_GETFL, 0);
+ if (iflags < 0
+ || ! fsetterminfo (onew, &q->snew))
+ fbad = TRUE;
+ }
+
+ if (fbad)
+ (void) close (onew);
+ else
+ {
+ (void) close (q->o);
+ q->o = onew;
+ q->iflags = iflags;
+#if HAVE_TIOCSINUSE
+ (void) ioctl (onew, TIOCSINUSE, 0);
+#endif
+ }
+ }
+ }
+
+#endif /* ! defined (TIOCWONLINE) */
}
return TRUE;
@@ -1855,6 +2096,7 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
boolean fret;
register struct ssysdep_conn * const q
= (struct ssysdep_conn *) qconn->psysdep;
+ int cwouldblock;
cwant = *pclen;
*pclen = 0;
@@ -1893,6 +2135,7 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
fret = FALSE;
+ cwouldblock = 0;
while (TRUE)
{
int cgot;
@@ -2009,10 +2252,26 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
(normally we would have received SIGHUP, but we can't count
on that). We turn off the signals before calling ulog to
reduce problems with interrupted system calls. */
- if (cgot <= 0)
+ if (cgot > 0)
+ cwouldblock = 0;
+ else
{
if (cgot < 0 && errno == EINTR)
cgot = 0;
+ else if (cgot < 0
+ && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && cwouldblock < 2)
+ {
+ /* Incomprehensibly, on some systems the read will
+ return EWOULDBLOCK even though the descriptor has
+ been set to blocking mode. We permit the read call
+ to do this twice in a row, and then error out. We
+ don't want to permit an arbitrary number of
+ EWOULDBLOCK errors, since that could hang us up
+ indefinitely. */
+ ++cwouldblock;
+ cgot = 0;
+ }
else
{
int ierr;
@@ -2128,10 +2387,10 @@ fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
return fret;
}
-/* Read from a stdin port. */
+/* Read from a port with separate read/write file descriptors. */
-static boolean
-fsstdin_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
+boolean
+fsdouble_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
struct sconnection *qconn;
char *zbuf;
size_t *pclen;
@@ -2142,7 +2401,7 @@ fsstdin_read (qconn, zbuf, pclen, cmin, ctimeout, freport)
struct ssysdep_conn *qsysdep;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = 0;
+ qsysdep->o = qsysdep->ord;
return fsysdep_conn_read (qconn, zbuf, pclen, cmin, ctimeout, freport);
}
@@ -2180,7 +2439,7 @@ fsysdep_conn_write (qconn, zwrite, cwrite)
#if HAVE_TLI
if (q->ftli)
{
- cdid = t_snd (q->o, zwrite, cwrite, 0);
+ cdid = t_snd (q->o, (char *) zwrite, cwrite, 0);
if (cdid < 0 && t_errno != TSYSERR)
{
ulog (LOG_ERROR, "t_snd: %s",
@@ -2239,10 +2498,10 @@ fsysdep_conn_write (qconn, zwrite, cwrite)
return TRUE;
}
-/* Write to a stdin port. */
+/* Write to a port with separate read/write file descriptors. */
-static boolean
-fsstdin_write (qconn, zwrite, cwrite)
+boolean
+fsdouble_write (qconn, zwrite, cwrite)
struct sconnection *qconn;
const char *zwrite;
size_t cwrite;
@@ -2250,10 +2509,10 @@ fsstdin_write (qconn, zwrite, cwrite)
struct ssysdep_conn *qsysdep;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = 0;
+ qsysdep->o = qsysdep->ord;
if (! fsblock (qsysdep, TRUE))
return FALSE;
- qsysdep->o = 1;
+ qsysdep->o = qsysdep->owr;
return fsysdep_conn_write (qconn, zwrite, cwrite);
}
@@ -2317,8 +2576,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
/* If we are running on standard input, we switch the file
descriptors by hand. */
- if (q->istdout_flags >= 0)
- q->o = 0;
+ if (q->ord >= 0)
+ q->o = q->ord;
/* Do an unblocked read. */
if (! fsblock (q, FALSE))
@@ -2392,8 +2651,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
cdo = SINGLE_WRITE;
#endif
- if (q->istdout_flags >= 0)
- q->o = 1;
+ if (q->owr >= 0)
+ q->o = q->owr;
/* Loop until we get something besides EINTR. */
while (TRUE)
@@ -2405,7 +2664,7 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
#if HAVE_TLI
if (q->ftli)
{
- cdid = t_snd (q->o, zwrite, cdo, 0);
+ cdid = t_snd (q->o, (char *) zwrite, cdo, 0);
if (cdid < 0)
{
if (t_errno == TFLOW)
@@ -2460,8 +2719,8 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
{
/* We didn't write any data. Do a blocking write. */
- if (q->istdout_flags >= 0)
- q->o = 0;
+ if (q->ord >= 0)
+ q->o = q->ord;
if (! fsblock (q, TRUE))
return FALSE;
@@ -2471,11 +2730,11 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
cdo = SINGLE_WRITE;
DEBUG_MESSAGE1 (DEBUG_PORT,
- "fsysdep_conn_io: Blocking write of %lud",
+ "fsysdep_conn_io: Blocking write of %lu",
(unsigned long) cdo);
- if (q->istdout_flags >= 0)
- q->o = 1;
+ if (q->owr >= 0)
+ q->o = q->owr;
/* Loop until we get something besides EINTR. */
while (TRUE)
@@ -2487,7 +2746,7 @@ fsysdep_conn_io (qconn, zwrite, pcwrite, zread, pcread)
#if HAVE_TLI
if (q->ftli)
{
- cdid = t_snd (q->o, zwrite, cdo, 0);
+ cdid = t_snd (q->o, (char *) zwrite, cdo, 0);
if (cdid < 0 && t_errno != TSYSERR)
{
ulog (LOG_ERROR, "t_snd: %s",
@@ -2576,7 +2835,7 @@ fsstdin_break (qconn)
struct ssysdep_conn *qsysdep;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = 1;
+ qsysdep->o = qsysdep->owr;
return fsserial_break (qconn);
}
@@ -2805,6 +3064,22 @@ fsserial_set (qconn, tparity, tstrip, txonxoff)
}
#endif /* HAVE_POSIX_TERMIOS */
#endif /* defined (CRTSCTS) */
+#ifdef CRTSFL
+ if ((q->snew.c_cflag & CRTSFL) != 0)
+ {
+ iset = IXON;
+ iclear = IXOFF;
+ /* SCO says we cant have CRTSFL **and** RTSFLOW/CTSFLOW */
+#ifdef RTSFLOW
+ iclear |= RTSFLOW;
+#endif
+#ifdef CTSFLOW
+ iclear |= CTSFLOW;
+#endif
+ fdo = TRUE;
+ break;
+ }
+#endif /* defined(CRTSFL) */
iset = IXON | IXOFF;
iclear = 0;
fdo = TRUE;
@@ -2890,7 +3165,7 @@ fsstdin_set (qconn, tparity, tstrip, txonxoff)
struct ssysdep_conn *qsysdep;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- qsysdep->o = 0;
+ qsysdep->o = qsysdep->ord;
return fsserial_set (qconn, tparity, tstrip, txonxoff);
}
@@ -2954,15 +3229,22 @@ fsrun_chat (oread, owrite, pzprog)
return ixswait ((unsigned long) ipid, "Chat program") == 0;
}
-/* Run a chat program on a stdin port. */
+/* Run a chat program on a port using separate read/write file
+ descriptors. */
-/*ARGSUSED*/
-static boolean
-fsstdin_chat (qconn, pzprog)
+boolean
+fsdouble_chat (qconn, pzprog)
struct sconnection *qconn;
char **pzprog;
{
- return fsrun_chat (0, 1, pzprog);
+ struct ssysdep_conn *qsysdep;
+ boolean fret;
+
+ qsysdep = (struct ssysdep_conn *) qconn->psysdep;
+ fret = fsrun_chat (qsysdep->ord, qsysdep->owr, pzprog);
+ if (qsysdep->fterminal)
+ (void) fgetterminfo (qsysdep->ord, &qsysdep->snew);
+ return fret;
}
/* Run a chat program on any general type of connection. */
@@ -2973,9 +3255,13 @@ fsysdep_conn_chat (qconn, pzprog)
char **pzprog;
{
struct ssysdep_conn *qsysdep;
+ boolean fret;
qsysdep = (struct ssysdep_conn *) qconn->psysdep;
- return fsrun_chat (qsysdep->o, qsysdep->o, pzprog);
+ fret = fsrun_chat (qsysdep->o, qsysdep->o, pzprog);
+ if (qsysdep->fterminal)
+ (void) fgetterminfo (qsysdep->o, &qsysdep->snew);
+ return fret;
}
/* Return baud rate of a serial port. */
diff --git a/gnu/libexec/uucp/libunix/signal.c b/gnu/libexec/uucp/libunix/signal.c
index 33e24a724574..75016c30e116 100644
--- a/gnu/libexec/uucp/libunix/signal.c
+++ b/gnu/libexec/uucp/libunix/signal.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/sindir.c b/gnu/libexec/uucp/libunix/sindir.c
index d98750818915..7c9da50045ff 100644
--- a/gnu/libexec/uucp/libunix/sindir.c
+++ b/gnu/libexec/uucp/libunix/sindir.c
@@ -18,7 +18,10 @@ zsysdep_in_dir (zdir, zfile)
cdir = strlen (zdir);
cfile = strlen (zfile);
zret = zbufalc (cdir + cfile + 2);
- memcpy (zret, zdir, cdir);
+ if (cdir == 1 && *zdir == '/')
+ cdir = 0;
+ else
+ memcpy (zret, zdir, cdir);
memcpy (zret + cdir + 1, zfile, cfile);
zret[cdir] = '/';
zret[cdir + cfile + 1] = '\0';
diff --git a/gnu/libexec/uucp/libunix/sleep.c b/gnu/libexec/uucp/libunix/sleep.c
index b232f9674ff0..910c9292e198 100644
--- a/gnu/libexec/uucp/libunix/sleep.c
+++ b/gnu/libexec/uucp/libunix/sleep.c
@@ -10,5 +10,17 @@ void
usysdep_sleep (c)
int c;
{
+#if HAVE_NAPMS || HAVE_NAP || HAVE_USLEEP || HAVE_SELECT || HAVE_POLL
+ int i;
+
+ /* In this case, usysdep_pause is accurate. */
+ for (i = 2 * c; i > 0; i--)
+ usysdep_pause ();
+#else
+ /* On some system sleep (1) may not sleep at all. Avoid this sort
+ of problem by always doing at least sleep (2). */
+ if (c < 2)
+ c = 2;
(void) sleep (c);
+#endif
}
diff --git a/gnu/libexec/uucp/libunix/spawn.c b/gnu/libexec/uucp/libunix/spawn.c
index 7ab080d1a9ca..67b915fc66a1 100644
--- a/gnu/libexec/uucp/libunix/spawn.c
+++ b/gnu/libexec/uucp/libunix/spawn.c
@@ -1,7 +1,7 @@
/* spawn.c
Spawn a program securely.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -102,6 +102,9 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
char *azenv[9];
char **pazenv;
boolean ferr;
+#if HAVE_FULLDUPLEX_PIPES
+ boolean ffullduplex;
+#endif
int ierr = 0;
int onull;
int aichild_descs[3];
@@ -196,6 +199,11 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
cpar_close = 0;
cchild_close = 0;
+#if HAVE_FULLDUPLEX_PIPES
+ ffullduplex = (aidescs[0] == SPAWN_WRITE_PIPE
+ && aidescs[1] == SPAWN_READ_PIPE);
+#endif
+
for (i = 0; i < 3; i++)
{
if (aidescs[i] == SPAWN_NULL)
@@ -224,6 +232,16 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
{
int aipipe[2];
+#if HAVE_FULLDUPLEX_PIPES
+ if (ffullduplex && i == 1)
+ {
+ /* Just use the fullduplex pipe. */
+ aidescs[i] = aidescs[0];
+ aichild_descs[i] = aichild_descs[0];
+ continue;
+ }
+#endif
+
if (pipe (aipipe) < 0)
{
ierr = errno;
@@ -249,8 +267,10 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
++cpar_close;
++cchild_close;
- if (fcntl (aidescs[i], F_SETFD,
- fcntl (aidescs[i], F_GETFD, 0) | FD_CLOEXEC) < 0)
+ if (fcntl (aipipe[0], F_SETFD,
+ fcntl (aipipe[0], F_GETFD, 0) | FD_CLOEXEC) < 0
+ || fcntl (aipipe[1], F_SETFD,
+ fcntl (aipipe[1], F_GETFD, 0) | FD_CLOEXEC) < 0)
{
ierr = errno;
ferr = TRUE;
@@ -332,9 +352,21 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
if (! fkeepuid)
{
+ /* Return to the uid of the invoking user. */
(void) setuid (getuid ());
(void) setgid (getgid ());
}
+ else
+ {
+ /* Try to force the UUCP uid to be both real and effective user
+ ID, in order to present a consistent environment regardless
+ of the invoking user. This won't work on System V based
+ systems, but it will do no harm. It would be possible to use
+ a setuid root program to force the UID setting, but I don't
+ think the efficiency loss is worth it. */
+ (void) setuid (geteuid ());
+ (void) setgid (getegid ());
+ }
if (zchdir != NULL)
(void) chdir (zchdir);
@@ -352,11 +384,24 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell,
#endif
}
+#ifdef isc386
+#ifdef _POSIX_SOURCE
+ /* ISC has a remarkably stupid notion of environments. If a program
+ is compiled in the POSIX environment, it sets a process state.
+ If you then exec a program which expects the USG environment, the
+ process state is not reset, so the execed program fails. The
+ __setostype call is required to change back to the USG
+ environment. This ought to be a switch in policy.h, but it seems
+ too trivial, so I will leave this code here and wait for it to
+ break in some fashion in the next version of ISC. */
+ __setostype (0);
+#endif
+#endif
+
(void) execve ((char *) zcmd, (char **) pazargs, pazenv);
/* The exec failed. If permitted, try using /bin/sh to execute a
shell script. */
-
if (errno == ENOEXEC && fshell)
{
char *zto;
diff --git a/gnu/libexec/uucp/libunix/splcmd.c b/gnu/libexec/uucp/libunix/splcmd.c
index 9f6616a36dd0..774066119967 100644
--- a/gnu/libexec/uucp/libunix/splcmd.c
+++ b/gnu/libexec/uucp/libunix/splcmd.c
@@ -1,7 +1,7 @@
/* splcmd.c
Spool a command.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -44,10 +44,12 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds)
int ccmds;
const struct scmd *pascmds;
{
- char *z;
+ char abtempfile[sizeof "TMP1234567890"];
+ char *ztemp;
FILE *e;
int i;
const struct scmd *q;
+ char *z;
char *zjobid;
#if DEBUG > 0
@@ -55,14 +57,17 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds)
ulog (LOG_FATAL, "Bad grade %d", bgrade);
#endif
- z = zscmd_file (qsys, bgrade);
- if (z == NULL)
+ /* Write the commands into a temporary file and then rename it to
+ avoid a race with uucico reading the file. */
+ sprintf (abtempfile, "TMP%010lx", (unsigned long) getpid ());
+ ztemp = zsfind_file (abtempfile, qsys->uuconf_zname, bgrade);
+ if (ztemp == NULL)
return NULL;
- e = esysdep_fopen (z, FALSE, FALSE, TRUE);
+ e = esysdep_fopen (ztemp, FALSE, FALSE, TRUE);
if (e == NULL)
{
- ubuffree (z);
+ ubuffree (ztemp);
return NULL;
}
@@ -93,8 +98,8 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds)
"zsysdep_spool_commands: Unrecognized type %d",
q->bcmd);
(void) fclose (e);
- (void) remove (z);
- ubuffree (z);
+ (void) remove (ztemp);
+ ubuffree (ztemp);
return NULL;
}
}
@@ -102,11 +107,30 @@ zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds)
if (fclose (e) != 0)
{
ulog (LOG_ERROR, "fclose: %s", strerror (errno));
- (void) remove (z);
+ (void) remove (ztemp);
+ ubuffree (ztemp);
+ return NULL;
+ }
+
+ z = zscmd_file (qsys, bgrade);
+ if (z == NULL)
+ {
+ (void) remove (ztemp);
+ ubuffree (ztemp);
+ return NULL;
+ }
+
+ if (! fsysdep_move_file (ztemp, z, FALSE, FALSE, FALSE,
+ (const char *) NULL))
+ {
+ (void) remove (ztemp);
+ ubuffree (ztemp);
ubuffree (z);
return NULL;
}
+ ubuffree (ztemp);
+
zjobid = zsfile_to_jobid (qsys, z, bgrade);
if (zjobid == NULL)
(void) remove (z);
diff --git a/gnu/libexec/uucp/libunix/spool.c b/gnu/libexec/uucp/libunix/spool.c
index a3e50f7747f1..fa1d8e6b34c2 100644
--- a/gnu/libexec/uucp/libunix/spool.c
+++ b/gnu/libexec/uucp/libunix/spool.c
@@ -1,7 +1,7 @@
/* spool.c
Find a file in the spool directory.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char spool_rcsid[] = "$Id: spool.c,v 1.1 1993/08/05 18:24:31 conklin Exp $";
+const char spool_rcsid[] = "$Id: spool.c,v 1.2 1994/05/07 18:11:24 ache Exp $";
#endif
#include "uudefs.h"
@@ -194,7 +194,12 @@ zsfind_file (zsimple, zsystem, bgrade)
const char *zsystem;
int bgrade;
{
- if (! fspool_file (zsimple))
+ /* zsysdep_spool_commands calls this with TMPXXX which we must treat
+ as a C. file. */
+ if ((zsimple[0] != 'T'
+ || zsimple[1] != 'M'
+ || zsimple[2] != 'P')
+ && ! fspool_file (zsimple))
{
ulog (LOG_ERROR, "Unrecognized file name %s", zsimple);
return NULL;
@@ -203,7 +208,9 @@ zsfind_file (zsimple, zsystem, bgrade)
#if ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR
if (*zsimple == 'X')
{
- size_t clen;
+ static char *zbuf;
+ static size_t cbuf;
+ size_t clen, cwant;
/* Files beginning with X. are execute files. It is important
for security reasons that we know the system which created
@@ -216,22 +223,19 @@ zsfind_file (zsimple, zsystem, bgrade)
too short, but hopefully no problem will occur since any
System V systems will be using HDB or SVR4 or TAYLOR. */
clen = strlen (zsimple);
- if (clen <= 7 || strncmp (zsimple + 2, zsystem, clen - 7) != 0)
+ if (clen < 5)
{
- static char *zbuf;
- static size_t cbuf;
- size_t cwant;
-
- cwant = strlen (zsystem) + 8;
- if (cwant > cbuf)
- {
- zbuf = (char *) xrealloc ((pointer) zbuf, cwant);
- cbuf = cwant;
- }
- sprintf (zbuf, "X.%s%s", zsystem,
- clen < 5 ? zsimple : zsimple + clen - 5);
- zsimple = zbuf;
+ ulog (LOG_ERROR, "Bad file name (too short) %s", zsimple);
+ return NULL;
}
+ cwant = strlen (zsystem) + 8;
+ if (cwant > cbuf)
+ {
+ zbuf = (char *) xrealloc ((pointer) zbuf, cwant);
+ cbuf = cwant;
+ }
+ sprintf (zbuf, "X.%s%s", zsystem, zsimple + clen - 5);
+ zsimple = zbuf;
}
#endif /* ! SPOOLDIR_HDB && ! SPOOLDIR_SVR4 && ! SPOOLDIR_TAYLOR */
@@ -264,6 +268,7 @@ zsfind_file (zsimple, zsystem, bgrade)
switch (*zsimple)
{
case 'C':
+ case 'T':
#if SPOOLDIR_BSD42 || SPOOLDIR_BSD43
return zsysdep_in_dir ("C.", zsimple);
#endif /* SPOOLDIR_BSD42 || SPOOLDIR_BSD43 */
diff --git a/gnu/libexec/uucp/libunix/srmdir.c b/gnu/libexec/uucp/libunix/srmdir.c
index 28487ef30970..6110b003fc25 100644
--- a/gnu/libexec/uucp/libunix/srmdir.c
+++ b/gnu/libexec/uucp/libunix/srmdir.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -35,7 +35,7 @@
#include <ftw.h>
#endif
-static int isremove_dir P((const char *, const struct stat *, int));
+static int isremove_dir P((const char *, struct stat *, int));
/* Keep a list of directories to be removed. */
@@ -90,7 +90,7 @@ fsysdep_rmdir (zdir)
static int
isremove_dir (zfile, qstat, iflag)
const char *zfile;
- const struct stat *qstat;
+ struct stat *qstat;
int iflag;
{
if (iflag == FTW_D || iflag == FTW_DNR)
diff --git a/gnu/libexec/uucp/libunix/statsb.c b/gnu/libexec/uucp/libunix/statsb.c
index aa17f9e9df07..733cad260fa3 100644
--- a/gnu/libexec/uucp/libunix/statsb.c
+++ b/gnu/libexec/uucp/libunix/statsb.c
@@ -1,7 +1,7 @@
/* statsb.c
System dependent routines for uustat.
- Copyright (C) 1992 Ian Lance Taylor
+ Copyright (C) 1992, 1993, 1994 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char statsb_rcsid[] = "$Id: statsb.c,v 1.1 1993/08/05 18:24:34 conklin Exp $";
+const char statsb_rcsid[] = "$Id: statsb.c,v 1.2 1994/05/07 18:11:29 ache Exp $";
#endif
#include "uudefs.h"
@@ -73,32 +73,16 @@ const char statsb_rcsid[] = "$Id: statsb.c,v 1.1 1993/08/05 18:24:34 conklin Exp
/* Local functions. */
-static int ussettime P((const char *z, time_t inow));
+static int issettime P((const char *z, time_t inow));
static boolean fskill_or_rejuv P((pointer puuconf, const char *zid,
boolean fkill));
-/* See whether the user is permitted to kill arbitrary jobs. This is
- true only for root and uucp. We check for uucp by seeing if the
- real user ID and the effective user ID are the same; this works
- because we should be suid to uucp, so our effective user ID will
- always be uucp while our real user ID will be whoever ran the
- program. */
-
-boolean
-fsysdep_privileged ()
-{
- uid_t iuid;
-
- iuid = getuid ();
- return iuid == 0 || iuid == geteuid ();
-}
-
/* Set file access time to the present. On many systems this could be
done by passing NULL to utime, but on some that doesn't work. This
routine is not time critical, so we never rely on NULL. */
static int
-ussettime(z, inow)
+issettime(z, inow)
const char *z;
time_t inow;
{
@@ -238,7 +222,7 @@ fskill_or_rejuv (puuconf, zid, fkill)
if (fkill)
isys = remove (ztemp);
else
- isys = ussettime (ztemp, inow);
+ isys = issettime (ztemp, inow);
if (isys != 0 && errno != ENOENT)
{
@@ -261,7 +245,7 @@ fskill_or_rejuv (puuconf, zid, fkill)
if (fkill)
isys = remove (zfile);
else
- isys = ussettime (zfile, inow);
+ isys = issettime (zfile, inow);
if (isys != 0 && errno != ENOENT)
{
@@ -313,6 +297,21 @@ ixsysdep_file_time (zfile)
return (long) s.st_mtime;
}
+
+/* Set the time of a file to the current time. */
+
+boolean
+fsysdep_touch_file (zfile)
+ const char *zfile;
+{
+ if (issettime (zfile, time ((time_t *) NULL)) != 0)
+ {
+ ulog (LOG_ERROR, "utime (%s): %s", zfile, strerror (errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
/* Start getting the status files. */
@@ -399,7 +398,10 @@ fsysdep_lock_status ()
DIR *qdir;
struct dirent *qentry;
int calc;
- int *pai;
+ pid_t *pai;
+#if HAVE_QNX_LOCKFILES
+ nid_t *painid;
+#endif
int cgot;
int aidescs[3];
char *zcopy, *ztok;
@@ -420,18 +422,28 @@ fsysdep_lock_status ()
calc = 0;
pai = NULL;
cgot = 0;
+#if HAVE_QNX_LOCKFILES
+ painid = NULL;
+#endif
while ((qentry = readdir (qdir)) != NULL)
{
char *zname;
int o;
+#if HAVE_QNX_LOCKFILES
+ nid_t inid;
+ char ab[23];
+ char *zend;
+#else
#if HAVE_V2_LOCKFILES
int i;
#else
char ab[12];
#endif
+#endif
int cread;
int ierr;
- int ipid;
+ pid_t ipid;
+ int icheck;
if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0)
continue;
@@ -464,22 +476,45 @@ fsysdep_lock_status ()
ubuffree (zname);
+#if HAVE_QNX_LOCKFILES
+ ab[cread] = '\0';
+ ipid = (pid_t) strtol (ab, &zend, 10);
+ inid = (nid_t) strtol (zend, (char **) NULL, 10);
+#else
#if HAVE_V2_LOCKFILES
- ipid = i;
+ ipid = (pid_t) i;
#else
ab[cread] = '\0';
- ipid = strtol (ab, (char **) NULL, 10);
+ ipid = (pid_t) strtol (ab, (char **) NULL, 10);
+#endif
#endif
- printf ("%s: %d\n", qentry->d_name, ipid);
+#if HAVE_QNX_LOCKFILES
+ printf ("%s: %ld %ld\n", qentry->d_name, (long) inid, (long) ipid);
+#else
+ printf ("%s: %ld\n", qentry->d_name, (long) ipid);
+#endif
+
+ for (icheck = 0; icheck < cgot; icheck++)
+ if (pai[icheck] == ipid)
+ break;
+ if (icheck < cgot)
+ continue;
if (cgot >= calc)
{
calc += 10;
- pai = (int *) xrealloc ((pointer) pai, calc * sizeof (int));
+ pai = (pid_t *) xrealloc ((pointer) pai, calc * sizeof (pid_t));
+#if HAVE_QNX_LOCKFILES
+ painid = (nid_t *) xrealloc ((pointer) painid,
+ calc * sizeof (nid_t));
+#endif
}
pai[cgot] = ipid;
+#if HAVE_QNX_LOCKFILES
+ painid[cgot] = inid;
+#endif
++cgot;
}
@@ -513,16 +548,40 @@ fsysdep_lock_status ()
{
int i;
char *zlast, *zset;
+#if HAVE_QNX_LOCKFILES
+ char *zpenultimate, *zsetnid;
+#endif /* HAVE_QNX_LOCKFILES */
zlast = pazargs[cargs - 1];
zset = zbufalc (strlen (zlast) + 20);
+
+#if HAVE_QNX_LOCKFILES
+ /* We assume in this case that PS_PROGRAM ends with " -n -p".
+ Thus, the last argument is "-p" and the second-to-last
+ (penultimate) argument is "-n". We modify them to read "-n###"
+ and "-p###" where "###" is the node ID and the process ID,
+ respectively. This seems like quite a roundabout way of doing
+ things. Why don't we just leave the " -n -p" part out of
+ PS_PROGRAM and construct the "-n###" and "-p###" arguments here
+ from scratch? Because that would not fit as well with how the
+ code works for the other systems and would require larger
+ changes. */
+ zpenultimate = pazargs[cargs - 2];
+ zsetnid = zbufalc (strlen (zpenultimate) + 20);
+#endif
+
for (i = 0; i < cgot; i++)
{
pid_t ipid;
- sprintf (zset, "%s%d", zlast, pai[i]);
+ sprintf (zset, "%s%ld", zlast, (long) pai[i]);
pazargs[cargs - 1] = zset;
+#if HAVE_QNX_LOCKFILES
+ sprintf (zsetnid, "%s%ld", zpenultimate, (long) painid[i]);
+ pazargs[cargs - 2] = zsetnid;
+#endif
+
ipid = ixsspawn ((const char **) pazargs, aidescs, FALSE, FALSE,
(const char *) NULL, FALSE, TRUE,
(const char *) NULL, (const char *) NULL,
@@ -533,6 +592,9 @@ fsysdep_lock_status ()
(void) ixswait ((unsigned long) ipid, PS_PROGRAM);
}
ubuffree (zset);
+#if HAVE_QNX_LOCKFILES
+ ubuffree (zsetnid);
+#endif
}
#else
{
@@ -546,7 +608,7 @@ fsysdep_lock_status ()
{
char ab[20];
- sprintf (ab, "%d", pai[i]);
+ sprintf (ab, "%ld", (long) pai[i]);
strcat (zlast, ab);
if (i + 1 < cgot)
strcat (zlast, ",");
@@ -563,7 +625,7 @@ fsysdep_lock_status ()
(void) ixswait ((unsigned long) ipid, PS_PROGRAM);
ubuffree (zlast);
}
-#endif
+#endif
ubuffree (zcopy);
xfree ((pointer) pazargs);
diff --git a/gnu/libexec/uucp/libunix/status.c b/gnu/libexec/uucp/libunix/status.c
index f403068a7094..a967085e08ff 100644
--- a/gnu/libexec/uucp/libunix/status.c
+++ b/gnu/libexec/uucp/libunix/status.c
@@ -1,7 +1,7 @@
/* status.c
Routines to get and set the status for a system.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -41,7 +41,7 @@
static const int aiMapstatus[] =
{
- 0, 13, 7, 6, 4, 20, 3, 2
+ 0, 13, 7, 6, 20, 4, 3, 2
};
#define CMAPENTRIES (sizeof (aiMapstatus) / sizeof (aiMapstatus[0]))
diff --git a/gnu/libexec/uucp/libunix/strerr.c b/gnu/libexec/uucp/libunix/strerr.c
index d2a6c2128d04..8e7480f1ec5c 100644
--- a/gnu/libexec/uucp/libunix/strerr.c
+++ b/gnu/libexec/uucp/libunix/strerr.c
@@ -12,6 +12,8 @@ extern int sys_nerr;
extern char *sys_errlist[];
#endif
+#undef strerror
+
char *
strerror (ierr)
int ierr;
diff --git a/gnu/libexec/uucp/libunix/tmpfil.c b/gnu/libexec/uucp/libunix/tmpfil.c
index 2dac0024388a..b10e8096df4e 100644
--- a/gnu/libexec/uucp/libunix/tmpfil.c
+++ b/gnu/libexec/uucp/libunix/tmpfil.c
@@ -1,7 +1,7 @@
/* tmpfil.c
Get a temporary file name.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,11 +20,12 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
+#include "uudefs.h"
#include "uuconf.h"
#include "system.h"
#include "sysdep.h"
diff --git a/gnu/libexec/uucp/libunix/uacces.c b/gnu/libexec/uucp/libunix/uacces.c
index c92c78eae354..d99ead36674b 100644
--- a/gnu/libexec/uucp/libunix/uacces.c
+++ b/gnu/libexec/uucp/libunix/uacces.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/ufopen.c b/gnu/libexec/uucp/libunix/ufopen.c
index 5a7b6f22b0d0..76ee1d1394d5 100644
--- a/gnu/libexec/uucp/libunix/ufopen.c
+++ b/gnu/libexec/uucp/libunix/ufopen.c
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
diff --git a/gnu/libexec/uucp/libunix/walk.c b/gnu/libexec/uucp/libunix/walk.c
index ab96123127dd..85b94dae8a98 100644
--- a/gnu/libexec/uucp/libunix/walk.c
+++ b/gnu/libexec/uucp/libunix/walk.c
@@ -11,8 +11,7 @@
#include <ftw.h>
#endif
-static int iswalk_dir P((const char *zname, const struct stat *qstat,
- int iflag));
+static int iswalk_dir P((const char *zname, struct stat *qstat, int iflag));
/* Walk a directory tree. */
@@ -41,7 +40,7 @@ usysdep_walk_tree (zdir, pufn, pinfo)
static int
iswalk_dir (zname, qstat, iflag)
const char *zname;
- const struct stat *qstat;
+ struct stat *qstat;
int iflag;
{
char *zcopy;
diff --git a/gnu/libexec/uucp/libunix/wldcrd.c b/gnu/libexec/uucp/libunix/wldcrd.c
index cfbd15eb848a..13faa29b9c43 100644
--- a/gnu/libexec/uucp/libunix/wldcrd.c
+++ b/gnu/libexec/uucp/libunix/wldcrd.c
@@ -1,7 +1,7 @@
/* wldcrd.c
Expand wildcards.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
@@ -113,9 +113,10 @@ fsysdep_wildcard_start (zfile)
azargs[2] = zcmd;
azargs[3] = NULL;
+ e = espopen (azargs, TRUE, &ipid);
+
ubuffree (zcmd);
- e = espopen (azargs, TRUE, &ipid);
if (e == NULL)
{
ulog (LOG_ERROR, "espopen: %s", strerror (errno));
diff --git a/gnu/libexec/uucp/libunix/work.c b/gnu/libexec/uucp/libunix/work.c
index 8744347aeb44..f5cdb7969e17 100644
--- a/gnu/libexec/uucp/libunix/work.c
+++ b/gnu/libexec/uucp/libunix/work.c
@@ -1,7 +1,7 @@
/* work.c
Routines to read command files.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char work_rcsid[] = "$Id: work.c,v 1.1 1993/08/05 18:24:45 conklin Exp $";
+const char work_rcsid[] = "$Id: work.c,v 1.2 1994/05/07 18:11:41 ache Exp $";
#endif
#include "uudefs.h"
@@ -55,10 +55,25 @@ static int iswork_cmp P((constpointer pkey, constpointer pdatum));
/* These functions can support multiple actions going on at once.
This allows the UUCP package to send and receive multiple files at
- the same time. This is a very flexible feature, but I'm not sure
- it will actually be used all that much.
+ the same time. */
- The ssfile structure holds a command file name and all the lines
+/* To avoid wasting a lot of time scanning the spool directory, which
+ might cause the remote system to time out, we limit each scan to
+ pick up at most a certain number of files. */
+#define COMMANDS_PER_SCAN (200)
+
+/* The ssfilename structure holds the name of a work file, as well as
+ its grade. */
+
+struct ssfilename
+{
+ char *zfile;
+ char bgrade;
+ /* Some compiler may need this, and it won't normally hurt. */
+ char bdummy;
+};
+
+/* The ssfile structure holds a command file name and all the lines
read in from that command file. The union within the ssline
structure initially holds a line from the file and then holds a
pointer back to the ssfile structure; a pointer to this union is
@@ -77,6 +92,9 @@ struct ssline
struct ssfile
{
char *zfile;
+ char bgrade;
+ /* bdummy is needed for some buggy compilers. */
+ char bdummy;
int clines;
int cdid;
struct ssline aslines[CFILELINES];
@@ -84,7 +102,7 @@ struct ssfile
/* Static variables for the work scan. */
-static char **azSwork_files;
+static struct ssfilename *asSwork_files;
static size_t cSwork_files;
static size_t iSwork_file;
static struct ssfile *qSwork_file;
@@ -182,10 +200,10 @@ iswork_cmp (pkey, pdatum)
constpointer pkey;
constpointer pdatum;
{
- const char * const *pzkey = (const char * const *) pkey;
- const char * const *pzdatum = (const char * const *) pdatum;
+ const struct ssfilename *qkey = (const struct ssfilename *) pkey;
+ const struct ssfilename *qdatum = (const struct ssfilename *) pdatum;
- return strcmp (*pzkey, *pzdatum);
+ return strcmp (qkey->zfile, qdatum->zfile);
}
/* See whether there is any work to do for a particular system. */
@@ -309,7 +327,8 @@ fsysdep_get_work_init (qsys, bgrade)
(bad) qsort implementations are very slow when given a sorted
array, which causes particularly bad effects here. */
if (chad > 0)
- qsort ((pointer) azSwork_files, chad, sizeof (char *), iswork_cmp);
+ qsort ((pointer) asSwork_files, chad, sizeof (struct ssfilename),
+ iswork_cmp);
#if SPOOLDIR_SVR4
qgdir = qdir;
@@ -342,6 +361,7 @@ fsysdep_get_work_init (qsys, bgrade)
{
char bfilegrade;
char *zname;
+ struct ssfilename slook;
#if ! SPOOLDIR_SVR4
zname = zbufcpy (qentry->d_name);
@@ -350,13 +370,14 @@ fsysdep_get_work_init (qsys, bgrade)
bfilegrade = qgentry->d_name[0];
#endif
+ slook.zfile = zname;
if (! fswork_file (qsys->uuconf_zname, qentry->d_name,
&bfilegrade)
|| UUCONF_GRADE_CMP (bgrade, bfilegrade) < 0
- || (azSwork_files != NULL
- && bsearch ((pointer) &zname,
- (pointer) azSwork_files,
- chad, sizeof (char *),
+ || (asSwork_files != NULL
+ && bsearch ((pointer) &slook,
+ (pointer) asSwork_files,
+ chad, sizeof (struct ssfilename),
iswork_cmp) != NULL))
ubuffree (zname);
else
@@ -368,18 +389,24 @@ fsysdep_get_work_init (qsys, bgrade)
if (cSwork_files >= callocated)
{
callocated += CWORKFILES;
- azSwork_files =
- (char **) xrealloc ((pointer) azSwork_files,
- callocated * sizeof (char *));
+ asSwork_files =
+ ((struct ssfilename *)
+ xrealloc ((pointer) asSwork_files,
+ (callocated * sizeof (struct ssfilename))));
}
- azSwork_files[cSwork_files] = zname;
+ asSwork_files[cSwork_files].zfile = zname;
+ asSwork_files[cSwork_files].bgrade = bfilegrade;
++cSwork_files;
+ if (cSwork_files - chad > COMMANDS_PER_SCAN)
+ break;
}
}
#if SPOOLDIR_SVR4
closedir (qdir);
+ if (cSwork_files - chad > COMMANDS_PER_SCAN)
+ break;
}
qdir = qgdir;
#endif
@@ -389,10 +416,10 @@ fsysdep_get_work_init (qsys, bgrade)
/* Sorting the files alphabetically will get the grades in the
right order, since all the file prefixes are the same. */
-
- if (cSwork_files > chad)
- qsort ((pointer) (azSwork_files + chad), cSwork_files - chad,
- sizeof (char *), iswork_cmp);
+ if (cSwork_files > iSwork_file)
+ qsort ((pointer) (asSwork_files + iSwork_file),
+ cSwork_files - iSwork_file,
+ sizeof (struct ssfilename), iswork_cmp);
return TRUE;
}
@@ -417,7 +444,7 @@ fsysdep_get_work (qsys, bgrade, qcmd)
if (qSwork_file != NULL && qSwork_file->cdid >= qSwork_file->clines)
qSwork_file = NULL;
- if (azSwork_files == NULL)
+ if (asSwork_files == NULL)
{
qcmd->bcmd = 'H';
return TRUE;
@@ -437,6 +464,7 @@ fsysdep_get_work (qsys, bgrade, qcmd)
char *zline;
size_t cline;
char *zname;
+ char bfilegrade;
/* Read all the lines of a command file into memory. */
do
@@ -464,7 +492,8 @@ fsysdep_get_work (qsys, bgrade, qcmd)
return FALSE;
}
- zname = zsysdep_in_dir (zdir, azSwork_files[iSwork_file]);
+ zname = zsysdep_in_dir (zdir, asSwork_files[iSwork_file].zfile);
+ bfilegrade = asSwork_files[iSwork_file].bgrade;
++iSwork_file;
@@ -521,6 +550,7 @@ fsysdep_get_work (qsys, bgrade, qcmd)
}
qfile->zfile = zname;
+ qfile->bgrade = bfilegrade;
qfile->clines = iline;
qfile->cdid = 0;
qSwork_file = qfile;
@@ -554,6 +584,7 @@ fsysdep_get_work (qsys, bgrade, qcmd)
qSwork_file->aslines[iline].zline = NULL;
continue;
}
+ qcmd->bgrade = qSwork_file->bgrade;
qSwork_file->aslines[iline].qfile = qSwork_file;
qcmd->pseq = (pointer) (&qSwork_file->aslines[iline]);
@@ -652,14 +683,14 @@ void
usysdep_get_work_free (qsys)
const struct uuconf_system *qsys;
{
- if (azSwork_files != NULL)
+ if (asSwork_files != NULL)
{
size_t i;
for (i = 0; i < cSwork_files; i++)
- ubuffree ((pointer) azSwork_files[i]);
- xfree ((pointer) azSwork_files);
- azSwork_files = NULL;
+ ubuffree ((pointer) asSwork_files[i].zfile);
+ xfree ((pointer) asSwork_files);
+ asSwork_files = NULL;
cSwork_files = 0;
iSwork_file = 0;
}
@@ -710,6 +741,7 @@ zsysdep_save_temp_file (pseq)
if (! fsysdep_move_file (qline->ztemp, zto, TRUE, FALSE, FALSE,
(const char *) NULL))
{
+ /* Leave the file where it was, not that is much help. */
ubuffree (zto);
return "Could not move file to preservation directory";
}
@@ -743,7 +775,7 @@ zsysdep_jobid (qsys, pseq)
this is a remote file; returning -1 will cause zsfind_file to do
the right thing. */
-char
+int
bsgrade (pseq)
pointer pseq;
{
diff --git a/gnu/libexec/uucp/libunix/xqtfil.c b/gnu/libexec/uucp/libunix/xqtfil.c
index 9edb40f23fef..75cbc5393472 100644
--- a/gnu/libexec/uucp/libunix/xqtfil.c
+++ b/gnu/libexec/uucp/libunix/xqtfil.c
@@ -1,7 +1,7 @@
/* xqtfil.c
Routines to read execute files.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char xqtfil_rcsid[] = "$Id: xqtfil.c,v 1.1 1993/08/05 18:24:46 conklin Exp $";
+const char xqtfil_rcsid[] = "$Id: xqtfil.c,v 1.2 1994/05/07 18:11:42 ache Exp $";
#endif
#include "uudefs.h"
@@ -144,9 +144,8 @@ zsysdep_get_xqt (pzsystem, pferr)
return NULL;
}
- /* No system name may start with a dot (this is enforced by
- tisystem in sysinf.c). This allows us to quickly skip
- impossible directories. */
+ /* No system name may start with a dot This allows us to
+ quickly skip impossible directories. */
if (qtop->d_name[0] == '.')
continue;
diff --git a/gnu/libexec/uucp/libunix/xqtsub.c b/gnu/libexec/uucp/libunix/xqtsub.c
index 87b558b83086..a7aca2a60efb 100644
--- a/gnu/libexec/uucp/libunix/xqtsub.c
+++ b/gnu/libexec/uucp/libunix/xqtsub.c
@@ -1,7 +1,7 @@
/* xqtsub.c
System dependent functions used only by uuxqt.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -20,13 +20,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
+ c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char xqtsub_rcsid[] = "$Id: xqtsub.c,v 1.1 1993/08/05 18:24:47 conklin Exp $";
+const char xqtsub_rcsid[] = "$Id: xqtsub.c,v 1.2 1994/05/07 18:11:43 ache Exp $";
#endif
#include "uudefs.h"
@@ -89,6 +89,7 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr)
boolean *pferr;
{
char **pz;
+ struct stat s;
*pferr = FALSE;
@@ -110,7 +111,16 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr)
/* If we already have an absolute path, we can get out
immediately. */
if (**pz == '/')
- return zbufcpy (*pz);
+ {
+ /* Quick error check. */
+ if (stat (*pz, &s) != 0)
+ {
+ ulog (LOG_ERROR, "%s: %s", *pz, strerror (errno));
+ *pferr = TRUE;
+ return NULL;
+ }
+ return zbufcpy (*pz);
+ }
break;
}
}
@@ -124,14 +134,12 @@ zsysdep_find_command (zcmd, pzcmds, pzpath, pferr)
for (pz = pzpath; *pz != NULL; pz++)
{
char *zname;
- struct stat s;
zname = zsysdep_in_dir (*pz, zcmd);
if (stat (zname, &s) == 0)
return zname;
}
- *pferr = FALSE;
return NULL;
}
@@ -159,7 +167,8 @@ zsysdep_xqt_local_file (qsys, zfile)
memcpy (zret, zfile + 1, clen);
return zret;
}
- return zsysdep_local_file (zfile, qsys->uuconf_zpubdir);
+ return zsysdep_local_file (zfile, qsys->uuconf_zpubdir,
+ (boolean *) NULL);
}
#if ! ALLOW_FILENAME_ARGUMENTS
@@ -177,9 +186,12 @@ fsysdep_xqt_check_file (qsys, zfile)
{
size_t clen;
+ /* Disallow exact "..", prefix "../", suffix "/..", internal "/../",
+ and restricted absolute paths. */
clen = strlen (zfile);
- if ((clen == sizeof "../" - 1
- && strcmp (zfile, "../") == 0)
+ if ((clen == sizeof ".." - 1
+ && strcmp (zfile, "..") == 0)
+ || strncmp (zfile, "../", sizeof "../" - 1) == 0
|| (clen >= sizeof "/.." - 1
&& strcmp (zfile + clen - (sizeof "/.." - 1), "/..") == 0)
|| strstr (zfile, "/../") != NULL
@@ -358,7 +370,7 @@ fsysdep_execute (qsys, zuser, pazargs, zfullcmd, zinput, zoutput,
/* Pass zchdir as zxqtdir, fnosigs as TRUE, fshell as TRUE if we
aren't already using the shell. */
- ipid = ixsspawn (pazargs, aidescs, FALSE, FALSE, zxqtdir, TRUE,
+ ipid = ixsspawn (pazargs, aidescs, TRUE, FALSE, zxqtdir, TRUE,
! fshell, zpath, qsys->uuconf_zname, zuser);
ierr = errno;