X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8356c34ac9097616997e5d9905f54aa3ba79dd22..aa361b5b0d95c7023b272c2c423af9d71c930787:/projects/rlm_stg/rlm_stg.c?ds=inline diff --git a/projects/rlm_stg/rlm_stg.c b/projects/rlm_stg/rlm_stg.c index 20d46a59..84df4e7b 100644 --- a/projects/rlm_stg/rlm_stg.c +++ b/projects/rlm_stg/rlm_stg.c @@ -57,9 +57,11 @@ static size_t toVPS(const STG_PAIR* pairs, VALUE_PAIR** vps) while (!emptyPair(pair)) { VALUE_PAIR* vp = pairmake(pair->key, pair->value, T_OP_SET); - pairadd(vps, vp); + if (vp != NULL) { + pairadd(vps, vp); + ++count; + } ++pair; - ++count; } return count; @@ -107,6 +109,23 @@ static STG_PAIR* fromVPS(const VALUE_PAIR* pairs) return res; } +static int toRLMCode(int code) +{ + switch (code) + { + case STG_REJECT: return RLM_MODULE_REJECT; + case STG_FAIL: return RLM_MODULE_FAIL; + case STG_OK: return RLM_MODULE_OK; + case STG_HANDLED: return RLM_MODULE_HANDLED; + case STG_INVALID: return RLM_MODULE_INVALID; + case STG_USERLOCK: return RLM_MODULE_USERLOCK; + case STG_NOTFOUND: return RLM_MODULE_NOTFOUND; + case STG_NOOP: return RLM_MODULE_NOOP; + case STG_UPDATED: return RLM_MODULE_UPDATED; + } + return RLM_MODULE_REJECT; +} + /* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections @@ -190,7 +209,7 @@ static int stg_authorize(void* instance, REQUEST* request) if (count) return RLM_MODULE_UPDATED; - return RLM_MODULE_NOOP; + return toRLMCode(result.returnCode); } /* @@ -231,7 +250,7 @@ static int stg_authenticate(void* instance, REQUEST* request) if (count) return RLM_MODULE_UPDATED; - return RLM_MODULE_NOOP; + return toRLMCode(result.returnCode); } /* @@ -272,7 +291,7 @@ static int stg_preacct(void* instance, REQUEST* request) if (count) return RLM_MODULE_UPDATED; - return RLM_MODULE_NOOP; + return toRLMCode(result.returnCode); } /* @@ -313,7 +332,7 @@ static int stg_accounting(void* instance, REQUEST* request) if (count) return RLM_MODULE_UPDATED; - return RLM_MODULE_OK; + return toRLMCode(result.returnCode); } /* @@ -372,7 +391,7 @@ static int stg_postauth(void* instance, REQUEST* request) if (count) return RLM_MODULE_UPDATED; - return RLM_MODULE_NOOP; + return toRLMCode(result.returnCode); } static int stg_detach(void* instance)