[__opendkim*] address cdist-contrib #32 review

This commit is contained in:
fnux 2024-05-29 15:34:04 +02:00
parent 40d7b4354e
commit d8afc76fdf
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12
6 changed files with 15 additions and 25 deletions

View file

@ -3,9 +3,6 @@
echo "# Managed remotely, manual changes will be lost." echo "# Managed remotely, manual changes will be lost."
# Used for OS-specific configuration.
os=$(cat "${__global:?}/explorer/os")
# Optional chdir(2) # Optional chdir(2)
if [ "$BASEDIR" ]; if [ "$BASEDIR" ];
then then
@ -71,3 +68,6 @@ if [ "$PIDFILE" ];
then then
printf "PidFile %s\n" "$PIDFILE" printf "PidFile %s\n" "$PIDFILE"
fi fi
# Custom user configuration, if any (passed via --custom-config):
$CUSTOM_CONFIG

View file

@ -14,7 +14,7 @@ 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 Debian, Alpine Linux and Note that this type is currently only implemented for Alpine Linux, Debian and
FreeBSD. Please contribute an implementation if you can. FreeBSD. Please contribute an implementation if you can.
@ -45,10 +45,6 @@ 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
enable more complex configurations. enable more complex configurations.
pidfile
Specifies the path to a file that should be created at process start
containing the process ID.
BOOLEAN PARAMETERS BOOLEAN PARAMETERS
------------------ ------------------
syslog syslog

View file

@ -77,9 +77,10 @@ if [ -f "${__object:?}/parameter/userid" ]; then
export USERID export USERID
fi fi
if [ -f "${__object:?}/parameter/pidfile" ]; then # Custom configuration handling.
PIDFILE="$(cat "${__object:?}/parameter/pidfile")" if [ -f "${__object:?}/parameter/custom-config" ]; then
export PIDFILE CUSTOM_CONFIG="$(cat "${__object:?}/parameter/custom-config")"
export CUSTOM_CONFIG
fi fi
# Debian: set configuration specific to debian packaging if no explicit value # Debian: set configuration specific to debian packaging if no explicit value
@ -89,15 +90,17 @@ if [ "$os" = "debian" ]; then
# using a local socket with MTAs that access the socket as a non-privileged # using a local socket with MTAs that access the socket as a non-privileged
# user (for example, Postfix). You may need to add user "postfix" to group # user (for example, Postfix). You may need to add user "postfix" to group
# "opendkim" in that case. # "opendkim" in that case.
if [ -z "$USERID" ]; then
# We only set UserID if it is not provided via custom configuration.
if [ -z "$USERID" ] && echo "$CUSTOM_CONFIG" | grep -Eq '^UserID\s+\w+$'; then
export USERID="opendkim" export USERID="opendkim"
fi fi
if [ -z "$UMASK" ]; then if [ -z "$UMASK" ] && echo "$CUSTOM_CONFIG" | grep -Eq '^UMask\s+\w+$'; then
export UMASK="007" export UMASK="007"
fi fi
if [ -z "$PIDFILE" ]; then if ! echo "$CUSTOM_CONFIG" | grep -Eq '^PidFile\s+\w+$'; then
export PIDFILE="/run/opendkim/opendkim.pid" export PIDFILE="/run/opendkim/opendkim.pid"
fi fi
fi fi
@ -113,12 +116,6 @@ mkdir -p "${__object:?}/files"
"${__type:?}/files/opendkim.conf.sh" >"$source_file" "${__type:?}/files/opendkim.conf.sh" >"$source_file"
# Add user custom config
if [ -f "${__object:?}/parameter/custom-config" ]; then
echo "# Custom user config" >>"$source_file"
cat "${__object:?}/parameter/custom-config" >>"$source_file"
fi
require="__package/opendkim" __file "$target_file" \ require="__package/opendkim" __file "$target_file" \
--source "$source_file" --mode 0644 --source "$source_file" --mode 0644

View file

@ -4,4 +4,3 @@ subdomains
umask umask
userid userid
custom-config custom-config
pidfile

View file

@ -1,13 +1,11 @@
#!/bin/sh -e #!/bin/sh -e
os=$( "${__explorer:?}/os" ) os=$( "${__explorer:?}/os" )
case "$os" in case "$os" in
'debian') 'debian')
DIRECTORY="/etc/dkimkeys/" DIRECTORY="/etc/dkimkeys/"
;; ;;
'alpine'|'freebsd')
DIRECTORY="/var/db/dkim/"
;;
*) *)
DIRECTORY="/var/db/dkim/" DIRECTORY="/var/db/dkim/"
;; ;;

View file

@ -22,7 +22,7 @@ associating any given `sigkey` values to this key.
Take into account that if you use this type without the `--domain` and Take into account that if you use this type without the `--domain` and
`--selector` parameters, the `$__object_id` must be in form `$domain/$selector`. `--selector` parameters, the `$__object_id` must be in form `$domain/$selector`.
Currently, this type is only implemented for Debian, Alpine Linux and FreeBSD. Currently, this type is only implemented for Alpine Linux, Debian and FreeBSD.
Please contribute an implementation if you can. Please contribute an implementation if you can.
NOTE: the name of the key file under `--directory` will default to NOTE: the name of the key file under `--directory` will default to