Blob Blame History Raw
From cf40987b7f847be70ef3a5a0fa359116c0259477 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Fri, 30 Oct 2020 13:19:09 +0100
Subject: [PATCH 1/6] service: add REALM_DBUS_OPTION_USE_LDAPS and
 realm_get_use_ldaps

Add a new option to the realmd service to use ldaps where possible and
supported.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1826964
---
 dbus/realm-dbus-constants.h |  1 +
 service/realm-options.c     | 17 +++++++++++++++++
 service/realm-options.h     |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/dbus/realm-dbus-constants.h b/dbus/realm-dbus-constants.h
index 40ffa2d..0bd7a5d 100644
--- a/dbus/realm-dbus-constants.h
+++ b/dbus/realm-dbus-constants.h
@@ -70,6 +70,7 @@ G_BEGIN_DECLS
 #define   REALM_DBUS_OPTION_OS_NAME                "os-name"
 #define   REALM_DBUS_OPTION_OS_VERSION             "os-version"
 #define   REALM_DBUS_OPTION_LEGACY_SMB_CONF        "legacy-samba-config"
+#define   REALM_DBUS_OPTION_USE_LDAPS              "use-ldaps"
 
 #define   REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY   "active-directory"
 #define   REALM_DBUS_IDENTIFIER_WINBIND            "winbind"
diff --git a/service/realm-options.c b/service/realm-options.c
index 34a209f..d42eb7c 100644
--- a/service/realm-options.c
+++ b/service/realm-options.c
@@ -199,3 +199,20 @@ realm_options_ad_specific (GVariant *options,
 
 	return g_strdup (value);
 }
+
+gboolean realm_option_use_ldaps (GVariant *options)
+{
+	gchar *use_ldaps_str;
+
+	use_ldaps_str = realm_options_ad_specific (options,
+	                                          REALM_DBUS_OPTION_USE_LDAPS);
+	if (use_ldaps_str != NULL
+	            && ( g_ascii_strcasecmp (use_ldaps_str, "True") == 0
+	                || g_ascii_strcasecmp (use_ldaps_str, "Yes") == 0)) {
+		g_free (use_ldaps_str);
+		return TRUE;
+	}
+	g_free (use_ldaps_str);
+
+	return FALSE;
+}
diff --git a/service/realm-options.h b/service/realm-options.h
index b71d219..bc13cd7 100644
--- a/service/realm-options.h
+++ b/service/realm-options.h
@@ -48,6 +48,8 @@ const gchar *  realm_options_computer_name           (GVariant *options,
 const gchar *  realm_options_ad_specific              (GVariant *options,
                                                        const gchar *option_name);
 
+gboolean       realm_option_use_ldaps                 (GVariant *options);
+
 G_END_DECLS
 
 #endif /* __REALM_OPTIONS_H__ */
-- 
2.26.2