summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-20 19:43:48 +0200
committerGitHub <noreply@github.com>2023-06-20 19:43:48 +0200
commit3f197566f957cb0e354a474bccee0aefd62b33be (patch)
treeb0add832fa259ff7becde37626df901741af9911
parent33016220be8e156720a3692ca309753c4e84cd2a (diff)
parent0439ade98cd8a0301351dfcdfe3e3f4dc7040473 (diff)
downloadvyos-1x-3f197566f957cb0e354a474bccee0aefd62b33be.tar.gz
vyos-1x-3f197566f957cb0e354a474bccee0aefd62b33be.zip
Merge pull request #2050 from jestabro/check-port-availability
vyos.util: T5300: check_port_availability should return False only on EADDRINUSE
-rw-r--r--python/vyos/util.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 61ce59324..e62f9d5cf 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -1063,9 +1063,13 @@ def check_port_availability(ipaddress, port, protocol):
if protocol == 'udp':
server = UDPServer((ipaddress, port), None, bind_and_activate=True)
server.server_close()
- return True
- except:
- return False
+ except Exception as e:
+ # errno.h:
+ #define EADDRINUSE 98 /* Address already in use */
+ if e.errno == 98:
+ return False
+
+ return True
def install_into_config(conf, config_paths, override_prompt=True):
# Allows op-mode scripts to install values if called from an active config session