OSDN Git Service

could not extract files under readonly directories.
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sat, 16 Feb 2008 19:12:23 +0000 (19:12 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sat, 16 Feb 2008 19:12:23 +0000 (19:12 +0000)
    % chmod 555 foo
    % ls -ld foo foo/bar
    dr-xr-xr-x 2 arai arai 4096 Jan  5 03:30 foo/
    -rw-r--r-- 1 arai arai    0 Jan  5 03:30 foo/bar
    % lha c foo.lzh foo
    % lha x foo.lzh -w baz
    LHa: Error: Cannot extract a file "baz/foo/bar"

Please enter the commit message for your changes.

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@880 6a8cc165-1e22-0410-a132-eb4e3f353aba

.gitignore
ChangeLog
configure.ac
src/lhext.c
tests/Makefile.am
tests/lha-test.in
tests/lha-test18 [new file with mode: 0644]

index 20d33af..c88b997 100644 (file)
@@ -12,3 +12,7 @@ missing
 olddoc/Makefile.in
 src/Makefile.in
 tests/Makefile.in
+GPATH
+GRTAGS
+GSYMS
+GTAGS
index 2e3686f..cb119e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2008-02-17  Koji Arai  <arai@users.sourceforge.jp>
+
+       * src/lhext.c (extract_one) could not extract files under readonly directories, like:
+
+           dr-xr-xr-x 2 arai arai 4096 Jan  5 03:30 foo/
+           -rw-r--r-- 1 arai arai    0 Jan  5 03:30 foo/bar
+
+       * tests/Makefile.am: added a test for above.
+
+       * tests/lha-test.in: ditto.
+
+       * tests/lha-test18: ditto.
+
+2008-02-05  Koji Arai  <arai@users.sourceforge.jp>
+
+       * config.h. configure.ac: added a configure option
+       --with-additional-suffixes for SuSE Linux.
+
+       * src/lharc.c (open_old_archive): make it possible to add archive
+       suffixes.
+
+       * src/lharc.c (print_version): show the configure option by the
+       --version option.
+
 2007-09-09  Koji Arai  <arai@users.sourceforge.jp>
 
        * src/header.c: `put_longword()' should be used the ANSI-C declaration.
index b4f4d44..ae6bddd 100644 (file)
@@ -1,5 +1,5 @@
 # Process this file with autoconf to produce a configure script.
-AC_INIT([LHa for UNIX], 1.14i-ac20080117, arai@users.sourceforge.jp, lha)
+AC_INIT([LHa for UNIX], 1.14i-ac20080217, arai@users.sourceforge.jp, lha)
 AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args",
            [specified options for the configure script.])
 AC_CANONICAL_HOST
index dc6c3c3..2d3d7f6 100644 (file)
@@ -170,16 +170,11 @@ adjust_info(name, hdr)
     if (hdr->extend_type == EXTEND_UNIX
         || hdr->extend_type == EXTEND_OS68K
         || hdr->extend_type == EXTEND_XOSK) {
-#ifdef NOT_COMPATIBLE_MODE
-        /* Please need your modification in this space. */
-#ifdef __DJGPP__
-        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
-            chmod(name, hdr->unix_mode);
-#endif /* __DJGPP__ */
-#else
-        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
+
+        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK) {
             chmod(name, hdr->unix_mode);
-#endif
+        }
+
         if (!getuid()){
             uid_t uid = hdr->unix_uid;
             gid_t gid = hdr->unix_gid;
@@ -502,8 +497,10 @@ extract_one(afp, hdr)
             error("Unknown file type: \"%s\". use `f' option to force extract.", name);
     }
 
-    if (!output_to_stdout)
-        adjust_info(name, hdr);
+    if (!output_to_stdout) {
+        if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_DIRECTORY)
+            adjust_info(name, hdr);
+    }
 
     return read_size;
 }
@@ -590,12 +587,12 @@ is_directory_traversal(char *path)
 }
 
 /*
- * restore directory information (time stamp).
+ * restore directory information (timestamp, permission and uid/gid).
  * added by A.Iriyama  2003.12.12
  */
 
-typedef struct lhdDirectoryInfo_t {
-    struct lhdDirectoryInfo_t *next;
+typedef struct LzHeaderList_t {
+    struct LzHeaderList_t *next;
     LzHeader hdr;
 } LzHeaderList;
 
index e57e570..79c1c25 100644 (file)
@@ -21,6 +21,7 @@ EXTRA_DIST =  lha-test1 \
                lha-test16-l1.lzh \
                lha-test16-l2.lzh \
                lha-test17 \
+               lha-test18 \
                lha-test51 \
                lha-test51-2G.lzh \
                lha-test52-4G.lzh
index a57c3f2..4999e15 100644 (file)
@@ -1,8 +1,20 @@
 #!/bin/bash
 
+print_usage()
+{
+  cat <<EOF
+usage: $0 [-n] [test number]
+
+option:
+   -n:   do not cleanup.
+EOF
+  exit
+}
+
 for _opt
 do
    case $_opt in
+   --help) print_usage ;;
    -n) no_cleanup=true; shift ;;
    *) perform_number=$1; shift ;;
    esac
@@ -27,7 +39,8 @@ DUALCASE=1; export DUALCASE # for MKS sh
 : ${builddir=$(cd @builddir@ && pwd)}
 
 if [[ x$no_cleanup = x ]]; then
-  trap '_stat=$?; rm -rf test-*; exit $_stat' 0 1 2 3 15
+  trap '_stat=$?; chmod -R 755 test-* 2>/dev/null;
+        rm -rf test-*; exit $_stat' 0 1 2 3 15
 fi
 
 typeset -i i   # for loop
@@ -71,6 +84,7 @@ check()
 cleanup()
 {
   if [[ x$no_cleanup = x ]]; then
+    chmod -R 755 test-tmp* 2>/dev/null
     rm -rf test-tmp*
   fi
 }
@@ -133,6 +147,7 @@ else
   testsuite lha-test15
   testsuite lha-test16
   testsuite lha-test17
+  testsuite lha-test18
   # followings will take a long time
   if [[ $perform_number = all ]]; then
     testsuite lha-test51       # extract 2G over files
diff --git a/tests/lha-test18 b/tests/lha-test18
new file mode 100644 (file)
index 0000000..906a88b
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- shell-script -*-
+message restore directory permission
+
+echo -------------------------------------------------------------------
+
+mkdir -p test-tmp1/test1/test2 &&
+cp -r test-1 test-tmp1/test1/test2 &&
+chmod 444 test-tmp1 &&
+chmod 644 test-tmp1/test1 &&
+chmod 666 test-tmp1/test1/test2 &&
+chmod 755 test-tmp1/test1/test2/test-1
+                                                       check $? $LINENO
+
+$lha c test-tmp1.lzh test-tmp1
+                                                       check $? $LINENO
+
+$lha xw=test-tmp2 test-tmp1.lzh
+                                                       check $? $LINENO
+
+diff -r test-tmp2/test-tmp1 test-tmp1
+                                                       check $? $LINENO
+
+ls -ld test-tmp2/test-tmp1                    | grep '^dr--r--r--' &&
+ls -ld test-tmp2/test-tmp1/test1              | grep '^drw-r--r--' &&
+ls -ld test-tmp2/test-tmp1/test1/test2        | grep '^drw-rw-rw-' &&
+ls -ld test-tmp2/test-tmp1/test1/test2/test-1 | grep '^drwxr-xr-x'
+                                                       check $? $LINENO