]> git.ozlabs.org Git - ppp.git/commitdiff
Merge branch 'master' of https://github.com/ncopa/ppp
authorPaul Mackerras <paulus@samba.org>
Fri, 14 Aug 2015 10:11:23 +0000 (20:11 +1000)
committerPaul Mackerras <paulus@samba.org>
Fri, 14 Aug 2015 10:13:41 +0000 (20:13 +1000)
This merges in one commit, which adds the new "defaultroute-metric" option.

Signed-off-by: Paul Mackerras <paulus@samba.org>
17 files changed:
README
pppd/ccp.c
pppd/ccp.h
pppd/chap_ms.c
pppd/ipv6cp.c
pppd/ipv6cp.h
pppd/ipxcp.c
pppd/options.c
pppd/patchlevel.h
pppd/plugins/Makefile.linux
pppd/plugins/pppol2tp/pppol2tp.c
pppd/plugins/radius/radrealms.c
pppd/pppd.h
pppd/sys-linux.c
pppd/sys-solaris.c
pppd/tty.c
solaris/ppp_mod.c

diff --git a/README b/README
index 3f172f8e9332ad1c8781aa508cdd34c31d58254f..a21d9f1dac7bfa143a5fcd334d324edbd76b3864 100644 (file)
--- a/README
+++ b/README
@@ -61,9 +61,20 @@ use any IP address.  (This only applies where the peer is
 authenticating itself to you, of course.)
 
 
-What's new in ppp-2.4.6.
+What's 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,
+  indicating the number of stop bits to use for async serial ports.
+
+* Various bug fixes.
+
+
+What was new in ppp-2.4.6.
+**************************
+
 * Man page updates.
 
 * Several bug fixes.
index 5814f358eb44c5a4791f06b8170c69d45e7c4e9d..7d7922afcfc0b2d4178319dc903dc3c19427c1c3 100644 (file)
@@ -676,7 +676,8 @@ ccp_cilen(f)
     ccp_options *go = &ccp_gotoptions[f->unit];
 
     return (go->bsd_compress? CILEN_BSD_COMPRESS: 0)
-       + (go->deflate? CILEN_DEFLATE: 0)
+       + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0)
+       + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
        + (go->predictor_1? CILEN_PREDICTOR_1: 0)
        + (go->predictor_2? CILEN_PREDICTOR_2: 0)
        + (go->mppe? CILEN_MPPE: 0);
