mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Fix the "Kernel features are written to cache:" test
the cache test is failing because it assumes that kernel features are stored in a file instead of a directory Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
3876299fa0
commit
c8e134930f
2 changed files with 27 additions and 4 deletions
|
@ -768,7 +768,7 @@ static char *handle_features_dir(const char *filename, char **buffer, int size,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = snprintf_buffer(*buffer, pos, size, " }\n");
|
pos = snprintf_buffer(*buffer, pos, size, "}\n");
|
||||||
}
|
}
|
||||||
if (dirent_path)
|
if (dirent_path)
|
||||||
free(dirent_path);
|
free(dirent_path);
|
||||||
|
|
|
@ -49,11 +49,34 @@ echo -n "Profiles are cached when requested: "
|
||||||
[ ! -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile does not exist)" && exit 1
|
[ ! -f $basedir/cache/$profile ] && echo "FAIL ($basedir/cache/$profile does not exist)" && exit 1
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
read_features_dir()
|
||||||
|
{
|
||||||
|
directory="$1"
|
||||||
|
if [ ! -d "$directory" ] ; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
for f in `ls -AU "$directory"` ; do
|
||||||
|
if [ -f "$directory/$f" ] ; then
|
||||||
|
read -r -d "" KF < "$directory/$f" || true
|
||||||
|
echo -e "$f {$KF\n}"
|
||||||
|
elif [ -d "$directory/$f" ] ; then
|
||||||
|
echo -n "$f {"
|
||||||
|
KF=`read_features_dir "$directory/$f" "$KF"` || true
|
||||||
|
echo "$KF"
|
||||||
|
echo -e "}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
echo -n "Kernel features are written to cache: "
|
echo -n "Kernel features are written to cache: "
|
||||||
[ ! -f $basedir/cache/.features ] && echo "FAIL ($basedir/cache/.features missing)" && exit 1
|
[ ! -f $basedir/cache/.features ] && echo "FAIL ($basedir/cache/.features missing)" && exit 1
|
||||||
read CF < $basedir/cache/.features || true
|
read -r -d "" CF < $basedir/cache/.features || true
|
||||||
read KF < /sys/kernel/security/apparmor/features || true
|
if [ -d /sys/kernel/security/apparmor/features ] ; then
|
||||||
[ "$CF" != "$KF" ] && echo "FAIL (feature text mismatch: cache '$CF' vs kernel '$KF')" && exit 1
|
KF=`read_features_dir /sys/kernel/security/apparmor/features`
|
||||||
|
else
|
||||||
|
read -r -d "" KF < /sys/kernel/security/apparmor/features || true
|
||||||
|
fi
|
||||||
|
[ "$CF" != "$KF" ] && echo -e "FAIL (feature text mismatch:\n cache '$CF'\nvs\n kernel '$KF')" && exit 1
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
echo -n "Cache is loaded when it exists and features match: "
|
echo -n "Cache is loaded when it exists and features match: "
|
||||||
|
|
Loading…
Add table
Reference in a new issue