--- l2tpd.orig/l2tpd.c	2003-11-04 10:16:27.000000000 +0000
+++ l2tpd/l2tpd.c	2003-11-04 10:08:33.000000000 +0000
@@ -13,6 +13,8 @@
  *
  */
 
+#define USE_KERNEL BOB
+
 #include <stdlib.h>
 #include <sys/utsname.h>
 #include <sys/stat.h>
@@ -273,6 +275,12 @@
 #endif
     struct termios ptyconf;
     char *str;
+
+    char pid_name[ STRLEN ];
+    char unit_command[ STRLEN ];
+
+    snprintf( unit_command, sizeof( unit_command ), "unit" );
+   
     p = opts;
     stropt[0] = strdup (PPPD);
     while (p)
@@ -302,7 +310,7 @@
         ioctl (server_socket, L2TPIOCGETCALLOPTS, &co);
         stropt[pos++] = strdup ("channel");
         stropt[pos] = (char *) malloc (10);
-        snprintf (stropt[pos], 10, "%d", co.id);
+        snprintf (stropt[pos], 10, "%d", co.id + 1);
         pos++;
         stropt[pos] = NULL;
     }
@@ -332,21 +340,24 @@
 #ifdef USE_KERNEL
     }
 #endif
+
+#ifdef DEBUG
     str = stropt[0];
-#ifdef DEBUG_PPPD
-    log (LOG_DEBUG, "%s: I'm running:  ", __FUNCTION__);
+    log (LOG_LOG, "%s: I'm running:  ", __FUNCTION__);
     for (x = 0; stropt[x]; x++)
     {
-        log (LOG_DEBUG, "\"%s\" ", stropt[x]);
+        log (LOG_LOG, "\"%s\" ", stropt[x]);
     };
-    log (LOG_DEBUG, "\n");
+    log (LOG_LOG, "\n");
 #endif
     c->pppd = fork ();
+
     if (c->pppd < 0)
     {
         log (LOG_WARN, "%s: unable to fork(), abandoning!\n", __FUNCTION__);
         return -EINVAL;
     }
+        
     else if (!c->pppd)
     {
         struct call *sc;
@@ -388,6 +399,19 @@
         /* close the control pipe fd */
         close (control_fd);
 
+	/* Rename the connection using "Unit" */
+        /* prefix a "9" to the front of the ppp name, i.e. ppp9" then add the PID */
+        /* which should allow this to be unique */
+
+        snprintf( pid_name, sizeof( pid_name ), "9%d", (int) getpid());
+	
+        stropt[ pos++ ] = unit_command;
+	stropt[ pos++ ] = pid_name;
+	stropt[ pos ] = NULL;
+	
+	//po = add_opt( po, "unit" );
+        //po = add_opt( po, pid_name );
+	
         execv (PPPD, stropt);
         log (LOG_WARN, "%s: Exec of %s failed!\n", __FUNCTION__, PPPD);
         exit (1);
diff -Nurb l2tpd-0.69/l2tpd.c l2tpd-0.69.new/l2tpd.c
--- l2tpd-0.69/l2tpd.c	2004-11-10 12:55:48.000000000 +0000
+++ l2tpd-0.69.new/l2tpd.c	2004-11-10 12:55:09.000000000 +0000
@@ -1038,7 +1038,7 @@
            write a new pid file immediately. */
         if (pid && (pid == getpid () || kill (pid, 0) < 0)) {
             unlink (gconfig.pidfile);
-            if ((i = open (gconfig.pidfile, O_WRONLY | O_CREAT, 0640)) >= 0)
+            if ((i = open (gconfig.pidfile, O_WRONLY | O_CREAT, 0644)) >= 0)
             {
                 snprintf (buf, sizeof(buf), "%d\n", (int)getpid());
                 write (i, buf, strlen(buf));
diff -Nurb l2tpd-0.69.old/l2tpd.c l2tpd-0.69/l2tpd.c
--- l2tpd-0.69.old/l2tpd.c	2004-11-10 12:56:51.000000000 +0000
+++ l2tpd-0.69/l2tpd.c	2004-11-10 13:01:50.000000000 +0000
@@ -1059,7 +1059,7 @@
 
     if(! pidfilewritten) {
         unlink(gconfig.pidfile);
-        if ((i = open (gconfig.pidfile, O_WRONLY | O_CREAT, 0640)) >= 0) {
+        if ((i = open (gconfig.pidfile, O_WRONLY | O_CREAT, 0644)) >= 0) {
             snprintf (buf, strlen(buf), "%d\n", (int)getpid());
             write (i, buf, strlen(buf));
             close (i);
diff -Nurb l2tpd-0.69.old/l2tpd.c l2tpd-0.69/l2tpd.c
--- l2tpd-0.69.old/l2tpd.c	2004-11-10 13:04:59.000000000 +0000
+++ l2tpd-0.69/l2tpd.c	2004-11-10 13:07:36.000000000 +0000
@@ -1060,7 +1060,7 @@
     if(! pidfilewritten) {
         unlink(gconfig.pidfile);
         if ((i = open (gconfig.pidfile, O_WRONLY | O_CREAT, 0644)) >= 0) {
-            snprintf (buf, strlen(buf), "%d\n", (int)getpid());
+            snprintf (buf, sizeof(buf), "%d\n", (int)getpid());
             write (i, buf, strlen(buf));
             close (i);
             pidfilewritten = 1;
