Revision
997
Author
mww@apple.com
Date
2012-01-23 10:55:08 -0800 (Mon, 23 Jan 2012)

Log Message

darwinup: Clear quarantine xattr from installed files.

Modified Paths

Property Changed

Diff

Property changes: trunk


Modified: svn:mergeinfo

/branches/PR-10363375:959-960 /branches/PR-10397485:967 /branches/PR-10412052:973-975 /branches/PR-10412066:974-975 /branches/PR-10431324:979-980 /branches/PR-4841388:399-419 /branches/PR-6358021:442-443 /branches/PR-6392966:423-427 /branches/PR-6398060:433-434 /branches/PR-6493844:460-461 /branches/PR-6497694:466-468,471 /branches/PR-6634286:632-650 /branches/PR-6688645:479-490 /branches/PR-6722857:495-499 /branches/PR-6729491:655-664 /branches/PR-6973110:804-813 /branches/PR-7250612:635-650 /branches/PR-7341154:682-694 /branches/PR-7431723:660-664 /branches/PR-7461534:650-664 /branches/PR-7482850:670-671 /branches/PR-7489777:676-731 /branches/PR-7529688:692-694 /branches/PR-7593824:739-772 /branches/PR-7598640:703-731 /branches/PR-7748469:777-785 /branches/PR-7765119:790-791 /branches/PR-7798586:796-799 /branches/PR-7872907:830-840 /branches/PR-7935095:819-821 /branches/PR-8116613:849 /branches/PR-8279204:854-862 /branches/PR-8416637:870-880 /branches/PR-8486662:885-889 /branches/PR-8488185:894-898 /branches/PR-8604911:903-905 /branches/PR-8817822:917-933 /branches/PR-8908468:912 + /branches/PR-10008999:984 /branches/PR-10307836:993-996 /branches/PR-10363375:959-960 /branches/PR-10397485:967 /branches/PR-10412052:973-975 /branches/PR-10412066:974-975 /branches/PR-10431324:979-980 /branches/PR-4841388:399-419 /branches/PR-6358021:442-443 /branches/PR-6392966:423-427 /branches/PR-6398060:433-434 /branches/PR-6493844:460-461 /branches/PR-6497694:466-468,471 /branches/PR-6634286:632-650 /branches/PR-6688645:479-490 /branches/PR-6722857:495-499 /branches/PR-6729491:655-664 /branches/PR-6973110:804-813 /branches/PR-7250612:635-650 /branches/PR-7341154:682-694 /branches/PR-7431723:660-664 /branches/PR-7461534:650-664 /branches/PR-7482850:670-671 /branches/PR-7489777:676-731 /branches/PR-7529688:692-694 /branches/PR-7593824:739-772 /branches/PR-7598640:703-731 /branches/PR-7748469:777-785 /branches/PR-7765119:790-791 /branches/PR-7798586:796-799 /branches/PR-7872907:830-840 /branches/PR-7935095:819-821 /branches/PR-8116613:849 /branches/PR-8279204:854-862 /branches/PR-8416637:870-880 /branches/PR-8486662:885-889 /branches/PR-8488185:894-898 /branches/PR-8604911:903-905 /branches/PR-8817822:917-933 /branches/PR-8908468:912

Modified: trunk/darwinup/Depot.cpp (996 => 997)


--- trunk/darwinup/Depot.cpp	2012-01-21 18:07:29 UTC (rev 996)
+++ trunk/darwinup/Depot.cpp	2012-01-23 18:55:08 UTC (rev 997)
@@ -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: trunk/darwinup/File.cpp (996 => 997)


--- trunk/darwinup/File.cpp	2012-01-21 18:07:29 UTC (rev 996)
+++ trunk/darwinup/File.cpp	2012-01-23 18:55:08 UTC (rev 997)
@@ -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: trunk/darwinup/File.h (996 => 997)


--- trunk/darwinup/File.h	2012-01-21 18:07:29 UTC (rev 996)
+++ trunk/darwinup/File.h	2012-01-23 18:55:08 UTC (rev 997)
@@ -183,6 +183,9 @@
 	// Removes the file
 	virtual int remove();
 
+	// Removes any quarantine xattrs present
+	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);