]> git.proxmox.com Git - pve-manager.git/commitdiff
restrict vzdump cron options
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 17 Oct 2016 08:14:22 +0000 (10:14 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 17 Oct 2016 08:36:06 +0000 (10:36 +0200)
modeled after the VZDump API path, but since we are
restricted to Sys.Modify users already, we only need to
restrict these three options.

PVE/API2/Backup.pm

index e86b72390bc5f12d0a82b58f1aa89f669f6d5273..3dfe8a0d5f8590f375757030d53bea288681d4bc 100644 (file)
@@ -233,6 +233,7 @@ __PACKAGE__->register_method({
     description => "Create new vzdump backup job.",
     permissions => {
        check => ['perm', '/', ['Sys.Modify']],
+       description => "The 'tmpdir', 'dumpdir' and 'script' parameters are additionally restricted to the 'root\@pam' user.",
     },
     parameters => {
        additionalProperties => 0,
@@ -264,6 +265,11 @@ __PACKAGE__->register_method({
        my $rpcenv = PVE::RPCEnvironment::get();
        my $user = $rpcenv->get_user();
 
+       foreach my $key (qw(tmpdir dumpdir script)) {
+           raise_param_exc({ $key => "Only root may set this option."})
+               if defined($param->{$key}) && ($user ne 'root@pam');
+       }
+
        my $data = cfs_read_file('vzdump.cron');
 
        $param->{dow} = 'mon,tue,wed,thu,fri,sat,sun' if !defined($param->{dow});