Index: l2tpd.c =================================================================== RCS file: /usr/local/cvsroot/l2tpd/l2tpd.c,v retrieving revision 1.14 diff -u -r1.14 l2tpd.c --- l2tpd.c 21 Aug 2002 17:26:28 -0000 1.14 +++ l2tpd.c 26 Aug 2002 15:45:57 -0000 @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -253,8 +254,8 @@ int start_pppd (struct call *c, struct ppp_opts *opts) { - char a, b; - char tty[80]; + /* char a, b; */ + char *tty; char *stropt[80]; struct ppp_opts *p; #ifdef USE_KERNEL @@ -302,22 +303,62 @@ else { #endif - if ((c->fd = getPtyMaster (&a, &b)) < 0) + c->fd = open("/dev/ptmx", O_RDWR); + if (c->fd == -1) + { + log (LOG_WARNING, "%s: unable to open /dev/ptmx to allocate pty\n", + __FUNCTION__); + return -EINVAL; + } else + { + if (grantpt(c->fd)) + { + log (LOG_WARNING, "%s: unable to grantpt() on pty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + if (unlockpt(c->fd)) + { + log (LOG_WARNING, "%s: unable to unlockpt() on pty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + tty = ptsname(c->fd); + if (tty == NULL) + { + log (LOG_WARNING, "%s: unable to obtain name of slave tty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + } + + + +/* if ((c->fd = getPtyMaster (&a, &b)) < 0) { log (LOG_WARNING, "%s: unable to allocate pty, abandoning!\n", __FUNCTION__); return -EINVAL; - } + } */ /* set fd opened above to not echo so we don't see read our own packets back of the file descriptor that we just wrote them to */ tcgetattr (c->fd, &ptyconf); *(c->oldptyconf) = ptyconf; - ptyconf.c_cflag &= ~(ICANON | ECHO); + ptyconf.c_lflag &= ~(ICANON | ECHO); tcsetattr (c->fd, TCSANOW, &ptyconf); - snprintf (tty, sizeof (tty), "/dev/tty%c%c", a, b); + /* snprintf (tty, sizeof (tty), "/dev/tty%c%c", a, b); */ fd2 = open (tty, O_RDWR); + if (fd2 == -1) + { + log (LOG_WARNING, "%s: unable to open slave tty %s\n", __FUNCTION__, tty); + close(c->fd); + return -EINVAL; + } #ifdef USE_KERNEL }