-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix addKey to handle substrings of existing keys #5211
Conversation
I added a pretty heft comment to the addKey function, to describe the situation. Depending on project expectations, that comment might need trimming, or even complete removal. Such a decision is better in the hands of more experienced project contributors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. This clearly an issue which should be fixed.
Maybe it's easier just to add the anchor at the end of the line as well?
Why did you close the PR? I think the long comment can go now and please squash all your commits down. I think afterwards it's ready to go... |
Because I am an inexperienced idiot? How do I get it open again? |
Sorry, I'd like the comment to be there please. @PromoFaux This potentially affects environment variables for docker. Please check this over. |
Fix addKey to handle the case where a key is being added, and that key is the leading substring of an already existing key within that file. For example: add "server=192.168.1.1", when "server=192.168.1.178" already exists within the /etc/dnsmasq.d/01-pihole.conf file. Check pihole docker with PIHOLE_DNS="192.168.1.178;192.168.1.1". Its /etc/dnsmasq/01-pihole.conf will be missing its second server= entry. Add the test_key_addition_substr, to test addKey when its adding a substring key of an existing key in the file. Signed-off-by: William Blew <william@kulian.org>
Per @dschaper, restore the addKey clarifying comment. It has been reworded to describe the use of anchors where before it referenced using grep's 'match only an entire line' argument. Signed-off-by: William Blew <william@kulian.org>
I failed to add my signoff, in the first attempt. Here is another try to restore the comment, with my signoff. |
I started off a little confused as to what was being fixed/changed here.. The issue you describe with docker does not exist as you describe it - at least, I cannot reproduce it: Which is because they are added as But then I re-read the issue and realised that the issue is actually nothing to do with docker at all, rather it is when pi-hole/advanced/Scripts/webpage.sh Line 157 in d86b325
That was all a very long way of saying "I've tested this and confirm it does what it says on the tin" |
Yes, my problem statement is woefully incomplete. Thus causing confusion. Why is hindsight always so clear? |
Thank you all. For your time, patience, and advice. |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-ftl-v5-22-web-v5-19-and-core-v5-16-1-released/61999/1 |
What does this PR aim to accomplish?:
This PR intends to address the case where a second upstream DNS server's address is a substring of the first upstream DNS
server's address. For example: using the Pi-hole docker image, with
PIHOLE_DNS_="192.168.1.178;192.168.1.1".
How does this PR accomplish the above?:
Fix
addKey
inutils.sh
to handle the case where a key is being added, and that key is the leading substring of an already existing key within that file. The new testtest_key_addition_substr
is added, to verify this behaviour is correct.For example: add
"server=192.168.1.1"
, when"server=192.168.1.178"
already exists within theetc/dnsmasq.d/01-pihole.conf
file.Check pihole docker with
PIHOLE_DNS_="192.168.1.178;192.168.1.1"
. Its/etc/dnsmasq/01-pihole.conf
will be missing its secondserver=
entry.Link documentation PRs if any are needed to support this PR:
None necessary, this is a bug fix. There are no intended changes in observable behaviour.
By submitting this pull request, I confirm the following:
git rebase
)