Compare commits

..

No commits in common. "ac03f05766f2ef12b893918b6d206b281d32e263" and "422b97bc1b310c8f3515f3911794d2d674eb964a" have entirely different histories.

7 changed files with 31 additions and 80 deletions

View file

@ -153,7 +153,7 @@ EOF
if [ -f "${__object}/parameter/secured-domains" ]; then if [ -f "${__object}/parameter/secured-domains" ]; then
SECURED_DOMAINS_STATE='present' SECURED_DOMAINS_STATE='present'
SECURED_DOMAINS_STATE_JICOFO='present' SECURED_DOMAINS_STATE_JICOFO='replace'
else else
SECURED_DOMAINS_STATE='absent' SECURED_DOMAINS_STATE='absent'
SECURED_DOMAINS_STATE_JICOFO='absent' SECURED_DOMAINS_STATE_JICOFO='absent'

View file

@ -1,7 +1,6 @@
#!/bin/sh -e #!/bin/sh -e
# Generate an opendkim.conf(5) file for opendkim(8). # Generate an opendkim.conf(5) file for opendkim(8).
echo "# Managed remotely, manual changes will be lost."
# Optional chdir(2) # Optional chdir(2)
if [ "$BASEDIR" ]; if [ "$BASEDIR" ];
@ -34,8 +33,8 @@ then
fi fi
# Key and Domain tables # Key and Domain tables
echo "KeyTable ${CFG_DIR}/KeyTable" echo 'KeyTable /etc/opendkim/KeyTable'
echo "SigningTable ${CFG_DIR}/SigningTable" echo 'SigningTable /etc/opendkim/SigningTable'
# Required socket to listen on # Required socket to listen on
printf "Socket %s\n" "${SOCKET:?}" printf "Socket %s\n" "${SOCKET:?}"

View file

@ -14,8 +14,8 @@ installation and basic configuration of an instance of OpenDKIM.
Note that this type does not generate or ensure that a key is present: use Note that this type does not generate or ensure that a key is present: use
`cdist-type__opendkim-genkey(7)` for that. `cdist-type__opendkim-genkey(7)` for that.
Note that this type is currently only implemented for Alpine Linux and FreeBSD. Note that this type is currently only implemented for Alpine Linux. Please
Please contribute an implementation if you can. contribute an implementation if you can.
REQUIRED PARAMETERS REQUIRED PARAMETERS
@ -42,9 +42,8 @@ umask
Set the umask for the socket and PID file. Set the umask for the socket and PID file.
userid userid
Change the user the opendkim program is to run as. Change the user the opendkim program is to run as. By default, Alpine Linux's
By default, Alpine Linux's OpenRC service will set this to `opendkim` on the OpenRC service will set this to `opendkim` on the command-line.
command-line and FreeBSD's rc will set it to `mailnull`.
custom-config custom-config
The string following this parameter is appended as-is in the configuration, to The string following this parameter is appended as-is in the configuration, to
@ -87,12 +86,11 @@ SEE ALSO
AUTHORS AUTHORS
------- -------
Joachim Desroches <joachim.desroches@epfl.ch> Joachim Desroches <joachim.desroches@epfl.ch>
Evilham <contact@evilham.com>
COPYING COPYING
------- -------
Copyright \(C) 2022 Joachim Desroches, Evilham. You can redistribute it Copyright \(C) 2021 Joachim Desroches. You can redistribute it
and/or modify it under the terms of the GNU General Public License as and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version. License, or (at your option) any later version.

View file

