mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-13 11:07:46 +10:00
selinux: Chain up tool resolving errors in install_policy.sh
[ Upstream commit6ae0042f4d
] Subshell evaluations are not exempt from errexit, so if a command is not available, `which` will fail and exit the script as a whole. This causes the helpful error messages to not be printed if they are tacked on using a `$?` comparison. Resolve the issue by using chains of logical operators, which are not subject to the effects of errexit. Fixes:e37c1877ba
("scripts/selinux: modernize mdp") Signed-off-by: Tim Schumacher <tim.schumacher1@huawei.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
51c36f0d21
commit
159b1b9493
@ -6,27 +6,24 @@ if [ `id -u` -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SF=`which setfiles`
|
||||
if [ $? -eq 1 ]; then
|
||||
SF=`which setfiles` || {
|
||||
echo "Could not find setfiles"
|
||||
echo "Do you have policycoreutils installed?"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
CP=`which checkpolicy`
|
||||
if [ $? -eq 1 ]; then
|
||||
CP=`which checkpolicy` || {
|
||||
echo "Could not find checkpolicy"
|
||||
echo "Do you have checkpolicy installed?"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
VERS=`$CP -V | awk '{print $1}'`
|
||||
|
||||
ENABLED=`which selinuxenabled`
|
||||
if [ $? -eq 1 ]; then
|
||||
ENABLED=`which selinuxenabled` || {
|
||||
echo "Could not find selinuxenabled"
|
||||
echo "Do you have libselinux-utils installed?"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if selinuxenabled; then
|
||||
echo "SELinux is already enabled"
|
||||
|
Loading…
Reference in New Issue
Block a user