]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-osf.c
make sure fds 0, 1, 2 are always open
[ppp.git] / pppd / sys-osf.c
index 45e176f788caabc4fbf8ea8aef7cd376e8eac227..6d882a95c3af914e9bf105ced7c78d7df019de7a 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: sys-osf.c,v 1.24 1999/04/01 07:20:10 paulus Exp $";
+static char rcsid[] = "$Id: sys-osf.c,v 1.27 1999/05/12 06:16:16 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -200,7 +200,7 @@ sys_check_options()
     return 1;
 }
 
-
+#if 0
 /*
  * daemon - Detach us from controlling terminal session.
  */
@@ -224,6 +224,7 @@ daemon(nochdir, noclose)
     }
     return 0;
 }
+#endif
 
 /*
  * ppp_available - check whether the system has any ppp interfaces
@@ -374,6 +375,13 @@ establish_ppp(fd)
             if (i != fd && i != sockfd)
                 close(i);
         closed_stdio = 1;
+       /* make sure 0, 1, 2 are open to /dev/null */
+       while ((i = open("/dev/null", O_RDWR)) >= 0) {
+           if (i > 2) {
+               close(i);
+               break;
+           }
+       }
     }
 
     /*
@@ -1112,6 +1120,7 @@ sifdown(u)
 {
     struct ifreq ifr;
 
+    bzero(&ifr, sizeof(ifr));
     strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
     if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) {
        error("Couldn't mark interface down (get): %m");
@@ -1204,7 +1213,8 @@ sifaddr(u, o, h, m)
         ret = 0;
     }
 
-    ifr.ifr_metric = link_mtu;
+    ifr.ifr_data = (caddr_t)&link_mtu;
+
     if (ioctl(sockfd, SIOCSIPMTU, &ifr) < 0) {
        error("Couldn't set IP MTU: %m");
         ret = 0;
@@ -1434,9 +1444,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);
@@ -1658,6 +1668,7 @@ get_pty(master_fdp, slave_fdp, slave_name, uid)
     return 1;
 }
 
+#if 0
 /*
  * Code for locking/unlocking the serial device.
  * This code is derived from chat.c.
@@ -1761,6 +1772,7 @@ unlock()
        lock_file = NULL;
     }
 }
+#endif
 
 int
 set_filters(pass, active)