@ -20,23 +20,16 @@
os=$(cat "${__global:?}/explorer/os") os=$(cat "${__global:?}/explorer/os")
CFG_DIR="/etc/opendkim"
service="opendkim"
case "$os" in case "$os" in
'alpine') 'alpine')
: :
;; ;;
'freebsd')
CFG_DIR="/usr/local/etc/mail"
service="milter-opendkim"
;;
*) *)
printf "__opendkim does not yet support %s.\n" "$os" >&2 printf "__opendkim does not yet support %s.\n" "$os" >&2
printf "Please contribute an implementation if you can.\n" >&2 printf "Please contribute an implementation if you can.\n" >&2
exit 1 exit 1
;; ;;
esac esac
export CFG_DIR
__package opendkim __package opendkim
@ -75,7 +68,7 @@ fi
# Generate and deploy configuration file. # Generate and deploy configuration file.
source_file="${__object:?}/files/opendkim.conf" source_file="${__object:?}/files/opendkim.conf"
target_file="${CFG_DIR}/opendkim.conf" target_file="/etc/opendkim/opendkim.conf"
mkdir -p "${__object:?}/files" mkdir -p "${__object:?}/files"
@ -90,22 +83,9 @@ fi
require="__package/opendkim" __file "$target_file" \ require="__package/opendkim" __file "$target_file" \
--source "$source_file" --mode 0644 --source "$source_file" --mode 0644
require="__package/opendkim" __start_on_boot "${service}" require="__package/opendkim" __start_on_boot opendkim
# Ensure Key and Signing tables exist and have proper permissions require="__file${target_file}" \
key_table="${CFG_DIR}/KeyTable"
signing_table="${CFG_DIR}/SigningTable"
require="__package/opendkim" \
__file "${key_table}" \
--mode 444
require="__package/opendkim" \
__file "${signing_table}" \
--mode 444
require="__file${target_file} __file${key_table}
__file${signing_table} __start_on_boot/${service}" \
__check_messages opendkim \ __check_messages opendkim \
--pattern "^__file${target_file}" \ --pattern "^__file${target_file}" \
--execute "service ${service} restart" --execute "service opendkim restart"

View file

@ -30,8 +30,7 @@ fi
DIRECTORY="/var/db/dkim/" DIRECTORY="/var/db/dkim/"
if [ -f "${__object:?}/parameter/directory" ]; then if [ -f "${__object:?}/parameter/directory" ]; then
# Be forgiving about a lack of trailing slash DIRECTORY="$(cat "${__object:?}/parameter/directory")"
DIRECTORY="$(sed -E 's!([^/])$!\1/!' < "${__object:?}/parameter/directory")"
fi fi
# Boolean parameters # Boolean parameters
@ -45,12 +44,7 @@ if [ -f "${__object:?}/parameters/unrestricted" ]; then
RESTRICTED= RESTRICTED=
fi fi
user="$(cat "${__object:?}/user")"
group="$(cat "${__object:?}/group")"
if ! [ -f "${DIRECTORY}${SELECTOR}.private" ]; then if ! [ -f "${DIRECTORY}${SELECTOR}.private" ]; then
echo "opendkim-genkey $BITS --domain=$DOMAIN --directory=$DIRECTORY $RESTRICTED --selector=$SELECTOR $SUBDOMAINS" echo "opendkim-genkey $BITS --domain=$DOMAIN --directory=$DIRECTORY $RESTRICTED --selector=$SELECTOR $SUBDOMAINS"
echo "chown ${user}:${group} ${DIRECTORY}${SELECTOR}.private" echo "chown opendkim:opendkim ${DIRECTORY}${SELECTOR}.private"
# This is usually generated, if it weren't we do not want to fail
echo "chown ${user}:${group} ${DIRECTORY}${SELECTOR}.txt || true"
fi fi

View file

@ -17,8 +17,8 @@ will be added to the OpenDKIM signing table, using either the domain or the
provided key for the `domain:selector:keyfile` value in the table. An existing provided key for the `domain:selector:keyfile` value in the table. An existing
key will not be overwritten. key will not be overwritten.
Currently, this type is only implemented for Alpine Linux and FreeBSD. Currently, this type is only implemented for Alpine Linux. Please contribute an
Please contribute an implementation if you can. implementation if you can.
REQUIRED PARAMETERS REQUIRED PARAMETERS
------------------- -------------------
@ -85,12 +85,11 @@ SEE ALSO
AUTHORS AUTHORS
------- -------
Joachim Desroches <joachim.desroches@epfl.ch> Joachim Desroches <joachim.desroches@epfl.ch>
Evilham <contact@evilham.com>
COPYING COPYING
------- -------
Copyright \(C) 2022 Joachim Desroches, Evilham. You can redistribute it Copyright \(C) 2021 Joachim Desroches. You can redistribute it
and/or modify it under the terms of the GNU General Public License as and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version. License, or (at your option) any later version.

