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

Include statements are processed even when commented out. #9

Open
manuthambi opened this issue Feb 8, 2022 · 5 comments · May be fixed by #10
Open

Include statements are processed even when commented out. #9

manuthambi opened this issue Feb 8, 2022 · 5 comments · May be fixed by #10

Comments

@manuthambi
Copy link

Include statements in /etc/bind/named.conf are processed even when commented out using //.

@oasys
Copy link
Owner

oasys commented Feb 8, 2022

Thanks for the report.

Can you provide a minimal test case that shows this behavior? I took a quick look at the code and the $INCLUDE match regex is anchored to the beginning of the line, so I must be misunderstanding your report (or the code).

@manuthambi
Copy link
Author

Thanks for looking into it!

I am not super familiar with Perl, but looks like the script is processing .conf files here without stripping out comments.

The $INCLUDE processing is in reverse maps?

@manuthambi
Copy link
Author

If you still need a test case, I'll try to build one later today.

@manuthambi
Copy link
Author

Here is minimal test case: named.conf

# include "does-not-exist.conf"

When running: mkrdns -debug ./named.conf produces:

Debugging turned on.
Version     = 3.3
C. Revision = $Id: mkrdns,v 1.59 2002/12/05 21:19:28 felicity Stab $
Help        = 0
Quiet Mode  = 0
Root Dir    = /
Hash Func   = 32-bit checksum

(debug) Include statement (# include "does-not-exist.conf") found.
(warn) Include found before named directory was specified!  Using ".".
(debug) Path changed from "./does-not-exist.conf" to "/does-not-exist.conf".
(debug) Including file /does-not-exist.conf.
(fatal) Can't open /does-not-exist.conf:No such file or directory at ./mkrdns/mkrdns line 201, <CONF> line 1.

@elyograg
Copy link

elyograg commented Sep 18, 2022

I got around this by mangling the commented include line in named.conf:

include "/etc/bind/named.conf.options";
// commented statement below mangled to let mkrdns work
// inXclude "/etc/bind/named.conf.default-zones";
include "/etc/bind/named.conf.local";

Everything was fine before I amended my config to have an external view and an internal view, which is when I commented that line and moved it to the internal view. The script really should remove comments before it processes includes, and then remove comments on the included file before processing any includes THAT file might contain. Getting that recursive nature handled might be difficult, depending on how the logic actually works ... my mangling solution is probably easier!

The best solution would be to use or write a processor that truly understands EVERYTHING bind config syntax can do, which would know to completely ignore anything that is commented with any of the available commenting syntax. I have no idea whether any such animal exists already or not.

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

Successfully merging a pull request may close this issue.

3 participants