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