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

Side by Side Diff: session_manager_service.h

Issue 6239002: [login_manager] Prevent non-children from calling RestartJob (Closed) Base URL: http://git.chromium.org/git/login_manager.git@master
Patch Set: Created 9 years, 11 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 | session_manager_service.cc » ('j') | 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) 2009-2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009-2010 The Chromium OS 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 LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ 5 #ifndef LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_
6 #define LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ 6 #define LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_
7 7
8 #include <gtest/gtest.h> 8 #include <dbus/dbus.h>
9
10 #include <errno.h> 9 #include <errno.h>
11 #include <glib.h> 10 #include <glib.h>
11 #include <gtest/gtest.h>
12 #include <signal.h> 12 #include <signal.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include <base/basictypes.h> 18 #include <base/basictypes.h>
19 #include <base/scoped_ptr.h> 19 #include <base/scoped_ptr.h>
20 #include <chromeos/dbus/abstract_dbus_service.h> 20 #include <chromeos/dbus/abstract_dbus_service.h>
21 #include <chromeos/dbus/dbus.h> 21 #include <chromeos/dbus/dbus.h>
22 #include <chromeos/dbus/service_constants.h> 22 #include <chromeos/dbus/service_constants.h>
23 23
24 #include "login_manager/file_checker.h" 24 #include "login_manager/file_checker.h"
25 #include "login_manager/owner_key.h" 25 #include "login_manager/owner_key.h"
26 #include "login_manager/owner_key_loss_mitigator.h" 26 #include "login_manager/owner_key_loss_mitigator.h"
27 #include "login_manager/pref_store.h" 27 #include "login_manager/pref_store.h"
28 #include "login_manager/system_utils.h" 28 #include "login_manager/system_utils.h"
29 #include "login_manager/upstart_signal_emitter.h" 29 #include "login_manager/upstart_signal_emitter.h"
30 30
31 class CommandLine;
32
33 namespace login_manager { 31 namespace login_manager {
34 namespace gobject { 32 namespace gobject {
35 struct SessionManager; 33 struct SessionManager;
36 } // namespace gobject 34 } // namespace gobject
37 35
38 class ChildJobInterface; 36 class ChildJobInterface;
37 class CommandLine;
39 class NssUtil; 38 class NssUtil;
40 39
41 // Provides a wrapper for exporting SessionManagerInterface to 40 // Provides a wrapper for exporting SessionManagerInterface to
42 // D-Bus and entering the glib run loop. 41 // D-Bus and entering the glib run loop.
43 // 42 //
44 // ::g_type_init() must be called before this class is used. 43 // ::g_type_init() must be called before this class is used.
45 // 44 //
46 // All signatures used in the methods of the ownership API are 45 // All signatures used in the methods of the ownership API are
47 // SHA1 with RSA encryption. 46 // SHA1 with RSA encryption.
48 class SessionManagerService : public chromeos::dbus::AbstractDbusService { 47 class SessionManagerService : public chromeos::dbus::AbstractDbusService {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 : session_manager_service_(session_manager_service) {} 123 : session_manager_service_(session_manager_service) {}
125 SessionManagerService* session_manager_service_; 124 SessionManagerService* session_manager_service_;
126 }; 125 };
127 126
128 // TestApi exposes internal routines for testing purposes. 127 // TestApi exposes internal routines for testing purposes.
129 TestApi test_api() { return TestApi(this); } 128 TestApi test_api() { return TestApi(this); }
130 129
131 //////////////////////////////////////////////////////////////////////////// 130 ////////////////////////////////////////////////////////////////////////////
132 // Implementing chromeos::dbus::AbstractDbusService 131 // Implementing chromeos::dbus::AbstractDbusService
133 virtual bool Initialize(); 132 virtual bool Initialize();
133 virtual bool Register(const chromeos::dbus::BusConnection &conn);
134 virtual bool Reset(); 134 virtual bool Reset();
135 135
136 // Takes ownership of |file_checker|. 136 // Takes ownership of |file_checker|.
137 void set_file_checker(FileChecker* file_checker) { 137 void set_file_checker(FileChecker* file_checker) {
138 file_checker_.reset(file_checker); 138 file_checker_.reset(file_checker);
139 } 139 }
140 140
141 // Takes ownership of |mitigator|. 141 // Takes ownership of |mitigator|.
142 void set_mitigator(OwnerKeyLossMitigator* mitigator) { 142 void set_mitigator(OwnerKeyLossMitigator* mitigator) {
143 mitigator_.reset(mitigator); 143 mitigator_.reset(mitigator);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 virtual bool Shutdown(); 178 virtual bool Shutdown();
179 179
180 // Fork, then call child_job_->Run() in the child and set a 180 // Fork, then call child_job_->Run() in the child and set a
181 // babysitter in the parent's glib default context that calls 181 // babysitter in the parent's glib default context that calls
182 // HandleChildExit when the child is done. 182 // HandleChildExit when the child is done.
183 void RunChildren(); 183 void RunChildren();
184 184
185 // Run one of the children. 185 // Run one of the children.
186 int RunChild(ChildJobInterface* child_job); 186 int RunChild(ChildJobInterface* child_job);
187 187
188 bool IsKnownChild(int pid);
189
188 // Tell us that, if we want, we can cause a graceful exit from g_main_loop. 190 // Tell us that, if we want, we can cause a graceful exit from g_main_loop.
189 void AllowGracefulExit(); 191 void AllowGracefulExit();
190 192
191 //////////////////////////////////////////////////////////////////////////// 193 ////////////////////////////////////////////////////////////////////////////
192 // SessionManagerService commands 194 // SessionManagerService commands
193 195
194 // Emits the "login-prompt-ready" and "login-prompt-visible" upstart signals. 196 // Emits the "login-prompt-ready" and "login-prompt-visible" upstart signals.
195 gboolean EmitLoginPromptReady(gboolean* OUT_emitted, GError** error); 197 gboolean EmitLoginPromptReady(gboolean* OUT_emitted, GError** error);
196 gboolean EmitLoginPromptVisible(GError** error); 198 gboolean EmitLoginPromptVisible(GError** error);
197 199
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 306
305 static void do_nothing(int sig) {} 307 static void do_nothing(int sig) {}
306 308
307 // Common code between SIG{HUP, INT, TERM}Handler. 309 // Common code between SIG{HUP, INT, TERM}Handler.
308 static void GracefulShutdownHandler(int signal); 310 static void GracefulShutdownHandler(int signal);
309 static void SIGHUPHandler(int signal); 311 static void SIGHUPHandler(int signal);
310 static void SIGINTHandler(int signal); 312 static void SIGINTHandler(int signal);
311 static void SIGTERMHandler(int signal); 313 static void SIGTERMHandler(int signal);
312 314
313 // |data| is a SessionManagerService* 315 // |data| is a SessionManagerService*
316 static DBusHandlerResult FilterMessage(DBusConnection* conn,
317 DBusMessage* message,
318 void* data);
319
320 // |data| is a SessionManagerService*
314 static void HandleChildExit(GPid pid, 321 static void HandleChildExit(GPid pid,
315 gint status, 322 gint status,
316 gpointer data); 323 gpointer data);
317 324
318 // |data| is a SessionManagerService*. This is a wrapper around 325 // |data| is a SessionManagerService*. This is a wrapper around
319 // ServiceShutdown() so that we can register it as the callback for 326 // ServiceShutdown() so that we can register it as the callback for
320 // when |source| has data to read. 327 // when |source| has data to read.
321 static gboolean HandleKill(GIOChannel* source, 328 static gboolean HandleKill(GIOChannel* source,
322 GIOCondition condition, 329 GIOCondition condition,
323 gpointer data); 330 gpointer data);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 bool set_uid_; 457 bool set_uid_;
451 458
452 bool shutting_down_; 459 bool shutting_down_;
453 460
454 friend class TestAPI; 461 friend class TestAPI;
455 DISALLOW_COPY_AND_ASSIGN(SessionManagerService); 462 DISALLOW_COPY_AND_ASSIGN(SessionManagerService);
456 }; 463 };
457 } // namespace login_manager 464 } // namespace login_manager
458 465
459 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ 466 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | session_manager_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698