Module Name: src
Committed By: martin
Date: Mon Feb 10 19:30:00 UTC 2020
Modified Files:
src/external/bsd/libarchive/dist/libarchive [netbsd-9]:
archive_write_disk_posix.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #692):
external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:
revision 1.5
When extracting symlinks atomically remove them like we do for hard links.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2.2.1 -r1.1.1.2.2.2 \
src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c
diff -u src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.1.1.2.2.1 src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.1.1.2.2.2
--- src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.1.1.2.2.1 Tue Jan 21 15:48:51 2020
+++ src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c Mon Feb 10 19:30:00 2020
@@ -2301,6 +2301,11 @@ create_filesystem_object(struct archive_
}
free(linkname_copy);
archive_string_free(&error_string);
+ /*
+ * Unlinking and linking here is really not atomic,
+ * but doing it right, would require us to construct
+ * an mktemplink() function, and then use rename(2).
+ */
if (a->flags & ARCHIVE_EXTRACT_ATOMIC)
unlink(a->name);
r = link(linkname, a->name) ? errno : 0;
@@ -2341,7 +2346,15 @@ create_filesystem_object(struct archive_
linkname = archive_entry_symlink(a->entry);
if (linkname != NULL) {
#if HAVE_SYMLINK
- int error = symlink(linkname, a->name) ? errno : 0;
+ int error;
+ /*
+ * Unlinking and linking here is really not atomic,
+ * but doing it right, would require us to construct
+ * an mktempsymlink() function, and then use rename(2).
+ */
+ if (a->flags & ARCHIVE_EXTRACT_ATOMIC)
+ unlink(a->name);
+ error = symlink(linkname, a->name) ? errno : 0;
if (error == 0) {
#ifdef HAVE_LSTAT
r = lstat(a->name, &st);