Skip to content

Commit 0d8ece1

Browse files
authored
Merge pull request #3889 from pi-hole/release/v5.2.1
Pi-hole Core release v5.2.1
2 parents fee1b8b + 8443262 commit 0d8ece1

36 files changed

+469
-413
lines changed

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test Supported Distributions
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
distro-test:
9+
if: github.event.pull_request.draft == false
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
distro: [debian_9, debian_10, ubuntu_16, ubuntu_18, ubuntu_20, centos_7, centos_8, fedora_31, fedora_32]
14+
env:
15+
DISTRO: ${{matrix.distro}}
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Set up Python 3.7
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.7
22+
- name: Install dependencies
23+
run: pip install -r test/requirements.txt
24+
- name: Test with tox
25+
run: tox -c test/tox.${DISTRO}.ini

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

advanced/Scripts/piholeDebug.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ processor_check() {
560560
else
561561
# Check if the architecture is currently supported for FTL
562562
case "${PROCESSOR}" in
563-
"amd64") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}"
563+
"amd64" | "x86_64") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}"
564564
;;
565565
"armv6l") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}"
566566
;;
@@ -977,7 +977,7 @@ make_array_from_file() {
977977
# Otherwise, read the file line by line
978978
while IFS= read -r line;do
979979
# Othwerise, strip out comments and blank lines
980-
new_line=$(echo "${line}" | sed -e 's/#.*$//' -e '/^$/d')
980+
new_line=$(echo "${line}" | sed -e 's/^\s*#.*$//' -e '/^$/d')
981981
# If the line still has content (a non-zero value)
982982
if [[ -n "${new_line}" ]]; then
983983
# Put it into the array

advanced/Scripts/webpage.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
217217

218218
if [[ "${CONDITIONAL_FORWARDING}" == true ]]; then
219219
# Convert legacy "conditional forwarding" to rev-server configuration
220+
# Remove any existing REV_SERVER settings
221+
delete_setting "REV_SERVER"
222+
delete_setting "REV_SERVER_DOMAIN"
223+
delete_setting "REV_SERVER_TARGET"
224+
delete_setting "REV_SERVER_CIDR"
225+
220226
REV_SERVER=true
221227
add_setting "REV_SERVER" "true"
222228

@@ -226,7 +232,25 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
226232
REV_SERVER_TARGET="${CONDITIONAL_FORWARDING_IP}"
227233
add_setting "REV_SERVER_TARGET" "${REV_SERVER_TARGET}"
228234

229-
REV_SERVER_CIDR="${CONDITIONAL_FORWARDING_REVERSE}"
235+
#Convert CONDITIONAL_FORWARDING_REVERSE if necessary e.g:
236+
# 1.1.168.192.in-addr.arpa to 192.168.1.1/32
237+
# 1.168.192.in-addr.arpa to 192.168.1.0/24
238+
# 168.192.in-addr.arpa to 192.168.0.0/16
239+
# 192.in-addr.arpa to 192.0.0.0/8
240+
if [[ "${CONDITIONAL_FORWARDING_REVERSE}" == *"in-addr.arpa" ]];then
241+
arrRev=("${CONDITIONAL_FORWARDING_REVERSE//./ }")
242+
case ${#arrRev[@]} in
243+
6 ) REV_SERVER_CIDR="${arrRev[3]}.${arrRev[2]}.${arrRev[1]}.${arrRev[0]}/32";;
244+
5 ) REV_SERVER_CIDR="${arrRev[2]}.${arrRev[1]}.${arrRev[0]}.0/24";;
245+
4 ) REV_SERVER_CIDR="${arrRev[1]}.${arrRev[0]}.0.0/16";;
246+
3 ) REV_SERVER_CIDR="${arrRev[0]}.0.0.0/8";;
247+
esac
248+
else
249+
# Set REV_SERVER_CIDR to whatever value it was set to
250+
REV_SERVER_CIDR="${CONDITIONAL_FORWARDING_REVERSE}"
251+
fi
252+
253+
# If REV_SERVER_CIDR is not converted by the above, then use the REV_SERVER_TARGET variable to derive it
230254
if [ -z "${REV_SERVER_CIDR}" ]; then
231255
# Convert existing input to /24 subnet (preserves legacy behavior)
232256
# This sed converts "192.168.1.2" to "192.168.1.0/24"
@@ -253,6 +277,13 @@ trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC68345710423
253277
# This follows https://support.mozilla.org/en-US/kb/configuring-networks-disable-dns-over-https
254278
# (sourced 7th September 2019)
255279
add_dnsmasq_setting "server=/use-application-dns.net/"
280+
281+
# We need to process DHCP settings here as well to account for possible
282+
# changes in the non-FQDN forwarding. This cannot be done in 01-pihole.conf
283+
# as we don't want to delete all local=/.../ lines so it's much safer to
284+
# simply rewrite the entire corresponding config file (which is what the
285+
# DHCP settings subroutie is doing)
286+
ProcessDHCPSettings
256287
}
257288

258289
SetDNSServers() {
@@ -375,6 +406,11 @@ dhcp-leasefile=/etc/pihole/dhcp.leases
375406

376407
if [[ "${PIHOLE_DOMAIN}" != "none" ]]; then
377408
echo "domain=${PIHOLE_DOMAIN}" >> "${dhcpconfig}"
409+
410+
# When there is a Pi-hole domain set and "Never forward non-FQDNs" is
411+
# ticked, we add `local=/domain/` to tell FTL that this domain is purely
412+
# local and FTL may answer queries from /etc/hosts or DHCP but should
413+
# never forward queries on that domain to any upstream servers
378414
if [[ "${DNS_FQDN_REQUIRED}" == true ]]; then
379415
echo "local=/${PIHOLE_DOMAIN}/" >> "${dhcpconfig}"
380416
fi

automated install/basic-install.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ elif is_command rpm ; then
393393
PKG_INSTALL=("${PKG_MANAGER}" install -y)
394394
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
395395
INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig bind-utils)
396-
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlite libcap)
396+
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlite libcap lsof)
397397
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xml php-json php-intl)
398398
LIGHTTPD_USER="lighttpd"
399399
LIGHTTPD_GROUP="lighttpd"
@@ -528,8 +528,10 @@ make_repo() {
528528
printf " %b %s..." "${INFO}" "${str}"
529529
# If the directory exists,
530530
if [[ -d "${directory}" ]]; then
531-
# delete everything in it so git can clone into it
532-
rm -rf "${directory}"
531+
# Return with a 1 to exit the installer. We don't want to overwrite what could already be here in case it is not ours
532+
str="Unable to clone ${remoteRepo} into ${directory} : Directory already exists"
533+
printf "%b %b%s\\n" "${OVER}" "${CROSS}" "${str}"
534+
return 1
533535
fi
534536
# Clone the repo and return the return code from this command
535537
git clone -q --depth 20 "${remoteRepo}" "${directory}" &> /dev/null || return $?
@@ -1913,7 +1915,7 @@ finalExports() {
19131915
# If the setup variable file exists,
19141916
if [[ -e "${setupVars}" ]]; then
19151917
# update the variables in the file
1916-
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;/CACHE_SIZE/d;' "${setupVars}"
1918+
sed -i.update.bak '/PIHOLE_INTERFACE/d;/IPV4_ADDRESS/d;/IPV6_ADDRESS/d;/PIHOLE_DNS_1\b/d;/PIHOLE_DNS_2\b/d;/QUERY_LOGGING/d;/INSTALL_WEB_SERVER/d;/INSTALL_WEB_INTERFACE/d;/LIGHTTPD_ENABLED/d;/CACHE_SIZE/d;' "${setupVars}"
19171919
fi
19181920
# echo the information to the user
19191921
{

autotest

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/ubuntu_16.Dockerfile renamed to test/_ubuntu_16.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ RUN true && \
1313

1414
ENV PH_TEST true
1515

16-
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
16+
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
File renamed without changes.
File renamed without changes.

test/conftest.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ def args(request):
7070

7171

7272
@pytest.fixture(params=[
73-
'debian_9',
74-
'debian_10',
75-
'centos_7',
76-
'centos_8',
77-
'fedora_31',
78-
'fedora_32',
79-
'ubuntu_16',
80-
'ubuntu_18',
81-
'ubuntu_20'
73+
'test_container'
8274
])
8375
def tag(request):
8476
'''
File renamed without changes.

setup.py renamed to test/setup.py

File renamed without changes.

test/test_000_build_containers.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

test/test_centos_7_support.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from .conftest import (
2+
tick_box,
3+
info_box,
4+
mock_command,
5+
)
6+
7+
8+
def test_php_upgrade_default_optout_centos_eq_7(Pihole):
9+
'''
10+
confirms the default behavior to opt-out of installing PHP7 from REMI
11+
'''
12+
distro_check = Pihole.run('''
13+
source /opt/pihole/basic-install.sh
14+
distro_check
15+
''')
16+
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
17+
'Deprecated PHP may be in use.')
18+
assert expected_stdout in distro_check.stdout
19+
remi_package = Pihole.package('remi-release')
20+
assert not remi_package.is_installed
21+
22+
23+
def test_php_upgrade_user_optout_centos_eq_7(Pihole):
24+
'''
25+
confirms installer behavior when user opt-out of installing PHP7 from REMI
26+
(php not currently installed)
27+
'''
28+
# Whiptail dialog returns Cancel for user prompt
29+
mock_command('whiptail', {'*': ('', '1')}, Pihole)
30+
distro_check = Pihole.run('''
31+
source /opt/pihole/basic-install.sh
32+
distro_check
33+
''')
34+
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
35+
'Deprecated PHP may be in use.')
36+
assert expected_stdout in distro_check.stdout
37+
remi_package = Pihole.package('remi-release')
38+
assert not remi_package.is_installed
39+
40+
41+
def test_php_upgrade_user_optin_centos_eq_7(Pihole):
42+
'''
43+
confirms installer behavior when user opt-in to installing PHP7 from REMI
44+
(php not currently installed)
45+
'''
46+
# Whiptail dialog returns Continue for user prompt
47+
mock_command('whiptail', {'*': ('', '0')}, Pihole)
48+
distro_check = Pihole.run('''
49+
source /opt/pihole/basic-install.sh
50+
distro_check
51+
''')
52+
assert 'opt-out' not in distro_check.stdout
53+
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
54+
'(https://rpms.remirepo.net)')
55+
assert expected_stdout in distro_check.stdout
56+
expected_stdout = tick_box + (' Remi\'s RPM repository has '
57+
'been enabled for PHP7')
58+
assert expected_stdout in distro_check.stdout
59+
remi_package = Pihole.package('remi-release')
60+
assert remi_package.is_installed

test/test_centos_8_support.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from .conftest import (
2+
tick_box,
3+
info_box,
4+
mock_command,
5+
)
6+
7+
8+
def test_php_upgrade_default_continue_centos_gte_8(Pihole):
9+
'''
10+
confirms the latest version of CentOS continues / does not optout
11+
(should trigger on CentOS7 only)
12+
'''
13+
distro_check = Pihole.run('''
14+
source /opt/pihole/basic-install.sh
15+
distro_check
16+
''')
17+
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
18+
' Deprecated PHP may be in use.')
19+
assert unexpected_stdout not in distro_check.stdout
20+
# ensure remi was not installed on latest CentOS
21+
remi_package = Pihole.package('remi-release')
22+
assert not remi_package.is_installed
23+
24+
25+
def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole):
26+
'''
27+
confirms installer skips user opt-out of installing PHP7 from REMI on
28+
latest CentOS (should trigger on CentOS7 only)
29+
(php not currently installed)
30+
'''
31+
# Whiptail dialog returns Cancel for user prompt
32+
mock_command('whiptail', {'*': ('', '1')}, Pihole)
33+
distro_check = Pihole.run('''
34+
source /opt/pihole/basic-install.sh
35+
distro_check
36+
''')
37+
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
38+
' Deprecated PHP may be in use.')
39+
assert unexpected_stdout not in distro_check.stdout
40+
# ensure remi was not installed on latest CentOS
41+
remi_package = Pihole.package('remi-release')
42+
assert not remi_package.is_installed
43+
44+
45+
def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole):
46+
'''
47+
confirms installer skips user opt-in to installing PHP7 from REMI on
48+
latest CentOS (should trigger on CentOS7 only)
49+
(php not currently installed)
50+
'''
51+
# Whiptail dialog returns Continue for user prompt
52+
mock_command('whiptail', {'*': ('', '0')}, Pihole)
53+
distro_check = Pihole.run('''
54+
source /opt/pihole/basic-install.sh
55+
distro_check
56+
''')
57+
assert 'opt-out' not in distro_check.stdout
58+
unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository '
59+
'(https://rpms.remirepo.net)')
60+
assert unexpected_stdout not in distro_check.stdout
61+
unexpected_stdout = tick_box + (' Remi\'s RPM repository has '
62+
'been enabled for PHP7')
63+
assert unexpected_stdout not in distro_check.stdout
64+
remi_package = Pihole.package('remi-release')
65+
assert not remi_package.is_installed

0 commit comments

Comments
 (0)