From: Nick Porter Date: Fri, 7 Mar 2025 14:40:55 +0000 (+0000) Subject: Remove & from rlm_smtp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e9c897fb1b6684d4139f1eda7ed256c9fb51de5;p=thirdparty%2Ffreeradius-server.git Remove & from rlm_smtp --- diff --git a/doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc b/doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc index e430941955..c0ddc98ad5 100644 --- a/doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc +++ b/doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc @@ -323,21 +323,23 @@ smtp { } uri = "smtp://192.0.20.1/" timeout = 5s -# username_attribute = &User-Name -# password_attribute = &User-Password + authenticate { +# username = User-Name +# password = User-Password + } # username = "user" # password = "secret" template_directory = raddb/mods_config/smtp - attachments = &SMTP-Attachments[*] + attachments = SMTP-Attachments[*] envelope_address = "postmaster@localhost" - sender_address = &SMTP-Sender-Address[*] -# recipients = &SMTP-Recipients[*] -# recipients = &SMTP-TO[*] -# recipients = &SMTP-CC[*] -# recipients = &SMTP-BCC[*] -# to = &SMTP-TO[*] -# cc = &SMTP-CC[*] -# bcc = &SMTP-BCC[*] + sender_address = SMTP-Sender-Address[*] +# recipients = SMTP-Recipients[*] +# recipients = SMTP-TO[*] +# recipients = SMTP-CC[*] +# recipients = SMTP-BCC[*] +# to = SMTP-TO[*] +# cc = SMTP-CC[*] +# bcc = SMTP-BCC[*] # set_date = yes header { subject = "email subject" diff --git a/raddb/mods-available/smtp b/raddb/mods-available/smtp index 04c4a22094..60c53761bb 100644 --- a/raddb/mods-available/smtp +++ b/raddb/mods-available/smtp @@ -198,16 +198,27 @@ smtp { timeout = 5s # - # username_attribute:: Which attribute in the request should be used as - # the user's username when performing SMTP authentication. + # authenticate: Configuration for verifying a users name and clear-text password + # against an SMTP server. # -# username_attribute = &User-Name + # This is not generally recommended, but is supported for cases where an LDAP server + # is not available, and only an SMTP server is available. + # + authenticate { + # + # username:: The users name when performing SMTP authentication. + # +# username = User-Name + + # + # password_attribute:: The users password when performing SMTP authentication + # +# password = User-Password + } # - # password_attribute:: Which attribute in the request should be used as - # the user's password when performing SMTP authentication. + # In most cases, the SMTP module will be used to send email. # -# password_attribute = &User-Password # # username:: User name to use when sending emails. Can be a fixed @@ -232,7 +243,7 @@ smtp { # Attachments:: attachments with their relative path from template_directory # There can be no leading / or .. # - attachments = &SMTP-Attachments[*] + attachments = SMTP-Attachments[*] # # envelope_address:: This is the address used to send the mail, @@ -242,42 +253,55 @@ smtp { envelope_address = "postmaster@localhost" # - # sender_address:: This are the addresses displayed in the FROM: element of the header - # This can be different than the provided envelope_address, - # If envelope_address is set, this can be formatted however you want it to appear to the receiver - # If envelope_address is not set, the first element in sender_address will be used as the envelope address + # sender_address:: Set the body `FROM` address. + # + # This can be different than the provided envelope_address. + # + # If envelope_address is set, this can be formatted however + # you want it to appear to the receiver. # - sender_address = &SMTP-Sender-Address[*] + # If envelope_address is not set, the first element in + # sender_address will be used as the envelope address. + # + sender_address = SMTP-Sender-Address[*] # # recipients:: Email addresses to be set as recipients for the email - # If recipients is set bcc, cc, and to will not be automatically added to the email - # And so they must be included here. # -# recipients = &SMTP-Recipients[*] -# recipients = &SMTP-TO[*] -# recipients = &SMTP-CC[*] -# recipients = &SMTP-BCC[*] + # If recipients is set, then `bcc`, `cc`, and `to` will not + # be automatically added to the email. Only the list of + # `recipients` will be used. + # +# recipients = SMTP-Recipients[*] +# recipients = SMTP-TO[*] +# recipients = SMTP-CC[*] +# recipients = SMTP-BCC[*] # - # to:: Email addresses to be set in the TO: header - # These addresses will be added as envelope recipients only if recipients is not set + # to:: Set the body `TO` header. + # + # If `recepients` is not set, then messages will be sent to the `TO` address. + # +# to = SMTP-TO[*] + # -# to = &SMTP-TO[*] + # cc:: Set the body `CC` header. # - # cc:: Email addresses to be set in the CC: header - # These addresses will be added as envelope recipients only if recipients is not set + # If `recepients` is not set, then messages will also be sent to the `CC` addresses. # -# cc = &SMTP-CC[*] +# cc = SMTP-CC[*] # - # bcc:: Comma separated list of emails. - # the local part may contain commas, the domain may not (RFC 2821) - # Therefore, first comma after the @ represents a new address - # not listed in the header of the email - # if recipients is not set, these emails will be added to the envelope recipients + # bcc:: Set the `BCC` recipients. + # + # The local part may contain commas, the domain may not (RFC 2821) + # + # Therefore, the first comma after the @ represents a new + # address, and is not listed in the header of the email. + # + # If `recepients` is not set, then messages will also be sent to the `CCC` addresses. # -# bcc = &SMTP-BCC[*] +# bcc = SMTP-BCC[*] # # set_date:: Adds a Date: to the header, set to the time the request is received diff --git a/src/modules/rlm_smtp/rlm_smtp.c b/src/modules/rlm_smtp/rlm_smtp.c index 1752ebb1a0..5ff952ea9f 100644 --- a/src/modules/rlm_smtp/rlm_smtp.c +++ b/src/modules/rlm_smtp/rlm_smtp.c @@ -1000,17 +1000,17 @@ static const call_env_method_t method_env = { { FR_CALL_ENV_PARSE_OFFSET("username", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_CONCAT, rlm_smtp_env_t, username, username_tmpl), .pair.dflt_quote = T_DOUBLE_QUOTED_STRING }, { FR_CALL_ENV_OFFSET("password", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_CONCAT, rlm_smtp_env_t, password), .pair.dflt_quote = T_DOUBLE_QUOTED_STRING }, - { FR_CALL_ENV_OFFSET("sender_address", FR_TYPE_STRING, CALL_ENV_FLAG_NONE, rlm_smtp_env_t, sender_address) }, - { FR_CALL_ENV_OFFSET("recipients", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, recipient_addrs), - .pair.dflt = "&SMTP-Recipients[*]", .pair.dflt_quote = T_BARE_WORD }, - { FR_CALL_ENV_OFFSET("TO", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, to_addrs), - .pair.dflt = "&SMTP-TO[*]", .pair.dflt_quote = T_BARE_WORD }, - { FR_CALL_ENV_OFFSET("CC", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, cc_addrs), - .pair.dflt = "&SMTP-CC[*]", .pair.dflt_quote = T_BARE_WORD }, - { FR_CALL_ENV_OFFSET("BCC", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, bcc_addrs), - .pair.dflt = "&SMTP-BCC[*]", .pair.dflt_quote = T_BARE_WORD }, - { FR_CALL_ENV_OFFSET("attachments", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE, rlm_smtp_env_t, attachments), - .pair.dflt = "&SMTP-Attachments[*]", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_OFFSET("sender_address", FR_TYPE_STRING, CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, sender_address) }, + { FR_CALL_ENV_OFFSET("recipients", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, recipient_addrs), + .pair.dflt = "SMTP-Recipients[*]", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_OFFSET("to", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, to_addrs), + .pair.dflt = "SMTP-TO[*]", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_OFFSET("cc", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, cc_addrs), + .pair.dflt = "SMTP-CC[*]", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_OFFSET("bcc", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, bcc_addrs), + .pair.dflt = "SMTP-BCC[*]", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_OFFSET("attachments", FR_TYPE_STRING, CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE, rlm_smtp_env_t, attachments), + .pair.dflt = "SMTP-Attachments[*]", .pair.dflt_quote = T_BARE_WORD }, { FR_CALL_ENV_SUBSECTION_FUNC("header", CF_IDENT_ANY, CALL_ENV_FLAG_SUBSECTION, smtp_header_section_parse) }, CALL_ENV_TERMINATOR @@ -1020,12 +1020,16 @@ static const call_env_method_t method_env = { static const call_env_method_t auth_env = { FR_CALL_ENV_METHOD_OUT(rlm_smtp_auth_env_t), .env = (call_env_parser_t[]) { - { FR_CALL_ENV_PARSE_OFFSET("username_attribute", FR_TYPE_STRING, - CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE, - rlm_smtp_auth_env_t, username, username_tmpl), .pair.dflt = "&User-Name", .pair.dflt_quote = T_BARE_WORD }, - { FR_CALL_ENV_PARSE_OFFSET("password_attribute", FR_TYPE_STRING, - CALL_ENV_FLAG_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_SECRET, - rlm_smtp_auth_env_t, password, password_tmpl), .pair.dflt = "&User-Password", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_SUBSECTION("authenticate", NULL, CALL_ENV_FLAG_SUBSECTION | CALL_ENV_FLAG_PARSE_MISSING, + ((call_env_parser_t[]) { + { FR_CALL_ENV_PARSE_OFFSET("username", FR_TYPE_STRING, + CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE, + rlm_smtp_auth_env_t, username, username_tmpl), .pair.dflt = "User-Name", .pair.dflt_quote = T_BARE_WORD }, + { FR_CALL_ENV_PARSE_OFFSET("password", FR_TYPE_STRING, + CALL_ENV_FLAG_BARE_WORD_ATTRIBUTE | CALL_ENV_FLAG_REQUIRED | CALL_ENV_FLAG_NULLABLE | CALL_ENV_FLAG_SECRET, + rlm_smtp_auth_env_t, password, password_tmpl), .pair.dflt = "User-Password", .pair.dflt_quote = T_BARE_WORD }, + CALL_ENV_TERMINATOR + }))}, CALL_ENV_TERMINATOR } }; diff --git a/src/tests/modules/smtp/module.conf b/src/tests/modules/smtp/module.conf index af9e096d29..1ff7d9ab6b 100644 --- a/src/tests/modules/smtp/module.conf +++ b/src/tests/modules/smtp/module.conf @@ -32,18 +32,18 @@ smtp { template_directory = "$ENV{top_srcdir}build/ci/exim4" envelope_address = "postmaster@localhost" - attachments = &SMTP-Attachments[*] + attachments = SMTP-Attachments[*] recipients = "conf_recipient_1@localhost" recipients = "conf_recipient_2@localhost" - recipients = &SMTP-Recipients[*] - recipients = &SMTP-TO[*] - recipients = &SMTP-CC[*] + recipients = SMTP-Recipients[*] + recipients = SMTP-TO[*] + recipients = SMTP-CC[*] - TO = "conf_to@localhost" - TO = &SMTP-TO[*] + to = "conf_to@localhost" + to = SMTP-TO[*] - CC = &SMTP-CC[*] + cc = SMTP-CC[*] set_date = no } diff --git a/src/tests/modules/smtp/smtp_attachment/module.conf b/src/tests/modules/smtp/smtp_attachment/module.conf index 284a4d5226..1319cd19cc 100644 --- a/src/tests/modules/smtp/smtp_attachment/module.conf +++ b/src/tests/modules/smtp/smtp_attachment/module.conf @@ -33,12 +33,12 @@ smtp { recipients = "conf_recipient_1@localhost" recipients = "conf_recipient_2@localhost" - recipients = &SMTP-Recipients[*] + recipients = SMTP-Recipients[*] - TO = "conf_to@localhost" - TO = &SMTP-TO[*] + to = "conf_to@localhost" + to = SMTP-TO[*] - CC = &SMTP-CC[*] + cc = SMTP-CC[*] set_date = no } diff --git a/src/tests/modules/smtp/smtp_crln/module.conf b/src/tests/modules/smtp/smtp_crln/module.conf index 43471dede5..ec81a83d20 100644 --- a/src/tests/modules/smtp/smtp_crln/module.conf +++ b/src/tests/modules/smtp/smtp_crln/module.conf @@ -30,7 +30,7 @@ smtp { sender_address = "sender_email2@localhost" envelope_address = "postmaster@localhost" recipients = "crln_test_receiver@localhost" - recipients = &SMTP-Recipients[*] + recipients = SMTP-Recipients[*] set_date = no } diff --git a/src/tests/modules/smtp/smtp_stringparse/module.conf b/src/tests/modules/smtp/smtp_stringparse/module.conf index 7550568589..43e2dce698 100644 --- a/src/tests/modules/smtp/smtp_stringparse/module.conf +++ b/src/tests/modules/smtp/smtp_stringparse/module.conf @@ -23,16 +23,16 @@ smtp { message_id = "123456789@example.com" } - username = &User-Name - password = &User-Password + username = "%{User-Name}" + password = "%{User-Password}" uri = "$ENV{SMTP_TEST_SERVER}:$ENV{SMTP_TEST_SERVER_PORT}" timeout = 5s template_directory = "$ENV{top_srcdir}build/ci/exim4" - sender_address = &SMTP-Sender-Address[*] + sender_address = SMTP-Sender-Address[*] envelope_address = "postmaster@localhost" recipients = "conf-stringparse-recipient@localhost" - recipients = &SMTP-Recipients[*] + recipients = SMTP-Recipients[*] set_date = no }