Current solution with changing passwd and shadow files in VM private directories doesn't work with PLOOP. We MUST use vzctl set --userpasswd
diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm index 06fe60b..13fdb5a 100644 --- a/PVE/API2/OpenVZ.pm +++ b/PVE/API2/OpenVZ.pm @@ -411,9 +411,7 @@ __PACKAGE__->register_method({ '--ostemplate', $archive, '--private', $private]; run_command($cmd); - # hack: vzctl '--userpasswd' starts the CT, but we want - # to avoid that for create - PVE::OpenVZ::set_rootpasswd($private, $password) + PVE::OpenVZ::set_rootpassword($vmid, $password) if defined($password); } diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm index a16d4fc..90b0479 100644 --- a/PVE/OpenVZ.pm +++ b/PVE/OpenVZ.pm @@ -1243,6 +1243,19 @@ sub replacepw { } } +sub set_rootpassword { + my ($vmid, $opt_rootpasswd, $login) = @_; + + if (!defined($login)){ + $login = "root"; + } + + my $cmd = ['/usr/sbin/vzctl', '--skiplock', 'set', $vmid, '--userpasswd', "$login:$opt_rootpasswd", '--save']; + eval { PVE::Tools::run_command($cmd); }; + my $err = $@; + syslog('err', $err) if $err; +} + sub set_rootpasswd { my ($privatedir, $opt_rootpasswd) = @_; _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel