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

Prevent "pihole disable $timeout" from messing up future state changes #2887

Merged
merged 3 commits into from
Jul 15, 2020

Conversation

tlk
Copy link
Contributor

@tlk tlk commented Aug 24, 2019

By submitting this pull request, I confirm the following:
please fill any appropriate checkboxes, e.g: [X]

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes, and have included unit tests where possible.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)

Please make sure you Sign Off all commits. Pi-hole enforces the DCO.


What does this PR aim to accomplish?:
Fixes #2879
Prevent "pihole disable $timeout" from messing up future state changes.

Example:

pihole disable 30s
pihole enable
pihole disable
sleep 30
pihole status

Without this fix the following command sequence produces a somewhat surprising result, namely that pihole ends up being enabled. This is because pihole was enabled by a "reenable" job 30s after the first "disable" command. The operator, however, did not expect this because the last command to pihole was to disable itself.

With this fix the above command sequence will leave pihole disabled.

Please note that this fix depends on the existence of the pkill command.

I can confirm that pkill exists on my device running Raspbian GNU/Linux 10 (buster).

DL6ER
DL6ER previously requested changes Aug 24, 2019
Copy link
Member

@DL6ER DL6ER left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkill is contained in procps. This package is often not available in minimal environments. It might even be missing in the official Pi-hole docker container (@diginc would know more).

If we decide to use pkill, we would - at least - have to add procps to the installer dependencies (see automated install/basic-install.sh).

@diginc
Copy link
Contributor

diginc commented Aug 24, 2019

@tlk tlk force-pushed the fix/reenable branch 2 times, most recently from d01708e to 6209d6d Compare August 25, 2019 20:47
@tlk
Copy link
Contributor Author

tlk commented Aug 25, 2019

Thank you for checking up on pkill. After diving into a couple of rabbit holes over at #2879 I have updated the PR, and it no longer depends on pkill but uses a combination of killall and a new wrapper script.

The new wrapper script does not have the .sh suffix. This is because the name of the wrapper script is limited to 15 characters for it to be targetable by killall and the pihole-reenable name is exactly 15 characters. Please share if you know how to convince killall to target scripts with longer filenames.

@tlk tlk mentioned this pull request Aug 25, 2019
3 tasks
@dschaper
Copy link
Member

Since the file will be in /opt/pihole you don't really need to call it pihole-reenable. reenable.sh will work fine.

@oakkitten
Copy link

oakkitten commented Aug 25, 2019

yes, but killall reenable might kill unwanted stuff

anyways, the process name of pihole-reenable.sh is pihole-reenable 🙄 so it will work

$ ./pihole-reenable.sh & cat "/proc/${!}/stat"
[3] 3927
3927 (pihole-reenable) R 1534 3927 1534 34825 392 ...

I tried testing this branch but i have no idea how to install pihole from git. any hints?

@tlk
Copy link
Contributor Author

tlk commented Aug 25, 2019

yes, but killall reenable might kill unwanted stuff
anyways, the process name of pihole-reenable.sh is pihole-reenable 🙄 so it will work

Good point! Renamed to pihole-reenable.sh

@PromoFaux
Copy link
Member

PromoFaux commented Nov 16, 2019

I tried testing this branch but i have no idea how to install pihole from git. any hints?

@oakkitten :

git clone https://github.com/pi-hole/pi-hole /etc/.pihole
cd /etc/.pihole
git checkout [whatever branch here]
./automated\ install/basic-install.sh

though if you wanted to try this branch specifically, then do this after moving into the directory:

git checkout -b tlk-fix/reenable development
git pull https://github.com/tlk/pi-hole.git fix/reenable

@DL6ER , do your change requests still stand?

@DL6ER DL6ER dismissed their stale review November 16, 2019 13:32

pkill is no longer used

Copy link
Member

@PromoFaux PromoFaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlk Please could you resolve the merge conflicts on PR, thanks!

@PromoFaux PromoFaux added the PR: Merge Conflict Issue blocking check and merge of code label Nov 25, 2019
@tlk
Copy link
Contributor Author

tlk commented Nov 25, 2019

@PromoFaux Sure. Just checking - is pi-hole:development the correct target branch?

@PromoFaux
Copy link
Member

Yep! All new code goes into development before master

pihole Show resolved Hide resolved
@HighMileage
Copy link

@tlk it looks like this PR has been waiting for a rebase for almost 6 months. Do you have time for this rebase or would you rather someone else open a PR and drive this work?

Signed-off-by: Thomas L. Kjeldsen <tlk@closureconsulting.com>
tlk added 2 commits May 30, 2020 03:13
Signed-off-by: Thomas L. Kjeldsen <tlk@closureconsulting.com>
Signed-off-by: Thomas L. Kjeldsen <tlk@closureconsulting.com>
@tlk
Copy link
Contributor Author

tlk commented May 30, 2020

@HighMileage Thank you for the kind reminder!

@PromoFaux The PR has now been rebased to development and this should solve the merge conflicts.

@tlk tlk requested a review from PromoFaux June 8, 2020 22:46
@HighMileage
Copy link

@PromoFaux can you take a look at this PR 👀? It's been rebased and should be good to merge now

@PromoFaux PromoFaux changed the base branch from development to release/v5.1 July 15, 2020 13:23
@PromoFaux PromoFaux merged commit 7b41b99 into pi-hole:release/v5.1 Jul 15, 2020
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-5-1-released/35577/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Merge Conflict Issue blocking check and merge of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants