Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libarchive does not populate st_flags Use the proper API
Baptiste Daroussin committed 11 years ago
commit 169b46cbca837d79dcfee2fb2c1f093dac7acc09
parent e990c5d
1 file changed +7 -8
modified libpkg/pkg_add.c
@@ -155,6 +155,7 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
	struct pkg_config_file *rcf;
	struct sbuf *newconf;
	bool automerge = pkg_object_bool(pkg_config_get("AUTOMERGE"));
+
	unsigned long set, clear;

#ifndef HAVE_ARC4RANDOM
	srand(time(NULL));
@@ -181,6 +182,7 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
		strlcpy(rpath, pathname, sizeof(rpath));

		aest = archive_entry_stat(ae);
+
		archive_entry_fflags(ae, &set, &clear);
		if (lstat(rpath, &st) != -1) {
			/*
			 * We have an existing file on the path, so handle it
@@ -265,7 +267,7 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
			pkg_debug(1, "Renaming %s -> %s", rpath, pathname);
#ifdef HAVE_CHFLAGS
			bool old = false;
-
			if (aest->st_flags & NOCHANGESFLAGS)
+
			if (set & NOCHANGESFLAGS)
				chflags(rpath, 0);

			if (lstat(pathname, &st) != -1) {
@@ -287,11 +289,8 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
				goto cleanup;
			}
#ifdef HAVE_CHFLAGS
-
			/* Restore flags on the final file exept on libarchive pre 3.x*/
-
#if ARCHIVE_VERSION_NUMBER >= 3000002
-
			chflags(pathname, aest->st_flags);
-
#endif
-

+
			/* Restore flags */
+
			chflags(pathname, set);
#endif
		}

@@ -314,8 +313,8 @@ cleanup:

	if (renamed && retcode == EPKG_FATAL) {
#ifdef HAVE_CHFLAGS
-
		if (aest->st_flags & NOCHANGESFLAGS)
-
			chflags(rpath, aest->st_flags & ~NOCHANGESFLAGS);
+
		if (set & NOCHANGESFLAGS)
+
			chflags(rpath, set & ~NOCHANGESFLAGS);
#endif
		unlink(rpath);
	}