* [pve-devel] [PATCH container] Fix bug #6040 in the exclusion pattern of tar
@ 2025-01-04 18:47 Orwa Diraneyya via pve-devel
2025-02-13 10:15 ` Fabian Grünbichler
0 siblings, 1 reply; 2+ messages in thread
From: Orwa Diraneyya via pve-devel @ 2025-01-04 18:47 UTC (permalink / raw)
To: pve-devel; +Cc: Orwa Diraneyya, Orwa Diraneyya
[-- Attachment #1: Type: message/rfc822, Size: 4470 bytes --]
From: Orwa Diraneyya <info@orwa.tech>
To: pve-devel@lists.proxmox.com
Cc: Orwa Diraneyya <diraneyyaorwa@gmail.com>
Subject: [PATCH container] Fix bug #6040 in the exclusion pattern of tar
Date: Sat, 4 Jan 2025 19:47:26 +0100
Message-ID: <20250104184726.95658-1-info@orwa.tech>
From: Orwa Diraneyya <diraneyyaorwa@gmail.com>
After this fix, users of Proxmox will be able to
use the root filesystem tarballs found publicly
(e.g. at https://cloud-images.ubuntu.com/) as LXC
container templates.
Currently, this results in a container-creation
failure due to the root folder `/dev` exclusion
pattern being ineffective.
The bugfix is also announced on the dev mailing
list (mailman.74.1735960093.441.pve-devel)
Signed-off-by: Orwa Diraneyya <diraneyyaorwa@gmail.com>
---
src/PVE/LXC/Create.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 8c8cb9a..4d0d11e 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -75,7 +75,7 @@ my sub restore_tar_archive_command {
# *sigh*, gnu...
push @$cmd, '--skip-old-files';
push @$cmd, '--anchored';
- push @$cmd, '--exclude' , './dev/*';
+ push @$cmd, '--exclude' , 'dev/*';
if (defined($bwlimit)) {
$cmd = [ ['cstream', '-t', $bwlimit*1024], $cmd ];
--
2.46.0
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pve-devel] [PATCH container] Fix bug #6040 in the exclusion pattern of tar
2025-01-04 18:47 [pve-devel] [PATCH container] Fix bug #6040 in the exclusion pattern of tar Orwa Diraneyya via pve-devel
@ 2025-02-13 10:15 ` Fabian Grünbichler
0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2025-02-13 10:15 UTC (permalink / raw)
To: Proxmox VE development discussion; +Cc: Orwa Diraneyya
> Orwa Diraneyya via pve-devel <pve-devel@lists.proxmox.com> hat am 04.01.2025 19:47 CET geschrieben:
> From: Orwa Diraneyya <diraneyyaorwa@gmail.com>
>
> After this fix, users of Proxmox will be able to
> use the root filesystem tarballs found publicly
> (e.g. at https://cloud-images.ubuntu.com/) as LXC
> container templates.
>
> Currently, this results in a container-creation
> failure due to the root folder `/dev` exclusion
> pattern being ineffective.
>
> The bugfix is also announced on the dev mailing
> list (mailman.74.1735960093.441.pve-devel)
>
> Signed-off-by: Orwa Diraneyya <diraneyyaorwa@gmail.com>
> ---
> src/PVE/LXC/Create.pm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
> index 8c8cb9a..4d0d11e 100644
> --- a/src/PVE/LXC/Create.pm
> +++ b/src/PVE/LXC/Create.pm
> @@ -75,7 +75,7 @@ my sub restore_tar_archive_command {
> # *sigh*, gnu...
> push @$cmd, '--skip-old-files';
> push @$cmd, '--anchored';
> - push @$cmd, '--exclude' , './dev/*';
> + push @$cmd, '--exclude' , 'dev/*';
Thanks for your patch!
Unfortunately, this is not the correct way to tackle this - because of `--anchored`, `./dev/*` and `dev/*` match different things:
$ mkdir dev; touch dev/test
$ ls dev
test
$ tar cf test.tar ./dev
$ tar tf test.tar
./dev/
./dev/test
$ rm -rf extract; mkdir extract
$ tar -xf test.tar -C extract --anchored --exclude './dev/*' -v
./dev/
$ rm -rf extract; mkdir extract
$ tar -xf test.tar -C extract --anchored --exclude 'dev/*' -v
./dev/
./dev/test
Note how the tarball contains a relative dir ./dev with a file test inside (like our/most container templates), and how extracting it with the original exclusion pattern just extracts the empty dev dir, skipping its contents, while your proposed pattern extracts the contents as well.
The inverse is true for your tarball with the contents the other way round:
$ rm test.tar
$ tar cf test.tar dev
$ tar tf test.tar
dev/
dev/test
$ rm -rf extract; mkdir extract
$ tar -xf test.tar -C extract --anchored --exclude './dev/*' -v
dev/
dev/test
$ rm -rf extract; mkdir extract
$ tar -xf test.tar -C extract --anchored --exclude 'dev/*' -v
dev/
So what we actually want if we want to support both variants is to exclude *both* patterns.
Note that your original use case of just passing an image not intended for container consumption might still fail for other reasons ;) But such a patch would at least allow manually created templates that don't use the ./ prefix to work properly.
> if (defined($bwlimit)) {
> $cmd = [ ['cstream', '-t', $bwlimit*1024], $cmd ];
> --
> 2.46.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-13 10:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-04 18:47 [pve-devel] [PATCH container] Fix bug #6040 in the exclusion pattern of tar Orwa Diraneyya via pve-devel
2025-02-13 10:15 ` Fabian Grünbichler
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