Fixes #507 permissions on /var/lib/amavis (#510)

This commit is contained in:
Thomas VIAL 2017-02-07 20:53:34 +01:00 committed by GitHub
parent 5abff5208e
commit 0a6733c65a
1 changed files with 28 additions and 14 deletions

View File

@ -3,7 +3,7 @@
########################################################################## ##########################################################################
# >> DEFAULT VARS # >> DEFAULT VARS
# #
# add them here. # add them here.
# Example: DEFAULT_VARS["KEY"]="VALUE" # Example: DEFAULT_VARS["KEY"]="VALUE"
########################################################################## ##########################################################################
declare -A DEFAULT_VARS declare -A DEFAULT_VARS
@ -44,17 +44,17 @@ DOMAINNAME="$(hostname -d)"
########################################################################## ##########################################################################
# >> REGISTER FUNCTIONS # >> REGISTER FUNCTIONS
# #
# add your new functions/methods here. # add your new functions/methods here.
# #
# NOTE: position matters when registering a function in stacks. First in First out # NOTE: position matters when registering a function in stacks. First in First out
# Execution Logic: # Execution Logic:
# > check functions # > check functions
# > setup functions # > setup functions
# > fix functions # > fix functions
# > misc functions # > misc functions
# > start-daemons # > start-daemons
# #
# Example: # Example:
# if [ CONDITION IS MET ]; then # if [ CONDITION IS MET ]; then
# _register_{setup,fix,check,start}_{functions,daemons} "$FUNCNAME" # _register_{setup,fix,check,start}_{functions,daemons} "$FUNCNAME"
# fi # fi
@ -124,13 +124,14 @@ function register_functions() {
################### >> fix funcs ################### >> fix funcs
_register_fix_function "_fix_var_mail_permissions" _register_fix_function "_fix_var_mail_permissions"
_register_fix_function "_fix_var_amavis_permissions"
################### << fix funcs ################### << fix funcs
################### >> misc funcs ################### >> misc funcs
_register_misc_function "_misc_save_states" _register_misc_function "_misc_save_states"
################### << misc funcs ################### << misc funcs
################### >> daemon funcs ################### >> daemon funcs
@ -154,7 +155,7 @@ function register_functions() {
if [ "$ENABLE_POSTGREY" = 1 ]; then if [ "$ENABLE_POSTGREY" = 1 ]; then
_register_start_daemon "_start_daemons_postgrey" _register_start_daemon "_start_daemons_postgrey"
fi fi
_register_start_daemon "_start_daemons_postfix" _register_start_daemon "_start_daemons_postfix"
if [ "$ENABLE_SASLAUTHD" = 1 ];then if [ "$ENABLE_SASLAUTHD" = 1 ];then
@ -293,7 +294,7 @@ function notify () {
} }
function defunc() { function defunc() {
notify 'fatal' "Please fix your configuration. Exiting..." notify 'fatal' "Please fix your configuration. Exiting..."
exit 1 exit 1
} }
@ -342,7 +343,7 @@ function _check_hostname() {
if ( ! echo $HOSTNAME | grep -E '^(\S+[.]\S+)$' > /dev/null ); then if ( ! echo $HOSTNAME | grep -E '^(\S+[.]\S+)$' > /dev/null ); then
notify 'err' "Setting hostname/domainname is required" notify 'err' "Setting hostname/domainname is required"
return 1 return 1
else else
notify 'inf' "Domain has been set to $DOMAINNAME" notify 'inf' "Domain has been set to $DOMAINNAME"
notify 'inf' "Hostname has been set to $HOSTNAME" notify 'inf' "Hostname has been set to $HOSTNAME"
return 0 return 0
@ -507,7 +508,7 @@ function _setup_postgrey() {
sed -i -e 's/bl.spamcop.net$/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf sed -i -e 's/bl.spamcop.net$/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf
sed -i -e "s/\"--inet=10023\"/\"--inet=10023 --delay=$POSTGREY_DELAY --max-age=$POSTGREY_MAX_AGE\"/" /etc/default/postgrey sed -i -e "s/\"--inet=10023\"/\"--inet=10023 --delay=$POSTGREY_DELAY --max-age=$POSTGREY_MAX_AGE\"/" /etc/default/postgrey
TEXT_FOUND=`grep -i "POSTGREY_TEXT" /etc/default/postgrey | wc -l` TEXT_FOUND=`grep -i "POSTGREY_TEXT" /etc/default/postgrey | wc -l`
if [ $TEXT_FOUND -eq 0 ]; then if [ $TEXT_FOUND -eq 0 ]; then
printf "POSTGREY_TEXT=\"$POSTGREY_TEXT\"\n\n" >> /etc/default/postgrey printf "POSTGREY_TEXT=\"$POSTGREY_TEXT\"\n\n" >> /etc/default/postgrey
fi fi
@ -769,7 +770,7 @@ function _setup_postfix_virtual_transport() {
[ -z "${POSTFIX_DAGENT}" ] && \ [ -z "${POSTFIX_DAGENT}" ] && \
echo "${POSTFIX_DAGENT} not set." && \ echo "${POSTFIX_DAGENT} not set." && \
return 1 return 1
postconf -e "virtual_transport = ${POSTFIX_DAGENT}" postconf -e "virtual_transport = ${POSTFIX_DAGENT}"
} }
function _setup_postfix_override_configuration() { function _setup_postfix_override_configuration() {
@ -912,6 +913,19 @@ function _fix_var_mail_permissions() {
return 0 return 0
fi fi
} }
function _fix_var_amavis_permissions() {
notify 'task' 'Fixing /var/lib/amavis permissions'
if [ `find /var/lib/amavis -maxdepth 3 -a \( \! -user amavis -o \! -group amavis \) | grep -c .` != 0 ]; then
notify 'inf' "Fixing /var/lib/amavis permissions"
chown -R amavis:amavis /var/lib/amavis
else
notify 'inf' "Permissions in /var/lib/amavis look OK"
return 0
fi
}
########################################################################## ##########################################################################
# << Fix Stack # << Fix Stack
########################################################################## ##########################################################################
@ -970,12 +984,12 @@ function start_daemons() {
function _start_daemons_cron() { function _start_daemons_cron() {
notify 'task' 'Starting cron' 'n' notify 'task' 'Starting cron' 'n'
display_startup_daemon "cron" display_startup_daemon "cron"
} }
function _start_daemons_rsyslog() { function _start_daemons_rsyslog() {
notify 'task' 'Starting rsyslog' 'n' notify 'task' 'Starting rsyslog' 'n'
display_startup_daemon "/etc/init.d/rsyslog start" display_startup_daemon "/etc/init.d/rsyslog start"
} }
function _start_daemons_saslauthd() { function _start_daemons_saslauthd() {
@ -1024,7 +1038,7 @@ function _start_daemons_dovecot() {
/usr/sbin/dovecot reload /usr/sbin/dovecot reload
fi fi
# @TODO fix: on integration test # @TODO fix: on integration test
# doveadm: Error: userdb lookup: connect(/var/run/dovecot/auth-userdb) failed: No such file or directory # doveadm: Error: userdb lookup: connect(/var/run/dovecot/auth-userdb) failed: No such file or directory
# doveadm: Fatal: user listing failed # doveadm: Fatal: user listing failed
@ -1095,7 +1109,7 @@ notify 'taskgrp' ""
register_functions register_functions
check check
setup setup
fix fix
misc misc