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

Side by Side Diff: cryptohomed.cc

Issue 6883081: cryptohome: look for flag file to determine if init pkcs11 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cryptohome.git@master
Patch Set: fix comment Created 9 years, 8 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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "service.h" 5 #include "service.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <base/at_exit.h> 10 #include <base/at_exit.h>
11 #include <base/command_line.h> 11 #include <base/command_line.h>
12 #include <base/logging.h> 12 #include <base/logging.h>
13 #include <chromeos/syslog_logging.h> 13 #include <chromeos/syslog_logging.h>
14 14
15 // TODO(wad) This is a placeholder DBus service which allows 15 // TODO(wad) This is a placeholder DBus service which allows
16 // chrome-login (and anything else running as chronos) 16 // chrome-login (and anything else running as chronos)
17 // to request to mount, unmount, or check if a mapper 17 // to request to mount, unmount, or check if a mapper
18 // device is mounted. This is very temporary but should 18 // device is mounted. This is very temporary but should
19 // serve as a baseline for moving all the shell scripts 19 // serve as a baseline for moving all the shell scripts
20 // into C++. 20 // into C++.
21 // We will need a "CheckKey" interface as well to simplify 21 // We will need a "CheckKey" interface as well to simplify
22 // offline authentication checks. 22 // offline authentication checks.
23 23
24 24
25 namespace switches { 25 namespace switches {
26 // Keeps std* open for debugging 26 // Keeps std* open for debugging
27 static const char *kNoCloseOnDaemonize = "noclose"; 27 static const char *kNoCloseOnDaemonize = "noclose";
28 } // namespace switches
29
28 // Enable PKCS#11 initialization via cryptohomed 30 // Enable PKCS#11 initialization via cryptohomed
29 // TODO(gauravsh): crosbug.com/14277 Remove this flag once this 31 // TODO(gauravsh): crosbug.com/14277 Remove this code once this
30 // feature is stabilized. 32 // feature is stabilized.
31 static const char *kEnablePkcs11Init = "cryptohome-init-pkcs11"; 33 static const char *kEnablePkcs11Path = "/home/chronos/.cryptohome-init-pkcs11";
32 } // namespace switches
33 34
34 int main(int argc, char **argv) { 35 int main(int argc, char **argv) {
35 ::g_type_init(); 36 ::g_type_init();
36 base::AtExitManager exit_manager; 37 base::AtExitManager exit_manager;
37 CommandLine::Init(argc, argv); 38 CommandLine::Init(argc, argv);
38 39
39 chromeos::InitLog(chromeos::kLogToSyslog | chromeos::kLogToStderr); 40 chromeos::InitLog(chromeos::kLogToSyslog | chromeos::kLogToStderr);
40 41
41 // Allow the commands to be configurable. 42 // Allow the commands to be configurable.
42 CommandLine *cl = CommandLine::ForCurrentProcess(); 43 CommandLine *cl = CommandLine::ForCurrentProcess();
43 int noclose = cl->HasSwitch(switches::kNoCloseOnDaemonize); 44 int noclose = cl->HasSwitch(switches::kNoCloseOnDaemonize);
44 PLOG_IF(FATAL, daemon(0, noclose) == -1) << "Failed to daemonize"; 45 PLOG_IF(FATAL, daemon(0, noclose) == -1) << "Failed to daemonize";
45 46
46 int enable_pkcs11_init = cl->HasSwitch(switches::kEnablePkcs11Init); 47 int enable_pkcs11_init = file_util::PathExists(FilePath(kEnablePkcs11Path));
gauravsh 2011/04/20 18:25:02 Should you use platform.FileExists here?
kmixter1 2011/04/20 19:00:58 Oddly there is none (and I actually tried that fir
47 cryptohome::Service service(enable_pkcs11_init); 48 cryptohome::Service service(enable_pkcs11_init);
48 if (!service.Initialize()) { 49 if (!service.Initialize()) {
49 LOG(FATAL) << "Service initialization failed"; 50 LOG(FATAL) << "Service initialization failed";
50 return 1; 51 return 1;
51 } 52 }
52 53
53 if (!service.Register(chromeos::dbus::GetSystemBusConnection())) { 54 if (!service.Register(chromeos::dbus::GetSystemBusConnection())) {
54 LOG(FATAL) << "DBUS service registration failed"; 55 LOG(FATAL) << "DBUS service registration failed";
55 return 1; 56 return 1;
56 } 57 }
57 58
58 if (!service.Run()) { 59 if (!service.Run()) {
59 LOG(FATAL) << "Service run failed."; 60 LOG(FATAL) << "Service run failed.";
60 return 1; 61 return 1;
61 } 62 }
62 63
63 return 0; 64 return 0;
64 } 65 }
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