From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D722669F6F for ; Thu, 25 Feb 2021 15:13:58 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D40AC353E8 for ; Thu, 25 Feb 2021 15:13:28 +0100 (CET) Received: from gaia.proxmox.com (212-186-127-178.static.upcbusiness.at [212.186.127.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 46AA9353DD for ; Thu, 25 Feb 2021 15:13:28 +0100 (CET) Received: from gaia.proxmox.com (localhost.localdomain [127.0.0.1]) by gaia.proxmox.com (8.15.2/8.15.2/Debian-14~deb10u1) with ESMTP id 11PEBIi6855179; Thu, 25 Feb 2021 15:11:18 +0100 Received: (from oguz@localhost) by gaia.proxmox.com (8.15.2/8.15.2/Submit) id 11PEBIJH855178; Thu, 25 Feb 2021 15:11:18 +0100 From: Oguz Bektas To: pve-devel@lists.proxmox.com Date: Thu, 25 Feb 2021 15:11:17 +0100 Message-Id: <20210225141117.855118-3-o.bektas@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210225141117.855118-1-o.bektas@proxmox.com> References: <20210225141117.855118-1-o.bektas@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.328 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.001 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH v4 container 2/2] do not limit restoring container templates to root X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 14:13:58 -0000 but still keep the lxc.* parameters limited to root note: $orig_mp_param isn't protected by $is_root, but when it's used we make another recover_config() call on the archive file Signed-off-by: Oguz Bektas --- v3->v4: * split src/PVE/API2/LXC.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 04456a8..df0cc88 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -352,7 +352,7 @@ __PACKAGE__->register_method({ my $orig_mp_param; # only used if $restore if ($restore) { die "can't overwrite running container\n" if PVE::LXC::check_running($vmid); - if ($is_root && $archive ne '-') { + if ($archive ne '-') { my $orig_conf; print "recovering backed-up configuration from '$archive'\n"; ($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($storage_cfg, $archive, $vmid); @@ -361,7 +361,7 @@ __PACKAGE__->register_method({ # causing it to restore the raw lxc entries, among which there may be # 'lxc.idmap' entries. We need to make sure that the extracted contents # of the container match up with the restored configuration afterwards: - $conf->{lxc} = $orig_conf->{lxc}; + $conf->{lxc} = $orig_conf->{lxc} if $is_root; $conf->{unprivileged} = $orig_conf->{unprivileged} if !defined($unprivileged) && defined($orig_conf->{unprivileged}); -- 2.20.1