summaryrefslogtreecommitdiff
path: root/chooser
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2017-03-31 15:40:21 -0400
committerRay Strode <rstrode@redhat.com>2017-03-31 17:22:27 -0400
commit9e2d145ad0693dcb9a2c1c1a926b28305da564b3 (patch)
tree8c5a3d5758ba9973f298cee29c3f6773c484e7c1 /chooser
parent672df0abf5da56b00e81ed79eee337c44e1bee15 (diff)
downloadgdm-9e2d145ad0693dcb9a2c1c1a926b28305da564b3.tar.gz
chooser: filter out duplicate hostnames
One host may report itself on multiple interfaces. GDM only supports based on hostname not interface, so that leads duplicate entries in the list. This commit filters out the dupes. https://bugzilla.gnome.org/show_bug.cgi?id=780787
Diffstat (limited to 'chooser')
-rw-r--r--chooser/gdm-host-chooser-widget.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/chooser/gdm-host-chooser-widget.c b/chooser/gdm-host-chooser-widget.c
index f8aabf3e..e2507900 100644
--- a/chooser/gdm-host-chooser-widget.c
+++ b/chooser/gdm-host-chooser-widget.c
@@ -119,6 +119,33 @@ chooser_host_remove (GdmHostChooserWidget *widget,
}
#endif
+static gboolean
+address_hostnames_equal (GdmAddress *address,
+ GdmAddress *other_address)
+{
+ char *hostname, *other_hostname;
+ gboolean are_equal;
+
+ if (gdm_address_equal (address, other_address)) {
+ return TRUE;
+ }
+
+ if (!gdm_address_get_hostname (address, &hostname)) {
+ gdm_address_get_numeric_info (address, &hostname, NULL);
+ }
+
+ if (!gdm_address_get_hostname (other_address, &other_hostname)) {
+ gdm_address_get_numeric_info (other_address, &other_hostname, NULL);
+ }
+
+ are_equal = g_strcmp0 (hostname, other_hostname) == 0;
+
+ g_free (hostname);
+ g_free (other_hostname);
+
+ return are_equal;
+}
+
static GdmChooserHost *
find_known_host (GdmHostChooserWidget *widget,
GdmAddress *address)
@@ -127,8 +154,13 @@ find_known_host (GdmHostChooserWidget *widget,
GdmChooserHost *host;
for (li = widget->priv->chooser_hosts; li != NULL; li = li->next) {
+ GdmAddress *other_address;
+
host = li->data;
- if (gdm_address_equal (gdm_chooser_host_get_address (host), address)) {
+
+ other_address = gdm_chooser_host_get_address (host);
+
+ if (address_hostnames_equal (address, other_address)) {
goto out;
}
}