]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/chap.c
New options system with priorities for option values, with options
[ppp.git] / pppd / chap.c
index b580d2cb40e1cc6ce82f40331cdc01e1b23f4c34..3d7a660618af65dbf1ce71b6f896992a29ffce85 100644 (file)
@@ -33,9 +33,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static char rcsid[] = "$Id: chap.c,v 1.20 1999/03/16 22:54:38 paulus Exp $";
-#endif
+#define RCSID  "$Id: chap.c,v 1.25 2001/03/08 05:11:11 paulus Exp $"
 
 /*
  * TODO:
@@ -53,16 +51,18 @@ static char rcsid[] = "$Id: chap.c,v 1.20 1999/03/16 22:54:38 paulus Exp $";
 #include "chap_ms.h"
 #endif
 
+static const char rcsid[] = RCSID;
+
 /*
  * Command-line options.
  */
 static option_t chap_option_list[] = {
     { "chap-restart", o_int, &chap[0].timeouttime,
-      "Set timeout for CHAP" },
+      "Set timeout for CHAP", OPT_PRIO },
     { "chap-max-challenge", o_int, &chap[0].max_transmits,
-      "Set max #xmits for challenge" },
+      "Set max #xmits for challenge", OPT_PRIO },
     { "chap-interval", o_int, &chap[0].chal_interval,
-      "Set interval for rechallenge" },
+      "Set interval for rechallenge", OPT_PRIO },
 #ifdef MSLANMAN
     { "ms-lanman", o_bool, &ms_lanman,
       "Use LanMan passwd when using MS-CHAP", 1 },
@@ -436,8 +436,8 @@ ChapReceiveChallenge(cstate, inp, id, len)
     rhostname[len] = '\000';
 
     /* Microsoft doesn't send their name back in the PPP packet */
-    if (remote_name[0] != 0 && (explicit_remote || rhostname[0] == 0)) {
-       strlcpy(rhostname, sizeof(rhostname), remote_name);
+    if (explicit_remote || (remote_name[0] != 0 && rhostname[0] == 0)) {
+       strlcpy(rhostname, remote_name, sizeof(rhostname));
        CHAPDEBUG(("ChapReceiveChallenge: using '%q' as remote name",
                   rhostname));
     }
@@ -552,8 +552,8 @@ ChapReceiveResponse(cstate, inp, id, len)
      * do the hash ourselves, and compare the result.
      */
     code = CHAP_FAILURE;
-    if (!get_secret(cstate->unit, rhostname, cstate->chal_name,
-                   secret, &secret_len, 1)) {
+    if (!get_secret(cstate->unit, (explicit_remote? remote_name: rhostname),
+                   cstate->chal_name, secret, &secret_len, 1)) {
        warn("No CHAP secret found for authenticating %q", rhostname);
     } else {
 
@@ -741,7 +741,7 @@ ChapGenChallenge(cstate)
 {
     int chal_len;
     u_char *ptr = cstate->challenge;
-    unsigned int i;
+    int i;
 
     /* pick a random challenge length between MIN_CHALLENGE_LENGTH and 
        MAX_CHALLENGE_LENGTH */  
@@ -753,7 +753,7 @@ ChapGenChallenge(cstate)
     cstate->chal_transmits = 0;
 
     /* generate a random string */
-    for (i = 0; i < chal_len; i++ )
+    for (i = 0; i < chal_len; i++)
        *ptr++ = (char) (drand48() * 0xff);
 }