OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/installer/gcapi_mac/gcapi.h" | 5 #include "chrome/installer/gcapi_mac/gcapi.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <sys/utsname.h> | 10 #include <sys/utsname.h> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // files are created with group of parent dir (good), owner of euid (good). | 152 // files are created with group of parent dir (good), owner of euid (good). |
153 chmod([system_path fileSystemRepresentation], Permissions() & ~0111); | 153 chmod([system_path fileSystemRepresentation], Permissions() & ~0111); |
154 return system_path; | 154 return system_path; |
155 } | 155 } |
156 | 156 |
157 // Failed, try user. | 157 // Failed, try user. |
158 // -stringByExpandingTildeInPath returns root's home directory if this is run | 158 // -stringByExpandingTildeInPath returns root's home directory if this is run |
159 // setuid root, and in that case the kSystemBrandPath path above should have | 159 // setuid root, and in that case the kSystemBrandPath path above should have |
160 // worked anyway. So only try user if geteuid() isn't root. | 160 // worked anyway. So only try user if geteuid() isn't root. |
161 if (geteuid() != 0) { | 161 if (geteuid() != 0) { |
162 NSString* user_path = [user_path stringByExpandingTildeInPath]; | 162 user_path = [user_path stringByExpandingTildeInPath]; |
163 if (CreatePathToFile(user_path) && | 163 if (CreatePathToFile(user_path) && |
164 [data writeToFile:user_path atomically:YES]) { | 164 [data writeToFile:user_path atomically:YES]) { |
165 chmod([user_path fileSystemRepresentation], Permissions() & ~0111); | 165 chmod([user_path fileSystemRepresentation], Permissions() & ~0111); |
166 return user_path; | 166 return user_path; |
167 } | 167 } |
168 } | 168 } |
169 return nil; | 169 return nil; |
170 } | 170 } |
171 | 171 |
172 NSString* WriteBrandCode(const char* brand_code) { | 172 NSString* WriteBrandCode(const char* brand_code) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // root. | 364 // root. |
365 } | 365 } |
366 return 1; | 366 return 1; |
367 } | 367 } |
368 | 368 |
369 int LaunchGoogleChrome() { | 369 int LaunchGoogleChrome() { |
370 @autoreleasepool { | 370 @autoreleasepool { |
371 return [[NSWorkspace sharedWorkspace] launchApplication:kChromeInstallPath]; | 371 return [[NSWorkspace sharedWorkspace] launchApplication:kChromeInstallPath]; |
372 } | 372 } |
373 } | 373 } |
OLD | NEW |