]> git.ozlabs.org Git - ppp.git/commitdiff
Merge branch 'master' of git://github.com/cmcqueen/ppp
authorPaul Mackerras <paulus@samba.org>
Fri, 1 Aug 2014 11:41:27 +0000 (21:41 +1000)
committerPaul Mackerras <paulus@samba.org>
Fri, 1 Aug 2014 11:41:27 +0000 (21:41 +1000)
This merges in one commit, which adds the new "stop-bits" option.

Signed-off-by: Paul Mackerras <paulus@samba.org>
pppd/chap_ms.c
pppd/ipv6cp.c
pppd/ipv6cp.h
pppd/options.c
pppd/plugins/Makefile.linux
pppd/plugins/pppol2tp/pppol2tp.c
pppd/plugins/radius/radrealms.c
pppd/pppd.h
pppd/sys-linux.c

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 45fa742cd9ce9d095490ebc68fa199023f8da8cc..f66b7657bc31c9b197b8449fa12902293fdf85d1 100644 (file)
@@ -776,10 +776,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;
 
@@ -1289,9 +1292,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);
@@ -1329,9 +1333,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 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 873b832598f7351c8aece87d09bcc5fced68ec68..247fa153739b387d217719e6ac1beb8bf407d708 100644 (file)
@@ -658,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 163f5618582c109fd68c45d0b8392a745b44d234..e5e9baf8821ff775305a7681441634a0f1bb97c3 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 */
 
@@ -338,6 +340,9 @@ void sys_cleanup(void)
        if_is_up = 0;
        sifdown(0);
     }
+    if (if6_is_up)
+       sif6down(0);
+
 /*
  * Delete any routes through the device.
  */
@@ -2255,25 +2260,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;
 }
 
 /********************************************************************
@@ -2284,11 +2276,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) {
@@ -2297,7 +2337,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))