#!/bin/sh IMAPCONF=/etc/imapd.conf CONFDIR=$(grep -se "^configdirectory:" $IMAPCONF | cut -d":" -f2) if [ "x$CONFDIR" = "x" ]; then echo "$0 error: configdirectory not found in /etc/imapd.conf, exiting!" exit 1 fi find $CONFDIR -type d ! -name "lost+found" -exec chmod 700 {} \; -exec chown cyrus:mail {} \; grep -se "^partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do if [ "x$SPOOLDIR" = "x" ]; then echo "$0 warning: invalid partition configuration in /etc/imapd.conf found!" else find $SPOOLDIR -type d ! -name "lost+found" -exec chmod 700 {} \; -exec chown cyrus:mail {} \; fi done find $CONFDIR -type f ! -name "lost+found" -exec chmod 600 {} \; -exec chown cyrus:mail {} \; grep -se "^partition-.*:" $IMAPCONF | cut -d":" -f2 | while read SPOOLDIR; do if [ "x$SPOOLDIR" = "x" ]; then echo "$0 warning: invalid partition configuration in /etc/imapd.conf found!" else find $SPOOLDIR -type f ! -name "lost+found" -exec chmod 600 {} \; -exec chown cyrus:mail {} \; fi done # lmtp socket must be accessible by group mail chmod 750 $CONFDIR chmod 750 ${CONFDIR}/socket