diff options
author | GoliathLabs | 2020-06-22 14:11:40 +0200 |
---|---|---|
committer | GoliathLabs | 2020-06-22 14:11:40 +0200 |
commit | f440bcd34523ad4b2f8a1cd7d3d70c6eb14f9b6c (patch) | |
tree | ec3f8bd39172114b8a37e7dafc5aa5b9c6e48e12 /0003-discover-try-to-get-domain-name-from-hostname.patch | |
parent | 3efd20d51255057cecd2d5b8852d923f0ad1d3a8 (diff) | |
download | aur-f440bcd34523ad4b2f8a1cd7d3d70c6eb14f9b6c.tar.gz |
Updated: patches
Diffstat (limited to '0003-discover-try-to-get-domain-name-from-hostname.patch')
-rw-r--r-- | 0003-discover-try-to-get-domain-name-from-hostname.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/0003-discover-try-to-get-domain-name-from-hostname.patch b/0003-discover-try-to-get-domain-name-from-hostname.patch new file mode 100644 index 000000000000..b611d6c8ada8 --- /dev/null +++ b/0003-discover-try-to-get-domain-name-from-hostname.patch @@ -0,0 +1,76 @@ +From 5e28cf702ad338e399f8fff0b3fa18736a297318 Mon Sep 17 00:00:00 2001 +From: Sumit Bose <sbose@redhat.com> +Date: Tue, 21 Aug 2018 13:09:20 +0200 +Subject: [PATCH 3/3] discover: try to get domain name from hostname + +If there is no domain name returned by DHCP check if the hostname +contains a domain part and use this to discover a realm. + +Related to https://bugzilla.redhat.com/show_bug.cgi?id=1619162 +--- + service/realm-provider.c | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +diff --git a/service/realm-provider.c b/service/realm-provider.c +index d647c7a..258e8e1 100644 +--- a/service/realm-provider.c ++++ b/service/realm-provider.c +@@ -28,6 +28,8 @@ + #include <glib/gi18n.h> + #include <gio/gio.h> + ++#include <errno.h> ++ + #define TIMEOUT_SECONDS 15 + + G_DEFINE_TYPE (RealmProvider, realm_provider, G_TYPE_DBUS_OBJECT_SKELETON); +@@ -181,6 +183,25 @@ on_discover_complete (GObject *source, + return_discover_result (method, realms, relevance, error); + } + ++static gchar * ++get_domain_from_hostname (void) ++{ ++ gchar hostname[HOST_NAME_MAX + 1]; ++ gchar *dot; ++ ++ if (gethostname (hostname, sizeof (hostname)) < 0) { ++ g_warning ("Couldn't get the computer host name: %s", g_strerror (errno)); ++ return NULL; ++ } ++ ++ dot = strchr (hostname, '.'); ++ if (dot != NULL) { ++ return g_strdup (dot + 1); ++ } ++ ++ return NULL; ++} ++ + static void + on_discover_default (GObject *source, + GAsyncResult *result, +@@ -195,6 +216,10 @@ on_discover_default (GObject *source, + g_clear_error (&error); + } + ++ if (method->string == NULL) { ++ method->string = get_domain_from_hostname (); ++ } ++ + if (method->string) { + g_strstrip (method->string); + if (g_str_equal (method->string, "")) { +@@ -210,7 +235,8 @@ on_discover_default (GObject *source, + on_discover_complete, method); + + } else { +- realm_diagnostics_info (method->invocation, "No default domain received via DHCP"); ++ realm_diagnostics_info (method->invocation, ++ "No default domain received via DHCP or given by hostname"); + return_discover_result (method, NULL, 0, NULL); + } + } +-- +2.17.1 + |