diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2020-01-31 01:06:50 +0100 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2020-01-31 01:06:50 +0100 |
commit | 4e2e62572c51455c199485496c3fb6af5e833915 (patch) | |
tree | 7829697bea02b39efc21ac9ad190cbc37786fa3b | |
parent | b9e7dec64b6edf7931b7826f0514654eb97bbac6 (diff) | |
download | fetchmail-4e2e62572c51455c199485496c3fb6af5e833915.tar.gz fetchmail-4e2e62572c51455c199485496c3fb6af5e833915.tar.bz2 fetchmail-4e2e62572c51455c199485496c3fb6af5e833915.zip |
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.
-rwxr-xr-x | fetchmailconf.py | 44 |
1 files 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. |