summaryrefslogtreecommitdiffstats
path: root/sbin/slattach
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-09-20 04:53:08 +0000
committerache <ache@FreeBSD.org>1995-09-20 04:53:08 +0000
commit241d9dc635e0ca470094184ed7f6af3523143f96 (patch)
tree5cc5004466f8b16f0e9c65ad7170499423513b45 /sbin/slattach
parent190b17ed87280b0d691911615b093f2da62f8ac4 (diff)
downloadFreeBSD-src-241d9dc635e0ca470094184ed7f6af3523143f96.zip
FreeBSD-src-241d9dc635e0ca470094184ed7f6af3523143f96.tar.gz
Make uucp-locking optional: -L option
Diffstat (limited to 'sbin/slattach')
-rw-r--r--sbin/slattach/slattach.8114
-rw-r--r--sbin/slattach/slattach.c44
2 files changed, 105 insertions, 53 deletions
diff --git a/sbin/slattach/slattach.8 b/sbin/slattach/slattach.8
index 57ec88b..3b304c7 100644
--- a/sbin/slattach/slattach.8
+++ b/sbin/slattach/slattach.8
@@ -31,7 +31,7 @@
.\"
.\" @(#)slattach.8 6.4 (Berkeley) 3/16/91
.\"
-.\" $Header: /home/ncvs/src/sbin/slattach/slattach.8,v 1.5 1995/09/18 13:33:28 ache Exp $
+.\" $Header: /home/ncvs/src/sbin/slattach/slattach.8,v 1.6 1995/09/18 14:06:36 ache Exp $
.\"
.Dd April 4, 1993
.Dt SLATTACH 8
@@ -40,7 +40,7 @@
.Nm slattach
.Nd attach serial lines as network interfaces
.Sh SYNOPSIS
-.Nm Slattach
+.Nm slattach
.Op Fl a
.Op Fl c
.Op Fl e Ar exit-command
@@ -48,10 +48,11 @@
.Op Fl h
.Op Fl l
.Op Fl n
+.Op Fl z
+.Op Fl L
.Op Fl r Ar redial-command
.Op Fl s Ar baudrate
.Op Fl u Ar unit-command
-.Op Fl z
.Op Fl K Ar keepalive
.Op Fl O Ar outfill
.Op Fl S Ar unit
@@ -71,39 +72,62 @@ headers will be used.
Enables the VJ header compression option. Note that both ends of the link
must be able to use VJ header compression for this to work.
.It Fl e Ar exit-command
-Specifies a command to be invoked within a shell (sh -c exit-command)
-before slattach exits.
+Specifies a command to be invoked within a shell
+.Ql sh \-c Ar exit-command
+before
+.Nm slattach
+exits.
.It Fl f
-Disables the invocation of daemon() to run slattach in the background.
+Disables the invocation of daemon() to run
+.Nm slattach
+in the background.
.It Fl h
Turn on cts/rts style flow control on the slip port, by default no flow
control is done.
.It Fl l
disable modem control (CLOCAL) and ignore carrier detect on the slip
-port. By default the redial-command is invoked upon carrier drop and
-slattach aborts if no redial-command is specified.
+port. By default the
+.Ar redial-commmand
+is invoked upon carrier drop and
+.Nm slattach
+aborts if no
+.Ar redial-commmand
+is specified.
.It Fl n
Throw away ICMP packets. The slip interface will ignore ICMP packets
to prevent slow lines being saturated by ICMP responses.
-.It Fl r Ar redial-command
-Specifies a command to be invoked within a shell (sh -c
-redial-command) whenever carrier is lost on the line.
+.It Fl r Ar redial-commmand
+Specifies a command to be invoked within a shell
+.Ql sh \-c Ar redial-command
+whenever carrier is lost on the line.
.It Fl s Ar baudrate
Specifies the speed of the connection. If not specified, the
default of 9600 is used.
.It Fl u Ar unit-command
When the line is switched to slip discipline, run
-.Ql sh \-c unit-command <last> <current>
-where <last> and <current> are the slip unit numbers when the line was
+.Ql sh \-c Ar unit-command <last> <current>
+where
+.Ar <last>
+and
+.Ar <current>
+are the slip unit numbers when the line was
last opened and the unit number of the current slip connection
respecitvely. The unit number can change after redialing if you are
-using more than one slip line. Slattach will abort if the unit number
+using more than one slip line.
+.Nm Slattach
+will abort if the unit number
changes and
-.Ql \-u unit-command
+.Fl u Ar unit-command
was not specified.
.It Fl z
forces redial
-redial-cmd upon startup irrespective of carrier.
+.Ar redial-command
+upon startup irrespective of carrier.
+.It Fl L
+Use uucp-style device locking. You need it unless you start
+.Nm slattach
+from external program which already does uucp locking.
+Default case is no uucp locking to satisfy such programs.
.It Fl K Ar keepalive
Set SLIP "keep alive" timeout in seconds. If FRAME_END not received in this
timeout, reconnect occurse. Active "out fill" timeout expected from other
@@ -122,8 +146,9 @@ Default is dynamic assignment.
Specifies the name of the tty device.
.Ar Ttyname
should be a string of the form
-.Ql ttyXX or
-.Ql /dev/ttyXX.
+.Ql ttyXX
+or
+.Ql /dev/ttyXX .
.El
.Pp
Only the super-user may attach a network interface.
@@ -138,49 +163,63 @@ process using
is the name that is shown by
.Xr netstat 1
.Pp
-To setup slattach to redial the phone when carrier is lost, use the
-.Ql \-r redial-cmd
+To setup
+.Nm slattach
+to redial the phone when carrier is lost, use the
+.Fl r Ar redial-command
option to specify a script or executable that will reconnect the
serial line to the slip server. For example, the script could redial
the server and log in, etc.
.Pp
To reconfigure the network interface in case the slip unit number
changes, use the
-.Ql \-u unit-cmd
+.Fl u Ar unit-command
option to specify a script or executable that will be invoked as
-.Ql sh \-c unit-cmd old new,
-where old and new are the slip unit numbers before and after
+.Ql sh \-c Ar unit-command old new
+where
+.Ar old
+and
+.Ar new
+are the slip unit numbers before and after
reconnecting the line. The unit number can change if you have more
than one line disconnect at the same time. The first to succeed in
reconnecting will get the lowest unit number.
.Pp
-To kill slattach use
+To kill
+.Nm slattach
+use
.Ql kill -INT
(SIGINT) which causes it to close the tty and exit.
.Pp
To force a redial, use
.Ql kill -HUP
-(SIGHUP) which causes slattach to think carrier was lost and thus invoke
-.Ql sh -c redial-command
+(SIGHUP) which causes
+.Nm slattach
+to think carrier was lost and thus invoke
+.Ql sh \-c Ar redial-command
to reconnect to the server.
.Pp
If you use a hard-wired connection rather than a modem, invoke
-slattach with the
-.Ql \-l
+.Nm slattach
+with the
+.Fl l
option in order to ignore carrier on the slip line.
.Sh EXAMPLES
.Bd -literal -offset indent -compact
-slattach ttyh8
-slattach \-s 4800 /dev/tty01
-slattach \-c \-s 38400 /dev/sio01
+slattach ttyd8
+slattach \-s 4800 /dev/ttyd1
+slattach \-c \-s 38400 /dev/cuaa1
slattach \-r 'kermit -y dial.script >kermit.log 2>&1'
.Ed
.Sh DIAGNOSTICS
-Look for error messages in /var/log/messages (slattach is a daemon).
+Look for error messages in /var/log/messages (
+.Nm slattach
+is a daemon).
Messages indicating the specified interface does not exit, the
requested address is unknown, the user is not privileged and tried to
-alter an interface's configuration are logged there. Slattach also
-logs failure to set the controlling terminal or failure to install
+alter an interface's configuration are logged there.
+.Nm Slattach
+also logs failure to set the controlling terminal or failure to install
signal handlers. Upon connection and redial the ttyname and baud rate
are logged and on shutdown the ttyname is logged.
.Pp
@@ -188,20 +227,21 @@ are logged and on shutdown the ttyname is logged.
.Pa /var/run/slattach.<tty>.pid ,
.Pp
with
-.Aq tty
+.Ar tty
replaced by the terminal path name component of
.Ar ttyname .
This file contains the numerical process ID of the
.Nm slattach
process and can be examined by scripts in oder to send a signal to
-.Nm slattch .
+.Nm slattach .
.Sh SEE ALSO
.Xr startslip 1 ,
.Xr sliplogin 8 ,
.Xr netstat 1 ,
.Xr netintro 4 ,
.Xr ifconfig 8 ,
-.Xr rc 8
+.Xr rc 8 ,
+.Xr uustat 1
.Sh HISTORY
The
.Nm
diff --git a/sbin/slattach/slattach.c b/sbin/slattach/slattach.c
index 4a01e5a..cfd8275 100644
--- a/sbin/slattach/slattach.c
+++ b/sbin/slattach/slattach.c
@@ -78,7 +78,7 @@ void acquire_line(); /* get tty device as controling terminal */
int fd = -1;
char *dev = (char *)0; /* path name of the tty (e.g. /dev/tty01) */
char *dvname; /* basename of dev */
-int locked = 0; /* uucp lock */
+int locked = 0; /* uucp lock active */
int flow_control = 0; /* non-zero to enable hardware flow control. */
int modem_control = HUPCL; /* !CLOCAL+HUPCL iff we watch carrier. */
int comstate; /* TIOCMGET current state of serial driver */
@@ -90,6 +90,7 @@ int foreground = 0; /* act as demon if zero, else don't fork. */
int keepal = 0; /* keepalive timeout */
int outfill = 0; /* outfill timeout */
int sl_unit = -1; /* unit number */
+int uucp_lock = 0; /* do uucp locking */
int exiting = 0; /* allready running exit_handler */
struct termios tty; /* tty configuration/state */
@@ -102,7 +103,7 @@ char *exit_cmd = 0; /* command to exec before exiting. */
static char usage_str[] = "\
usage: %s [-acfhlnz] [-e command] [-r command] [-s speed] [-u command] \\\n\
- [-K timeout] [-O timeout] [-S unit] device\n\
+ [-L] [-K timeout] [-O timeout] [-S unit] device\n\
-a -- autoenable VJ compression\n\
-c -- enable VJ compression\n\
-e ECMD -- run ECMD before exiting\n\
@@ -114,6 +115,7 @@ usage: %s [-acfhlnz] [-e command] [-r command] [-s speed] [-u command] \\\n\
-s # -- set baud rate (default 9600)\n\
-u UCMD -- run 'UCMD <old sl#> <new sl#>' before switch to slip discipline\n\
-z -- run RCMD upon startup irrespective of carrier\n\
+ -L -- do uucp-style device locking\n\
-K # -- set SLIP \"keep alive\" timeout (default 0)\n\
-O # -- set SLIP \"out fill\" timeout (default 0)\n\
-S # -- set SLIP unit number (default is dynamic)\n\
@@ -125,7 +127,7 @@ int main(int argc, char **argv)
extern char *optarg;
extern int optind;
- while ((option = getopt(argc, argv, "ace:fhlnr:s:u:zK:O:S:")) != EOF) {
+ while ((option = getopt(argc, argv, "ace:fhlnr:s:u:zLK:O:S:")) != EOF) {
switch (option) {
case 'a':
slflags |= IFF_LINK2;
@@ -162,6 +164,9 @@ int main(int argc, char **argv)
case 'z':
redial_on_startup = 1;
break;
+ case 'L':
+ uucp_lock = 1;
+ break;
case 'K':
keepal = atoi(optarg);
break;
@@ -281,12 +286,14 @@ void acquire_line()
if ((int)signal(SIGHUP,sighup_handler) < 0) /* Re-enable HUP signal */
syslog(LOG_NOTICE,"cannot install SIGHUP handler: %m");
- /* unlock not needed here, always re-lock with new pid */
- if (uu_lock(dvname)) {
- syslog(LOG_ERR, "can't lock %s", dev);
- exit_handler(1);
+ if (uucp_lock) {
+ /* unlock not needed here, always re-lock with new pid */
+ if (uu_lock(dvname)) {
+ syslog(LOG_ERR, "can't lock %s", dev);
+ exit_handler(1);
+ }
+ locked = 1;
}
- locked = 1;
if ((fd = open(dev, O_RDWR | O_NONBLOCK, 0)) < 0) {
syslog(LOG_ERR, "open(%s) %m", dev);
@@ -440,16 +447,21 @@ again:
setup_line(CLOCAL);
syslog(LOG_NOTICE,"SIGHUP on %s (sl%d); running %s",
dev,unit,redial_cmd);
- uu_unlock(dvname); /* for redial */
- locked = 0;
+ if (locked) {
+ if (uucp_lock)
+ uu_unlock(dvname); /* for redial */
+ locked = 0;
+ }
if (system(redial_cmd))
goto again;
- if (uu_lock(dvname)) {
- syslog(LOG_ERR, "can't relock %s after %s, aborting",
- dev, redial_cmd);
- exit_handler(1);
+ if (uucp_lock) {
+ if (uu_lock(dvname)) {
+ syslog(LOG_ERR, "can't relock %s after %s, aborting",
+ dev, redial_cmd);
+ exit_handler(1);
+ }
+ locked = 1;
}
- locked = 1;
/* Now check again for carrier (dial command is done): */
if (!(modem_control & CLOCAL)) {
tty.c_cflag &= ~CLOCAL;
@@ -538,7 +550,7 @@ void exit_handler(int ret)
*/
if (fd != -1)
close(fd);
- if (locked)
+ if (uucp_lock && locked)
uu_unlock(dvname);
/* Remove the PID file */
OpenPOWER on IntegriCloud