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)
/* 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
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
/* 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
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
* 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;
/* 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__)
#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