From 96681887b8cd24f0293bcd7245c077515071f9b2 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 28 Jul 2018 20:35:15 -0400 Subject: [PATCH 1/6] Fix wildcard/regex usage formatting Fix whitespace issue and missing backslashes in the regex example. Signed-off-by: Mcat12 --- manpages/pihole.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manpages/pihole.8 b/manpages/pihole.8 index c30570df..a6ad8068 100644 --- a/manpages/pihole.8 +++ b/manpages/pihole.8 @@ -282,10 +282,10 @@ Some usage examples .br \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist .br - \fBpihole --wild example.com\fR Add example.com as a wildcard - would + \fBpihole --wild example.com\fR Add example.com as a wildcard - would block all subdomains of example.com, including example.com itself. .br - \fBpihole --regex "ad.*\.example\.com$"\fR Add "ad.*\.example\.com$" to the regex + \fBpihole --regex "ad.*\\.example\\.com$"\fR Add "ad.*\\.example\\.com$" to the regex blacklist - would block all subdomains of example.com which start with "ad" .br From f90c412b35d646c8639f2352d8b1bbf67d89fc87 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sat, 28 Jul 2018 18:28:25 -0700 Subject: [PATCH 2/6] nroff checked pihole.8 for formatting. `nroff -man pihole.8` Signed-off-by: Dan Schaper --- manpages/pihole.8 | 85 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/manpages/pihole.8 b/manpages/pihole.8 index a6ad8068..e0845387 100644 --- a/manpages/pihole.8 +++ b/manpages/pihole.8 @@ -125,13 +125,16 @@ Available commands and options: .br -k, kelvin Set Kelvin as preferred temperature unit .br - -r, hostrecord Add a name to the DNS associated to an IPv4/IPv6 address + -r, hostrecord Add a name to the DNS associated to an + IPv4/IPv6 address .br - -e, email Set an administrative contact address for the Block Page + -e, email Set an administrative contact address for the + Block Page .br -i, interface Specify dnsmasq's interface listening behavior .br - -l, privacylevel Set privacy level (0 = lowest, 3 = highest) + -l, privacylevel Set privacy level + (0 = lowest, 3 = highest) .br \fB-c, chronometer\fR [options] @@ -181,7 +184,8 @@ Available commands and options: .br on Enable the Pi-hole log at /var/log/pihole.log .br - off Disable and flush the Pi-hole log at /var/log/pihole.log + off Disable and flush the Pi-hole log at + /var/log/pihole.log .br off noflush Disable the Pi-hole log at /var/log/pihole.log .br @@ -204,7 +208,8 @@ Available commands and options: .br -p, --pihole Only retrieve info regarding Pi-hole repository .br - -a, --admin Only retrieve info regarding AdminLTE repository + -a, --admin Only retrieve info regarding AdminLTE + repository .br -f, --ftl Only retrieve info regarding FTL repository .br @@ -214,7 +219,8 @@ Available commands and options: .br -l, --latest Return the latest version .br - --hash Return the Github hash from your local repositories + --hash Return the Github hash from your local + repositories .br \fBuninstall\fR @@ -266,7 +272,8 @@ Available commands and options: .br master Update subsystems to the latest stable release .br - dev Update subsystems to the latest development release + dev Update subsystems to the latest development + release .br branchname Update subsystems to the specified branchname .br @@ -275,50 +282,74 @@ Available commands and options: Some usage examples .br - Whitelist/blacklist manipulation +Whitelist/blacklist manipulation .br - \fBpihole -w iloveads.example.com\fR Add "iloveads.example.com" to whitelist +\fBpihole -w iloveads.example.com\fR .br - \fBpihole -b -d noads.example.com\fR Remove "noads.example.com" from blacklist -.br - \fBpihole --wild example.com\fR Add example.com as a wildcard - would - block all subdomains of example.com, including example.com itself. -.br - \fBpihole --regex "ad.*\\.example\\.com$"\fR Add "ad.*\\.example\\.com$" to the regex - blacklist - would block all subdomains of example.com which start with "ad" + Adds "iloveads.example.com" to whitelist .br - Changing the Web Interface password +\fBpihole -b -d noads.example.com\fR +.br + Removes "noads.example.com" from blacklist .br - \fBpihole -a -p ExamplePassword\fR Change the password to "ExamplePassword" +\fBpihole --wild example.com\fR +.br + Adds example.com as a wildcard - would block all subdomains of + example.com, including example.com itself. .br - Updating lists from internet sources +\fBpihole --regex "ad.*\\.example\\.com$"\fR +.br + Adds "ad.*\\.example\\.com$" to the regex blacklist. + Would block all subdomains of example.com which start with "ad" .br - \fBpihole -g\fR Update the list of ad-serving domains +Changing the Web Interface password .br - Displaying version information +\fBpihole -a -p ExamplePassword\fR +.br + Change the password to "ExamplePassword" .br - \fBpihole -v -a -c\fR Display the current version of AdminLTE +Updating lists from internet sources .br - Temporarily disabling Pi-hole +\fBpihole -g\fR +.br + Update the list of ad-serving domains .br - \fBpihole disable 5m\fR Disable Pi-hole functionality for five minutes +Displaying version information .br - Switching Pi-hole subsystem branches +\fBpihole -v -a -c\fR +.br + Display the current version of AdminLTE .br - \fBpihole checkout master\fR Switch to master branch +Temporarily disabling Pi-hole .br - \fBpihole checkout core dev\fR Switch to core development branch + +\fBpihole disable 5m\fR +.br + Disable Pi-hole functionality for five minutes +.br + +Switching Pi-hole subsystem branches +.br + +\fBpihole checkout master\fR +.br + Switch to master branch +.br + +\fBpihole checkout core dev\fR +.br + Switch to core development branch .br .SH "SEE ALSO" From 1a8d5fb4a90cacae4a4378513a35cfc059cb37b2 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 28 Jul 2018 21:56:18 -0400 Subject: [PATCH 3/6] Allow PHP to edit the regex file if installed Fixes permissions error on the web interface when modifying the regex. Signed-off-by: Mcat12 --- automated install/basic-install.sh | 9 +++++++++ gravity.sh | 5 ----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c7158435..1bbebde9 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -50,6 +50,7 @@ PI_HOLE_INSTALL_DIR="/opt/pihole" useUpdateVars=false adlistFile="/etc/pihole/adlists.list" +regexFile="/etc/pihole/regex.list" # Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until # this script can run IPV4_ADDRESS="" @@ -1235,6 +1236,11 @@ installConfigs() { # Make sure Pi-hole's config files are in place version_check_dnsmasq + # Install an empty regex file + touch "${regexFile}" + chown pihole:pihole "${regexFile}" + chmod 664 "${regexFile}" + # If the user chose to install the dashboard, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then # and if the Web server conf directory does not exist, @@ -1261,6 +1267,9 @@ installConfigs() { chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress mkdir -p /var/cache/lighttpd/uploads chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads + + # Let PHP edit the regex file + chown pihole:${LIGHTTPD_GROUP} "${regexFile}" fi } diff --git a/gravity.sh b/gravity.sh index b018e2ea..50c37784 100755 --- a/gravity.sh +++ b/gravity.sh @@ -643,11 +643,6 @@ if [[ "${skipDownload}" == false ]] || [[ "${listType}" == "whitelist" ]]; then gravity_Whitelist fi -# Set proper permissions on the regex file -touch "${regexFile}" -chown pihole:www-data "${regexFile}" -chmod 664 "${regexFile}" - convert_wildcard_to_regex gravity_ShowBlockCount From a55cc5533853264fb2768eb1fc48a67dd55a804f Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 28 Jul 2018 23:07:35 -0400 Subject: [PATCH 4/6] Only `touch` the regex file if it doesn't already exist The other permission calls will always be run so that the file is in the expected state after install and repair. Signed-off-by: Mcat12 --- automated install/basic-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1bbebde9..9d04bd85 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1237,7 +1237,9 @@ installConfigs() { version_check_dnsmasq # Install an empty regex file - touch "${regexFile}" + if [[ ! -f "${regexFile}" ]]; then + touch "${regexFile}" + fi chown pihole:pihole "${regexFile}" chmod 664 "${regexFile}" From 57af0ba0a49044968fd472025cd50ae3b3f3f0fa Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 29 Jul 2018 18:26:00 -0400 Subject: [PATCH 5/6] Use `install` to make the regex file Signed-off-by: Mcat12 --- automated install/basic-install.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9d04bd85..6ea66554 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1238,10 +1238,9 @@ installConfigs() { # Install an empty regex file if [[ ! -f "${regexFile}" ]]; then - touch "${regexFile}" + # Let PHP edit the regex file, if installed + install -o pihole -g "${LIGHTTPD_GROUP:-pihole}" -m 644 /dev/null "${regexFile}" fi - chown pihole:pihole "${regexFile}" - chmod 664 "${regexFile}" # If the user chose to install the dashboard, if [[ "${INSTALL_WEB_SERVER}" == true ]]; then @@ -1269,9 +1268,6 @@ installConfigs() { chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress mkdir -p /var/cache/lighttpd/uploads chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads - - # Let PHP edit the regex file - chown pihole:${LIGHTTPD_GROUP} "${regexFile}" fi } From fb2810557a2e5d42d18d01d6595ac77f693aacb0 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 29 Jul 2018 16:09:03 -0700 Subject: [PATCH 6/6] Allow web user group to access regex.list Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6ea66554..7b38df31 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1239,7 +1239,7 @@ installConfigs() { # Install an empty regex file if [[ ! -f "${regexFile}" ]]; then # Let PHP edit the regex file, if installed - install -o pihole -g "${LIGHTTPD_GROUP:-pihole}" -m 644 /dev/null "${regexFile}" + install -o pihole -g "${LIGHTTPD_GROUP:-pihole}" -m 664 /dev/null "${regexFile}" fi # If the user chose to install the dashboard,