summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-07-24 17:50:05 +0000
committerkientzle <kientzle@FreeBSD.org>2004-07-24 17:50:05 +0000
commitf7e00cb8911a0a9ef1c68a5e897fe5f3d1376dbe (patch)
tree10eb6468a056c1b5f6014a9cc0a4a81dede4374e /lib
parent394fd52d6c65e679a60c37a69034a2336e994b21 (diff)
downloadFreeBSD-src-f7e00cb8911a0a9ef1c68a5e897fe5f3d1376dbe.zip
FreeBSD-src-f7e00cb8911a0a9ef1c68a5e897fe5f3d1376dbe.tar.gz
Use "linux" instead of "LINUX" to control Linux-specific code.
Thanks to: David O'Brien for pointing this out. Also, add in a few additional portability tweaks and make a few more things conditional on features (HAVE_XXXX macros) rather than platform.
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_entry.c2
-rw-r--r--lib/libarchive/archive_platform.h3
-rw-r--r--lib/libarchive/archive_read_extract.c21
3 files changed, 18 insertions, 8 deletions
diff --git a/lib/libarchive/archive_entry.c b/lib/libarchive/archive_entry.c
index f04fee8..71e950f 100644
--- a/lib/libarchive/archive_entry.c
+++ b/lib/libarchive/archive_entry.c
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <wchar.h>
-#ifdef LINUX
+#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ext2fs/ext2_fs.h> /* for Linux file flags */
#endif
diff --git a/lib/libarchive/archive_platform.h b/lib/libarchive/archive_platform.h
index 789d19d..332ef0d 100644
--- a/lib/libarchive/archive_platform.h
+++ b/lib/libarchive/archive_platform.h
@@ -54,6 +54,7 @@
#define HAVE_CHFLAGS 1
#define HAVE_LUTIMES 1
#define HAVE_LCHMOD 1
+#define HAVE_LCHOWN 1
#define HAVE_STRERROR_R 1
#define ARCHIVE_ERRNO_FILE_FORMAT EFTYPE
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
@@ -98,6 +99,8 @@
#define ARCHIVE_ERRNO_FILE_FORMAT EILSEQ
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
#define ARCHIVE_ERRNO_MISC (-1)
+#define HAVE_EXT2FS_EXT2_FS_H 1
+#define HAVE_LCHOWN 1
#define HAVE_STRERROR_R 1
#define STRERROR_R_CHAR_P 1
diff --git a/lib/libarchive/archive_read_extract.c b/lib/libarchive/archive_read_extract.c
index d4de42f..e91a744 100644
--- a/lib/libarchive/archive_read_extract.c
+++ b/lib/libarchive/archive_read_extract.c
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef LINUX
+#ifdef linux
#include <ext2fs/ext2_fs.h>
#include <sys/ioctl.h>
#endif
@@ -827,7 +827,13 @@ set_ownership(struct archive *a, struct archive_entry *entry, int flags)
if (a->user_uid != 0 && a->user_uid != uid)
return (ARCHIVE_OK);
- if (lchown(archive_entry_pathname(entry), uid, gid)) {
+#ifdef HAVE_LCHOWN
+ if (lchown(archive_entry_pathname(entry), uid, gid))
+#else
+ if (!S_ISLNK(archive_entry_mode(entry))
+ && chown(archive_entry_pathname(entry), uid, gid) != 0)
+#endif
+ {
archive_set_error(a, errno,
"Can't set user=%d/group=%d for %s", uid, gid,
archive_entry_pathname(entry));
@@ -922,8 +928,8 @@ set_perm(struct archive *a, struct archive_entry *entry, int mode, int flags)
archive_set_error(a, errno, "Can't set permissions");
return (ARCHIVE_WARN);
}
- } else {
#ifdef HAVE_LCHMOD
+ } else {
/*
* If lchmod() isn't supported, it's no big deal.
* Permissions on symlinks are actually ignored on
@@ -1005,7 +1011,7 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
{
struct extract *extract;
int ret;
-#ifdef LINUX
+#ifdef linux
int fd;
int err;
unsigned long newflags, oldflags;
@@ -1034,9 +1040,9 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
}
extract->pst = &extract->st;
}
-#endif
+#else
+#ifdef linux
/* Linux has flags too, but no chflags syscall */
-#ifdef LINUX
/*
* Linux has no define for the flags that are only settable
* by the root user...
@@ -1071,7 +1077,8 @@ set_fflags(struct archive *a, const char *name, mode_t mode,
ret = ARCHIVE_WARN;
}
}
-#endif
+#endif /* linux */
+#endif /* HAVE_CHFLAGS */
return (ret);
}
OpenPOWER on IntegriCloud