[PATCH 2/2] Check if the given NTP server is a valid hostname (#865869)
Vratislav Podzimek
vpodzime at redhat.com
Fri Nov 30 08:54:53 UTC 2012
On Thu, 2012-11-29 at 14:25 -0800, Brian C. Lane wrote:
> On Thu, Nov 29, 2012 at 03:30:44PM +0100, Vratislav Podzimek wrote:
> >
> > Signed-off-by: Vratislav Podzimek <vpodzime at 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.
I was thinking about that too, but the problem is (or isn't it?) that
these error strings are translated. I believe they still might be
helpful, but I'm not sure we want translated messages in logs.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list