]> Dogcows Code - chaz/tar/commitdiff
Fix backup handling and restoring file modes of existing directories
authorSergey Poznyakoff <gray@gnu.org.ua>
Wed, 5 Aug 2009 07:38:50 +0000 (10:38 +0300)
committerSergey Poznyakoff <gray@gnu.org.ua>
Wed, 5 Aug 2009 07:38:50 +0000 (10:38 +0300)
* NEWS, THANKS: Update
* src/extract.c (extract_dir): reset status to 0 if the
directory already exists.
* src/misc.c (maybe_backup_file): Assign before_backup_name
and clear after_backup_name before checking if we really need
to backup the file.
* tests/backup01.at: New testcase.
* tests/extrac08.at: New testcase.
* tests/Makefile.am, tests/testsuite.at: Add extrac08.at and
backup01.at

NEWS
THANKS
src/extract.c
src/misc.c
tests/Makefile.am
tests/backup01.at [new file with mode: 0644]
tests/extrac08.at [new file with mode: 0644]
tests/testsuite.at

diff --git a/NEWS b/NEWS
index e9a31ca34a80123b5b3dfc14e2026e3e9083647a..9c15ad79a50cb8552ee8ebad1b6bd1ef7443de80 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU tar NEWS - User visible changes. 2009-05-25
+GNU tar NEWS - User visible changes. 2009-08-05
 Please send GNU tar bug reports to <bug-tar@gnu.org>
 
 \f
@@ -10,6 +10,12 @@ When listing or extracting archives, the actual record size is
 reported only if the archive is read from a device (as opposed
 to regular files and pipes).
 
+* Bugfixes
+** Fix handling of hard link targets by -c --transform.
+** Fix hard links recognition with -c --remove-files.
+** Fix restoring files from backup (debian bug #508199).
+** Correctly restore modes and permissions on existing directories.
+
 \f
 version 1.22 - Sergey Poznyakoff, 2009-03-05
 
diff --git a/THANKS b/THANKS
index dbb64d25f64f9cadcf372bb292915693979c897f..9d918ba8d178ed3e99219fed74ad07deba3a40c9 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -70,6 +70,7 @@ Burkhard Plache               plache@krusty.optimax.ns.ca
 Calvin Cliff           cliff@trifid.astro.ucla.edu
 Cameron Elliott                cam@mvbms.mvbms.com
 Carl Streeter          streeter@cae.wisc.edu
+Carl Worth              cworth@cworth.org
 Carsten Heyl           heyl@nads.de
 Catrin Urbanneck       cur@gppc.de
 Cesar Romani           romani@ifm.uni-hamburg.de
index 63f3525915022558319eacbe006df92107ba09be..5361506aedb26dea7c3fa699d3602c1eb30bcb7c 100644 (file)
@@ -682,6 +682,7 @@ extract_dir (char *file_name, int typeflag)
                }
              if (S_ISDIR (st.st_mode))
                {
+                 status = 0;
                  mode = st.st_mode;
                  break;
                }
index 951449eb0c0b035246b02fc50f27d7a7c7e1a49f..b609b862ddadc4d07f99f6a132a82512bbd1b2f8 100644 (file)
@@ -417,6 +417,15 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
 {
   struct stat file_stat;
 
+  assign_string (&before_backup_name, file_name);
+
+  /* A run situation may exist between Emacs or other GNU programs trying to
+     make a backup for the same file simultaneously.  If theoretically
+     possible, real problems are unlikely.  Doing any better would require a
+     convention, GNU-wide, for all programs doing backups.  */
+
+  assign_string (&after_backup_name, 0);
+
   /* Check if we really need to backup the file.  */
 
   if (this_is_the_archive && _remdev (file_name))
@@ -438,14 +447,6 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
       && (S_ISBLK (file_stat.st_mode) || S_ISCHR (file_stat.st_mode)))
     return true;
 
