Package: tar
Version: 1.23-3
Severity: normal
Tags: squeeze upstream

Tar sets directory permissions and creates symlinks after extraction
of the archive has been completed.  When tar gets interrupted by SIGINT,
it does not perform these steps leaving directories with wrong
permissions/ownership and symlinks as regular files with size 0.

We use tape drives to do full backups keeping index files elsewhere.  When
restoring only part of the archive, e.g. a single directory, we
fast-forward the tape to the right block and interrupt tar after the
relevant part has been extracted, because it would take hours reading
the whole tape.

There are several bug reports about symlinks being extracted as regular
files with size 0 (#452365 for example).  Maybe these are related to the
problem reported here.

The following path works as a remedy for us:

diff --git a/src/tar.c b/src/tar.c
index da12419..ecb435b 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -949,17 +949,25 @@ sigstat (int signo)
 #endif
 }
 
+static RETSIGTYPE
+sigterm (int signo)
+{
+  error (0, 0,
+   _("signal %d received; will set permissions and create symlinks"), signo);
+  fatal_exit ();
+}
+
 static void
-stat_on_signal (int signo)
+set_signal (int signo, RETSIGTYPE (*func) (int signo))
 {
 #ifdef HAVE_SIGACTION
   struct sigaction act;
-  act.sa_handler = sigstat;
+  act.sa_handler = func;
   sigemptyset (&act.sa_mask);
   act.sa_flags = 0;
   sigaction (signo, &act, NULL);
 #else
-  signal (signo, sigstat);
+  signal (signo, func);
 #endif
 }
 
@@ -987,7 +995,7 @@ set_stat_signal (const char *name)
   for (p = sigtab; p < sigtab + sizeof (sigtab) / sizeof (sigtab[0]); p++)
     if (strcmp (p->name, name) == 0)
       {
-       stat_on_signal (p->signo);
+       set_signal (p->signo, sigstat);
        return;
       }
   FATAL_ERROR ((0, 0, _("Unknown signal name: %s"), name));
@@ -2607,12 +2615,9 @@ main (int argc, char **argv)
 
     case EXTRACT_SUBCOMMAND:
       extr_init ();
+      set_signal (SIGINT, sigterm);
       read_and (extract_archive);
-
-      /* FIXME: should extract_finish () even if an ordinary signal is
-        received.  */
       extract_finish ();
-
       break;
 
     case LIST_SUBCOMMAND:

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.37-rc1-64+ (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages tar depends on:
ii  libc6              2.11.2-6+squeeze1bfw1 Embedded GNU C Library: Shared lib

tar recommends no packages.

Versions of packages tar suggests:
ii  bzip2             1.0.5-6                high-quality block-sorting file co
pn  ncompress         <none>                 (no description available)
ii  xz-utils          4.999.9beta+20100810-1 XZ-format compression utilities

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to