[apparmor] [PATCH 11/11] Fix the "Kernel features are written to cache:" test
Steve Beattie
steve at nxnw.org
Thu Mar 8 19:26:25 UTC 2012
On Wed, Mar 07, 2012 at 06:17:30AM -0800, John Johansen wrote:
> 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 at canonical.com>
Acked-By: Steve Beattie <sbeattie at ubuntu.com>
> ---
> parser/parser_main.c | 2 +-
> parser/tst/caching.sh | 29 ++++++++++++++++++++++++++---
> 2 files changed, 27 insertions(+), 4 deletions(-)
>
> diff --git a/parser/parser_main.c b/parser/parser_main.c
> index ea2e1ed..67ab231 100644
> --- a/parser/parser_main.c
> +++ b/parser/parser_main.c
> @@ -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)
> free(dirent_path);
> diff --git a/parser/tst/caching.sh b/parser/tst/caching.sh
> index 2d3f552..ac265a9 100755
> --- a/parser/tst/caching.sh
> +++ b/parser/tst/caching.sh
> @@ -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
> 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: "
> [ ! -f $basedir/cache/.features ] && echo "FAIL ($basedir/cache/.features missing)" && exit 1
> -read CF < $basedir/cache/.features || true
> -read KF < /sys/kernel/security/apparmor/features || true
> -[ "$CF" != "$KF" ] && echo "FAIL (feature text mismatch: cache '$CF' vs kernel '$KF')" && exit 1
> +read -r -d "" CF < $basedir/cache/.features || true
> +if [ -d /sys/kernel/security/apparmor/features ] ; then
> + 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 -n "Cache is loaded when it exists and features match: "
> --
> 1.7.9
>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
--
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20120308/6ab2cfb7/attachment.pgp>
More information about the AppArmor
mailing list