[pve-devel] [PATCH][pve-manager] Changes set_userpasswd method

Игорь Шестаков shine at selectel.ru
Thu Nov 14 09:24:38 CET 2013


On Mon, Nov 11, 2013 at 9:25 AM, Dietmar Maurer <dietmar at proxmox.com> wrote:

> 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?
>

It seems, that my editor make it automatically..  Sorry


> > +             my $cmd = ['vzctl', '--skiplock', 'create', $vmid,
> > +                        '--ostemplate', $ostmp, '--private', $private];
>
> Variable '$ostmp' is undefined!
>

Sorry. New version of vzctl doesn't accept full path to templates location.
It's use only name of template. In my internal patches it tested and fixed.
I use local storage, and simply remove 'vztmpl', '.gz', and 'local:' from
ostemplate params. It pass only name of template(e.g ubuntu-12-03-i386).
And i test this patches on my lab.

Dont know how it affect on your network/cluster storages. I fix it with
change $ostmp to $archive in my commit.
And we need to discuss, how to solve this problem. We need to update vzctl
in new versions of proxmox and somehow pass vztemplate param. Or we need to
recompile vzctl(remove template download functions and change container
create function to support full path to templates)



>
> > +             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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pve.proxmox.com/pipermail/pve-devel/attachments/20131114/e9c3db3f/attachment.html>


More information about the pve-devel mailing list