2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00
apparmor/parser/apparmor.systemd
Georgia Garcia b7f9b66cba Merge gitlab-ci.yml: fix pipeline for ubuntu:latest (noble)
Since we are using ubuntu:latest, and noble was released, some tests
are failing.

shellcheck needs python3 to run, which was possibly installed by
default in previous ubuntu images and is no longer the case.

Ignore dist-packages python files during our coverage tests.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/388

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

Closes #388
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1223
Merged-by: Steve Beattie <steve+gitlab@nxnw.org>


(cherry picked from commit 8c9ac7a84eeff7bbf49e7bedb6f05be08d1dd6a3)

731880de gitlab-ci.yml: fix pipeline for ubuntu:latest (noble)
aaad725a apparmor.systemd: fix shellcheck false positive

Co-authored-by: Steve Beattie <steve+gitlab@nxnw.org>
2024-05-02 13:37:53 +00:00

132 lines
2.8 KiB
Bash

#!/bin/sh
# ----------------------------------------------------------------------
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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, contact Novell, Inc.
# ----------------------------------------------------------------------
APPARMOR_FUNCTIONS=/lib/apparmor/rc.apparmor.functions
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_action()
{
echo "$1"
shift
"$@"
return $?
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_warning_msg()
{
echo "Warning: $*"
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_failure_msg()
{
echo "Error: $*"
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_action_start()
{
echo "$@"
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_action_end()
{
printf ""
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_daemon_msg()
{
echo "$@"
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_skipped_msg()
{
echo "Skipped: $*"
}
# This function is used in rc.apparmor.functions
# shellcheck disable=SC2317
aa_log_end_msg()
{
printf ""
}
# source apparmor function library
if [ -f "${APPARMOR_FUNCTIONS}" ]; then
# shellcheck source=rc.apparmor.functions
. "${APPARMOR_FUNCTIONS}"
else
aa_log_failure_msg "Unable to find AppArmor initscript functions"
exit 1
fi
case "$1" in
start)
if [ -x /usr/bin/systemd-detect-virt ] && \
systemd-detect-virt --quiet --container && \
! is_container_with_internal_policy; then
aa_log_daemon_msg "Not starting AppArmor in container"
aa_log_end_msg 0
exit 0
fi
apparmor_start
rc=$?
;;
stop)
apparmor_stop
rc=$?
;;
restart|reload|force-reload)
if [ -x /usr/bin/systemd-detect-virt ] && \
systemd-detect-virt --quiet --container && \
! is_container_with_internal_policy; then
aa_log_daemon_msg "Not starting AppArmor in container"
aa_log_end_msg 0
exit 0
fi
apparmor_restart
rc=$?
;;
try-restart)
apparmor_try_restart
rc=$?
;;
kill)
apparmor_kill
rc=$?
;;
status)
apparmor_status
rc=$?
;;
*)
exit 1
;;
esac
exit "$rc"