summaryrefslogtreecommitdiff
path: root/usr.bin/unzip
diff options
context:
space:
mode:
authorAlex Kozlov <ak@FreeBSD.org>2015-12-13 21:31:45 +0000
committerAlex Kozlov <ak@FreeBSD.org>2015-12-13 21:31:45 +0000
commit46021e01287d486960d9a62bcd0f31a51e087db1 (patch)
tree88c0c5383cfb71e8564769da3e5df39eda38e2d7 /usr.bin/unzip
parent371028a3b7a94dd72d0d690eda0d1555224f932d (diff)
downloadsrc-test-46021e01287d486960d9a62bcd0f31a51e087db1.tar.gz
src-test-46021e01287d486960d9a62bcd0f31a51e087db1.zip
- Properly set mode and atime/ctime for symlinks
Approved by: des
Notes
Notes: svn path=/head/; revision=292172
Diffstat (limited to 'usr.bin/unzip')
-rw-r--r--usr.bin/unzip/unzip.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c
index 74c1542a12f2c..cb639fb86600a 100644
--- a/usr.bin/unzip/unzip.c
+++ b/usr.bin/unzip/unzip.c
@@ -127,7 +127,6 @@ errorx(const char *fmt, ...)
exit(1);
}
-#if 0
/* non-fatal error message + errno */
static void
warning(const char *fmt, ...)
@@ -143,7 +142,6 @@ warning(const char *fmt, ...)
va_end(ap);
fprintf(stderr, ": %s\n", strerror(errno));
}
-#endif
/* non-fatal error message, no errno */
static void
@@ -539,12 +537,21 @@ recheck:
return;
}
+ ts[0].tv_sec = 0;
+ ts[0].tv_nsec = UTIME_NOW;
+ ts[1] = mtime;
+
/* process symlinks */
linkname = archive_entry_symlink(e);
if (linkname != NULL) {
- if (symlink(linkname, *path) < 0)
+ if (symlink(linkname, *path) != 0)
error("symlink('%s')", *path);
info(" extracting: %s -> %s\n", *path, linkname);
+ if (lchmod(*path, mode) != 0)
+ warning("Cannot set mode for '%s'", *path);
+ /* set access and modification time */
+ if (utimensat(AT_FDCWD, *path, ts, AT_SYMLINK_NOFOLLOW) != 0)
+ warning("utimensat('%s')", *path);
return;
}
@@ -629,9 +636,6 @@ recheck:
info("\n");
/* set access and modification time */
- ts[0].tv_sec = 0;
- ts[0].tv_nsec = UTIME_NOW;
- ts[1] = mtime;
if (futimens(fd, ts) != 0)
error("futimens('%s')", *path);
if (close(fd) != 0)