From c807ba5a11364d8eb83b86b0e4262a32b6834267 Mon Sep 17 00:00:00 2001
From: Anoop C S <anoopcs@redhat.com>
Date: Thu, 13 Dec 2018 12:05:37 +0530
Subject: [PATCH 483/493] Do not blindly add volume share section to smb.conf
With this change, by default GlusterFS volume share section will
no longer be added to smb.conf for client access unless user.cifs
or user.smb volume set options are enabled. This also fixes the
hook script to check for presence of all configuration possibilities
for those volume set options like 'enable' or 'on'.
upstream ref: https://review.gluster.org/c/glusterfs/+/19204
Change-Id: Ibecf7fffb4507d7255d963c3b1482afb0d0db984
BUG: 1541568
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/158497
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
extras/hook-scripts/set/post/S30samba-set.sh | 13 +++++++++++--
extras/hook-scripts/start/post/S30samba-start.sh | 18 +++++++++++++++---
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/extras/hook-scripts/set/post/S30samba-set.sh b/extras/hook-scripts/set/post/S30samba-set.sh
index c596db0..d2a62d3 100755
--- a/extras/hook-scripts/set/post/S30samba-set.sh
+++ b/extras/hook-scripts/set/post/S30samba-set.sh
@@ -123,9 +123,18 @@ function get_smb () {
usersmbvalue=$(grep user.smb $GLUSTERD_WORKDIR/vols/"$volname"/info |\
cut -d"=" -f2)
- if [ $usercifsvalue = "disable" ] || [ $usersmbvalue = "disable" ]; then
- uservalue="disable"
+ if [ -n "$usercifsvalue" ]; then
+ if [ "$usercifsvalue" = "disable" ] || [ "$usercifsvalue" = "off" ]; then
+ uservalue="disable"
+ fi
fi
+
+ if [ -n "$usersmbvalue" ]; then
+ if [ "$usersmbvalue" = "disable" ] || [ "$usersmbvalue" = "off" ]; then
+ uservalue="disable"
+ fi
+ fi
+
echo "$uservalue"
}
diff --git a/extras/hook-scripts/start/post/S30samba-start.sh b/extras/hook-scripts/start/post/S30samba-start.sh
index dfd9c1b..2854bdd 100755
--- a/extras/hook-scripts/start/post/S30samba-start.sh
+++ b/extras/hook-scripts/start/post/S30samba-start.sh
@@ -111,14 +111,26 @@ function get_smb () {
usersmbvalue=$(grep user.smb "$GLUSTERD_WORKDIR"/vols/"$volname"/info |\
cut -d"=" -f2)
- if [ "$usercifsvalue" = "disable" ] || [ "$usersmbvalue" = "disable" ]; then
- uservalue="disable"
+ if [ -n "$usercifsvalue" ]; then
+ if [ "$usercifsvalue" = "enable" ] || [ "$usercifsvalue" = "on" ]; then
+ uservalue="enable"
+ fi
fi
+
+ if [ -n "$usersmbvalue" ]; then
+ if [ "$usersmbvalue" = "enable" ] || [ "$usersmbvalue" = "on" ]; then
+ uservalue="enable"
+ fi
+ fi
+
echo "$uservalue"
}
parse_args "$@"
-if [ "$(get_smb "$VOL")" = "disable" ]; then
+
+value=$(get_smb "$VOL")
+
+if [ -z "$value" ] || [ "$value" != "enable" ]; then
exit 0
fi
--
1.8.3.1