View file

@ -21,18 +21,10 @@
os=$(cat "${__global:?}/explorer/os") os=$(cat "${__global:?}/explorer/os")
CFG_DIR="/etc/opendkim"
user="opendkim"
group="opendkim"
case "$os" in case "$os" in
'alpine') 'alpine')
: :
;; ;;
'freebsd')
CFG_DIR="/usr/local/etc/mail"
user="mailnull"
group="mailnull"
;;
*) *)
cat <<- EOF >&2 cat <<- EOF >&2
__opendkim_genkey currently only supports Alpine Linux. Please __opendkim_genkey currently only supports Alpine Linux. Please
@ -40,9 +32,6 @@ case "$os" in
EOF EOF
;; ;;
esac esac
# Persist user and group for gencode-remote
printf '%s' "${user}" > "${__object:?}/user"
printf '%s' "${group}" > "${__object:?}/group"
SELECTOR="$(cat "${__object:?}/parameter/selector")" SELECTOR="$(cat "${__object:?}/parameter/selector")"
DOMAIN="$(cat "${__object:?}/parameter/domain")" DOMAIN="$(cat "${__object:?}/parameter/domain")"
@ -50,8 +39,7 @@ DOMAIN="$(cat "${__object:?}/parameter/domain")"
DIRECTORY="/var/db/dkim/" DIRECTORY="/var/db/dkim/"
if [ -f "${__object:?}/parameter/directory" ]; if [ -f "${__object:?}/parameter/directory" ];
then then
# Be forgiving about a lack of trailing slash DIRECTORY="$(cat "${__object:?}/parameter/directory")"
DIRECTORY="$(sed -E 's!([^/])$!\1/!' < "${__object:?}/parameter/directory")"
fi fi
SIGKEY="${DOMAIN:?}" SIGKEY="${DOMAIN:?}"
@ -60,26 +48,19 @@ then
SIGKEY="$(cat "${__object:?}/parameter/sigkey")" SIGKEY="$(cat "${__object:?}/parameter/sigkey")"
fi fi
# Ensure the key-container directory exists with the proper permissions __package opendkim-utils
__directory "${DIRECTORY}" \
--mode 0750 \
--owner "${user}" --group "${group}"
# OS-specific code require='__package/opendkim-utils' \
case "$os" in __file /etc/opendkim/KeyTable
'alpine') require='__package/opendkim-utils' \
# This is needed for opendkim-genkey __file /etc/opendkim/SigningTable
__package opendkim-utils
;;
esac
key_table="${CFG_DIR}/KeyTable" require='__file/etc/opendkim/KeyTable' \
signing_table="${CFG_DIR}/SigningTable" __line "line-key-${__object_id:?}" \
--file /etc/opendkim/KeyTable \
--line "${SELECTOR:?}._domainkey.${DOMAIN:?} ${DOMAIN:?}:${SELECTOR:?}:${DIRECTORY:?}${SELECTOR:?}.private"
__line "line-key-${__object_id:?}" \ require='__file/etc/opendkim/SigningTable' \
--file "${key_table}" \ __line "line-sig-${__object_id:?}" \
--line "${SELECTOR:?}._domainkey.${DOMAIN:?} ${DOMAIN:?}:${SELECTOR:?}:${DIRECTORY:?}${SELECTOR:?}.private" --file /etc/opendkim/SigningTable \
--line "${SIGKEY:?} ${SELECTOR:?}._domainkey.${DOMAIN:?}"
__line "line-sig-${__object_id:?}" \
--file "${signing_table}" \
--line "${SIGKEY:?} ${SELECTOR:?}._domainkey.${DOMAIN:?}"