Skip to content

Instantly share code, notes, and snippets.

@gks
Created March 29, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gks/2d42dfcbd5d5b2452b3bef8b66d28640 to your computer and use it in GitHub Desktop.
Save gks/2d42dfcbd5d5b2452b3bef8b66d28640 to your computer and use it in GitHub Desktop.
1Password's Repair Permissions In Diagnostics Utility
- (IBAction)resetFolderPermissions:(id)sender {
setenv("F1", [[@"~/Library/Application Support/1Password" stringByExpandingTildeInPath] UTF8String], 1);
setenv("F2", [[@"~/Library/ScriptingAdditions" stringByExpandingTildeInPath] UTF8String], 1);
setenv("F3", [[@"~/Library/LaunchAgents" stringByExpandingTildeInPath] UTF8String], 1);
setenv("THEUSER", [NSUserName() UTF8String], 1);
NSString *script = @"mkdir \"$F1\";chmod -R u+rw,-t \"$F1\"; chmod -R -N \"$F1\"; chown -R \"$THEUSER:staff\" \"$F1\";mkdir \"$F2\";chmod 700 \"$F2\";chown \"$THEUSER:staff\" \"$F2\";chmod -a \"everyone deny add_subdirectory\" \"$F2\";chmod -a \"everyone deny delete_child\" \"$F2\";chmod -a \"everyone deny list\" \"$F2\";chmod -R u+rw,-t \"$F2/1Password Addition.osax\";chmod -R u+rw,-t \"$F2/1Password Addition Leopard.osax\";mkdir \"$F3\";chmod 700 \"$F3\";chown \"$THEUSER:staff\" \"$F3\";chmod -a \"everyone deny delete_child\" \"$F3\";chmod -a \"everyone deny add_file\" \"$F3\";chmod -a \"everyone deny list\" \"$F3\";chmod 644 \"$F3/ws.agile.1PasswordAgent.plist\";chmod -N \"$F3/ws.agile.1PasswordAgent.plist\"";
BOOL result = runShellWithAuthorization(NSLocalizedString(@"Please enter your Mac OS X password.\n\nFolder permissions will be reset. ", @"prompt"), script);
if (result) {
NSRunAlertPanel(NSLocalizedString(@"The folder permissions have been reset successfully.", @"info"), NSLocalizedString(@"Please restart 1Password.", @"info"), nil, nil, nil);;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment