mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
chore: fix and cosmetic.
This commit is contained in:
parent
f022ca3299
commit
abaf9fdc7c
10
configure
vendored
10
configure
vendored
@ -9,7 +9,7 @@ DISTRIBUTION="$(lsb_release --id --short)"
|
|||||||
readonly DISTRIBUTION="${DISTRIBUTION,,}"
|
readonly DISTRIBUTION="${DISTRIBUTION,,}"
|
||||||
readonly ROOT=.build
|
readonly ROOT=.build
|
||||||
|
|
||||||
_die() { printf 'Error: %s\n' "$*" >&2 && exit 1; }
|
_die() { printf 'Error: %s\n' "$*" >&2 && exit 1; }
|
||||||
_warning() { printf ' Warning: %s\n' "$*" >&2; }
|
_warning() { printf ' Warning: %s\n' "$*" >&2; }
|
||||||
_title() { printf '%s\n' "$*" >&2; }
|
_title() { printf '%s\n' "$*" >&2; }
|
||||||
_msg() { printf ' - %s\n' "$*" >&2; }
|
_msg() { printf ' - %s\n' "$*" >&2; }
|
||||||
@ -36,7 +36,7 @@ ignore() {
|
|||||||
while read -r profile; do
|
while read -r profile; do
|
||||||
[[ "$profile" =~ ^\# ]] && continue
|
[[ "$profile" =~ ^\# ]] && continue
|
||||||
[[ -z "$profile" ]] && continue
|
[[ -z "$profile" ]] && continue
|
||||||
if [[ -e "${ROOT:?}/$profile" ]]; then
|
if [[ -e "${ROOT:?}/$profile" ]]; then
|
||||||
rm -r "${ROOT:?}/$profile"
|
rm -r "${ROOT:?}/$profile"
|
||||||
else
|
else
|
||||||
find "$ROOT/apparmor.d" -iname "$profile" -type f -exec rm {} \;
|
find "$ROOT/apparmor.d" -iname "$profile" -type f -exec rm {} \;
|
||||||
@ -86,7 +86,7 @@ configure() {
|
|||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*) _die "$DISTRIBUTION is not a supported distribution." ;;
|
*) _die "$DISTRIBUTION is not a supported distribution." ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ flags() {
|
|||||||
_msg "Set profiles flags from dists/flags/$name"
|
_msg "Set profiles flags from dists/flags/$name"
|
||||||
|
|
||||||
while read -r profile; do
|
while read -r profile; do
|
||||||
IFS=' ' read -r -a manifest <<< "$profile"
|
IFS=' ' read -r -a manifest <<<"$profile"
|
||||||
profile="${manifest[0]:-}" flags="${manifest[1]:-}"
|
profile="${manifest[0]:-}" flags="${manifest[1]:-}"
|
||||||
|
|
||||||
[[ "$profile" =~ ^\# || -z "$profile" ]] && continue
|
[[ "$profile" =~ ^\# || -z "$profile" ]] && continue
|
||||||
@ -127,7 +127,7 @@ complain() {
|
|||||||
[[ "$flags" =~ complain ]] && continue
|
[[ "$flags" =~ complain ]] && continue
|
||||||
echo -n .
|
echo -n .
|
||||||
sed -e "s/flags=(.*)//" \
|
sed -e "s/flags=(.*)//" \
|
||||||
-e "s/ {$/ flags=(complain $flags) {/" \
|
-e "s/ {$/ flags=(complain $flags) {/" \
|
||||||
-i "$path"
|
-i "$path"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
14
pick
14
pick
@ -3,6 +3,11 @@
|
|||||||
# Copyright (C) 2021 Alexandre Pujol <alexandre@pujol.io>
|
# Copyright (C) 2021 Alexandre Pujol <alexandre@pujol.io>
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
DISTRIBUTION="$(lsb_release --id --short)"
|
||||||
|
readonly DISTRIBUTION="${DISTRIBUTION,,}"
|
||||||
|
|
||||||
_set_complain() {
|
_set_complain() {
|
||||||
local path="$1"
|
local path="$1"
|
||||||
[[ -d "$path" ]] && return
|
[[ -d "$path" ]] && return
|
||||||
@ -25,12 +30,15 @@ _install_tunables() {
|
|||||||
for path in apparmor.d/tunables/*; do
|
for path in apparmor.d/tunables/*; do
|
||||||
install -Dm0644 "$path" "/etc/apparmor.d/tunables/$(basename "$path")"
|
install -Dm0644 "$path" "/etc/apparmor.d/tunables/$(basename "$path")"
|
||||||
done
|
done
|
||||||
|
if [[ "$DISTRIBUTION" != "arch" ]]; then
|
||||||
|
sed -i -e '/Archlinux/d' /etc/apparmor.d/tunables/extend
|
||||||
|
sed -i -e '/etc/d' /etc/apparmor.d/tunables/global
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_reload_apparmor() {
|
_reload_apparmor() {
|
||||||
systemctl restart apparmor || true
|
systemctl restart apparmor || true
|
||||||
systemctl status apparmor
|
systemctl status apparmor
|
||||||
return $?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pick() {
|
pick() {
|
||||||
@ -41,7 +49,6 @@ pick() {
|
|||||||
[[ "$COMPLAIN" == 1 ]] && _set_complain "/etc/apparmor.d/$profile"
|
[[ "$COMPLAIN" == 1 ]] && _set_complain "/etc/apparmor.d/$profile"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return $?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print help message
|
# Print help message
|
||||||
@ -59,7 +66,7 @@ main() {
|
|||||||
local opts err
|
local opts err
|
||||||
small_arg="ch"
|
small_arg="ch"
|
||||||
long_arg="complain,help"
|
long_arg="complain,help"
|
||||||
opts="$(getopt -o $small_arg -l $long_arg -n "$PROGRAM" -- "$@")"
|
opts="$(getopt -o $small_arg -l $long_arg -n "pick" -- "$@")"
|
||||||
err=$?
|
err=$?
|
||||||
eval set -- "$opts"
|
eval set -- "$opts"
|
||||||
while true; do case $1 in
|
while true; do case $1 in
|
||||||
@ -72,7 +79,6 @@ main() {
|
|||||||
_install_abstractions
|
_install_abstractions
|
||||||
_install_tunables
|
_install_tunables
|
||||||
pick "$@" && _reload_apparmor
|
pick "$@" && _reload_apparmor
|
||||||
return $?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COMPLAIN=0
|
COMPLAIN=0
|
||||||
|
Loading…
Reference in New Issue
Block a user