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:
committed by
Ryan Leavengood
parent
c8ae843f3d
commit
a5a5f4ca70
@@ -196,20 +196,20 @@ print_usage(const char* name)
|
|||||||
{
|
{
|
||||||
printf("usage:\n");
|
printf("usage:\n");
|
||||||
printf("\t%s list passwords [<fromKeyring>]\n", name);
|
printf("\t%s list passwords [<fromKeyring>]\n", name);
|
||||||
printf("\t\tLists all accessible passwords from the specified keyring or"
|
printf("\t\tLists all passwords of the specified keyring or from the"
|
||||||
" from the default keyring if none is supplied.\n");
|
" master keyring if none is supplied.\n");
|
||||||
printf("\t%s list keyrings\n", name);
|
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>"
|
printf("\t%s add password <identifier> [<secondaryIdentifier>] <password>"
|
||||||
"\n", name);
|
"\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>]"
|
printf("\t%s add password to <keyring> <identifier> [<secondaryIdentifier>]"
|
||||||
" <password>\n", name);
|
" <password>\n", name);
|
||||||
printf("\t\tAdds the specified password to the specified keyring.\n\n");
|
printf("\t\tAdds the specified password to the specified keyring.\n\n");
|
||||||
|
|
||||||
printf("\t%s remove password <identifier> [<secondaryIdentifier>]\n", name);
|
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>"
|
printf("\t%s remove password from <keyring> <identifier>"
|
||||||
" [<secondaryIdentifier>]\n", name);
|
" [<secondaryIdentifier>]\n", name);
|
||||||
printf("\t\tRemoves the specified password from the specified keyring.\n\n");
|
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%s status [<keyring>]\n", name);
|
||||||
printf("\t\tShows the lock state of the specified keyring, or the"
|
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%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");
|
" supplied.\n\n");
|
||||||
|
|
||||||
printf("\t%s master add <keyring>\n", name);
|
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");
|
" keyring.\n");
|
||||||
|
|
||||||
printf("\t%s master remove <keyring>\n", name);
|
printf("\t%s master remove <keyring>\n", name);
|
||||||
printf("\t\tRemove the access key for the specified keyring from the"
|
printf("\t\tRemove the access key for the specified keyring from the"
|
||||||
" default keyring.\n");
|
" master keyring.\n\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kMasterKeyringName = "Master";
|
||||||
static const char* kKeyringKeysIdentifier = "Keyrings";
|
static const char* kKeyringKeysIdentifier = "Keyrings";
|
||||||
|
|
||||||
static const uint32 kFlagGetKey = 0x0001;
|
static const uint32 kFlagGetKey = 0x0001;
|
||||||
@@ -57,7 +58,7 @@ static const uint32 kDefaultAppFlags = kFlagGetKey | kFlagEnumerateKeys
|
|||||||
KeyStoreServer::KeyStoreServer()
|
KeyStoreServer::KeyStoreServer()
|
||||||
:
|
:
|
||||||
BApplication(kKeyStoreServerSignature),
|
BApplication(kKeyStoreServerSignature),
|
||||||
fDefaultKeyring(NULL),
|
fMasterKeyring(NULL),
|
||||||
fKeyrings(20, true)
|
fKeyrings(20, true)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
@@ -82,8 +83,8 @@ KeyStoreServer::KeyStoreServer()
|
|||||||
|
|
||||||
_ReadKeyStoreDatabase();
|
_ReadKeyStoreDatabase();
|
||||||
|
|
||||||
if (fDefaultKeyring == NULL)
|
if (fMasterKeyring == NULL)
|
||||||
fDefaultKeyring = new(std::nothrow) Keyring("");
|
fMasterKeyring = new(std::nothrow) Keyring(kMasterKeyringName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -303,7 +304,7 @@ KeyStoreServer::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cookie == 0)
|
if (cookie == 0)
|
||||||
keyring = fDefaultKeyring;
|
keyring = fMasterKeyring;
|
||||||
else
|
else
|
||||||
keyring = fKeyrings.ItemAt(cookie - 1);
|
keyring = fKeyrings.ItemAt(cookie - 1);
|
||||||
|
|
||||||
@@ -336,9 +337,9 @@ KeyStoreServer::MessageReceived(BMessage* message)
|
|||||||
case KEY_STORE_ADD_KEYRING_TO_MASTER:
|
case KEY_STORE_ADD_KEYRING_TO_MASTER:
|
||||||
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
|
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
|
||||||
{
|
{
|
||||||
// We also need access to the default keyring.
|
// We also need access to the master keyring.
|
||||||
while (!fDefaultKeyring->IsUnlocked()) {
|
while (!fMasterKeyring->IsUnlocked()) {
|
||||||
status_t unlockResult = _UnlockKeyring(*fDefaultKeyring);
|
status_t unlockResult = _UnlockKeyring(*fMasterKeyring);
|
||||||
if (unlockResult != B_OK) {
|
if (unlockResult != B_OK) {
|
||||||
result = unlockResult;
|
result = unlockResult;
|
||||||
message->what = 0;
|
message->what = 0;
|
||||||
@@ -358,12 +359,12 @@ KeyStoreServer::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case KEY_STORE_ADD_KEYRING_TO_MASTER:
|
case KEY_STORE_ADD_KEYRING_TO_MASTER:
|
||||||
result = fDefaultKeyring->AddKey(kKeyringKeysIdentifier,
|
result = fMasterKeyring->AddKey(kKeyringKeysIdentifier,
|
||||||
secondaryIdentifier, keyMessage);
|
secondaryIdentifier, keyMessage);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
|
case KEY_STORE_REMOVE_KEYRING_FROM_MASTER:
|
||||||
result = fDefaultKeyring->RemoveKey(kKeyringKeysIdentifier,
|
result = fMasterKeyring->RemoveKey(kKeyringKeysIdentifier,
|
||||||
keyMessage);
|
keyMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -466,8 +467,8 @@ KeyStoreServer::_ReadKeyStoreDatabase()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(keyringName) == 0)
|
if (strcmp(keyringName, kMasterKeyringName) == 0)
|
||||||
fDefaultKeyring = keyring;
|
fMasterKeyring = keyring;
|
||||||
else
|
else
|
||||||
fKeyrings.BinaryInsert(keyring, &Keyring::Compare);
|
fKeyrings.BinaryInsert(keyring, &Keyring::Compare);
|
||||||
}
|
}
|
||||||
@@ -480,8 +481,8 @@ status_t
|
|||||||
KeyStoreServer::_WriteKeyStoreDatabase()
|
KeyStoreServer::_WriteKeyStoreDatabase()
|
||||||
{
|
{
|
||||||
BMessage keyrings;
|
BMessage keyrings;
|
||||||
if (fDefaultKeyring != NULL)
|
if (fMasterKeyring != NULL)
|
||||||
fDefaultKeyring->WriteToMessage(keyrings);
|
fMasterKeyring->WriteToMessage(keyrings);
|
||||||
|
|
||||||
for (int32 i = 0; i < fKeyrings.CountItems(); i++) {
|
for (int32 i = 0; i < fKeyrings.CountItems(); i++) {
|
||||||
Keyring* keyring = fKeyrings.ItemAt(i);
|
Keyring* keyring = fKeyrings.ItemAt(i);
|
||||||
@@ -629,8 +630,8 @@ KeyStoreServer::_RequestAppAccess(const BString& keyringName,
|
|||||||
Keyring*
|
Keyring*
|
||||||
KeyStoreServer::_FindKeyring(const BString& name)
|
KeyStoreServer::_FindKeyring(const BString& name)
|
||||||
{
|
{
|
||||||
if (name.IsEmpty())
|
if (name.IsEmpty() || name == kMasterKeyringName)
|
||||||
return fDefaultKeyring;
|
return fMasterKeyring;
|
||||||
|
|
||||||
return fKeyrings.BinarySearchByKey(name, &Keyring::Compare);
|
return fKeyrings.BinarySearchByKey(name, &Keyring::Compare);
|
||||||
}
|
}
|
||||||
@@ -662,8 +663,8 @@ KeyStoreServer::_RemoveKeyring(const BString& name)
|
|||||||
if (keyring == NULL)
|
if (keyring == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
if (keyring == fDefaultKeyring) {
|
if (keyring == fMasterKeyring) {
|
||||||
// The default keyring can't be removed.
|
// The master keyring can't be removed.
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,10 +676,10 @@ status_t
|
|||||||
KeyStoreServer::_UnlockKeyring(Keyring& keyring)
|
KeyStoreServer::_UnlockKeyring(Keyring& keyring)
|
||||||
{
|
{
|
||||||
// If we are accessing a keyring that has been added to master access we
|
// 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;
|
BMessage keyMessage;
|
||||||
if (&keyring != fDefaultKeyring && fDefaultKeyring->IsUnlocked()) {
|
if (&keyring != fMasterKeyring && fMasterKeyring->IsUnlocked()) {
|
||||||
if (fDefaultKeyring->FindKey(kKeyringKeysIdentifier, keyring.Name(),
|
if (fMasterKeyring->FindKey(kKeyringKeysIdentifier, keyring.Name(),
|
||||||
false, &keyMessage) == B_OK) {
|
false, &keyMessage) == B_OK) {
|
||||||
// We found a key for this keyring, try to unlock with it.
|
// We found a key for this keyring, try to unlock with it.
|
||||||
if (keyring.Unlock(keyMessage) == B_OK)
|
if (keyring.Unlock(keyMessage) == B_OK)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
status_t _RequestKey(const BString& keyringName,
|
status_t _RequestKey(const BString& keyringName,
|
||||||
BMessage& keyMessage);
|
BMessage& keyMessage);
|
||||||
|
|
||||||
Keyring* fDefaultKeyring;
|
Keyring* fMasterKeyring;
|
||||||
KeyringList fKeyrings;
|
KeyringList fKeyrings;
|
||||||
BFile fKeyStoreFile;
|
BFile fKeyStoreFile;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user