Friday, May 1, 2020

[389-commits] [389-ds-base] branch 389-ds-base-1.4.3 updated: Issue 51064 - Unable to install server where IPv6 is disabled

This is an automated email from the git hooks/post-receive script.

mreynolds pushed a commit to branch 389-ds-base-1.4.3
in repository 389-ds-base.

The following commit(s) were added to refs/heads/389-ds-base-1.4.3 by this push:
new 6cc0867 Issue 51064 - Unable to install server where IPv6 is disabled
6cc0867 is described below

commit 6cc08673b5b35a8f90517ea49a5823fd4374f96f
Author: Mark Reynolds <mreynolds@redhat.com>
AuthorDate: Thu Apr 30 14:02:13 2020 -0400

Issue 51064 - Unable to install server where IPv6 is disabled

Description: When checking if a port is available, first attempt to
create a socket using AF_INET6, if that fails then use
AF_INET

relates: https://pagure.io/389-ds-base/issue/51064

Reviewed by: firstyear(Thanks!)
---
src/lib389/lib389/utils.py | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py
index 6afbfe6..9a9260b 100644
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -1143,11 +1143,28 @@ def getDateTime():


def socket_check_open(host, port):
- with closing(socket.socket(socket.AF_INET6, socket.SOCK_STREAM)) as sock:
- if sock.connect_ex((host, port)) == 0:
- return True
- else:
- return False
+ """
+ Check if a socket can be opened. Need to handle cases where IPv6 is completely
+ disabled.
+ """
+ try:
+ # Trying IPv6 first ...
+ family = socket.AF_INET6
+ with closing(socket.socket(family, socket.SOCK_STREAM)) as sock:
+ if sock.connect_ex((host, port)) == 0:
+ return True
+ else:
+ return False
+ except OSError:
+ # No IPv6, adjust hostname, and try IPv4 ...
+ family = socket.AF_INET
+ if host == "::1":
+ host = "127.0.0.1"
+ with closing(socket.socket(family, socket.SOCK_STREAM)) as sock:
+ if sock.connect_ex((host, port)) == 0:
+ return True
+ else:
+ return False


def ensure_bytes(val):

--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/389-commits@lists.fedoraproject.org

No comments:

Post a Comment