Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: base/mac/authorization_util.h

Issue 9791049: New BASE_EXPORT macros. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_MAC_AUTHORIZATION_UTIL_H_ 5 #ifndef BASE_MAC_AUTHORIZATION_UTIL_H_
6 #define BASE_MAC_AUTHORIZATION_UTIL_H_ 6 #define BASE_MAC_AUTHORIZATION_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 // AuthorizationExecuteWithPrivileges fork()s and exec()s the tool, but it 9 // AuthorizationExecuteWithPrivileges fork()s and exec()s the tool, but it
10 // does not wait() for it. It also doesn't provide the caller with access to 10 // does not wait() for it. It also doesn't provide the caller with access to
(...skipping 11 matching lines...) Expand all
22 // else. 22 // else.
23 // 23 //
24 // http://developer.apple.com/library/mac/#samplecode/BetterAuthorizationSample/ Listings/BetterAuthorizationSampleLib_c.html 24 // http://developer.apple.com/library/mac/#samplecode/BetterAuthorizationSample/ Listings/BetterAuthorizationSampleLib_c.html
25 // (Look for "What's This About Zombies?") 25 // (Look for "What's This About Zombies?")
26 26
27 #include <CoreFoundation/CoreFoundation.h> 27 #include <CoreFoundation/CoreFoundation.h>
28 #include <Security/Authorization.h> 28 #include <Security/Authorization.h>
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <sys/types.h> 30 #include <sys/types.h>
31 31
32 #include "base/base_export.h"
33
32 namespace base { 34 namespace base {
33 namespace mac { 35 namespace mac {
34 36
35 // Obtains an AuthorizationRef that can be used to run commands as root. If 37 // Obtains an AuthorizationRef that can be used to run commands as root. If
36 // necessary, prompts the user for authentication. If the user is prompted, 38 // necessary, prompts the user for authentication. If the user is prompted,
37 // |prompt| will be used as the prompt string and an icon appropriate for the 39 // |prompt| will be used as the prompt string and an icon appropriate for the
38 // application will be displayed in a prompt dialog. Note that the system 40 // application will be displayed in a prompt dialog. Note that the system
39 // appends its own text to the prompt string. Returns NULL on failure. 41 // appends its own text to the prompt string. Returns NULL on failure.
42 BASE_EXPORT
40 AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt); 43 AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt);
41 44
42 // Calls straight through to AuthorizationExecuteWithPrivileges. If that 45 // Calls straight through to AuthorizationExecuteWithPrivileges. If that
43 // call succeeds, |pid| will be set to the pid of the executed tool. If the 46 // call succeeds, |pid| will be set to the pid of the executed tool. If the
44 // pid can't be determined, |pid| will be set to -1. |pid| must not be NULL. 47 // pid can't be determined, |pid| will be set to -1. |pid| must not be NULL.
45 // |pipe| may be NULL, but the tool will always be executed with a pipe in 48 // |pipe| may be NULL, but the tool will always be executed with a pipe in
46 // order to read the pid from its stdout. 49 // order to read the pid from its stdout.
47 OSStatus ExecuteWithPrivilegesAndGetPID(AuthorizationRef authorization, 50 OSStatus ExecuteWithPrivilegesAndGetPID(AuthorizationRef authorization,
48 const char* tool_path, 51 const char* tool_path,
49 AuthorizationFlags options, 52 AuthorizationFlags options,
50 const char** arguments, 53 const char** arguments,
51 FILE** pipe, 54 FILE** pipe,
52 pid_t* pid); 55 pid_t* pid);
53 56
54 // Calls ExecuteWithPrivilegesAndGetPID, and if that call succeeds, calls 57 // Calls ExecuteWithPrivilegesAndGetPID, and if that call succeeds, calls
55 // waitpid() to wait for the process to exit. If waitpid() succeeds, the 58 // waitpid() to wait for the process to exit. If waitpid() succeeds, the
56 // exit status is placed in |exit_status|, otherwise, -1 is stored. 59 // exit status is placed in |exit_status|, otherwise, -1 is stored.
57 // |exit_status| may be NULL and this function will still wait for the process 60 // |exit_status| may be NULL and this function will still wait for the process
58 // to exit. 61 // to exit.
62 BASE_EXPORT
59 OSStatus ExecuteWithPrivilegesAndWait(AuthorizationRef authorization, 63 OSStatus ExecuteWithPrivilegesAndWait(AuthorizationRef authorization,
60 const char* tool_path, 64 const char* tool_path,
61 AuthorizationFlags options, 65 AuthorizationFlags options,
62 const char** arguments, 66 const char** arguments,
63 FILE** pipe, 67 FILE** pipe,
64 int* exit_status); 68 int* exit_status);
65 69
66 } // namespace mac 70 } // namespace mac
67 } // namespace base 71 } // namespace base
68 72
69 #endif // BASE_MAC_AUTHORIZATION_UTIL_H_ 73 #endif // BASE_MAC_AUTHORIZATION_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698