2007-02-25 23:35:05 +01:00
|
|
|
#! /bin/bash
|
|
|
|
# This module checks and sets file permissions
|
|
|
|
# Copyright (C) 1996-2007 SUSE Linux Products GmbH, Nuernberg, Germany.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2006-12-19 00:17:28 +01:00
|
|
|
#
|
|
|
|
# Author: Burchard Steinbild, 1996-97
|
|
|
|
# Bernhard Kaindl <bk@suse.de>, 1999
|
2007-02-25 23:35:05 +01:00
|
|
|
# Rüdiger Oertel <ro@suse.de>, 2000-01
|
|
|
|
# Ludwig Nussel <lnussel@suse.de> 2007
|
2006-12-19 00:17:28 +01:00
|
|
|
#
|
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
. /lib/YaST/SuSEconfig.functions || exit 1
|
2006-12-19 00:17:28 +01:00
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
for i in /etc/sysconfig/security /etc/sysconfig/suseconfig ; do
|
|
|
|
. $i || exit 1
|
2006-12-19 00:17:28 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "$ENABLE_SUSECONFIG" -a "$ENABLE_SUSECONFIG" = "no" ; then
|
2007-02-25 23:35:05 +01:00
|
|
|
echo "SuSEconfig is disabled in /etc/sysconfig/suseconfig"
|
2006-12-19 00:17:28 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
mode=""
|
|
|
|
case "$CHECK_PERMISSIONS" in
|
|
|
|
set) mode="-set" ;;
|
|
|
|
warn) ;;
|
|
|
|
no|"") exit 0 ;;
|
|
|
|
*) echo "invalid value '$CHECK_PERMISSIONS' for \$CHECK_PERMISSIONS" >&2 ;;
|
|
|
|
esac
|
2006-12-19 00:17:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
# collect files that contain permission specifications
|
|
|
|
#
|
|
|
|
# 1. central fixed permissions file
|
|
|
|
files="/etc/permissions"
|
2006-12-19 00:17:28 +01:00
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
# 2. central easy, secure paranoid as those are defined by SUSE
|
|
|
|
for level in $PERMISSION_SECURITY; do
|
|
|
|
case "$level" in
|
|
|
|
easy|secure|paranoid)
|
|
|
|
if [ -e /etc/permissions.$level ]; then
|
|
|
|
files="$files /etc/permissions.$level"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2006-12-19 00:17:28 +01:00
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
# 3. package specific permissions
|
|
|
|
pkgfiles=(/etc/permissions.d/*)
|
|
|
|
pkgfiles=(${pkgfiles[*]##*/})
|
|
|
|
pkgfiles=(${pkgfiles[*]%%.*})
|
|
|
|
pkgfiles=(`for i in ${pkgfiles[@]}; do echo $i; done | /usr/bin/sort -u`)
|
2006-12-19 00:17:28 +01:00
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
for file in ${pkgfiles[@]}; do
|
|
|
|
file=/etc/permissions.d/$file
|
|
|
|
[ -e $file ] && files="$files $file"
|
|
|
|
for level in $PERMISSION_SECURITY; do
|
|
|
|
[ -e $file.$level ] && files="$files $file.$level"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
# 4. central permissions files with user defined level incl 'local'
|
|
|
|
for level in $PERMISSION_SECURITY; do
|
|
|
|
case "$level" in
|
|
|
|
easy|secure|paranoid) continue ;;
|
|
|
|
esac
|
|
|
|
if [ -e /etc/permissions.$level ]; then
|
|
|
|
files="$files /etc/permissions.$level"
|
|
|
|
fi
|
|
|
|
done
|
2006-12-19 00:17:28 +01:00
|
|
|
|
2007-02-25 23:35:05 +01:00
|
|
|
/usr/bin/chkstat $mode $files
|