--- embedaddon/mpd/src/auth.c 2021/03/17 00:39:23 1.1.1.4 +++ embedaddon/mpd/src/auth.c 2023/09/27 11:08:00 1.1.1.4.2.1 @@ -188,10 +188,12 @@ void authparamsInit(struct authparams *ap) { memset(ap, 0, sizeof(struct authparams)); +#ifdef USE_RADIUS ap->eapmsg = NULL; ap->state = NULL; ap->class = NULL; ap->filter_id = NULL; +#endif ap->msdomain = NULL; #ifdef SIOCSIFDESCR ap->ifdescr = NULL; @@ -208,10 +210,12 @@ authparamsDestroy(struct authparams *ap) int i; #endif +#ifdef USE_RADIUS Freee(ap->eapmsg); Freee(ap->state); Freee(ap->class); Freee(ap->filter_id); +#endif #ifdef USE_IPFW ACLDestroy(ap->acl_rule); @@ -252,6 +256,7 @@ authparamsCopy(struct authparams *src, struct authpara memcpy(dst, src, sizeof(struct authparams)); +#ifdef USE_RADIUS if (src->eapmsg) dst->eapmsg = Mdup(MB_AUTH, src->eapmsg, src->eapmsg_len); if (src->state) @@ -260,6 +265,7 @@ authparamsCopy(struct authparams *src, struct authpara dst->class = Mdup(MB_AUTH, src->class, src->class_len); if (src->filter_id) dst->filter_id = Mstrdup(MB_AUTH, src->filter_id); +#endif #ifdef USE_IPFW ACLCopy(src->acl_rule, &dst->acl_rule); @@ -308,8 +314,10 @@ AuthInit(Link l) Enable(&ac->options, AUTH_CONF_INTERNAL); Enable(&ac->options, AUTH_CONF_ACCT_MANDATORY); +#ifdef USE_RADIUS EapInit(l); RadiusInit(l); +#endif } /* @@ -420,9 +428,11 @@ AuthStart(Link l) case PROTO_CHAP: ChapStart(l, AUTH_SELF_TO_PEER); break; +#ifdef USE_RADIUS case PROTO_EAP: EapStart(l, AUTH_SELF_TO_PEER); break; +#endif default: assert(0); } @@ -437,9 +447,11 @@ AuthStart(Link l) case PROTO_CHAP: ChapStart(l, AUTH_PEER_TO_SELF); break; +#ifdef USE_RADIUS case PROTO_EAP: EapStart(l, AUTH_PEER_TO_SELF); break; +#endif default: assert(0); } @@ -449,6 +461,7 @@ AuthStart(Link l) * AuthInput() * * Deal with PAP/CHAP/EAP packet + * But cannot be called for EAP packet if RADIUS support is not compiled in. */ void @@ -494,15 +507,16 @@ AuthInput(Link l, int proto, Mbuf bp) len -= sizeof(fsmh); pkt = MBDATA(bp); +#ifdef USE_RADIUS if (proto == PROTO_EAP && bp) { Log(LG_AUTH, ("[%s] %s: rec'd %s #%d len: %hu, type: %s", l->name, ProtoName(proto), AuthCode(proto, fsmh.code, buf, sizeof(buf)), fsmh.id, fsmh_len, EapType(pkt[0]))); - } else { + } else +#endif Log(LG_AUTH, ("[%s] %s: rec'd %s #%d len: %hu", l->name, ProtoName(proto), AuthCode(proto, fsmh.code, buf, sizeof(buf)), fsmh.id, fsmh_len)); - } auth = AuthDataNew(l); auth->proto = proto; @@ -518,9 +532,11 @@ AuthInput(Link l, int proto, Mbuf bp) case PROTO_CHAP: ChapInput(l, auth, pkt, len); break; +#ifdef USE_RADIUS case PROTO_EAP: EapInput(l, auth, pkt, len); break; +#endif default: assert(0); } @@ -563,13 +579,14 @@ AuthOutput(Link l, int proto, u_int code, u_int id, co } bp = mbcopyback(bp, MBLEN(bp), ptr, len); +#ifdef USE_RADIUS if (proto == PROTO_EAP) { Log(LG_AUTH, ("[%s] %s: sending %s #%d len: %d, type: %s", l->name, ProtoName(proto), AuthCode(proto, code, buf, sizeof(buf)), id, plen, EapType(eap_type))); - } else { + } else +#endif Log(LG_AUTH, ("[%s] %s: sending %s #%d len: %d", l->name, ProtoName(proto), AuthCode(proto, code, buf, sizeof(buf)), id, plen)); - } /* Send it out */ NgFuncWritePppFrameLink(l, proto, bp); @@ -718,7 +735,9 @@ AuthStop(Link l) TimerStop(&a->timer); PapStop(&a->pap); ChapStop(&a->chap); +#ifdef USE_RADIUS EapStop(&a->eap); +#endif paction_cancel(&a->thread); } @@ -979,8 +998,10 @@ AuthAccount(void *arg) Log(LG_AUTH2, ("[%s] ACCT: Thread started", auth->info.lnkname)); +#ifdef USE_RADIUS if (Enabled(&auth->conf.options, AUTH_CONF_RADIUS_ACCT)) err |= RadiusAccount(auth); +#endif #ifdef USE_PAM if (Enabled(&auth->conf.options, AUTH_CONF_PAM_ACCT)) err |= AuthPAMAcct(auth); @@ -1020,8 +1041,10 @@ AuthAccountFinish(void *arg, int was_canceled) auth->info.lnkname)); } +#ifdef USE_RADIUS /* Cleanup */ RadiusClose(auth); +#endif if (was_canceled) { AuthDataDestroy(auth); @@ -1188,6 +1211,7 @@ AuthAsync(void *arg) return; } } +#ifdef USE_RADIUS if (auth->proto == PROTO_EAP && auth->eap_radius) { auth->params.authentic = AUTH_CONF_RADIUS_AUTH; RadiusEapProxy(auth); @@ -1205,6 +1229,7 @@ AuthAsync(void *arg) return; } } +#endif #ifdef USE_PAM if (Enabled(&auth->conf.options, AUTH_CONF_PAM_AUTH)) { auth->params.authentic = AUTH_CONF_PAM_AUTH; @@ -1274,8 +1299,10 @@ AuthAsyncFinish(void *arg, int was_canceled) if (was_canceled) Log(LG_AUTH2, ("[%s] AUTH: Thread was canceled", auth->info.lnkname)); +#ifdef USE_RADIUS /* cleanup */ RadiusClose(auth); +#endif if (was_canceled) { AuthDataDestroy(auth); @@ -1948,9 +1975,11 @@ static const char * AuthCode(int proto, u_char code, char *buf, size_t len) { switch (proto) { +#ifdef USE_RADIUS case PROTO_EAP: return EapCode(code, buf, len); +#endif case PROTO_CHAP: return ChapCode(code, buf, len);