]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-NeXT.c
Fix an fd leak on the discovery socket.
[ppp.git] / pppd / sys-NeXT.c
index 7db81d4a43038954cccde98426018319232680b6..bf819f6af5293884cdbfa00548a975f06f39e4d3 100644 (file)
@@ -2,26 +2,49 @@
  * sys-next.c - System-dependent procedures for setting up
  * PPP interfaces on NeXT 3.2/3.3  systems
  *
- * Copyright (c) 1989 Carnegie Mellon University.
  * Copyright (c) 1994 Philippe-Andre Prindeville.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by Carnegie Mellon University.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The name "Carnegie Mellon University" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For permission or any legal
+ *    details, please contact
+ *      Office of Technology Transfer
+ *      Carnegie Mellon University
+ *      5000 Forbes Avenue
+ *      Pittsburgh, PA  15213-3890
+ *      (412) 268-4387, fax: (412) 268-7395
+ *      tech-transfer@andrew.cmu.edu
+ *
+ * 4. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by Computing Services
+ *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
+ *
+ * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef lint
-static char rcsid[] = "$Id: sys-NeXT.c,v 1.16 1999/03/19 04:23:46 paulus Exp $";
-#endif
+#define RCSID  "$Id: sys-NeXT.c,v 1.21 2002/12/04 23:03:32 paulus Exp $"
 
 #include <stdio.h>
 #include <termios.h>
@@ -58,6 +81,8 @@ static char rcsid[] = "$Id: sys-NeXT.c,v 1.16 1999/03/19 04:23:46 paulus Exp $";
 
 #include "pppd.h"
 
+static const char rcsid[] = RCSID;
+
 static int initdisc = -1;      /* Initial TTY discipline */
 static int initfdflags = -1;   /* Initial file descriptor flags for fd */
 static int ppp_fd = -1;                /* fd which is set to PPP discipline */
@@ -73,8 +98,6 @@ extern int errno;
 static int     restore_term;   /* 1 => we've munged the terminal */
 static struct termios inittermios; /* Initial TTY termios */
 
-static char *lock_file;
-
 static int sockfd;             /* socket for doing interface ioctls */
 static int pppdev;  /* +++ */
 
@@ -1178,7 +1201,7 @@ int have_route_to(u_int32_t addr)
     return -1;
 }
 
-
+#if 0
 /*
  * daemon - Detach us from the terminal session.
  */
@@ -1202,7 +1225,7 @@ daemon(nochdir, noclose)
     }
     return 0;
 }
-
+#endif
 
 char *
 strdup(s)
@@ -1246,9 +1269,9 @@ logwtmp(line, name, host)
     if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0)
        return;
     if (!fstat(fd, &buf)) {
-       strlcpy(ut.ut_line, line, sizeof(ut.ut_line));
-       strlcpy(ut.ut_name, name, sizeof(ut.ut_name));
-       strlcpy(ut.ut_host, host, sizeof(ut.ut_host));
+       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
+       strncpy(ut.ut_name, name, sizeof(ut.ut_name));
+       strncpy(ut.ut_host, host, sizeof(ut.ut_host));
        (void)time(&ut.ut_time);
        if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp))
            (void)ftruncate(fd, buf.st_size);
@@ -1256,6 +1279,7 @@ logwtmp(line, name, host)
     close(fd);
 }
 
+#if 0
 /*
  * Routines for locking and unlocking the serial device, moved here
  * from chat.c.
@@ -1263,6 +1287,8 @@ logwtmp(line, name, host)
 
 #define LOCK_PREFIX    "/usr/spool/uucp/LCK/LCK.."
 
+static char *lock_file;
+
 /*
  * lock - create a lock file for the named device
  */
@@ -1331,6 +1357,7 @@ unlock()
        lock_file = NULL;
     }
 }
+#endif
 
 #if defined(i386) && defined(HAS_BROKEN_IOCTL)
 int
@@ -1455,7 +1482,7 @@ get_idle_time(u, ip)
 int
 get_ppp_stats(u, stats)
     int u;
-    struct ppp_stats *stats;
+    struct pppd_stats *stats;
 {
     struct ifpppstatsreq req;
 
@@ -1465,7 +1492,8 @@ get_ppp_stats(u, stats)
        error("Couldn't get PPP statistics: %m");
        return 0;
     }
-    *stats = req.stats;
+    stats->bytes_in = req.stats.p.ppp_ibytes;
+    stats->bytes_out = req.stats.p.ppp_obytes;
     return 1;
 }