[node-patches] Change in ovirt-node[master]: Add validator for ssh port to only accpet "22" or "1024-65535"

hadong0720 at gmail.com hadong0720 at gmail.com
Fri Jul 11 13:16:51 UTC 2014


hadong has uploaded a new change for review.

Change subject: Add validator for ssh port to only accpet "22" or "1024-65535"
......................................................................

Add validator for ssh port to only accpet "22" or "1024-65535"

Change-Id: I4e5fe06ad0a1c8345e3b1265cbafdabc275bf1b5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1118758
Signed-off-by: hadong <hadong at redhat.com>
---
M src/ovirt/node/setup/core/security_page.py
M src/ovirt/node/utils/security.py
2 files changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/57/29957/1

diff --git a/src/ovirt/node/setup/core/security_page.py b/src/ovirt/node/setup/core/security_page.py
index 5845939..6c476c3 100644
--- a/src/ovirt/node/setup/core/security_page.py
+++ b/src/ovirt/node/setup/core/security_page.py
@@ -53,7 +53,9 @@
             valid.Empty()
         return {"strongrng.num_bytes": number_or_empty,
                 "passwd.admin.password":
-                valid.Empty() | valid.Text(min_length=5)
+                valid.Empty() | valid.Text(min_length=5),
+                "ssh.port":
+                (valid.Number(exactly=22) | valid.Number(bounds=[1024, 65535]))
                 }
 
     def ui_content(self):
diff --git a/src/ovirt/node/utils/security.py b/src/ovirt/node/utils/security.py
index e25a1b5..1fc0112 100644
--- a/src/ovirt/node/utils/security.py
+++ b/src/ovirt/node/utils/security.py
@@ -192,16 +192,16 @@
             except ValueError:
                 raise RuntimeError("Port must be an integer")
         if port is not None:
-            if int(port) in range(1, 65535):
+            if int(port) in range(1, 65536):
                 self.logger.debug("Setting SSH port to %s" % port)
                 aug.set(augpath, port)
                 self.restart()
 
             else:
-                raise RuntimeError("Port must be in the range [1-65535]")
+                raise RuntimeError("Port must be in the range [1-65536]")
 
         state = str(aug.get(augpath)).lower()
-        if state != "none" and int(state) not in range(1, 65535):
+        if state != "none" and int(state) not in range(1, 65536):
             raise RuntimeError("Failed to set SSH port: value is %s" % state)
         return state
 


-- 
To view, visit http://gerrit.ovirt.org/29957
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e5fe06ad0a1c8345e3b1265cbafdabc275bf1b5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list