Change ``set device'' so that it parses its arguments as one
device per argument rather than the old way of concatenating everything then splitting the result at commas and whitespace. Old syntax of ``set device /dev/cuaa0, /dev/cuaa1'' may no longer contain the comma, but syntax such as ``set device "!ssh host ppp -direct label"'' is now possible.
This commit is contained in:
parent
37aa35f17e
commit
9a2c03d6d7
@ -80,3 +80,6 @@ o Random dial timeouts are now between 1 and 30 seconds inclusive rather
|
|||||||
than between 0 and 29.
|
than between 0 and 29.
|
||||||
o Ppp now accepts M$CHAP (as well as normal CHAP) by default. If this
|
o Ppp now accepts M$CHAP (as well as normal CHAP) by default. If this
|
||||||
is not required, you must ``deny chap05 chap80''.
|
is not required, you must ``deny chap05 chap80''.
|
||||||
|
o The ``set device'' command now expects each device to be specified as an
|
||||||
|
argument rather than concatentating all arguments and splitting based
|
||||||
|
on commas and spaces.
|
||||||
|
@ -15,21 +15,22 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: defs.h,v 1.40 1999/02/25 20:05:55 brian Exp $
|
* $Id: defs.h,v 1.41 1999/02/26 21:28:10 brian Exp $
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check the following definitions for your machine environment */
|
/* Check the following definitions for your machine environment */
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
# define MODEM_LIST "/dev/cuaa1, /dev/cuaa0" /* name of tty device */
|
# define MODEM_LIST "/dev/cuaa1\0/dev/cuaa0" /* name of tty device */
|
||||||
#else
|
#else
|
||||||
# ifdef __OpenBSD__
|
# ifdef __OpenBSD__
|
||||||
# define MODEM_LIST "/dev/cua01, /dev/cua00" /* name of tty device */
|
# define MODEM_LIST "/dev/cua01\0/dev/cua00" /* name of tty device */
|
||||||
# else
|
# else
|
||||||
# define MODEM_LIST "/dev/tty01, /dev/tty00" /* name of tty device */
|
# define MODEM_LIST "/dev/tty01\0/dev/tty00" /* name of tty device */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#define NMODEMS 2
|
||||||
|
|
||||||
#define _PATH_PPP "/etc/ppp"
|
#define _PATH_PPP "/etc/ppp"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: modem.c,v 1.110 1999/04/21 08:03:35 brian Exp $
|
* $Id: modem.c,v 1.111 1999/04/26 08:54:34 brian Exp $
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
*/
|
*/
|
||||||
@ -36,7 +36,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h> /* TIOCOUTQ */
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -132,8 +132,8 @@ modem_Create(struct datalink *dl, int type)
|
|||||||
p->cfg.rts_cts = MODEM_CTSRTS;
|
p->cfg.rts_cts = MODEM_CTSRTS;
|
||||||
p->cfg.speed = MODEM_SPEED;
|
p->cfg.speed = MODEM_SPEED;
|
||||||
p->cfg.parity = CS8;
|
p->cfg.parity = CS8;
|
||||||
strncpy(p->cfg.devlist, MODEM_LIST, sizeof p->cfg.devlist - 1);
|
memcpy(p->cfg.devlist, MODEM_LIST, sizeof MODEM_LIST);
|
||||||
p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0';
|
p->cfg.ndev = NMODEMS;
|
||||||
p->cfg.cd.required = 0;
|
p->cfg.cd.required = 0;
|
||||||
p->cfg.cd.delay = DEF_CDDELAY;
|
p->cfg.cd.delay = DEF_CDDELAY;
|
||||||
|
|
||||||
@ -263,8 +263,10 @@ modem_SetDevice(struct physical *physical, const char *name)
|
|||||||
|
|
||||||
strncpy(physical->name.full, name, sizeof physical->name.full - 1);
|
strncpy(physical->name.full, name, sizeof physical->name.full - 1);
|
||||||
physical->name.full[sizeof physical->name.full - 1] = '\0';
|
physical->name.full[sizeof physical->name.full - 1] = '\0';
|
||||||
physical->name.base = strncmp(physical->name.full, _PATH_DEV, len) ?
|
physical->name.base = *physical->name.full == '!' ?
|
||||||
physical->name.full : physical->name.full + len;
|
physical->name.full + 1 :
|
||||||
|
strncmp(physical->name.full, _PATH_DEV, len) ?
|
||||||
|
physical->name.full : physical->name.full + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -498,11 +500,8 @@ int
|
|||||||
modem_Open(struct physical *modem, struct bundle *bundle)
|
modem_Open(struct physical *modem, struct bundle *bundle)
|
||||||
{
|
{
|
||||||
struct termios rstio;
|
struct termios rstio;
|
||||||
int oldflag;
|
int oldflag, devno;
|
||||||
char *host, *port;
|
char *host, *port, *cp, *dev;
|
||||||
char *cp;
|
|
||||||
char tmpDeviceList[sizeof modem->cfg.devlist];
|
|
||||||
char *tmpDevice;
|
|
||||||
|
|
||||||
if (modem->fd >= 0)
|
if (modem->fd >= 0)
|
||||||
log_Printf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
log_Printf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
||||||
@ -527,14 +526,17 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
|||||||
return modem->fd = STDIN_FILENO;
|
return modem->fd = STDIN_FILENO;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strncpy(tmpDeviceList, modem->cfg.devlist, sizeof tmpDeviceList - 1);
|
dev = modem->cfg.devlist;
|
||||||
tmpDeviceList[sizeof tmpDeviceList - 1] = '\0';
|
devno = 0;
|
||||||
|
while (devno < modem->cfg.ndev && modem->fd < 0) {
|
||||||
for(tmpDevice=strtok(tmpDeviceList, ", "); tmpDevice && modem->fd < 0;
|
modem_SetDevice(modem, dev);
|
||||||
tmpDevice=strtok(NULL,", ")) {
|
|
||||||
modem_SetDevice(modem, tmpDevice);
|
|
||||||
|
|
||||||
if (*modem->name.full == '/') {
|
if (*modem->name.full == '/') {
|
||||||
|
/* PPP via a device file */
|
||||||
|
/*
|
||||||
|
* XXX: Fix me - this should be another sort of link (similar to a
|
||||||
|
* physical
|
||||||
|
*/
|
||||||
if (modem_lock(modem, bundle->unit) != -1) {
|
if (modem_lock(modem, bundle->unit) != -1) {
|
||||||
modem->fd = ID0open(modem->name.full, O_RDWR | O_NONBLOCK);
|
modem->fd = ID0open(modem->name.full, O_RDWR | O_NONBLOCK);
|
||||||
if (modem->fd < 0) {
|
if (modem->fd < 0) {
|
||||||
@ -555,13 +557,13 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
|||||||
*/
|
*/
|
||||||
int fids[2];
|
int fids[2];
|
||||||
|
|
||||||
modem->name.base = modem->name.full + 1;
|
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, fids) < 0)
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, fids) < 0)
|
||||||
log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n",
|
log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
else {
|
else {
|
||||||
int stat;
|
int stat, argc;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
char *argv[MAXARGS];
|
||||||
|
|
||||||
stat = fcntl(fids[0], F_GETFL, 0);
|
stat = fcntl(fids[0], F_GETFL, 0);
|
||||||
if (stat > 0) {
|
if (stat > 0) {
|
||||||
@ -573,22 +575,36 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
|||||||
log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n",
|
log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
close(fids[0]);
|
close(fids[0]);
|
||||||
timer_TermService();
|
timer_TermService();
|
||||||
|
setuid(geteuid());
|
||||||
|
|
||||||
|
switch (fork()) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -1:
|
||||||
|
log_Printf(LogPHASE, "Unable to fork to drop parent: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
default:
|
||||||
|
_exit(127);
|
||||||
|
}
|
||||||
|
|
||||||
fids[1] = fcntl(fids[1], F_DUPFD, 3);
|
fids[1] = fcntl(fids[1], F_DUPFD, 3);
|
||||||
dup2(fids[1], STDIN_FILENO);
|
dup2(fids[1], STDIN_FILENO);
|
||||||
dup2(fids[1], STDOUT_FILENO);
|
dup2(fids[1], STDOUT_FILENO);
|
||||||
dup2(fids[1], STDERR_FILENO);
|
dup2(fids[1], STDERR_FILENO);
|
||||||
setuid(geteuid());
|
|
||||||
if (fork())
|
argc = MakeArgs(modem->name.base, argv, VECSIZE(argv));
|
||||||
exit(127);
|
command_Expand(argv, argc, (char const *const *)argv, bundle, 0);
|
||||||
execlp(modem->name.base, modem->name.base, NULL);
|
execvp(*argv, argv);
|
||||||
fprintf(stderr, "execvp failed: %s: %s\n", modem->name.base,
|
fprintf(stderr, "execvp failed: %s: %s\r\n", *argv,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(127);
|
_exit(127);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
close(fids[1]);
|
close(fids[1]);
|
||||||
modem->fd = fids[0];
|
modem->fd = fids[0];
|
||||||
@ -599,36 +615,35 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if ((cp = strchr(modem->name.full, ':')) != NULL) {
|
||||||
/* PPP over TCP */
|
/* PPP over TCP */
|
||||||
/*
|
/*
|
||||||
* XXX: Fix me - this should be another sort of link (similar to a
|
* XXX: Fix me - this should be another sort of link (similar to a
|
||||||
* physical
|
* physical
|
||||||
*/
|
*/
|
||||||
cp = strchr(modem->name.full, ':');
|
*cp = '\0';
|
||||||
if (cp) {
|
host = modem->name.full;
|
||||||
*cp = '\0';
|
port = cp + 1;
|
||||||
host = modem->name.full;
|
if (*host && *port) {
|
||||||
port = cp + 1;
|
modem->fd = OpenConnection(modem->link.name, host, port);
|
||||||
if (*host && *port) {
|
*cp = ':'; /* Don't destroy name.full */
|
||||||
modem->fd = OpenConnection(modem->link.name, host, port);
|
if (modem->fd >= 0) {
|
||||||
*cp = ':'; /* Don't destroy name.full */
|
modem_Found(modem, bundle);
|
||||||
if (modem->fd >= 0) {
|
log_Printf(LogDEBUG, "%s: Opened socket %s\n", modem->link.name,
|
||||||
modem_Found(modem, bundle);
|
modem->name.full);
|
||||||
log_Printf(LogDEBUG, "%s: Opened socket %s\n", modem->link.name,
|
}
|
||||||
modem->name.full);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*cp = ':'; /* Don't destroy name.full */
|
|
||||||
log_Printf(LogWARN, "%s: Invalid host:port: \"%s\"\n",
|
|
||||||
modem->link.name, modem->name.full);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log_Printf(LogWARN, "%s: Device (%s) must begin with a '/',"
|
*cp = ':'; /* Don't destroy name.full */
|
||||||
" a '!' or be a host:port pair\n", modem->link.name,
|
log_Printf(LogWARN, "%s: Invalid host:port: \"%s\"\n",
|
||||||
modem->name.full);
|
modem->link.name, modem->name.full);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log_Printf(LogWARN, "%s: Device (%s) must begin with a '/',"
|
||||||
|
" a '!' or be a host:port pair\n", modem->link.name,
|
||||||
|
modem->name.full);
|
||||||
}
|
}
|
||||||
|
dev += strlen(dev) + 1;
|
||||||
|
devno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modem->fd < 0)
|
if (modem->fd < 0)
|
||||||
@ -887,9 +902,8 @@ int
|
|||||||
modem_ShowStatus(struct cmdargs const *arg)
|
modem_ShowStatus(struct cmdargs const *arg)
|
||||||
{
|
{
|
||||||
struct physical *modem = arg->cx->physical;
|
struct physical *modem = arg->cx->physical;
|
||||||
#ifdef TIOCOUTQ
|
const char *dev;
|
||||||
int nb;
|
int n;
|
||||||
#endif
|
|
||||||
|
|
||||||
prompt_Printf(arg->prompt, "Name: %s\n", modem->link.name);
|
prompt_Printf(arg->prompt, "Name: %s\n", modem->link.name);
|
||||||
prompt_Printf(arg->prompt, " State: ");
|
prompt_Printf(arg->prompt, " State: ");
|
||||||
@ -912,8 +926,8 @@ modem_ShowStatus(struct cmdargs const *arg)
|
|||||||
prompt_Printf(arg->prompt, " Connect Count: %d\n",
|
prompt_Printf(arg->prompt, " Connect Count: %d\n",
|
||||||
modem->connect_count);
|
modem->connect_count);
|
||||||
#ifdef TIOCOUTQ
|
#ifdef TIOCOUTQ
|
||||||
if (modem->fd >= 0 && ioctl(modem->fd, TIOCOUTQ, &nb) >= 0)
|
if (modem->fd >= 0 && ioctl(modem->fd, TIOCOUTQ, &n) >= 0)
|
||||||
prompt_Printf(arg->prompt, " Physical outq: %d\n", nb);
|
prompt_Printf(arg->prompt, " Physical outq: %d\n", n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prompt_Printf(arg->prompt, " Queued Packets: %d\n",
|
prompt_Printf(arg->prompt, " Queued Packets: %d\n",
|
||||||
@ -921,8 +935,17 @@ modem_ShowStatus(struct cmdargs const *arg)
|
|||||||
prompt_Printf(arg->prompt, " Phone Number: %s\n", arg->cx->phone.chosen);
|
prompt_Printf(arg->prompt, " Phone Number: %s\n", arg->cx->phone.chosen);
|
||||||
|
|
||||||
prompt_Printf(arg->prompt, "\nDefaults:\n");
|
prompt_Printf(arg->prompt, "\nDefaults:\n");
|
||||||
prompt_Printf(arg->prompt, " Device List: %s\n", modem->cfg.devlist);
|
|
||||||
prompt_Printf(arg->prompt, " Characteristics: ");
|
prompt_Printf(arg->prompt, " Device List: ");
|
||||||
|
dev = modem->cfg.devlist;
|
||||||
|
for (n = 0; n < modem->cfg.ndev; n++) {
|
||||||
|
if (n)
|
||||||
|
prompt_Printf(arg->prompt, ", ");
|
||||||
|
prompt_Printf(arg->prompt, "\"%s\"", dev);
|
||||||
|
dev += strlen(dev) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_Printf(arg->prompt, "\n Characteristics: ");
|
||||||
if (physical_IsSync(arg->cx->physical))
|
if (physical_IsSync(arg->cx->physical))
|
||||||
prompt_Printf(arg->prompt, "sync");
|
prompt_Printf(arg->prompt, "sync");
|
||||||
else
|
else
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: physical.c,v 1.6 1998/08/25 17:48:43 brian Exp $
|
* $Id: physical.c,v 1.7 1999/01/10 01:26:29 brian Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -71,10 +71,11 @@ physical_SetDeviceList(struct physical *p, int argc, const char *const *argv)
|
|||||||
p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0';
|
p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0';
|
||||||
for (f = 0, pos = 0; f < argc && pos < sizeof p->cfg.devlist - 1; f++) {
|
for (f = 0, pos = 0; f < argc && pos < sizeof p->cfg.devlist - 1; f++) {
|
||||||
if (pos)
|
if (pos)
|
||||||
p->cfg.devlist[pos++] = ' ';
|
p->cfg.devlist[pos++] = '\0';
|
||||||
strncpy(p->cfg.devlist + pos, argv[f], sizeof p->cfg.devlist - pos - 1);
|
strncpy(p->cfg.devlist + pos, argv[f], sizeof p->cfg.devlist - pos - 1);
|
||||||
pos += strlen(p->cfg.devlist + pos);
|
pos += strlen(p->cfg.devlist + pos);
|
||||||
}
|
}
|
||||||
|
p->cfg.ndev = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: physical.h,v 1.6 1999/02/16 00:16:56 brian Exp $
|
* $Id: physical.h,v 1.7 1999/04/03 11:54:00 brian Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -55,7 +55,8 @@ struct physical {
|
|||||||
unsigned rts_cts : 1; /* Is rts/cts enabled? */
|
unsigned rts_cts : 1; /* Is rts/cts enabled? */
|
||||||
unsigned parity; /* What parity is enabled? (TTY flags) */
|
unsigned parity; /* What parity is enabled? (TTY flags) */
|
||||||
unsigned speed; /* Modem speed */
|
unsigned speed; /* Modem speed */
|
||||||
char devlist[LINE_LEN]; /* Comma-separated list of devices */
|
char devlist[LINE_LEN]; /* NUL separated list of devices */
|
||||||
|
int ndev; /* number of devices in list */
|
||||||
struct {
|
struct {
|
||||||
unsigned required : 1; /* Is cd *REQUIRED* on this device */
|
unsigned required : 1; /* Is cd *REQUIRED* on this device */
|
||||||
int delay; /* Wait this many seconds after login script */
|
int delay; /* Wait this many seconds after login script */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user