summaryrefslogtreecommitdiffstats
path: root/LMI_RealmdKerberosRealmProvider.c
diff options
context:
space:
mode:
Diffstat (limited to 'LMI_RealmdKerberosRealmProvider.c')
-rw-r--r--LMI_RealmdKerberosRealmProvider.c249
1 files changed, 222 insertions, 27 deletions
diff --git a/LMI_RealmdKerberosRealmProvider.c b/LMI_RealmdKerberosRealmProvider.c
index fc4628a..0aecd12 100644
--- a/LMI_RealmdKerberosRealmProvider.c
+++ b/LMI_RealmdKerberosRealmProvider.c
@@ -41,8 +41,8 @@ CMPIStatus LMI_RealmdKerberosRealm_InitFromDBusPath(
return handle_g_error(&g_error, _cb, &status, CMPI_RC_ERR_FAILED, "rdcp_dbus_initialize failed");
}
- GetDBusProperies(realm_props, dbus_path, REALM_DBUS_REALM_INTERFACE);
- GetDBusProperies(kerberos_props, dbus_path, REALM_DBUS_KERBEROS_INTERFACE);
+ GetDBusProperies(realm_props, dbus_path, REALM_DBUS_REALM_INTERFACE, &status);
+ GetDBusProperies(kerberos_props, dbus_path, REALM_DBUS_KERBEROS_INTERFACE, &status);
LMI_RealmdRealmInitKeys(LMI_RealmdKerberosRealm, self, dbus_path);
LMI_InitFromDBusRealmProps(LMI_RealmdKerberosRealm, self, realm_props);
@@ -50,7 +50,7 @@ CMPIStatus LMI_RealmdKerberosRealm_InitFromDBusPath(
if (SupportsDBusInterface(realm_props, REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE)) {
GetDBusProperies(kerberos_membership_props, dbus_path,
- REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE);
+ REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE, &status);
LMI_InitFromDBusKerberosMembershipProps(LMI_RealmdKerberosRealm, self,
kerberos_membership_props);
@@ -107,14 +107,14 @@ static CMPIStatus LMI_RealmdKerberosRealmEnumInstances(
return handle_g_error(&g_error, _cb, &status, CMPI_RC_ERR_FAILED, "rdcp_dbus_initialize failed");
}
- GetDBusProperies(provider_props, REALM_DBUS_SERVICE_PATH, REALM_DBUS_PROVIDER_INTERFACE);
+ GetDBusProperies(provider_props, REALM_DBUS_SERVICE_PATH, REALM_DBUS_PROVIDER_INTERFACE, &status);
g_variant_lookup(provider_props, "Realms", "ao", &iter);
while (g_variant_iter_next(iter, "&o", &realm_obj_path)) {
GVariant *realm_props = NULL;
LMI_RealmdKerberosRealm realmd_realm;
- GetDBusProperies(realm_props, realm_obj_path, REALM_DBUS_REALM_INTERFACE);
+ GetDBusProperies(realm_props, realm_obj_path, REALM_DBUS_REALM_INTERFACE, &status);
if (!SupportsDBusInterface(realm_props, REALM_DBUS_KERBEROS_INTERFACE)) {
continue;
}
@@ -277,31 +277,31 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
GVariant *data_variant = NULL;
GVariant *options = NULL;
- KUint32_Set(&result, 0);
+ 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, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!Type->exists || Type->null) {
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Type parameter absent")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Type parameter absent");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!Owner->exists || Owner->null) {
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Owner parameter absent")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Owner parameter absent");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!dbus_path_from_instance_id(self->InstanceID.chars, &dbus_path, &g_error)) {
handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED,
"dbus_path_from_instance_id() failed");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -317,8 +317,8 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
case LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_none:
break;
default:
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Owner parameter")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Owner parameter");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -330,20 +330,20 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
if ((Name->exists && !Name->null) || (Password->exists && !Password->null)) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Name & Password parameters must be NULL when Type is ccache");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!Data->exists || Data->null) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Data parameter must be provided when Type is ccache");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if ((data = get_data_from_KUint8A(Data, &data_len)) == NULL) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_FAILED,
"unabled to allocate memory");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
data_variant = g_variant_new_from_data(G_VARIANT_TYPE ("ay"),
@@ -356,13 +356,13 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
if (!Name->exists || Name->null || !Password->exists || Password->null) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Name & Password parameters must be provided when Type is password");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (Data->exists && !Data->null) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Data parameter must be NULL when Type is password");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -374,20 +374,20 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
if ((Name->exists && !Name->null) || (Password->exists && !Password->null)) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Name & Password parameters must be NULL when Type is secret");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!Data->exists || Data->null) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Data parameter must be provided when Type is secret");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if ((data = get_data_from_KUint8A(Data, &data_len)) == NULL) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_FAILED,
"unabled to allocate memory");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
credentials = g_variant_new("(ssv)", cred_type, cred_owner,
@@ -399,7 +399,7 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
(Data->exists && !Data->null)) {
CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
"Name, Password & Data parameters must be NULL when Type is secret");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -408,8 +408,8 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
break;
default:
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Type parameter")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Type parameter");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -417,13 +417,13 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
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, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!dbus_join_call(system_bus, dbus_path, credentials, options, &g_error)) {
handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED, "dbus_join_call() failed");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -446,6 +446,201 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
return result;
}
+KEXTERN KUint32 LMI_RealmdKerberosRealm_Leave(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdKerberosRealmRef* self,
+ const KUint32* Type,
+ const KUint32* Owner,
+ const KString* Name,
+ const KString* Password,
+ const KUint8A* Data,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status)
+{
+ GError *g_error = NULL;
+ KUint32 result = KUINT32_INIT;
+ const char *cred_type = NULL;
+ const char *cred_owner = NULL;
+ gchar *data = NULL;
+ gsize data_len;
+ gchar *dbus_path = NULL;
+ GVariant *credentials = NULL;
+ GVariant *data_variant = NULL;
+ GVariant *options = NULL;
+
+ 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 (!Type->exists || Type->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Type parameter absent");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ if (!Owner->exists || Owner->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Owner parameter absent");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ if (!dbus_path_from_instance_id(self->InstanceID.chars, &dbus_path, &g_error)) {
+ handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED,
+ "dbus_path_from_instance_id() failed");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+#ifdef RDCP_DEBUG
+ printf("%s: InstanceID=\"%s\" dbus_path=\"%s\"\n",
+ __FUNCTION__, self->InstanceID.chars, dbus_path);
+#endif
+
+ switch(Owner->value) {
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_administrator:
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_user:
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_computer:
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_none:
+ break;
+ default:
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Owner parameter");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ cred_type = SupportedLeaveCredentialTypes_enum_to_name(Type->value);
+ cred_owner = SupportedLeaveCredentialOwners_enum_to_name(Owner->value);
+
+ switch(Type->value) {
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_ccache:
+ if ((Name->exists && !Name->null) || (Password->exists && !Password->null)) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Name & Password parameters must be NULL when Type is ccache");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ if (!Data->exists || Data->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Data parameter must be provided when Type is ccache");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ if ((data = get_data_from_KUint8A(Data, &data_len)) == NULL) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_FAILED,
+ "unabled to allocate memory");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ data_variant = g_variant_new_from_data(G_VARIANT_TYPE ("ay"),
+ data, data_len,
+ TRUE, g_free, (gpointer) data);
+
+ credentials = g_variant_new("(ssv)", cred_type, cred_owner, data_variant);
+ break;
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_password:
+ if (!Name->exists || Name->null || !Password->exists || Password->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Name & Password parameters must be provided when Type is password");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ if (Data->exists && !Data->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Data parameter must be NULL when Type is password");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ credentials = g_variant_new("(ssv)", cred_type, cred_owner,
+ g_variant_new("(ss)", Name->chars, Password->chars));
+
+ break;
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_secrect:
+ if ((Name->exists && !Name->null) || (Password->exists && !Password->null)) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Name & Password parameters must be NULL when Type is secret");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ if (!Data->exists || Data->null) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Data parameter must be provided when Type is secret");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ if ((data = get_data_from_KUint8A(Data, &data_len)) == NULL) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_FAILED,
+ "unabled to allocate memory");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ credentials = g_variant_new("(ssv)", cred_type, cred_owner,
+ g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE,
+ data, data_len, 1));
+ break;
+ case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_automatic:
+ if ((Name->exists && !Name->null) || (Password->exists && !Password->null) ||
+ (Data->exists && !Data->null)) {
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Name, Password & Data parameters must be NULL when Type is secret");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ credentials = g_variant_new ("(ssv)", cred_type, cred_owner,
+ g_variant_new_string (""));
+
+ break;
+ default:
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "Invalid Type parameter");
+ 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_leave_call(system_bus, dbus_path, credentials, options, &g_error)) {
+ handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED, "dbus_leave_call() failed");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+
+ exit:
+
+ if (data) {
+ g_free(data);
+ }
+ if (credentials) {
+ g_variant_unref(credentials);
+ }
+ if (data_variant) {
+ g_variant_unref(data_variant);
+ }
+ if (options) {
+ g_variant_unref(options);
+ }
+
+ return result;
+}
+
+
KONKRET_REGISTRATION(
"root/cimv2",
"LMI_RealmdKerberosRealm",