index 6f4a2fee0a2c6692b11a74318821b39b566e0bbe..76446db007c00604120f7044cc67be520ad3650c 100644 (file)
@@ -37,7 +37,7 @@ typedef struct ccp_options {
     bool predictor_2;          /* do Predictor-2? */
     bool deflate_correct;      /* use correct code for deflate? */
     bool deflate_draft;                /* use draft RFC code for deflate? */
-    bool mppe;                 /* do MPPE? */
+    u_char mppe;               /* MPPE bitfield */
     u_short bsd_bits;          /* # bits/code for BSD Compress */
     u_short deflate_size;      /* lg(window size) for Deflate */
     short method;              /* code for chosen compression method */
index 016b42e0c10ee9a845a3e96ad8aa55dcb2b0464c..c2bd00f9c6f7ec0e3e3a5dd6b00c4153b6c41d25 100644 (file)
@@ -382,7 +382,7 @@ chapms2_make_response(unsigned char *response, int id, char *our_name,
                      unsigned char *private)
 {
        const struct chapms2_response_cache_entry *cache_entry;
-       unsigned char auth_response[MS_AUTH_RESPONSE_LENGTH];
+       unsigned char auth_response[MS_AUTH_RESPONSE_LENGTH+1];
 
        challenge++;    /* skip length, should be 16 */
        *response++ = MS_CHAP2_RESPONSE_LEN;
index caa2b265d7e7b20f3b3bb1a093d88d26fb1cdcda..356ff84ead4103cb846c31c6e806786b166a33e5 100644 (file)
@@ -249,10 +249,8 @@ static option_t ipv6cp_option_list[] = {
     { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
       "Use (default) IPv4 address as interface identifier", 1 },
 
-#if defined(SOL2) || defined(__linux__)
     { "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent,
       "Use uniquely-available persistent value for link local address", 1 },
-#endif /* defined(SOL2) */
 
     { "ipv6cp-restart", o_int, &ipv6cp_fsm[0].timeouttime,
       "Set timeout for IPv6CP", OPT_PRIO },
@@ -1088,7 +1086,6 @@ ipv6_check_options()
     if (!ipv6cp_protent.enabled_flag)
        return;
 
-#if defined(SOL2) || defined(__linux__)
     /*
      * Persistent link-local id is only used when user has not explicitly
      * configure/hard-code the id
@@ -1108,7 +1105,6 @@ ipv6_check_options()
            wo->opt_local = 1;
        }
     }
-#endif
 
     if (!wo->opt_local) {      /* init interface identifier */
        if (wo->use_ip && eui64_iszero(wo->ourid)) {
@@ -1146,15 +1142,8 @@ ipv6_demand_conf(u)
 {
     ipv6cp_options *wo = &ipv6cp_wantoptions[u];
 
-#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
-#if defined(SOL2)
     if (!sif6up(u))
        return 0;
-#else
-    if (!sifup(u))
-       return 0;
-#endif /* defined(SOL2) */
-#endif    
     if (!sif6addr(u, wo->ourid, wo->hisid))
        return 0;
 #if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
@@ -1247,43 +1236,20 @@ ipv6cp_up(f)
        sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
 
     } else {
-       /*
-        * Set LL addresses
-        */
-#if !defined(__linux__) && !defined(SOL2) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
-       if (!sif6addr(f->unit, go->ourid, ho->hisid)) {
-           if (debug)
-               warn("sif6addr failed");
-           ipv6cp_close(f->unit, "Interface configuration failed");
-           return;
-       }
-#endif
-
        /* bring the interface up for IPv6 */
-#if defined(SOL2)
        if (!sif6up(f->unit)) {
            if (debug)
-               warn("sifup failed (IPV6)");
+               warn("sif6up failed (IPV6)");
            ipv6cp_close(f->unit, "Interface configuration failed");
            return;
        }
-#else
-       if (!sifup(f->unit)) {
-           if (debug)
-               warn("sifup failed (IPV6)");
-           ipv6cp_close(f->unit, "Interface configuration failed");
-           return;
-       }
-#endif /* defined(SOL2) */
 
-#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
        if (!sif6addr(f->unit, go->ourid, ho->hisid)) {
            if (debug)
                warn("sif6addr failed");
            ipv6cp_close(f->unit, "Interface configuration failed");
            return;
        }
-#endif
        sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
 
        notice("local  LL address %s", llv6_ntoa(go->ourid));
@@ -1340,16 +1306,14 @@ ipv6cp_down(f)
     } else {
        sifnpmode(f->unit, PPP_IPV6, NPMODE_DROP);
 #if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC)))
-#if defined(SOL2)
        sif6down(f->unit);
-#else
-       sifdown(f->unit);
-#endif /* defined(SOL2) */
 #endif
        ipv6cp_clear_addrs(f->unit, 
                           ipv6cp_gotoptions[f->unit].ourid,
                           ipv6cp_hisoptions[f->unit].hisid);
-#if defined(__linux__) || (defined(SVR4) && (defined(SNI) || defined(__USLC)))
+#if defined(__linux__)
+       sif6down(f->unit);
+#elif defined(SVR4) && (defined(SNI) || defined(__USLC))
        sifdown(f->unit);
 #endif
     }
index cc4568dea22c91cffcdd126835bd33a8c97ca875..2f4c06ddc1892c2c27f26a519f5e78efc82fc219 100644 (file)
@@ -154,9 +154,7 @@ typedef struct ipv6cp_options {
     int opt_local;             /* ourtoken set by option */
     int opt_remote;            /* histoken set by option */
     int use_ip;                        /* use IP as interface identifier */
-#if defined(SOL2) || defined(__linux__)
     int use_persistent;                /* use uniquely persistent value for address */
-#endif /* defined(SOL2) */
     int neg_vj;                        /* Van Jacobson Compression? */
     u_short vj_protocol;       /* protocol value to use in VJ option */
     eui64_t ourid, hisid;      /* Interface identifiers */
index 7b2343e155377120273793d3be2ce2cf28daff29..aaff10f76200fd65799edb2e45c0a506c2147933 100644 (file)
@@ -1194,7 +1194,7 @@ ipxcp_reqci(f, inp, len, reject_if_disagree)
        case IPX_ROUTER_NAME:
            if (cilen >= CILEN_NAME) {
                int name_size = cilen - CILEN_NAME;
-               if (name_size > sizeof (ho->name))
+               if (name_size >= sizeof (ho->name))
                    name_size = sizeof (ho->name) - 1;
                memset (ho->name, 0, sizeof (ho->name));
                memcpy (ho->name, p, name_size);
index ca3f8750c8bb4547895c5057ed3ae937224f0452..c06a2b4ad8ed4560501dfeb61902946c14ea7d96 100644 (file)
@@ -781,10 +781,13 @@ process_option(opt, cmd, argv)
        if (opt->flags & OPT_STATIC) {
            strlcpy((char *)(opt->addr), *argv, opt->upper_limit);
        } else {
+           char **optptr = (char **)(opt->addr);
            sv = strdup(*argv);
            if (sv == NULL)
                novm("option argument");
-           *(char **)(opt->addr) = sv;
+           if (*optptr)
+               free(*optptr);
+           *optptr = sv;
        }
        break;
 
@@ -1294,9 +1297,10 @@ getword(f, word, newlinep, filename)
            /*
             * Store the resulting character for the escape sequence.
             */
-           if (len < MAXWORDLEN-1)
+           if (len < MAXWORDLEN) {
                word[len] = value;
-           ++len;
+               ++len;
+           }
 
            if (!got)
                c = getc(f);
@@ -1334,9 +1338,10 @@ getword(f, word, newlinep, filename)
        /*
         * An ordinary character: store it in the word and get another.
         */
-       if (len < MAXWORDLEN-1)
+       if (len < MAXWORDLEN) {
            word[len] = c;
-       ++len;
+           ++len;
+       }
 
        c = getc(f);
     }
index cd4b6b36563ba02c518909b908101715d0c42c7c..da5e0523dfc847b9e29bd0546c7dff2336fcafe2 100644 (file)
@@ -1,2 +1,2 @@
-#define VERSION                "2.4.6"
-#define DATE           "2 January 2014"
+#define VERSION                "2.4.7"
+#define DATE           "9 August 2014"
index 0a7ec7badb2a62ec71ed9343b3aa6ed07246b00d..ab8cf50d94729168f9b3cafa2d85788ba5b63349 100644 (file)
@@ -14,6 +14,13 @@ SUBDIRS := rp-pppoe pppoatm pppol2tp
 SUBDIRS += radius
 PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
 
+# This setting should match the one in ../Makefile.linux
+MPPE=y
+
+ifdef MPPE
+CFLAGS   += -DMPPE=1
+endif
+
 # include dependencies if present
 ifeq (.depend,$(wildcard .depend))
 include .depend
index a7e3400e72faed5ac0fac7991910af704f7920bf..0e28606f9ae4caae126f32bcabd49d9ae79ce78e 100644 (file)
@@ -74,8 +74,6 @@ struct channel pppol2tp_channel;
 
 static void (*old_snoop_recv_hook)(unsigned char *p, int len) = NULL;
 static void (*old_snoop_send_hook)(unsigned char *p, int len) = NULL;
-static void (*old_ip_up_hook)(void) = NULL;
-static void (*old_ip_down_hook)(void) = NULL;
 
 /* Hook provided to allow other plugins to handle ACCM changes */
 void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
@@ -436,22 +434,18 @@ static void pppol2tp_lcp_snoop_send(unsigned char *p, int len)
  * Interface up/down events
  *****************************************************************************/
 
-static void pppol2tp_ip_up_hook(void)
+static void pppol2tp_ip_up(void *opaque, int arg)
 {
-       if (old_ip_up_hook != NULL)
-               (*old_ip_up_hook)();
-
+       /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
        if (pppol2tp_ip_updown_hook != NULL) {
                (*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
                                           pppol2tp_session_id, 1);
        }
 }
 
-static void pppol2tp_ip_down_hook(void)
+static void pppol2tp_ip_down(void *opaque, int arg)
 {
-       if (old_ip_down_hook != NULL)
-               (*old_ip_down_hook)();
-
+       /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
        if (pppol2tp_ip_updown_hook != NULL) {
                (*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
                                           pppol2tp_session_id, 0);
@@ -478,14 +472,6 @@ static void pppol2tp_check_options(void)
                snoop_recv_hook = pppol2tp_lcp_snoop_recv;
                snoop_send_hook = pppol2tp_lcp_snoop_send;
        }
-
-       /* Hook up ip up/down hooks to send indicator to openl2tpd
-        * that the link is up
-        */
-       old_ip_up_hook = ip_up_hook;
-       ip_up_hook = pppol2tp_ip_up_hook;
-       old_ip_down_hook = ip_down_hook;
-       ip_down_hook = pppol2tp_ip_down_hook;
 }
 
 /* Called just before pppd exits.
@@ -509,6 +495,14 @@ void plugin_init(void)
        fatal("No PPPoL2TP support on this OS");
 #endif
        add_options(pppol2tp_options);
+
+       /* Hook up ip up/down notifiers to send indicator to openl2tpd
+        * that the link is up
+        */
+       add_notifier(&ip_up_notifier, pppol2tp_ip_up, NULL);
+       add_notifier(&ip_down_notifier, pppol2tp_ip_down, NULL);
+       add_notifier(&ipv6_up_notifier, pppol2tp_ip_up, NULL);
+       add_notifier(&ipv6_down_notifier, pppol2tp_ip_down, NULL);
 }
 
 struct channel pppol2tp_channel = {
index 1d8da6247ec926f81514e683dd38de81354341a1..7a30370121bdbca99fab7ac7b7479b74933d3d6b 100644 (file)
@@ -28,7 +28,8 @@ char pppd_version[] = VERSION;
 char radrealms_config[MAXPATHLEN] = "/etc/radiusclient/realms";
 
 static option_t Options[] = {
-    { "realms-config-file", o_string, &radrealms_config },
+    { "realms-config-file", o_string, &radrealms_config,
+      "Configuration file for RADIUS realms", OPT_STATIC, NULL, MAXPATHLEN },
     { NULL }
 };
 
index 47e4d9ad40c36e692b97be97d268116fb8b0ef46..247fa153739b387d217719e6ac1beb8bf407d708 100644 (file)
@@ -279,6 +279,7 @@ extern int  kdebugflag;     /* Tell kernel to print debug messages */
 extern int     default_device; /* Using /dev/tty or equivalent */
 extern char    devnam[MAXPATHLEN];     /* Device name */
 extern int     crtscts;        /* Use hardware flow control */
+extern int     stop_bits;      /* Number of serial port stop bits */
 extern bool    modem;          /* Use modem control lines */
 extern int     inspeed;        /* Input/Output speed requested */
 extern u_int32_t netmask;      /* IP netmask to set on interface */
@@ -657,6 +658,8 @@ int  cifaddr __P((int, u_int32_t, u_int32_t));
                                /* Reset i/f IP addresses */
 #ifdef INET6
 int  ether_to_eui64(eui64_t *p_eui64); /* convert eth0 hw address to EUI64 */
+int  sif6up __P((int));                /* Configure i/f up for IPv6 */
+int  sif6down __P((int));      /* Configure i/f down for IPv6 */
 int  sif6addr __P((int, eui64_t, eui64_t));
                                /* Configure IPv6 addresses for i/f */
 int  cif6addr __P((int, eui64_t, eui64_t));
index 37bdda4d78184bc85ce0c29715f05226e8b0a0bc..b4a435d2a99368bdb48316c798961f1be8f08147 100644 (file)
@@ -205,6 +205,7 @@ static char loop_name[20];
 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 u_int32_t proxy_arp_addr;       /* Addr for proxy arp entry added */
 static char proxy_arp_dev[16];         /* Device for proxy arp entry */
@@ -239,6 +240,7 @@ static void decode_version (char *buf, int *version, int *mod, int *patch);
 static int set_kdebugflag(int level);
 static int ppp_registered(void);
 static int make_ppp_unit(void);
+static int setifstate (int u, int state);
 
 extern u_char  inpacket_buf[]; /* borrowed from main.c */
 
@@ -340,6 +342,9 @@ void sys_cleanup(void)
        if_is_up = 0;
        sifdown(0);
     }
+    if (if6_is_up)
+       sif6down(0);
+
 /*
  * Delete any routes through the device.
  */
@@ -968,6 +973,9 @@ void set_up_tty(int tty_fd, int local)
        break;
     }
 
+    if (stop_bits >= 2)
+       tios.c_cflag |= CSTOPB;
+
     speed = translate_speed(inspeed);
     if (speed) {
        cfsetospeed (&tios, speed);
@@ -2262,25 +2270,12 @@ int sifvjcomp (int u, int vjcomp, int cidcomp, int maxcid)
 
 int sifup(int u)
 {
-    struct ifreq ifr;
-
-    memset (&ifr, '\0', sizeof (ifr));
-    strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-    if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
-       if (! ok_error (errno))
-           error("ioctl (SIOCGIFFLAGS): %m (line %d)", __LINE__);
-       return 0;
-    }
+    int ret;
 
-    ifr.ifr_flags |= (IFF_UP | IFF_POINTOPOINT);
-    if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
-       if (! ok_error (errno))
-           error("ioctl(SIOCSIFFLAGS): %m (line %d)", __LINE__);
-       return 0;
-    }
-    if_is_up++;
+    if ((ret = setifstate(u, 1)))
+       if_is_up++;
 
-    return 1;
+    return ret;
 }
 
 /********************************************************************
@@ -2291,11 +2286,59 @@ int sifup(int u)
 
 int sifdown (int u)
 {
-    struct ifreq ifr;
-
     if (if_is_up && --if_is_up > 0)
        return 1;
 
+#ifdef INET6
+    if (if6_is_up)
+       return 1;
+#endif /* INET6 */
+
+    return setifstate(u, 0);
+}
+
+#ifdef INET6
+/********************************************************************
+ *
+ * sif6up - Config the interface up for IPv6
+ */
+
+int sif6up(int u)
+{
+    int ret;
+
+    if ((ret = setifstate(u, 1)))
+       if6_is_up = 1;
+
+    return ret;
+}
+
+/********************************************************************
+ *
+ * sif6down - Disable the IPv6CP protocol and config the interface
+ *           down if there are no remaining protocols.
+ */
+
+int sif6down (int u)
+{
+    if6_is_up = 0;
+
+    if (if_is_up)
+       return 1;
+
+    return setifstate(u, 0);
+}
+#endif /* INET6 */
+
+/********************************************************************
+ *
+ * setifstate - Config the interface up or down
+ */
+
+static int setifstate (int u, int state)
+{
+    struct ifreq ifr;
+
     memset (&ifr, '\0', sizeof (ifr));
     strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
     if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
@@ -2304,7 +2347,10 @@ int sifdown (int u)
        return 0;
     }
 
-    ifr.ifr_flags &= ~IFF_UP;
+    if (state)
+       ifr.ifr_flags |= IFF_UP;
+    else
+       ifr.ifr_flags &= ~IFF_UP;
     ifr.ifr_flags |= IFF_POINTOPOINT;
     if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
        if (! ok_error (errno))
index 50ce3dfac2d39a28e1ba26a3e5175f6bc0a73388..93d90332e0d4f2116b17800970e082cf193640dd 100644 (file)
@@ -1225,6 +1225,9 @@ set_up_tty(fd, local)
     }
 #endif
 
