/* * The link is established. * Proceed to the Dead, Authenticate or Network phase as appropriate. */ void link_established(int unit) { int auth; lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ho = &lcp_hisoptions[unit]; int i; struct protent *protp; /* * Tell higher-level protocols that LCP is up. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) if (protp->protocol != PPP_LCP && protp->enabled_flag && protp->lowerup != NULL) (*protp->lowerup)(unit); if (auth_required && !(go->neg_chap || go->neg_upap)) { /* * We wanted the peer to authenticate itself, and it refused: * treat it as though it authenticated with PAP using a username * of "" and a password of "". If that's not OK, boot it out. */ if (!wo->neg_upap || !null_login(unit)) { syslog(LOG_WARNING, "peer refused to authenticate"); lcp_close(unit, "peer refused to authenticate"); return; } } phase = PHASE_AUTHENTICATE; auth = 0; if (go->neg_chap) { ChapAuthPeer(unit, our_name, go->chap_mdtype); auth |= CHAP_PEER; } else if (go->neg_upap) { upap_authpeer(unit); auth |= PAP_PEER; } if (ho->neg_chap) { ChapAuthWithPeer(unit, user, ho->chap_mdtype); auth |= CHAP_WITHPEER; } else if (ho->neg_upap) { if (passwd[0] == 0) { passwd_from_file = 1; if (!get_pap_passwd(passwd)) syslog(LOG_ERR, "No secret found for PAP login"); } upap_authwithpeer(unit, user, passwd); auth |= PAP_WITHPEER; } auth_pending[unit] = auth; if (!auth) network_phase(unit); }
/* * auth_reset - called when LCP is starting negotiations to recheck * authentication options, i.e. whether we have appropriate secrets * to use for authenticating ourselves and/or the peer. */ void auth_reset(int unit) { lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ao = &lcp_allowoptions[0]; ipcp_options *ipwo = &ipcp_wantoptions[0]; u32_t remote; AUTHDEBUG((LOG_INFO, "auth_reset: %d\n", unit)); ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL)); ao->neg_chap = !ppp_settings.refuse_chap && have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0); if (go->neg_upap && !have_pap_secret()) go->neg_upap = 0; if (go->neg_chap) { remote = ipwo->accept_remote? 0: ipwo->hisaddr; if (!have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote)) go->neg_chap = 0; } }
/* * auth_reset - called when LCP is starting negotiations to recheck * authentication options, i.e. whether we have appropriate secrets * to use for authenticating ourselves and/or the peer. */ void auth_reset(int unit) { lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ao = &lcp_allowoptions[0]; ipcp_options *ipwo = &ipcp_wantoptions[0]; u_int32_t remote; ao->neg_upap = !refuse_pap && (passwd[0] != 0 || get_pap_passwd(NULL)); ao->neg_chap = !refuse_chap && have_chap_secret(user, remote_name, (u_int32_t)0); if (go->neg_upap && !uselogin && !have_pap_secret()) go->neg_upap = 0; if (go->neg_chap) { remote = ipwo->accept_remote? 0: ipwo->hisaddr; if (!have_chap_secret(remote_name, our_name, remote)) go->neg_chap = 0; } }
/* * The link is established. * Proceed to the Dead, Authenticate or Network phase as appropriate. */ void link_established(int unit) { int auth; int i; struct protent *protp; lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *go = &lcp_gotoptions[unit]; #if PAP_SUPPORT || CHAP_SUPPORT lcp_options *ho = &lcp_hisoptions[unit]; #endif /* PAP_SUPPORT || CHAP_SUPPORT */ AUTHDEBUG((LOG_INFO, "link_established: %d\n", unit)); /* * Tell higher-level protocols that LCP is up. */ for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { if (protp->protocol != PPP_LCP && protp->enabled_flag && protp->lowerup != NULL) { (*protp->lowerup)(unit); } } if (ppp_settings.auth_required && !(go->neg_chap || go->neg_upap)) { /* * We wanted the peer to authenticate itself, and it refused: * treat it as though it authenticated with PAP using a username * of "" and a password of "". If that's not OK, boot it out. */ if (!wo->neg_upap || !null_login(unit)) { AUTHDEBUG((LOG_WARNING, "peer refused to authenticate\n")); lcp_close(unit, "peer refused to authenticate"); return; } } lcp_phase[unit] = PHASE_AUTHENTICATE; auth = 0; #if CHAP_SUPPORT if (go->neg_chap) { ChapAuthPeer(unit, ppp_settings.our_name, go->chap_mdtype); auth |= CHAP_PEER; } #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT && CHAP_SUPPORT else #endif /* PAP_SUPPORT && CHAP_SUPPORT */ #if PAP_SUPPORT if (go->neg_upap) { upap_authpeer(unit); auth |= PAP_PEER; } #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT if (ho->neg_chap) { ChapAuthWithPeer(unit, ppp_settings.user, ho->chap_mdtype); auth |= CHAP_WITHPEER; } #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT && CHAP_SUPPORT else #endif /* PAP_SUPPORT && CHAP_SUPPORT */ #if PAP_SUPPORT if (ho->neg_upap) { if (ppp_settings.passwd[0] == 0) { passwd_from_file = 1; if (!get_pap_passwd(unit, ppp_settings.user, ppp_settings.passwd)) { AUTHDEBUG((LOG_ERR, "No secret found for PAP login\n")); } } upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); auth |= PAP_WITHPEER; } #endif /* PAP_SUPPORT */ auth_pending[unit] = auth; if (!auth) { network_phase(unit); } }