bug in web interface for bind package

  • On the webif, if I add custom options to the server like:

    recursion no;
    allow-transfer { none; };
    bindkeys-file "/etc/namedb/bind.keys";

    look at the generated named.conf

    recursion no;^M
    allow-transfer { none; };^M
    bindkeys-file "/etc/namedb/bind.keys";

    There will be ^M after each line except for the last. Removed all options, saved, insert them again. Same. Bind still works, but it would be cleaner to fix it.


  • LAYER 8

    @aligator638 said in bug in web interface for bind package:


    ^M should be the way vim displays 0xD
    0xD is the carriage return character
    0xD=13 and M it's the 13th letter in the English alphabet

    the bind package is ok, i think it's something on your side

  • Yes bind is still working, but it is still a problem laying with the web interface, if I add data in other custom fields like in views, I also get the ^M. This is not standard format for a bind file which should just palin ASCII with control characters.

  • Hello!

    In the latest bind gui code there is this:

    $bind_conf .= preg_replace("/^/m", "\t", $custom_options);

    Are you on the latest?

    "Mama says regex is the devil", but I think that should get rid of the ^M's...?


  • @serbus Hello John, not yet I am on 2.4.5p1, I can safely wait.

  • LAYER 8 Global Moderator

    That code has been in the bind package since 2015..Atleast

    I just put some stuff in custom, and then looked at the named.conf file - and there are no ^m in there..

    Running 2.4.5p1 with bind package 9.14_8

  • Usually, the "^M" comes from the Windows (or DOS) line ending sequence of Carriage Return/Line Feed (or 0x0d 0x0a in hex). Unix land hates that. The most likely way to get that in pfSense is by directly pasting something into the text box from the clipboard in Windows. The text will not be converted to Unix line endings automatically when pasted in. Looks like that regex in the package tries, but if the lowercase "M" is correctly written in the post that is incorrect. It needs to be searching for the uppercase "M".

    I get around this in one of two ways, and both are extra work --

    1. Paste in one line at a time but be very sure you do not grab the line ending character. So highlight up to the very last character you see on the Windows screen and then stop. Don't grab multiple lines, and don't grab that little "space" that may highlight at the end of a text line in some Windows text editors.

    2. Create your file of text in Windows, then use WinSCP or something similar to copy the file over to pfSense. WinSCP has an option to transfer as "text", and it will fix the line endings for the destination system when that option is used. So it will strip the 0x0d0x0a character sequence and leave the proper 0x0a value on the FreeBSD side. However, this option is not the default! You must manually choose it. You can set it as the default if you wish. Of course once you get the physical file over on pfSense, you still have to manually get the content into the text box on the GUI tab.

  • This post is deleted!

  • @bmeeks

    named.conf is rewritten from the xml file every time you save, so it should not be edited manually.

  • @johnpoz very odd, I removed the entries, checked named.conf was ok. Retyped everything, and my ^M are back.

  • @aligator638 said in bug in web interface for bind package:

    @johnpoz very odd, I removed the entries, checked named.conf was ok. Retyped everything, and my ^M are back.

    In my previous post, I was talking about typing in any text input box in the pfSense GUI, not editing a file directly on the system. So if you are "pasting" something into a text box in the GUI, and that pasted text contains Windows or DOS line ending sequences, this ^M problem will show up.

    So when you say "typed", do you mean only typing from the keyboard, or are you perhaps pasting in something from elsewhere into the GUI text box? I'm not a user of bind on pfSense, but I assume it has a place for the user to manually enter certain things into the configuration by typing or pasting text into one or more text boxes or text input areas in the GUI screens. If Windows or DOS line endings get copied into those GUI text boxes, they will get saved into the XML and then subsequently written out to the named.conf or any other file generated at runtime by the pfSense system.

    How do I know this can happen? Because I fought it for some time in the code I wrote for the Snort and Suricata packages.

  • @bmeeks sorry, I re-TYPED everything, not cut and paste. And as explained in previous posts, this happens in all the custom fields in this package.

  • Checked the main xml file and decoded the saved text (it is base64)



    recursion no;
    allow-transfer { none; };
    bindkeys-file "/etc/named/bind.keys";

    No ^M characters in the xml file. So these characters are added when the data is saved into named.conf

  • Hello!

    What are you using to view the named.conf after adding custom options with the web gui? e.g. "ssh in with putty on windows and cat the named.conf" , or "Diagnostics -> Edit File in the gui", etc...


  • @serbus very interesting comment John, in vi (ssh), I can see the ^M, but not with the GUI editor, just to check I selected into the editor, and copied that data back into vi again, no ^M

Log in to reply