]> git.proxmox.com Git - qemu-server.git/commitdiff
cloud-init: pre-hash passwords
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 8 Mar 2018 13:57:19 +0000 (14:57 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 8 Mar 2018 13:59:27 +0000 (14:59 +0100)
We don't leave this up to cloud-init as we don't want
un-hashed values at all in our configs.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
PVE/API2/Qemu.pm

index e8152cc3695d837b17629e8941d90f262fd6d17e..0174feb32d7fd99f76fa6d21bcc34d62df04a084 100644 (file)
@@ -941,6 +941,12 @@ my $update_vm_api  = sub {
        PVE::Tools::validate_ssh_public_keys($ssh_keys);
     }
 
+    if (defined(my $cipassword = $param->{cipassword})) {
+       # Same logic as in cloud-init (but with the regex fixed...)
+       $param->{cipassword} = PVE::Tools::encrypt_pw($cipassword)
+           if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/;
+    }
+
     die "no options specified\n" if !$delete_str && !$revert_str && !scalar(keys %$param);
 
     my $storecfg = PVE::Storage::config();