Compare commits
19 Commits
unsupporte
...
0a903feb12
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a903feb12 | |||
| 15874b002e | |||
| ca9de23ca5 | |||
| d807c40ba5 | |||
| 6ee7eca1e5 | |||
| 396f85614d | |||
| c95094a6d3 | |||
| 0159461cc0 | |||
| 8d24316758 | |||
| e972595170 | |||
|
|
4125bcccdc | ||
|
|
ac37014628 | ||
|
|
d765ce768f | ||
|
|
527895a377 | ||
|
|
11344c39f5 | ||
|
|
b2e56662c0 | ||
|
|
95021fce58 | ||
|
|
082d74eeb1 | ||
|
|
1a3a23a867 |
@@ -50,9 +50,10 @@ rm -f "/etc/pihole/GitHubVersions"
|
||||
rm -f "/etc/pihole/localbranches"
|
||||
rm -f "/etc/pihole/localversions"
|
||||
|
||||
# Create new versions file if it does not exist
|
||||
VERSION_FILE="/etc/pihole/versions"
|
||||
touch "${VERSION_FILE}"
|
||||
|
||||
# Truncates the file to zero length if it exists to clear it up, otherwise creates an empty file.
|
||||
truncate -s 0 "${VERSION_FILE}"
|
||||
chmod 644 "${VERSION_FILE}"
|
||||
|
||||
# if /pihole.docker.tag file exists, we will use it's value later in this script
|
||||
|
||||
@@ -30,9 +30,6 @@ addOrEditKeyValPair() {
|
||||
local key="${2}"
|
||||
local value="${3}"
|
||||
|
||||
# touch file to prevent grep error if file does not exist yet
|
||||
touch "${file}"
|
||||
|
||||
if grep -q "^${key}=" "${file}"; then
|
||||
# Key already exists in file, modify the value
|
||||
sed -i "/^${key}=/c\\${key}=${value}" "${file}"
|
||||
|
||||
@@ -57,9 +57,9 @@ start() {
|
||||
stop() {
|
||||
if is_running; then
|
||||
kill "${FTL_PID}"
|
||||
# Give FTL 60 seconds to gracefully stop
|
||||
# Give FTL 120 seconds to gracefully stop
|
||||
i=1
|
||||
while [ "${i}" -le 60 ]; do
|
||||
while [ "${i}" -le 120 ]; do
|
||||
if ! is_running; then
|
||||
break
|
||||
fi
|
||||
|
||||
@@ -28,7 +28,7 @@ ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStopPost=+/opt/pihole/pihole-FTL-poststop.sh
|
||||
|
||||
# Use graceful shutdown with a reasonable timeout
|
||||
TimeoutStopSec=60s
|
||||
TimeoutStopSec=120s
|
||||
|
||||
# Make /usr, /boot, /etc and possibly some more folders read-only...
|
||||
ProtectSystem=full
|
||||
|
||||
@@ -1963,9 +1963,18 @@ get_binary_name() {
|
||||
|
||||
# If the machine is aarch64 (armv8)
|
||||
if [[ "${machine}" == "aarch64" ]]; then
|
||||
# If AArch64 is found (e.g., BCM2711 in Raspberry Pi 4)
|
||||
printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}"
|
||||
l_binary="pihole-FTL-arm64"
|
||||
if [[ "$(getconf LONG_BIT)" == "64" ]]; then
|
||||
# If the OS is 64 bit, we use the arm64 binary
|
||||
printf "%b %b Detected AArch64 (64 Bit ARM) architecture\\n" "${OVER}" "${TICK}"
|
||||
l_binary="pihole-FTL-arm64"
|
||||
else
|
||||
# If the OS is 32 bit, we use the armv7 binary (aarch64 is actually armv8)
|
||||
# Even though the machine is 64 bit capable, this makes debugging
|
||||
# very hard as 32bit tools like gdb, etc. cannot analyze the 64 bit
|
||||
# binary. See FTL issue #2494 for such an example.
|
||||
printf "%b %b Detected AArch64 (64 Bit ARM) architecture with 32 bit OS\\n" "${OVER}" "${TICK}"
|
||||
l_binary="pihole-FTL-armv7"
|
||||
fi
|
||||
elif [[ "${machine}" == "arm"* ]]; then
|
||||
# ARM 32 bit
|
||||
# Get supported processor from other binaries installed on the system
|
||||
|
||||
57
gravity.sh
57
gravity.sh
@@ -612,7 +612,7 @@ compareLists() {
|
||||
gravity_DownloadBlocklistFromUrl() {
|
||||
local url="${1}" adlistID="${2}" saveLocation="${3}" compression="${4}" gravity_type="${5}" domain="${6}"
|
||||
local listCurlBuffer str httpCode success="" ip customUpstreamResolver=""
|
||||
local file_path permissions ip_addr port blocked=false download=true
|
||||
local file_path ip_addr port blocked=false download=true
|
||||
# modifiedOptions is an array to store all the options used to check if the adlist has been changed upstream
|
||||
local modifiedOptions=()
|
||||
|
||||
@@ -721,29 +721,40 @@ gravity_DownloadBlocklistFromUrl() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we are going to "download" a local file, we first check if the target
|
||||
# file has a+r permission. We explicitly check for all+read because we want
|
||||
# to make sure that the file is readable by everyone and not just the user
|
||||
# running the script.
|
||||
if [[ $url == "file://"* ]]; then
|
||||
# If we "download" a local file (file://), verify read access before using it.
|
||||
# When running as root (e.g., via pihole -g), check that the 'pihole' user can read the file
|
||||
# to match the effective runtime user of FTL; otherwise, check the current user's read access
|
||||
# (e.g., in Docker or when invoked by a non-root user). The target must
|
||||
# resolve to a regular file and be readable by the evaluated user.
|
||||
if [[ "${url}" == "file:/"* ]]; then
|
||||
# Get the file path
|
||||
file_path=$(echo "$url" | cut -d'/' -f3-)
|
||||
file_path=$(echo "${url}" | cut -d'/' -f3-)
|
||||
# Check if the file exists and is a regular file (i.e. not a socket, fifo, tty, block). Might still be a symlink.
|
||||
if [[ ! -f $file_path ]]; then
|
||||
# Output that the file does not exist
|
||||
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
||||
download=false
|
||||
else
|
||||
# Check if the file or a file referenced by the symlink has a+r permissions
|
||||
permissions=$(stat -L -c "%a" "$file_path")
|
||||
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
||||
# Output that we are using the local file
|
||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||
else
|
||||
# Output that the file does not have the correct permissions
|
||||
echo -e "${OVER} ${CROSS} Cannot read file (file needs to have a+r permission)"
|
||||
if [[ ! -f ${file_path} ]]; then
|
||||
# Output that the file does not exist
|
||||
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
||||
download=false
|
||||
fi
|
||||
else
|
||||
if [ "$(id -un)" == "root" ]; then
|
||||
# If we are root, we need to check if the pihole user has read permission
|
||||
# otherwise, we might read files that the pihole user should not be able to read
|
||||
if sudo -u pihole test -r "${file_path}"; then
|
||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||
else
|
||||
echo -e "${OVER} ${CROSS} Cannot read file (user 'pihole' lacks read permission)"
|
||||
download=false
|
||||
fi
|
||||
else
|
||||
# If we are not root, we just check if the current user has read permission
|
||||
if [[ -r "${file_path}" ]]; then
|
||||
# Output that we are using the local file
|
||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||
else
|
||||
# Output that the file is not readable by the current user
|
||||
echo -e "${OVER} ${CROSS} Cannot read file (current user '$(id -un)' lacks read permission)"
|
||||
download=false
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -811,6 +822,10 @@ gravity_DownloadBlocklistFromUrl() {
|
||||
fix_owner_permissions "${saveLocation}"
|
||||
# Compare lists if they are identical
|
||||
compareLists "${adlistID}" "${saveLocation}"
|
||||
# Set permissions for the *.etag file
|
||||
if [[ -f "${saveLocation}.etag" ]]; then
|
||||
fix_owner_permissions "${saveLocation}.etag"
|
||||
fi
|
||||
# Add domains to database table file
|
||||
pihole-FTL "${gravity_type}" parseList "${saveLocation}" "${gravityTEMPfile}" "${adlistID}"
|
||||
done="true"
|
||||
|
||||
@@ -2,6 +2,7 @@ def test_key_val_replacement_works(host):
|
||||
"""Confirms addOrEditKeyValPair either adds or replaces a key value pair in a given file"""
|
||||
host.run("""
|
||||
source /opt/pihole/utils.sh
|
||||
touch ./testoutput
|
||||
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1"
|
||||
addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2"
|
||||
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value3"
|
||||
|
||||
Reference in New Issue
Block a user