a3470f
From a25382d5aa9cddde04b1b3355e9d0d1b43e66406 Mon Sep 17 00:00:00 2001
a3470f
From: Atin Mukherjee <amukherj@redhat.com>
a3470f
Date: Mon, 16 Apr 2018 22:49:37 +0530
a3470f
Subject: [PATCH 222/236] hooks: remove selinux hooks
a3470f
a3470f
Label: DOWNSTREAM ONLY
a3470f
a3470f
Change-Id: I810466a0ca99ab21f5a8eac8cdffbb18333d10ad
a3470f
BUG: 1565962
a3470f
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/135800
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Jiffin Thottan <jthottan@redhat.com>
a3470f
Reviewed-by: Milind Changire <mchangir@redhat.com>
a3470f
---
a3470f
 configure.ac                                       | 20 -------
a3470f
 extras/hook-scripts/Makefile.am                    |  2 +-
a3470f
 extras/hook-scripts/create/Makefile.am             |  1 -
a3470f
 extras/hook-scripts/create/post/Makefile.am        |  6 ---
a3470f
 .../create/post/S10selinux-label-brick.sh          | 62 ----------------------
a3470f
 extras/hook-scripts/delete/Makefile.am             |  1 -
a3470f
 extras/hook-scripts/delete/pre/Makefile.am         |  6 ---
a3470f
 .../delete/pre/S10selinux-del-fcontext.sh          | 59 --------------------
a3470f
 glusterfs.spec.in                                  |  5 +-
a3470f
 9 files changed, 4 insertions(+), 158 deletions(-)
a3470f
 delete mode 100644 extras/hook-scripts/create/Makefile.am
a3470f
 delete mode 100644 extras/hook-scripts/create/post/Makefile.am
a3470f
 delete mode 100755 extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
 delete mode 100644 extras/hook-scripts/delete/Makefile.am
a3470f
 delete mode 100644 extras/hook-scripts/delete/pre/Makefile.am
a3470f
 delete mode 100755 extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
a3470f
diff --git a/configure.ac b/configure.ac
a3470f
index c9a1cde..b388a13 100644
a3470f
--- a/configure.ac
a3470f
+++ b/configure.ac
a3470f
@@ -228,10 +228,6 @@ AC_CONFIG_FILES([Makefile
a3470f
                 extras/hook-scripts/add-brick/Makefile
a3470f
                 extras/hook-scripts/add-brick/pre/Makefile
a3470f
                 extras/hook-scripts/add-brick/post/Makefile
a3470f
-                extras/hook-scripts/create/Makefile
a3470f
-                extras/hook-scripts/create/post/Makefile
a3470f
-                extras/hook-scripts/delete/Makefile
a3470f
-                extras/hook-scripts/delete/pre/Makefile
a3470f
                 extras/hook-scripts/start/Makefile
a3470f
                 extras/hook-scripts/start/post/Makefile
a3470f
                 extras/hook-scripts/set/Makefile
a3470f
@@ -911,21 +907,6 @@ else
a3470f
 fi
a3470f
 # end of xml-output
a3470f
 
a3470f
-dnl SELinux feature enablement
a3470f
-case $host_os in
a3470f
-  linux*)
a3470f
-    AC_ARG_ENABLE([selinux],
a3470f
-                  AC_HELP_STRING([--disable-selinux],
a3470f
-                                 [Disable SELinux features]),
a3470f
-                  [USE_SELINUX="${enableval}"], [USE_SELINUX="yes"])
a3470f
-    ;;
a3470f
-  *)
a3470f
-    USE_SELINUX=no
a3470f
-    ;;
a3470f
-esac
a3470f
-AM_CONDITIONAL(USE_SELINUX, test "x${USE_SELINUX}" = "xyes")
a3470f
-dnl end of SELinux feature enablement
a3470f
-
a3470f
 AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes])
a3470f
 if test "x${have_backtrace}" = "xyes"; then
a3470f
    AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
a3470f
@@ -1577,7 +1558,6 @@ echo "Unit Tests           : $BUILD_UNITTEST"
a3470f
 echo "Track priv ports     : $TRACK_PRIVPORTS"
a3470f
 echo "POSIX ACLs           : $BUILD_POSIX_ACLS"
a3470f
 echo "Data Classification  : $BUILD_GFDB"
a3470f
-echo "SELinux features     : $USE_SELINUX"
a3470f
 echo "firewalld-config     : $BUILD_FIREWALLD"
a3470f
 echo "Events               : $BUILD_EVENTS"
a3470f
 echo "EC dynamic support   : $EC_DYNAMIC_SUPPORT"