+    if (stop_bits >= 2)
+       tios.c_cflag |= CSTOPB;
+
     tios.c_cflag |= CS8 | CREAD | HUPCL;
     if (local || !modem)
        tios.c_cflag |= CLOCAL;
index d571b111d7e34755d9304104c075dcbcc16f4e44..c9a0b33715bc829a7dae446f5f5e1b29d1d78e26 100644 (file)
@@ -136,6 +136,7 @@ struct stat devstat;                /* result of stat() on devnam */
 
 /* option variables */
 int    crtscts = 0;            /* Use hardware flow control */
+int    stop_bits = 1;          /* Number of serial port stop bits */
 bool   modem = 1;              /* Use modem control lines */
 int    inspeed = 0;            /* Input/Output speed requested */
 bool   lockflag = 0;           /* Create lock file to lock the serial dev */
@@ -221,6 +222,9 @@ option_t tty_options[] = {
       OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
     { "xonxoff", o_special_noarg, (void *)setxonxoff,
       "Set software (XON/XOFF) flow control", OPT_PRIOSUB },
+    { "stop-bits", o_int, &stop_bits,
+      "Number of stop bits in serial port",
+      OPT_PRIO | OPT_PRIVFIX | OPT_LIMITS, NULL, 2, 1 },
 
     { "modem", o_bool, &modem,
       "Use modem control lines", OPT_PRIO | 1 },
index 4f4fd44668b0801440d6617b6e8f574ddd14cdc7..80ca20345644fb583a488bc1f68475eec1f3bd38 100644 (file)
@@ -91,7 +91,7 @@ static struct dev_ops ppp_ops = {
 
 static struct modldrv modldrv = {
     &mod_driverops,                    /* says this is a pseudo driver */
-    "PPP-2.4.6 multiplexing driver",
+    "PPP-2.4.7 multiplexing driver",
     &ppp_ops                           /* driver ops */
 };