Beispiel #1
0
static void
pap_authenticate(pap *_this, const char *password)
{
	if (npppd_ppp_bind_realm(_this->ppp->pppd, _this->ppp, _this->name, 0)
	    == 0) {
		if (!npppd_ppp_is_realm_ready(_this->ppp->pppd, _this->ppp)) {
			pap_log(_this, LOG_INFO,
			    "username=\"%s\" realm is not ready.", _this->name);
			goto fail;
			/* NOTREACHED */
		}
#if USE_NPPPD_RADIUS
		if (npppd_ppp_is_realm_radius(_this->ppp->pppd, _this->ppp)) {
			pap_radius_authenticate(_this, _this->name, password);
			return;
			/* NOTREACHED */
		} else
#endif
		if (npppd_ppp_is_realm_local(_this->ppp->pppd, _this->ppp)) {
			pap_local_authenticate(_this, _this->name, password);
			return;
			/* NOTREACHED */
		}
	}
fail:
	pap_response(_this, 0, DEFAULT_FAILURE_MESSAGE);
}
Beispiel #2
0
/** Called by PPP on start */
void
npppd_ppp_radius_acct_start(npppd *pppd, npppd_ppp *ppp)
{
	NPPPD_RADIUS_DBG((ppp, LOG_INFO, "%s()", __func__));

	if (ppp->realm == NULL || !npppd_ppp_is_realm_radius(pppd, ppp))
		return;
	radius_acct_request(pppd, ppp, 0);
}
Beispiel #3
0
static void
chap_authenticate(chap *_this, u_char *response, int lresponse)
{

	switch(_this->type) {
	case PPP_AUTH_CHAP_MD5:
		/* check the length */
		if (lresponse != 16) {
			chap_log(_this, LOG_ERR,
			    "Invalid response length %d != 16", lresponse);
			chap_failure(_this, "FAILED",
			    ERROR_AUTHENTICATION_FAILURE);
			return;
		}
		break;
	case PPP_AUTH_CHAP_MS_V2:
		/* check the length */
		if (lresponse < 49) {
			chap_log(_this, LOG_ERR, "Packet too short.");
			chap_failure(_this, "FAILED",
			    ERROR_AUTHENTICATION_FAILURE);
			return;
		}
		break;
	}
	if (npppd_ppp_bind_realm(_this->ppp->pppd, _this->ppp, _this->name, 0)
	    == 0) {
		if (!npppd_ppp_is_realm_ready(_this->ppp->pppd, _this->ppp)) {
			chap_log(_this, LOG_INFO,
			    "username=\"%s\" realm is not ready.", _this->name);
			chap_failure(_this, "FAILED",
			    ERROR_AUTH_SERVER_TIMEOUT);
			return;
		}
#ifdef USE_NPPPD_RADIUS
		if (npppd_ppp_is_realm_radius(_this->ppp->pppd, _this->ppp)) {
			chap_radius_authenticate(_this, _this->challid,
			    _this->name, _this->chall, _this->lchall, response);
			return;
			/* NOTREACHED */
		} else
#endif
		if (npppd_ppp_is_realm_local(_this->ppp->pppd, _this->ppp)) {
			switch(_this->type) {
			case PPP_AUTH_CHAP_MD5:
				md5chap_authenticate(_this, _this->challid,
				    _this->name, _this->chall, _this->lchall,
				    response);
				return;
				/* NOTREACHED */
			case PPP_AUTH_CHAP_MS_V2:
				mschapv2_authenticate(_this, _this->challid,
				    strip_nt_domain(_this->name),
				    _this->chall, _this->lchall, response);
				return;
				/* NOTREACHED */
			}
		}
	}
	chap_failure(_this, "FAILED", ERROR_AUTHENTICATION_FAILURE);

	return;
}