From 4e2e62572c51455c199485496c3fb6af5e833915 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Fri, 31 Jan 2020 01:06:50 +0100 Subject: fetchmailconf: Catch errors from get_greetline() This will handle name service errors with an individual error message, and other OSErrors in a general way. Reported by: Sergey Alirzaev. Fixes Gitlab Issue #12. --- fetchmailconf.py | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/fetchmailconf.py b/fetchmailconf.py index d74f74ee..365ada04 100755 --- a/fetchmailconf.py +++ b/fetchmailconf.py @@ -1316,25 +1316,39 @@ class ServerEdit(Frame, MyWidget): realhost = self.server.pollname errors=[] sslmode, protocol = None, None # will be used after loop - for sslmode in True, False: - for protocol in "IMAP", "POP3", "POP2": - service = defaultports[protocol] - if sslmode: - if service not in sslservices: - continue - port = sslservices[service] - else: - port = ianaservices[service] - greetline, address, new_errors = get_greetline(realhost, port, sslmode) - if new_errors: - errors += new_errors + confirm = "" + try: + for sslmode in True, False: + for protocol in "IMAP", "POP3", "POP2": + service = defaultports[protocol] + if sslmode: + if service not in sslservices: + continue + port = sslservices[service] + else: + port = ianaservices[service] + greetline, address, new_errors = get_greetline(realhost, port, sslmode) + if new_errors: + errors += new_errors + if greetline: + break if greetline: break - if greetline: - break + except socket.gaierror as e: + confirm = """ +Fetchmailconf could not resolve the hostname. +Error was: +"""+str(e) + except OSError as e: + confirm = """ +Fetchmailconf could not probe servers. +Error was: +"""+str(e) confwin = Toplevel() - if greetline is None: + if confirm: + title = "Autoprobe of {} failed".format(realhost) + elif greetline is None: title = "Autoprobe of " + realhost + " failed" confirm = """ Fetchmailconf didn't find any mailservers active. -- cgit v1.2.3