]> git.proxmox.com Git - pve-container.git/commitdiff
fix #2117: don't keep custom idmap in pct pipe restore
authorOguz Bektas <o.bektas@proxmox.com>
Mon, 4 Mar 2019 10:02:53 +0000 (11:02 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Mar 2019 11:26:22 +0000 (12:26 +0100)
while doing a pct restore operation, custom id mappings were being
obtained from the archive file to be used in the newly created container.
this fails when using pipe restore, since there is no file for the
mappings to be recovered from.

Co-Authored by: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
src/PVE/API2/LXC.pm

index 27d26d5be5ceb480fc6cc4379e4037008b806cae..1cc29790b431a4ba070ed6f398c818804c1e0006 100644 (file)
@@ -331,10 +331,11 @@ __PACKAGE__->register_method({
            my $vollist = [];
            eval {
                my $orig_mp_param; # only used if $restore
+               my $orig_conf;
                if ($restore) {
                    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
-                   (my $orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
-                   if ($is_root) {
+                   if ($is_root && $archive ne '-') {
+                       ($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
                        # When we're root call 'restore_configuration' with ristricted=0,
                        # 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
@@ -344,6 +345,9 @@ __PACKAGE__->register_method({
                }
                if ($storage_only_mode) {
                    if ($restore) {
+                       if (!defined $orig_mp_param) {
+                           (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
+                       }
                        $mp_param = $orig_mp_param;
                        die "rootfs configuration could not be recovered, please check and specify manually!\n"
                            if !defined($mp_param->{rootfs});