PiPass / blockpage

A temporary unblock solution and blockpage for your Pi-Hole system
BSD 3-Clause "New" or "Revised" License
196 stars 14 forks source link

Setup: More modifications. Backup files, put PiPass in it's own directory #21

Closed JoeSchubert closed 5 years ago

JoeSchubert commented 5 years ago

There's no reason that PiPass would need to be in the base directory (as far as I can tell). Go ahead and put it in one directory and update the install scripts to point the 404 redirect there. This should also prevent PiPass from interfering with any existing webpages outside of the 404 redirection.

This will allow the uninstall to consist of: delete 'webroot'/PiPass rename the backed up files 'xxxxx'.pipass.bak to the original filenames remove the line that was added to the sudoers file.

Note: the files being backed up would only apply to installations going forward. If they're already modified, they would be backed up with those modifications.

JoeSchubert commented 5 years ago

per the ticket here: https://github.com/roenw/PiPass/issues/18

took the time to work out what an uninstaller should/would/could look like. the /var/www/html directory shouldn't be hardcoded in this. That should be simple enough to read from the config though and replace that in this. But this should clean everything up based on what's been changed. The real question will be how you would want to roll this into everything. Based on this and the other PRs, this should return the user's system to what it was prior to PiPass being installed.

<?php
echo "[ + ] Commencing uninstallation of PiPass."
echo "[ + ] We're sad to see you go... please help improve this project by leaving feedback on what issues casued you to leave.";
$GLOBALS['phpuser'] = get_current_user();
$localPU = $GLOBALS['phpuser'];
$sudoersline = preg_quote("$localPU ALL=(ALL) NOPASSWD: /usr/local/bin/pihole -w *, /usr/local/bin/pihole -w -d *", '/,');
echo "[ + ] Removing PiPass entry from /etc/suoders";
exec("sudo sed -ri '/$sudoersline/d' /etc/sudoers");

if (file_exists('/var/www/html/blockpage')) {
  echo "[ + ] Removing PiPass files...";
  exec("cd /var/www/html && sudo rm -rf index.php config.php setup blockpage");
}
if (file_exists('/etc/lighttpd/lighttpd.conf.pipass.bak')) {
  echo "[ + ] Restoring backup of lighttpd.conf";
  exec("sudo mv /etc/lighttpd/lighttpd.conf.pipass.bak /etc/lighttpd/lighttpd.conf");
}
  if (file_exists('/etc/pihole/pihole-FTL.conf.pipass.bak')) {
  echo "[ + ] Restoring backup of pihole-FTL.conf";
  exec("sudo mv /etc/pihole/pihole-FTL.conf.pipass.bak /etc/pihole/pihole-FTL.conf");
}
echo "[ + ] PiPass has been uninstalled."
?>
JoeSchubert commented 5 years ago

Somehow this change: https://github.com/roenw/PiPass/commit/4e318d811196e29788baf0a92b4854bc7b5c71c0 had gotten removed during the merges. Probably from one of the conflicts from my PRs. Updated to reflect the PiPass directory in the rest of this PR.

This change should prevent issues like the redirect loop here: https://github.com/roenw/PiPass/issues/20

roenw commented 5 years ago

PiPass is in the root directory because I discovered a lot of people use Pi-Hole to block porn/inappropriate sites. This would be necessary once we implement the option to require authentication before unblocking, for example, if I type in:

blockedsite.com, a 404 will not occur and PiPass will not be redirected to.

It’s also crucial that the user visits root/index.php BEFORE they visit root/blockpage/index.php since PiPass uses root/index.php to capture the blocked URL.

As far as I can tell, due to the limitations of this implementation and of DNS, if we want to keep the unblocking functionality, we would have to capture the URL and that entails using the webroot.

JoeSchubert commented 5 years ago

ahh fair enough. I didn't test it fully enough apparently.

I'll be changing this back to not put it in it's own directory.

JoeSchubert commented 5 years ago

fixed it now. I'll update my comment for the uninstall portion. The index.php, config.php and blockpage directory would each just need to be checked for and deleted individually.

roenw commented 5 years ago

Good to merge now?

JoeSchubert commented 5 years ago

Yeah, it should be good to go now. I also updated the uninstall snippet in my second comment. I don't know if that's something that you would want in it's own file, or to include in the setup.php as a function that would be called if you were to pass say, "php setup.php uninstall"

roenw commented 5 years ago

I think it should be in its own file honestly. We don't need to further complicate things :)

JoeSchubert commented 5 years ago

Sounds good. Just remember that I hardcoded the /var/www/html path in that snippet.

roenw commented 5 years ago

@yoinx Yeah, I will probably end up changing that to be another prompt, but not an issue right now. Probably won't be releasing this for another week or so, once I push locale support as well.