mirror of
https://review.haiku-os.org/haiku
synced 2025-02-22 21:48:35 +01:00
Only write and encrypt the flat buffer when modified.
This commit is contained in:
parent
1b3bb46aed
commit
6ef5917d45
@ -10,7 +10,8 @@
|
||||
Keyring::Keyring(const char* name, const BMessage* keyMessage)
|
||||
:
|
||||
fName(name),
|
||||
fAccessible(false)
|
||||
fAccessible(false),
|
||||
fModified(false)
|
||||
{
|
||||
if (keyMessage != NULL)
|
||||
Access(*keyMessage);
|
||||
@ -225,7 +226,12 @@ Keyring::AddKey(const BString& identifier, const BString& secondaryIdentifier,
|
||||
return B_NAME_IN_USE;
|
||||
|
||||
// We're fine, just add the new key.
|
||||
return fData.AddMessage(identifier, &keyMessage);
|
||||
status_t result = fData.AddMessage(identifier, &keyMessage);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
fModified = true;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +256,11 @@ Keyring::RemoveKey(const BString& identifier,
|
||||
if (!candidate.HasSameData(keyMessage))
|
||||
continue;
|
||||
|
||||
fData.RemoveData(identifier, i);
|
||||
status_t result = fData.RemoveData(identifier, i);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
fModified = true;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -275,6 +285,9 @@ Keyring::Compare(const BString* name, const Keyring* keyring)
|
||||
status_t
|
||||
Keyring::_EncryptToFlatBuffer()
|
||||
{
|
||||
if (!fModified)
|
||||
return B_OK;
|
||||
|
||||
if (!fAccessible)
|
||||
return B_NOT_ALLOWED;
|
||||
|
||||
@ -296,6 +309,7 @@ Keyring::_EncryptToFlatBuffer()
|
||||
|
||||
// TODO: Actually encrypt the flat buffer...
|
||||
|
||||
fModified = false;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ private:
|
||||
BMessage fApplications;
|
||||
BMessage fKeyMessage;
|
||||
bool fAccessible;
|
||||
bool fModified;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user