There was a simpler upstream change to support Unix98 ptys through the
use of openpty(), which I have applied instead.

diff -u l2tpd-0.70-pre20031121/l2tpd.c l2tpd-0.70-pre20031121/l2tpd.c
--- l2tpd-0.70-pre20031121/l2tpd.c
+++ l2tpd-0.70-pre20031121/l2tpd.c
@@ -42,6 +42,7 @@
 #ifdef USE_KERNEL
 #include <sys/ioctl.h>
 #endif
+#include <pty.h>
 #include "l2tp.h"
 
 struct tunnel_list tunnels;
@@ -274,7 +275,6 @@
 
 int start_pppd (struct call *c, struct ppp_opts *opts)
 {
-    char a, b;
     char tty[80];
     char *stropt[80];
     struct ppp_opts *p;
@@ -324,6 +324,8 @@
     else
     {
 #endif
+#ifdef USE_BSD_PTYS
+       char a, b;
         if ((c->fd = getPtyMaster (&a, &b)) < 0)
         {
             log (LOG_WARN, "%s: unable to allocate pty, abandoning!\n",
@@ -347,7 +349,20 @@
                /* XXX JEF: CHECK ME */
                stropt[pos++] = strdup(tty);
                stropt[pos] = NULL;
+#else
+               int pty_fd, tty_fd, fd_flags;
 
+               if (openpty(&pty_fd, &tty_fd, NULL, NULL, NULL) != 0)
+               {
+                       log (LOG_WARN, "%s: unable to allocate pty/tty, 
abandoning!\n",
+                               __FUNCTION__);
+                       return -EINVAL;
+               }
+               fd_flags = fcntl(pty_fd, F_GETFL);
+               fcntl(pty_fd, F_SETFL, fd_flags | O_NONBLOCK);
+               c->fd = pty_fd;
+               fd2 = tty_fd;
+#endif
 #ifdef USE_KERNEL
     }
 #endif
diff -u l2tpd-0.70-pre20031121/Makefile l2tpd-0.70-pre20031121/Makefile
--- l2tpd-0.70-pre20031121/Makefile
+++ l2tpd-0.70-pre20031121/Makefile
@@ -51,6 +51,7 @@
 #
 #OSFLAGS= -DSOLARIS
 #OSLIBS= -lnsl -lsocket
+OSLIB= -lutil
 #
 # Feature flags
 #
only in patch2:
unchanged:
--- l2tpd-0.70-pre20031121.orig/pty.c
+++ l2tpd-0.70-pre20031121/pty.c
@@ -15,6 +15,7 @@
  * from pty-redir by Magosanyi Arpad.
  *
  */
+#ifdef USE_BSD_PTYS
 
 #include "l2tp.h"
 #include <fcntl.h>
@@ -62,3 +63,4 @@
     log (LOG_CRIT, "%s: No more free pseudo-tty's\n", __FUNCTION__);
     return -1;
 }
+#endif
-- END --

I have also taken the liberty of fixing most other open bugs (I hope) in
an NMU with the following changes:

diff -u l2tpd-0.70-pre20031121/avp.h l2tpd-0.70-pre20031121/avp.h
--- l2tpd-0.70-pre20031121/avp.h
+++ l2tpd-0.70-pre20031121/avp.h
@@ -111,8 +111,8 @@
 #define ASSIGNED_TUN_ID_AVP            9
 #define        RX_WIN_SIZE_AVP                 10
 #define        CHALLENGE_AVP                   11
-#define        CHALLENGE_RESP_AVP              12
-#define        CAUSE_ERROR_AVP                 13
+#define        CAUSE_ERROR_AVP                 12
+#define        CHALLENGE_RESP_AVP              13
 #define        ASSIGNED_SES_ID_AVP             14
 #define        SERIAL_NUMBER_AVP               15
 #define        MIN_BPS_AVP                             16
diff -u l2tpd-0.70-pre20031121/debian/control 
l2tpd-0.70-pre20031121/debian/control
--- l2tpd-0.70-pre20031121/debian/control
+++ l2tpd-0.70-pre20031121/debian/control
@@ -13,7 +13,6 @@
-Depends: ${shlibs:Depends}
-Description: A layer 2 tunneling protocol implementation.
+Depends: ${shlibs:Depends}, ppp
+Description: a layer 2 tunneling protocol implementation
  l2tpd is the open source implementation of the L2TP tunneling
- protocol (RFC2661). It does implement both LAC and LNS role 
- in a L2TP networking architecture. The main goal of this protocol is 
- to tunnel PPP frame trough an ip network. 
-
+ protocol (RFC2661).  The main purpose of this protocol is to tunnel
+ PPP frames through IP networks.  It implements both LAC and LNS role
+ in the L2TP networking architecture.
diff -u l2tpd-0.70-pre20031121/debian/copyright 
l2tpd-0.70-pre20031121/debian/copyright
--- l2tpd-0.70-pre20031121/debian/copyright
+++ l2tpd-0.70-pre20031121/debian/copyright
@@ -1,8 +1,11 @@
-This package have been packaged by Jean-Francois Dive <[EMAIL PROTECTED]>
+This software was packaged by Jean-Francois Dive <[EMAIL PROTECTED]>
 as l2tpd.
 
-The upstream source is the open source implementation of l2tpd which can be 
found
-at www.l2tpd.org. This source is a branch from the orginal work of Mark Spencer
-(www.marko.net)
+The upstream source is the open source implementation of l2tpd found
+at <http://l2tpd.sourceforge.net/> and previously at
+<http://www.l2tpd.org>.  This source is a branch from the orginal work
+of Mark Spencer (www.marko.net).
 
-The l2tpd license is the GPL version 2.
+The l2tpd license is the GNU General Public License, version 2.  On
+Debian systems, the complete text of the GNU General Public License
+can be found in `/usr/share/common-licenses/GPL'.
diff -u l2tpd-0.70-pre20031121/debian/changelog 
l2tpd-0.70-pre20031121/debian/changelog
--- l2tpd-0.70-pre20031121/debian/changelog
+++ l2tpd-0.70-pre20031121/debian/changelog
@@ -1,3 +1,18 @@
+l2tpd (0.70-pre20031121-2.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Applied upstream change to remove reliance on BSD pseudo-terminals
+    (Closes: #276746, #409944).
+  * Corrected AVP numbers for challenge-response and cause code
+    (Closes: #265732).
+  * Implemented alignment fix-up for AVPs (Closes: #351870).
+  * Updated no-detach option to pppd (Closes: #298716).
+  * Added dependency on ppp (Closes: #395905).
+  * Updated copyright to mention newer web site and path to GPL text.
+  * Improved package description (Closes: #300003).
+
+ -- Ben Hutchings <[EMAIL PROTECTED]>  Tue, 20 Feb 2007 06:20:44 +0000
+
 l2tpd (0.70-pre20031121-2.1) unstable; urgency=low
 
   * Non-maintainer upload.
reverted:
--- l2tpd-0.70-pre20031121/debian/.#l2tpd.init.1.3
+++ l2tpd-0.70-pre20031121.orig/debian/.#l2tpd.init.1.3
@@ -1,27 +0,0 @@
-#!/bin/sh
-#
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-DAEMON=/usr/sbin/l2tpd
-PIDFILE=/var/run/l2tpd.pid
-
-test -f $DAEMON || exit 0
-
-case "$1" in
-  start)
-    start-stop-daemon --start --verbose --pidfile $PIDFILE --exec $DAEMON 
-    ;;
-  stop)
-    start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DAEMON
-    ;;
-  restart|force-reload)
-    start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DAEMON 
-    sleep 1
-    start-stop-daemon --start --verbose --pidfile $PIDFILE --exec $DAEMON
-    ;;
-  *)
-    echo "Usage: /etc/init.d/l2tdp {start|stop|restart|force-reload}"
-    exit 1
-    ;;
-esac
-
-exit 0
diff -u l2tpd-0.70-pre20031121/avp.c l2tpd-0.70-pre20031121/avp.c
--- l2tpd-0.70-pre20031121/avp.c
+++ l2tpd-0.70-pre20031121/avp.c
@@ -775,6 +775,7 @@
     int firstavp = -1;
     int hidlen = 0;
     char *data = buf->start + sizeof (struct control_hdr);
+       u_int32_t alignedbuf[(sizeof (struct avp_hdr) + 0x400 + 3) / 4];
     avp = (struct avp_hdr *) data;
 
     if (debug_avp)
@@ -867,7 +868,7 @@
             /* We want to rewrite the AVP as an unhidden AVP
                and then pass it along as normal.  Remeber how
                long the AVP was in the first place though! */
-            hidlen = avp->length;
+            hidlen = rlen;
             if (decrypt_avp (data, t))
             {
                 if (debug_avp)
@@ -890,10 +891,12 @@
         else
             hidlen = 0;
 
+               memcpy(alignedbuf, avp, sizeof (struct avp_hdr) + ALENGTH 
(rlen));
+
                /* validate */
                if (avps[attr].validate) 
                {
-                       if(avps[attr].validate(attr, t, c, avp, ALENGTH 
(rlen))) {
+                       if(avps[attr].validate(attr, t, c, (struct avp_hdr *) 
alignedbuf, ALENGTH (rlen))) {
                                 if (AMBIT (rlen))
                 {
                     log (LOG_WARN,
@@ -917,7 +920,7 @@
                /* handling */
         if (avps[attr].handle)
         {
-            if (avps[attr].handle(t, c, avp, ALENGTH (rlen)))
+            if (avps[attr].handle(t, c, (struct avp_hdr *) alignedbuf, ALENGTH 
(rlen)))
             {
                 if (AMBIT (rlen))
                 {
diff -u l2tpd-0.70-pre20031121/control.c l2tpd-0.70-pre20031121/control.c
--- l2tpd-0.70-pre20031121/control.c
+++ l2tpd-0.70-pre20031121/control.c
@@ -808,7 +808,7 @@
         control_xmit (buf);
         po = NULL;
         po = add_opt (po, "passive");
-        po = add_opt (po, "-detach");
+        po = add_opt (po, "nodetach");
         if (c->lac)
         {
             if (c->lac->defaultroute)
@@ -900,7 +900,7 @@
         strncpy (ip2, IPADDY (c->addr), sizeof (ip2));
         po = NULL;
         po = add_opt (po, "passive");
-        po = add_opt (po, "-detach");
+        po = add_opt (po, "nodetach");
         po = add_opt (po, "%s:%s", c->lns->localaddr ? ip1 : "", ip2);
         if (c->lns->authself)
         {
@@ -948,7 +948,7 @@
     case OCCN:                 /* jz: get OCCN, so the only thing we must do 
is to start the pppd */
         po = NULL;
         po = add_opt (po, "passive");
-        po = add_opt (po, "-detach");
+        po = add_opt (po, "nodetach");
         po = add_opt (po, "file");
         strcat (dummy_buf, c->dial_no); /* jz: use /etc/ppp/dialnumber.options 
for pppd - kick it if you dont like */
         strcat (dummy_buf, ".options");
-- END --

However, I still could not recommend using this package.  This is
essentially an alpha version and there is no final release.  The package
should probably be replaced with xl2tpd or rp-l2tpd (not that I can
vouch for their quality).

Ben.

-- 
Ben Hutchings
The obvious mathematical breakthrough [to break modern encryption] would be
development of an easy way to factor large prime numbers. - Bill Gates

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to