summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2013-04-11 08:05:08 -0400
committerJohn Dennis <jdennis@redhat.com>2013-04-11 08:05:08 -0400
commit6b6fc332a421674109afb759d05c32c47dcc378f (patch)
tree586c5161ddbead5c5becfa0b9d654ba9fcd846e3
parent5109fc7f1592036a662c2b678727db93d9b6a8cd (diff)
downloadrealmd-cim-6b6fc332a421674109afb759d05c32c47dcc378f.tar.gz
realmd-cim-6b6fc332a421674109afb759d05c32c47dcc378f.tar.xz
realmd-cim-6b6fc332a421674109afb759d05c32c47dcc378f.zip
Implement get_joined_domain(), used to initialize Domain property.
Add G_VARIANT_FREE & G_VARIANT_ITER_FREE macros that free the object and set the pointer to NULL.
-rw-r--r--LMI_RealmdKerberosRealmProvider.c6
-rw-r--r--LMI_RealmdServiceProvider.c62
-rw-r--r--rdcp_util.h16
3 files changed, 82 insertions, 2 deletions
diff --git a/LMI_RealmdKerberosRealmProvider.c b/LMI_RealmdKerberosRealmProvider.c
index 70253d1..abb0dbe 100644
--- a/LMI_RealmdKerberosRealmProvider.c
+++ b/LMI_RealmdKerberosRealmProvider.c
@@ -60,6 +60,12 @@ CMPIStatus LMI_RealmdKerberosRealm_InitFromDBusPath(
if (realm_props) {
g_variant_unref(realm_props);
}
+ if (kerberos_props) {
+ g_variant_unref(kerberos_props);
+ }
+ if (kerberos_membership_props) {
+ g_variant_unref(kerberos_membership_props);
+ }
return status;
}
diff --git a/LMI_RealmdServiceProvider.c b/LMI_RealmdServiceProvider.c
index 52d7d7d..d269469 100644
--- a/LMI_RealmdServiceProvider.c
+++ b/LMI_RealmdServiceProvider.c
@@ -8,6 +8,57 @@
static const CMPIBroker* _cb = NULL;
+/**
+ * get_joined_domain:
+ *
+ * @provider_props Realmd service provider properties
+ *
+ * Determine if the host is joined to a domain and if so return the domain name.
+ *
+ * Returns: domain name if found, NULL otherwise. Must be freed with g_free.
+ */
+static gchar *
+get_joined_domain(GVariant *provider_props)
+{
+ CMPIStatus status;
+ GError *g_error = NULL;
+ GVariant *realm_props = NULL;
+ GVariant *kerberos_props = NULL;
+ GVariantIter *iter = NULL;
+ gchar *realm_obj_path = NULL;
+ gchar *configured_interface = NULL;
+ gchar *domain_name = NULL;
+
+ CMSetStatus(&status, CMPI_RC_OK);
+
+ g_variant_lookup(provider_props, "Realms", "ao", &iter);
+ while (g_variant_iter_next(iter, "&o", &realm_obj_path)) {
+ GetDBusProperies(realm_props, realm_obj_path, REALM_DBUS_REALM_INTERFACE, &status);
+ if (g_variant_lookup(realm_props, "Configured", "&s", &configured_interface)) {
+ if (strlen(configured_interface)) {
+ if (strcmp(configured_interface, REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE) == 0) {
+ GetDBusProperies(kerberos_props, realm_obj_path,
+ REALM_DBUS_KERBEROS_INTERFACE, &status);
+ if (g_variant_lookup(kerberos_props, "DomainName", "&s", &domain_name)) {
+ goto exit;
+ }
+ G_VARIANT_FREE(kerberos_props);
+ }
+ }
+ }
+ G_VARIANT_FREE(realm_props);
+ }
+
+ exit:
+ G_VARIANT_ITER_FREE(iter);
+ G_VARIANT_FREE(realm_props);
+ G_VARIANT_FREE(kerberos_props);
+
+ return domain_name ? g_strdup(domain_name) : NULL;
+}
+
+
+
static void LMI_RealmdServiceInitialize()
{
}
@@ -47,8 +98,9 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
GVariantIter *iter;
gsize n_items;
gchar *realm_obj_path;
- gchar *name;
- gchar *version;
+ gchar *name = NULL;
+ gchar *version = NULL;
+ gchar *joined_domain = NULL;
CMSetStatus(&status, CMPI_RC_OK);
@@ -79,6 +131,10 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
LMI_RealmdService_Set_RealmdVersion(&lmi_realmd_service, version);
}
+ if ((joined_domain = get_joined_domain(provider_props))) {
+ LMI_RealmdService_Set_Domain(&lmi_realmd_service, joined_domain);
+ }
+
KReturnInstance(cr, lmi_realmd_service);
exit:
@@ -86,6 +142,8 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
g_variant_unref(provider_props);
}
+ g_free(joined_domain);
+
return status;
}
diff --git a/rdcp_util.h b/rdcp_util.h
index eb7e533..aef255a 100644
--- a/rdcp_util.h
+++ b/rdcp_util.h
@@ -13,6 +13,22 @@
#define REALMD_SERVICE_NAME "OpenLMI Realmd Service"
+#define G_VARIANT_FREE(variant) \
+{ \
+ if (variant) { \
+ g_variant_unref(variant); \
+ variant = NULL; \
+ } \
+}
+
+#define G_VARIANT_ITER_FREE(iter) \
+{ \
+ if (iter) { \
+ g_variant_iter_free(iter); \
+ iter = NULL; \
+ } \
+}
+
/**
* octetstring_parse
* @octetstring Pointer to octetstring data