diff options
| author | Christian Breunig <christian@breunig.cc> | 2023-06-20 19:43:48 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-20 19:43:48 +0200 | 
| commit | 3f197566f957cb0e354a474bccee0aefd62b33be (patch) | |
| tree | b0add832fa259ff7becde37626df901741af9911 /python | |
| parent | 33016220be8e156720a3692ca309753c4e84cd2a (diff) | |
| parent | 0439ade98cd8a0301351dfcdfe3e3f4dc7040473 (diff) | |
| download | vyos-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
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/util.py | 10 | 
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 | 
