[darwinbuild-changes] [995] branches/PR-10307836/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 21 10:07:30 PST 2012


Revision: 995
          http://trac.macosforge.org/projects/darwinbuild/changeset/995
Author:   mww at apple.com
Date:     2012-01-21 10:07:28 -0800 (Sat, 21 Jan 2012)
Log Message:
-----------
Strip quarantine xattrs from installed files.

Modified Paths:
--------------
    branches/PR-10307836/darwinup/Depot.cpp
    branches/PR-10307836/darwinup/File.cpp
    branches/PR-10307836/darwinup/File.h

Modified: branches/PR-10307836/darwinup/Depot.cpp
===================================================================
--- branches/PR-10307836/darwinup/Depot.cpp	2012-01-21 07:07:10 UTC (rev 994)
+++ branches/PR-10307836/darwinup/Depot.cpp	2012-01-21 18:07:28 UTC (rev 995)
@@ -434,7 +434,7 @@
 						"aborting to avoid damaging darwinup metadata.\n");
 				return DEPOT_ERROR;
 			}
-			
+
 			// Perform a three-way-diff between the file to be installed (file),
 			// the file we last installed in this location (preceding),
 			// and the file that actually exists in this location (actual).
@@ -706,6 +706,12 @@
 	InstallContext* context = (InstallContext*)ctx;
 	int res = 0;
 
+	// Strip the quarantine xattr off all files to avoid them being rendered useless.
+	if (file->unquarantine(context->depot->m_archives_path) != 0) {
+		fprintf(stderr, "Error: unable to unquarantine file in staging area.\n");
+		return DEPOT_ERROR;
+	}
+
 	if (INFO_TEST(file->info(), FILE_INFO_INSTALL_DATA)) {
 		++context->files_modified;
 

Modified: branches/PR-10307836/darwinup/File.cpp
===================================================================
--- branches/PR-10307836/darwinup/File.cpp	2012-01-21 07:07:10 UTC (rev 994)
+++ branches/PR-10307836/darwinup/File.cpp	2012-01-21 18:07:28 UTC (rev 995)
@@ -42,6 +42,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <removefile.h>
+#include <sys/xattr.h>
 
 File::File() {
 	m_serial = 0;
@@ -244,6 +245,26 @@
 	return -1;
 }
 
+int File::unquarantine(const char *prefix) {
+	int res = 0;
+	Archive *archive = this->archive();
+	const char *srcpath = archive->directory_name(prefix);
+	char path[PATH_MAX];
+	snprintf(path, sizeof(path), "%s/%s", srcpath, this->path());
+
+	res = removexattr(path, "com.apple.quarantine", XATTR_NOFOLLOW);
+	IF_DEBUG("[unquarantine] removexattr %s\n", path);
+	if (res == -1 && errno == ENOATTR) {
+		// Safely ignore ENOATTR, we didn't have the quarantine
+		// xattr set on this file.
+		res = 0;
+	} else if (res != 0) {
+		fprintf(stderr, "%s:%d: %s: %s (%d)\n",
+				__FILE__, __LINE__, m_path, strerror(errno), errno);
+	}
+	return res;
+}
+
 int File::install_info(const char* dest) {
 	int res = 0;
 	char* path;

Modified: branches/PR-10307836/darwinup/File.h
===================================================================
--- branches/PR-10307836/darwinup/File.h	2012-01-21 07:07:10 UTC (rev 994)
+++ branches/PR-10307836/darwinup/File.h	2012-01-21 18:07:28 UTC (rev 995)
@@ -183,6 +183,9 @@
 	// Removes the file
 	virtual int remove();
 
+	// Removes any quarantine xattrs present
+	virtual int unquarantine(const char *prefix);
+
 	// Prints one line to the output stream indicating
 	// the file mode, ownership, digest and name.
 	virtual void print(FILE* stream);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20120121/370e5b17/attachment.html>


More information about the darwinbuild-changes mailing list