diff options
Diffstat (limited to 'ipaserver/install')
-rw-r--r-- | ipaserver/install/dsinstance.py | 11 | ||||
-rw-r--r-- | ipaserver/install/installutils.py | 30 |
2 files changed, 9 insertions, 32 deletions
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index 9c137af0..25c449a6 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -119,8 +119,15 @@ def get_ds_instances(): return instances def check_ports(): - ds_unsecure = installutils.port_available(389) - ds_secure = installutils.port_available(636) + """ + Check of Directory server ports are open. + + Returns a tuple with two booleans, one for unsecure port 389 and one for + secure port 636. True means that the port is free, False means that the + port is taken. + """ + ds_unsecure = not ipautil.host_port_open(None, 389) + ds_secure = not ipautil.host_port_open(None, 636) return (ds_unsecure, ds_secure) def is_ds_running(server_id=''): diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index b65958ed..903e8f18 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -256,36 +256,6 @@ def read_dns_forwarders(): return addrs -def port_available(port): - """Try to bind to a port on the wildcard host - Return 1 if the port is available - Return 0 if the port is in use - """ - rv = 1 - - try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - fcntl.fcntl(s, fcntl.F_SETFD, fcntl.FD_CLOEXEC) - s.bind(('', port)) - s.close() - except socket.error, e: - if e[0] == errno.EADDRINUSE: - rv = 0 - - if rv: - try: - s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - fcntl.fcntl(s, fcntl.F_SETFD, fcntl.FD_CLOEXEC) - s.bind(('', port)) - s.close() - except socket.error, e: - if e[0] == errno.EADDRINUSE: - rv = 0 - - return rv - def get_password(prompt): if os.isatty(sys.stdin.fileno()): return getpass.getpass(prompt) |