summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/authorization_util.h
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-28 22:05:11 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-28 22:05:11 +0000
commiteee9f55299e1223c156f1bcf86f557446009cc5e (patch)
tree5eb3b23a1754afca47a4a8e5b74078224d0c122e /chrome/browser/cocoa/authorization_util.h
parent110086c1a303bdcf3829a289efebef7e9378ab7b (diff)
downloadchromium_src-eee9f55299e1223c156f1bcf86f557446009cc5e.zip
chromium_src-eee9f55299e1223c156f1bcf86f557446009cc5e.tar.gz
chromium_src-eee9f55299e1223c156f1bcf86f557446009cc5e.tar.bz2
In-application Keystone ticket promotion.
The concept of "ticket promotion" is added to the application when Keystone is in use. Ticket promotion is used to turn a user Keystone ticket, which Chrome normally establishes when it launches, into a system Keystone ticket, after successful user authentication and authorization. Having a system Keystone with a system ticket means that updates are applied with root privileges instead of user privileges, essentially eliminating the possibility that a user will fall off of the auto-update train because they can read and execute but not write the application. Two principles of promotion apply: - An application on a user ticket NEEDS promotion if it determines that it doesn't have permission to write to itself. Being on a user ticket, an update attempt would fail. - An application on a user ticket WANTS promotion if it already NEEDS promotion. Additionally, if it is installed in a system-wide location such as /Applications, it will WANT promotion, even if it does not NEED it. If promotion is needed, an info bar will show up on launch requesting it. This info bar works similarly to the default browser info bar: it has a "don't bother me again" button, it will only show up after the first launch, it won't disappear on navigation if the navigation happens very quickly, and it won't show itself if another info bar is up. This means that if both the default browser info bar and the promotion info bar have a shot at showing, only one will win. In my experience, each wins about half of the time. If promotion is needed, the update UI in the About window will be hidden. Checking for updates and offering to apply them doesn't make much sense when the update won't be able to install successfully. All of the auto-update machinery is still working in the background, but the About window UI is hidden. If promotion is wanted, the About window will contain a new button allowing the user to enter promotion. This gives access to the same promotion routine as the promotion info bar. It can be used even from an administrative account that is able to update the application without promotion. It's intended to be used by the system administrator of the family without requiring them to switch to one of the kids' accounts. BUG=16360 TEST=Exhaustively, please. Review URL: http://codereview.chromium.org/437053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/authorization_util.h')
-rw-r--r--chrome/browser/cocoa/authorization_util.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/authorization_util.h b/chrome/browser/cocoa/authorization_util.h
new file mode 100644
index 0000000..2d7c09d
--- /dev/null
+++ b/chrome/browser/cocoa/authorization_util.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_AUTHORIZATION_UTIL_H_
+#define CHROME_BROWSER_COCOA_AUTHORIZATION_UTIL_H_
+
+// AuthorizationExecuteWithPrivileges fork()s and exec()s the tool, but it
+// does not wait() for it. It also doesn't provide the caller with access to
+// the forked pid. If used irresponsibly, zombie processes will accumulate.
+//
+// Apple's really gotten us between a rock and a hard place, here.
+//
+// Fortunately, AuthorizationExecuteWithPrivileges does give access to the
+// tool's stdout (and stdin) via a FILE* pipe. The tool can output its pid
+// to this pipe, and the main program can read it, and then have something
+// that it can wait() for.
+//
+// The contract is that any tool executed by the wrappers declared in this
+// file must print its pid to stdout on a line by itself before doing anything
+// else.
+//
+// http://developer.apple.com/mac/library/samplecode/BetterAuthorizationSample/listing1.html
+// (Look for "What's This About Zombies?")
+
+#include <Security/Authorization.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+namespace authorization_util {
+
+// Calls straight through to AuthorizationExecuteWithPrivileges. If that
+// call succeeds, |pid| will be set to the pid of the executed tool. If the
+// pid can't be determined, |pid| will be set to -1. |pid| must not be NULL.
+// |pipe| may be NULL, but the tool will always be executed with a pipe in
+// order to read the pid from its stdout.
+OSStatus ExecuteWithPrivilegesAndGetPID(AuthorizationRef authorization,
+ const char* tool_path,
+ AuthorizationFlags options,
+ const char** arguments,
+ FILE** pipe,
+ pid_t* pid);
+
+// Calls ExecuteWithPrivilegesAndGetPID, and if that call succeeds, calls
+// waitpid() to wait for the process to exit. If waitpid() succeeds, the
+// exit status is placed in |exit_status|, otherwise, -1 is stored.
+// |exit_status| may be NULL and this function will still wait for the process
+// to exit.
+OSStatus ExecuteWithPrivilegesAndWait(AuthorizationRef authorization,
+ const char* tool_path,
+ AuthorizationFlags options,
+ const char** arguments,
+ FILE** pipe,
+ int* exit_status);
+
+} // namespace authorization_util
+
+#endif // CHROME_BROWSER_COCOA_AUTHORIZATION_UTIL_H_