[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] Incremental extract improvement

From: Wolfram Kleff
Subject: [Bug-tar] Incremental extract improvement
Date: Tue, 9 May 2006 13:29:51 +0200
User-agent: KMail/1.9.1


I have found a problem in tar 1.15.1:
In case of an incremental extract, we might experience the case that a new 
file/symlink etc. should be written over a dir with subdirs in it. In this 
case, a normal tar extraction fails. The correct solution would be to use the 
recursive-unlink option. But in case of an incremental extract, we might mess 
the previous dir-content because the incremental extract tries to recursive 
delete the previous dir-content.

To fix this problem, I have patched the extract.c to check if a dir replaces a 
dir in incremental mode. In this case a chmod is done instead of a mkdir. 
(Patch attached)

This patch works with my test scenarios.
Please let me know if there is a scenario in which this patch fails.
Otherwise please update tar in the next release.

Wolfram Kleff

Patch for tar 1.15.1:
--- extract.orig.c      2004-12-21 10:55:12.000000000 +0100
+++ extract.c   2006-05-09 12:24:21.000000000 +0200
@@ -1039,6 +1039,23 @@
               | (we_are_root ? 0 : MODE_WXUSR))
              & MODE_RWX);

+      /*
+        If we do an incremental extract,
+        be very careful not to delete an existing (not empty) dir.
+        This is especially necessary if the recursive-unlink option
+        is used. Otherwise we might mess up the previous extraction(s).
+        WK 20060508
+      */
+      if (incremental_option) {
+        struct stat buf;
+        if (lstat(file_name, &buf) == 0) {
+          if (S_ISDIR(buf.st_mode)) {
+            status = chmod(file_name, mode);
+            goto directory_exists;
+          }
+        }
+      }
       status = prepare_to_extract (file_name);
       if (status == 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]