summaryrefslogtreecommitdiffstats
path: root/src/realmd/LMI_RealmdServiceProvider.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/realmd/LMI_RealmdServiceProvider.c')
-rw-r--r--src/realmd/LMI_RealmdServiceProvider.c131
1 files changed, 21 insertions, 110 deletions
diff --git a/src/realmd/LMI_RealmdServiceProvider.c b/src/realmd/LMI_RealmdServiceProvider.c
index 8bc1b79..fa4f834 100644
--- a/src/realmd/LMI_RealmdServiceProvider.c
+++ b/src/realmd/LMI_RealmdServiceProvider.c
@@ -1,10 +1,9 @@
#include <konkret/konkret.h>
#include "LMI_RealmdService.h"
+#include "rdcp_util.h"
#include "globals.h"
#include "rdcp_error.h"
#include "rdcp_dbus.h"
-#include "rdcp_util.h"
-#include "rdcp_realmdrealm.h"
static const CMPIBroker* _cb = NULL;
@@ -94,13 +93,7 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
LMI_RealmdService lmi_realmd_service;
const char *name_space = KNameSpace(cop);
const char *host_name = get_system_name();
- CMPICount i;
GVariant *provider_props = NULL;
- GVariantIter *iter;
- gsize n_items;
- gchar *realm_obj_path;
- gchar *name = NULL;
- gchar *version = NULL;
gchar *joined_domain = NULL;
CMSetStatus(&status, CMPI_RC_OK);
@@ -114,24 +107,6 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
GET_DBUS_PROPERIES_OR_EXIT(provider_props, REALM_DBUS_SERVICE_PATH,
REALM_DBUS_PROVIDER_INTERFACE, &status);
- g_variant_lookup(provider_props, "Realms", "ao", &iter);
- n_items = g_variant_iter_n_children(iter);
- LMI_RealmdService_Init_Realms(&lmi_realmd_service, n_items);
- for (i = 0; g_variant_iter_next(iter, "&o", &realm_obj_path); i++) {
-#ifdef RDCP_DEBUG
- printf("path[%d]=%s\n", i, realm_obj_path);
-#endif
- LMI_RealmdService_Set_Realms(&lmi_realmd_service, i, realm_obj_path);
- }
-
- if (g_variant_lookup(provider_props, "Name", "&s", &name)) {
- LMI_RealmdService_Set_RealmdName(&lmi_realmd_service, name);
- }
-
- if (g_variant_lookup(provider_props, "Version", "&s", &version)) {
- 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);
}
@@ -139,7 +114,6 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
KReturnInstance(cr, lmi_realmd_service);
exit:
- G_VARIANT_ITER_FREE(iter);
G_VARIANT_FREE(provider_props);
g_free(joined_domain);
@@ -289,88 +263,6 @@ KUint32 LMI_RealmdService_ChangeAffectedElementsAssignedSequence(
return result;
}
-KUint32 LMI_RealmdService_Discover(
- const CMPIBroker* cb,
- CMPIMethodMI* mi,
- const CMPIContext* context,
- const LMI_RealmdServiceRef* self,
- const KString* Target,
- const KStringA* OptionNames,
- const KStringA* OptionValues,
- KRefA* DiscoveredRealms,
- CMPIStatus* status)
-{
- GError *g_error = NULL;
- KUint32 result = KUINT32_INIT;
- GVariant *options = NULL;
- gint32 relevance = 0;
- gchar **paths = NULL;
- gchar *path, **pp;
- CMPICount i, n_paths;
-
- KUint32_Set(&result, LMI_REALMD_RESULT_SUCCESS);
- CMSetStatus(status, CMPI_RC_OK);
-
- if (!rdcp_dbus_initialize(&g_error)) {
- handle_g_error(&g_error, _cb, status, CMPI_RC_ERR_FAILED, "rdcp_dbus_initialize failed");
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
-
- if (!build_g_variant_options_from_KStringA(OptionNames, OptionValues, &options, &g_error)) {
- handle_g_error(&g_error, _cb, status, CMPI_RC_ERR_FAILED,
- "failed to convert options to gvariant");
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
-
- if (!dbus_discover_call(system_bus, Target->chars, options,
- &relevance, &paths, &g_error)) {
- handle_g_error(&g_error, _cb, status, CMPI_RC_ERR_FAILED, "dbus_discover_call() failed");
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
-
-#ifdef RDCP_DEBUG
- print_paths(paths, "%s: target=%s, paths:", __FUNCTION__, Target->chars);
-#endif
-
- for (pp = paths, path = *pp++, n_paths = 0; path; path = *pp++, n_paths++);
-
- if (!KRefA_Init(DiscoveredRealms, cb, n_paths)) {
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
-
- for (pp = paths, path = *pp++, i = 0; path; path = *pp++, i++) {
- LMI_RealmdRealmRef realmdrealm_ref;
- CMPIObjectPath *realmdrealm_op;
-
-
- *status = LMI_RealmdRealmRef_InitFromDBusPath(&realmdrealm_ref, cb,
- LMI_RealmdServiceRef_NameSpace((LMI_RealmdServiceRef*)self), path);
- if (status->rc != CMPI_RC_OK) {
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
-
- if ((realmdrealm_op = LMI_RealmdRealmRef_ToObjectPath(&realmdrealm_ref, status)) == NULL) {
- goto exit;
- }
- if (!KRefA_Set(DiscoveredRealms, i, realmdrealm_op)) {
- KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
- goto exit;
- }
- }
-
- exit:
-
- G_VARIANT_FREE(options);
- g_strfreev(paths);
-
- return result;
-}
-
// FIXME
static gboolean
get_credential_supported_owner(GVariant *supported, const gchar *cred_type, const gchar **cred_owner_return)
@@ -408,6 +300,25 @@ is_credential_supported (GVariant *supported, const gchar *cred_type, const gcha
return FALSE;
}
+static gboolean
+supports_dbus_interface(GVariant *dbus_props, const char *dbus_interface)
+{
+ gboolean result = FALSE;
+ GVariantIter *iter = NULL;
+ gchar *value;
+
+ if (g_variant_lookup(dbus_props, "SupportedInterfaces", "as", &iter)) {
+ while (g_variant_iter_next(iter, "&s", &value)) {
+ if (strcmp(value, dbus_interface) == 0) {
+ result = TRUE;
+ break;
+ }
+ }
+ G_VARIANT_ITER_FREE(iter);
+ }
+ return result;
+}
+
KUint32 LMI_RealmdService_Join_Leave_Domain(
bool join,
const CMPIBroker* cb,
@@ -487,7 +398,7 @@ KUint32 LMI_RealmdService_Join_Leave_Domain(
/* Lookup the realm properties so we can determine the supported DBus interfaces */
GET_DBUS_PROPERIES_OR_EXIT(realm_props, dbus_path,
REALM_DBUS_REALM_INTERFACE, status);
- if (!SupportsDBusInterface(realm_props, REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE)) {
+ if (!supports_dbus_interface(realm_props, REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE)) {
SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED, "Domain (%s) does not support joining or leaving",
Domain->chars);
KUint32_Set(&result, LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_JOINING);