Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of forwarders addresses with custom port. #6269

Closed
wants to merge 9 commits into from

Conversation

rjeffman
Copy link
Member

When setting a DNS forwarder, IPA allows the use of a custom port using
the format ' port ', and this configuration is validated with
dnspython to ensure the forwarder is resolvable.

Starting with dnspython 2.2.0 the Resolver.nameservers property, used
to resolve the forwarders IP address, validates the IP address when
the value is assigned to property, and as the forwarder format is not
an IP address, it fails and a ValueError exception is raised.

Modifying the way forwarders are handled when validating them prevents
the exception to be raised, and test for the correct port.

Fixes: https://pagure.io/freeipa/issue/9158

@rjeffman rjeffman added the ipa-4-9 Mark for backport to ipa 4.9 label May 19, 2022
ipalib/util.py Outdated Show resolved Hide resolved
@rjeffman rjeffman force-pushed the dns-fix-f36-dnspython-2-2 branch 6 times, most recently from 13d536b to fc9031d Compare May 20, 2022 23:13
Related to: https://pagure.io/freeipa/issue/9158

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
@rjeffman rjeffman force-pushed the dns-fix-f36-dnspython-2-2 branch 3 times, most recently from a09b9f5 to 9756730 Compare May 24, 2022 14:18
Related to: https://pagure.io/freeipa/issue/9158

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
Related to: https://pagure.io/freeipa/issue/9158

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
When setting a DNS forwarder, IPA allows the use of a custom port using
the format '<ip> port <port>', and this configuration is validated with
dnspython to ensure the forwarder is resolvable.

Starting with dnspython 2.2.0 the Resolver.nameservers property, used
to resolve the forwarders IP address, validates the IP address when
the value is assigned to property, and as the forwarder format is not
an IP address, it fails and a ValueError exception is raised.

Modifying the way forwarders are handled when validating them prevents
the exception to be raised, and test for the correct port.

Fixes: https://pagure.io/freeipa/issue/9158

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
@rjeffman rjeffman added the re-run Trigger a new run of PR-CI label May 25, 2022
@freeipa-pr-ci freeipa-pr-ci removed the re-run Trigger a new run of PR-CI label May 25, 2022
@rjeffman rjeffman force-pushed the dns-fix-f36-dnspython-2-2 branch 2 times, most recently from ee14537 to 29119ba Compare May 29, 2022 19:14
# case, split the string and add the IP part to res.nameservers,
# and the ip:port pair to res.nameserver_ports dict.
nameserver_ip = re.sub(r'\s+', ' ', nameserver_ip.strip())
nameserver_ip, *port = nameserver_ip.split(" port ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ease of testing I wonder if this should be put into a separate function. Then you could use straight pytest to pass in a variety of values with ease.

Copy link
Member

@t-woerner t-woerner Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to fix this in DNSResolver?
Here is an example: master...t-woerner:freeipa:fix_dns_resolver_for_nameservers_with_ports

@t-woerner
Copy link
Member

bind is allowing to specify the port for a forwarders with "port " additionally to the IP addresses. But dnspython that is used to verify the list of forwarders (nameservers) is only allowing to have IP addresses in the list. With dnspython version 2.20 there is a new validator in dns.resolver.BaseResolver that ensures this.

@rjeffman
Copy link
Member Author

Dropping this PR in favor of #6408

@rjeffman rjeffman closed this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ipa-4-9 Mark for backport to ipa 4.9
Projects
None yet
4 participants