Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtar produces corrupted archive with symlinks and --preserve-{xattrs,acl,flags} #628

Open
rezib opened this issue Mar 6, 2025 · 0 comments · May be fixed by #629
Open

dtar produces corrupted archive with symlinks and --preserve-{xattrs,acl,flags} #628

rezib opened this issue Mar 6, 2025 · 0 comments · May be fixed by #629

Comments

@rezib
Copy link
Contributor

rezib commented Mar 6, 2025

For example:

$ ls -lh test/
total 4.0K
-rw-rw-r-- 1 remi remi 4 Mar  6 14:07 file1
lrwxrwxrwx 1 remi remi 5 Mar  6 14:07 symlink1 -> file1
$ mpirun --mca mpi_abort_print_stack 1 -N 4 /home/remi/Documents/git/cea/env/bin/dtar --preserve-xattrs -cf archive.tar test
[2025-03-06T14:09:23] Walking /path/to/test
[2025-03-06T14:09:23] Walked 3 items in 0.003 secs (935.879 items/sec) ...
[2025-03-06T14:09:23] Walked 3 items in 0.003 seconds (888.621 items/sec)
[2025-03-06T14:09:23] Writing archive to archive.tar
[2025-03-06T14:09:23] Items: 3
[2025-03-06T14:09:23]   Directories: 1
[2025-03-06T14:09:23]   Files: 1
[2025-03-06T14:09:23]   Links: 1
[2025-03-06T14:09:23] Data: 4.000 B (4.000 B per file)
[2025-03-06T14:09:23] Sorted 3 items in 0.000 seconds (9201.325 items/sec)
[2025-03-06T14:09:23] Truncating archive
[2025-03-06T14:09:23] Gathering index
[2025-03-06T14:09:23] Writing index as last entry in archive.tar
[2025-03-06T14:09:23] Writing entry headers
[2025-03-06T14:09:23] Copying file data
[2025-03-06T14:09:23] Started:   Mar-06-2025, 14:09:23
[2025-03-06T14:09:23] Completed: Mar-06-2025, 14:09:23
[2025-03-06T14:09:23] Seconds: 0.003
[2025-03-06T14:09:23] Archive size: 8.500 KiB
[2025-03-06T14:09:23] Rate: 3.040 MiB/s (8704 bytes in 0.003 seconds)

The generated archive is corrupted:

$ tar -tf archive.tar 
test/
test/file1
test/symlink1
tar: Skipping to next header
archive.tar.dtaridx
tar: Exiting with failure status due to previous errors
rezib added a commit to rezib/mpifileutils that referenced this issue Mar 6, 2025
Fix creation of corrupted archive with symlink when
--preserve-{xattrs,acl,flags} command line option is used.

When it is provided a valid file descriptor, libarchive
archive_read_disk_entry_from_file() calls fstat() which follows
symlinks. This commit introduces an exception for symlinks to not
provide a file descriptor to archive_read_disk_entry_from_file() which
makes it call lstat() on entry path and create a valid symlink archive
entry eventually.

fix hpc#628

Signed-off-by: Rémi Palancher <remi@rackslab.io>
@rezib rezib linked a pull request Mar 6, 2025 that will close this issue
rezib added a commit to rezib/mpifileutils that referenced this issue Mar 6, 2025
Fix creation of corrupted archive with symlink when
--preserve-{xattrs,acl,flags} command line option is used.

When it is provided a valid file descriptor, libarchive
archive_read_disk_entry_from_file() calls fstat() which follows
symlinks. This commit introduces an exception for symlinks to not
provide a file descriptor to archive_read_disk_entry_from_file() which
makes it call lstat() on entry path and create a valid symlink archive
entry eventually.

fix hpc#628

Signed-off-by: Rémi Palancher <remi@rackslab.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant