sektioneins / suhosin

SUHOSIN [수호신] for PHP 5.x - The PHP security extension.
https://www.suhosin.org
Other
469 stars 71 forks source link

Configuration file handling in .deb packages #91

Open szepeviktor opened 9 years ago

szepeviktor commented 9 years ago

Thank you for packaging suhosin!

Please consider using ucf for the configuration file.

I think it takes one line in the source package: http://security.debian.org/debian-security/pool/updates/main/p/php5/php5_5.6.9+dfsg-0+deb8u1.debian.tar.xz

And that becomes: http://security.debian.org/debian-security/pool/updates/main/p/php5/php5-mysqlnd_5.6.9+dfsg-0+deb8u1_amd64.deb

#!/bin/sh

set -e

if [ "$1" = "configure" ]; then
    ucf /usr/share/php5/mysqlnd/mysqlnd.ini /etc/php5/mods-available/mysqlnd.ini
fi

dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/10-mysqlnd.ini /etc/php5/mods-available/mysqlnd.ini 5.4.0~rc6-1 -- "$@";

if [ "$1" = "configure" ]; then
    inidir=/etc/php5/mods-available

    if [ -e /usr/share/php5/php5-maintscript-helper ] ; then
    . /usr/share/php5/php5-maintscript-helper

    for dsoname in mysqlnd mysql mysqli pdo_mysql ; do
        inifile=${dsoname}.ini

        # Register new conffile with UCF
        ucf /usr/share/php5/mysqlnd/${inifile} ${inidir}/${inifile}
        ucfr --force php5-mysqlnd ${inidir}/${inifile}

        # Move pre-extension manager conffile
        dpkg-maintscript-helper mv_conffile /etc/php5/conf.d/${inifile} ${inidir}/${inifile} 5.4.0~rc6-1 -- "$@";

        if [ -f "${inidir}/${inifile}.dpkg-new" ]; then
        md5sum="$(md5sum ${inidir}/${inifile}.dpkg-new | sed -e 's/ .*//')"
        old_md5sum="$(md5sum ${inidir}/${inifile} | sed -e 's/ .*//')"
        if [ "$md5sum" = "$old_md5sum" ]; then
            mv "${inidir}/${inifile}.dpkg-new" "${inidir}/${inifile}"
        fi
        fi

        php5_invoke enmod ALL ${dsoname}
    done
    fi
fi
exit 0