#46 setup-ds-admin.pl does not like ipv6 only hostnames
Closed: Fixed None Opened 7 years ago by mkosek.

https://bugzilla.redhat.com/show_bug.cgi?id=700695

Description of problem:

I am attempting to setup Directory 389 in a pure ipv6 environment.  I have
added an ldap host (with an AAAA record only) to bind that I will just call
"example.com".  During the execution of the setup script, I get to the stage:

Computer name [xxx.com]: example.com

WARNING: There are problems with the hostname.
Could not find an address for hostname 'example.com'.

It looks to me that the script is only searching for ipv4 hosts, and since I'm
in a pure ipv6 environment nothing is found.  I can ping6 example.com with no
issues, and dig shows everything is working just fine.

Version-Release number of selected component (if applicable):

1.2.8.2

How reproducible:

Have run the script twice, results are the same.  Setup fails at the end when
the host cannot be found.  Have only attempted on one machine, since it seems
pretty clear to me what the problem is.

Steps to Reproduce:
1. Setup machine with ipv6 address only
2. Attempt setup with this machine
3. See bug.

Actual results:

N/A

Expected results:

N/A

Additional info:

We could support IPv6 only environment if the system has Perl 5.14. It's available on FC16 and newer as well as on EL7 for now. Can we reset the milestone of this bug to 1.2.11?

http://www.perl.org/about/whitepapers/perl-ipv6.html
Perl 5.14 ships with a complete set of IPv6-related functions in the Socket module. It provides the AF_INET6 constant, sockaddr_in6 address structure handling functions, and the getaddrinfo and getnameinfo functions. IO::Socket::IP uses these on Perl 5.14, making it an easy install requiring no other modules, nor compiling any XSexternal link code.

koji:
perl-5.14.2-194.fc16 psabata 2012-02-02 15:44:54 complete
perl-5.14.2-210.fc17 pghmcfc 2012-01-10 11:57:22 complete
brew:
perl-5.14.2-190.el7 dmach 2011-11-16 20:19:13 complete

I think it's fine if we wait on this one until we have perl support.
/me wishes we could just write the entire setup framework from scratch in python so we could avoid this and other problems with perl (such as the fact that it's perl)

Fix Description:
Perl functions gethostbyname/gethostbyaddr do not support IPv6
addresses. This patch replaces the obsolete functions with the
ones from Socket::GetAddrInfo.

Fix Description:
Adding IPv6 friendly perl packages to Requires list:
Requires: perl-Socket-GetAddrInfo
Requires: perl-NetAddr-IP

Reviewed by Rich (Thank you!!)

Pushed to master.

$ git merge trac46
Updating d6deb25..f26658c
Fast-forward
ldap/admin/src/scripts/DSUtil.pm.in | 47 ++++++++++++++++++++---------------
1 files changed, 27 insertions(+), 20 deletions(-)

$ git push
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 1.18 KiB, done.
Total 7 (delta 5), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
d6deb25..f26658c master -> master

389-ds-base.spec

Pushed to master.

$ git merge work
Updating 5e3fefb..12a64b8
Fast-forward
389-ds-base.spec | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 617 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://pkgs.fedoraproject.org/389-ds-base.git
5e3fefb..12a64b8 master -> master

Pushed to f17 branch.

$ git push origin f17-local:f17
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 640 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://pkgs.fedoraproject.org/389-ds-base.git
5e3fefb..e07e415 f17-local -> f17

Fix Description:
Socket::GetAddrInfo class is not available on all the supported
platforms. Instead, this patch uses Socket6, which has better
supports.

If perl-Socket (2.000) is available, this change would fulfill the requirement in the cleaner way. But perl-Socket is not available yet on RHEL6. (See also Bug 807390 - Adding perl-Socket (>= 2.000) to RHEL6)

diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil
index 2f3306b..1c5a734 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -58,9 +58,10 @@ require Exporter;

use strict;

-use Socket;
-use Socket::GetAddrInfo qw( :newapi getaddrinfo getnameinfo AI_CANONNAME );
-use NetAddr::IP::Util qw( ipv6_n2x );
+use Socket qw (:addrinfo inet_ntoa unpack_sockaddr_in unpack_sockaddr_in6
+ AF_INET AI_CANONNAME INADDR_ANY
+ PF_INET SO_REUSEADDR SOCK_STREAM SOL_SOCKET);
+use NetAddr::IP::Util qw(ipv6_n2x);

use File::Temp qw(tempfile tempdir);
use File::Basename qw(dirname);

Would it be possible to import the modules conditionally? That is, try to import the required symbols from Socket - if not available, import them from Socket6 if available. That is, something like this:

http://www.perlmonks.org/?node_id=817254

would rather not have to change the code again - would be better to just use/require/import whatever module is available that provides the necessary functionality. And, if necessary, create our own wrapper functions/modules to avoid doing things like this in other parts of the code:

if ($using_socket6) {
# do something with a socket6 function
} else {
# do something else
}

Thanks to Rich for his suggestions and reviewing the proposals (3 times! ;)

Pushed to master.

$ git merge trac46
Updating 0610f9a..8500054
Fast-forward
ldap/admin/src/scripts/DSUtil.pm.in | 107 +++++++++++++++++++++++++++--------
1 files changed, 84 insertions(+), 23 deletions(-)

$ git push
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 1.64 KiB, done.
Total 7 (delta 5), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
0610f9a..8500054 master -> master

originally targeted for 1.2.11.rc1, but actually in the 1.2.11.a1 release

Fix description:
1) When Socket6 is used, if the same FQDN appears twice in
/etc/hosts (e.g., localhost.localdomain for 127.0.0.1 and
::1), the result from getaddrinfo was not correctly shifted.
2) perl require takes package name. In the commit 8500054-
2c5b9b0027f944fcd33633c8db46, a tag ':addrinfo" was mistakenly
passed and it was ignored. This patch checks the version of
Socket. If it is greater than 2.000, getaddrinfo in the
Socket module is used. Otherwise, it falls back to Socket6.

Reviewed by Rich (Thank you!!)

Pushed to master.

$ git push
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 1.16 KiB, done.
Total 7 (delta 5), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
396c932..7ef6558 master -> master

Added initial screened field value.

Metadata Update from @nhosoi:
- Issue assigned to nhosoi
- Issue set to the milestone: 1.2.11.a1

2 years ago

Login to comment on this ticket.

Metadata