From 6fb7a4569b10af8e7f333bc63c174317208f9a14 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 8 Jan 2012 01:15:03 +0100 Subject: [PATCH] Add commands for adding/removig keyrings from/to the master. Also adds missing revoke usage string. --- src/bin/keystore.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/bin/keystore.cpp b/src/bin/keystore.cpp index 204c184083..8d6cf028c7 100644 --- a/src/bin/keystore.cpp +++ b/src/bin/keystore.cpp @@ -160,6 +160,36 @@ revoke_access(const char* keyring) } +int +add_keyring_to_master(const char* keyring) +{ + BKeyStore keyStore; + status_t result= keyStore.AddKeyringToMaster(keyring); + if (result != B_OK) { + printf("failed to add keyring \"%s\" to master: %s\n", keyring, + strerror(result)); + return 2; + } + + return 0; +} + + +int +remove_keyring_from_master(const char* keyring) +{ + BKeyStore keyStore; + status_t result= keyStore.RemoveKeyringFromMaster(keyring); + if (result != B_OK) { + printf("failed to remove keyring \"%s\" from master: %s\n", keyring, + strerror(result)); + return 2; + } + + return 0; +} + + int print_usage(const char* name) { @@ -190,8 +220,21 @@ print_usage(const char* name) printf("\t%s remove keyring \n", name); printf("\t\tRemoves the specified keyring.\n\n"); - printf("\t%s status \n", name); - printf("\t\tShows the access status of the specified keyring.\n\n"); + printf("\t%s status []\n", name); + printf("\t\tShows the access status of the specified keyring, or the" + " default keyring if none is supplied.\n\n"); + + printf("\t%s revoke []\n", name); + printf("\t\tRevoke access to the specified keyring, or to the default" + " keyring if none is supplied.\n\n"); + + printf("\t%s master add \n", name); + printf("\t\tAdd the access key for the specified keyring to the default" + " keyring.\n"); + + printf("\t%s master remove \n", name); + printf("\t\tRemove the access key for the specified keyring from the" + " default keyring.\n"); return 1; } @@ -292,6 +335,14 @@ main(int argc, char* argv[]) return print_usage(argv[0]); return revoke_access(argc == 3 ? argv[2] : ""); + } else if (strcmp(argv[1], "master") == 0) { + if (argc != 4) + return print_usage(argv[0]); + + if (strcmp(argv[2], "add") == 0) + return add_keyring_to_master(argv[3]); + if (strcmp(argv[2], "remove") == 0) + return remove_keyring_from_master(argv[3]); } return print_usage(argv[0]);