|
|
688d36 |
From 6f0aa79c3e8dd93e723f29bf46e1b8b14403254f Mon Sep 17 00:00:00 2001
|
|
|
688d36 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
688d36 |
Date: Mon, 5 Dec 2016 18:25:44 +0100
|
|
|
688d36 |
Subject: [PATCH] Kerberos: fall back to tcp SRV lookup
|
|
|
688d36 |
|
|
|
688d36 |
---
|
|
|
688d36 |
service/realm-kerberos-provider.c | 48 +++++++++++++++++++++++++++++++--------
|
|
|
688d36 |
1 file changed, 39 insertions(+), 9 deletions(-)
|
|
|
688d36 |
|
|
|
688d36 |
diff --git a/service/realm-kerberos-provider.c b/service/realm-kerberos-provider.c
|
|
|
688d36 |
index 2b3a0f8..1477ae8 100644
|
|
|
688d36 |
--- a/service/realm-kerberos-provider.c
|
|
|
688d36 |
+++ b/service/realm-kerberos-provider.c
|
|
|
688d36 |
@@ -19,6 +19,7 @@
|
|
|
688d36 |
#include "realm-kerberos-provider.h"
|
|
|
688d36 |
|
|
|
688d36 |
#include <errno.h>
|
|
|
688d36 |
+#include <string.h>
|
|
|
688d36 |
|
|
|
688d36 |
struct _RealmKerberosProvider {
|
|
|
688d36 |
RealmProvider parent;
|
|
|
688d36 |
@@ -38,28 +39,54 @@ realm_kerberos_provider_init (RealmKerberosProvider *self)
|
|
|
688d36 |
|
|
|
688d36 |
}
|
|
|
688d36 |
|
|
|
688d36 |
+typedef struct {
|
|
|
688d36 |
+ gchar *name;
|
|
|
688d36 |
+ const char *prot;
|
|
|
688d36 |
+} NameProtPair;
|
|
|
688d36 |
+
|
|
|
688d36 |
+static void
|
|
|
688d36 |
+name_prot_pair_free (gpointer data)
|
|
|
688d36 |
+{
|
|
|
688d36 |
+ NameProtPair *name_prot_pair = data;
|
|
|
688d36 |
+ g_free (name_prot_pair->name);
|
|
|
688d36 |
+ g_free (name_prot_pair);
|
|
|
688d36 |
+}
|
|
|
688d36 |
+
|
|
|
688d36 |
static void
|
|
|
688d36 |
on_kerberos_discover (GObject *source,
|
|
|
688d36 |
GAsyncResult *result,
|
|
|
688d36 |
gpointer user_data)
|
|
|
688d36 |
{
|
|
|
688d36 |
GTask *task = G_TASK (user_data);
|
|
|
688d36 |
- const gchar *domain = g_task_get_task_data (task);
|
|
|
688d36 |
+ NameProtPair *name_prot_pair = g_task_get_task_data (task);
|
|
|
688d36 |
GError *error = NULL;
|
|
|
688d36 |
RealmDisco *disco;
|
|
|
688d36 |
GList *targets;
|
|
|
688d36 |
+ GResolver *resolver;
|
|
|
688d36 |
|
|
|
688d36 |
targets = g_resolver_lookup_service_finish (G_RESOLVER (source), result, &error);
|
|
|
688d36 |
if (targets) {
|
|
|
688d36 |
g_list_free_full (targets, (GDestroyNotify)g_srv_target_free);
|
|
|
688d36 |
- disco = realm_disco_new (domain);
|
|
|
688d36 |
- disco->kerberos_realm = g_ascii_strup (domain, -1);
|
|
|
688d36 |
+ disco = realm_disco_new (name_prot_pair->name);
|
|
|
688d36 |
+ disco->kerberos_realm = g_ascii_strup (name_prot_pair->name, -1);
|
|
|
688d36 |
g_task_return_pointer (task, disco, realm_disco_unref);
|
|
|
688d36 |
|
|
|
688d36 |
} else if (error) {
|
|
|
688d36 |
- g_debug ("Resolving %s failed: %s", domain, error->message);
|
|
|
688d36 |
+ g_debug ("Resolving %s failed: %s", name_prot_pair->name, error->message);
|
|
|
688d36 |
g_error_free (error);
|
|
|
688d36 |
- g_task_return_pointer (task, NULL, NULL);
|
|
|
688d36 |
+
|
|
|
688d36 |
+ if (strcmp (name_prot_pair->prot, "tcp") == 0) {
|
|
|
688d36 |
+ g_task_return_pointer (task, NULL, NULL);
|
|
|
688d36 |
+ } else {
|
|
|
688d36 |
+ /* Try tcp */
|
|
|
688d36 |
+ name_prot_pair->prot = "tcp";
|
|
|
688d36 |
+ resolver = g_resolver_get_default ();
|
|
|
688d36 |
+ g_resolver_lookup_service_async (resolver, "kerberos", name_prot_pair->prot,
|
|
|
688d36 |
+ name_prot_pair->name,
|
|
|
688d36 |
+ g_task_get_cancellable (task),
|
|
|
688d36 |
+ on_kerberos_discover, g_object_ref (task));
|
|
|
688d36 |
+ g_object_unref (resolver);
|
|
|
688d36 |
+ }
|
|
|
688d36 |
}
|
|
|
688d36 |
|
|
|
688d36 |
g_object_unref (task);
|
|
|
688d36 |
@@ -76,7 +103,7 @@ realm_kerberos_provider_discover_async (RealmProvider *provider,
|
|
|
688d36 |
GTask *task;
|
|
|
688d36 |
const gchar *software;
|
|
|
688d36 |
GResolver *resolver;
|
|
|
688d36 |
- gchar *name;
|
|
|
688d36 |
+ NameProtPair *name_prot_pair;
|
|
|
688d36 |
|
|
|
688d36 |
task = g_task_new (provider, NULL, callback, user_data);
|
|
|
688d36 |
|
|
|
688d36 |
@@ -86,12 +113,15 @@ realm_kerberos_provider_discover_async (RealmProvider *provider,
|
|
|
688d36 |
g_task_return_pointer (task, NULL, NULL);
|
|
|
688d36 |
|
|
|
688d36 |
} else {
|
|
|
688d36 |
- name = g_hostname_to_ascii (string);
|
|
|
688d36 |
+ name_prot_pair = g_new0 (NameProtPair, 1);
|
|
|
688d36 |
+ name_prot_pair->name = g_hostname_to_ascii (string);
|
|
|
688d36 |
+ name_prot_pair->prot = "udp";
|
|
|
688d36 |
resolver = g_resolver_get_default ();
|
|
|
688d36 |
- g_resolver_lookup_service_async (resolver, "kerberos", "udp", name,
|
|
|
688d36 |
+ g_resolver_lookup_service_async (resolver, "kerberos", name_prot_pair->prot,
|
|
|
688d36 |
+ name_prot_pair->name,
|
|
|
688d36 |
realm_invocation_get_cancellable (invocation),
|
|
|
688d36 |
on_kerberos_discover, g_object_ref (task));
|
|
|
688d36 |
- g_task_set_task_data (task, name, g_free);
|
|
|
688d36 |
+ g_task_set_task_data (task, name_prot_pair, name_prot_pair_free);
|
|
|
688d36 |
g_object_unref (resolver);
|
|
|
688d36 |
}
|
|
|
688d36 |
|
|
|
688d36 |
--
|
|
|
688d36 |
2.9.3
|
|
|
688d36 |
|