Skip to content
Snippets Groups Projects
Commit 3095eff3 authored by Frederic Danis's avatar Frederic Danis
Browse files

apparmor/ofono: Remove test


Test has been moved to `tests/ofono`.

Signed-off-by: default avatarFrédéric Danis <frederic.danis@collabora.com>
parent bfcb0d77
No related branches found
No related tags found
2 merge requests!271Backport from v2023dev1 to v2022,!266geoclue: Update malicious test
#!/bin/sh
# vim: set sts=4 sw=4 et tw=0 :
set -e
set -x
CURDIR=$(cd $(dirname $0); pwd; cd - >/dev/null 2>&1)
if [ $# -ne 1 ] || { [ "$1" != normal ] && [ "$1" != malicious ] ; }
then
echo "Usage: $0 <normal|malicious>"
exit 1
fi
# This expects to run as root.
if [ "$(id -u)" -ne 0 ]; then
echo "$CURDIR/ofonod must run as root."
exit 2
fi
systemctl stop ofono.service
if [ "$1" = "malicious" ]; then
# Create temporary service conf file
SERVICE_CONF_DIR="/run/systemd/system/ofono.service.d/"
mkdir -p $SERVICE_CONF_DIR
SERVICE_CONF_FILE=$SERVICE_CONF_DIR"apertis-tests-temporary.conf"
echo "[Service]" > $SERVICE_CONF_FILE
echo "Environment=LD_PRELOAD=$CURDIR/libofonod-malicious-override.so" >> $SERVICE_CONF_FILE
# Load this temp file
systemctl daemon-reload
fi
systemctl start ofono.service
# Check it is actually confined.
pid=`pidof /usr/sbin/ofonod`
confinement=`cat /proc/$pid/attr/current`
if [ "$confinement" != "/usr/sbin/ofonod (enforce)" ]; then
echo "Invalid confinement: $confinement"
exit 3
fi
sleep 5
systemctl stop ofono.service
if [ -n "$SERVICE_CONF_FILE" ]; then
rm $SERVICE_CONF_FILE
# Reload now that the temp config file has been removed
systemctl daemon-reload
fi
systemctl start ofono.service
# Lava compatibility:
# systemctl status will exit 0 if service is running, non-zero otherwise
systemctl status ofono.service
exit $?
====
profile:/usr/sbin/ofonod
sdmode:REJECTING
denied_mask:r
operation:open
name:/etc/shadow
request_mask:r
../run-aa-test
\ No newline at end of file
#!/bin/sh
set -x
CURDIR=$(cd $(dirname $0); pwd; cd - >/dev/null 2>&1)
# These tests must run as root: they need to manage the ofonod system process.
# They should also use the existing system bus.
export RUN_AS_USER=no
export LAUNCH_DBUS=no
${CURDIR}/run-aa-test ${CURDIR}/ofonod.malicious.expected ${CURDIR}/ofonod malicious
RET1=$?
${CURDIR}/run-aa-test ${CURDIR}/ofonod.normal.expected ${CURDIR}/ofonod normal
RET2=$?
# Output is boring below here
set +x
if [ $RET1 -ne 0 -o $RET2 -ne 0 ]; then
exit 1
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment