summaryrefslogtreecommitdiffstats
path: root/extras/hook-scripts
diff options
context:
space:
mode:
authorXavier Hernandez <jahernan@redhat.com>2018-01-19 12:18:13 +0100
committerAmar Tumballi <amarts@redhat.com>2019-05-09 09:24:10 +0000
commitaee9e3d27f56e4c0c2f981f20b15189eb7ffce51 (patch)
tree7b1281112c04cf30577277ad3ae0485f89f0e331 /extras/hook-scripts
parent84b7cc57df065e2d8c0ac88b179aab3614ec814a (diff)
tests: improve and fix some test scripts
Change-Id: Iceefe22af754096c599dc570d4894d14fce4deae Updates: bz#1193929 Signed-off-by: Xavier Hernandez <xhernandez@redhat.com>
Diffstat (limited to 'extras/hook-scripts')
-rwxr-xr-xextras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh30
1 files changed, 17 insertions, 13 deletions
diff --git a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh b/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
index e7f4e8f5d49..056b52afe76 100755
--- a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
+++ b/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
@@ -35,26 +35,30 @@ function parse_args () {
function delete_brick_fcontext()
{
- volname="${1}"
+ local volname=$1
+ local fctx
+ local list=()
+ fctx="$(semanage fcontext --list -C)"
# grab the path for each local brick
brickpath="/var/lib/glusterd/vols/${volname}/bricks/"
- brickdirs=$(
- find "${brickpath}" -type f -exec grep '^path=' {} \; | \
- cut -d= -f 2 | \
- sort -u
- )
-
+ brickdirs=$(find "${brickpath}" -type f -exec grep '^path=' {} \; | \
+ cut -d= -f 2 | sort -u)
for b in ${brickdirs}
do
- # remove the file context associated with the brick path
pattern="${b}(/.*)?"
- semanage fcontext --delete "${pattern}"
-
- # remove the labels on brick path.
+ echo "${fctx}" | grep "^${pattern}\s" >/dev/null
+ if [[ $? -eq 0 ]]; then
+ list+=("${pattern}")
+ fi
+ done
+ if [[ ${#list[@]} -gt 0 ]]; then
+ printf 'fcontext --delete %s\n' "${list[@]}" | semanage -i -
+ fi
+ for b in ${brickdirs}
+ do
restorecon -R "${b}"
- done
-
+ done
}
SELINUX_STATE=$(which getenforce && getenforce)