Skip to content

Commit e41c4b5

Browse files
authored
Merge pull request pi-hole#2881 from pi-hole/release/v4.3.2
Pi-hole Core v4.3.2
2 parents 1a741f6 + b209629 commit e41c4b5

14 files changed

+115
-108
lines changed

.github/FUNDING.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
patreon: pihole
4+
custom: https://pi-hole.net/donate

advanced/01-pihole.conf

-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,3 @@ log-facility=/var/log/pihole.log
4343
local-ttl=2
4444

4545
log-async
46-
47-
# If a DHCP client claims that its name is "wpad", ignore that.
48-
# This fixes a security hole. see CERT Vulnerability VU#598349
49-
dhcp-name-match=set:wpad-ignore,wpad
50-
dhcp-ignore-names=tag:wpad-ignore

advanced/Scripts/query.sh

+15-15
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ scanList(){
5454
# /dev/null forces filename to be printed when only one list has been generated
5555
# shellcheck disable=SC2086
5656
case "${type}" in
57-
"exact" ) grep -i -E -l "(^|(?<!#)\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;;
57+
"exact" ) grep -i -E "(^|\\s)${domain}($|\\s|#)" ${lists} /dev/null 2>/dev/null;;
5858
"wc" ) grep -i -o -m 1 "/${domain}/" ${lists} 2>/dev/null;;
5959
* ) grep -i "${domain}" ${lists} /dev/null 2>/dev/null;;
6060
esac
@@ -157,6 +157,20 @@ lists=("$(cd "$piholeDir" || exit 0; printf "%s\\n" -- *.domains | sort -V)")
157157
# Query blocklists for occurences of domain
158158
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")"
159159

160+
# Remove unwanted content from $results
161+
# Each line in $results is formatted as such: [fileName]:[line]
162+
# 1. Delete lines starting with #
163+
# 2. Remove comments after domain
164+
# 3. Remove hosts format IP address
165+
# 4. Remove any lines that no longer contain the queried domain name (in case the matched domain name was in a comment)
166+
esc_domain="${domainQuery//./\\.}"
167+
mapfile -t results <<< "$(IFS=$'\n'; sed \
168+
-e "/:#/d" \
169+
-e "s/[ \\t]#.*//g" \
170+
-e "s/:.*[ \\t]/:/g" \
171+
-e "/${esc_domain}/!d" \
172+
<<< "${results[*]}")"
173+
160174
# Handle notices
161175
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
162176
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
@@ -170,20 +184,6 @@ elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
170184
exit 0
171185
fi
172186
173-
# Remove unwanted content from non-exact $results
174-
if [[ -z "${exact}" ]]; then
175-
# Delete lines starting with #
176-
# Remove comments after domain
177-
# Remove hosts format IP address
178-
mapfile -t results <<< "$(IFS=$'\n'; sed \
179-
-e "/:#/d" \
180-
-e "s/[ \\t]#.*//g" \
181-
-e "s/:.*[ \\t]/:/g" \
182-
<<< "${results[*]}")"
183-
# Exit if result was in a comment
184-
[[ -z "${results[*]}" ]] && exit 0
185-
fi
186-
187187
# Get adlist file content as array
188188
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then
189189
for adlistUrl in $(< "${adListsList}"); do

advanced/Scripts/webpage.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf"
1616
readonly FTLconf="/etc/pihole/pihole-FTL.conf"
1717
# 03 -> wildcards
1818
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
19+
readonly PI_HOLE_BIN_DIR="/usr/local/bin"
1920

2021
coltable="/opt/pihole/COL_TABLE"
2122
if [[ -f ${coltable} ]]; then
@@ -274,7 +275,7 @@ Reboot() {
274275
}
275276

276277
RestartDNS() {
277-
/usr/local/bin/pihole restartdns
278+
"${PI_HOLE_BIN_DIR}"/pihole restartdns
278279
}
279280

