]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove & from rlm_smtp
authorNick Porter <nick@portercomputing.co.uk>
Fri, 7 Mar 2025 14:40:55 +0000 (14:40 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 7 Mar 2025 14:40:55 +0000 (14:40 +0000)
doc/antora/modules/reference/pages/raddb/mods-available/smtp.adoc
raddb/mods-available/smtp
src/modules/rlm_smtp/rlm_smtp.c
src/tests/modules/smtp/module.conf
src/tests/modules/smtp/smtp_attachment/module.conf
src/tests/modules/smtp/smtp_crln/module.conf
src/tests/modules/smtp/smtp_stringparse/module.conf

index e430941955208e73c49afd1318fbb3f8abeb7afd..c0ddc98ad5b27f8d1feeb33d7c0e8bfd96b88c52 100644 (file)
@@ -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"
index 04c4a2209471c0ff99ac28ea0f5e0ba223ee447a..60c53761bb79bbf14ef2525a2bed90fb450ecdc4 100644 (file)
@@ -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
index 1752ebb1a04071aee2f04af33eefea12a1f62bd9..5ff952ea9ff6a7ca317b10c7aefdf32a9df4f844 100644 (file)
@@ -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
        }
 };
index af9e096d2996bf8ba0c8d512035fb997977e4aa5..1ff7d9ab6b972376debb9e78b69b83e26d2b41c2 100644 (file)
@@ -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
 }
index 284a4d52262e091664509f27bead453925cf7823..1319cd19cc897ec3b3b5371904a6bd347708df4e 100644 (file)
@@ -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
 }
index 43471dede5d1531078961697f9707d7763fcba6b..ec81a83d20985107b16c2a16bdb86346628ded1e 100644 (file)
@@ -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
 }
 
index 755056858963d43db7b6537deb7d2dd18ef3fbeb..43e2dce69802e68235172198b1673150f62debe7 100644 (file)
@@ -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
 }