| 82 | | success = [fm copyPath:[frapPath stringByAppendingPathComponent:@"Contents/Frameworks/CommonMediaPlayer.framework"] toPath:frameworkPath handler:nil]; |
| | 94 | success = YES; |
| | 95 | NSString *frameworksDir = [frameworkPath stringByDeletingLastPathComponent]; |
| | 96 | BOOL isDir; |
| | 97 | if([fm fileExistsAtPath:frameworksDir isDirectory:&isDir] && isDir) |
| | 98 | { |
| | 99 | //Check permissions |
| | 100 | NSDictionary *attributes = [fm fileAttributesAtPath:frameworksDir traverseLink:YES]; |
| | 101 | if([[attributes objectForKey:NSFileOwnerAccountID] intValue] == 0) |
| | 102 | { |
| | 103 | //Owned by root |
| | 104 | AuthorizationItem authItems[2] = { |
| | 105 | {kAuthorizationEnvironmentUsername, strlen("frontrow"), "frontrow", 0}, |
| | 106 | {kAuthorizationEnvironmentPassword, strlen("frontrow"), "frontrow", 0}, |
| | 107 | }; |
| | 108 | AuthorizationEnvironment environ = {2, authItems}; |
| | 109 | AuthorizationItem rightSet[] = {{kAuthorizationRightExecute, 0, NULL, 0}}; |
| | 110 | AuthorizationRights rights = {1, rightSet}; |
| | 111 | AuthorizationRef auth; |
| | 112 | OSStatus result = AuthorizationCreate(&rights, &environ, kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights, &auth); |
| | 113 | if(result == errAuthorizationSuccess) |
| | 114 | { |
| | 115 | char *command = "chown frontrow \"$FWDIR\""; |
| | 116 | setenv("FWDIR", [frameworksDir fileSystemRepresentation], 1); |
| | 117 | char *arguments[] = {"-c", command, NULL}; |
| | 118 | result = AuthorizationExecuteWithPrivileges(auth, "/bin/sh", kAuthorizationFlagDefaults, arguments, NULL); |
| | 119 | unsetenv("FWDIR"); |
| | 120 | } |
| | 121 | if(result != errAuthorizationSuccess) |
| | 122 | { |
| | 123 | success = NO; |
| | 124 | FrameworkLoadPrint(@"Failed to correct permissions on Frameworks directory"); |
| | 125 | } |
| | 126 | AuthorizationFree(auth, kAuthorizationFlagDefaults); |
| | 127 | int status; |
| | 128 | wait(&status); |
| | 129 | } |
| | 130 | } |
| | 131 | else |
| | 132 | success = createDirectoryTree(fm, frameworksDir); |
| | 133 | FrameworkLoadPrint(@"Creation of dir is %d", success); |
| | 134 | success = [fm copyPath:frameworkInFrap toPath:frameworkPath handler:nil]; |