summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath2001-06-22 02:55:16 +0000
committerGlenn L McGrath2001-06-22 02:55:16 +0000
commit76ce7549cec009ac1f4706f9c20da27d8c6b4239 (patch)
treef45b55655c61d952c869b6ba0cd85655aead8bff /libbb
parent9f832deecf028ca55dcf1e20996892cce8ab87d0 (diff)
downloadbusybox-76ce7549cec009ac1f4706f9c20da27d8c6b4239.zip
busybox-76ce7549cec009ac1f4706f9c20da27d8c6b4239.tar.gz
Dont change date or chmod on symlinks, lchown on symlinks if lchown available
Diffstat (limited to 'libbb')
-rw-r--r--libbb/unarchive.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index e4150bd..199123e 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -162,13 +162,23 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
}
break;
}
- if (function & extract_preserve_date) {
- t.actime = file_entry->mtime;
- t.modtime = file_entry->mtime;
- utime(full_name, &t);
+
+ /* Changing a symlink's properties normally changes the properties of the
+ * file pointed to, so dont try and change the date or mode, lchown does
+ * does the right thing, but isnt available in older versions of libc */
+ if (S_ISLNK(file_entry->mode)) {
+#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+ lchown(full_name, file_entry->uid, file_entry->gid);
+#endif
+ } else {
+ if (function & extract_preserve_date) {
+ t.actime = file_entry->mtime;
+ t.modtime = file_entry->mtime;
+ utime(full_name, &t);
+ }
+ chmod(full_name, file_entry->mode);
+ chown(full_name, file_entry->uid, file_entry->gid);
}
- chmod(full_name, file_entry->mode);
- lchown(full_name, file_entry->uid, file_entry->gid);
} else {
/* If we arent extracting data we have to skip it,
* if data size is 0 then then just do it anyway