#!/bin/sh
#
# Univention Fix Logfile Permissions
#
# SPDX-FileCopyrightText: 2007-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only
#

chmod 640 /var/log/univention/*.log
chmod 640 /var/log/univention/*.log.[1-9]*

FNLIST="/var/log/univention/directory-manager-web.log \
        /var/log/univention/management-console-web.log"

for fn in $FNLIST ; do
	if [ -f "$fn" ] ; then
		chown www-data:adm "$fn"
		chmod 640 "$fn"
	fi
done

STRICTLIST="/var/log/mail.err /var/log/mail.warn /var/log/mail.info /var/log/mail.log /var/log/apache2/other_vhosts_access.log"

for fn in $STRICTLIST ; do
	if [ -f "$fn" ] ; then
		chown root:adm "$fn"
		chmod 640 "$fn"
	fi
done
