3 ms·
The tar file format doesn't prevent you from specifying absolute paths in the archive. It's up to the tool extracting the archive to reject/ignore such paths.
by 10000truths 2y ago
The tar file format doesn't prevent you from specifying absolute paths in the archive. It's up to the tool extracting the archive to reject/ignore such paths.
- vorakl 2y agoI asked about options for GNU tar because there is a bit of strange behavior. To add absolute paths to an archive, there is "-P" option, and man says it works only for creating archives: "Don't strip leading slashes from filenames when creating archives". To extract absolute paths from the archive, you need to add the "-C /" option, and although the tool says "tar: Strip leading `/' from member names", it will still extract it in the right place because the paths become relative and -C puts them in the root. However, if you add "-P" during the extraction (which is not mentioned in man), the "strip leading slashes" information disappears. So if this message bothers someone, "tar -C / -xPf file.tar" will cleanly extract absolute paths from the archive ;)