280281
SetQueryLogOptions() {
@@ -363,6 +364,14 @@ EnableDHCP() {
363364
delete_dnsmasq_setting "dhcp-"
364365
delete_dnsmasq_setting "quiet-dhcp"
365366

367+
# If a DHCP client claims that its name is "wpad", ignore that.
368+
# This fixes a security hole. see CERT Vulnerability VU#598349
369+
# We also ignore "localhost" as Windows behaves strangely if a
370+
# device claims this host name
371+
add_dnsmasq_setting "dhcp-name-match=set:hostname-ignore,wpad
372+
dhcp-name-match=set:hostname-ignore,localhost
373+
dhcp-ignore-names=tag:hostname-ignore"
374+
366375
ProcessDHCPSettings
367376

368377
RestartDNS

advanced/Templates/pihole-FTL.service

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ FTLUSER=pihole
1313
PIDFILE=/var/run/pihole-FTL.pid
1414

1515
get_pid() {
16-
pidof "pihole-FTL"
16+
# First, try to obtain PID from PIDFILE
17+
if [ -s "${PIDFILE}" ]; then
18+
cat "${PIDFILE}"
19+
return
20+
fi
21+
22+
# If the PIDFILE is empty or not available, obtain the PID using pidof
23+
pidof "pihole-FTL" | awk '{print $(NF)}'
1724
}
1825

1926
is_running() {

advanced/lighttpd.conf.debian

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ server.modules = (
2727
)
2828

2929
server.document-root = "/var/www/html"
30-
server.error-handler-404 = "pihole/index.php"
30+
server.error-handler-404 = "/pihole/index.php"
3131
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
3232
server.errorlog = "/var/log/lighttpd/error.log"
3333
server.pid-file = "/var/run/lighttpd.pid"

advanced/lighttpd.conf.fedora

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ server.modules = (
2828
)
2929

3030
server.document-root = "/var/www/html"
31-
server.error-handler-404 = "pihole/index.php"
31+
server.error-handler-404 = "/pihole/index.php"
3232
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
3333
server.errorlog = "/var/log/lighttpd/error.log"
3434
server.pid-file = "/var/run/lighttpd.pid"

automated install/basic-install.sh

+29-19
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set -e
3131
# List of supported DNS servers
3232
DNS_SERVERS=$(cat << EOM
3333
Google (ECS);8.8.8.8;8.8.4.4;2001:4860:4860:0:0:0:0:8888;2001:4860:4860:0:0:0:0:8844
34-
OpenDNS (ECS);208.67.222.222;208.67.220.220;2620:0:ccc::2;2620:0:ccd::2
34+
OpenDNS (ECS);208.67.222.222;208.67.220.220;2620:119:35::35;2620:119:53::53
3535
Level3;4.2.2.1;4.2.2.2;;
3636
Comodo;8.26.56.26;8.20.247.20;;
3737
DNS.WATCH;84.200.69.80;84.200.70.40;2001:1608:10:25:0:0:1c04:b12f;2001:1608:10:25:0:0:9249:d69b
@@ -65,6 +65,7 @@ PI_HOLE_FILES=(chronometer list piholeDebug piholeLogFlush setupLCD update versi
6565
# This directory is where the Pi-hole scripts will be installed
6666
PI_HOLE_INSTALL_DIR="/opt/pihole"
6767
PI_HOLE_CONFIG_DIR="/etc/pihole"
68+
PI_HOLE_BIN_DIR="/usr/local/bin"
6869
PI_HOLE_BLOCKPAGE_DIR="${webroot}/pihole"
6970
useUpdateVars=false
7071

@@ -84,8 +85,13 @@ if [ -z "${USER}" ]; then
8485
fi
8586

8687

87-
# Find the rows and columns will default to 80x24 if it can not be detected
88-
screen_size=$(stty size || printf '%d %d' 24 80)
88+
# Check if we are running on a real terminal and find the rows and columns
89+
# If there is no real terminal, we will default to 80x24
90+
if [ -t 0 ] ; then
91+
screen_size=$(stty size)
92+
else
93+
screen_size="24 80"
94+
fi
8995
# Set rows variable to contain first number
9096
printf -v rows '%d' "${screen_size%% *}"
9197
# Set columns variable to contain second number
@@ -283,7 +289,7 @@ elif is_command rpm ; then
283289
UPDATE_PKG_CACHE=":"
284290
PKG_INSTALL=(${PKG_MANAGER} install -y)
285291
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
286-
INSTALLER_DEPS=(dialog git iproute newt procps-ng which)
292+
INSTALLER_DEPS=(dialog git iproute newt procps-ng which chkconfig)
287293
PIHOLE_DEPS=(bind-utils cronie curl findutils nmap-ncat sudo unzip wget libidn2 psmisc sqlite libcap)
288294
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo)
289295
LIGHTTPD_USER="lighttpd"
@@ -1168,12 +1174,11 @@ chooseBlocklists() {
11681174
mv "${adlistFile}" "${adlistFile}.old"
11691175
fi
11701176
# Let user select (or not) blocklists via a checklist
1171-
cmd=(whiptail --separate-output --checklist "Pi-hole relies on third party lists in order to block ads.\\n\\nYou can use the suggestions below, and/or add your own after installation\\n\\nTo deselect any list, use the arrow keys and spacebar" "${r}" "${c}" 7)
1177+
cmd=(whiptail --separate-output --checklist "Pi-hole relies on third party lists in order to block ads.\\n\\nYou can use the suggestions below, and/or add your own after installation\\n\\nTo deselect any list, use the arrow keys and spacebar" "${r}" "${c}" 6)
11721178
# In an array, show the options available (all off by default):
11731179
options=(StevenBlack "StevenBlack's Unified Hosts List" on
11741180
MalwareDom "MalwareDomains" on
11751181
Cameleon "Cameleon" on
1176-
ZeusTracker "ZeusTracker" on
11771182
DisconTrack "Disconnect.me Tracking" on
11781183
DisconAd "Disconnect.me Ads" on
11791184
HostsFile "Hosts-file.net Ads" on)
@@ -1195,7 +1200,6 @@ appendToListsFile() {
11951200
StevenBlack ) echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >> "${adlistFile}";;
11961201
MalwareDom ) echo "https://mirror1.malwaredomains.com/files/justdomains" >> "${adlistFile}";;
11971202
Cameleon ) echo "http://sysctl.org/cameleon/hosts" >> "${adlistFile}";;
1198-
ZeusTracker ) echo "https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist" >> "${adlistFile}";;
11991203
DisconTrack ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt" >> "${adlistFile}";;
12001204
DisconAd ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}";;
12011205
HostsFile ) echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}";;
@@ -1213,7 +1217,6 @@ installDefaultBlocklists() {
12131217
appendToListsFile StevenBlack
12141218
appendToListsFile MalwareDom
12151219
appendToListsFile Cameleon
1216-
appendToListsFile ZeusTracker
12171220
appendToListsFile DisconTrack
12181221
appendToListsFile DisconAd
12191222
appendToListsFile HostsFile
@@ -1337,7 +1340,7 @@ installScripts() {
13371340
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/*.sh
13381341
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
13391342
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
1340-
install -o "${USER}" -Dm755 -t /usr/local/bin/ pihole
1343+
install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
13411344
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
13421345
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
13431346

@@ -1605,7 +1608,6 @@ install_dependent_packages() {
16051608

16061609
# Install packages passed in via argument array
16071610
# No spinner - conflicts with set -e
1608-
declare -a argArray1=("${!1}")
16091611
declare -a installArray
16101612

16111613
# Debian based package install - debconf will download the entire package list
@@ -1615,7 +1617,7 @@ install_dependent_packages() {
16151617
# installed by us, and remove only the installed packages, and not the entire list.
16161618
if is_command debconf-apt-progress ; then
16171619
# For each package,
1618-
for i in "${argArray1[@]}"; do
1620+
for i in "$@"; do
16191621
printf " %b Checking for %s..." "${INFO}" "${i}"
16201622
if dpkg-query -W -f='${Status}' "${i}" 2>/dev/null | grep "ok installed" &> /dev/null; then
16211623
printf "%b %b Checking for %s\\n" "${OVER}" "${TICK}" "${i}"
@@ -1634,7 +1636,7 @@ install_dependent_packages() {
16341636
fi
16351637

16361638
# Install Fedora/CentOS packages
1637-
for i in "${argArray1[@]}"; do
1639+
for i in "$@"; do
16381640
printf " %b Checking for %s..." "${INFO}" "${i}"
16391641
if ${PKG_MANAGER} -q list installed "${i}" &> /dev/null; then
16401642
printf "%b %b Checking for %s" "${OVER}" "${TICK}" "${i}"
@@ -1691,13 +1693,13 @@ installPiholeWeb() {
16911693
# and copy in the pihole sudoers file
16921694
install -m 0640 ${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole.sudo /etc/sudoers.d/pihole
16931695
# Add lighttpd user (OS dependent) to sudoers file
1694-
echo "${LIGHTTPD_USER} ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
1696+
echo "${LIGHTTPD_USER} ALL=NOPASSWD: ${PI_HOLE_BIN_DIR}/pihole" >> /etc/sudoers.d/pihole
16951697

16961698
# If the Web server user is lighttpd,
16971699
if [[ "$LIGHTTPD_USER" == "lighttpd" ]]; then
16981700
# Allow executing pihole via sudo with Fedora
1699-
# Usually /usr/local/bin is not permitted as directory for sudoable programs
1700-
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
1701+
# Usually /usr/local/bin ${PI_HOLE_BIN_DIR} is not permitted as directory for sudoable programs
1702+
echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:${PI_HOLE_BIN_DIR}" >> /etc/sudoers.d/pihole
17011703
fi
17021704
# Set the strict permissions on the file
17031705
chmod 0440 /etc/sudoers.d/pihole
@@ -2381,8 +2383,16 @@ FTLcheckUpdate() {
23812383
if [[ ${ftlLoc} ]]; then
23822384
local FTLversion
23832385
FTLversion=$(/usr/bin/pihole-FTL tag)
2386+
local FTLreleaseData
23842387
local FTLlatesttag
2385-
FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n')
2388+
2389+
if ! FTLreleaseData=$(curl -sI https://github.com/pi-hole/FTL/releases/latest); then
2390+
# There was an issue while retrieving the latest version
2391+
printf " %b Failed to retrieve latest FTL release metadata" "${CROSS}"
2392+
return 3
2393+
fi
2394+
2395+
FTLlatesttag=$(grep 'Location' <<< "${FTLreleaseData}" | awk -F '/' '{print $NF}' | tr -d '\r\n')
23862396

23872397
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
23882398
return 0
@@ -2506,7 +2516,7 @@ main() {
25062516
notify_package_updates_available
25072517

25082518
# Install packages used by this installation script
2509-
install_dependent_packages INSTALLER_DEPS[@]
2519+
install_dependent_packages "${INSTALLER_DEPS[@]}"
25102520

25112521
# Check if SELinux is Enforcing
25122522
checkSelinux
@@ -2557,7 +2567,7 @@ main() {
25572567
dep_install_list+=("${PIHOLE_WEB_DEPS[@]}")
25582568
fi
25592569

2560-
install_dependent_packages dep_install_list[@]
2570+
install_dependent_packages "${dep_install_list[@]}"
25612571
unset dep_install_list
25622572

25632573
# On some systems, lighttpd is not enabled on first install. We need to enable it here if the user
@@ -2665,7 +2675,7 @@ main() {
26652675

26662676
if [[ "${INSTALL_TYPE}" == "Update" ]]; then
26672677
printf "\\n"
2668-
/usr/local/bin/pihole version --current
2678+
"${PI_HOLE_BIN_DIR}"/pihole version --current
26692679
fi
26702680
}
26712681

automated install/uninstall.sh

+10-7
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ fi
5555
# Compatability
5656
if [ -x "$(command -v apt-get)" ]; then
5757
# Debian Family
58-
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
58+
PKG_REMOVE=("${PKG_MANAGER}" -y remove --purge)
5959
package_check() {
6060
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
6161
}
6262
elif [ -x "$(command -v rpm)" ]; then
6363
# Fedora Family
64-
PKG_REMOVE="${PKG_MANAGER} remove -y"
64+
PKG_REMOVE=("${PKG_MANAGER}" remove -y)
6565
package_check() {
6666
rpm -qa | grep "^$1-" > /dev/null
6767
}
@@ -80,7 +80,7 @@ removeAndPurge() {
8080
case ${yn} in
8181
[Yy]* )
8282
echo -ne " ${INFO} Removing ${i}...";
83-
${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null;
83+
${SUDO} "${PKG_REMOVE[@]}" "${i}" &> /dev/null;
8484
echo -e "${OVER} ${INFO} Removed ${i}";
8585
break;;
8686
[Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
@@ -132,12 +132,15 @@ removeNoPurge() {
132132
fi
133133

134134
if package_check lighttpd > /dev/null; then
135-
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
136-
echo -e " ${TICK} Removed lighttpd"
137-
else
138-
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
135+
if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
139136
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
140137
fi
138+
139+
if [[ -f /etc/lighttpd/external.conf ]]; then
140+
${SUDO} rm /etc/lighttpd/external.conf
141+
fi
142+
143+
echo -e " ${TICK} Removed lighttpd configs"
141144
fi
142145

143146
${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null

0 commit comments

Comments
 (0)