Tar appears to be not preserving all metadata when --no-overwrite-dir is used for file extraction. I started seeing this regression when we updated from Ubuntu 20 to Ubuntu 22: tar 1.30 -> 1.34.

This is the example that made me aware of the issue. These commands pass with tar 1.30.

$ mkdir usr
$ tar -cf test.tar usr
$ tar --no-overwrite-dir -xf test.tar -C /
tar: usr: Cannot change mode to rwxr-xr-x: Operation not permitted
tar: Exiting with failure status due to previous errors


And here is a similar example with folder metadata. I observed that even with '--no-overwrite-dir' passed to tar, the folder's "modify" metadata is rolled back to match the folder contained in the tarball. But based on the documentation, I expected neither Modify nor Change fields to update.

$ mkdir test
$ tar -cf test2.tar test
$ rmdir test
$ mkdir test
$ stat test
  File: test
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 259,2   Inode: 21561426    Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1000/    nate)   Gid: ( 1000/    nate)
Access: 2024-11-11 08:26:02.696280292 -0600
Modify: 2024-11-11 08:26:02.696280292 -0600
Change: 2024-11-11 08:26:02.696280292 -0600
 Birth: 2024-11-11 08:26:02.696280292 -0600

$ tar --no-overwrite-dir -xf test2.tar
$ stat test
  File: test
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 259,2   Inode: 21561426    Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1000/    nate)   Gid: ( 1000/    nate)
Access: 2024-11-11 08:26:02.696280292 -0600
Modify: 2024-11-11 08:23:40.000000000 -0600
Change: 2024-11-11 08:26:17.222659660 -0600
 Birth: 2024-11-11 08:26:02.696280292 -0600

Reply via email to