Registered Member
|
I was looking at the Kwallet framework (https://invent.kde.org/frameworks/kwallet) and I found something somewhat confusing. In the KWallet C++ API, the Kwallet::readPassword() method is documented as follows (documentation here):
This makes me think that doing readPassword("non-existing-key", ...) should return an error code, and not success (zero). However, in its implementation I can see that it always returns success, except if a DBus error occurs. In fact, in the implementation of KWalletD::readPassword() I can see that the return value is always a QString. Even when no password entry with such a name exists, or when another entry with the same name but different type exists, the return value is an empty QString ("").
Is this the intended implementation? It does not seem like a good way to handle non-existing entries or entries of different type. How should an application recognize that there actually is a password in the wallet? After all, one application could actually store an empty password item in the wallet, and in that case it would get exactly the same result back (i.e. an empty string) when reading it. An application could theoretically first check with the hasEntry() method and then query the entryType() before finally doing readPassword(), but this seems more complex than needed, and more importantly easily prone to TOCTTOU bugs. In fact, an application could very well get hasEntry() => true and entryType() => EntryType::Password, but then the password gets removed by the user or some other app before the readPassword() call, and the application reads an empty string, thinking that it's valid, when in reality it was just returned as a default value instead of returning some kind of error. This ambiguous implementation is the same for all types of entry in KWalletD:
In light of the above, shouldn't the current KWalletD runtime and KWallet API implementations be changed? |
Registered Member
|
Nevermind! I found this problem mentioned in this pretty old bug report from 2006 (https://bugs.kde.org/show_bug.cgi?id=138841) so the issue is known. Just a design flaw that stuck around for a long time and will probably never be fixed.
|
Registered users: Bing [Bot], Google [Bot], kesang, Yahoo [Bot]