#!/bin/sh
# Copyright (C) 2009  Raphael Bossek <bossekr@debian.org>

set -e

# Let's fix the permissions for the /var/lib directory
chown -R www-data:www-data $BUGZILLA_DATADIR
chmod -R g+rw,u+rw $BUGZILLA_DATADIR
d="/etc/bugzilla3"
chown root:www-data "$d"
chmod 0750 "$d"
for f in index.html localconfig params; do
	test -e "$d/$f" || continue
	chown -R www-data: "$d/$f"
	chmod 0640 "$d/$f"
done
for f in dbconfig-params; do
	test -e "$d/$f" || continue
	chown -R root: "$d/$f"
	chmod 0640 "$d/$f"
done

# fix the permission for the contrib files
if [ -d /usr/share/bugzilla3/contrib ]; then
	find /usr/share/bugzilla3/contrib -name '*.pl' -exec chmod a+x {} \;
	find /usr/share/bugzilla3/contrib -name '*.sh' -exec chmod a+x {} \;
fi

# Modify access rights for installed skins
chown -R root:www-data /usr/share/bugzilla3/web/skins
find /usr/share/bugzilla3/web/skins -type d -exec chmod o-rxw,g=rx,u=rwx {} \;
find /usr/share/bugzilla3/web/skins -type f -exec chmod o-rw,g=r,u=rw {} \;

exit 0
