From 1aa145faffde86065d6ae1af4041d185c7733342 Mon Sep 17 00:00:00 2001 From: "David F. Skoll" Date: Sun, 1 Sep 2002 12:00:15 +0000 Subject: [PATCH] Patches from Frank Cusack. --- README.MSCHAP80 | 7 +++-- pppd/auth.c | 77 +++++++++++++++++++++++++------------------------ pppd/ccp.c | 4 +-- pppd/chap.c | 4 +-- pppd/chap_ms.c | 10 +++++-- pppd/pppd.h | 3 +- 6 files changed, 56 insertions(+), 49 deletions(-) diff --git a/README.MSCHAP80 b/README.MSCHAP80 index c77d769..7c16f3e 100644 --- a/README.MSCHAP80 +++ b/README.MSCHAP80 @@ -226,7 +226,8 @@ int main(argc, argv) for (i = 0; i < sizeof(challenge); i++) challenge[i] = (u_char)challengeInt[i]; - ChapMS(&cstate, challenge, sizeof(challenge), argv[2], strlen(argv[2])); + ChapMS(&cstate, challenge, argv[2], strlen(argv[2]), + (MS_ChapResponse *)&cstate.response); printf("Response length is %d, response is:", cstate.resp_length); for (i = 0; i < cstate.resp_length; i++) { @@ -241,8 +242,8 @@ int main(argc, argv) } ------------- -This needs to link against chap_ms.o, md4.o, and the DES library. When -you run it with the command line: +This needs to link against chap_ms.o, md4.o, sha1.o and the DES library. +When you run it with the command line: $ testchap 00000000000000000000000000000000 hello diff --git a/pppd/auth.c b/pppd/auth.c index 469b0f8..76fc821 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -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.81 2002/09/01 12:00:15 dfs Exp $" #include #include @@ -608,59 +608,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"); } /* diff --git a/pppd/ccp.c b/pppd/ccp.c index 2941de5..54fc743 100644 --- a/pppd/ccp.c +++ b/pppd/ccp.c @@ -25,7 +25,7 @@ * OR MODIFICATIONS. */ -#define RCSID "$Id: ccp.c,v 1.38 2002/07/10 20:04:35 kad Exp $" +#define RCSID "$Id: ccp.c,v 1.39 2002/09/01 12:00:15 dfs Exp $" #include #include @@ -1421,7 +1421,7 @@ ccp_up(f) if (go->mppe) { BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN); BZERO(mppe_send_key, MPPE_MAX_KEY_LEN); - start_networks(f->unit); /* Bring up IP et al */ + continue_networks(f->unit); /* Bring up IP et al */ } #endif } diff --git a/pppd/chap.c b/pppd/chap.c index c295bb3..a48f69f 100644 --- a/pppd/chap.c +++ b/pppd/chap.c @@ -33,7 +33,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: chap.c,v 1.32 2002/05/21 17:26:49 dfs Exp $" +#define RCSID "$Id: chap.c,v 1.33 2002/09/01 12:00:15 dfs Exp $" /* * TODO: @@ -500,7 +500,6 @@ ChapReceiveChallenge(cstate, inp, id, len) case CHAP_MICROSOFT: ChapMS(cstate, rchallenge, secret, secret_len, (MS_ChapResponse *) cstate->response); - cstate->resp_length = MS_CHAP_RESPONSE_LEN; break; case CHAP_MICROSOFT_V2: @@ -509,7 +508,6 @@ ChapReceiveChallenge(cstate, inp, id, len) cstate->resp_name, secret, secret_len, (MS_Chap2Response *) cstate->response, cstate->earesponse, MS_CHAP2_AUTHENTICATEE); - cstate->resp_length = MS_CHAP2_RESPONSE_LEN; break; #endif /* CHAPMS */ diff --git a/pppd/chap_ms.c b/pppd/chap_ms.c index 0f627fb..fb54843 100644 --- a/pppd/chap_ms.c +++ b/pppd/chap_ms.c @@ -40,7 +40,7 @@ * Copyright (c) 2002 Google, Inc. */ -#define RCSID "$Id: chap_ms.c,v 1.20 2002/04/02 14:15:07 dfs Exp $" +#define RCSID "$Id: chap_ms.c,v 1.21 2002/09/01 12:00:15 dfs Exp $" #ifdef CHAPMS @@ -570,18 +570,19 @@ ChapMS(chap_state *cstate, u_char *rchallenge, char *secret, int secret_len, #endif BZERO(response, sizeof(*response)); - /* Calculate both always */ ChapMS_NT(rchallenge, secret, secret_len, response->NTResp); #ifdef MSLANMAN ChapMS_LANMan(rchallenge, secret, secret_len, response); - /* prefered method is set by option */ + /* preferred method is set by option */ response->UseNT[0] = !ms_lanman; #else response->UseNT[0] = 1; #endif + cstate->resp_length = MS_CHAP_RESPONSE_LENGTH; + #ifdef MPPE Set_Start_Key(rchallenge, secret, secret_len); #endif @@ -625,6 +626,9 @@ ChapMS2(chap_state *cstate, u_char *rchallenge, u_char *PeerChallenge, GenerateAuthenticatorResponse(secret, secret_len, response->NTResp, response->PeerChallenge, rchallenge, user, authResponse); + + cstate->resp_length = MS_CHAP2_RESPONSE_LEN; + #ifdef MPPE SetMasterKeys(secret, secret_len, response->NTResp, authenticator); #endif diff --git a/pppd/pppd.h b/pppd/pppd.h index e2cc428..1a5a109 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pppd.h,v 1.71 2002/07/16 13:11:43 kad Exp $ + * $Id: pppd.h,v 1.72 2002/09/01 12:00:15 dfs Exp $ */ /* @@ -496,6 +496,7 @@ void link_terminated __P((int)); /* we are finished with the link */ void link_down __P((int)); /* the LCP layer has left the Opened state */ void link_established __P((int)); /* the link is up; authenticate now */ void start_networks __P((int)); /* start all the network control protos */ +void continue_networks __P((int)); /* start network [ip, etc] control protos */ void np_up __P((int, int)); /* a network protocol has come up */ void np_down __P((int, int)); /* a network protocol has gone down */ void np_finished __P((int, int)); /* a network protocol no longer needs link */ -- 2.39.2