]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use correct rcode depending on why the call could not run
authorNick Porter <nick@portercomputing.co.uk>
Thu, 4 Sep 2025 12:50:05 +0000 (13:50 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 4 Sep 2025 14:32:40 +0000 (15:32 +0100)
src/modules/rlm_smtp/rlm_smtp.c

index e2ab62f7a3fed3b7911f276a15acb9594e2530ad..d7792e84b8f192b054572c5fd9c223de9144e8bf 100644 (file)
@@ -637,7 +637,7 @@ static unlang_action_t CC_HINT(nonnull) mod_mail(unlang_result_t *p_result, modu
        rlm_smtp_env_t                  *call_env = talloc_get_type_abort(mctx->env_data, rlm_smtp_env_t);
        fr_curl_io_request_t            *randle = NULL;
        fr_mail_ctx_t                   *mail_ctx;
-
+       rlm_rcode_t                     rcode = RLM_MODULE_INVALID;
        fr_pair_t const                 *smtp_body;
 
        /* Elements provided by the request */
@@ -653,7 +653,7 @@ static unlang_action_t CC_HINT(nonnull) mod_mail(unlang_result_t *p_result, modu
                RDEBUG2("At least one of \"sender_address\" or \"envelope_address\" in the config, or \"SMTP-Sender-Address\" in the request is needed");
        error:
                if (randle) smtp_slab_release(randle);
-               RETURN_UNLANG_INVALID;
+               RETURN_UNLANG_RCODE(rcode);
        }
 
        /*
@@ -708,6 +708,7 @@ skip_auth:
        /* Set the header elements */
                if (header_source(mail_ctx, inst, call_env) != 0) {
                REDEBUG("The header slist could not be generated");
+               rcode = RLM_MODULE_FAIL;
                goto error;
        }
 
@@ -721,6 +722,7 @@ skip_auth:
        /* Initialize the body elements to be uploaded */
        if (body_init(mail_ctx, mail_ctx->mime) == 0) {
                REDEBUG("The body could not be generated");
+               rcode = RLM_MODULE_FAIL;
                goto error;
        }
 
@@ -732,7 +734,10 @@ skip_auth:
        /* Add the mime encoded elements to the curl request */
        FR_CURL_REQUEST_SET_OPTION(CURLOPT_MIMEPOST, mail_ctx->mime);
 
-       if (fr_curl_io_request_enqueue(t->mhandle, request, randle)) goto error;
+       if (fr_curl_io_request_enqueue(t->mhandle, request, randle)) {
+               rcode = RLM_MODULE_FAIL;
+               goto error;
+       }
 
        return unlang_module_yield(request, smtp_io_module_resume, smtp_io_module_signal, ~FR_SIGNAL_CANCEL, randle);
 }