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

Wrong quoting for local-data TXT records #196

Closed
countsudoku opened this issue Apr 23, 2019 · 5 comments
Closed

Wrong quoting for local-data TXT records #196

countsudoku opened this issue Apr 23, 2019 · 5 comments

Comments

@countsudoku
Copy link

Hi,

There is a problem with the qouting in the unbound.conf file for TXT records in the local-data field. Since TXT records can contain whitespaces double quotes are needed around the rdata part of the local-data set. Hence the local-data entry has to be single quoted. This is explicitly described in the unbound.conf man page:

For record types such as TXT, use single quotes, as in
local-data: 'example. TXT "text"'.

I would suggest to use single quotes for all local-data entries. This is not explicitly allowed in the unbound.conf manual, but it works on my unbound installation flawless.

Kind regards
Count Sudoku

@countsudoku
Copy link
Author

Sorry, I was wrong! The quoting can be set by the caller for arrays.

@zachfi
Copy link
Contributor

zachfi commented Apr 23, 2019

Not a worry, glad you sorted it out.

@FredericLespez
Copy link
Contributor

I stumbled on the same problem and I don't understand what you were meaning by:

The quoting can be set by the caller for arrays.

As far as I can see, the double quotes are hardcoded in the erb template:

local-data: "<%= rr %>"

So how do you handle TXT records containing double quotes and spaces (like DKIM records) ?

Thanks in advance for your help.

@countsudoku
Copy link
Author

countsudoku commented Jun 29, 2020

My comment above

Sorry, I was wrong! The quoting can be set by the caller for arrays.

was for the local-data part in the templates/unbound.conf.erb:

<%= print_config('local-data', @local_data) -%>

If you hand over something like this:

$local_data = [
    "'mail._domainkey.example.com 14400 IN TXT \"v=DKIM1;h=sha256;k=rsa;\"\"p=DKIM_KEY_PART_1\"\"DKIM_KEY_PART_2\"'"
]

to the unbound class:

class { '::unbound':
    …,
    local_data => $local_data,
    …,
}

you will get, what you want.

For the quoting in templates/local_zone.erb you are absolutely right. So my comment above was right by accident:

I would suggest to use single quotes for all local-data entries.

But I would suggest to do this on all local-data config locations

@FredericLespez
Copy link
Contributor

Thanks a lot for your answer. I identified two ways to insert local-data (local_zone and record) but I missed the third one :-)
May be I will propose a pull request to automatically single quote TXT records and split them into pieces of 255 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants