Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 30 lines 1.2 kB view raw
1commit 166afaf144d6473464975438353257359dd51708 2Author: Andreas Wiese <andreas.wiese@kernkonzept.com> 3Date: Thu Feb 1 11:35:02 2024 +0100 4 5 aa-remove-unknown: fix readability check 6 7 This check is intended for ensuring that the profiles file can actually 8 be opened. The *actual* check is performed by the shell, not the read 9 utility, which won't even be executed if the input redirection (and 10 hence the test) fails. 11 12 If the test succeeds, though, using `read` here might actually 13 jeopardize the test result if there are no profiles loaded and the file 14 is empty. 15 16 This commit fixes that case by simply using `true` instead of `read`. 17 18diff --git a/utils/aa-remove-unknown b/utils/aa-remove-unknown 19index 0e00d6a0..3351feef 100755 20--- a/utils/aa-remove-unknown 21+++ b/utils/aa-remove-unknown 22@@ -63,7 +63,7 @@ fi 23 # We have to do this check because error checking awk's getline() below is 24 # tricky and, as is, results in an infinite loop when apparmorfs returns an 25 # error from open(). 26-if ! IFS= read -r _ < "$PROFILES" ; then 27+if ! true < "$PROFILES" ; then 28 echo "ERROR: Unable to read apparmorfs profiles file" 1>&2 29 exit 1 30 elif [ ! -w "$REMOVE" ] ; then