]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/utils.c
Large patch from Frank Cusack <fcusack@fcusack.com> to add proper
[ppp.git] / pppd / utils.c
index 580363a950dec0ee7f77afb1681c60f2880217b3..935f56272a87e8ea55db72265095d4011e0d5e97 100644 (file)
@@ -17,7 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: utils.c,v 1.14 2001/05/23 03:39:14 paulus Exp $"
+#define RCSID  "$Id: utils.c,v 1.17 2002/01/14 15:31:34 dfs Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
@@ -29,6 +29,7 @@
 #include <fcntl.h>
 #include <syslog.h>
 #include <netdb.h>
 #include <fcntl.h>
 #include <syslog.h>
 #include <netdb.h>
+#include <time.h>
 #include <utmp.h>
 #include <pwd.h>
 #include <sys/param.h>
 #include <utmp.h>
 #include <pwd.h>
 #include <sys/param.h>
@@ -790,7 +791,7 @@ dump_packet(const char *tag, unsigned char *p, int len)
            return;
     }
 
            return;
     }
 
-    dbglog("%s %P", tag, p - PPP_HDRLEN, len + PPP_HDRLEN);
+    dbglog("%s %P", tag, p, len);
 }
 
 /* Procedures for locking the serial device using a lock file. */
 }
 
 /* Procedures for locking the serial device using a lock file. */
@@ -820,7 +821,7 @@ lock(dev)
 
     result = mklock (dev, (void *) 0);
     if (result == 0) {
 
     result = mklock (dev, (void *) 0);
     if (result == 0) {
-       strlcpy(lock_file, sizeof(lock_file), dev);
+       strlcpy(lock_file, dev, sizeof(lock_file));
        return 0;
     }
 
        return 0;
     }
 
@@ -851,9 +852,20 @@ lock(dev)
             major(sbuf.st_rdev), minor(sbuf.st_rdev));
 #else
     char *p;
             major(sbuf.st_rdev), minor(sbuf.st_rdev));
 #else
     char *p;
+    char lockdev[MAXPATHLEN];
+
+    if ((p = strstr(dev, "dev/")) != NULL) {
+       dev = p + 4;
+       strncpy(lockdev, dev, MAXPATHLEN-1);
+       lockdev[MAXPATHLEN-1] = 0;
+       while ((p = strrchr(lockdev, '/')) != NULL) {
+           *p = '_';
+       }
+       dev = lockdev;
+    } else
+       if ((p = strrchr(dev, '/')) != NULL)
+           dev = p + 1;
 
 
-    if ((p = strrchr(dev, '/')) != NULL)
-       dev = p + 1;
     slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);
 #endif
 
     slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);
 #endif