]> git.ozlabs.org Git - ppp.git/commitdiff
Merge branch 'monotonic-time' of https://github.com/themiron/ppp
authorPaul Mackerras <paulus@ozlabs.org>
Mon, 25 May 2020 03:26:55 +0000 (13:26 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Mon, 25 May 2020 03:26:55 +0000 (13:26 +1000)
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
41 files changed:
README
pppd/Makefile.linux
pppd/auth.c
pppd/cbcp.c
pppd/ccp.c
pppd/chap_ms.c
pppd/demand.c
pppd/eap.c
pppd/ecp.c
pppd/eui64.c
pppd/fsm.c
pppd/ipcp.c
pppd/ipv6cp.c
pppd/ipv6cp.h
pppd/ipxcp.c
pppd/lcp.c
pppd/magic.c
pppd/magic.h
pppd/main.c
pppd/multilink.c
pppd/options.c
pppd/patchlevel.h
pppd/plugins/radius/avpair.c
pppd/plugins/radius/clientid.c
pppd/plugins/radius/config.c
pppd/plugins/radius/util.c
pppd/plugins/rp-pppoe/common.c
pppd/plugins/rp-pppoe/config.h
pppd/plugins/rp-pppoe/plugin.c
pppd/plugins/rp-pppoe/pppoe-discovery.c
pppd/plugins/rp-pppoe/pppoe.h
pppd/pppd.8
pppd/pppd.h
pppd/session.c
pppd/sha1.c
pppd/sys-linux.c
pppd/sys-solaris.c
pppd/tty.c
pppd/upap.c
pppd/utils.c
pppdump/pppdump.c

diff --git a/README b/README
index a21d9f1dac7bfa143a5fcd334d324edbd76b3864..b25d06db325a8abcea3efd8be633e7b6d076e715 100644 (file)
--- a/README
+++ b/README
@@ -61,9 +61,33 @@ use any IP address.  (This only applies where the peer is
 authenticating itself to you, of course.)
 
 
-What's new in ppp-2.4.7.
+What's new in ppp-2.4.8.
 ************************
 
+* New pppd options have been added:
+  - ifname, to set the name for the PPP interface device
+  - defaultroute-metric, to set the metric for the default route
+  - defaultroute6, to add an IPv6 default route (with nodefaultroute6
+    to prevent adding an IPv6 default route)
+  - up_sdnotify, to have pppd notify systemd when the link is up.
+
+* The rp-pppoe plugin has new options:
+  - host-uniq, to set the Host-Uniq value to send
+  - pppoe-padi-timeout, to set the timeout for discovery packets
+  - pppoe-padi-attempts, to set the number of discovery attempts.
+
+* Added the CLASS attribute in radius packets.
+
+* Sundry bug fixes.
+
+* Fixed warnings and issues found by static analysis.
+
+* Added Submitting-patches.md.
+
+
+What was new in ppp-2.4.7.
+**************************
+
 * Fixed a potential security issue in parsing option files (CVE-2014-3158).
 
 * There is a new "stop-bits" option, which takes an argument of 1 or 2,
index 2a05bc42492b4b2973653b05cc2007e9eb963238..a22dcfab9d74f9658a1522bada021a41249aa90d 100644 (file)
@@ -99,6 +99,7 @@ CFLAGS   += -DMSLANMAN=1
 endif
 ifdef MPPE
 CFLAGS   += -DMPPE=1
+HEADERS  += mppe.h
 endif
 endif
 
@@ -125,7 +126,7 @@ CFLAGS   += -DHAS_SHADOW
 #LIBS     += -lshadow $(LIBS)
 endif
 
-ifneq ($(wildcard /usr/include/crypt.h),)
+ifneq ($(wildcard $(shell $(CC) --print-sysroot)/usr/include/crypt.h),)
 CFLAGS  += -DHAVE_CRYPT_H=1
 LIBS   += -lcrypt
 endif
@@ -137,7 +138,7 @@ endif
 
 ifdef NEEDDES
 ifndef USE_CRYPT
-CFLAGS   += -I/usr/include/openssl
+CFLAGS   += -I$(shell $(CC) --print-sysroot)/usr/include/openssl
 LIBS     += -lcrypto
 else
 CFLAGS   += -DUSE_CRYPT=1
index 590a265eda7b3cb646493d8fbc812a5a3ed25162..ec137109141fa6428eed257862326aaf6048afff 100644 (file)
 #include "pathnames.h"
 #include "session.h"
 
-static const char rcsid[] = RCSID;
 
 /* Bits in scan_authfile return value */
 #define NONWILD_SERVER 1
index 7f2f7877cbbf4011a007441c3545d4dd2520e8dd..f735ab92271c03a0cddf5e6939b27db3add012a2 100644 (file)
@@ -45,7 +45,6 @@
 #include "fsm.h"
 #include "lcp.h"
 
-static const char rcsid[] = RCSID;
 
 /*
  * Options.
index 7d7922afcfc0b2d4178319dc903dc3c19427c1c3..61947d96992c55872874253a5a8219372b66c59b 100644 (file)
@@ -43,7 +43,6 @@
 #include "lcp.h"       /* lcp_close(), lcp_fsm */
 #endif
 
-static const char rcsid[] = RCSID;
 
 /*
  * Unfortunately there is a bug in zlib which means that using a
index c2bd00f9c6f7ec0e3e3a5dd6b00c4153b6c41d25..1de50428fa4d5636c514957734dd1840c1fc76e5 100644 (file)
@@ -94,7 +94,6 @@
 #include "pppcrypt.h"
 #include "magic.h"
 
-static const char rcsid[] = RCSID;
 
 
 static void    ascii2unicode __P((char[], int, u_char[]));
index 5e57658ea831908e98e7554e23329e51e14918a1..72e379c2e5d42c7ccd1625209e90a5e7e76cf67e 100644 (file)
@@ -52,7 +52,6 @@
 #include "ipcp.h"
 #include "lcp.h"
 
-static const char rcsid[] = RCSID;
 
 char *frame;
 int framelen;
index 6ea6c1f8bff6423c4038edb9e47763e111ea0724..082e95343120954abe1de82991387373344e1ba7 100644 (file)
@@ -76,7 +76,6 @@
 #define        SHA_DIGESTSIZE 20
 #endif
 
-static const char rcsid[] = RCSID;
 
 eap_state eap_states[NUM_PPP];         /* EAP state; one for each unit */
 #ifdef USE_SRP
@@ -1329,6 +1328,12 @@ int len;
        int fd;
 #endif /* USE_SRP */
 
+       /*
+        * Ignore requests if we're not open
+        */
+       if (esp->es_client.ea_state <= eapClosed)
+               return;
+
        /*
         * Note: we update es_client.ea_id *only if* a Response
         * message is being generated.  Otherwise, we leave it the
@@ -1421,7 +1426,7 @@ int len;
                }
 
                /* Not so likely to happen. */
-               if (vallen >= len + sizeof (rhostname)) {
+               if (len - vallen >= sizeof (rhostname)) {
                        dbglog("EAP: trimming really long peer name down");
                        BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
                        rhostname[sizeof (rhostname) - 1] = '\0';
@@ -1737,6 +1742,12 @@ int len;
        u_char dig[SHA_DIGESTSIZE];
 #endif /* USE_SRP */
 
+       /*
+        * Ignore responses if we're not open
+        */
+       if (esp->es_server.ea_state <= eapClosed)
+               return;
+
        if (esp->es_server.ea_id != id) {
                dbglog("EAP: discarding Response %d; expected ID %d", id,
                    esp->es_server.ea_id);
@@ -1847,7 +1858,7 @@ int len;
                }
 
                /* Not so likely to happen. */
-               if (vallen >= len + sizeof (rhostname)) {
+               if (len - vallen >= sizeof (rhostname)) {
                        dbglog("EAP: trimming really long peer name down");
                        BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
                        rhostname[sizeof (rhostname) - 1] = '\0';
@@ -2048,6 +2059,12 @@ u_char *inp;
 int id;
 int len;
 {
+       /*
+        * Ignore failure messages if we're not open
+        */
+       if (esp->es_client.ea_state <= eapClosed)
+               return;
+
        if (!eap_client_active(esp)) {
                dbglog("EAP unexpected failure message in state %s (%d)",
                    eap_state_name(esp->es_client.ea_state),
index e5754e5516f3730fa6b83ea678b89747412434d6..dada8e6c6fb2d875d453db7774d290649c00df00 100644 (file)
@@ -59,7 +59,6 @@
 
 #define RCSID  "$Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp $"
 
-static const char rcsid[] = RCSID;
 
 #include <string.h>
 
index d025eff4c1e2742d8dbf86ee205dc53ff059ab6c..e7be0e1e63e92f1e6fe445627af873badd03a5bb 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "pppd.h"
 
-static const char rcsid[] = RCSID;
 
 /*
  * eui64_ntoa - Make an ascii representation of an interface identifier
index e9bd34f0e8f48fd0da69e4ffea3349691975f435..d78ef793e8f190354777c1ec6baea4ff413b317e 100644 (file)
@@ -55,7 +55,6 @@
 #include "pppd.h"
 #include "fsm.h"
 
-static const char rcsid[] = RCSID;
 
 static void fsm_timeout __P((void *));
 static void fsm_rconfreq __P((fsm *, int, u_char *, int));
index 1624450aa41b4e048e7a201445f66e7f6c167d86..ed6cd4b7b86926bca2b991a4f49a91171128c933 100644 (file)
@@ -61,7 +61,6 @@
 #include "ipcp.h"
 #include "pathnames.h"
 
-static const char rcsid[] = RCSID;
 
 /* global vars */
 ipcp_options ipcp_wantoptions[NUM_PPP];        /* Options that we want to request */
index 356ff84ead4103cb846c31c6e806786b166a33e5..bda91e90afb0b38ca303c666393deec19756e223 100644 (file)
 #include "magic.h"
 #include "pathnames.h"
 
-static const char rcsid[] = RCSID;
 
 /* global vars */
 ipv6cp_options ipv6cp_wantoptions[NUM_PPP];     /* Options that we want to request */
@@ -178,6 +177,7 @@ ipv6cp_options ipv6cp_hisoptions[NUM_PPP];  /* Options that we ack'd */
 int no_ifaceid_neg = 0;
 
 /* local vars */
+static int default_route_set[NUM_PPP];         /* Have set up a default route */
 static int ipv6cp_is_up;
 
 /* Hook for a plugin to know when IPv6 protocol has come up */
@@ -246,6 +246,15 @@ static option_t ipv6cp_option_list[] = {
     { "ipv6cp-accept-local", o_bool, &ipv6cp_allowoptions[0].accept_local,
       "Accept peer's interface identifier for us", 1 },
 
+    { "defaultroute6", o_bool, &ipv6cp_wantoptions[0].default_route,
+      "Add default IPv6 route", OPT_ENABLE|1, &ipv6cp_allowoptions[0].default_route },
+    { "nodefaultroute6", o_bool, &ipv6cp_allowoptions[0].default_route,
+      "disable defaultroute6 option", OPT_A2CLR,
+      &ipv6cp_wantoptions[0].default_route },
+    { "-defaultroute6", o_bool, &ipv6cp_allowoptions[0].default_route,
+      "disable defaultroute6 option", OPT_ALIAS | OPT_A2CLR,
+      &ipv6cp_wantoptions[0].default_route },
+
     { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
       "Use (default) IPv4 address as interface identifier", 1 },
 
@@ -444,6 +453,10 @@ ipv6cp_init(unit)
     wo->vj_protocol = IPV6CP_COMP;
 #endif
 
+    /*
+     * XXX This controls whether the user may use the defaultroute option.
+     */
+    ao->default_route = 1;
 }
 
 
@@ -1152,6 +1165,9 @@ ipv6_demand_conf(u)
 #endif
     if (!sifnpmode(u, PPP_IPV6, NPMODE_QUEUE))
        return 0;
+    if (wo->default_route)
+       if (sif6defaultroute(u, wo->ourid, wo->hisid))
+           default_route_set[u] = 1;
 
     notice("ipv6_demand_conf");
     notice("local  LL address %s", llv6_ntoa(wo->ourid));
@@ -1231,6 +1247,10 @@ ipv6cp_up(f)
                return;
            }
 
+           /* assign a default route through the interface if required */
+           if (ipv6cp_wantoptions[f->unit].default_route)
+               if (sif6defaultroute(f->unit, go->ourid, ho->hisid))
+                   default_route_set[f->unit] = 1;
        }
        demand_rexmit(PPP_IPV6);
        sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
@@ -1252,6 +1272,11 @@ ipv6cp_up(f)
        }
        sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
 
+       /* assign a default route through the interface if required */
+       if (ipv6cp_wantoptions[f->unit].default_route)
+           if (sif6defaultroute(f->unit, go->ourid, ho->hisid))
+               default_route_set[f->unit] = 1;
+
        notice("local  LL address %s", llv6_ntoa(go->ourid));
        notice("remote LL address %s", llv6_ntoa(ho->hisid));
     }
index 2f4c06ddc1892c2c27f26a519f5e78efc82fc219..25235d27fd2313e202a8817fe48b58cf0128e1b6 100644 (file)
 typedef struct ipv6cp_options {
     int neg_ifaceid;           /* Negotiate interface identifier? */
     int req_ifaceid;           /* Ask peer to send interface identifier? */
+    int default_route;         /* Assign default route through interface? */
     int accept_local;          /* accept peer's value for iface id? */
     int opt_local;             /* ourtoken set by option */
     int opt_remote;            /* histoken set by option */
index aaff10f76200fd65799edb2e45c0a506c2147933..04605b123524498c3969fcb433e062caf4d33ec1 100644 (file)
@@ -62,7 +62,6 @@
 #include "pathnames.h"
 #include "magic.h"
 
-static const char rcsid[] = RCSID;
 
 /* global vars */
 ipxcp_options ipxcp_wantoptions[NUM_PPP];      /* Options that we want to request */
index 8ed2778bfb672084181a0b27834dfcfdbb875abb..625d2f75a20debb9bebe19768d49e7ba5cfcceef 100644 (file)
@@ -56,7 +56,6 @@
 #include "chap-new.h"
 #include "magic.h"
 
-static const char rcsid[] = RCSID;
 
 /*
  * When the link comes up we want to be able to wait for a short while,
index 2fb23ff4adf48b68e6da309eb90373cd6bcc1d0f..e8bb71fa109b4b7056687e733e694fbcb08e6d61 100644 (file)
 #include "pppd.h"
 #include "magic.h"
 
-static const char rcsid[] = RCSID;
 
-extern long mrand48 __P((void));
-extern void srand48 __P((long));
+extern long mrand48 (void);
+extern void srand48 (long);
 
 /*
  * magic_init - Initialize the magic number generator.
@@ -64,7 +63,7 @@ extern void srand48 __P((long));
  * and current time, currently.
  */
 void
-magic_init()
+magic_init(void)
 {
     long seed;
     struct timeval t;
@@ -78,7 +77,7 @@ magic_init()
  * magic - Returns the next magic number.
  */
 u_int32_t
-magic()
+magic(void)
 {
     return (u_int32_t) mrand48();
 }
@@ -102,20 +101,19 @@ random_bytes(unsigned char *buf, int len)
  */
 
 double
-drand48()
+drand48(void)
 {
     return (double)random() / (double)0x7fffffffL; /* 2**31-1 */
 }
 
 long
-mrand48()
+mrand48(void)
 {
     return random();
 }
 
 void
-srand48(seedval)
-long seedval;
+srand48(long seedval)
 {
     srandom((int)seedval);
 }
index c81213b40545bd204818a4f1053c6aeba5151a53..9d399e307a5fe252321039b708053018054242b8 100644 (file)
@@ -42,8 +42,8 @@
  * $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
  */
 
-void magic_init __P((void));   /* Initialize the magic number generator */
-u_int32_t magic __P((void));   /* Returns the next magic number */
+void magic_init (void);        /* Initialize the magic number generator */
+u_int32_t magic (void);        /* Returns the next magic number */
 
 /* Fill buffer with random bytes */
-void random_bytes __P((unsigned char *buf, int len));
+void random_bytes (unsigned char *buf, int len);
index dccd78b28d07aacdf45a1da146ecbf439f99bf9e..c18ea510582adc7f9365ad2497a7d9a39c4a2072 100644 (file)
@@ -80,7 +80,6 @@
 #include <netdb.h>
 #include <utmp.h>
 #include <pwd.h>
-#include <setjmp.h>
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include "atcp.h"
 #endif
 
-static const char rcsid[] = RCSID;
 
 /* interface vars */
 char ifname[MAXIFNAMELEN];     /* Interface name */
@@ -181,7 +179,7 @@ int got_sighup;
 
 static sigset_t signals_handled;
 static int waiting;
-static sigjmp_buf sigjmp;
+static int sigpipe[2];
 
 char **script_env;             /* Env. variable values for scripts */
 int s_env_nalloc;              /* # words avail at script_env */
@@ -599,19 +597,21 @@ static void
 handle_events()
 {
     struct timeval timo;
+    unsigned char buf[16];
 
     kill_link = open_ccp_flag = 0;
-    if (sigsetjmp(sigjmp, 1) == 0) {
-       sigprocmask(SIG_BLOCK, &signals_handled, NULL);
-       if (got_sighup || got_sigterm || got_sigusr2 || got_sigchld) {
-           sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
-       } else {
-           waiting = 1;
-           sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
-           wait_input(timeleft(&timo));
-       }
-    }
+
+    /* alert via signal pipe */
+    waiting = 1;
+    /* flush signal pipe */
+    for (; read(sigpipe[0], buf, sizeof(buf)) > 0; );
+    add_fd(sigpipe[0]);
+    /* wait if necessary */
+    if (!(got_sighup || got_sigterm || got_sigusr2 || got_sigchld))
+       wait_input(timeleft(&timo));
     waiting = 0;
+    remove_fd(sigpipe[0]);
+
     calltimeout();
     if (got_sighup) {
        info("Hangup (SIGHUP)");
@@ -646,6 +646,14 @@ setup_signals()
 {
     struct sigaction sa;
 
+    /* create pipe to wake up event handler from signal handler */
+    if (pipe(sigpipe) < 0)
+       fatal("Couldn't create signal pipe: %m");
+    fcntl(sigpipe[0], F_SETFD, fcntl(sigpipe[0], F_GETFD) | FD_CLOEXEC);
+    fcntl(sigpipe[1], F_SETFD, fcntl(sigpipe[1], F_GETFD) | FD_CLOEXEC);
+    fcntl(sigpipe[0], F_SETFL, fcntl(sigpipe[0], F_GETFL) | O_NONBLOCK);
+    fcntl(sigpipe[1], F_SETFL, fcntl(sigpipe[1], F_GETFL) | O_NONBLOCK);
+
     /*
      * Compute mask of all interesting signals and install signal handlers
      * for each.  Only one signal handler may be active at a time.  Therefore,
@@ -729,12 +737,16 @@ void
 set_ifunit(iskey)
     int iskey;
 {
+    char ifkey[32];
+
     if (req_ifname[0] != '\0')
        slprintf(ifname, sizeof(ifname), "%s", req_ifname);
     else
        slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
     info("Using interface %s", ifname);
     script_setenv("IFNAME", ifname, iskey);
+    slprintf(ifkey, sizeof(ifkey), "%d", ifunit);
+    script_setenv("UNIT", ifkey, iskey);
     if (iskey) {
        create_pidfile(getpid());       /* write pid to file */
        create_linkpidfile(getpid());
@@ -1432,7 +1444,7 @@ hup(sig)
        kill_my_pg(sig);
     notify(sigreceived, sig);
     if (waiting)
-       siglongjmp(sigjmp, 1);
+       write(sigpipe[1], &sig, sizeof(sig));
 }
 
 
@@ -1453,7 +1465,7 @@ term(sig)
        kill_my_pg(sig);
     notify(sigreceived, sig);
     if (waiting)
-       siglongjmp(sigjmp, 1);
+       write(sigpipe[1], &sig, sizeof(sig));
 }
 
 
@@ -1467,7 +1479,7 @@ chld(sig)
 {
     got_sigchld = 1;
     if (waiting)
-       siglongjmp(sigjmp, 1);
+       write(sigpipe[1], &sig, sizeof(sig));
 }
 
 
@@ -1502,7 +1514,7 @@ open_ccp(sig)
 {
     got_sigusr2 = 1;
     if (waiting)
-       siglongjmp(sigjmp, 1);
+       write(sigpipe[1], &sig, sizeof(sig));
 }
 
 
@@ -1566,7 +1578,8 @@ safe_fork(int infd, int outfd, int errfd)
        /* Executing in the child */
        sys_close();
 #ifdef USE_TDB
-       tdb_close(pppdb);
+       if (pppdb != NULL)
+               tdb_close(pppdb);
 #endif
 
        /* make sure infd, outfd and errfd won't get tromped on below */
index c49c4465ced8f1b65d3be54c35b71c000c0ac33b..3aee0bcf6876686e73599835c483a1d585824cba 100644 (file)
@@ -204,7 +204,7 @@ mp_join_bundle()
                        /* make sure the string is null-terminated */
                        rec.dptr[rec.dsize-1] = 0;
                        /* parse the interface number */
-                       parse_num(rec.dptr, "IFNAME=ppp", &unit);
+                       parse_num(rec.dptr, "UNIT=", &unit);
                        /* check the pid value */
                        if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
                            || !process_exists(pppd_pid)
@@ -420,7 +420,7 @@ owns_unit(key, unit)
        TDB_DATA kd, vd;
        int ret = 0;
 
-       slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
+       slprintf(ifkey, sizeof(ifkey), "UNIT=%d", unit);
        kd.dptr = ifkey;
        kd.dsize = strlen(ifkey);
        vd = tdb_fetch(pppdb, kd);
@@ -445,13 +445,9 @@ get_default_epdisc(ep)
        if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) {
                ep->class = EPD_MAC;
                ep->length = 6;
-               free(p);
                return 1;
        }
 
-       if (p)
-               free(p);
-
        /* see if our hostname corresponds to a reasonable IP address */
        hp = gethostbyname(hostname);
        if (hp != NULL) {
@@ -593,4 +589,3 @@ str_to_epdisc(ep, str)
        ep->length = l;
        return 1;
 }
-
index 5db580a0e270c0628fb99d1400423599a1f0ce5e..e08c1080e738fa3ee2059bf4c632210d4baf58d2 100644 (file)
@@ -79,7 +79,6 @@
 char *strdup __P((char *));
 #endif
 
-static const char rcsid[] = RCSID;
 
 struct option_value {
     struct option_value *next;
@@ -802,6 +801,11 @@ process_option(opt, cmd, argv)
                free(*optptr);
            *optptr = sv;
        }
+       /* obfuscate original argument for things like password */
+       if (opt->flags & OPT_HIDE) {
+           memset(*argv, '?', strlen(*argv));
+           *argv = "********";
+       }
        break;
 
     case o_special_noarg:
@@ -1089,7 +1093,7 @@ showversion(argv)
     char **argv;
 {
     if (phase == PHASE_INITIALIZE) {
-       fprintf(stderr, "pppd version %s\n", VERSION);
+       fprintf(stdout, "pppd version %s\n", VERSION);
        exit(0);
     }
     return 0;
@@ -1358,6 +1362,7 @@ getword(f, word, newlinep, filename)
 
        c = getc(f);
     }
+    word[MAXWORDLEN-1] = 0;    /* make sure word is null-terminated */
 
     /*
      * End of the word: check for errors.
index da5e0523dfc847b9e29bd0546c7dff2336fcafe2..434e98493b9d67a3277d540253054c73a08e97bb 100644 (file)
@@ -1,2 +1,2 @@
-#define VERSION                "2.4.7"
-#define DATE           "9 August 2014"
+#define VERSION                "2.4.8"
+#define DATE           "31 December 2019"
index b22a0a2423dc3302c593508ffd5dd2565350792d..ebc1895c0a6900d79e8d799e596e1169dcaad8e4 100644 (file)
@@ -737,7 +737,7 @@ int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
                }
                else
                {
-                       sprintf (buffer, "%ld", pair->lvalue);
+                       sprintf (buffer, "%d", pair->lvalue);
                        strncpy(value, buffer, (size_t) lv);
                }
                break;
index d49579c43cc3ec10039bf754268495dcad16c4fa..09ec3d04c56346e309d0c209690214dcbe9dd3d8 100644 (file)
@@ -110,7 +110,7 @@ UINT4 rc_map2id(char *name)
        if (*name != '/')
                strcpy(ttyname, "/dev/");
 
-       strncat(ttyname, name, sizeof(ttyname));
+       strncat(ttyname, name, sizeof(ttyname) - strlen(ttyname) -1);
 
        for(p = map2id_list; p; p = p->next)
                if (!strcmp(ttyname, p->name)) return p->id;
index 6e36d898a27a58bdae7e29f8e616797ff1eb0ab2..871cea060cb0e68cbccd99957ca1e800b55b0e8c 100644 (file)
@@ -273,7 +273,7 @@ char *rc_conf_str(char *optname)
        option = find_option(optname, OT_STR);
 
        if (option == NULL)
-               fatal("rc_conf_str: unkown config option requested: %s", optname);
+               fatal("rc_conf_str: unknown config option requested: %s", optname);
        return (char *)option->val;
 }
 
@@ -284,7 +284,7 @@ int rc_conf_int(char *optname)
        option = find_option(optname, OT_INT|OT_AUO);
 
        if (option == NULL)
-               fatal("rc_conf_int: unkown config option requested: %s", optname);
+               fatal("rc_conf_int: unknown config option requested: %s", optname);
        return *((int *)option->val);
 }
 
@@ -295,7 +295,7 @@ SERVER *rc_conf_srv(char *optname)
        option = find_option(optname, OT_SRV);
 
        if (option == NULL)
-               fatal("rc_conf_srv: unkown config option requested: %s", optname);
+               fatal("rc_conf_srv: unknown config option requested: %s", optname);
        return (SERVER *)option->val;
 }
 
@@ -482,26 +482,14 @@ int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
                if ((h = strtok (buffer, " \t\n")) == NULL) /* first hostname */
                        continue;
 
-               memset (hostnm, '\0', AUTH_ID_LEN);
-               len = strlen (h);
-               if (len > AUTH_ID_LEN)
-               {
-                       len = AUTH_ID_LEN;
-               }
-               strncpy (hostnm, h, (size_t) len);
-               hostnm[AUTH_ID_LEN] = '\0';
+               memset (hostnm, '\0', AUTH_ID_LEN + 1);
+               strlcpy (hostnm, h, AUTH_ID_LEN + 1);
 
                if ((s = strtok (NULL, " \t\n")) == NULL) /* and secret field */
                        continue;
 
-               memset (secret, '\0', MAX_SECRET_LENGTH);
-               len = strlen (s);
-               if (len > MAX_SECRET_LENGTH)
-               {
-                       len = MAX_SECRET_LENGTH;
-               }
-               strncpy (secret, s, (size_t) len);
-               secret[MAX_SECRET_LENGTH] = '\0';
+               memset (secret, '\0', MAX_SECRET_LENGTH + 1);
+               strlcpy (secret, s, MAX_SECRET_LENGTH + 1);
 
                if (!strchr (hostnm, '/')) /* If single name form */
                {
index 6f976a712951947217977c57e8606b1cbafec597..740131e8377c51f326b1f465ca94a12526563712 100644 (file)
@@ -73,9 +73,9 @@ void rc_mdelay(int msecs)
 char *
 rc_mksid (void)
 {
-  static char buf[15];
+  static char buf[32];
   static unsigned short int cnt = 0;
-  sprintf (buf, "%08lX%04X%02hX",
+  slprintf(buf, sizeof(buf), "%08lX%04X%02hX",
           (unsigned long int) time (NULL),
           (unsigned int) getpid (),
           cnt & 0xFF);
index 8f175ece345b67bb4d276131aa97f1fce139d31c..9ea7fd609c8774aafbaf2cbe9bb6a6d86679b516 100644 (file)
@@ -65,7 +65,7 @@ parsePacket(PPPoEPacket *packet, ParseFunc *func, void *extra)
 
     /* Step through the tags */
     curTag = packet->payload;
-    while(curTag - packet->payload < len) {
+    while (curTag - packet->payload + TAG_HDR_SIZE <= len) {
        /* Alignment is not guaranteed, so do this by hand... */
        tagType = (curTag[0] << 8) + curTag[1];
        tagLen = (curTag[2] << 8) + curTag[3];
index 570308772932773e2632e75e211695e4e9aa4637..a70885948fb8dff3075ef2f15862c41960b23ac4 100644 (file)
 /* Define if you have the <netpacket/packet.h> header file.  */
 #define HAVE_NETPACKET_PACKET_H 1
 
-/* Define if you have the <sys/cdefs.h> header file.  */
-#define HAVE_SYS_CDEFS_H 1
-
 /* Define if you have the <sys/dlpi.h> header file.  */
 /* #undef HAVE_SYS_DLPI_H */
 
index 9e838d30d58b81208b9289ff239acfb9937f03fb..44e0c31de9f3f6af6abd629ae78954462eccc2f8 100644 (file)
@@ -302,8 +302,10 @@ PPPOEDisconnectDevice(void)
 static void
 PPPOEDeviceOptions(void)
 {
-    char buf[256];
-    snprintf(buf, 256, _PATH_ETHOPT "%s", devnam);
+    char buf[MAXPATHLEN];
+
+    strlcpy(buf, _PATH_ETHOPT, MAXPATHLEN);
+    strlcat(buf, devnam, MAXPATHLEN);
     if (!options_from_file(buf, 0, 0, 1))
        exit(EXIT_OPTION_ERROR);
 
index 8b2e946f4d711d516e6f43fc73dbd45405c8b7a9..f19c6d8b58318203430401ab641236be82d24c4e 100644 (file)
@@ -15,6 +15,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+#include <time.h>
 
 #include "pppoe.h"
 
index b4b309fbeb04ed2c36cd08bf7aa8d0eeed95cb5c..a4e7d5cceefc5712165bfbe15b1e449fd41844e0 100644 (file)
 #error Unknown method for accessing raw Ethernet frames
 #endif
 
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
index 76a209766f2afc89b8e43187d87c05271f740ae5..eed3b5b384896661db07d364abb73f8ccb52b446 100644 (file)
@@ -127,6 +127,12 @@ is no other default route with the same metric.  With the default
 value of -1, the route is only added if there is no default route at
 all.
 .TP
+.B defaultroute6
+Add a default IPv6 route to the system routing tables, using the peer as
+the gateway, when IPv6CP negotiation is successfully completed.
+This entry is removed when the PPP connection is broken.  This option
+is privileged if the \fInodefaultroute6\fR option has been specified.
+.TP
 .B disconnect \fIscript
 Execute the command specified by \fIscript\fR, by passing it to a
 shell, after
@@ -743,6 +749,11 @@ Disable the \fIdefaultroute\fR option.  The system administrator who
 wishes to prevent users from creating default routes with pppd
 can do so by placing this option in the /etc/ppp/options file.
 .TP
+.B nodefaultroute6
+Disable the \fIdefaultroute6\fR option.  The system administrator who
+wishes to prevent users from adding a default route with pppd
+can do so by placing this option in the /etc/ppp/options file.
+.TP
 .B nodeflate
 Disables Deflate compression; pppd will not request or agree to
 compress packets using the Deflate scheme.
@@ -1843,6 +1854,11 @@ Simpson, W.A.
 .I PPP in HDLC-like Framing.
 July 1994.
 .TP
+.B RFC1990
+Sklower, K.; et al.,
+.I The PPP Multilink Protocol (MP).
+August 1996.
+.TP
 .B RFC2284
 Blunk, L.; Vollbrecht, J.,
 .I PPP Extensible Authentication Protocol (EAP).
index 9214aaeb6ff1c778032c922af3cc62bc6de10b5b..4ab2ac1309902b05b21fe71a5113f3d16a066800 100644 (file)
@@ -50,6 +50,8 @@
 #define __PPPD_H__
 
 #include <stdio.h>             /* for FILE */
+#include <stdlib.h>            /* for encrypt */
+#include <unistd.h>            /* for setkey */
 #include <limits.h>            /* for NGROUPS_MAX */
 #include <sys/param.h>         /* for MAXPATHLEN and BSD4_4, if defined */
 #include <sys/types.h>         /* for u_int32_t, if defined */
@@ -683,6 +685,12 @@ int  sifdefaultroute __P((int, u_int32_t, u_int32_t));
                                /* Create default route through i/f */
 int  cifdefaultroute __P((int, u_int32_t, u_int32_t));
                                /* Delete default route through i/f */
+#ifdef INET6
+int  sif6defaultroute __P((int, eui64_t, eui64_t));
+                               /* Create default IPv6 route through i/f */
+int  cif6defaultroute __P((int, eui64_t, eui64_t));
+                               /* Delete default IPv6 route through i/f */
+#endif
 int  sifproxyarp __P((int, u_int32_t));
                                /* Add proxy ARP entry for peer */
 int  cifproxyarp __P((int, u_int32_t));
index 56385dd638742ba9fd7028165104e8565cff0778..473e51e1912f63074eb7c1d058a601f17fc2749e 100644 (file)
@@ -384,8 +384,8 @@ session_start(flags, user, passwd, ttyName, msg)
                 memset((void *)&ll, 0, sizeof(ll));
                (void)time(&tnow);
                 ll.ll_time = tnow;
-                (void)strncpy(ll.ll_line, ttyName, sizeof(ll.ll_line));
-                (void)strncpy(ll.ll_host, ifname, sizeof(ll.ll_host));
+                strlcpy(ll.ll_line, ttyName, sizeof(ll.ll_line));
+                strlcpy(ll.ll_host, ifname, sizeof(ll.ll_host));
                 (void)write(fd, (char *)&ll, sizeof(ll));
                 (void)close(fd);
             }
index f4f975cf516f6c9b58516f08a71152bdef62beca..4e51cee506c237ce2385ad3ed94003e31c9f1914 100644 (file)
@@ -17,6 +17,7 @@
 /* #define SHA1HANDSOFF * Copies data before messing with it. */
 
 #include <string.h>
+#include <time.h>
 #include <netinet/in.h>        /* htonl() */
 #include <net/ppp_defs.h>
 #include "sha1.h"
index b3959915938c19b758c38b0d267e0d2a95abce6a..fc309ad267d02b6ac4e3f66b56ecdf1733bd610e 100644 (file)
 #define MAX_ADDR_LEN 7
 #endif
 
-#if __GLIBC__ >= 2
+#if !defined(__GLIBC__) || __GLIBC__ >= 2
 #include <asm/types.h>         /* glibc 2 conflicts with linux/types.h */
 #include <net/if.h>
 #include <net/if_arp.h>
@@ -163,6 +163,7 @@ struct in6_ifreq {
        eui64_copy(eui64, sin6.s6_addr32[2]);                   \
        } while (0)
 
+static const eui64_t nulleui64;
 #endif /* INET6 */
 
 /* We can get an EIO error on an ioctl if the modem has hung up */
@@ -207,6 +208,7 @@ static unsigned char inbuf[512]; /* buffer for chars read from loopback */
 static int     if_is_up;       /* Interface has been marked up */
 static int     if6_is_up;      /* Interface has been marked up for IPv6, to help differentiate */
 static int     have_default_route;     /* Gateway for default route added */
+static int     have_default_route6;    /* Gateway for default IPv6 route added */
 static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
 static char proxy_arp_dev[16];         /* Device for proxy arp entry */
 static u_int32_t our_old_addr;         /* for detecting address changes */
@@ -234,6 +236,7 @@ static void close_route_table (void);
 static int open_route_table (void);
 static int read_route_table (struct rtentry *rt);
 static int defaultroute_exists (struct rtentry *rt, int metric);
+static int defaultroute6_exists (struct in6_rtmsg *rt, int metric);
 static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr,
                           char *name, int namelen);
 static void decode_version (char *buf, int *version, int *mod, int *patch);
@@ -350,6 +353,10 @@ void sys_cleanup(void)
  */
     if (have_default_route)
        cifdefaultroute(0, 0, 0);
+#ifdef INET6
+    if (have_default_route6)
+       cif6defaultroute(0, nulleui64, nulleui64);
+#endif
 
     if (has_proxy_arp)
        cifproxyarp(0, proxy_arp_addr);
@@ -649,8 +656,8 @@ static int make_ppp_unit()
                char t[MAXIFNAMELEN];
                memset(&ifr, 0, sizeof(struct ifreq));
                slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
-               strncpy(ifr.ifr_name, t, IF_NAMESIZE);
-               strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
+               strlcpy(ifr.ifr_name, t, IF_NAMESIZE);
+               strlcpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
                x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
                if (x < 0)
                    error("Couldn't rename interface %s to %s: %m", t, req_ifname);
@@ -1710,6 +1717,198 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
     return 1;
 }
 
+#ifdef INET6
+/*
+ * /proc/net/ipv6_route parsing stuff.
+ */
+static int route_dest_plen_col;
+static int open_route6_table (void);
+static int read_route6_table (struct in6_rtmsg *rt);
+
+/********************************************************************
+ *
+ * open_route6_table - open the interface to the route table
+ */
+static int open_route6_table (void)
+{
+    char *path;
+
+    close_route_table();
+
+    path = path_to_procfs("/net/ipv6_route");
+    route_fd = fopen (path, "r");
+    if (route_fd == NULL) {
+       error("can't open routing table %s: %m", path);
+       return 0;
+    }
+
+    /* default to usual columns */
+    route_dest_col = 0;
+    route_dest_plen_col = 1;
+    route_gw_col = 4;
+    route_metric_col = 5;
+    route_flags_col = 8;
+    route_dev_col = 9;
+    route_num_cols = 10;
+
+    return 1;
+}
+
+/********************************************************************
+ *
+ * read_route6_table - read the next entry from the route table
+ */
+
+static void hex_to_in6_addr(struct in6_addr *addr, const char *s)
+{
+    char hex8[9];
+    unsigned i;
+    uint32_t v;
+
+    hex8[8] = 0;
+    for (i = 0; i < 4; i++) {
+       memcpy(hex8, s + 8*i, 8);
+       v = strtoul(hex8, NULL, 16);
+       addr->s6_addr32[i] = v;
+    }
+}
+
+static int read_route6_table(struct in6_rtmsg *rt)
+{
+    char *cols[ROUTE_MAX_COLS], *p;
+    int col;
+
+    memset (rt, '\0', sizeof (struct in6_rtmsg));
+
+    if (fgets (route_buffer, sizeof (route_buffer), route_fd) == (char *) 0)
+       return 0;
+
+    p = route_buffer;
+    for (col = 0; col < route_num_cols; ++col) {
+       cols[col] = strtok(p, route_delims);
+       if (cols[col] == NULL)
+           return 0;           /* didn't get enough columns */
+       p = NULL;
+    }
+
+    hex_to_in6_addr(&rt->rtmsg_dst, cols[route_dest_col]);
+    rt->rtmsg_dst_len = strtoul(cols[route_dest_plen_col], NULL, 16);
+    hex_to_in6_addr(&rt->rtmsg_gateway, cols[route_gw_col]);
+
+    rt->rtmsg_metric = strtoul(cols[route_metric_col], NULL, 16);
+    rt->rtmsg_flags = strtoul(cols[route_flags_col], NULL, 16);
+    rt->rtmsg_ifindex = if_nametoindex(cols[route_dev_col]);
+
+    return 1;
+}
+
+/********************************************************************
+ *
+ * defaultroute6_exists - determine if there is a default route
+ */
+
+static int defaultroute6_exists (struct in6_rtmsg *rt, int metric)
+{
+    int result = 0;
+
+    if (!open_route6_table())
+       return 0;
+
+    while (read_route6_table(rt) != 0) {
+       if ((rt->rtmsg_flags & RTF_UP) == 0)
+           continue;
+
+       if (rt->rtmsg_dst_len != 0)
+           continue;
+       if (rt->rtmsg_dst.s6_addr32[0] == 0L
+        && rt->rtmsg_dst.s6_addr32[1] == 0L
+        && rt->rtmsg_dst.s6_addr32[2] == 0L
+        && rt->rtmsg_dst.s6_addr32[3] == 0L
+        && (metric < 0 || rt->rtmsg_metric == metric)) {
+           result = 1;
+           break;
+       }
+    }
+
+    close_route_table();
+    return result;
+}
+
+/********************************************************************
+ *
+ * sif6defaultroute - assign a default route through the address given.
+ *
+ * If the global default_rt_repl_rest flag is set, then this function
+ * already replaced the original system defaultroute with some other
+ * route and it should just replace the current defaultroute with
+ * another one, without saving the current route. Use: demand mode,
+ * when pppd sets first a defaultroute it it's temporary ppp0 addresses
+ * and then changes the temporary addresses to the addresses for the real
+ * ppp connection when it has come up.
+ */
+
+int sif6defaultroute (int unit, eui64_t ouraddr, eui64_t gateway)
+{
+    struct in6_rtmsg rt;
+    char buf[IF_NAMESIZE];
+
+    if (defaultroute6_exists(&rt, dfl_route_metric) &&
+           rt.rtmsg_ifindex != if_nametoindex(ifname)) {
+       if (rt.rtmsg_flags & RTF_GATEWAY)
+           error("not replacing existing default route via gateway");
+       else
+           error("not replacing existing default route through %s",
+                 if_indextoname(rt.rtmsg_ifindex, buf));
+       return 0;
+    }
+
+    memset (&rt, 0, sizeof (rt));
+
+    rt.rtmsg_ifindex = if_nametoindex(ifname);
+    rt.rtmsg_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
+    rt.rtmsg_dst_len = 0;
+
+    rt.rtmsg_flags = RTF_UP;
+    if (ioctl(sock6_fd, SIOCADDRT, &rt) < 0) {
+       if ( ! ok_error ( errno ))
+           error("default route ioctl(SIOCADDRT): %m");
+       return 0;
+    }
+
+    have_default_route6 = 1;
+    return 1;
+}
+
+/********************************************************************
+ *
+ * cif6defaultroute - delete a default route through the address given.
+ */
+
+int cif6defaultroute (int unit, eui64_t ouraddr, eui64_t gateway)
+{
+    struct in6_rtmsg rt;
+
+    have_default_route6 = 0;
+
+    memset (&rt, '\0', sizeof (rt));
+
+    rt.rtmsg_ifindex = if_nametoindex(ifname);
+    rt.rtmsg_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
+    rt.rtmsg_dst_len = 0;
+
+    rt.rtmsg_flags = RTF_UP;
+    if (ioctl(sock6_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
+       if (still_ppp()) {
+           if ( ! ok_error ( errno ))
+               error("default route ioctl(SIOCDELRT): %m");
+           return 0;
+       }
+    }
+
+    return 1;
+}
+#endif /* INET6 */
+
 /********************************************************************
  *
  * sifproxyarp - Make a proxy ARP entry for the peer.
index 83b1815080cd60be33e0e02aa283ed6bbb73b4be..65b173a79695b7e80b8b421072532073be513ca0 100644 (file)
 #define        UDP6_DEV_NAME   "/dev/udp6"
 #endif /* !defined(UDP6_DEV_NAME) && defined(SOL2) */
 
-static const char rcsid[] = RCSID;
 
 #if defined(SOL2)
 /*
@@ -190,6 +189,12 @@ static int ip6fd;          /* IP file descriptor */
 static int     ip6muxid = -1;  /* Multiplexer file descriptor */
 static int     if6_is_up = 0;  /* IPv6 interface has been marked up */
 
+#define IN6_SOCKADDR_FROM_EUI64(s, eui64) do { \
+       (s)->sin6_family = AF_INET6; \
+       (s)->sin6_addr.s6_addr32[0] = htonl(0xfe800000); \
+       eui64_copy(eui64, (s)->sin6_addr.s6_addr32[2]); \
+       } while(0)
+
 #define _IN6_LLX_FROM_EUI64(l, s, eui64, as) do {      \
        s->sin6_addr.s6_addr32[0] = htonl(as);  \
        eui64_copy(eui64, s->sin6_addr.s6_addr32[2]);   \
@@ -199,12 +204,20 @@ static int        if6_is_up = 0;  /* IPv6 interface has been marked up */
        l.lifr_addr = laddr;                    \
        } while (0)
 
+#define _IN6A_LLX_FROM_EUI64(s, eui64, as) do {        \
+       s->s6_addr32[0] = htonl(as);    \
+       eui64_copy(eui64, s->s6_addr32[2]);     \
+       } while (0)
+
 #define IN6_LLADDR_FROM_EUI64(l, s, eui64)  \
     _IN6_LLX_FROM_EUI64(l, s, eui64, 0xfe800000)
 
 #define IN6_LLTOKEN_FROM_EUI64(l, s, eui64) \
     _IN6_LLX_FROM_EUI64(l, s, eui64, 0)
 
+#define IN6A_LLADDR_FROM_EUI64(s, eui64)  \
+    _IN6A_LLX_FROM_EUI64(s, eui64, 0xfe800000)
+
 #endif /* defined(INET6) && defined(SOL2) */
 
 #if defined(INET6) && defined(SOL2)
@@ -239,6 +252,7 @@ static int  tty_npushed;
 static int     if_is_up;       /* Interface has been marked up */
 static u_int32_t remote_addr;          /* IP address of peer */
 static u_int32_t default_route_gateway;        /* Gateway for default route added */
+static eui64_t default_route_gateway6; /* Gateway for default IPv6 route added */
 static u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
 
 /* Prototypes for procedures local to this file. */
@@ -788,6 +802,8 @@ sys_cleanup()
        sifdown(0);
     if (default_route_gateway)
        cifdefaultroute(0, default_route_gateway, default_route_gateway);
+    if (default_route_gateway6.e32[0] != 0 || default_route_gateway6.e32[1] != 0)
+       cif6defaultroute(0, default_route_gateway6, default_route_gateway6);
     if (proxy_arp_addr)
        cifproxyarp(0, proxy_arp_addr);
 #if defined(SOL2)
@@ -1958,6 +1974,70 @@ cif6addr(u, o, h)
     return 1;
 }
 
+/*
+ * sif6defaultroute - assign a default route through the address given.
+ */
+int
+sif6defaultroute(u, l, g)
+    int u;
+    eui64_t l, g;
+{
+    struct {
+       struct rt_msghdr rtm;
+       struct sockaddr_in6 dst;
+       struct sockaddr_in6 gw;
+    } rmsg;
+    static int seq;
+    int rtsock;
+
+#if defined(__USLC__)
+    g = l;                     /* use the local address as gateway */
+#endif
+    memset(&rmsg, 0, sizeof(rmsg));
+
+    rmsg.rtm.rtm_msglen = sizeof (rmsg);
+    rmsg.rtm.rtm_version = RTM_VERSION;
+    rmsg.rtm.rtm_type = RTM_ADD;
+    rmsg.rtm.rtm_flags = RTF_GATEWAY;
+    rmsg.rtm.rtm_addrs = RTA_DST | RTA_GATEWAY;
+    rmsg.rtm.rtm_pid = getpid();
+    rmsg.rtm.rtm_seq = seq++;
+
+    rmsg.dst.sin6_family = AF_INET6;
+
+    rmsg.gw.sin6_family = AF_INET6;
+    IN6_SOCKADDR_FROM_EUI64(&rmsg.gw, g);
+
+    rtsock = socket(PF_ROUTE, SOCK_RAW, 0);
+
+    if (rtsock < 0) {
+       error("Can't add default route: %m");
+       return 0;
+    }
+
+    if (write(rtsock, &rmsg, sizeof(rmsg)) < 0)
+       error("Can't add default route: %m");
+
+    close(rtsock);
+
+    default_route_gateway6 = g;
+    return 1;
+}
+
+/*
+ * cif6defaultroute - delete a default route through the address given.
+ */
+int
+cif6defaultroute(u, l, g)
+    int u;
+    eui64_t l, g;
+{
+    /* No need to do this on Solaris; the kernel deletes the
+       route when the interface goes down. */
+    memset(&default_route_gateway6, 0, sizeof(default_route_gateway6));
+    return 1;
+}
+
 #endif /* defined(SOL2) && defined(INET6) */
 
 
index 485a44d8102cf665b878c384279896217789eb5f..4d5b2dbb534a330d32ee0eb316515049b7ea9d05 100644 (file)
@@ -83,7 +83,6 @@
 #include <netdb.h>
 #include <utmp.h>
 #include <pwd.h>
-#include <setjmp.h>
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/wait.h>
index 8a736218d93bdd3f8fe3a1fd6965e6cfe0da5600..87335339944dfd353fc59a02ff9e8daec5b6b543 100644 (file)
@@ -52,7 +52,6 @@
 #include "pppd.h"
 #include "upap.h"
 
-static const char rcsid[] = RCSID;
 
 static bool hide_password = 1;
 
index 3ac1b60926d20014808dcaf708d59f6adb33ee1a..3602aa61674ab23c538d6e3cebdea511cde42a6e 100644 (file)
@@ -59,7 +59,6 @@
 #include "fsm.h"
 #include "lcp.h"
 
-static const char rcsid[] = RCSID;
 
 #if defined(SUNOS4)
 extern char *strerror();
@@ -167,6 +166,7 @@ vslprintf(buf, buflen, fmt, args)
     u_int32_t ip;
     static char hexchars[] = "0123456789abcdef";
     struct buffer_info bufinfo;
+    int termch;
 
     buf0 = buf;
     --buflen;
@@ -300,13 +300,17 @@ vslprintf(buf, buflen, fmt, args)
                    p = (unsigned char *)"<NULL>";
            if (fillch == '0' && prec >= 0) {
                n = prec;
+               termch = -1;    /* matches no unsigned char value */
            } else {
-               n = strlen((char *)p);
-               if (prec >= 0 && n > prec)
+               n = buflen;
+               if (prec != -1 && n > prec)
                    n = prec;
+               termch = 0;     /* stop on null byte */
            }
            while (n > 0 && buflen > 0) {
                c = *p++;
+               if (c == termch)
+                   break;
                --n;
                if (!quoted && c >= 0x80) {
                    OUTCHAR('M');
@@ -386,9 +390,9 @@ vslprintf(buf, buflen, fmt, args)
            }
            len = num + sizeof(num) - 1 - str;
        } else {
-           len = strlen(str);
-           if (prec >= 0 && len > prec)
-               len = prec;
+           for (len = 0; len < buflen && (prec == -1 || len < prec); ++len)
+               if (str[len] == 0)
+                   break;
        }
        if (width > 0) {
            if (width > buflen)
index 87c2e8f1ac69e95ca080058ad403975ea10a76ba..130300a17d348046dbc4a81100f8fbfcf3d9f0a5 100644 (file)
@@ -320,7 +320,7 @@ dumpppp(f)
                            ++r;
                        ++r;
                        if (endp - r > mru)
-                           printf("     ERROR: length (%d) > MRU (%d)\n",
+                           printf("     ERROR: length (%zd) > MRU (%d)\n",
                                   endp - r, mru);
                        if (decompress && fcs == PPP_GOODFCS) {
                            /* See if this is a CCP or compressed packet */