[vlc-devel] [PATCH 2/4] keystore: use the system keystore in priority
Thomas Guillem
thomas at gllm.fr
Fri Dec 18 10:31:39 UTC 2020
If user interaction is not disabled (the default when browsing/playing via an
UI) fetch the system keystore before the memory one (the memory one will
only be used if the system keystore is dysfunctional or the user choose
to not save credentials in the system keystore).
The distinction between interact and no interact is interesting for apps
doing background browsing (to speed up user browsing experience). In
that case, you don't want VLC to trigger any UI interaction.
---
src/misc/keystore.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/src/misc/keystore.c b/src/misc/keystore.c
index 74038bccb5c..328c8ef3733 100644
--- a/src/misc/keystore.c
+++ b/src/misc/keystore.c
@@ -376,12 +376,44 @@ credential_get_next_order(vlc_credential *p_credential, vlc_object_t *p_parent)
{
(void) p_parent;
- /* DIALOG is the last way to fetch credential, use it until credentials are
- * valid or until the user cancel it */
- if (p_credential->i_get_order == GET_FROM_DIALOG)
- return p_credential->i_get_order;
+ if (p_parent->no_interact)
+ {
+ /* Don't query the system keystore (may cause UI interaction by
+ * prompting pin/passphrase/...) or prompt a dialog in case of no
+ * interact. */
+ if (p_credential->i_get_order == GET_FROM_MEMORY_KEYSTORE)
+ return GET_FROM_INIT;
+
+ p_credential->i_get_order++;
+ }
+ else
+ {
+ switch (p_credential->i_get_order)
+ {
+ /* DIALOG is the last way to fetch credential, use it until
+ * credentials are valid or until the user cancel it */
+ case GET_FROM_DIALOG:
+ break;
+
+ /* Query the system keystore before the memory keystore (cache) in
+ * order to always have up to date credentials (since the user may
+ * change its credential from an other app for example). */
+ case GET_FROM_MEMORY_KEYSTORE - 1:
+ p_credential->i_get_order = GET_FROM_KEYSTORE;
+ break;
+ case GET_FROM_KEYSTORE:
+ p_credential->i_get_order = GET_FROM_MEMORY_KEYSTORE;
+ break;
+ case GET_FROM_MEMORY_KEYSTORE:
+ p_credential->i_get_order = GET_FROM_KEYSTORE + 1;
+ break;
+
+ default:
+ p_credential->i_get_order++;
+ }
+ }
- return p_credential->i_get_order++;
+ return p_credential->i_get_order;
}
#undef vlc_credential_get
--
2.29.2
More information about the vlc-devel
mailing list