mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
More checks when downloading from file:// scheme
Signed-off-by: Orazio <22700499+orazioedoardo@users.noreply.github.com>
This commit is contained in:
parent
74a44cad7a
commit
d80fcf2e62
1 changed files with 4 additions and 4 deletions
|
@ -567,14 +567,14 @@ gravity_DownloadBlocklistFromUrl() {
|
||||||
if [[ $url == "file://"* ]]; then
|
if [[ $url == "file://"* ]]; then
|
||||||
# Get the file path
|
# Get the file path
|
||||||
file_path=$(echo "$url" | cut -d'/' -f3-)
|
file_path=$(echo "$url" | cut -d'/' -f3-)
|
||||||
# Check if the file exists
|
# Check if the file exists and is a regular file (i.e. not a socket, fifo, tty, block). Might still be a symlink.
|
||||||
if [[ ! -e $file_path ]]; then
|
if [[ ! -f $file_path ]]; then
|
||||||
# Output that the file does not exist
|
# Output that the file does not exist
|
||||||
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
echo -e "${OVER} ${CROSS} ${file_path} does not exist"
|
||||||
download=false
|
download=false
|
||||||
else
|
else
|
||||||
# Check if the file has a+r permissions
|
# Check if the file or a file referenced by the symlink has a+r permissions
|
||||||
permissions=$(stat -c "%a" "$file_path")
|
permissions=$(stat -L -c "%a" "$file_path")
|
||||||
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
if [[ $permissions == *4 || $permissions == *5 || $permissions == *6 || $permissions == *7 ]]; then
|
||||||
# Output that we are using the local file
|
# Output that we are using the local file
|
||||||
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
echo -e "${OVER} ${INFO} Using local file ${file_path}"
|
||||||
|
|
Loading…
Reference in a new issue