From e770e6672fdb54c30a787d71043a84b010a8e67f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 19 Jun 2019 11:46:18 +0200 Subject: [PATCH 1/1] ticket: reorder calls when rotating MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit to shrink the window between the two file_set_contents calls. we don't need the mtimes to line up exactly since we have 300s of uncertainty anyway, but generating an RSA key could take a while ;) Signed-off-by: Fabian Grünbichler --- PVE/AccessControl.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PVE/AccessControl.pm b/PVE/AccessControl.pm index fff2df2..0132268 100644 --- a/PVE/AccessControl.pm +++ b/PVE/AccessControl.pm @@ -166,6 +166,7 @@ sub rotate_authkey { return if check_authkey(); my $old = get_pubkey(); + my $new = Crypt::OpenSSL::RSA->generate_key(2048); if ($old) { eval { @@ -175,7 +176,6 @@ sub rotate_authkey { die "Failed to store old auth key: $@\n" if $@; } - my $new = Crypt::OpenSSL::RSA->generate_key(2048); eval { my $pem = $new->get_public_key_x509_string(); PVE::Tools::file_set_contents($pve_auth_key_files->{pub}, $pem); -- 2.39.2