[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.
This commit is contained in:
parent
49d39eaee5
commit
445bc75deb
4 changed files with 26 additions and 34 deletions
|
@ -17,25 +17,18 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# 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:
|
# in dma's auth.conf and reports:
|
||||||
# present: a line matching login + host + password exists
|
# present: a line matching login + host + password exists
|
||||||
# absent: no line matching login + host exists
|
# absent: no line matching login + host exists
|
||||||
# different_password: a line exists but with a different pasword
|
# different_login: a line exists but with a different login user
|
||||||
# multiple: multiple lines matching login + host exist
|
# different_password: a line exists but with a different password
|
||||||
# (should never happen)
|
# multiple: multiple lines matching host exist (should not happen)
|
||||||
|
|
||||||
auth_conf=$("${__type_explorer}/auth_conf")
|
auth_conf=$("${__type_explorer}/auth_conf")
|
||||||
test -r "${auth_conf}" || exit 0
|
test -r "${auth_conf}" || exit 0
|
||||||
|
|
||||||
if test -f "${__object}/parameter/server"
|
awk -F'\n' '
|
||||||
then
|
|
||||||
server=$(cat "${__object}/parameter/server")
|
|
||||||
else
|
|
||||||
server=$__object_id
|
|
||||||
fi
|
|
||||||
|
|
||||||
awk -F'\n' -v server="${server}" '
|
|
||||||
function getvalue(path) {
|
function getvalue(path) {
|
||||||
# Reads the first line of the file located at path and returns it.
|
# Reads the first line of the file located at path and returns it.
|
||||||
getline < path
|
getline < path
|
||||||
|
@ -49,8 +42,7 @@ BEGIN {
|
||||||
parameter_dir = ENVIRON["__object"] "/parameter/"
|
parameter_dir = ENVIRON["__object"] "/parameter/"
|
||||||
|
|
||||||
# Read the parameters of this object
|
# Read the parameters of this object
|
||||||
host_param = getvalue(parameter_dir "server")
|
host_param = ENVIRON["__object_id"]
|
||||||
if (!host_param) host_param = ENVIRON["__object_id"]
|
|
||||||
login_param = getvalue(parameter_dir "login")
|
login_param = getvalue(parameter_dir "login")
|
||||||
passwd_param = getvalue(parameter_dir "password")
|
passwd_param = getvalue(parameter_dir "password")
|
||||||
|
|
||||||
|
@ -78,10 +70,15 @@ BEGIN {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host == host_param && login == login_param {
|
host == host_param {
|
||||||
# a match…
|
# a match…
|
||||||
if (state == "absent") {
|
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 {
|
} else {
|
||||||
# report "multiple" to that the type can remove the duplicates.
|
# report "multiple" to that the type can remove the duplicates.
|
||||||
state = "multiple"
|
state = "multiple"
|
||||||
|
|
|
@ -21,14 +21,16 @@
|
||||||
state_is=$(cat "${__object}/explorer/state")
|
state_is=$(cat "${__object}/explorer/state")
|
||||||
state_should=$(cat "${__object}/parameter/state")
|
state_should=$(cat "${__object}/parameter/state")
|
||||||
|
|
||||||
if test -f "${__object}/parameter/server"
|
|
||||||
then
|
|
||||||
server=$(cat "${__object}/parameter/server")
|
|
||||||
else
|
|
||||||
server=$__object_id
|
server=$__object_id
|
||||||
fi
|
|
||||||
login=$(cat "${__object}/parameter/login")
|
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}"
|
if test "${state_is}" = "${state_should}"
|
||||||
then
|
then
|
||||||
# state is as it should
|
# state is as it should
|
||||||
|
@ -61,13 +63,6 @@ in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
auth_conf=$(cat "${__object}/explorer/auth_conf")
|
|
||||||
|
|
||||||
test -n "${auth_conf}" || {
|
|
||||||
echo 'Cannot determine path of dma auth.conf' >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
auth_conf='${auth_conf}'
|
auth_conf='${auth_conf}'
|
||||||
|
@ -94,8 +89,7 @@ BEGIN {
|
||||||
|
|
||||||
parameter_dir = ENVIRON["__object"] "/parameter/"
|
parameter_dir = ENVIRON["__object"] "/parameter/"
|
||||||
|
|
||||||
host_param = getvalue(parameter_dir "server")
|
host_param = ENVIRON["__object_id"]
|
||||||
if (!host_param) host_param = ENVIRON["__object_id"]
|
|
||||||
login_param = getvalue(parameter_dir "login")
|
login_param = getvalue(parameter_dir "login")
|
||||||
passwd_param = getvalue(parameter_dir "password")
|
passwd_param = getvalue(parameter_dir "password")
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@ DESCRIPTION
|
||||||
This cdist type allows you to set up credentials to log in to remote SMTP
|
This cdist type allows you to set up credentials to log in to remote SMTP
|
||||||
servers.
|
servers.
|
||||||
|
|
||||||
|
NB: dma currently (v0.13) does not differentiate between users on a host.
|
||||||
|
It will use whatever user it finds in the ``auth.conf`` first.
|
||||||
|
Thus, this type will use the ``__object_id`` as the host specifier.
|
||||||
|
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
|
@ -22,8 +26,6 @@ password
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
server
|
|
||||||
The SMTP server on which the login is valid. Defaults to `__object_id`.
|
|
||||||
state
|
state
|
||||||
Either `present` or `absent`. Defaults to `present`.
|
Either `present` or `absent`. Defaults to `present`.
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
server
|
|
||||||
state
|
state
|
||||||
|
|
Loading…
Reference in a new issue