| Index: base/mac/authorization_util.mm
|
| diff --git a/base/mac/authorization_util.mm b/base/mac/authorization_util.mm
|
| index c2925896209aad9adc99481b856d0d9a23aca466..6cb8de3f73b8459cfbcb41fb56017d570647b5e8 100644
|
| --- a/base/mac/authorization_util.mm
|
| +++ b/base/mac/authorization_util.mm
|
| @@ -22,7 +22,10 @@
|
| namespace base {
|
| namespace mac {
|
|
|
| -AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
|
| +AuthorizationRef GetAuthorizationRightsWithPrompt(
|
| + AuthorizationRights* rights,
|
| + CFStringRef prompt,
|
| + AuthorizationFlags extraFlags) {
|
| // Create an empty AuthorizationRef.
|
| ScopedAuthorizationRef authorization;
|
| OSStatus status = AuthorizationCreate(NULL,
|
| @@ -34,12 +37,11 @@ AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
|
| return NULL;
|
| }
|
|
|
| - // Specify the "system.privilege.admin" right, which allows
|
| - // AuthorizationExecuteWithPrivileges to run commands as root.
|
| - AuthorizationItem right_items[] = {
|
| - {kAuthorizationRightExecute, 0, NULL, 0}
|
| - };
|
| - AuthorizationRights rights = {arraysize(right_items), right_items};
|
| + AuthorizationFlags flags = kAuthorizationFlagDefaults |
|
| + kAuthorizationFlagInteractionAllowed |
|
| + kAuthorizationFlagExtendRights |
|
| + kAuthorizationFlagPreAuthorize |
|
| + extraFlags;
|
|
|
| // product_logo_32.png is used instead of app.icns because Authorization
|
| // Services can't deal with .icns files.
|
| @@ -63,16 +65,12 @@ AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
|
| AuthorizationEnvironment environment = {arraysize(environment_items),
|
| environment_items};
|
|
|
| - AuthorizationFlags flags = kAuthorizationFlagDefaults |
|
| - kAuthorizationFlagInteractionAllowed |
|
| - kAuthorizationFlagExtendRights |
|
| - kAuthorizationFlagPreAuthorize;
|
| -
|
| status = AuthorizationCopyRights(authorization,
|
| - &rights,
|
| + rights,
|
| &environment,
|
| flags,
|
| NULL);
|
| +
|
| if (status != errAuthorizationSuccess) {
|
| if (status != errAuthorizationCanceled) {
|
| OSSTATUS_LOG(ERROR, status) << "AuthorizationCopyRights";
|
| @@ -83,6 +81,17 @@ AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
|
| return authorization.release();
|
| }
|
|
|
| +AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
|
| + // Specify the "system.privilege.admin" right, which allows
|
| + // AuthorizationExecuteWithPrivileges to run commands as root.
|
| + AuthorizationItem right_items[] = {
|
| + {kAuthorizationRightExecute, 0, NULL, 0}
|
| + };
|
| + AuthorizationRights rights = {arraysize(right_items), right_items};
|
| +
|
| + return GetAuthorizationRightsWithPrompt(&rights, prompt, 0);
|
| +}
|
| +
|
| OSStatus ExecuteWithPrivilegesAndGetPID(AuthorizationRef authorization,
|
| const char* tool_path,
|
| AuthorizationFlags options,
|
|
|