From 3d5757effc2914b67e953319d187bc9c0b9098be8739faf01f606283a1d45709 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Sat, 22 Aug 2026 06:10:50 +0200 Subject: [PATCH] check config file permissions before sourcing --- pbc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pbc b/pbc index 94738b7..c50eb61 100755 --- a/pbc +++ b/pbc @@ -264,6 +264,12 @@ while (( $# > 0 )); do 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 [ -f "$cfgfile" ] && source "$cfgfile" 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 done 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 $? PBC=${PBC:-/usr/local/bin/proxmox-backup-client} [ ! -f "$PBC" ] && echo "Error: $PBC: no such file" >&2 && exit 200