Package: l2tpd Severity: grave Tags: patch The l2tpd binary still uses the legacy PTY method for getting PTYs. The configuration option for this in the kernel is going to be disabled in Debian 2.6.20 kernels for all architectures and has already been removed for some architectures (powerpc, mipsel?).
The patch to fix this is included. It is not the cleanest possible patch, but is based upon the work already found on the internet, mainly here: http://www.jacco2.dds.nl/networking/freeswan-l2tp.html#L2TPconfigLinux (Work by Jacco de Leeuw) I have tested this and it seems to work properly. -- Naked
Index: l2tpd-0.70-pre20031121/l2tpd.c =================================================================== --- l2tpd-0.70-pre20031121.orig/l2tpd.c 2007-02-06 16:40:46.000000000 +0200 +++ l2tpd-0.70-pre20031121/l2tpd.c 2007-02-06 16:57:53.000000000 +0200 @@ -15,7 +15,9 @@ * */ +#define _XOPEN_SOURCE #include <stdlib.h> +#include <sys/types.h> #include <sys/utsname.h> #include <sys/stat.h> #include <sys/wait.h> @@ -274,8 +276,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 @@ -324,29 +326,63 @@ else { #endif - if ((c->fd = getPtyMaster (&a, &b)) < 0) + c->fd = open("/dev/ptmx", O_RDWR | O_NONBLOCK); + if (c->fd == -1) + { + log (LOG_WARN, "%s: unable to open /dev/ptmx to allocate pty\n", + __FUNCTION__); + return -EINVAL; + } else + { + if (grantpt(c->fd)) + { + log (LOG_WARN, "%s: unable to grantpt() on pty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + if (unlockpt(c->fd)) + { + log (LOG_WARN, "%s: unable to unlockpt() on pty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + tty = ptsname(c->fd); + if (tty == NULL) + { + log (LOG_WARN, "%s: unable to obtain name of slave tty\n", + __FUNCTION__); + close(c->fd); + return -EINVAL; + } + } + + + /* if ((c->fd = getPtyMaster (&a, &b)) < 0) { log (LOG_WARN, "%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 &= ~ECHO; + ptyconf.c_lflag &= ~ECHO; tcsetattr (c->fd, TCSANOW, &ptyconf); - snprintf (tty, sizeof (tty), "/dev/tty%c%c", a, b); - fd2 = open (tty, O_RDWR); - if(!fd2) - log(LOG_WARN, "unable to open tty %s", tty); - /* XXX JEF: CHECK ME */ - stropt[pos++] = strdup(tty); - stropt[pos] = NULL; + /* snprintf (tty, sizeof (tty), "/dev/tty%c%c", a, b); */ + fd2 = open (tty, O_RDWR); + if (fd2 == -1) + { + log (LOG_WARN, "%s: unable to open slave tty %s\n", __FUNCTION__, tty); + close(c->fd); + return -EINVAL; + } #ifdef USE_KERNEL }