Merge pull request #285915 from herrwiese/for-master/fix-273164

apparmor-utils: fix aa-remove-unknown read check
This commit is contained in:
ajs124 2024-02-25 15:16:23 +01:00 committed by GitHub
commit 991ec05997
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,30 @@
commit 166afaf144d6473464975438353257359dd51708
Author: Andreas Wiese <andreas.wiese@kernkonzept.com>
Date: Thu Feb 1 11:35:02 2024 +0100
aa-remove-unknown: fix readability check
This check is intended for ensuring that the profiles file can actually
be opened. The *actual* check is performed by the shell, not the read
utility, which won't even be executed if the input redirection (and
hence the test) fails.
If the test succeeds, though, using `read` here might actually
jeopardize the test result if there are no profiles loaded and the file
is empty.
This commit fixes that case by simply using `true` instead of `read`.
diff --git a/utils/aa-remove-unknown b/utils/aa-remove-unknown
index 0e00d6a0..3351feef 100755
--- a/utils/aa-remove-unknown
+++ b/utils/aa-remove-unknown
@@ -63,7 +63,7 @@ fi
# We have to do this check because error checking awk's getline() below is
# tricky and, as is, results in an infinite loop when apparmorfs returns an
# error from open().
-if ! IFS= read -r _ < "$PROFILES" ; then
+if ! true < "$PROFILES" ; then
echo "ERROR: Unable to read apparmorfs profiles file" 1>&2
exit 1
elif [ ! -w "$REMOVE" ] ; then

View file

@ -56,7 +56,9 @@ let
--replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h" --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
''; '';
patches = lib.optionals stdenv.hostPlatform.isMusl [ patches = [
./0001-aa-remove-unknown_empty-ruleset.patch
] ++ lib.optionals stdenv.hostPlatform.isMusl [
(fetchpatch { (fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/testing/apparmor/0003-Added-missing-typedef-definitions-on-parser.patch?id=74b8427cc21f04e32030d047ae92caa618105b53"; url = "https://git.alpinelinux.org/aports/plain/testing/apparmor/0003-Added-missing-typedef-definitions-on-parser.patch?id=74b8427cc21f04e32030d047ae92caa618105b53";
name = "0003-Added-missing-typedef-definitions-on-parser.patch"; name = "0003-Added-missing-typedef-definitions-on-parser.patch";