summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-06-30 04:54:07 +0000
committerkientzle <kientzle@FreeBSD.org>2004-06-30 04:54:07 +0000
commit50e158218df9e4373201bba21553f8355328cd65 (patch)
tree1d8298482f6d213299b56d1671037b9ef194a160 /lib
parent13c866dd866446e06b215a9cf57bc7908700b898 (diff)
downloadFreeBSD-src-50e158218df9e4373201bba21553f8355328cd65.zip
FreeBSD-src-50e158218df9e4373201bba21553f8355328cd65.tar.gz
In case symlinks happen to already be sitting around, be sure to use
chmod() and not lchmod() whenever we know we didn't extract a symlink.
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_read_extract.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/libarchive/archive_read_extract.c b/lib/libarchive/archive_read_extract.c
index 8fd3196..6726f1b 100644
--- a/lib/libarchive/archive_read_extract.c
+++ b/lib/libarchive/archive_read_extract.c
@@ -827,14 +827,28 @@ set_perm(struct archive *a, struct archive_entry *entry, int mode, int flags)
mode &= ~ S_ISGID;
}
+ /*
+ * Ensure we change permissions on the object we extracted,
+ * and not any incidental symlink that might have gotten in
+ * the way.
+ */
+ if (!S_ISLNK(archive_entry_mode(entry))) {
+ if (chmod(name, mode) != 0) {
+ archive_set_error(a, errno, "Can't set permissions");
+ return (ARCHIVE_WARN);
+ }
+ } else {
#ifdef HAVE_LCHMOD
- if (lchmod(name, mode) != 0) {
-#else
- if ((archive_entry_mode(entry) & S_IFMT) != S_IFLNK &&
- chmod(name, mode) != 0) {
+ /*
+ * If lchmod() isn't supported, it's no big deal.
+ * Permissions on symlinks are actually ignored on
+ * most platforms.
+ */
+ if (lchmod(name, mode) != 0) {
+ archive_set_error(a, errno, "Can't set permissions");
+ return (ARCHIVE_WARN);
+ }
#endif
- archive_set_error(a, errno, "Can't set permissions");
- return (ARCHIVE_WARN);
}
if (flags & ARCHIVE_EXTRACT_ACL) {
OpenPOWER on IntegriCloud