In hosts.cgi it is possible to define host names containg spaces. This is not allowed by RFC 1132. And thus unbound doesn't like it. hosts.cgi checks the validity of the name with the function validhostname ( located in /var/ipfire/general-functions.pl ). The error can be corrected by replacement of if ($hostname !~ /^[a-zA-Z0-9-\s]*$/) { return 0;} # First character can only be a letter or a digit if (substr ($hostname, 0, 1) !~ /^[a-zA-Z0-9]*$/) { return 0;} # Last character can only be a letter or a digit if (substr ($hostname, -1, 1) !~ /^[a-zA-Z0-9]*$/) { return 0;} with # First and last character can only be letter or decimal digit # else letter, decimal digits and hyphen are allowed if ($hostname != /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/) { return 0; } This modification should be applied with other possible modifications to the general-functions.pl file.
The lines should read # First and last character can only be letter or decimal digit # else letter, decimal digits and hyphen are allowed if ($hostname !~ /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/) { return 0; } Sorry, for posting too fast. (: In testing this modification, I had to restart unbound manually ( after clean-up of my host definitions ). Maybe there is another problem also.
Hello Bernhard, could you please put this in a patch and submit it to the mailing list? I think the solution looks good. Best, -Michael
Hi Bernhard, Do you still plan to provide a patch for this fix for spaces in hostnames? Looking through general-functions.pl it might be worth it, for consistency, to also do the same check in function validfqdn as the same check is carried out for the hostname portion of the fqdn. Regards, Adolf.
I will pick this up and submit Bernhard's proposal as a patch to the mailing list. If I am stepping on any toes then please just unassign me from this bug.
From my side this is ok. Sorry, forgot to do it myself. But if I remember right, at the time I opened this ticket there were several activities in cleaning up and correcting general-functions.pl.
Fix provided by Bernhard Bitsch converted into patch. Patch implemented in testbed system and confirmed working. Spaces in hostnames result in an error message for invalid hostname. https://patchwork.ipfire.org/patch/3774/
*** Bug 12401 has been marked as a duplicate of this bug. ***
After further testing I realised that the regex would fail if the hostname had less than two characters whereas a hostname can go down to one character according to the rfc definitions. So I had to update the patch to fix that After further thinking and searching I also realised that the validfqdn subroutine also needed to be updated to be consistent with the validhostname and validdomainname subroutines. So I also updated that in the patch. I then tested the patch in my testbed system against IPFire pages using hostnames, domain names and FQDN's. The patch worked for all. Also tested with single characters in the hostname and domain name and up to 63 characters in one of the octets. I also confirmed that having a zero octet (ie ..) in the domain name also was flagged as being invalid. New patch submitted to patchwork and the development list:- https://patchwork.ipfire.org/patch/3779/
https://git.ipfire.org/?p=ipfire-2.x.git;a=commit;h=5b4e33bc3b754dd14ecc279bc421ec232a489507
https://blog.ipfire.org/post/ipfire-2-25-core-update-154-available-for-testing
fix patch has been released with Core Update 154