-  assign_string (&before_backup_name, file_name);
-
-  /* A run situation may exist between Emacs or other GNU programs trying to
-     make a backup for the same file simultaneously.  If theoretically
-     possible, real problems are unlikely.  Doing any better would require a
-     convention, GNU-wide, for all programs doing backups.  */
-
-  assign_string (&after_backup_name, 0);
   after_backup_name = find_backup_file_name (file_name, backup_type);
   if (! after_backup_name)
     xalloc_die ();
index 2001834d33ef9d541a4b812f12d6ff0b359ea39e..64b173010ef3b539b89ccbdca5838a5f9b7e9c7a 100644 (file)
@@ -52,6 +52,7 @@ TESTSUITE_AT = \
  append.at\
  append01.at\
  append02.at\
+ backup01.at\
  chtype.at\
  comprec.at\
  delete01.at\
@@ -67,6 +68,7 @@ TESTSUITE_AT = \
  extrac05.at\
  extrac06.at\
  extrac07.at\
+ extrac08.at\
  gzip.at\
  grow.at\
  incremental.at\
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644 (file)
index 0000000..538dd3d
--- /dev/null
@@ -0,0 +1,49 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+
+# Test suite for GNU tar.
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Description:
+# When extracting, tar (<1.22) sometimes renamed a backup back to the
+# original name (overwriting the newly-extracted file) for no good reason.
+#
+# Reported by: Carl Worth <cworth@cworth.org>,
+#              Eric Lammerts <eric@lammerts.org>
+#
+# References: <1249419998.4905.84.camel@yoom.home.cworth.org>
+#             http://lists.gnu.org/archive/html/bug-tar/2009-08/msg00005.html
+#             http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508199
+#
+
+AT_SETUP([extracting existing dir with --backup])
+AT_KEYWORDS([extract backup backup01])
+
+AT_TAR_CHECK([
+mkdir dir1 dir2
+echo bla > dir1/file1
+tar cf test.tar dir1 dir2
+tar xfv test.tar --backup
+],
+[0],
+[dir1/
+dir1/file1
+Renaming `dir1/file1' to `dir1/file1~'
+dir2/
+])
+
+AT_CLEANUP
\ No newline at end of file
diff --git a/tests/extrac08.at b/tests/extrac08.at
new file mode 100644 (file)
index 0000000..2bcd10c
--- /dev/null
@@ -0,0 +1,51 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+
+# Test suite for GNU tar.
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# Description:
+# When extracting, tar (<1.22) did not restore directory permissions on
+# existing directories.
+# This was discovered when fixing debian bug #508199. See also backup01.at.
+#
+# Reported by: Carl Worth <cworth@cworth.org>,
+#
+# References: <1249419998.4905.84.camel@yoom.home.cworth.org>
+#             http://lists.gnu.org/archive/html/bug-tar/2009-08/msg00005.html
+#             http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508199
+#
+
+AT_SETUP([restoring mode on existing directory])
+AT_KEYWORDS([extract extrac08])
+
+AT_TAR_CHECK([
+mkdir dir
+chmod 755 dir
+echo bla > dir/file
+tar cf test.tar dir
+chmod 700 dir
+tar xfv test.tar
+genfile --stat=mode.777 dir
+],
+[0],
+[dir/
+dir/file
+755
+])
+
+AT_CLEANUP
\ No newline at end of file
index 634133b79ccd7543f0ed4140802d0a0d8e8dfd39..2c87281c5e0ed9d34c3d834c5714bdbc4336bcd9 100644 (file)
@@ -139,6 +139,9 @@ m4_include([extrac04.at])
 m4_include([extrac05.at])
 m4_include([extrac06.at])
 m4_include([extrac07.at])
+m4_include([extrac08.at])
+
+m4_include([backup01.at])
 
 m4_include([gzip.at])
 
This page took 0.032839 seconds and 4 git commands to generate.