--- src/PVE/LXC.pm | 8 ++++++++ src/PVE/LXC/Create.pm | 4 +--- src/PVE/VZDump/LXC.pm | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 07ac4fc..ccab284 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2411,4 +2411,12 @@ sub parse_id_maps { return ($id_map, $rootuid, $rootgid); } +sub userns_command { + my ($id_map) = @_; + if (@$id_map) { + return ['lxc-usernsexec', (map { ('-m', join(':', @$_)) } @$id_map), '--']; + } + return []; +} + 1; diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm index 441b445..853a840 100644 --- a/src/PVE/LXC/Create.pm +++ b/src/PVE/LXC/Create.pm @@ -25,12 +25,10 @@ sub next_free_nbd_dev { sub restore_archive { my ($archive, $rootdir, $conf) = @_; - my $userns_cmd = []; - # we always use the same mapping: 'b:0:100000:65536' my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf); + my $userns_cmd = PVE::LXC::userns_command($id_map); if (@$id_map) { - $userns_cmd = ['lxc-usernsexec', (map { ('-m', join(':', @$_)) } @$id_map), '--']; PVE::Tools::run_command(['chown', '-R', "$rootuid:$rootgid", $rootdir]); } diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm index f138588..72ad9c0 100644 --- a/src/PVE/VZDump/LXC.pm +++ b/src/PVE/VZDump/LXC.pm @@ -105,6 +105,9 @@ sub prepare { $task->{hostname} = $conf->{'hostname'} || "CT$vmid"; + my ($id_map, $rootuid, $rootgid) = PVE::LXC::parse_id_maps($conf); + $task->{userns_cmd} = PVE::LXC::userns_command($id_map); + PVE::LXC::foreach_mountpoint($conf, sub { my ($name, $data) = @_; my $volid = $data->{volume}; @@ -278,7 +281,8 @@ sub archive { my $snapdir = $task->{snapdir}; my $tmpdir = $task->{tmpdir}; - my $tar = ['tar', 'cpf', '-', '--totals', + my $userns_cmd = $task->{userns_cmd}; + my $tar = [@$userns_cmd, 'tar', 'cpf', '-', '--totals', @$PVE::LXC::COMMON_TAR_FLAGS, '--one-file-system', '--warning=no-file-ignored']; -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel