[pve-devel] [PATCH pve-container 2/2] setup: fix ssh-key perms lost with the rewrite

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Nov 6 13:09:23 CET 2015


---
 src/PVE/LXC/Setup.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 9e80088..89bb4ee 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -183,8 +183,8 @@ sub rewrite_ssh_host_keys {
 	my $cmd = ['ssh-keygen', '-q', '-f', $file, '-t', $keytype,
 		   '-N', '', '-C', "root\@$hostname"];
 	PVE::Tools::run_command($cmd);
-	$keyfiles->{"/etc/ssh/$basename"} = PVE::Tools::file_get_contents($file);
-	$keyfiles->{"/etc/ssh/$basename.pub"} = PVE::Tools::file_get_contents("$file.pub");
+	$keyfiles->{"/etc/ssh/$basename"} = [PVE::Tools::file_get_contents($file), 0600];
+	$keyfiles->{"/etc/ssh/$basename.pub"} = [PVE::Tools::file_get_contents("$file.pub"), 0644];
 	unlink $file;
 	unlink "$file.pub";
     }
@@ -193,7 +193,7 @@ sub rewrite_ssh_host_keys {
 
     my $code = sub {
 	foreach my $file (keys %$keyfiles) {
-	    $plugin->ct_file_set_contents($file, $keyfiles->{$file});
+	    $plugin->ct_file_set_contents($file, @{$keyfiles->{$file}});
 	}
     };
     $self->protected_call($code);
-- 
2.1.4





More information about the pve-devel mailing list