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