190130
From 07ab5a460da007fc3809b1a943614d1c7f5fcfef Mon Sep 17 00:00:00 2001
190130
From: Sunny Kumar <sunkumar@redhat.com>
190130
Date: Fri, 17 Jan 2020 11:03:46 +0000
190130
Subject: [PATCH 408/449] geo-rep: Fix ssh-port validation
190130
190130
If non-standard ssh-port is used, Geo-rep can be configured to use ssh port
190130
by using config option, the value should be in allowed port range and non negative.
190130
190130
At present it can accept negative value and outside allowed port range which is incorrect.
190130
190130
Many Linux kernels use the port range 32768 to 61000.
190130
IANA suggests it should be in the range 1 to 2^16 - 1, so keeping the same.
190130
190130
$ gluster volume geo-replication master 127.0.0.1::slave config ssh-port -22
190130
geo-replication config updated successfully
190130
$ gluster volume geo-replication master 127.0.0.1::slave config ssh-port 22222222
190130
geo-replication config updated successfully
190130
190130
This patch fixes the above issue and have added few validations around this
190130
in test cases.
190130
Backport of:
190130
    >Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/24035/
190130
    >Change-Id: I9875ab3f00d7257370fbac6f5ed4356d2fed3f3c
190130
    >Fixes: bz#1792276
190130
    >Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
190130
190130
BUG: 1796814
190130
Change-Id: I9875ab3f00d7257370fbac6f5ed4356d2fed3f3c
190130
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
190130
Reviewed-on: https://code.engineering.redhat.com/gerrit/202453
190130
Tested-by: RHGS Build Bot <nigelb@redhat.com>
190130
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
190130
---
190130
 geo-replication/gsyncd.conf.in                     |  4 +++-
190130
 tests/00-geo-rep/00-georep-verify-non-root-setup.t | 16 ++++++++++++++++
190130
 tests/00-geo-rep/georep-basic-dr-rsync.t           | 13 +++++++++++++
190130
 3 files changed, 32 insertions(+), 1 deletion(-)
190130
190130
diff --git a/geo-replication/gsyncd.conf.in b/geo-replication/gsyncd.conf.in
190130
index 9155cd8..11e57fd 100644
190130
--- a/geo-replication/gsyncd.conf.in
190130
+++ b/geo-replication/gsyncd.conf.in
190130
@@ -266,7 +266,9 @@ allowed_values=ERROR,INFO,WARNING,DEBUG
190130
 
190130
 [ssh-port]
190130
 value=22
190130
-validation=int
190130
+validation=minmax
190130
+min=1
190130
+max=65535
190130
 help=Set SSH port
190130
 type=int
190130
 
190130
diff --git a/tests/00-geo-rep/00-georep-verify-non-root-setup.t b/tests/00-geo-rep/00-georep-verify-non-root-setup.t
190130
index c9fd8b2..12f0c01 100644
190130
--- a/tests/00-geo-rep/00-georep-verify-non-root-setup.t
190130
+++ b/tests/00-geo-rep/00-georep-verify-non-root-setup.t
190130
@@ -223,6 +223,22 @@ TEST $GEOREP_CLI  $master $slave_url resume
190130
 #Validate failure of volume stop when geo-rep is running
190130
 TEST ! $CLI volume stop $GMV0
190130
 
190130
+#Negative test for ssh-port
190130
+#Port should be integer and between 1-65535 range
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave_url config ssh-port -22
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave_url config ssh-port abc
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave_url config ssh-port 6875943
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave_url config ssh-port 4.5
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave_url config ssh-port 22a
190130
+
190130
+#Config Set ssh-port to validate int validation
190130
+TEST $GEOREP_CLI $master $slave config ssh-port 22
190130
+
190130
 #Hybrid directory rename test BZ#1763439
190130
 TEST $GEOREP_CLI $master $slave_url config change_detector xsync
190130
 mkdir ${master_mnt}/dir1
190130
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t
190130
index b6fbf18..d785aa5 100644
190130
--- a/tests/00-geo-rep/georep-basic-dr-rsync.t
190130
+++ b/tests/00-geo-rep/georep-basic-dr-rsync.t
190130
@@ -71,6 +71,19 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 4 check_status_num_rows "Created"
190130
 #Config gluster-command-dir
190130
 TEST $GEOREP_CLI $master $slave config gluster-command-dir ${GLUSTER_CMD_DIR}
190130
 
190130
+#Negative test for ssh-port
190130
+#Port should be integer and between 1-65535 range
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave config ssh-port -22
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave config ssh-port abc
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave config ssh-port 6875943
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave config ssh-port 4.5
190130
+
190130
+TEST ! $GEOREP_CLI $master $slave config ssh-port 22a
190130
+
190130
 #Config Set ssh-port to validate int validation
190130
 TEST $GEOREP_CLI $master $slave config ssh-port 22
190130
 
190130
-- 
190130
1.8.3.1
190130