diff --git a/headers/os/app/KeyStore.h b/headers/os/app/KeyStore.h index 7af178fbf8..aae65f111f 100644 --- a/headers/os/app/KeyStore.h +++ b/headers/os/app/KeyStore.h @@ -71,11 +71,11 @@ public: status_t GetNextMasterKeyring(uint32& cookie, BString& keyring); - // Access + // Locking - bool IsKeyringAccessible(const char* keyring); - status_t RevokeAccess(const char* keyring); - status_t RevokeMasterAccess(); + bool IsKeyringUnlocked(const char* keyring); + status_t LockKeyring(const char* keyring); + status_t LockMasterKeyring(); // Applications diff --git a/headers/private/app/KeyStoreDefs.h b/headers/private/app/KeyStoreDefs.h index 315944c18c..257a35275d 100644 --- a/headers/private/app/KeyStoreDefs.h +++ b/headers/private/app/KeyStoreDefs.h @@ -35,8 +35,8 @@ enum { KEY_STORE_ADD_KEYRING_TO_MASTER = 'KarM', KEY_STORE_REMOVE_KEYRING_FROM_MASTER = 'KrrM', KEY_STORE_GET_NEXT_MASTER_KEYRING = 'KnrM', - KEY_STORE_IS_KEYRING_ACCESSIBLE = 'KiaR', - KEY_STORE_REVOKE_ACCESS = 'KvaR', + KEY_STORE_IS_KEYRING_UNLOCKED = 'KuKR', + KEY_STORE_LOCK_KEYRING = 'KlKR', KEY_STORE_GET_NEXT_APPLICATION = 'KnKA', KEY_STORE_REMOVE_APPLICATION = 'KrKA', }; diff --git a/src/bin/keystore/keystore.cpp b/src/bin/keystore/keystore.cpp index 2dd66cddf3..5445f5dbb3 100644 --- a/src/bin/keystore/keystore.cpp +++ b/src/bin/keystore/keystore.cpp @@ -140,19 +140,19 @@ int show_status(const char* keyring) { BKeyStore keyStore; - printf("keyring \"%s\" is %saccessible\n", keyring, - keyStore.IsKeyringAccessible(keyring) ? "" : "not "); + printf("keyring \"%s\" is %slocked\n", keyring, + keyStore.IsKeyringUnlocked(keyring) ? "un" : ""); return 0; } int -revoke_access(const char* keyring) +lock_keyring(const char* keyring) { BKeyStore keyStore; - status_t result = keyStore.RevokeAccess(keyring); + status_t result = keyStore.LockKeyring(keyring); if (result != B_OK) { - printf("failed to revoke access to keyring \"%s\": %s\n", keyring, + printf("failed to lock keyring \"%s\": %s\n", keyring, strerror(result)); return 2; } @@ -222,12 +222,12 @@ print_usage(const char* 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, or the" + printf("\t\tShows the lock state 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 lock []\n", name); + printf("\t\tLock the specified keyring, or 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" @@ -333,11 +333,11 @@ main(int argc, char* argv[]) return print_usage(argv[0]); return show_status(argc == 3 ? argv[2] : ""); - } else if (strcmp(argv[1], "revoke") == 0) { + } else if (strcmp(argv[1], "lock") == 0) { if (argc != 2 && argc != 3) return print_usage(argv[0]); - return revoke_access(argc == 3 ? argv[2] : ""); + return lock_keyring(argc == 3 ? argv[2] : ""); } else if (strcmp(argv[1], "master") == 0) { if (argc != 4) return print_usage(argv[0]); diff --git a/src/kits/app/KeyStore.cpp b/src/kits/app/KeyStore.cpp index 64cca00cf8..f0f7de71c7 100644 --- a/src/kits/app/KeyStore.cpp +++ b/src/kits/app/KeyStore.cpp @@ -291,40 +291,40 @@ BKeyStore::GetNextMasterKeyring(uint32& cookie, BString& keyring) } -// #pragma mark - Access +// #pragma mark - Locking bool -BKeyStore::IsKeyringAccessible(const char* keyring) +BKeyStore::IsKeyringUnlocked(const char* keyring) { - BMessage message(KEY_STORE_IS_KEYRING_ACCESSIBLE); + BMessage message(KEY_STORE_IS_KEYRING_UNLOCKED); message.AddString("keyring", keyring); BMessage reply; if (_SendKeyMessage(message, &reply) != B_OK) return false; - bool accessible; - if (reply.FindBool("accessible", &accessible) != B_OK) + bool unlocked; + if (reply.FindBool("unlocked", &unlocked) != B_OK) return false; - return accessible; + return unlocked; } status_t -BKeyStore::RevokeAccess(const char* keyring) +BKeyStore::LockKeyring(const char* keyring) { - BMessage message(KEY_STORE_REVOKE_ACCESS); + BMessage message(KEY_STORE_LOCK_KEYRING); message.AddString("keyring", keyring); return _SendKeyMessage(message, NULL); } status_t -BKeyStore::RevokeMasterAccess() +BKeyStore::LockMasterKeyring() { - return RevokeAccess(NULL); + return LockKeyring(NULL); } diff --git a/src/servers/keystore/KeyStoreServer.cpp b/src/servers/keystore/KeyStoreServer.cpp index 4d6c93b3c4..fee00271c8 100644 --- a/src/servers/keystore/KeyStoreServer.cpp +++ b/src/servers/keystore/KeyStoreServer.cpp @@ -41,8 +41,8 @@ static const uint32 kFlagRemoveMasterKey = 0x0100; static const uint32 kFlagAddKeyringsToMaster = 0x0200; static const uint32 kFlagRemoveKeyringsFromMaster = 0x0400; static const uint32 kFlagEnumerateMasterKeyrings = 0x0800; -static const uint32 kFlagQueryAccessibility = 0x1000; -static const uint32 kFlagRevokeAccess = 0x2000; +static const uint32 kFlagQueryLockState = 0x1000; +static const uint32 kFlagLockKeyring = 0x2000; static const uint32 kFlagEnumerateApplications = 0x4000; static const uint32 kFlagRemoveApplications = 0x8000; @@ -50,9 +50,8 @@ static const uint32 kDefaultAppFlags = kFlagGetKey | kFlagEnumerateKeys | kFlagAddKey | kFlagRemoveKey | kFlagAddKeyring | kFlagRemoveKeyring | kFlagEnumerateKeyrings | kFlagSetMasterKey | kFlagRemoveMasterKey | kFlagAddKeyringsToMaster | kFlagRemoveKeyringsFromMaster - | kFlagEnumerateMasterKeyrings | kFlagQueryAccessibility - | kFlagQueryAccessibility | kFlagRevokeAccess | kFlagEnumerateApplications - | kFlagRemoveApplications; + | kFlagEnumerateMasterKeyrings | kFlagQueryLockState | kFlagLockKeyring + | kFlagEnumerateApplications | kFlagRemoveApplications; KeyStoreServer::KeyStoreServer() @@ -117,8 +116,8 @@ KeyStoreServer::MessageReceived(BMessage* message) case KEY_STORE_GET_NEXT_KEY: case KEY_STORE_ADD_KEY: case KEY_STORE_REMOVE_KEY: - case KEY_STORE_IS_KEYRING_ACCESSIBLE: - case KEY_STORE_REVOKE_ACCESS: + case KEY_STORE_IS_KEYRING_UNLOCKED: + case KEY_STORE_LOCK_KEYRING: case KEY_STORE_ADD_KEYRING_TO_MASTER: case KEY_STORE_REMOVE_KEYRING_FROM_MASTER: case KEY_STORE_GET_NEXT_APPLICATION: @@ -146,10 +145,10 @@ KeyStoreServer::MessageReceived(BMessage* message) case KEY_STORE_REMOVE_APPLICATION: { // These need keyring access to do anything. - while (!keyring->IsAccessible()) { - status_t accessResult = _AccessKeyring(*keyring); - if (accessResult != B_OK) { - result = accessResult; + while (!keyring->IsUnlocked()) { + status_t unlockResult = _UnlockKeyring(*keyring); + if (unlockResult != B_OK) { + result = unlockResult; message->what = 0; break; } @@ -320,16 +319,16 @@ KeyStoreServer::MessageReceived(BMessage* message) break; } - case KEY_STORE_IS_KEYRING_ACCESSIBLE: + case KEY_STORE_IS_KEYRING_UNLOCKED: { - reply.AddBool("accessible", keyring->IsAccessible()); + reply.AddBool("unlocked", keyring->IsUnlocked()); result = B_OK; break; } - case KEY_STORE_REVOKE_ACCESS: + case KEY_STORE_LOCK_KEYRING: { - keyring->RevokeAccess(); + keyring->Lock(); result = B_OK; break; } @@ -338,10 +337,10 @@ KeyStoreServer::MessageReceived(BMessage* message) case KEY_STORE_REMOVE_KEYRING_FROM_MASTER: { // We also need access to the default keyring. - while (!fDefaultKeyring->IsAccessible()) { - status_t accessResult = _AccessKeyring(*fDefaultKeyring); - if (accessResult != B_OK) { - result = accessResult; + while (!fDefaultKeyring->IsUnlocked()) { + status_t unlockResult = _UnlockKeyring(*fDefaultKeyring); + if (unlockResult != B_OK) { + result = unlockResult; message->what = 0; break; } @@ -528,10 +527,10 @@ KeyStoreServer::_AccessFlagsFor(uint32 command) const return kFlagRemoveKeyringsFromMaster; case KEY_STORE_GET_NEXT_MASTER_KEYRING: return kFlagEnumerateMasterKeyrings; - case KEY_STORE_IS_KEYRING_ACCESSIBLE: - return kFlagQueryAccessibility; - case KEY_STORE_REVOKE_ACCESS: - return kFlagRevokeAccess; + case KEY_STORE_IS_KEYRING_UNLOCKED: + return kFlagQueryLockState; + case KEY_STORE_LOCK_KEYRING: + return kFlagLockKeyring; case KEY_STORE_GET_NEXT_APPLICATION: return kFlagEnumerateApplications; case KEY_STORE_REMOVE_APPLICATION: @@ -673,16 +672,16 @@ KeyStoreServer::_RemoveKeyring(const BString& name) status_t -KeyStoreServer::_AccessKeyring(Keyring& keyring) +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. BMessage keyMessage; - if (&keyring != fDefaultKeyring && fDefaultKeyring->IsAccessible()) { + if (&keyring != fDefaultKeyring && fDefaultKeyring->IsUnlocked()) { if (fDefaultKeyring->FindKey(kKeyringKeysIdentifier, keyring.Name(), false, &keyMessage) == B_OK) { - // We found a key for this keyring, try to access with it. - if (keyring.Access(keyMessage) == B_OK) + // We found a key for this keyring, try to unlock with it. + if (keyring.Unlock(keyMessage) == B_OK) return B_OK; } } @@ -692,7 +691,7 @@ KeyStoreServer::_AccessKeyring(Keyring& keyring) if (result != B_OK) return result; - return keyring.Access(keyMessage); + return keyring.Unlock(keyMessage); } diff --git a/src/servers/keystore/KeyStoreServer.h b/src/servers/keystore/KeyStoreServer.h index 0490a7da6a..01e73a80cd 100644 --- a/src/servers/keystore/KeyStoreServer.h +++ b/src/servers/keystore/KeyStoreServer.h @@ -49,7 +49,7 @@ private: const BMessage& keyMessage); status_t _RemoveKeyring(const BString& name); - status_t _AccessKeyring(Keyring& keyring); + status_t _UnlockKeyring(Keyring& keyring); status_t _RequestKey(const BString& keyringName, BMessage& keyMessage); diff --git a/src/servers/keystore/Keyring.cpp b/src/servers/keystore/Keyring.cpp index 4f705785ce..eff7c0051a 100644 --- a/src/servers/keystore/Keyring.cpp +++ b/src/servers/keystore/Keyring.cpp @@ -10,11 +10,11 @@ Keyring::Keyring(const char* name, const BMessage* keyMessage) : fName(name), - fAccessible(false), + fUnlocked(false), fModified(false) { if (keyMessage != NULL) - Access(*keyMessage); + Unlock(*keyMessage); } @@ -59,7 +59,7 @@ Keyring::WriteToMessage(BMessage& message) status_t -Keyring::Access(const BMessage& keyMessage) +Keyring::Unlock(const BMessage& keyMessage) { fKeyMessage = keyMessage; @@ -69,15 +69,15 @@ Keyring::Access(const BMessage& keyMessage) return result; } - fAccessible = true; + fUnlocked = true; return B_OK; } void -Keyring::RevokeAccess() +Keyring::Lock() { - if (!fAccessible) + if (!fUnlocked) return; _EncryptToFlatBuffer(); @@ -85,14 +85,14 @@ Keyring::RevokeAccess() fKeyMessage.MakeEmpty(); fData.MakeEmpty(); fApplications.MakeEmpty(); - fAccessible = false; + fUnlocked = false; } bool -Keyring::IsAccessible() const +Keyring::IsUnlocked() const { - return fAccessible; + return fUnlocked; } @@ -131,7 +131,7 @@ status_t Keyring::FindApplication(const char* signature, const char* path, BMessage& appMessage) { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; int32 count; @@ -159,7 +159,7 @@ Keyring::FindApplication(const char* signature, const char* path, status_t Keyring::AddApplication(const char* signature, const BMessage& appMessage) { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; status_t result = fApplications.AddMessage(signature, &appMessage); @@ -174,7 +174,7 @@ Keyring::AddApplication(const char* signature, const BMessage& appMessage) status_t Keyring::RemoveApplication(const char* signature, const char* path) { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; if (path == NULL) { @@ -216,7 +216,7 @@ status_t Keyring::FindKey(const BString& identifier, const BString& secondaryIdentifier, bool secondaryIdentifierOptional, BMessage* _foundKeyMessage) const { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; int32 count; @@ -262,7 +262,7 @@ status_t Keyring::FindKey(BKeyType type, BKeyPurpose purpose, uint32 index, BMessage& _foundKeyMessage) const { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; for (int32 keyIndex = 0;; keyIndex++) { @@ -327,7 +327,7 @@ status_t Keyring::AddKey(const BString& identifier, const BString& secondaryIdentifier, const BMessage& keyMessage) { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; // Check for collisions. @@ -348,7 +348,7 @@ status_t Keyring::RemoveKey(const BString& identifier, const BMessage& keyMessage) { - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; int32 count; @@ -397,7 +397,7 @@ Keyring::_EncryptToFlatBuffer() if (!fModified) return B_OK; - if (!fAccessible) + if (!fUnlocked) return B_NOT_ALLOWED; BMessage container; diff --git a/src/servers/keystore/Keyring.h b/src/servers/keystore/Keyring.h index b5381f29f5..afbca03b14 100644 --- a/src/servers/keystore/Keyring.h +++ b/src/servers/keystore/Keyring.h @@ -20,9 +20,9 @@ public: status_t ReadFromMessage(const BMessage& message); status_t WriteToMessage(BMessage& message); - status_t Access(const BMessage& keyMessage); - void RevokeAccess(); - bool IsAccessible() const; + status_t Unlock(const BMessage& keyMessage); + void Lock(); + bool IsUnlocked() const; const BMessage& KeyMessage() const; status_t GetNextApplication(uint32& cookie, @@ -62,7 +62,7 @@ private: BMessage fData; BMessage fApplications; BMessage fKeyMessage; - bool fAccessible; + bool fUnlocked; bool fModified; };