Rename "default" to "master" keyring as that's what it is.

Also add a well defined name ("Master") for the master keyring so it is
easier to understand what this keyring does instead of displaying an
empty string.
This commit is contained in:
Michael Lotz 2012-06-24 14:48:45 +02:00 committed by Ryan Leavengood
parent c8ae843f3d
commit a5a5f4ca70
3 changed files with 31 additions and 30 deletions

View File

@ -196,20 +196,20 @@ print_usage(const char* name)
{
printf("usage:\n");
printf("\t%s list passwords [<fromKeyring>]\n", name);
printf("\t\tLists all accessible passwords from the specified keyring or"
" from the default keyring if none is supplied.\n");
printf("\t\tLists all passwords of the specified keyring or from the"
" master keyring if none is supplied.\n");
printf("\t%s list keyrings\n", name);
printf("\t\tLists all accessible keyrings.\n\n");
printf("\t\tLists all keyrings.\n\n");
printf("\t%s add password <identifier> [<secondaryIdentifier>] <password>"
"\n", name);
printf("\t\tAdds the specified password to the default keyring.\n");
printf("\t\tAdds the specified password to the master keyring.\n");
printf("\t%s add password to <keyring> <identifier> [<secondaryIdentifier>]"
" <password>\n", name);
printf("\t\tAdds the specified password to the specified keyring.\n\n");
printf("\t%s remove password <identifier> [<secondaryIdentifier>]\n", name);
printf("\t\tRemoves the specified password from the default keyring.\n");
printf("\t\tRemoves the specified password from the master keyring.\n");
printf("\t%s remove password from <keyring> <identifier>"
" [<secondaryIdentifier>]\n", name);
printf("\t\tRemoves the specified password from the specified keyring.\n\n");
@ -223,19 +223,19 @@ print_usage(const char* name)
printf("\t%s status [<keyring>]\n", name);
printf("\t\tShows the lock state of the specified keyring, or the"
" default keyring if none is supplied.\n\n");
" master keyring if none is supplied.\n\n");
printf("\t%s lock [<keyring>]\n", name);
printf("\t\tLock the specified keyring, or the default keyring if none is"
printf("\t\tLock the specified keyring, or the master keyring if none is"
" supplied.\n\n");
printf("\t%s master add <keyring>\n", name);
printf("\t\tAdd the access key for the specified keyring to the default"
printf("\t\tAdd the access key for the specified keyring to the master"
" keyring.\n");
printf("\t%s master remove <keyring>\n", name);
printf("\t\tRemove the access key for the specified keyring from the"
" default keyring.\n");
" master keyring.\n\n");
return 1;
}

View File

