
| Current Path : /var/lib/dpkg/info/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/lib/dpkg/info/amavisd-new.postinst |
#! /bin/sh
# postinst script for amavisd-new
# $Id: amavisd-new.postinst 908 2006-06-09 03:42:01Z hmh $
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
case "$1" in
configure)
# add amavis system user and group (requires adduser >= 3.34)
# don't muck around with this unless you KNOW what you're doing
# also, don't attempt to second guess what kind of fucked up
# mistakes other amavis packages might have made. Tell the user
# to kill the bogus entry. We can't simply overwrite it with
# usermod, since that would certainly cause severe headaches for
# a sysadmin out there...
#
# I don't care that users migrating from other amavis packages
# will have extra work. Someone lost 30GB because we tried to
# be nice once. See #190414.
echo "Creating/updating amavis user account..." >&2
if ! getent group amavis > /dev/null ; then
addgroup --quiet --system amavis || {
# addgroup failed. Why?
if ! getent group amavis >/dev/null ; then
echo "Could not create system group amavis." >&2
exit 1
fi
# well, the group is there, so just ignore the error
}
fi
if ! getent passwd amavis > /dev/null ; then
adduser --system --ingroup amavis --home /var/lib/amavis \
--gecos "AMaViS system user" --shell /bin/sh \
--quiet --disabled-password amavis || {
# adduser failed. Why?
if getent passwd amavis >/dev/null ; then
echo "Non-system user amavis found. I will not overwrite a non-system" >&2
echo "user. Remove the user and reinstall amavisd-new." >&2
exit 1
fi
# unknown adduser error, simply exit
exit 1
}
fi
# Clean up after #190414
homedir=$(getent passwd amavis | cut -d : -f 6)
if [ "x${homedir}" = "x/" ] ; then
echo 'WARNING! Homedir of user amavis was set to "/", this is' >&2
echo 'extremely dangerous! Overriding it to /var/lib/amavis...' >&2
homedir=/var/lib/amavis
usermod -d "${homedir}" amavis
fi
# Sanity-checks (see #367807)
if [ ! -d "${homedir}" ] ; then
echo "Broken amavis system user found. To insure data-safety," >&2
echo "it is up to you the local administrator to remove the broken" >&2
echo "amavis user, or repair it so that it is sane" >&2
exit 1
fi
# in order to give all critical dirs sane permissions we first check
# if we have the packages standard permissions, if yes we delete them,
# if no we alert the admin.
for i in /var/lib/amavis:755:0750:amavis:amavis /var/lib/amavis/db:755:0750:amavis:amavis \
/var/lib/amavis/tmp:755:0770:amavis:amavis /var/lib/amavis/virusmails:755:0750:amavis:amavis
do
dir=$(echo $i | cut -d : -f 1)
perms_local=$(dpkg-statoverride --list "$dir" | awk '{print $4,$3,$1,$2}' | tr -s " " ":")
if [ "$perms_local" ] ; then
perms_old=$(echo $i | cut -d : -f 1,2,4,5)
perms_new=$(echo $i | cut -d : -f 1,3,4,5)
mode_others=$(dpkg-statoverride --list "$dir" | awk '{print $3}' | sed 's/.*\([0-9]\{1\}\)$/\1/')
if [ "$perms_local" = "$perms_old" ] ; then
dpkg-statoverride --remove "$dir"
elif [ "$perms_local" != "$perms_new" ] && [ "$mode_others" != "0" ] ; then
echo
echo "WARNING: $dir has set custom permissions which may be too open - please take a look at README.Debian!"
echo
fi
fi
done
umask 022
for i in /var/lib/amavis:0750 /var/lib/amavis/db:0750 /var/lib/amavis/tmp:0770 \
/var/lib/amavis/virusmails:0750 /var/run/amavis:0755
do
dir=$(echo $i | cut -d : -f 1)
perm=$(echo $i | cut -d : -f 2)
if [ ! -d "$dir" ] ; then
mkdir -p "$dir"
fi
if ! dpkg-statoverride --list "$dir" > /dev/null ; then
dpkg-statoverride --update --add amavis amavis "$perm" "$dir"
fi
done
#
# Conffile upgrade handling
#
# Work around dpkg not deleting removed conffiles
# (template directories (with files) removed in 1:2.3.3-2)
if dpkg --compare-versions "1:2.3.3-2" gt-nl "$2" ; then
for i in pt_BR fr it_IT de_DE ; do
if [ -e "/etc/amavis/$i" ] ; then
echo "Moving outdated l10n template to /etc/amavis/${i}.outdated_for_2.3.3-2" >&2
mv "/etc/amavis/$i" "/etc/amavis/${i}.outdated_for_2.3.3-2"
fi
done
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
init_failed ()
{
echo "WARNING: Starting amavisd-new failed. Please check your configuration."
}
# Automatically added by dh_installinit/12.10ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/amavis" ]; then
update-rc.d amavis defaults >/dev/null
invoke-rc.d amavis start || exit 1
fi
fi
# End automatically added section
# Automatically added by dh_installinit/12.10ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/amavisd-snmp-subagent" ]; then
update-rc.d amavisd-snmp-subagent defaults-disabled >/dev/null
invoke-rc.d amavisd-snmp-subagent start || exit 1
fi
fi
# End automatically added section
# Automatically added by dh_installinit/12.10ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/amavis-mc" ]; then
update-rc.d amavis-mc defaults-disabled >/dev/null
invoke-rc.d amavis-mc start || exit 1
fi
fi
# End automatically added section
exit 0