]> git.proxmox.com Git - pve-container.git/commitdiff
fix #3313: restore: keep unprivileged status from archive config
authorOguz Bektas <o.bektas@proxmox.com>
Thu, 25 Feb 2021 14:11:16 +0000 (15:11 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 25 Feb 2021 14:24:06 +0000 (15:24 +0100)
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, it will be
still be unprivileged after restore, if not overwritten by API
arguments.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/API2/LXC.pm

index 6af2bbfc7fd93230958dc659fbcbe724dc46939a..df0cc88c274602c519a5dcfdd758ab0cfc560ff2 100644 (file)
@@ -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} if $is_root;
+
+                       $conf->{unprivileged} = $orig_conf->{unprivileged}
+                           if !defined($unprivileged) && defined($orig_conf->{unprivileged});
                    }
                }
                if ($storage_only_mode) {