From 4f2ef57437d6d2d789cd4216b1106e94a0d96651 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 6 Mar 1998 00:35:30 +0000 Subject: [PATCH] Use the correct device name in -direct mode. --- usr.sbin/ppp/modem.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index ae6be96054c2..fba92c351353 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.77 1998/01/29 00:42:05 brian Exp $ + * $Id: modem.c,v 1.78 1998/02/19 02:10:11 brian Exp $ * * TODO: */ @@ -226,6 +226,14 @@ IntToSpeed(int nspeed) return B0; } +static void +ModemSetDevice(const char *name) +{ + strncpy(VarDevice, name, sizeof VarDevice - 1); + VarDevice[sizeof VarDevice - 1] = '\0'; + VarBaseDevice = strncmp(VarDevice, "/dev/", 5) ? VarDevice : VarDevice + 5; +} + void DownConnection() { @@ -454,15 +462,9 @@ OpenModem() LogPrintf(LogDEBUG, "OpenModem: Modem is already open!\n"); /* We're going back into "term" mode */ else if (mode & MODE_DIRECT) { - struct cmdargs arg; - arg.cmd = NULL; - arg.data = (const void *)VAR_DEVICE; if (isatty(STDIN_FILENO)) { LogPrintf(LogDEBUG, "OpenModem(direct): Modem is a tty\n"); - cp = ttyname(STDIN_FILENO); - arg.argc = 1; - arg.argv = (char const *const *)&cp; - SetVariable(&arg); + ModemSetDevice(ttyname(STDIN_FILENO)); if (LockModem() == -1) { close(STDIN_FILENO); return -1; @@ -471,9 +473,7 @@ OpenModem() HaveModem(); } else { LogPrintf(LogDEBUG, "OpenModem(direct): Modem is not a tty\n"); - arg.argc = 0; - arg.argv = NULL; - SetVariable(&arg); + ModemSetDevice(""); /* We don't call ModemTimeout() with this type of connection */ HaveModem(); return modem = STDIN_FILENO; @@ -484,11 +484,7 @@ OpenModem() for(tmpDevice=strtok(tmpDeviceList, ","); tmpDevice && (modem < 0); tmpDevice=strtok(NULL,",")) { - strncpy(VarDevice, tmpDevice, sizeof VarDevice - 1); - VarDevice[sizeof VarDevice - 1]= '\0'; - VarBaseDevice = strrchr(VarDevice, '/'); - VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : ""; - + ModemSetDevice(tmpDevice); if (strncmp(VarDevice, "/dev/", 5) == 0) { if (LockModem() == -1) { modem = -1;