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

Unified Diff: cryptohome.cc

Issue 6801020: service,cryptohome: wire up lockbox to dbus (Closed)
Patch Set: auto-Finalization on Mount 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cryptohome.xml » ('j') | cryptohome.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cryptohome.cc
diff --git a/cryptohome.cc b/cryptohome.cc
index 136842b64a512029b9c8fd9eb5427eda474ab77d..460fb55f8ecde69942ab9f8f5406cdb7964d320b 100644
--- a/cryptohome.cc
+++ b/cryptohome.cc
@@ -49,6 +49,7 @@ namespace switches {
"tpm_take_ownership",
"tpm_clear_stored_password",
"tpm_wait_ownership",
+ "install_attributes_test",
NULL };
enum ActionEnum {
ACTION_MOUNT,
@@ -65,7 +66,8 @@ namespace switches {
ACTION_REMOVE_TRACKED_SUBDIRS,
ACTION_TPM_TAKE_OWNERSHIP,
ACTION_TPM_CLEAR_STORED_PASSWORD,
- ACTION_TPM_WAIT_OWNERSHIP };
+ ACTION_TPM_WAIT_OWNERSHIP,
+ ACTION_INSTALL_ATTRIBUTES_TEST };
gauravsh 2011/04/14 07:39:52 Can you make this more general instead of making t
Will Drewry 2011/04/15 01:31:49 Done.
static const char kUserSwitch[] = "user";
static const char kPasswordSwitch[] = "password";
static const char kOldPasswordSwitch[] = "old_password";
@@ -675,6 +677,86 @@ int main(int argc, char **argv) {
printf("TpmClearStoredPassword call failed: %s.\n", error->message);
}
} else if (!strcmp(
+ switches::kActions[switches::ACTION_INSTALL_ATTRIBUTES_TEST],
+ action.c_str())) {
+ chromeos::glib::ScopedError error;
+ gboolean result;
+ if (!org_chromium_CryptohomeInterface_install_attributes_is_ready(
+ proxy.gproxy(),
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("IsReady call failed: %s.\n", error->message);
+ }
+ if (result == FALSE) {
+ printf("Not ready.\n");
+ return 1;
+ }
+ printf("Ready!\n");
+ if (!org_chromium_CryptohomeInterface_install_attributes_is_first_install(
+ proxy.gproxy(),
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("IsFirstInstall() call failed: %s.\n", error->message);
+ }
+ bool is_first_install = result;
+ printf("First Install? %d\n", result);
+ const char* kTestNameA = "Test.IsManaged";
+ const char* kTestValueA = "TRUE";
+ const char* kTestNameB = "Test.Foo";
+ const char* kTestValueB = "Bar";
+ if (is_first_install) {
+ // Set a value!
+ GArray *value = g_array_new(FALSE, FALSE, sizeof(char));
+ g_array_append_vals(value, kTestValueA, strlen(kTestValueA));
+ if (!org_chromium_CryptohomeInterface_install_attributes_set(
+ proxy.gproxy(),
+ kTestNameA,
+ value,
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("Set() failed: %s.\n", error->message);
+ }
+ g_array_free(value, false);
+ printf("Set(%s,%s): %d\n", kTestNameA, kTestValueA, result);
+ // Set a value!
+ value = g_array_new(FALSE, FALSE, sizeof(char));
+ g_array_append_vals(value, kTestValueB, strlen(kTestValueB));
+ if (!org_chromium_CryptohomeInterface_install_attributes_set(
+ proxy.gproxy(),
+ kTestNameB,
+ value,
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("Set() failed: %s.\n", error->message);
+ }
+ g_array_free(value, false);
+ printf("Set(%s,%s): %d\n", kTestNameB, kTestValueB, result);
+ }
+ // Grab the value and emit it.
+ // Set a value!
+ GArray *value = NULL;
+ if (!org_chromium_CryptohomeInterface_install_attributes_get(
+ proxy.gproxy(),
+ kTestNameA,
+ &value,
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("Get() failed: %s.\n", error->message);
+ }
+ std::string value_str(value->data, value->len);
+ printf("Get(%s,%s): %d\n", kTestNameA, value_str.c_str(), result);
+ g_array_free(value, false);
+ if (!is_first_install)
+ return 0;
+ // Lock it down.
+ if (!org_chromium_CryptohomeInterface_install_attributes_finalize(
+ proxy.gproxy(),
+ &result,
+ &chromeos::Resetter(&error).lvalue())) {
+ printf("Finalize() failed: %s.\n", error->message);
+ }
+ printf("Finalize(): %d\n", result);
+ } else if (!strcmp(
switches::kActions[switches::ACTION_TPM_WAIT_OWNERSHIP],
action.c_str())) {
TpmWaitLoop client_loop;
« no previous file with comments | « no previous file | cryptohome.xml » ('j') | cryptohome.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698