]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Conditionalize link, symlink, and lstat support.
authorTim Kientzle <kientzle@gmail.com>
Sat, 1 Aug 2009 05:30:24 +0000 (01:30 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 1 Aug 2009 05:30:24 +0000 (01:30 -0400)
SVN-Revision: 1304

CMakeLists.txt
build/cmake/config.h.in
configure.ac
libarchive/archive_write_disk.c
libarchive/config_freebsd.h

index c0c4c89f3a37f3951385ba72cbae3c69d82bbe10..12ec0e8b7a05b73c8f6df00c26336f12f6bbdebc 100644 (file)
@@ -287,10 +287,10 @@ CHECK_FUNCTION_EXISTS(SHA512_Init HAVE_SHA512)
 CHECK_FUNCS(chflags chown chroot)
 CHECK_FUNCS(fchdir fchflags fchmod fchown fcntl fork)
 CHECK_FUNCS(fstat ftruncate futimes geteuid getpid)
-CHECK_FUNCS(lchflags lchmod lchown)
+CHECK_FUNCS(lchflags lchmod lchown link lstat)
 CHECK_FUNCS(lutimes memmove memset mkdir mkfifo mknod)
 CHECK_FUNCS(nl_langinfo pipe poll readlink select setenv setlocale)
-CHECK_FUNCS(strchr strdup strerror strrchr timegm)
+CHECK_FUNCS(strchr strdup strerror strrchr symlink timegm)
 CHECK_FUNCS(tzset unsetenv utime utimes vfork)
 CHECK_FUNCS(wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy)
 
index b260b1cb5293f8ab8ac687503d8af740a34d8cd8..b24016bfaf7c0918c98a281cf7e2650c1b72e4f7 100644 (file)
 /* Define to 1 if you have the <limits.h> header file. */
 #cmakedefine HAVE_LIMITS_H 1
 
+/* Define to 1 if you have the link() function. */
+#cmakedefine HAVE_LINK 1
+
 /* Define to 1 if you have the <linux/fs.h> header file. */
 #cmakedefine HAVE_LINUX_FS_H 1
 
 /* Define to 1 if you have the `lsetxattr' function. */
 #cmakedefine HAVE_LSETXATTR 1
 
+/* Define to 1 if you have the `lstat' function. */
+#cmakedefine HAVE_LSTAT 1
+
 /* Define to 1 if `lstat' has the bug that it succeeds when given the
    zero-length file name argument. */
 #cmakedefine HAVE_LSTAT_EMPTY_STRING_BUG 1
 /* Define to 1 if `st_umtime' is member of `struct stat'. */
 #cmakedefine HAVE_STRUCT_STAT_ST_UMTIME 1
 
+/* Define to 1 if you have the symlink() function. */
+#cmakedefine HAVE_SYMLINK 1
+
 /* Define to 1 if you have the <sys/acl.h> header file. */
 #cmakedefine HAVE_SYS_ACL_H 1
 
index 3b72e3d15dc89e9c4de3ac7f85575404614b5906..756bcbc3768569098d22a22bfee7caec9bb57261 100644 (file)
@@ -331,10 +331,10 @@ AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([chflags chown chroot])
 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
 AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid])
-AC_CHECK_FUNCS([lchflags lchmod lchown])
+AC_CHECK_FUNCS([lchflags lchmod lchown link])
 AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod])
 AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale])
-AC_CHECK_FUNCS([strchr strdup strerror strrchr timegm])
+AC_CHECK_FUNCS([strchr strdup strerror strrchr symlink timegm])
 AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork])
 AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
 # detects cygwin-1.7, as opposed to older versions
index 97743de9e7fcfb3b7b3fe92ced8c4ac96b4a0329..99e15a1087909aa845dd59f58e6ebb2c3587e5fb 100644 (file)
@@ -1073,6 +1073,9 @@ create_filesystem_object(struct archive_write_disk *a)
        /* Since link(2) and symlink(2) don't handle modes, we're done here. */
        linkname = archive_entry_hardlink(a->entry);
        if (linkname != NULL) {
+#if !HAVE_LINK
+               return (EPERM);
+#else
                r = link(linkname, a->name) ? errno : 0;
                /*
                 * New cpio and pax formats allow hardlink entries
@@ -1095,10 +1098,16 @@ create_filesystem_object(struct archive_write_disk *a)
                                r = errno;
                }
                return (r);
+#endif
        }
        linkname = archive_entry_symlink(a->entry);
-       if (linkname != NULL)
+       if (linkname != NULL) {
+#if HAVE_SYMLINK
                return symlink(linkname, a->name) ? errno : 0;
+#else
+               return (EPERM);
+#endif
+       }
 
        /*
         * The remaining system calls all set permissions, so let's
@@ -1398,9 +1407,15 @@ current_fixup(struct archive_write_disk *a, const char *pathname)
  * scan the path and both can be optimized by comparing against other
  * recent paths.
  */
+/* TODO: Extend this to support symlinks on Windows Vista and later. */
 static int
 check_symlinks(struct archive_write_disk *a)
 {
+#if !defined(HAVE_LSTAT)
+       /* Platform doesn't have lstat, so we can't look for symlinks. */
+       (void)a; /* UNUSED */
+       return (ARCHIVE_OK);
+#else
        char *pn, *p;
        char c;
        int r;
@@ -1481,6 +1496,7 @@ check_symlinks(struct archive_write_disk *a)
        /* We've checked and/or cleaned the whole path, so remember it. */
        archive_strcpy(&a->path_safe, a->name);
        return (ARCHIVE_OK);
+#endif
 }
 
 #if defined(_WIN32) || defined(__CYGWIN__)
index 5272fcb395910d1248e220ab4ce639d17c2eab6a..f8224b322303e66b3bbccde140ea230f7efdd9d8 100644 (file)
@@ -73,6 +73,8 @@
 #define        HAVE_LCHMOD 1
 #define        HAVE_LCHOWN 1
 #define        HAVE_LIMITS_H 1
+#define        HAVE_LINK 1
+#define        HAVE_LSTAT 1
 #define        HAVE_LUTIMES 1
 #define        HAVE_MALLOC 1
 #define        HAVE_MD5 1
 #define        HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
 #define        HAVE_STRUCT_STAT_ST_FLAGS 1
 #define        HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
+#define        HAVE_SYMLINK 1
 #define        HAVE_SYS_IOCTL_H 1
 #define        HAVE_SYS_SELECT_H 1
 #define        HAVE_SYS_STAT_H 1