Skip to content

Commit

Permalink
Fix regression which made libsecret backend unusable in v23.8.0
Browse files Browse the repository at this point in the history
libsecret/secret-schema.h has this enum:

    typedef enum {
        SECRET_SCHEMA_ATTRIBUTE_STRING = 0,
        SECRET_SCHEMA_ATTRIBUTE_INTEGER = 1,
        SECRET_SCHEMA_ATTRIBUTE_BOOLEAN = 2,
    } SecretSchemaAttributeType;

Because of this, bool(Secret.SchemaAttributeType.STRING) evaluates to
False. So when we do this in schema property, _query code ignores the
second argument:

    self._query(
        Secret.SchemaAttributeType.STRING,
        Secret.SchemaAttributeType.STRING,
        application=Secret.SchemaAttributeType.STRING,
    )

And it causes any use of libsecret backend to fail with this error:

    >>> import keyring.backends.libsecret
    >>> k = keyring.backends.libsecret.Keyring()
    >>> k.set_password('foo', 'bar', 'baz')

    (process:26311): libsecret-CRITICAL **: 19:22:53.299: secret_password_storev_sync: invalid username attribute for org.freedesktop.Secret.Generic schema
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/dmitry/upstream/keyring/keyring/backends/libsecret.py", line 98, in set_password
        raise PasswordSetError("Failed to store password!")
    keyring.errors.PasswordSetError: Failed to store password!
  • Loading branch information
mitya57 committed Aug 7, 2022
1 parent 0ed196d commit 52ceae8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion keyring/backend.py
Expand Up @@ -250,7 +250,7 @@ def _query(self, service, username=None, **base):
scheme['username']: username,
scheme['service']: service,
}
if username
if username is not None
else {
scheme['service']: service,
},
Expand Down

0 comments on commit 52ceae8

Please sign in to comment.