public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Oguz Bektas <o.bektas@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 container 1/2] fix #3313: recover unprivileged bit from old config during pct restore
Date: Thu, 25 Feb 2021 15:11:16 +0100	[thread overview]
Message-ID: <20210225141117.855118-2-o.bektas@proxmox.com> (raw)
In-Reply-To: <20210225141117.855118-1-o.bektas@proxmox.com>

since pct defaults to privileged containers, it restores the container
as privileged when `--unprivileged 1` is not passed.

instead we should check the old configuration and retrieve it from
there.

this way, when one creates an unprivileged container on GUI, it will be
still restored as unprivileged via pct (without having to pass
`--unprivileged`)

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---

v3->v4:
* split


 src/PVE/API2/LXC.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 8ce462f..04456a8 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -362,6 +362,9 @@ __PACKAGE__->register_method({
 			# '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->{unprivileged} = $orig_conf->{unprivileged}
+			    if !defined($unprivileged) && defined($orig_conf->{unprivileged});
 		    }
 		}
 		if ($storage_only_mode) {
-- 
2.20.1




  reply	other threads:[~2021-02-25 14:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 14:11 [pve-devel] [PATCH v4 container 0/2] bug fixes for " Oguz Bektas
2021-02-25 14:11 ` Oguz Bektas [this message]
2021-02-25 14:11 ` [pve-devel] [PATCH v4 container 2/2] do not limit restoring container templates to root Oguz Bektas
2021-02-25 18:23 ` [pve-devel] applied-series: [PATCH v4 container 0/2] bug fixes for pct restore Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210225141117.855118-2-o.bektas@proxmox.com \
    --to=o.bektas@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal