Skip to content

Commit

Permalink
Fixing issue with update as non admin user where the quarantine flag …
Browse files Browse the repository at this point in the history
…did not get correctly removed from new application
  • Loading branch information
Michael Ehrmann authored and andymatuschak committed Feb 4, 2013
1 parent c37fc01 commit 0ed83cf
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions SUPlainInstallerInternals.m
Expand Up @@ -198,17 +198,12 @@ + (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done after the application is moved to its
// new home with "mv" in case it's moved across filesystems: if
// that happens, "mv" actually performs a copy and may result
// in the application being quarantined. It also needs to be
// done before "chown" changes ownership, because the ownership
// change will almost certainly make it impossible to change
// attributes to release the files from the quarantine.
// This needs to be done before "chown" changes ownership,
// because the ownership change will fail if the file is quarantined.
if (res)
{
SULog(@"releaseFromQuarantine");
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:src waitUntilDone:YES];
}

if( res ) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
Expand Down Expand Up @@ -252,6 +247,21 @@ + (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst

AuthorizationFree(auth, 0);

// If the currently-running application is trusted, the new
// version should be trusted as well. Remove it from the
// quarantine to avoid a delay at launch, and to avoid
// presenting the user with a confusing trust dialog.
//
// This needs to be done after the application is moved to its
// new home with "mv" in case it's moved across filesystems: if
// that happens, "mv" actually performs a copy and may result
// in the application being quarantined.
if (res)
{
SULog(@"releaseFromQuarantine after installing");
[self performSelectorOnMainThread:@selector(releaseFromQuarantine:) withObject:dst waitUntilDone:YES];
}

if (!res)
{
// Something went wrong somewhere along the way, but we're not sure exactly where.
Expand Down

0 comments on commit 0ed83cf

Please sign in to comment.