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