diff options
author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-09-17 00:56:56 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-09-17 00:58:18 +0200 |
commit | 2dce264ab39c825bd737a2f369b2cfcda295add0 (patch) | |
tree | 9f0dadc04f13ff48611235f13bc6d53deead9a5f /scripts | |
parent | 04afadf39d068affc59685fc433d3fcba2c9b9ff (diff) |
Fixing Postfix's CApath.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/postfix-fixcerts.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/postfix-fixcerts.sh b/scripts/postfix-fixcerts.sh new file mode 100755 index 0000000..b9ec25a --- /dev/null +++ b/scripts/postfix-fixcerts.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# This script lists the content of the directory / the files specifing +# the trusted CAs in Postfix's configuration, makes a copy in the chroot +# jail and rehash the directory if necessary. +# +# Usage: sudo ./postfix-fixcerts.sh +# +# References: +# - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579247 +# - https://bugs.launchpad.net/ubuntu/+source/postfix/+bug/828047 + +queue_directory=$(postconf -h queue_directory) + +for K in smtp_tls_CAfile smtpd_tls_CAfile; do + CAfile=$(postconf -h "$K") + if [ -n "$CAfile" ]; then + [ -f "$CAfile" -a -r "$CAfile" ] || exit 1 + + certs=$(dirname "$queue_directory/${CAfile#/}") + mkdir -m 0755 --parent "$certs" + cp -L "$CAfile" "$certs" + fi +done + +for K in smtp_tls_CApath smtpd_tls_CApath; do + CApath=$(postconf -h "$K") + if [ -n "$CApath" ]; then + [ -d "$CApath" -a -r "$CApath" ] || exit 1 + echo "$CApath" "$queue_directory/${CApath#/}" + fi +done | sort -u | \ +while read S T; do + mkdir -m 0755 --parent "$T" + find -L "$S" -type f -a \( \! -name '*.[0-9]' \) -print0 | xargs -r0 cp -Lf -t "$T" + /usr/bin/c_rehash "$T" +done |