<div dir="ltr"><div>From 8118b81626a73fcb83b6b21d498b6724c4b63817 Mon Sep 17 00:00:00 2001</div><div>From: Igor Shestakov <<a href="mailto:shinespb@gmail.com">shinespb@gmail.com</a>></div><div>Date: Mon, 16 Dec 2013 17:39:09 +0400</div>
<div>Subject: [PATCH] changed set_rootpasswd method for ploop support</div><div><br></div><div><br></div><div>Signed-off-by: Igor Shestakov <<a href="mailto:shinespb@gmail.com">shinespb@gmail.com</a>></div><div>---</div>
<div>šPVE/API2/OpenVZ.pm | 12 +++++++++++-</div><div>šPVE/OpenVZ.pm š š š| š7 ++++---</div><div>š2 files changed, 15 insertions(+), 4 deletions(-)</div><div><br></div><div>diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm</div>
<div>index d9993fd..c5707e3 100644</div><div>--- a/PVE/API2/OpenVZ.pm</div><div>+++ b/PVE/API2/OpenVZ.pm</div><div>@@ -413,10 +413,20 @@ __PACKAGE__->register_method({</div><div>š<span class="" style="white-space:pre"> </span></div>
<div>š<span class="" style="white-space:pre"> </span># hack: vzctl '--userpasswd' starts the CT, but we wantš</div><div>š<span class="" style="white-space:pre"> </span># to avoid that for create</div><div>-<span class="" style="white-space:pre"> </span>PVE::OpenVZ::set_rootpasswd($private, $password)š</div>
<div>+<span class="" style="white-space:pre"> </span>my $rootdir = PVE::OpenVZ::get_rootdir($conf, $vmid);</div><div>+</div><div>+<span class="" style="white-space:pre"> </span>#mount container(for ploop support)</div>
<div>
+<span class="" style="white-space:pre"> </span>$cmd = ['/usr/sbin/vzctl', '--skiplock', 'mount', $vmid];</div><div>+<span class="" style="white-space:pre"> </span>run_command($cmd);</div><div>+<span class="" style="white-space:pre"> </span>die "Cannot mount $vmid" if !PVE::OpenVZ::check_mounted($conf, $vmid);</div>
<div>+</div><div>+<span class="" style="white-space:pre"> </span>PVE::OpenVZ::set_rootpasswd($password, $rootdir)š</div><div>š<span class="" style="white-space:pre"> </span> š šif defined($password);</div><div>š<span class="" style="white-space:pre"> </span> š š}</div>
<div>š</div><div>+<span class="" style="white-space:pre"> </span> š š$cmd = ['/usr/sbin/vzctl', '--skiplock', 'umount', $vmid];</div><div>+<span class="" style="white-space:pre"> </span> š šrun_command($cmd);</div>
<div>+</div><div>š<span class="" style="white-space:pre"> </span> š šPVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;</div><div>š<span class="" style="white-space:pre"> </span>};</div><div>š</div><div>diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm</div>
<div>index 2b92979..c01665d 100644</div><div>--- a/PVE/OpenVZ.pm</div><div>+++ b/PVE/OpenVZ.pm</div><div>@@ -1243,14 +1243,15 @@ sub replacepw {</div><div>š š š}<span class="" style="white-space:pre"> </span></div><div>š}</div>
<div>š</div><div>+</div><div>šsub set_rootpasswd {</div><div>- š šmy ($privatedir, $opt_rootpasswd) = @_;</div><div>+ š šmy ($opt_rootpasswd, $rootdir) = @_;</div><div>š</div><div>- š šmy $pwfile = "$privatedir/etc/passwd";</div>
<div>+ š šmy $pwfile = "$rootdir/etc/passwd";</div><div>š</div><div>š š šreturn if ! -f $pwfile;</div><div>š</div><div>- š šmy $shadow = "$privatedir/etc/shadow";</div><div>+ š šmy $shadow = "$rootdir/etc/shadow";</div>
<div>š</div><div>š š šif ($opt_rootpasswd !~ m/^\$/) {</div><div>š<span class="" style="white-space:pre"> </span>my $time = substr (Digest::SHA::sha1_base64 (time), 0, 8);</div><div>--š</div><div>1.8.1.msysgit.1</div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 9:46 AM, Dietmar Maurer <span dir="ltr"><<a href="mailto:dietmar@proxmox.com" target="_blank">dietmar@proxmox.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> Can we apply this patch as preparation for future ploop use?<br>
> If yes, later(this week) i send you correct patch.<br>
<br>
</div>Yes, but only if it works without problems. So please test your code before sending<br>
patches to the list.<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>ó Õ×ÁÖÅÎÉÅÍ, ûÅÓÔÁËÏ× éÇÏÒØ<br>óÅÔØ ÄÁÔÁ-ÃÅÎÔÒÏ× "óÅÌÅËÔÅÌ"
</div>