Honor directive parameters after a quoted filename reference#2457
Honor directive parameters after a quoted filename reference#2457FireBurn wants to merge 1 commit into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
rousskov
left a comment
There was a problem hiding this comment.
Thank you for fixing this dangerous bug! Can you tell when this bug was introduced?
Do not worry about PR description formatting if you do not want to fix it -- I will help with that.
Please add yourself to CONTRIBUTORS.
|
Thanks for the review! Pushed an update addressing all of it:
When was this introduced: commit f32cd13 ("Replace cnfig parser PS I've had 3 hours sleep because of the implementation and then this bug |
There was a problem hiding this comment.
I've had 3 hours sleep because of the implementation and then this bug
I am sorry to hear that and can certainly sympathize. We are almost done here -- there is only one problem left (see the new change request)! If you prefer, I would be happy to finish this up myself -- just let me know.
I edited PR title to avoid introducing a custom low-level ConfigParser: prefix/scope.
I adjusted PR description, primarily to remove diff-makes-that-obvious parts and improve formatting. Please feel free to revert my PR description changes or adjust further.
For example, the following ACL did not match `example.com`:
acl foo dstdomain "file-of-domains.txt" example.com
strtokFile() implements the "read directive parameters from a quoted
file" syntax used when configuration_includes_quoted_values is off (the
documented default). Once the named file's lines were exhausted,
strtokFile() returned nullptr, signalling end-of-directive to callers
such as ACLDomainData::parse(). Any tokens following the quoted filename
on the same configuration line (e.g., "example.com" above) were silently
discarded. A parameter file reference and trailing literal parameters
are valid syntax individually; combining them on one line has always
been allowed by the grammar, so the omission was "invisible" to admins.
This bug dates back to 2008 commit f32cd13 ("Replace cnfig parser gotos
with do-while loop."), which replaced a goto that resumed parsing after
the file's last line with an unconditional "return nullptr". Every Squid
release starting with v3.1.0.1 is affected.
Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
rousskov
left a comment
There was a problem hiding this comment.
Thank you for polishing this up! I hope we are done: If automated PR and staging tests succeed, and there are no objections from others, this fix will be merged.
@FireBurn, just FYI: There is no need to squash individual commits (and force-push) because Anubis, our merge bot, squashes automatically when merging a PR. It also uses PR title/description as the merged commit message...
|
|
||
| acl test51 dstdomain example.com example.net . | ||
|
|
||
| acl test61 dstdomain "bad-acl-dstdomain-dupe.domains" after-file.example.com |
There was a problem hiding this comment.
I hope we are done: If automated PR ... tests succeed
They failed. I do not know what exactly causes those failures. The same change appears to work in my local quick-and-dirty tests, but I did not test the latest master (yet).
The missing est letters after configuration context: t in the logged message quoted below are particularly alarming (to me):
2026/07/09 21:44:38| ERROR: Can not open file bad-acl-dstdomain-dupe.domains for reading
configuration context: t-suite/squidconf/bad-acl-dstdomain-dupe.conf(21) acl
There are other similarly malformed messages in that log as well.
I will find the time to investigate this further if you do not.
There was a problem hiding this comment.
I have (the bigger part of) the answer: There is another Squid bug here. I fixed that bug more than a year ago while working on other Squid configuration improvements, but that fix is still in the backlog. It explains why your (correct) changes work in my tests but not in the official Squid Project CI. I will post a dedicated PR to fix that other bug, so that your PR can be merged afterwords, hopefully without changes. Please stand by.
There was a problem hiding this comment.
FYI: I believe the missing letters are probably tes. Likely Squid trying badly to remove a relative path prefix (eg "../").
There was a problem hiding this comment.
There was a problem hiding this comment.
FYI: I believe the missing letters are probably
tes.
As I noted earlier, in the posted sample, the missing letters are est. The same CI log contains other missing letters as well:
configuration context: iguration(8) acl
Likely Squid trying badly to remove a relative path prefix (eg "../").
This is a different bug. I fixed this one in December 2024. That fix is also in the backlog. Hopefully, we will eventually find a way to resolve the long-standing issues that have created (and keep growing!) that backlog, badly hurting the Squid Project, but doing so is outside this PR scope.
There was a problem hiding this comment.
I read your OP. It seems very strange that you think that.
Debug::Extra << "configuration context: " << ConfigParser::CurrentLocation();ConfigParser::CurrentLocation() { return ToSBuf(SourceLocation(cfg_directive, cfg_filename, config_lineno)); }SourceLocation::print(std::ostream &os) { if (fileName) { os << SkipBuildPrefix(fileName); ...SkipBuildPrefix(const char* path) { ... return path + ToSkip; }
Much more likely that ToSkip is somehow N+3 when it should be N instead of that logic removing est from the middle of "test-suite...".
The fix for above bug still being in the backlog would explain why the current code shows it still present.
For example, the following ACL did not match
example.com:strtokFile() implements the "read directive parameters from a quoted
file" syntax used when configuration_includes_quoted_values is off (the
documented default). Once the named file's lines were exhausted,
strtokFile() returned nullptr, signalling end-of-directive to callers
such as ACLDomainData::parse(). Any tokens following the quoted filename
on the same configuration line (e.g., "example.com" above) were silently
discarded. A parameter file reference and trailing literal parameters
are valid syntax individually; combining them on one line has always
been allowed by the grammar, so the omission was "invisible" to admins.
This bug dates back to 2008 commit f32cd13 ("Replace cnfig parser gotos
with do-while loop."), which replaced a goto that resumed parsing after
the file's last line with an unconditional "return nullptr". Every Squid
release starting with v3.1.0.1 is affected.