On Thu, Nov 29, 2012 at 03:30:44PM +0100, Vratislav Podzimek wrote:
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
pyanaconda/ui/gui/spokes/datetime_spoke.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py
b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index e44c864..2ac6ee6 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -220,6 +220,19 @@ class NTPconfigDialog(GUIObject):
self._threads_counter += 1
def _add_server(self, server):
+ """
+ Checks if a given server is a valid hostname and if yes, adds it
+ to the list of servers.
+
+ @param server: string containing hostname
+
+ """
+
+ (valid, error) = network.sanityCheckHostname(server)
+ if not valid:
+ log.error("'%s' is not a valid hostname" % server)
+ return
+
for row in self._serversStore:
if row[0] == server:
#do not add duplicate items
@@ -251,6 +264,11 @@ class NTPconfigDialog(GUIObject):
if not path:
return
+ (valid, error) = network.sanityCheckHostname(new_text)
+ if not valid:
+ log.error("'%s' is not a valid hostname" % new_text)
+ return
+
itr = self._serversStore.get_iter(path)
if self._serversStore[itr][0] == new_text:
--
1.7.11.7
You may as well log the error string returned by the function, might be
helpful in some cases.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)