mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 1 | /* |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 2 | * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 13 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #import <Cocoa/Cocoa.h> |
| 30 | #import <CoreFoundation/CoreFoundation.h> |
| 31 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 32 | // We need to weak-import posix_spawn and friends as they're not available on Tiger. |
| 33 | // The BSD-level system headers do not have availability macros, so we redeclare the |
| 34 | // functions ourselves with the "weak" attribute. |
| 35 | |
| 36 | #define WEAK_IMPORT __attribute__((weak)) |
| 37 | |
| 38 | #define POSIX_SPAWN_SETEXEC 0x0040 |
| 39 | typedef void *posix_spawnattr_t; |
| 40 | typedef void *posix_spawn_file_actions_t; |
| 41 | int posix_spawnattr_init(posix_spawnattr_t *) WEAK_IMPORT; |
| 42 | int posix_spawn(pid_t * __restrict, const char * __restrict, const posix_spawn_file_actions_t *, const posix_spawnattr_t * __restrict, char *const __argv[ __restrict], char *const __envp[ __restrict]) WEAK_IMPORT; |
| 43 | int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, size_t, cpu_type_t *__restrict, size_t *__restrict) WEAK_IMPORT; |
| 44 | int posix_spawnattr_setflags(posix_spawnattr_t *, short) WEAK_IMPORT; |
| 45 | |
| 46 | |
| 47 | static void displayErrorAndQuit(NSString *title, NSString *message) |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 48 | { |
| 49 | NSApplicationLoad(); |
ddkilzer@apple.com | 2bf5733 | 2018-08-31 10:54:16 +0000 | [diff] [blame] | 50 | #pragma clang diagnostic push |
| 51 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
lforschler@apple.com | 4b3be90 | 2015-09-04 20:47:33 +0000 | [diff] [blame] | 52 | NSRunCriticalAlertPanel(title, @"%@", @"Quit", nil, nil, message); |
ddkilzer@apple.com | 2bf5733 | 2018-08-31 10:54:16 +0000 | [diff] [blame] | 53 | #pragma clang diagnostic pop |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 54 | exit(0); |
| 55 | } |
| 56 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 57 | static int getLastVersionShown() |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 58 | { |
| 59 | [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObject:@"-1" forKey:@"StartPageShownInVersion"]]; |
| 60 | return [[NSUserDefaults standardUserDefaults] integerForKey:@"StartPageShownInVersion"]; |
| 61 | } |
| 62 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 63 | static void saveLastVersionShown(int lastVersion) |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 64 | { |
| 65 | [[NSUserDefaults standardUserDefaults] setInteger:lastVersion forKey:@"StartPageShownInVersion"]; |
| 66 | [[NSUserDefaults standardUserDefaults] synchronize]; |
| 67 | } |
| 68 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 69 | static NSString *getPathForStartPage() |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 70 | { |
| 71 | return [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"start.html"]; |
| 72 | } |
| 73 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 74 | static int getCurrentVersion() |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 75 | { |
| 76 | return [[[[NSBundle mainBundle] infoDictionary] valueForKey:(NSString *)kCFBundleVersionKey] intValue]; |
| 77 | } |
| 78 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 79 | static int getShowStartPageVersion() |
| 80 | { |
| 81 | return getCurrentVersion() + 1; |
| 82 | } |
| 83 | |
| 84 | static BOOL startPageDisabled() |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 85 | { |
| 86 | return [[NSUserDefaults standardUserDefaults] boolForKey:@"StartPageDisabled"]; |
| 87 | } |
| 88 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 89 | static void addStartPageToArgumentsIfNeeded(NSMutableArray *arguments) |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 90 | { |
| 91 | if (startPageDisabled()) |
| 92 | return; |
| 93 | |
| 94 | if (getLastVersionShown() < getShowStartPageVersion()) { |
| 95 | saveLastVersionShown(getCurrentVersion()); |
| 96 | NSString *startPagePath = getPathForStartPage(); |
| 97 | if (startPagePath) |
| 98 | [arguments addObject:startPagePath]; |
| 99 | } |
| 100 | } |
| 101 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 102 | static cpu_type_t preferredArchitecture() |
| 103 | { |
| 104 | #if defined(__ppc__) |
| 105 | return CPU_TYPE_POWERPC; |
| 106 | #elif defined(__LP64__) |
| 107 | return CPU_TYPE_X86_64; |
| 108 | #else |
| 109 | return CPU_TYPE_X86; |
| 110 | #endif |
| 111 | } |
| 112 | |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 113 | static void myExecve(NSString *executable, NSArray *args, NSDictionary *environment) |
| 114 | { |
| 115 | char **argv = (char **)calloc(sizeof(char *), [args count] + 1); |
| 116 | char **env = (char **)calloc(sizeof(char *), [environment count] + 1); |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 117 | |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 118 | NSEnumerator *e = [args objectEnumerator]; |
| 119 | NSString *s; |
| 120 | int i = 0; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 121 | while ((s = [e nextObject])) |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 122 | argv[i++] = (char *) [s UTF8String]; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 123 | |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 124 | e = [environment keyEnumerator]; |
| 125 | i = 0; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 126 | while ((s = [e nextObject])) |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 127 | env[i++] = (char *) [[NSString stringWithFormat:@"%@=%@", s, [environment objectForKey:s]] UTF8String]; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 128 | |
| 129 | if (posix_spawnattr_init && posix_spawn && posix_spawnattr_setbinpref_np && posix_spawnattr_setflags) { |
| 130 | posix_spawnattr_t attr; |
| 131 | posix_spawnattr_init(&attr); |
| 132 | cpu_type_t architecturePreference[] = { preferredArchitecture(), CPU_TYPE_X86 }; |
| 133 | posix_spawnattr_setbinpref_np(&attr, 2, architecturePreference, 0); |
| 134 | short flags = POSIX_SPAWN_SETEXEC; |
| 135 | posix_spawnattr_setflags(&attr, flags); |
| 136 | posix_spawn(NULL, [executable fileSystemRepresentation], NULL, &attr, argv, env); |
| 137 | } else |
| 138 | execve([executable fileSystemRepresentation], argv, env); |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 139 | } |
| 140 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 141 | static NSBundle *locateSafariBundle() |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 142 | { |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 143 | NSArray *applicationDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES); |
| 144 | NSEnumerator *e = [applicationDirectories objectEnumerator]; |
| 145 | NSString *applicationDirectory; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 146 | while ((applicationDirectory = [e nextObject])) { |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 147 | NSString *possibleSafariPath = [applicationDirectory stringByAppendingPathComponent:@"Safari.app"]; |
| 148 | NSBundle *possibleSafariBundle = [NSBundle bundleWithPath:possibleSafariPath]; |
| 149 | if ([[possibleSafariBundle bundleIdentifier] isEqualToString:@"com.apple.Safari"]) |
| 150 | return possibleSafariBundle; |
| 151 | } |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 152 | |
| 153 | CFURLRef safariURL = nil; |
ddkilzer@apple.com | 2bf5733 | 2018-08-31 10:54:16 +0000 | [diff] [blame] | 154 | #pragma clang diagnostic push |
| 155 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 156 | OSStatus err = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.Safari"), nil, nil, &safariURL); |
ddkilzer@apple.com | 2bf5733 | 2018-08-31 10:54:16 +0000 | [diff] [blame] | 157 | #pragma clang diagnostic pop |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 158 | if (err != noErr) |
| 159 | displayErrorAndQuit(@"Unable to locate Safari", @"Nightly builds of WebKit require Safari to run. Please check that it is available and then try again."); |
| 160 | |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 161 | NSBundle *safariBundle = [NSBundle bundleWithPath:[(NSURL *)safariURL path]]; |
| 162 | CFRelease(safariURL); |
| 163 | return safariBundle; |
| 164 | } |
| 165 | |
dfarler@apple.com | 0b05065 | 2013-06-28 20:38:55 +0000 | [diff] [blame] | 166 | static NSString *determineExecutablePath(NSBundle *bundle) |
| 167 | { |
| 168 | NSString *safariExecutablePath = [bundle executablePath]; |
| 169 | |
| 170 | NSString *safariForWebKitDevelopmentExecutablePath = [bundle pathForAuxiliaryExecutable:@"SafariForWebKitDevelopment"]; |
| 171 | if (![[NSFileManager defaultManager] fileExistsAtPath:safariForWebKitDevelopmentExecutablePath]) |
| 172 | return safariExecutablePath; |
| 173 | |
| 174 | SecStaticCodeRef staticCode; |
| 175 | if (SecStaticCodeCreateWithPath((CFURLRef)[bundle executableURL], kSecCSDefaultFlags, &staticCode) != noErr) |
| 176 | return [bundle executablePath]; |
| 177 | |
| 178 | NSDictionary *codeInformation; |
| 179 | if (SecCodeCopySigningInformation(staticCode, kSecCSRequirementInformation, (CFDictionaryRef*)&codeInformation) != noErr) { |
| 180 | CFRelease(staticCode); |
| 181 | return safariExecutablePath; |
| 182 | } |
| 183 | CFRelease(staticCode); |
| 184 | [codeInformation autorelease]; |
| 185 | |
| 186 | if ([codeInformation objectForKey:(id)kSecCodeInfoEntitlements]) |
| 187 | return safariForWebKitDevelopmentExecutablePath; |
| 188 | |
| 189 | return safariExecutablePath; |
| 190 | } |
| 191 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 192 | static NSString *currentMacOSXVersion() |
| 193 | { |
mrowe@apple.com | cbb2ed4 | 2013-11-20 06:01:19 +0000 | [diff] [blame] | 194 | // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want. |
| 195 | NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0]; |
| 196 | NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"]; |
| 197 | NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath]; |
| 198 | return [systemVersionInfo objectForKey:@"ProductVersion"]; |
| 199 | } |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 200 | |
mrowe@apple.com | cbb2ed4 | 2013-11-20 06:01:19 +0000 | [diff] [blame] | 201 | static NSString *currentMacOSXMajorVersion() |
| 202 | { |
| 203 | NSArray *allComponents = [currentMacOSXVersion() componentsSeparatedByString:@"."]; |
| 204 | NSArray *majorAndMinorComponents = [allComponents objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)]]; |
| 205 | return [majorAndMinorComponents componentsJoinedByString:@"."]; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 206 | } |
| 207 | |
mitz@apple.com | ed970db | 2010-01-23 09:51:47 +0000 | [diff] [blame] | 208 | static NSString *fallbackMacOSXVersion(NSString *systemVersion) |
| 209 | { |
| 210 | NSDictionary *fallbackVersionMap = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"FallbackSystemVersions"]; |
| 211 | if (!fallbackVersionMap) |
| 212 | return nil; |
| 213 | NSString *fallbackSystemVersion = [fallbackVersionMap objectForKey:systemVersion]; |
| 214 | if (!fallbackSystemVersion || ![fallbackSystemVersion isKindOfClass:[NSString class]]) |
| 215 | return nil; |
| 216 | return fallbackSystemVersion; |
| 217 | } |
| 218 | |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 219 | static BOOL checkFrameworkPath(NSString *frameworkPath) |
| 220 | { |
| 221 | BOOL isDirectory = NO; |
| 222 | return [[NSFileManager defaultManager] fileExistsAtPath:frameworkPath isDirectory:&isDirectory] && isDirectory; |
| 223 | } |
| 224 | |
mrowe@apple.com | ddecc3e | 2009-07-28 23:15:42 +0000 | [diff] [blame] | 225 | static BOOL checkSafariVersion(NSBundle *safariBundle) |
| 226 | { |
| 227 | NSString *safariBundleVersion = [[safariBundle infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey]; |
| 228 | NSString *majorComponent = [[safariBundleVersion componentsSeparatedByString:@"."] objectAtIndex:0]; |
| 229 | NSString *majorVersion = [majorComponent substringFromIndex:[majorComponent length] - 3]; |
| 230 | return [majorVersion intValue] >= 530; |
| 231 | } |
| 232 | |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 233 | int main(int argc, char *argv[]) |
| 234 | { |
| 235 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 236 | |
mrowe@apple.com | cbb2ed4 | 2013-11-20 06:01:19 +0000 | [diff] [blame] | 237 | NSString *systemVersion = currentMacOSXMajorVersion(); |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 238 | NSString *frameworkPath = [[[NSBundle mainBundle] privateFrameworksPath] stringByAppendingPathComponent:systemVersion]; |
mitz@apple.com | ed970db | 2010-01-23 09:51:47 +0000 | [diff] [blame] | 239 | |
| 240 | BOOL frameworkPathIsUsable = checkFrameworkPath(frameworkPath); |
| 241 | |
| 242 | if (!frameworkPathIsUsable) { |
| 243 | NSString *fallbackSystemVersion = fallbackMacOSXVersion(systemVersion); |
| 244 | if (fallbackSystemVersion) { |
| 245 | frameworkPath = [[[NSBundle mainBundle] privateFrameworksPath] stringByAppendingPathComponent:fallbackSystemVersion]; |
| 246 | frameworkPathIsUsable = checkFrameworkPath(frameworkPath); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | if (!frameworkPathIsUsable) |
dfarler@apple.com | 0b05065 | 2013-06-28 20:38:55 +0000 | [diff] [blame] | 251 | displayErrorAndQuit([NSString stringWithFormat:@"OS X %@ is not supported", systemVersion], |
| 252 | [NSString stringWithFormat:@"Nightly builds of WebKit are not supported on OS X %@ at this time.", systemVersion]); |
mitz@apple.com | ed970db | 2010-01-23 09:51:47 +0000 | [diff] [blame] | 253 | |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 254 | NSString *pathToEnablerLib = [[NSBundle mainBundle] pathForResource:@"WebKitNightlyEnabler" ofType:@"dylib"]; |
dfarler@apple.com | 4476ec8 | 2013-12-16 18:17:01 +0000 | [diff] [blame] | 255 | NSString *dyldInsertLibraries = pathToEnablerLib; |
| 256 | NSString *pathToASanCrashReporterLib = [[NSBundle mainBundle] pathForResource:@"libasancrashreporter" ofType:@"dylib"]; |
| 257 | if (pathToASanCrashReporterLib) |
| 258 | dyldInsertLibraries = [@[ pathToASanCrashReporterLib, pathToEnablerLib ] componentsJoinedByString:@":"]; |
bdash | 9083385 | 2007-06-06 10:55:43 +0000 | [diff] [blame] | 259 | |
mrowe@apple.com | ddecc3e | 2009-07-28 23:15:42 +0000 | [diff] [blame] | 260 | NSBundle *safariBundle = locateSafariBundle(); |
dfarler@apple.com | 0b05065 | 2013-06-28 20:38:55 +0000 | [diff] [blame] | 261 | NSString *executablePath = determineExecutablePath(safariBundle); |
mrowe@apple.com | ddecc3e | 2009-07-28 23:15:42 +0000 | [diff] [blame] | 262 | |
mrowe@apple.com | ddecc3e | 2009-07-28 23:15:42 +0000 | [diff] [blame] | 263 | if (!checkSafariVersion(safariBundle)) { |
| 264 | NSString *safariVersion = [[safariBundle localizedInfoDictionary] objectForKey:@"CFBundleShortVersionString"]; |
| 265 | displayErrorAndQuit([NSString stringWithFormat:@"Safari %@ is not supported", safariVersion], |
| 266 | [NSString stringWithFormat:@"Nightly builds of WebKit are not supported with Safari %@ at this time. Please update to a newer version of Safari.", safariVersion]); |
| 267 | } |
| 268 | |
bdash | 9083385 | 2007-06-06 10:55:43 +0000 | [diff] [blame] | 269 | if ([frameworkPath rangeOfString:@":"].location != NSNotFound || |
| 270 | [pathToEnablerLib rangeOfString:@":"].location != NSNotFound) |
| 271 | displayErrorAndQuit(@"Unable to launch Safari", |
| 272 | @"WebKit is located at a path containing an unsupported character. Please move WebKit to a different location and try again."); |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 273 | |
| 274 | NSMutableArray *arguments = [NSMutableArray arrayWithObject:executablePath]; |
| 275 | NSMutableDictionary *environment = [[[NSDictionary dictionaryWithObjectsAndKeys:frameworkPath, @"DYLD_FRAMEWORK_PATH", @"YES", @"WEBKIT_UNSET_DYLD_FRAMEWORK_PATH", |
dfarler@apple.com | 4476ec8 | 2013-12-16 18:17:01 +0000 | [diff] [blame] | 276 | dyldInsertLibraries, @"DYLD_INSERT_LIBRARIES", [[NSBundle mainBundle] executablePath], @"WebKitAppPath", nil] mutableCopy] autorelease]; |
mrowe@apple.com | 6649851 | 2009-05-24 05:14:44 +0000 | [diff] [blame] | 277 | [environment addEntriesFromDictionary:[[NSProcessInfo processInfo] environment]]; |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 278 | addStartPageToArgumentsIfNeeded(arguments); |
| 279 | |
| 280 | while (*++argv) |
| 281 | [arguments addObject:[NSString stringWithUTF8String:*argv]]; |
| 282 | |
bdash | 51548af | 2007-01-15 00:53:11 +0000 | [diff] [blame] | 283 | myExecve(executablePath, arguments, environment); |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 284 | |
bdash | 51548af | 2007-01-15 00:53:11 +0000 | [diff] [blame] | 285 | char *error = strerror(errno); |
bdash | 0139db1 | 2007-03-13 09:21:41 +0000 | [diff] [blame] | 286 | NSString *errorMessage = [NSString stringWithFormat:@"Launching Safari at %@ failed with the error '%s' (%d)", [safariBundle bundlePath], error, errno]; |
bdash | 51548af | 2007-01-15 00:53:11 +0000 | [diff] [blame] | 287 | displayErrorAndQuit(@"Unable to launch Safari", errorMessage); |
mjs | 15819bc | 2006-04-06 04:14:24 +0000 | [diff] [blame] | 288 | |
| 289 | [pool release]; |
| 290 | return 0; |
| 291 | } |