]> git.proxmox.com Git - pve-manager-legacy.git/commit
fix #3430: handle hook script paths better
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 17 May 2021 07:46:47 +0000 (09:46 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 17 May 2021 07:49:34 +0000 (09:49 +0200)
commita4b186637499ab664773474d4aa3a14e20517ed9
treeb5845fcc633dea71a145140746c5500b73d88547
parent2c3e634d7d5aace6d261e7ce1ca1d332d96bd5ba
fix #3430: handle hook script paths better

if passing the hook script command as string, it might get interpreted
as shell command with side-effects. this is pretty harmless, since only
root is allowed to set the script parameter anyway, but making it more
robust and future-proof does not hurt.

tested with a reproducer of "/bin/echo $(touch $(whoami))" as script
parameter, with a file with that name existing, being executable and
having the following contents:

----8<----
echo "hello from hook script"
---->8----

without this change, the hookscript itself is not executed, but
'/bin/sh -c "/bin/echo $(touch $(whoami)) job"' and similar calls are,
which cause the file 'root' to be touched in the current working
directory of the vzdump process (or task worker).

with this change, the file is executed as is without any side-effects of
shell commands in the file name, and the 'hello from hook script' lines
are printed whenever the hook script is called by vzdump.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/VZDump.pm