]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/auth.c
Send NAS-Identifier attribute instead of NAS-IP-Address, if configured.
[ppp.git] / pppd / auth.c
index 469b0f857411fc2c62ead751e8aed6522ebcdbe7..5af2ee0f483f501a707711df1b490dd249e3c9d7 100644 (file)
@@ -32,7 +32,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define RCSID  "$Id: auth.c,v 1.80 2002/07/16 13:11:43 kad Exp $"
+#define RCSID  "$Id: auth.c,v 1.84 2002/09/24 11:35:22 fcusack Exp $"
 
 #include <stdio.h>
 #include <stddef.h>
@@ -228,39 +228,39 @@ option_t auth_options[] = {
     { "auth", o_bool, &auth_required,
       "Require authentication from peer", OPT_PRIO | 1 },
     { "noauth", o_bool, &auth_required,
-      "Don't require peer to authenticate", OPT_PRIOSUB | OPT_PRIV | OPT_A2COPY,
+      "Don't require peer to authenticate", OPT_PRIOSUB | OPT_PRIV,
       &allow_any_ip },
     { "require-pap", o_bool, &lcp_wantoptions[0].neg_upap,
       "Require PAP authentication from peer",
-      OPT_PRIOSUB | OPT_A2COPY | 1, &auth_required },
+      OPT_PRIOSUB | 1, &auth_required },
     { "+pap", o_bool, &lcp_wantoptions[0].neg_upap,
       "Require PAP authentication from peer",
-      OPT_ALIAS | OPT_PRIOSUB | OPT_A2COPY | 1, &auth_required },
-    { "require-chap", o_bool, &lcp_wantoptions[0].neg_chap,
+      OPT_ALIAS | OPT_PRIOSUB | 1, &auth_required },
+    { "require-chap", o_bool, &auth_required,
       "Require CHAP authentication from peer",
-      OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MD5,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
-    { "+chap", o_bool, &lcp_wantoptions[0].neg_chap,
+      OPT_PRIOSUB | OPT_A2OR | MDTYPE_MD5,
+      &lcp_wantoptions[0].chap_mdtype },
+    { "+chap", o_bool, &auth_required,
       "Require CHAP authentication from peer",
-      OPT_ALIAS | OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MD5,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
+      OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MD5,
+      &lcp_wantoptions[0].chap_mdtype },
 #ifdef CHAPMS
-    { "require-mschap", o_bool, &lcp_wantoptions[0].neg_chap,
+    { "require-mschap", o_bool, &auth_required,
       "Require MS-CHAP authentication from peer",
-      OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MICROSOFT,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
-    { "+mschap", o_bool, &lcp_wantoptions[0].neg_chap,
+      OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT,
+      &lcp_wantoptions[0].chap_mdtype },
+    { "+mschap", o_bool, &auth_required,
       "Require MS-CHAP authentication from peer",
-      OPT_ALIAS | OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MICROSOFT,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
-    { "require-mschap-v2", o_bool, &lcp_wantoptions[0].neg_chap,
+      OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT,
+      &lcp_wantoptions[0].chap_mdtype },
+    { "require-mschap-v2", o_bool, &auth_required,
       "Require MS-CHAPv2 authentication from peer",
-      OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MICROSOFT_V2,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
-    { "+mschap-v2", o_bool, &lcp_wantoptions[0].neg_chap,
+      OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT_V2,
+      &lcp_wantoptions[0].chap_mdtype },
+    { "+mschap-v2", o_bool, &auth_required,
       "Require MS-CHAPv2 authentication from peer",
-      OPT_ALIAS | OPT_PRIOSUB | OPT_A2COPY | OPT_A3OR | MDTYPE_MICROSOFT_V2,
-      &auth_required, 0, 0, NULL, 0, 0, &lcp_wantoptions[0].chap_mdtype },
+      OPT_ALIAS | OPT_PRIOSUB | OPT_A2OR | MDTYPE_MICROSOFT_V2,
+      &lcp_wantoptions[0].chap_mdtype },
 #endif
 
     { "refuse-pap", o_bool, &refuse_pap,
@@ -268,7 +268,8 @@ option_t auth_options[] = {
     { "-pap", o_bool, &refuse_pap,
       "Don't allow PAP authentication with peer", OPT_ALIAS | 1 },
     { "refuse-chap", o_bool, &refuse_chap,
-      "Don't agree to auth to peer with CHAP", OPT_A2CLRB | MDTYPE_MD5,
+      "Don't agree to auth to peer with CHAP",
+      OPT_A2CLRB | MDTYPE_MD5,
       &lcp_allowoptions[0].chap_mdtype },
     { "-chap", o_bool, &refuse_chap,
       "Don't allow CHAP authentication with peer",
@@ -277,14 +278,16 @@ option_t auth_options[] = {
 #ifdef CHAPMS
     { "refuse-mschap", o_bool, &refuse_mschap,
       "Don't agree to auth to peer with MS-CHAP",
-      OPT_A2CLRB | MDTYPE_MICROSOFT, &lcp_allowoptions[0].chap_mdtype },
+      OPT_A2CLRB | MDTYPE_MICROSOFT,
+      &lcp_allowoptions[0].chap_mdtype },
     { "-mschap", o_bool, &refuse_mschap,
       "Don't allow MS-CHAP authentication with peer",
       OPT_ALIAS | OPT_A2CLRB | MDTYPE_MICROSOFT,
       &lcp_allowoptions[0].chap_mdtype },
     { "refuse-mschap-v2", o_bool, &refuse_mschap_v2,
       "Don't agree to auth to peer with MS-CHAPv2",
-      OPT_A2CLRB | MDTYPE_MICROSOFT_V2, &lcp_allowoptions[0].chap_mdtype },
+      OPT_A2CLRB | MDTYPE_MICROSOFT_V2,
+      &lcp_allowoptions[0].chap_mdtype },
     { "-mschap-v2", o_bool, &refuse_mschap_v2,
       "Don't allow MS-CHAPv2 authentication with peer",
       OPT_ALIAS | OPT_A2CLRB | MDTYPE_MICROSOFT_V2,
@@ -608,59 +611,62 @@ void
 start_networks(unit)
     int unit;
 {
-    static int started = 0;
     int i;
     struct protent *protp;
     int ecp_required, mppe_required;
 
-    if (!started) {
-       started = 1;
-       new_phase(PHASE_NETWORK);
+    new_phase(PHASE_NETWORK);
 
 #ifdef HAVE_MULTILINK
-       if (multilink) {
-           if (mp_join_bundle()) {
-               if (updetach && !nodetach)
-                   detach();
-               return;
-           }
+    if (multilink) {
+       if (mp_join_bundle()) {
+           if (updetach && !nodetach)
+               detach();
+           return;
        }
+    }
 #endif /* HAVE_MULTILINK */
 
 #ifdef PPP_FILTER
-       if (!demand)
-           set_filters(&pass_filter, &active_filter);
+    if (!demand)
+       set_filters(&pass_filter, &active_filter);
 #endif
-       /* Start CCP and ECP */
-       for (i = 0; (protp = protocols[i]) != NULL; ++i)
-           if ((protp->protocol == PPP_ECP || protp->protocol == PPP_CCP)
-               && protp->enabled_flag && protp->open != NULL)
-               (*protp->open)(0);
-    }
+    /* Start CCP and ECP */
+    for (i = 0; (protp = protocols[i]) != NULL; ++i)
+       if ((protp->protocol == PPP_ECP || protp->protocol == PPP_CCP)
+           && protp->enabled_flag && protp->open != NULL)
+           (*protp->open)(0);
 
     /*
-     * Bring up other network protocols after encryption has completed.
-     * OPENED here merely means that negotiation has completed.  It is
-     * up to the protocol to correctly terminate or disable LCP/NCP 
-     * based on the result of the negotiation.
+     * Bring up other network protocols iff encryption is not required.
      */
     ecp_required = ecp_gotoptions[unit].required;
     mppe_required = ccp_gotoptions[unit].mppe;
-    if ((!ecp_required && !mppe_required)
-       || (ecp_required && ecp_fsm[unit].state == OPENED)
-       || (mppe_required && ccp_fsm[unit].state == OPENED)) {
-       for (i = 0; (protp = protocols[i]) != NULL; ++i)
-           if (protp->protocol < 0xC000
-               && protp->protocol != PPP_CCP && protp->protocol != PPP_ECP
-               && protp->enabled_flag && protp->open != NULL) {
-               (*protp->open)(0);
-               ++num_np_open;
-           }
+    if (!ecp_required && !mppe_required)
+       continue_networks(unit);
+}
 
-       if (num_np_open == 0)
-           /* nothing to do */
-           lcp_close(0, "No network protocols running");
-    }
+void
+continue_networks(unit)
+    int unit;
+{
+    int i;
+    struct protent *protp;
+
+    /*
+     * Start the "real" network protocols.
+     */
+    for (i = 0; (protp = protocols[i]) != NULL; ++i)
+       if (protp->protocol < 0xC000
+           && protp->protocol != PPP_CCP && protp->protocol != PPP_ECP
+           && protp->enabled_flag && protp->open != NULL) {
+           (*protp->open)(0);
+           ++num_np_open;
+       }
+
+    if (num_np_open == 0)
+       /* nothing to do */
+       lcp_close(0, "No network protocols running");
 }
 
 /*
@@ -981,6 +987,10 @@ auth_check_options()
        default_auth = 1;
     }
 
+    /* If we selected any CHAP flavors, we should probably negotiate it. :-) */
+    if (wo->chap_mdtype)
+       wo->neg_chap = 1;
+
     /* If authentication is required, ask peer for CHAP or PAP. */
     if (auth_required) {
        allow_any_ip = 0;
@@ -1355,7 +1365,7 @@ plogin(user, passwd, msg)
     tty = devnam;
     if (strncmp(tty, "/dev/", 5) == 0)
        tty += 5;
-    logwtmp(tty, user, remote_name);           /* Add wtmp login entry */
+    logwtmp(tty, user, ifname);                /* Add wtmp login entry */
 
 #if defined(_PATH_LASTLOG) && !defined(USE_PAM)
     if (pw != (struct passwd *)NULL) {