[gnome-online-accounts/wip/rishi/kcm-notification: 3/4] kerberos-identity-manager: Shuffle some code around
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/kcm-notification: 3/4] kerberos-identity-manager: Shuffle some code around
- Date: Tue, 20 Oct 2020 18:07:38 +0000 (UTC)
commit eeb9fa36ce373d87c4724af02a5ae85fdfde97b4
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Oct 20 19:46:11 2020 +0200
kerberos-identity-manager: Shuffle some code around
A subsequent commit will start using notifications from Kerberos KCM
credential caches as supported by the KCM implementation in SSSD. This
rearranges the code to make it easier to enable notifications for
different credential cache types.
src/goaidentity/goakerberosidentitymanager.c | 57 +++++++++++++---------------
1 file changed, 26 insertions(+), 31 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index 9657881f..50db6ed7 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -1341,7 +1341,6 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
GFileMonitor *monitor = NULL;
krb5_error_code error_code;
GError *monitoring_error = NULL;
- gboolean can_monitor = TRUE;
error_code = krb5_cc_default (self->kerberos_context, &default_cache);
@@ -1362,13 +1361,6 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
cache_type = krb5_cc_get_type (self->kerberos_context, default_cache);
g_assert (cache_type != NULL);
- if (strcmp (cache_type, "FILE") != 0 && strcmp (cache_type, "DIR") != 0)
- {
- g_warning ("GoaKerberosIdentityManager: Using polling for change notification for credential cache
type '%s'",
- cache_type);
- can_monitor = FALSE;
- }
-
g_free (self->credentials_cache_type);
self->credentials_cache_type = g_strdup (cache_type);
@@ -1390,38 +1382,41 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
if (cache_path[0] == ':')
cache_path++;
- if (can_monitor)
+ if (strcmp (cache_type, "FILE") == 0)
{
GFile *file;
file = g_file_new_for_path (cache_path);
monitoring_error = NULL;
- if (strcmp (cache_type, "FILE") == 0)
- {
- monitor = g_file_monitor_file (file,
- G_FILE_MONITOR_NONE,
- NULL,
- &monitoring_error);
- }
- else if (strcmp (cache_type, "DIR") == 0)
- {
- GFile *directory;
+ monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &monitoring_error);
- directory = g_file_get_parent (file);
- monitor = g_file_monitor_directory (directory,
- G_FILE_MONITOR_NONE,
- NULL,
- &monitoring_error);
- g_object_unref (directory);
+ g_object_unref (file);
+ }
+ else if (strcmp (cache_type, "DIR") == 0)
+ {
+ GFile *directory;
+ GFile *file;
- }
+ file = g_file_new_for_path (cache_path);
+ directory = g_file_get_parent (file);
+
+ monitoring_error = NULL;
+ monitor = g_file_monitor_directory (directory, G_FILE_MONITOR_NONE, NULL, &monitoring_error);
+
+ g_object_unref (directory);
g_object_unref (file);
}
if (monitor == NULL)
{
- if (monitoring_error != NULL)
+ if (monitoring_error == NULL)
+ {
+ g_warning ("GoaKerberosIdentityManager: Using polling for change notification for credential "
+ "cache type '%s'",
+ cache_type);
+ }
+ else
{
g_warning ("GoaKerberosIdentityManager: Could not monitor credentials for %s (type %s), reverting
to "
"polling: %s",
@@ -1430,7 +1425,10 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
monitoring_error != NULL? monitoring_error->message : "");
g_clear_error (&monitoring_error);
}
- can_monitor = FALSE;
+
+ self->polling_timeout_id = g_timeout_add_seconds (FALLBACK_POLLING_INTERVAL,
+ (GSourceFunc) on_polling_timeout,
+ self);
}
else
{
@@ -1438,9 +1436,6 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
self->credentials_cache_monitor = monitor;
}
- if (!can_monitor)
- self->polling_timeout_id = g_timeout_add_seconds (FALLBACK_POLLING_INTERVAL, (GSourceFunc)
on_polling_timeout, self);
-
krb5_cc_close (self->kerberos_context, default_cache);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]