[pve-devel] [PATCH][pve-manager] Changes set_userpasswd method
Игорь Шестаков
shine at selectel.ru
Mon Dec 16 16:35:32 CET 2013
>From 8118b81626a73fcb83b6b21d498b6724c4b63817 Mon Sep 17 00:00:00 2001
From: Igor Shestakov <shinespb at gmail.com>
Date: Mon, 16 Dec 2013 17:39:09 +0400
Subject: [PATCH] changed set_rootpasswd method for ploop support
Signed-off-by: Igor Shestakov <shinespb at gmail.com>
---
PVE/API2/OpenVZ.pm | 12 +++++++++++-
PVE/OpenVZ.pm | 7 ++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm
index d9993fd..c5707e3 100644
--- a/PVE/API2/OpenVZ.pm
+++ b/PVE/API2/OpenVZ.pm
@@ -413,10 +413,20 @@ __PACKAGE__->register_method({
# hack: vzctl '--userpasswd' starts the CT, but we want
# to avoid that for create
- PVE::OpenVZ::set_rootpasswd($private, $password)
+ my $rootdir = PVE::OpenVZ::get_rootdir($conf, $vmid);
+
+ #mount container(for ploop support)
+ $cmd = ['/usr/sbin/vzctl', '--skiplock', 'mount', $vmid];
+ run_command($cmd);
+ die "Cannot mount $vmid" if !PVE::OpenVZ::check_mounted($conf, $vmid);
+
+ 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;
};
diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm
index 2b92979..c01665d 100644
--- a/PVE/OpenVZ.pm
+++ b/PVE/OpenVZ.pm
@@ -1243,14 +1243,15 @@ 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);
--
1.8.1.msysgit.1
On Fri, Nov 15, 2013 at 9:46 AM, Dietmar Maurer <dietmar at proxmox.com> wrote:
> > Can we apply this patch as preparation for future ploop use?
> > If yes, later(this week) i send you correct patch.
>
> Yes, but only if it works without problems. So please test your code
> before sending
> patches to the list.
>
>
--
С уважением, Шестаков Игорь
Сеть дата-центров "Селектел"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20131216/7753c850/attachment.htm>
More information about the pve-devel
mailing list