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

Reverse DNS records are broken #127

Closed
siberian1967 opened this issue Feb 6, 2014 · 7 comments
Closed

Reverse DNS records are broken #127

siberian1967 opened this issue Feb 6, 2014 · 7 comments
Labels
bug Something isn't working critical Critical issue hasPR Has related pull request
Milestone

Comments

@siberian1967
Copy link

Reverse delegated zone example: 171.110.38.in-addr.arpa.

Records are PTR like this:

2.171.110.38.in-addr.arpa
and
2.171.110.38.in-addr.arpa.

When you 'Commit' changes dns.inc.php munges them

    if (!(preg_match("/$zone$/i", $name))) {
        if (isset($name) && $name != "") {
            $name = $name . "." . $zone;
        } else {
            $name = $zone;
        }
    }

What this does is change the above examples to:

2.171.110.38.in-addr.arpa.171.110.38.in-addr.arpa (it added the name)
and
2.171.110.38.in-addr.arpa (It stripped the period)

Change nothing and hit commit again and they become
2.171.110.38.in-addr.arpa.171.110.38.in-addr.arpa.171.110.38.in-addr.arpa (it added the name again)
and
2.171.110.38.in-addr.arpa.171.110.38.in-addr.arpa (It added the name)

And so on and so forth forever.

A quick fix for this is to change the above codeblock to ignore this munging if its an in-addr.arpa record.

Before I submitted a PR for this I wanted to me sure this was not intentional and that I was not missing a bigger picture.

Tx (this broke our network something fierce today, 2000 upset customers. sigh.).

@siberian1967
Copy link
Author

Oh sorry, my change would look like this

if (!(preg_match("/in-addr.arpa/i", $zone)) && !(preg_match("/$zone$/i", $name))) {

in dns.inc.php: validate_input

Tested and it works as expected but I want to make sure its desirable.

@siberian1967 siberian1967 assigned ghost Feb 26, 2014
@ghost ghost added the duplicate label Mar 1, 2014
@ghost ghost added this to the v2.1.7 milestone Mar 1, 2014
@ghost ghost added defect and removed duplicate labels Apr 4, 2014
@ghost
Copy link

ghost commented Apr 4, 2014

I have seen this issue before, but can't reproduce it with the latest code. Also it's not clear how you was able to add 2.171.110.38.in-addr.arpa and 2.171.110.38.in-addr.arpa. records to 171.110.38.in-addr.arpa zone. Maybe you can provide detailed steps?

@ghost ghost added defect and removed defect labels Apr 4, 2014
@ghost ghost modified the milestones: v2.1.8, v2.1.7 Apr 5, 2014
@KTamas
Copy link

KTamas commented Jun 3, 2014

I ran into this recently, really nasty when you run a production system with poweradmin...

We have partial rdns zones, and the / in them messes with the preg_match

like

$zone = "224/27.194.28.217.in-addr.arpa";
$name = "176.224/27.194.28.217.in-addr.arpa";
echo preg_match("/$zone$/i", $name);

preg_match will fail.

The fix above works.

@ghost ghost modified the milestones: v2.1.7, v2.1.8 Jun 3, 2014
@ghost ghost added defect and removed waiting labels Jun 3, 2014
@ghost ghost added the In development label Jun 10, 2014
@ghost
Copy link

ghost commented Jun 10, 2014

@siberian1967: how you was able to add reverse zone with dot at the end from Poweradmin?

@ghost ghost added this to the v2.1.8 milestone Jun 10, 2014
@ghost ghost removed this from the v2.1.7 milestone Jun 10, 2014
@ghost ghost removed the In development label Jun 10, 2014
@whysyn
Copy link

whysyn commented Aug 18, 2014

I ran into this same problem, still happens even in a fresh clone from git. Above suggested solution seems to completely stop it from appending the domain name when adding or updating a record in a sub-delegated reverse zone.

The regex delimiter just needs to be changed to something other than "/" so it doesn't conflict with any "/"s in the strings.

This did the trick for me and passed internal QA:

--- dns.inc.php.orig    2014-08-18 15:22:16.492241681 -0400
+++ dns.inc.php 2014-08-18 15:21:22.716239636 -0400
@@ -46,7 +46,7 @@

     $zone = get_zone_name_from_id($zid);    // TODO check for return

-    if (!(preg_match("/$zone$/i", $name))) {
+    if (!(preg_match("!$zone$!i", $name))) {
         if (isset($name) && $name != "") {
             $name = $name . "." . $zone;
         } else {

@stbuehler
Copy link
Contributor

just don't do suffix string checks (i guess that is what is supposed to do, right?) with preg hacks; see http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php for some "real" solutions.

@SebTM
Copy link
Contributor

SebTM commented Mar 9, 2016

Merged #247 so can be closed

@SebTM SebTM closed this as completed Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical Critical issue hasPR Has related pull request
Projects
None yet
Development

No branches or pull requests

5 participants