@ -27,6 +27,7 @@
using namespace BPrivate;
static const char* kMasterKeyringName = "Master";
static const char* kKeyringKeysIdentifier = "Keyrings";
static const uint32 kFlagGetKey = 0x0001;
@ -57,7 +58,7 @@ static const uint32 kDefaultAppFlags = kFlagGetKey | kFlagEnumerateKeys
KeyStoreServer::KeyStoreServer()
:
BApplication(kKeyStoreServerSignature),
fDefaultKeyring(NULL),
fMasterKeyring(NULL),
fKeyrings(20, true)
{
BPath path;
@ -82,8 +83,8 @@ KeyStoreServer::KeyStoreServer()
_ReadKeyStoreDatabase();
if (fDefaultKeyring == NULL)
fDefaultKeyring = new(std::nothrow) Keyring("");
if (fMasterKeyring == NULL)
fMasterKeyring = new(std::nothrow) Keyring(kMasterKeyringName);
}
@ -303,7 +304,7 @@ KeyStoreServer::MessageReceived(BMessage* message)
}
if (cookie == 0)
keyring = fDefaultKeyring;
keyring = fMasterKeyring;
else
keyring = fKeyrings.ItemAt(cookie - 1);
@ -336,9 +337,9 @@ KeyStoreServer::MessageReceived(BMessage* message)
case KEY_STORE_ADD_KEYRING_TO_MASTER:
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
{
// We also need access to the default keyring.
while (!fDefaultKeyring->IsUnlocked()) {
status_t unlockResult = _UnlockKeyring(*fDefaultKeyring);
// We also need access to the master keyring.
while (!fMasterKeyring->IsUnlocked()) {
status_t unlockResult = _UnlockKeyring(*fMasterKeyring);
if (unlockResult != B_OK) {
result = unlockResult;
message->what = 0;
@ -358,12 +359,12 @@ KeyStoreServer::MessageReceived(BMessage* message)
switch (message->what) {
case KEY_STORE_ADD_KEYRING_TO_MASTER:
result = fDefaultKeyring->AddKey(kKeyringKeysIdentifier,
result = fMasterKeyring->AddKey(kKeyringKeysIdentifier,
secondaryIdentifier, keyMessage);
break;
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
result = fDefaultKeyring->RemoveKey(kKeyringKeysIdentifier,
result = fMasterKeyring->RemoveKey(kKeyringKeysIdentifier,
keyMessage);
break;
}
@ -466,8 +467,8 @@ KeyStoreServer::_ReadKeyStoreDatabase()
continue;
}
if (strlen(keyringName) == 0)
fDefaultKeyring = keyring;
if (strcmp(keyringName, kMasterKeyringName) == 0)
fMasterKeyring = keyring;
else
fKeyrings.BinaryInsert(keyring, &Keyring::Compare);
}
@ -480,8 +481,8 @@ status_t
KeyStoreServer::_WriteKeyStoreDatabase()
{
BMessage keyrings;
if (fDefaultKeyring != NULL)
fDefaultKeyring->WriteToMessage(keyrings);
if (fMasterKeyring != NULL)
fMasterKeyring->WriteToMessage(keyrings);
for (int32 i = 0; i < fKeyrings.CountItems(); i++) {
Keyring* keyring = fKeyrings.ItemAt(i);
@ -629,8 +630,8 @@ KeyStoreServer::_RequestAppAccess(const BString& keyringName,
Keyring*
KeyStoreServer::_FindKeyring(const BString& name)
{
if (name.IsEmpty())
return fDefaultKeyring;
if (name.IsEmpty() || name == kMasterKeyringName)
return fMasterKeyring;
return fKeyrings.BinarySearchByKey(name, &Keyring::Compare);
}
@ -662,8 +663,8 @@ KeyStoreServer::_RemoveKeyring(const BString& name)
if (keyring == NULL)
return B_ENTRY_NOT_FOUND;
if (keyring == fDefaultKeyring) {
// The default keyring can't be removed.
if (keyring == fMasterKeyring) {
// The master keyring can't be removed.
return B_NOT_ALLOWED;
}
@ -675,10 +676,10 @@ status_t
KeyStoreServer::_UnlockKeyring(Keyring& keyring)
{
// If we are accessing a keyring that has been added to master access we
// get the key from the default keyring and unlock with that.
// get the key from the master keyring and unlock with that.
BMessage keyMessage;
if (&keyring != fDefaultKeyring && fDefaultKeyring->IsUnlocked()) {
if (fDefaultKeyring->FindKey(kKeyringKeysIdentifier, keyring.Name(),
if (&keyring != fMasterKeyring && fMasterKeyring->IsUnlocked()) {
if (fMasterKeyring->FindKey(kKeyringKeysIdentifier, keyring.Name(),
false, &keyMessage) == B_OK) {
// We found a key for this keyring, try to unlock with it.
if (keyring.Unlock(keyMessage) == B_OK)

View File

@ -54,7 +54,7 @@ private:
status_t _RequestKey(const BString& keyringName,
BMessage& keyMessage);
Keyring* fDefaultKeyring;
Keyring* fMasterKeyring;
KeyringList fKeyrings;
BFile fKeyStoreFile;
};