Skip to content

Commit

Permalink
More checks when downloading from file:// scheme (pi-hole#5620)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschaper committed Mar 28, 2024
2 parents 47998e1 + d80fcf2 commit 8cfccf9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gravity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ gravity_DownloadBlocklistFromUrl() {
if [[ $url == "file://"* ]]; then
# Get the file path
file_path=$(echo "$url" | cut -d'/' -f3-)
# Check if the file exists
if [[ ! -e $file_path ]]; then
# 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 has a+r permissions
permissions=$(stat -c "%a" "$file_path")
# 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}"
Expand Down

0 comments on commit 8cfccf9

Please sign in to comment.