a3470f
diff --git a/extras/hook-scripts/Makefile.am b/extras/hook-scripts/Makefile.am
a3470f
index 26059d7..771b37e 100644
a3470f
--- a/extras/hook-scripts/Makefile.am
a3470f
+++ b/extras/hook-scripts/Makefile.am
a3470f
@@ -1,5 +1,5 @@
a3470f
 EXTRA_DIST = S40ufo-stop.py S56glusterd-geo-rep-create-post.sh
a3470f
-SUBDIRS = add-brick create delete set start stop reset
a3470f
+SUBDIRS = add-brick set start stop reset
a3470f
 
a3470f
 scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/gsync-create/post/
a3470f
 if USE_GEOREP
a3470f
diff --git a/extras/hook-scripts/create/Makefile.am b/extras/hook-scripts/create/Makefile.am
a3470f
deleted file mode 100644
a3470f
index b083a91..0000000
a3470f
--- a/extras/hook-scripts/create/Makefile.am
a3470f
+++ /dev/null
a3470f
@@ -1 +0,0 @@
a3470f
-SUBDIRS = post
a3470f
diff --git a/extras/hook-scripts/create/post/Makefile.am b/extras/hook-scripts/create/post/Makefile.am
a3470f
deleted file mode 100644
a3470f
index adbce78..0000000
a3470f
--- a/extras/hook-scripts/create/post/Makefile.am
a3470f
+++ /dev/null
a3470f
@@ -1,6 +0,0 @@
a3470f
-EXTRA_DIST = S10selinux-label-brick.sh
a3470f
-
a3470f
-scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/create/post/
a3470f
-if USE_SELINUX
a3470f
-scripts_SCRIPTS = S10selinux-label-brick.sh
a3470f
-endif
a3470f
diff --git a/extras/hook-scripts/create/post/S10selinux-label-brick.sh b/extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
deleted file mode 100755
a3470f
index de242d2..0000000
a3470f
--- a/extras/hook-scripts/create/post/S10selinux-label-brick.sh
a3470f
+++ /dev/null
a3470f
@@ -1,62 +0,0 @@
a3470f
-#!/bin/bash
a3470f
-#
a3470f
-# Install to hooks/<HOOKS_VER>/create/post
a3470f
-#
a3470f
-# Add an SELinux file context for each brick using the glusterd_brick_t type.
a3470f
-# This ensures that the brick is relabeled correctly on an SELinux restart or
a3470f
-# restore. Subsequently, run a restore on the brick path to set the selinux
a3470f
-# labels.
a3470f
-#
a3470f
-###
a3470f
-
a3470f
-PROGNAME="Sselinux"
a3470f
-OPTSPEC="volname:"
a3470f
-VOL=
a3470f
-
a3470f
-parse_args () {
a3470f
-  ARGS=$(getopt -o '' -l ${OPTSPEC} -n ${PROGNAME} -- "$@")
a3470f
-  eval set -- "${ARGS}"
a3470f
-
a3470f
-  while true; do
a3470f
-    case ${1} in
a3470f
-      --volname)
a3470f
-        shift
a3470f
-        VOL=${1}
a3470f
-      ;;
a3470f
-      *)
a3470f
-        shift
a3470f
-        break
a3470f
-      ;;
a3470f
-    esac
a3470f
-    shift
a3470f
-  done
a3470f
-}
a3470f
-
a3470f
-set_brick_labels()
a3470f
-{
a3470f
-  volname=${1}
a3470f
-
a3470f
-  # grab the path for each local brick
a3470f
-  brickpath="/var/lib/glusterd/vols/${volname}/bricks/*"
a3470f
-  brickdirs=$(grep '^path=' "${brickpath}" | cut -d= -f 2 | sort -u)
a3470f
-
a3470f
-  for b in ${brickdirs}; do
a3470f
-    # Add a file context for each brick path and associate with the
a3470f
-    # glusterd_brick_t SELinux type.
a3470f
-    pattern="${b}\(/.*\)?"
a3470f
-    semanage fcontext --add -t glusterd_brick_t -r s0 "${pattern}"
a3470f
-
a3470f
-    # Set the labels on the new brick path.
a3470f
-    restorecon -R "${b}"
a3470f
-  done
a3470f
-}
a3470f
-
a3470f
-SELINUX_STATE=$(which getenforce && getenforce)
a3470f
-[ "${SELINUX_STATE}" = 'Disabled' ] && exit 0
a3470f
-
a3470f
-parse_args "$@"
a3470f
-[ -z "${VOL}" ] && exit 1
a3470f
-
a3470f
-set_brick_labels "${VOL}"
a3470f
-
a3470f
-exit 0
a3470f
diff --git a/extras/hook-scripts/delete/Makefile.am b/extras/hook-scripts/delete/Makefile.am
a3470f
deleted file mode 100644
a3470f
index c98a05d..0000000
a3470f
--- a/extras/hook-scripts/delete/Makefile.am
a3470f
+++ /dev/null
a3470f
@@ -1 +0,0 @@
a3470f
-SUBDIRS = pre
a3470f
diff --git a/extras/hook-scripts/delete/pre/Makefile.am b/extras/hook-scripts/delete/pre/Makefile.am
a3470f
deleted file mode 100644
a3470f
index bf0eabe..0000000
a3470f
--- a/extras/hook-scripts/delete/pre/Makefile.am
a3470f
+++ /dev/null
a3470f
@@ -1,6 +0,0 @@
a3470f
-EXTRA_DIST = S10selinux-del-fcontext.sh
a3470f
-
a3470f
-scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/delete/pre/
a3470f
-if USE_SELINUX
a3470f
-scripts_SCRIPTS = S10selinux-del-fcontext.sh
a3470f
-endif
a3470f
diff --git a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh b/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
deleted file mode 100755
a3470f
index 6eba66f..0000000
a3470f
--- a/extras/hook-scripts/delete/pre/S10selinux-del-fcontext.sh
a3470f
+++ /dev/null
a3470f
@@ -1,59 +0,0 @@
a3470f
-#!/bin/bash
a3470f
-#
a3470f
-# Install to hooks/<HOOKS_VER>/delete/pre
a3470f
-#
a3470f
-# Delete the file context associated with the brick path on volume deletion. The
a3470f
-# associated file context was added during volume creation.
a3470f
-#
a3470f
-# We do not explicitly relabel the brick, as this could be time consuming and
a3470f
-# unnecessary.
a3470f
-#
a3470f
-###
a3470f
-
a3470f
-PROGNAME="Sselinux"
a3470f
-OPTSPEC="volname:"
a3470f
-VOL=
a3470f
-
a3470f
-function parse_args () {
a3470f
-        ARGS=$(getopt -o '' -l $OPTSPEC -n $PROGNAME -- "$@")
a3470f
-        eval set -- "$ARGS"
a3470f
-
a3470f
-        while true; do
a3470f
-        case $1 in
a3470f
-        --volname)
a3470f
-         shift
a3470f
-         VOL=$1
a3470f
-         ;;
a3470f
-        *)
a3470f
-         shift
a3470f
-         break
a3470f
-         ;;
a3470f
-        esac
a3470f
-        shift
a3470f
-        done
a3470f
-}
a3470f
-
a3470f
-function delete_brick_fcontext()
a3470f
-{
a3470f
-        volname=$1
a3470f
-
a3470f
-        # grab the path for each local brick
a3470f
-        brickdirs=$(grep '^path=' /var/lib/glusterd/vols/${volname}/bricks/* | cut -d= -f 2)
a3470f
-
a3470f
-        for b in $brickdirs
a3470f
-        do
a3470f
-                # remove the file context associated with the brick path
a3470f
-                semanage fcontext --delete $b\(/.*\)?
a3470f
-        done
a3470f
-}
a3470f
-
a3470f
-SELINUX_STATE=$(which getenforce && getenforce)
a3470f
-[ "${SELINUX_STATE}" = 'Disabled' ] && exit 0
a3470f
-
a3470f
-parse_args "$@"
a3470f
-[ -z "$VOL" ] && exit 1
a3470f
-
a3470f
-delete_brick_fcontext $VOL
a3470f
-
a3470f
-# failure to delete the fcontext is not fatal
a3470f
-exit 0
a3470f
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
a3470f
index 4b5238a..64e7e29 100644
a3470f
--- a/glusterfs.spec.in
a3470f
+++ b/glusterfs.spec.in
a3470f
@@ -1523,7 +1523,6 @@ exit 0
a3470f
             %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/add-brick/pre/S28Quota-enable-root-xattr-heal.sh
a3470f
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create
a3470f
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create/post
a3470f
-            %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create/post/S10selinux-label-brick.sh
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/create/pre
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/copy-file
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/copy-file/post
a3470f
@@ -1532,7 +1531,6 @@ exit 0
a3470f
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete/post
a3470f
                             %{_sharedstatedir}/glusterd/hooks/1/delete/post/S57glusterfind-delete-post
a3470f
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete/pre
a3470f
-            %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/delete/pre/S10selinux-del-fcontext.sh
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick/post
a3470f
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/remove-brick/pre
a3470f
@@ -2157,6 +2155,9 @@ fi
a3470f
 %endif
a3470f
 
a3470f
 %changelog
a3470f
+* Wed Apr 18 2018 Atin Mukherjee  <amukherj@redhat.com>
a3470f
+- Revert SELinux hooks (#1565962)
a3470f
+
a3470f
 * Thu Feb 22 2018 Kotresh HR <khiremat@redhat.com>
a3470f
 - Added util-linux as dependency to georeplication rpm (#1544382)
a3470f
 
a3470f
-- 
a3470f
1.8.3.1
a3470f