check config file permissions before sourcing

This commit is contained in:
2026-08-22 06:10:50 +02:00
parent 6c7db396b2
commit 3d5757effc
+8
View File
@@ -264,6 +264,12 @@ while (( $# > 0 )); do
done done
if [ -f "$cfgfile" ]; then
perms=$(stat -c '%a' "$cfgfile")
(( 8#$perms & 0022 )) && echo "Error: $cfgfile is writable by group or others!" >&2 && exit 202
(( 8#$perms & 0007 )) && echo "Warning: $cfgfile is readable by others!" >&2
fi
if $FULL_HELP; then if $FULL_HELP; then
[ -f "$cfgfile" ] && source "$cfgfile" [ -f "$cfgfile" ] && source "$cfgfile"
PBC=${PBC:-/usr/local/bin/proxmox-backup-client} PBC=${PBC:-/usr/local/bin/proxmox-backup-client}
@@ -280,6 +286,8 @@ if [ "$action" == 'install' ]; then
! command -v "$exe" >/dev/null && echo "Error: $exe executable not found!" >&2 && exit 200 ! command -v "$exe" >/dev/null && echo "Error: $exe executable not found!" >&2 && exit 200
done done
else else
[ ! -f "$cfgfile" ] && echo "Error: $cfgfile: no such file" >&2 && exit 201
[ ! -r "$cfgfile" ] && echo "Error: $cfgfile: not readable" >&2 && exit 201
source "$cfgfile" || exit $? source "$cfgfile" || exit $?
PBC=${PBC:-/usr/local/bin/proxmox-backup-client} PBC=${PBC:-/usr/local/bin/proxmox-backup-client}
[ ! -f "$PBC" ] && echo "Error: $PBC: no such file" >&2 && exit 200 [ ! -f "$PBC" ] && echo "Error: $PBC: no such file" >&2 && exit 200