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