Files
kumomta/assets/resolve-queue-config
Wez Furlong 48e89105a7 fix provider rule matching with MXSuffix
Given a provider with the following config:

```json
      "match": [
        {
          "MXSuffix": "mta5.am0.yahoodns.net"
        },
        {
          "MXSuffix": "mta6.am0.yahoodns.net"
        },
        {
          "MXSuffix": "mta7.am0.yahoodns.net"
        }
      ]
```

(Note that this configuration is not ideal because someone with
`notreallymta5.am0.yahoodns.net` in their MX records will match
this.  If you were using SMTP auth for such a site, then you risk
leaking your credentials to it! We should consider adding an exact
match option for this case)

we could never match this because the logic had the inner and outer
loops swapped.

For a provider to match, all of the resolved host names must match
at least one of the MXSuffixes defined in the rule.

The flipped logic prevented that from matching.

Most of this commit is adding stuff to help trace this down
and debug it.

In particular, `resolve-queue-config` will tell you what the
effective value of the get-queue-config event is for a given
queue name, and `resolve-shaping-domain` will show you the shaping
configuration for a (bogus) source.
2024-12-16 12:46:31 -07:00

44 lines
947 B
Bash
Executable File

#!/bin/sh
CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-${PWD}/target}
POLICY_PATH=${POLICY_PATH:-/opt/kumomta/etc/policy/init.lua}
KUMOD=${KUMOD:-kumod}
if ! test -x ${KUMOD} ; then
for candidate in /opt/kumomta/sbin/kumod "${CARGO_TARGET_DIR}/release/kumod" "${CARGO_TARGET_DIR}/debug/kumod" ; do
if test -x "${candidate}" ; then
KUMOD="${candidate}"
break;
fi
done
if ! test -x "${KUMOD}" ; then
echo "Couldn't find kumod"
exit 1
fi
fi
script=$(mktemp)
trap "rm -f -- '$script'" EXIT
cat >${script} <<-EOT
local kumo = require 'kumo'
dofile "${POLICY_PATH}"
kumo.on('main', function(queue_name)
local config = kumo.invoke_get_queue_config(queue_name)
print(kumo.serde.json_encode_pretty(config))
end)
EOT
is_user_root () { [ "${EUID:-$(id -u)}" -eq 0 ]; }
RUN_AS_USER=""
if is_user_root ; then
chmod a+rx $script
RUN_AS_USER="--user kumod"
fi
${KUMOD} $RUN_AS_USER --policy $script --script -- "$@"