From 445bc75deba18b8fa978e7d5d8ed8189908457d6 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 28 Sep 2020 10:59:13 +0200 Subject: [PATCH] [type/__dma_auth] Drop --server parameter Currently, dma does not differentiate between login users on the SMTP server. It will pick whatever entry it finds first (https://github.com/corecode/dma/blob/v0.13/net.c#L531). As a result, the --server parameter only adds confusion. --- type/__dma_auth/explorer/state | 29 +++++++++++++---------------- type/__dma_auth/gencode-remote | 24 +++++++++--------------- type/__dma_auth/man.rst | 6 ++++-- type/__dma_auth/parameter/optional | 1 - 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/type/__dma_auth/explorer/state b/type/__dma_auth/explorer/state index 668b50f..621e5a2 100755 --- a/type/__dma_auth/explorer/state +++ b/type/__dma_auth/explorer/state @@ -17,25 +17,18 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# This explorer looks for a line matching the login and server parameters +# This explorer looks for a line matching the server parameter # in dma's auth.conf and reports: # present: a line matching login + host + password exists # absent: no line matching login + host exists -# different_password: a line exists but with a different pasword -# multiple: multiple lines matching login + host exist -# (should never happen) +# different_login: a line exists but with a different login user +# different_password: a line exists but with a different password +# multiple: multiple lines matching host exist (should not happen) auth_conf=$("${__type_explorer}/auth_conf") test -r "${auth_conf}" || exit 0 -if test -f "${__object}/parameter/server" -then - server=$(cat "${__object}/parameter/server") -else - server=$__object_id -fi - -awk -F'\n' -v server="${server}" ' +awk -F'\n' ' function getvalue(path) { # Reads the first line of the file located at path and returns it. getline < path @@ -49,8 +42,7 @@ BEGIN { parameter_dir = ENVIRON["__object"] "/parameter/" # Read the parameters of this object - host_param = getvalue(parameter_dir "server") - if (!host_param) host_param = ENVIRON["__object_id"] + host_param = ENVIRON["__object_id"] login_param = getvalue(parameter_dir "login") passwd_param = getvalue(parameter_dir "password") @@ -78,10 +70,15 @@ BEGIN { } } -host == host_param && login == login_param { +host == host_param { # a match… if (state == "absent") { - state = ((passwd == passwd_param) ? "present" : "different_password") + if (login != login_param) + state = "different_login" + else if (passwd != passwd_param) + state = "different_password" + else + state = "present" } else { # report "multiple" to that the type can remove the duplicates. state = "multiple" diff --git a/type/__dma_auth/gencode-remote b/type/__dma_auth/gencode-remote index c57e5cc..e73c424 100755 --- a/type/__dma_auth/gencode-remote +++ b/type/__dma_auth/gencode-remote @@ -21,14 +21,16 @@ state_is=$(cat "${__object}/explorer/state") state_should=$(cat "${__object}/parameter/state") -if test -f "${__object}/parameter/server" -then - server=$(cat "${__object}/parameter/server") -else - server=$__object_id -fi +server=$__object_id login=$(cat "${__object}/parameter/login") + +auth_conf=$(cat "${__object}/explorer/auth_conf") +test -n "${auth_conf}" || { + echo 'Cannot determine path of dma auth.conf' >&2 + exit 1 +} + if test "${state_is}" = "${state_should}" then # state is as it should @@ -61,13 +63,6 @@ in ;; esac -auth_conf=$(cat "${__object}/explorer/auth_conf") - -test -n "${auth_conf}" || { - echo 'Cannot determine path of dma auth.conf' >&2 - exit 1 -} - cat <