[pve-devel] [PATCH][pve-manager] Changes set_userpasswd method
Dietmar Maurer
dietmar at proxmox.com
Mon Nov 11 06:25:50 CET 2013
Please can you use 'git send-email' to send patches? Also add correct 'signed-of-by' entries.
> diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm
> index a16d4fc..7788f66 100644
> --- a/PVE/OpenVZ.pm
> +++ b/PVE/OpenVZ.pm
> @@ -1244,13 +1244,13 @@ sub replacepw {
> }
>
> sub set_rootpasswd {
> - my ($privatedir, $opt_rootpasswd) = @_;
> + my ($opt_rootpasswd, $rootdir) = @_;
>
> - my $pwfile = "$privatedir/etc/passwd";
> + my $pwfile = "$rootdir/etc/passwd";
>
> return if ! -f $pwfile;
>
> - my $shadow = "$privatedir/etc/shadow";
> + my $shadow = "$rootdir/etc/shadow";
>
> if ($opt_rootpasswd !~ m/^\$/) {
> my $time = substr (Digest::SHA::sha1_base64 (time), 0, 8);
>
>
>
> diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm
> index 06fe60b..60ef124 100644
> --- a/PVE/API2/OpenVZ.pm
> +++ b/PVE/API2/OpenVZ.pm
> @@ -406,15 +406,23 @@ __PACKAGE__->register_method({
> }
>
> } else {
> - PVE::Tools::file_set_contents($basecfg_fn, $rawconf);
> - my $cmd = ['vzctl', '--skiplock', 'create', $vmid,
> - '--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)
> - if defined($password);
> + PVE::Tools::file_set_contents($basecfg_fn, $rawconf);
why do you change indentation here?
> + my $cmd = ['vzctl', '--skiplock', 'create', $vmid,
> + '--ostemplate', $ostmp, '--private', $private];
Variable '$ostmp' is undefined!
> + run_command($cmd);
> + my $rootdir = PVE::OpenVZ::get_rootdir($conf, $vmid);
> +
> + $cmd = ['/usr/sbin/vzctl', '--skiplock', 'mount', $vmid];
> + run_command($cmd);
> + die "Cannot mount $vmid" if !PVE::OpenVZ::check_mounted($conf,
> $vmid);
> +
> + # hack: vzctl '--userpasswd' starts the CT, but we want
> + # to avoid that for create
> + PVE::OpenVZ::set_rootpasswd($password, $rootdir)
> + if defined($password);
> +
> + $cmd = ['/usr/sbin/vzctl', '--skiplock', 'umount', $vmid];
> + run_command($cmd);
> }
>
> PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
>
Please test you patches before sending them to the list.
- Dietmar
More information about the pve-devel
mailing list