diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-07-03 16:49:10 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-07-13 14:25:18 +0200 |
commit | 4879c68d68634715b9d08a08a4c7be882634409f (patch) | |
tree | f64ca647665df5b40fb5501735d7bb5a9776786c /ipaserver/install/installutils.py | |
parent | 5c54dd5b03681428040af51ef3e05c10bec91d3f (diff) | |
download | freeipa-4879c68d68634715b9d08a08a4c7be882634409f.tar.gz freeipa-4879c68d68634715b9d08a08a4c7be882634409f.tar.xz freeipa-4879c68d68634715b9d08a08a4c7be882634409f.zip |
Improve address family handling in sockets
Many functions use low-level socket interface for connection or
various checks. However, most of the time we don't respect
automatic address family detection but rather try to force our
values. This may cause either redundat connection tries when an
address family is disabled on system tries or even crashes
when socket exceptions are not properly caught.
Instead of forcing address families to socket, rather use
getaddrinfo interface to automatically retrieve a list of all
relevant address families and other connection settings when
connecting to remote/local machine or binding to a local port.
Now, we will also fill correctly all connection parameters like
flowinfo and scopeid for IPv6 connections which will for example
prevent issues with scoped IPv6 addresses.
bind_port_responder function was changed to at first try to bind
to IPv6 wildcard address before IPv4 as IPv6 socket is able to
accept both IPv4 and IPv6 connections (unlike IPv4 socket).
nsslib connection was refactored to use nss.io.AddrInfo class to
get all the available connections. Socket is now not created by
default in NSSConnection class initializer, but rather when the
actual connection is being made, becase we do not an address family
where connection is successful.
https://fedorahosted.org/freeipa/ticket/2913
https://fedorahosted.org/freeipa/ticket/2695
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r-- | ipaserver/install/installutils.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index b65958eda..903e8f185 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) |