pulb / mailnag

An extensible mail notification daemon
GNU General Public License v2.0
250 stars 32 forks source link

Change secret schema type to avoid no password prompt #231

Closed shejialuo closed 2 years ago

shejialuo commented 2 years ago

As shown in #213, mailnag won't authenticate on first start. The reason can be found in https://gitlab.gnome.org/GNOME/libsecret/-/issues/7. It is because that when creating schema using Secret.SchemaFlags.NONE. The schema name is sent as attribute to match (xdg:schema). However, for gnome-keyring side, when the secret is locked. The secret will have extra attributes which makes that the lookup fails. And use Secret.Schema.Flags.DONT_MATCH_NAME flag creates the schema can avoid this situation.

However, there is also another situation, just make the schema name to be None, which would be org.freedesktop.Secret.Generic schema, which means no schema at all, so any attributes can be used. So the password_lookpup_sync can also success to allow the password prompt.

This PR adopts the first solution, simply change the FLAG.

Closes #213


When using secret-tool search --all xdg:schema org.freedesktop.Secret.Generic. The following picture illustrates partial result.

image

We can see that gnome-keyring add attribute attribute.gkr:compat:hashed:xdg:schema and there are two original attributes account and service. When the secret is locked. The attributes become attribute.gkr:compat:hashed:account and attribute.gkr:compat:hashed:service. And when executing the command secret-tool search --all xdg:schema com.github.pulb.mailnag, the result is:

image

There would be no actions.

The reason can be found in https://gitlab.gnome.org/GNOME/libsecret/-/issues/7.