ACC SHELL
Path : /sbin/ |
|
Current File : //sbin/set_polkit_default_privs |
#! /bin/bash
# This module sets policykit default permissions
# Copyright (C) 2008 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
#
# Based on SuSEconfig.permissions
#
# Author: Ludwig Nussel <lnussel@suse.de> 2008
#
shopt -s nullglob
. /etc/sysconfig/security || exit 1
if [ -z "$POLKIT_DEFAULT_PRIVS" ]; then
case "$PERMISSION_SECURITY" in
*secure*|*paranoid*) POLKIT_DEFAULT_PRIVS="restrictive" ;;
*) POLKIT_DEFAULT_PRIVS="standard" ;;
esac
fi
mode=""
case "$CHECK_POLKIT_PRIVS" in
set|"") mode="-set" ;;
warn) ;;
no) exit 0 ;;
*) echo "invalid value '$CHECK_POLKIT_PRIVS' for \$CHECK_POLKIT_PRIVS, using 'set'" >&2; mode="-set" ;;
esac
# collect files that contain permission specifications
# we need to use a useful order
#
# 1. common privileges file (we have none yet)
files=""
# 2. relaxed, standard, restrictive as those are defined by SUSE
have_local=
for level in $POLKIT_DEFAULT_PRIVS; do
case "$level" in
relaxed|standard|restrictive)
if [ -e /etc/polkit-default-privs.$level ]; then
files="$files /etc/polkit-default-privs.$level"
fi
;;
esac
done
if [ -z "$have_local" ]; then
POLKIT_DEFAULT_PRIVS="$POLKIT_DEFAULT_PRIVS local"
fi
# 3. package specific privileges
pkgfiles=(/etc/polkit-default-privs.d/*)
pkgfiles=(${pkgfiles[*]##*/})
pkgfiles=(${pkgfiles[*]%%.*})
pkgfiles=(`for i in ${pkgfiles[@]}; do echo $i; done | /usr/bin/sort -u`)
for file in ${pkgfiles[@]}; do
file=/etc/polkit-default-privs.d/$file
[ -e $file ] && files="$files $file"
for level in $POLKIT_DEFAULT_PRIVS; do
[ -e $file.$level ] && files="$files $file.$level"
done
done
# 4. central privileges files with user defined level incl 'local'
for level in $POLKIT_DEFAULT_PRIVS; do
case "$level" in
relaxed|standard|restrictive) continue ;;
local) have_local=1 ;;
esac
if [ -e /etc/polkit-default-privs.$level ]; then
files="$files /etc/polkit-default-privs.$level"
fi
done
chkstat-polkit $mode $files
ACC SHELL 2018