]> git.proxmox.com Git - pve-manager.git/commit - PVE/VZDump.pm
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)
commit58f763e1aae15e5d5315a9823b910c353208694f
tree27d7f9b73e3d49cbe432d20440589c21ddd05fc2
parentcdb638259d2687eca95dbf7f1961c7a4e40f4603
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