Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
## Unreleased

### Added
- milter - `AuthResComments` configuration option.

### Changed

Expand Down
1 change: 1 addition & 0 deletions openarc/openarc-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/* config definition */
struct configdef arcf_config[] = {
{"AuthResComments", CONFIG_TYPE_BOOLEAN, false},
{"AuthResIP", CONFIG_TYPE_BOOLEAN, false},
{"AuthservID", CONFIG_TYPE_STRING, false},
{"AutoRestart", CONFIG_TYPE_BOOLEAN, false},
Expand Down
12 changes: 10 additions & 2 deletions openarc/openarc.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct arcf_config
bool conf_keeptmpfiles; /* keep temp files */
bool conf_finalreceiver; /* act as final receiver */
bool conf_overridecv; /* allow A-R to override CV */
bool conf_authrescomments; /* include comments in A-R */
bool conf_authresip; /* include remote IP in A-R */
unsigned int conf_refcnt; /* reference count */
unsigned int conf_mode; /* mode flags */
Expand Down Expand Up @@ -1165,6 +1166,7 @@ arcf_config_new(void)

new->conf_maxhdrsz = DEFMAXHDRSZ;
new->conf_safekeys = true;
new->conf_authrescomments = true;
new->conf_authresip = true;

new->conf_ret_disabled = SMFIS_ACCEPT;
Expand Down Expand Up @@ -1513,6 +1515,9 @@ arcf_config_load(struct config *data,
(void) config_get(data, "PermitAuthenticationOverrides",
&conf->conf_overridecv, sizeof conf->conf_overridecv);

config_get(data, "AuthResComments", &conf->conf_authrescomments,
sizeof conf->conf_authrescomments);

config_get(data, "AuthResIP", &conf->conf_authresip,
sizeof conf->conf_authresip);

Expand Down Expand Up @@ -3847,8 +3852,11 @@ mlfi_eom(SMFICTX *ctx)
{
if (ar.ares_result[i].result_ptype[j] == ARES_PTYPE_COMMENT)
{
arc_dstring_printf(afc->mctx_tmpstr, " %s",
ar.ares_result[i].result_value[j]);
if (conf->conf_authrescomments)
{
arc_dstring_printf(afc->mctx_tmpstr, " %s",
ar.ares_result[i].result_value[j]);
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions openarc/openarc.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ integer values default to
and string and dataset values default to being undefined.
.Sh PARAMETERS
.Bl -tag -width Ds
.It Cm AuthResComments Pq boolean
Controls whether Authentication-Results headers include any comments parsed from
the previously existing headers.
The default is
.Cm true .
.It Cm AuthResIP Pq boolean
Controls whether Authentication-Results headers include the remote IP.
The default is
Expand Down
1 change: 1 addition & 0 deletions openarc/openarc.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Only brief examples of each configuration option are provided. For
# detailed documentation, consult the openarc.conf(5) man page.

# AuthResComments true
# AuthResIP true

AuthservID example.com
Expand Down
3 changes: 3 additions & 0 deletions test/files/test_milter_authrescomments.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"AuthResComments": "false"
}
16 changes: 16 additions & 0 deletions test/test_milter.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,22 @@ def test_milter_ar(run_miltertest, data):
assert res['headers'][3] == ['ARC-Authentication-Results', f' i=1; example.com; {data[1]}']


def test_milter_authrescomments(run_miltertest):
"""AuthResComments=false strips out even reasonably-placed comments"""
res = run_miltertest(
[
[
'Authentication-Results',
'example.com; (a)spf (Sender Policy Framework) = pass (good) smtp (mail transfer) . (protocol) mailfrom = foo@example.com',
]
]
)
assert res['headers'][3] == [
'ARC-Authentication-Results',
' i=1; example.com; spf=pass smtp.mailfrom=foo@example.com;\n\tarc=none smtp.remote-ip=127.0.0.1',
]


def test_milter_ar_override(run_miltertest):
"""Override the chain validation state with Authentication-Results"""
res = run_miltertest()
Expand Down