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

zone2sql failed when it reached an $include statement ending in ; #14382

Open
2 tasks done
ITJamie opened this issue Jun 25, 2024 · 4 comments · May be fixed by #14414
Open
2 tasks done

zone2sql failed when it reached an $include statement ending in ; #14382

ITJamie opened this issue Jun 25, 2024 · 4 comments · May be fixed by #14414
Labels
Milestone

Comments

@ITJamie
Copy link

ITJamie commented Jun 25, 2024

  • Program: Authoritive - zone2sql command
  • Issue type: Bug report

Short description

when converting a bind config we found failures to open files. it turns out it was attempting to open files with a semicolon at the end of the filename

Environment

  • Operating system: debian 11 - powerdns docker container
  • Software version: 4.9.2
  • Software source: docker hub

Steps to reproduce

create some bind config files.
create a file that includes another file:
file1.conf

3.2.1.IN-ADDR.ARPA.	SOA	ns1.1.com.	support.1.com. (
			1274729723
			14400
			20000
			3600000
			3600)

@	NS	ns1.1.com.
@	NS	ns2.1.com.

$INCLUDE file2;

file2:

4.3.2.1.IN-ADDR.ARPA.	IN	PTR foo.bar.com. ; rr_id = 1234

attempt to export:

zone2sql --named-conf=file1.conf --gmysql --transactions=yes --on-error-resume-next=no --verbose

Expected behaviour

file is parsed correctly and included

Actual behaviour

died because of STL error: Unable to open file '/opt/named/file2;': No such file or directory: No such file or directory

Other information

include seems to be handled correctly IF the include path has quotes around it:
$INCLUDE "reverse_zones/1/2/file2"; but is not handled correctly if there is no quotes. $INCLUDE reverse_zones/1/2/file2;
when there are no quotes it includes the semicolon from the end of the string

@rgacogne rgacogne added the auth label Jun 25, 2024
@hlindqvist
Copy link
Contributor

Just for perspective, there is no need to have a ; at the end, $INCLUDE does not in any way demand a trailing ;.

However ; is the comment character for the master file format, so a ; and anything after it on that line should be ignored, provided the ; was not escaped (\;) or part of a quoted string ("foo;bar").
I assume there must be something that gets tripped up in the parser regarding where the string value ends in your example such that it doesn't recognize that the ; starts a comment.

(The observed behavior also raises the question of whether the same kind of misparsing of comments can occur in other contexts as well, or if maybe a whole different parser is used for these special directives starting with $)

@ITJamie
Copy link
Author

ITJamie commented Jun 25, 2024

sadly the existing system were looking to convert has many of these includes in this style and it writes the files back out often so even if we added a space or put quotes around the existing string it will get replaced not long after. ( this just added one more nail in the coffin of why its being replaced 😆 )

@hlindqvist
Copy link
Contributor

sadly the existing system were looking to convert has many of these includes in this style and it writes the files back out often so even if we added a space or put quotes around the existing string it will get replaced not long after. ( this just added one more nail in the coffin of why its being replaced 😆 )

Fair enough. it might well be too much of a pain to improve the thing that generates those entries, especially if you are migrating away from that system anyway.

But regarding adding spaces and whatnot, if there really is no actual comment text (like in your example), then it seems more straightforward to eliminate the ; entirely. Because while $INCLUDE file2; I like this because it avoids duplicating the records shared between these 5 zones (or whatever) could provide some kind of insight to the reader, just $INCLUDE file2; really adds nothing of value over the more normal looking $INCLUDE file2.

@ITJamie
Copy link
Author

ITJamie commented Jun 25, 2024

Correct in my case theres no comment text. Its the last character on that line

@Habbie Habbie added this to the auth-5 milestone Jun 27, 2024
@ITJamie ITJamie linked a pull request Jul 3, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants