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

Side by Side Diff: session_manager_service.h

Issue 6469072: [login_manager] Use keygen helper to generate owner key (Closed) Base URL: http://git.chromium.org/git/login_manager.git@master
Patch Set: Add a few constants Created 9 years, 10 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
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 <dbus/dbus.h> 8 #include <dbus/dbus.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <glib.h> 10 #include <glib.h>
11 #include <gtest/gtest.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/ref_counted.h> 19 #include <base/ref_counted.h>
20 #include <base/scoped_ptr.h> 20 #include <base/scoped_ptr.h>
21 #include <base/thread.h> 21 #include <base/thread.h>
22 #include <chromeos/dbus/abstract_dbus_service.h> 22 #include <chromeos/dbus/abstract_dbus_service.h>
23 #include <chromeos/dbus/dbus.h> 23 #include <chromeos/dbus/dbus.h>
24 #include <chromeos/dbus/service_constants.h> 24 #include <chromeos/dbus/service_constants.h>
25 25
26 #include "login_manager/child_job.h"
26 #include "login_manager/file_checker.h" 27 #include "login_manager/file_checker.h"
27 #include "login_manager/owner_key.h" 28 #include "login_manager/owner_key.h"
28 #include "login_manager/owner_key_loss_mitigator.h" 29 #include "login_manager/owner_key_loss_mitigator.h"
29 #include "login_manager/pref_store.h" 30 #include "login_manager/pref_store.h"
30 #include "login_manager/system_utils.h" 31 #include "login_manager/system_utils.h"
31 #include "login_manager/upstart_signal_emitter.h" 32 #include "login_manager/upstart_signal_emitter.h"
32 33
33 namespace base { 34 namespace base {
34 class MessageLoopProxy; 35 class MessageLoopProxy;
35 } // namespace base 36 } // namespace base
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 94 }
94 void set_ownerkey(OwnerKey* key) { 95 void set_ownerkey(OwnerKey* key) {
95 session_manager_service_->key_.reset(key); 96 session_manager_service_->key_.reset(key);
96 } 97 }
97 void set_prefstore(PrefStore* store) { 98 void set_prefstore(PrefStore* store) {
98 session_manager_service_->store_.reset(store); 99 session_manager_service_->store_.reset(store);
99 } 100 }
100 void set_upstart_signal_emitter(UpstartSignalEmitter* emitter) { 101 void set_upstart_signal_emitter(UpstartSignalEmitter* emitter) {
101 session_manager_service_->upstart_signal_emitter_.reset(emitter); 102 session_manager_service_->upstart_signal_emitter_.reset(emitter);
102 } 103 }
104 void set_keygen_job(ChildJobInterface* job) {
105 session_manager_service_->keygen_job_.reset(job);
106 }
103 107
104 // Sets whether the the manager exits when a child finishes. 108 // Sets whether the the manager exits when a child finishes.
105 void set_exit_on_child_done(bool do_exit) { 109 void set_exit_on_child_done(bool do_exit) {
106 session_manager_service_->exit_on_child_done_ = do_exit; 110 session_manager_service_->exit_on_child_done_ = do_exit;
107 } 111 }
108 112
109 // Executes the CleanupChildren() method on the manager. 113 // Executes the CleanupChildren() method on the manager.
110 void CleanupChildren(int timeout) { 114 void CleanupChildren(int timeout) {
111 session_manager_service_->CleanupChildren(timeout); 115 session_manager_service_->CleanupChildren(timeout);
112 } 116 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // with provided. 302 // with provided.
299 gboolean RestartJob(gint pid, 303 gboolean RestartJob(gint pid,
300 gchar* arguments, 304 gchar* arguments,
301 gboolean* OUT_done, 305 gboolean* OUT_done,
302 GError** error); 306 GError** error);
303 307
304 // Restarts (or starts if stopped) the entd upstart job. Returns if 308 // Restarts (or starts if stopped) the entd upstart job. Returns if
305 // start was successful. 309 // start was successful.
306 gboolean RestartEntd(GError** error); 310 gboolean RestartEntd(GError** error);
307 311
312 // Ensures that the public key in |buf| is legitimately paired with
313 // a private key held by the current user, signs and stores some
314 // ownership-related metadata, and then stores this key off as the
315 // new device Owner key.
316 void ValidateAndStoreOwnerKey(const std::string& buf);
317
308 // Perform very, very basic validation of |email_address|. 318 // Perform very, very basic validation of |email_address|.
309 static bool ValidateEmail(const std::string& email_address); 319 static bool ValidateEmail(const std::string& email_address);
310 320
311 // Breaks |args| into separate arg lists, delimited by "--". 321 // Breaks |args| into separate arg lists, delimited by "--".
312 // No initial "--" is needed, but is allowed. 322 // No initial "--" is needed, but is allowed.
313 // ("a", "b", "c") => ("a", "b", "c") 323 // ("a", "b", "c") => ("a", "b", "c")
314 // ("a", "b", "c", "--", "d", "e", "f") => 324 // ("a", "b", "c", "--", "d", "e", "f") =>
315 // ("a", "b", "c"), ("d", "e", "f"). 325 // ("a", "b", "c"), ("d", "e", "f").
316 // Converts args from wide to plain strings. 326 // Converts args from wide to plain strings.
317 static std::vector<std::vector<std::string> > GetArgLists( 327 static std::vector<std::vector<std::string> > GetArgLists(
(...skipping 19 matching lines...) Expand all
337 static void SIGHUPHandler(int signal); 347 static void SIGHUPHandler(int signal);
338 static void SIGINTHandler(int signal); 348 static void SIGINTHandler(int signal);
339 static void SIGTERMHandler(int signal); 349 static void SIGTERMHandler(int signal);
340 350
341 // |data| is a SessionManagerService* 351 // |data| is a SessionManagerService*
342 static DBusHandlerResult FilterMessage(DBusConnection* conn, 352 static DBusHandlerResult FilterMessage(DBusConnection* conn,
343 DBusMessage* message, 353 DBusMessage* message,
344 void* data); 354 void* data);
345 355
346 // |data| is a SessionManagerService* 356 // |data| is a SessionManagerService*
347 static void HandleChildExit(GPid pid, 357 static void HandleChildExit(GPid pid, gint status, gpointer data);
348 gint status, 358
349 gpointer data); 359 // |data| is a SessionManagerService*
360 static void HandleKeygenExit(GPid pid, gint status, gpointer data);
350 361
351 // |data| is a SessionManagerService*. This is a wrapper around 362 // |data| is a SessionManagerService*. This is a wrapper around
352 // ServiceShutdown() so that we can register it as the callback for 363 // ServiceShutdown() so that we can register it as the callback for
353 // when |source| has data to read. 364 // when |source| has data to read.
354 static gboolean HandleKill(GIOChannel* source, 365 static gboolean HandleKill(GIOChannel* source,
355 GIOCondition condition, 366 GIOCondition condition,
356 gpointer data); 367 gpointer data);
357 368
358 // So that we can enqueue an event that will exit the main loop. 369 // So that we can enqueue an event that will exit the main loop.
359 // |data| is a SessionManagerService* 370 // |data| is a SessionManagerService*
(...skipping 16 matching lines...) Expand all
376 // in his nssdb. Returns false if not, or if that cannot be determined. 387 // in his nssdb. Returns false if not, or if that cannot be determined.
377 // |error| is set appropriately on failure. 388 // |error| is set appropriately on failure.
378 gboolean CurrentUserHasOwnerKey(const std::vector<uint8>& pub_key, 389 gboolean CurrentUserHasOwnerKey(const std::vector<uint8>& pub_key,
379 GError** error); 390 GError** error);
380 391
381 // Cache |email_address| in |current_user_| and return true, if the address 392 // Cache |email_address| in |current_user_| and return true, if the address
382 // passes validation. Otherwise, set |error| appropriately and return false. 393 // passes validation. Otherwise, set |error| appropriately and return false.
383 gboolean ValidateAndCacheUserEmail(const gchar* email_address, 394 gboolean ValidateAndCacheUserEmail(const gchar* email_address,
384 GError** error); 395 GError** error);
385 396
397 // Searches through |child_pids_| for |pid|. Returns index of child if
398 // found, -1 if not.
399 int FindChildByPid(int pid);
400
386 // Terminate all children, with increasing prejudice. 401 // Terminate all children, with increasing prejudice.
387 void CleanupChildren(int timeout); 402 void CleanupChildren(int timeout);
388 403
389 // If the current user has access to the owner private key 404 // Assuming the current user has access to the owner private key
390 // (read: is the owner), this call whitelists |current_user_|, sets a 405 // (read: is the owner), this call whitelists |current_user_|, sets a
391 // property indicating |current_user_| is the owner, and schedules both 406 // property indicating |current_user_| is the owner, and schedules both
392 // a PersistWhitelist() and a PersistStore(). 407 // a PersistWhitelist() and a PersistStore().
393 // Returns false on failure, with |error| set appropriately. 408 // Returns false on failure, with |error| set appropriately.
394 gboolean StoreOwnerProperties(GError** error); 409 gboolean StoreOwnerProperties(GError** error);
395 410
396 // Signs and stores |name|=|value|, and schedules a PersistStore(). 411 // Signs and stores |name|=|value|, and schedules a PersistStore().
397 // Returns false on failure, populating |error| with |err_msg|. 412 // Returns false on failure, populating |error| with |err_msg|.
398 gboolean SignAndStoreProperty(const std::string& name, 413 gboolean SignAndStoreProperty(const std::string& name,
399 const std::string& value, 414 const std::string& value,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 void PersistKey(); 449 void PersistKey();
435 450
436 // |store_| is persisted to disk, and then posts a task to |message_loop_| 451 // |store_| is persisted to disk, and then posts a task to |message_loop_|
437 // to signal Chromium when done. 452 // to signal Chromium when done.
438 void PersistWhitelist(); 453 void PersistWhitelist();
439 454
440 // |store_| is persisted to disk, and then posts a task to |message_loop_| 455 // |store_| is persisted to disk, and then posts a task to |message_loop_|
441 // to signal Chromium when done. 456 // to signal Chromium when done.
442 void PersistStore(); 457 void PersistStore();
443 458
459 void StartKeyGeneration();
460
444 // Uses |system_| to send |signal_name| to Chromium. Attaches a payload 461 // Uses |system_| to send |signal_name| to Chromium. Attaches a payload
445 // to the signal indicating the status of |succeeded|. 462 // to the signal indicating the status of |succeeded|.
446 void SendSignal(const char signal_name[], bool succeeded); 463 void SendSignal(const char signal_name[], bool succeeded);
447 464
448 bool ShouldRunChildren(); 465 bool ShouldRunChildren();
449 // Returns true if |child_job| believes it should be stopped. 466 // Returns true if |child_job| believes it should be stopped.
450 // If the child believes it should be stopped (as opposed to not run anymore) 467 // If the child believes it should be stopped (as opposed to not run anymore)
451 // we actually exit the Service as well. 468 // we actually exit the Service as well.
452 bool ShouldStopChild(ChildJobInterface* child_job); 469 bool ShouldStopChild(ChildJobInterface* child_job);
453 470
454 static const uint32 kMaxEmailSize; 471 static const uint32 kMaxEmailSize;
455 static const char kEmailSeparator; 472 static const char kEmailSeparator;
456 static const char kLegalCharacters[]; 473 static const char kLegalCharacters[];
457 static const char kIncognitoUser[]; 474 static const char kIncognitoUser[];
458 // The name of the pref that Chrome sets to track who the owner is. 475 // The name of the pref that Chrome sets to track who the owner is.
459 static const char kDeviceOwnerPref[]; 476 static const char kDeviceOwnerPref[];
460 static const char kIOThreadName[]; 477 static const char kIOThreadName[];
478 static const char kKeygenExecutable[];
479 static const char kTemporaryKeyFilename[];
461 480
462 std::vector<ChildJobInterface*> child_jobs_; 481 std::vector<ChildJobInterface*> child_jobs_;
463 std::vector<int> child_pids_; 482 std::vector<int> child_pids_;
464 bool exit_on_child_done_; 483 bool exit_on_child_done_;
484 scoped_ptr<ChildJobInterface> keygen_job_;
465 485
466 gobject::SessionManager* session_manager_; 486 gobject::SessionManager* session_manager_;
467 GMainLoop* main_loop_; 487 GMainLoop* main_loop_;
468 scoped_ptr<MessageLoop> dont_use_directly_; 488 scoped_ptr<MessageLoop> dont_use_directly_;
469 scoped_refptr<base::MessageLoopProxy> message_loop_; 489 scoped_refptr<base::MessageLoopProxy> message_loop_;
470 490
471 scoped_ptr<SystemUtils> system_; 491 scoped_ptr<SystemUtils> system_;
472 scoped_ptr<NssUtil> nss_; 492 scoped_ptr<NssUtil> nss_;
473 scoped_ptr<OwnerKey> key_; 493 scoped_ptr<OwnerKey> key_;
474 scoped_ptr<PrefStore> store_; 494 scoped_ptr<PrefStore> store_;
(...skipping 17 matching lines...) Expand all
492 512
493 bool shutting_down_; 513 bool shutting_down_;
494 bool shutdown_already_; 514 bool shutdown_already_;
495 515
496 friend class TestAPI; 516 friend class TestAPI;
497 DISALLOW_COPY_AND_ASSIGN(SessionManagerService); 517 DISALLOW_COPY_AND_ASSIGN(SessionManagerService);
498 }; 518 };
499 } // namespace login_manager 519 } // namespace login_manager
500 520
501 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ 521 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_
OLDNEW
« no previous file with comments | « session_manager_main.cc ('k') | session_manager_service.cc » ('j') | session_manager_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698