From af6b16cc352b30b45e00c8ca071dc9688b2313b3 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 10 Apr 2021 09:38:47 +0200 Subject: [PATCH] bundles/pppd: fix KeyError in restart-pppoe-if-no-public-ip --- bundles/pppd/files/restart-pppoe-if-no-public-ip | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/pppd/files/restart-pppoe-if-no-public-ip b/bundles/pppd/files/restart-pppoe-if-no-public-ip index fcd1864..65893e6 100644 --- a/bundles/pppd/files/restart-pppoe-if-no-public-ip +++ b/bundles/pppd/files/restart-pppoe-if-no-public-ip @@ -26,13 +26,18 @@ for i in netifaces.interfaces(): system_has_public_ip = False for iface in ifaces: for type in [netifaces.AF_INET, netifaces.AF_INET6]: - for ip in netifaces.ifaddresses(iface)[type]: + try: + ips = netifaces.ifaddresses(iface)[type] + except KeyError: + continue + + for ip in ips try: addr = ip_address(ip['addr']) if not addr.is_private and not addr.is_loopback: system_has_public_ip = True - except: + except Exception: # Apparently not an ip pass