#!/bin/sh
#
# $Id$
#
set -e

if [ ! -f /etc/suid.conf ]; then
    cat > /etc/suid.conf <<EOF
# Configuration File for suid programs or special permissions
#
# The format is:
# package file user group permissions
EOF
fi

# suidexec was removed from this package
if grep -q '^suidmanager /usr/bin/suidexec ' /etc/suid.conf; then
    suidunregister /usr/bin/suidexec
elif grep -q '^suidmanager /usr/sbin/suidexec ' /etc/suid.conf; then
    suidunregister /usr/sbin/suidexec
fi

# clean up for version 0.38, which inserted patterns from
# suidunregister into the registry
if grep -q '^\[a-z0-9+-\\\.\]+' /etc/suid.conf; then
    perl -pe '
	unless (/^#|^\s*$/) {
	    s/^\[a-z0-9\+-\\\.\]\+(\s)/user$1/;
	    s/\\(.)/$1/g;
	}
    ' /etc/suid.conf > /etc/suid.conf.new
    mv /etc/suid.conf.new /etc/suid.conf
fi

# Now it's debhelper's turn.
#DEBHELPER#

if [ "$1" = configure ] && expr match "$2" '0.1[0-8]' >/dev/null; then
echo
echo "*** The suidexec program has been removed from this package due to ***"
echo "*** a security problem.  If you used it in any of your scripts, I  ***"
echo "*** suggest you switch to something more secure, such as perl.     ***"
echo
echo -n "Press <ENTER> to continue."
read nothing
fi
