]> git.proxmox.com Git - pve-storage.git/commitdiff
fix #1427: Set file mode on uploaded templates/ISOs
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 13 Jun 2019 09:33:28 +0000 (11:33 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 13 Jun 2019 09:55:18 +0000 (11:55 +0200)
simply chmod the temp file before copying to the "correct" permission
mode, where all users with access to the directory can read the file,
to mirror the behavior one gets for a apl_download call.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/API2/Storage/Status.pm

index 9a5a95239e6fe495501eaed874eee94367d49cb3..a56a02b904adc447a543e380a1a7d99f2f3075be 100644 (file)
@@ -369,7 +369,7 @@ __PACKAGE__->register_method ({
                type => 'string',
            },
            tmpfilename => { 
-               description => "The source file name. This parameter is usually set by the REST handler. You can only overwrite it when connecting to the trustet port on localhost.",
+               description => "The source file name. This parameter is usually set by the REST handler. You can only overwrite it when connecting to the trusted port on localhost.",
                type => 'string',
                optional => 1,
            },
@@ -427,7 +427,10 @@ __PACKAGE__->register_method ({
        my $dest = "$path/$filename";
        my $dirname = dirname($dest);
 
-       # we simply overwrite when destination when file already exists
+       # best effort to match apl_download behaviour
+       chmod 0644, $tmpfilename;
+
+       # we simply overwrite when destination file already exists
 
        my $cmd;
        if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
@@ -447,7 +450,7 @@ __PACKAGE__->register_method ({
            PVE::Tools::run_command([@remcmd, '/bin/mkdir', '-p', '--', PVE::Tools::shell_quote($dirname)],
                                    errmsg => "mkdir failed");
  
-           $cmd = ['/usr/bin/scp', @ssh_options, '--', $tmpfilename, "[$remip]:" . PVE::Tools::shell_quote($dest)];
+           $cmd = ['/usr/bin/scp', @ssh_options, '-p', '--', $tmpfilename, "[$remip]:" . PVE::Tools::shell_quote($dest)];
        } else {
            PVE::Storage::activate_storage($cfg, $param->{storage});
            File::Path::make_path($dirname);