Reply
New Member
Posts: 9
Registered: ‎04-08-2014
Kudos: 11

Bug in vyatta_update_resolv.pl

[ Edited ]

After getting some weird DNS resolution errors (ie. non-existing hostnames resolving to weird IP addresses), I found out a small but very nasty bug in the Vyatta file that generates the resolv.conf file.

nameserver      10.0.0.1
nameserver      10.1.0.1
nameserver      10.1.0.2
search          sub.example.com example.com              #line generated by /opt/vyatta/sbin/vyatta_update_resolv.pl

 

Essentially, at the end of the last line (search), Vyatta adds a comment. The ".by" TLD exists and is giving me results in some cases.

In a real-world example, using "search example.pt" (with the comment after):

  • www.example.pt - resolves to the correct result;
  • bogus.example.pt - not finding the hostname, it tries with the ".by" domain and finds "bogus.example.pt.by", which is a real hostname and resolves to 217.107.219.193 (srv73-h-st.jino.ru).

We are not using the EdgeRouter for DNS resolution so in our case this is not extremely serious. but could be (imagine someone registering google.com.by or something like that).

The resolv.conf manpage states that a comment is a line which first character is a "#" or a ";".

Simple fix:

--- /opt/vyatta/sbin/vyatta_update_resolv.pl.old
+++ /opt/vyatta/sbin/vyatta_update_resolv.pl
@@ -86,12 +86,12 @@

 my $search = '';
 if (length($doms) > 0) {
-       $search = "search\t\t$doms\t\t#line generated by $0\n";
+       $search = "#line generated by $0:\nsearch\t\t$doms\n";
 }

 my $domain = '';
 if ($domain_name && length($domain_name) > 0) {
-       $domain = "domain\t\t$domain_name\t\t#line generated by $0\n";
+       $domain = "#line generated by $0:\ndomain\t\t$domain_name\n";
 }

 # update /etc/resolv.conf for name-servers received from dhcp client, only done when dhclient-script calls this script
@@ -209,6 +209,8 @@
                if (length($domain) > 0) {
                        print $r $domain;
                }
+       } elsif ($line =~ /^#line generated by $0:\n/) {
+               # just remove comment line
        } else {
                print $r $line;
        }

 

Regards.

Previous Employee
Posts: 13,551
Registered: ‎06-10-2011
Kudos: 5430
Solutions: 1656
Contributions: 2

Re: Bug in vyatta_update_resolv.pl

Very good catch! The original author probably didn't look at the manpage carefully! Icon Smile

We'll need to review whether that "comment marker" is used anywhere else in the system and fix this issue. Thanks very much!

Highlighted
New Member
Posts: 9
Registered: ‎04-08-2014
Kudos: 11

Re: Bug in vyatta_update_resolv.pl

This issue is still not fixed in 1.6.0...

Previous Employee
Posts: 13,551
Registered: ‎06-10-2011
Kudos: 5430
Solutions: 1656
Contributions: 2

Re: Bug in vyatta_update_resolv.pl

Yeah looks like the marker is no longer used elsewhere in the system so I've applied the changes to fix the comment (will be in the next alpha/beta release). Thanks for your contributons!

Reply