summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2013-03-28 15:19:45 -0400
committerJohn Dennis <jdennis@redhat.com>2013-03-28 15:19:45 -0400
commit97a213ae1c58fec62a27c47fa46b822032f3d504 (patch)
tree4c54eecc94867413579d14adeabebe45692533a3
parentb6e01f4262176376920a59038012a4ef273d0235 (diff)
downloadrealmd-cim-97a213ae1c58fec62a27c47fa46b822032f3d504.tar.gz
realmd-cim-97a213ae1c58fec62a27c47fa46b822032f3d504.tar.xz
realmd-cim-97a213ae1c58fec62a27c47fa46b822032f3d504.zip
Add support for leaving realm
* Implement DBus leave method * Implement LMI_RealmdKerberosRealm.Leave() method * Implement LMI_RealmdService JoinDomain() & LeaveDomain() methods * GedDBusProperties now takes CMPIStatus arg * Add LMI_REALMD_RESULT_* constants, replaced hardcoded numbers * Implement SetCMPIStatus() which replaces CMSetStatusWithChars, SetCMPIStatus() permits printf style string formatting * Move handle_g_error() from rdcp_util to rdcp_error
-rw-r--r--LMI_RealmdKerberosRealm.h125
-rw-r--r--LMI_RealmdKerberosRealmProvider.c249
-rw-r--r--LMI_RealmdRealmProvider.c24
-rw-r--r--LMI_RealmdService.h279
-rw-r--r--LMI_RealmdServiceProvider.c286
-rw-r--r--LMI_ServiceAffectsRealmdRealmProvider.c2
-rw-r--r--mof/LMI_Realmd.mof100
-rw-r--r--rdcp_dbus.c92
-rw-r--r--rdcp_dbus.h8
-rw-r--r--rdcp_error.c100
-rw-r--r--rdcp_error.h18
-rw-r--r--rdcp_util.c53
-rw-r--r--rdcp_util.h5
13 files changed, 1208 insertions, 133 deletions
diff --git a/LMI_RealmdKerberosRealm.h b/LMI_RealmdKerberosRealm.h
index 0193afe..641fb29 100644
--- a/LMI_RealmdKerberosRealm.h
+++ b/LMI_RealmdKerberosRealm.h
@@ -2793,6 +2793,81 @@ KINLINE void LMI_RealmdKerberosRealm_Join_Args_Print(
KBase_Print(os, &self->__base, 'a');
}
+/* classname=LMI_RealmdKerberosRealm */
+typedef struct _LMI_RealmdKerberosRealm_Leave_Args
+{
+ KBase __base;
+ /* IN */
+ KUint32 Type;
+ /* IN */
+ KUint32 Owner;
+ /* IN */
+ KString Name;
+ /* IN */
+ KString Password;
+ /* IN */
+ KUint8A Data;
+ /* IN */
+ KStringA OptionNames;
+ /* IN */
+ KStringA OptionValues;
+}
+LMI_RealmdKerberosRealm_Leave_Args;
+
+static const unsigned char __LMI_RealmdKerberosRealm_Leave_Args_sig[] =
+{
+ 0x05,0x4c,0x65,0x61,0x76,0x65,0x00,0x07,0x25,0x04,0x54,0x79,0x70,0x65,0x00,
+ 0x25,0x05,0x4f,0x77,0x6e,0x65,0x72,0x00,0x2c,0x04,0x4e,0x61,0x6d,0x65,0x00,
+ 0x2c,0x08,0x50,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x00,0xa1,0x04,0x44,0x61,
+ 0x74,0x61,0x00,0xac,0x0b,0x4f,0x70,0x74,0x69,0x6f,0x6e,0x4e,0x61,0x6d,0x65,
+ 0x73,0x00,0xac,0x0c,0x4f,0x70,0x74,0x69,0x6f,0x6e,0x56,0x61,0x6c,0x75,0x65,
+ 0x73,0x00,
+};
+
+KINLINE void LMI_RealmdKerberosRealm_Leave_Args_Init(
+ LMI_RealmdKerberosRealm_Leave_Args* self,
+ const CMPIBroker* cb)
+{
+ const unsigned char* sig = __LMI_RealmdKerberosRealm_Leave_Args_sig;
+ KBase_Init(&self->__base, cb, sizeof(*self), sig, NULL);
+}
+
+KINLINE CMPIStatus LMI_RealmdKerberosRealm_Leave_Args_InitFromArgs(
+ LMI_RealmdKerberosRealm_Leave_Args* self,
+ const CMPIBroker* cb,
+ const CMPIArgs* x,
+ CMPIBoolean in,
+ CMPIBoolean out)
+{
+ LMI_RealmdKerberosRealm_Leave_Args_Init(self, cb);
+ return KBase_FromArgs(&self->__base, x, in, out);
+}
+
+KINLINE CMPIArgs* LMI_RealmdKerberosRealm_Leave_Args_ToArgs(
+ const LMI_RealmdKerberosRealm_Leave_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIStatus* status)
+{
+ return KBase_ToArgs(&self->__base, in, out, status);
+}
+
+KINLINE CMPIStatus LMI_RealmdKerberosRealm_Leave_Args_SetArgs(
+ const LMI_RealmdKerberosRealm_Leave_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIArgs* ca)
+{
+ return KBase_SetToArgs(&self->__base, in, out, ca);
+}
+
+KINLINE void LMI_RealmdKerberosRealm_Leave_Args_Print(
+ const LMI_RealmdKerberosRealm_Leave_Args* self,
+ FILE* os)
+{
+ KBase_Print(os, &self->__base, 'a');
+}
+
/*
**==============================================================================
**
@@ -2832,6 +2907,20 @@ KEXTERN KUint32 LMI_RealmdKerberosRealm_Join(
const KStringA* OptionValues,
CMPIStatus* status);
+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);
+
KINLINE CMPIStatus LMI_RealmdKerberosRealm_DispatchMethod(
const CMPIBroker* cb,
CMPIMethodMI* mi,
@@ -2943,6 +3032,42 @@ KINLINE CMPIStatus LMI_RealmdKerberosRealm_DispatchMethod(
KReturn(OK);
}
+ if (strcasecmp(meth, "Leave") == 0)
+ {
+ CMPIStatus st = KSTATUS_INIT;
+ LMI_RealmdKerberosRealm_Leave_Args args;
+ KUint32 r;
+
+ KReturnIf(LMI_RealmdKerberosRealm_Leave_Args_InitFromArgs(
+ &args, cb, in, 1, 0));
+
+ r = LMI_RealmdKerberosRealm_Leave(
+ cb,
+ mi,
+ cc,
+ &self,
+ &args.Type,
+ &args.Owner,
+ &args.Name,
+ &args.Password,
+ &args.Data,
+ &args.OptionNames,
+ &args.OptionValues,
+ &st);
+
+ if (!KOkay(st))
+ return st;
+
+ if (!r.exists)
+ KReturn(ERR_FAILED);
+
+ KReturnIf(LMI_RealmdKerberosRealm_Leave_Args_SetArgs(
+ &args, 0, 1, out));
+ KReturnUint32Data(cr, &r);
+ CMReturnDone(cr);
+
+ KReturn(OK);
+ }
KReturn(ERR_METHOD_NOT_FOUND);
}
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",
diff --git a/LMI_RealmdRealmProvider.c b/LMI_RealmdRealmProvider.c
index 54915bd..30039f5 100644
--- a/LMI_RealmdRealmProvider.c
+++ b/LMI_RealmdRealmProvider.c
@@ -40,7 +40,7 @@ CMPIStatus LMI_RealmdRealm_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(realm_props, dbus_path, REALM_DBUS_REALM_INTERFACE, &status);
LMI_RealmdRealmInitKeys(LMI_RealmdRealm, self, dbus_path);
LMI_InitFromDBusRealmProps(LMI_RealmdRealm, self, realm_props);
@@ -95,7 +95,7 @@ static CMPIStatus LMI_RealmdRealmEnumInstances(
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)) {
@@ -245,12 +245,12 @@ KUint32 LMI_RealmdRealm_ChangeLoginPolicy(
GVariant *permitted_remove = 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;
}
@@ -261,21 +261,21 @@ KUint32 LMI_RealmdRealm_ChangeLoginPolicy(
}
if (!PermittedAdd->exists || PermittedAdd->null) {
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "PermittedAdd parameter absent")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "PermittedAdd parameter absent");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!PermittedRemove->exists || PermittedRemove->null) {
- CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "PermittedRemove parameter absent")
- KUint32_Set(&result, 1);
+ CMSetStatusWithChars(cb, status, CMPI_RC_ERR_INVALID_PARAMETER, "PermittedRemove 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;
}
@@ -287,14 +287,14 @@ KUint32 LMI_RealmdRealm_ChangeLoginPolicy(
if (!build_g_variant_string_array_from_KStringA(PermittedAdd, &permitted_add, &g_error)) {
handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED,
"failed to convert PermittedAdd to gvariant array");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
if (!build_g_variant_string_array_from_KStringA(PermittedRemove, &permitted_remove, &g_error)) {
handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED,
"failed to convert PermittedRemove to gvariant array");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -305,7 +305,7 @@ KUint32 LMI_RealmdRealm_ChangeLoginPolicy(
permitted_add, permitted_remove,
options, &g_error)) {
handle_g_error(&g_error, cb, status, CMPI_RC_ERR_FAILED, "dbus_change_login_policy_call() failed");
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
diff --git a/LMI_RealmdService.h b/LMI_RealmdService.h
index e0b9547..4f74d3b 100644
--- a/LMI_RealmdService.h
+++ b/LMI_RealmdService.h
@@ -322,13 +322,14 @@ typedef struct _LMI_RealmdService
const KString RealmdVersion;
const KString Locale;
const KStringA Realms;
+ const KString Domain;
}
LMI_RealmdService;
static const unsigned char __LMI_RealmdService_sig[] =
{
0x11,0x4c,0x4d,0x49,0x5f,0x52,0x65,0x61,0x6c,0x6d,0x64,0x53,0x65,0x72,0x76,
- 0x69,0x63,0x65,0x00,0x20,0x0c,0x0a,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
+ 0x69,0x63,0x65,0x00,0x21,0x0c,0x0a,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,
0x49,0x44,0x00,0x0c,0x07,0x43,0x61,0x70,0x74,0x69,0x6f,0x6e,0x00,0x0c,0x0b,
0x44,0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x00,0x0c,0x0b,0x45,
0x6c,0x65,0x6d,0x65,0x6e,0x74,0x4e,0x61,0x6d,0x65,0x00,0x0d,0x0b,0x49,0x6e,
@@ -363,7 +364,7 @@ static const unsigned char __LMI_RealmdService_sig[] =
0x0a,0x52,0x65,0x61,0x6c,0x6d,0x64,0x4e,0x61,0x6d,0x65,0x00,0x0c,0x0d,0x52,
0x65,0x61,0x6c,0x6d,0x64,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x00,0x0c,0x06,
0x4c,0x6f,0x63,0x61,0x6c,0x65,0x00,0x8c,0x06,0x52,0x65,0x61,0x6c,0x6d,0x73,
- 0x00,
+ 0x00,0x0c,0x06,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x00,
};
KINLINE void LMI_RealmdService_Init(
@@ -2492,6 +2493,48 @@ KINLINE void LMI_RealmdService_Clr_Realms(
}
}
+KINLINE void LMI_RealmdService_SetString_Domain(
+ LMI_RealmdService* self,
+ CMPIString* x)
+{
+ if (self && self->__base.magic == KMAGIC)
+ {
+ KString* field = (KString*)&self->Domain;
+ KString_SetString(field, x);
+ }
+}
+
+KINLINE void LMI_RealmdService_Set_Domain(
+ LMI_RealmdService* self,
+ const char* s)
+{
+ if (self && self->__base.magic == KMAGIC)
+ {
+ KString* field = (KString*)&self->Domain;
+ KString_Set(field, self->__base.cb, s);
+ }
+}
+
+KINLINE void LMI_RealmdService_Null_Domain(
+ LMI_RealmdService* self)
+{
+ if (self && self->__base.magic == KMAGIC)
+ {
+ KString* field = (KString*)&self->Domain;
+ KString_Null(field);
+ }
+}
+
+KINLINE void LMI_RealmdService_Clr_Domain(
+ LMI_RealmdService* self)
+{
+ if (self && self->__base.magic == KMAGIC)
+ {
+ KString* field = (KString*)&self->Domain;
+ KString_Clr(field);
+ }
+}
+
/* classname=LMI_RealmdService */
typedef struct _LMI_RealmdService_RequestStateChange_Args
{
@@ -2739,6 +2782,146 @@ KINLINE void LMI_RealmdService_Discover_Args_Print(
KBase_Print(os, &self->__base, 'a');
}
+/* classname=LMI_RealmdService */
+typedef struct _LMI_RealmdService_JoinDomain_Args
+{
+ KBase __base;
+ /* IN */
+ KString Domain;
+ /* IN */
+ KString User;
+ /* IN */
+ KString Password;
+ /* IN */
+ KStringA OptionNames;
+ /* IN */
+ KStringA OptionValues;
+}
+LMI_RealmdService_JoinDomain_Args;
+
+static const unsigned char __LMI_RealmdService_JoinDomain_Args_sig[] =
+{
+ 0x0a,0x4a,0x6f,0x69,0x6e,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x00,0x05,0x2c,0x06,
+ 0x44,0x6f,0x6d,0x61,0x69,0x6e,0x00,0x2c,0x04,0x55,0x73,0x65,0x72,0x00,0x2c,
+ 0x08,0x50,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x00,0xac,0x0b,0x4f,0x70,0x74,
+ 0x69,0x6f,0x6e,0x4e,0x61,0x6d,0x65,0x73,0x00,0xac,0x0c,0x4f,0x70,0x74,0x69,
+ 0x6f,0x6e,0x56,0x61,0x6c,0x75,0x65,0x73,0x00,
+};
+
+KINLINE void LMI_RealmdService_JoinDomain_Args_Init(
+ LMI_RealmdService_JoinDomain_Args* self,
+ const CMPIBroker* cb)
+{
+ const unsigned char* sig = __LMI_RealmdService_JoinDomain_Args_sig;
+ KBase_Init(&self->__base, cb, sizeof(*self), sig, NULL);
+}
+
+KINLINE CMPIStatus LMI_RealmdService_JoinDomain_Args_InitFromArgs(
+ LMI_RealmdService_JoinDomain_Args* self,
+ const CMPIBroker* cb,
+ const CMPIArgs* x,
+ CMPIBoolean in,
+ CMPIBoolean out)
+{
+ LMI_RealmdService_JoinDomain_Args_Init(self, cb);
+ return KBase_FromArgs(&self->__base, x, in, out);
+}
+
+KINLINE CMPIArgs* LMI_RealmdService_JoinDomain_Args_ToArgs(
+ const LMI_RealmdService_JoinDomain_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIStatus* status)
+{
+ return KBase_ToArgs(&self->__base, in, out, status);
+}
+
+KINLINE CMPIStatus LMI_RealmdService_JoinDomain_Args_SetArgs(
+ const LMI_RealmdService_JoinDomain_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIArgs* ca)
+{
+ return KBase_SetToArgs(&self->__base, in, out, ca);
+}
+
+KINLINE void LMI_RealmdService_JoinDomain_Args_Print(
+ const LMI_RealmdService_JoinDomain_Args* self,
+ FILE* os)
+{
+ KBase_Print(os, &self->__base, 'a');
+}
+
+/* classname=LMI_RealmdService */
+typedef struct _LMI_RealmdService_LeaveDomain_Args
+{
+ KBase __base;
+ /* IN */
+ KString Domain;
+ /* IN */
+ KString User;
+ /* IN */
+ KString Password;
+ /* IN */
+ KStringA OptionNames;
+ /* IN */
+ KStringA OptionValues;
+}
+LMI_RealmdService_LeaveDomain_Args;
+
+static const unsigned char __LMI_RealmdService_LeaveDomain_Args_sig[] =
+{
+ 0x0b,0x4c,0x65,0x61,0x76,0x65,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x00,0x05,0x2c,
+ 0x06,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x00,0x2c,0x04,0x55,0x73,0x65,0x72,0x00,
+ 0x2c,0x08,0x50,0x61,0x73,0x73,0x77,0x6f,0x72,0x64,0x00,0xac,0x0b,0x4f,0x70,
+ 0x74,0x69,0x6f,0x6e,0x4e,0x61,0x6d,0x65,0x73,0x00,0xac,0x0c,0x4f,0x70,0x74,
+ 0x69,0x6f,0x6e,0x56,0x61,0x6c,0x75,0x65,0x73,0x00,
+};
+
+KINLINE void LMI_RealmdService_LeaveDomain_Args_Init(
+ LMI_RealmdService_LeaveDomain_Args* self,
+ const CMPIBroker* cb)
+{
+ const unsigned char* sig = __LMI_RealmdService_LeaveDomain_Args_sig;
+ KBase_Init(&self->__base, cb, sizeof(*self), sig, NULL);
+}
+
+KINLINE CMPIStatus LMI_RealmdService_LeaveDomain_Args_InitFromArgs(
+ LMI_RealmdService_LeaveDomain_Args* self,
+ const CMPIBroker* cb,
+ const CMPIArgs* x,
+ CMPIBoolean in,
+ CMPIBoolean out)
+{
+ LMI_RealmdService_LeaveDomain_Args_Init(self, cb);
+ return KBase_FromArgs(&self->__base, x, in, out);
+}
+
+KINLINE CMPIArgs* LMI_RealmdService_LeaveDomain_Args_ToArgs(
+ const LMI_RealmdService_LeaveDomain_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIStatus* status)
+{
+ return KBase_ToArgs(&self->__base, in, out, status);
+}
+
+KINLINE CMPIStatus LMI_RealmdService_LeaveDomain_Args_SetArgs(
+ const LMI_RealmdService_LeaveDomain_Args* self,
+ CMPIBoolean in,
+ CMPIBoolean out,
+ CMPIArgs* ca)
+{
+ return KBase_SetToArgs(&self->__base, in, out, ca);
+}
+
+KINLINE void LMI_RealmdService_LeaveDomain_Args_Print(
+ const LMI_RealmdService_LeaveDomain_Args* self,
+ FILE* os)
+{
+ KBase_Print(os, &self->__base, 'a');
+}
+
/*
**==============================================================================
**
@@ -2782,6 +2965,30 @@ KEXTERN KUint32 LMI_RealmdService_Discover(
KRefA* DiscoveredRealms,
CMPIStatus* status);
+KEXTERN KUint32 LMI_RealmdService_JoinDomain(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdServiceRef* self,
+ const KString* Domain,
+ const KString* User,
+ const KString* Password,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status);
+
+KEXTERN KUint32 LMI_RealmdService_LeaveDomain(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdServiceRef* self,
+ const KString* Domain,
+ const KString* User,
+ const KString* Password,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status);
+
KINLINE CMPIStatus LMI_RealmdService_DispatchMethod(
const CMPIBroker* cb,
CMPIMethodMI* mi,
@@ -2919,6 +3126,74 @@ KINLINE CMPIStatus LMI_RealmdService_DispatchMethod(
KReturn(OK);
}
+ if (strcasecmp(meth, "JoinDomain") == 0)
+ {
+ CMPIStatus st = KSTATUS_INIT;
+ LMI_RealmdService_JoinDomain_Args args;
+ KUint32 r;
+
+ KReturnIf(LMI_RealmdService_JoinDomain_Args_InitFromArgs(
+ &args, cb, in, 1, 0));
+
+ r = LMI_RealmdService_JoinDomain(
+ cb,
+ mi,
+ cc,
+ &self,
+ &args.Domain,
+ &args.User,
+ &args.Password,
+ &args.OptionNames,
+ &args.OptionValues,
+ &st);
+
+ if (!KOkay(st))
+ return st;
+
+ if (!r.exists)
+ KReturn(ERR_FAILED);
+
+ KReturnIf(LMI_RealmdService_JoinDomain_Args_SetArgs(
+ &args, 0, 1, out));
+ KReturnUint32Data(cr, &r);
+ CMReturnDone(cr);
+
+ KReturn(OK);
+ }
+ if (strcasecmp(meth, "LeaveDomain") == 0)
+ {
+ CMPIStatus st = KSTATUS_INIT;
+ LMI_RealmdService_LeaveDomain_Args args;
+ KUint32 r;
+
+ KReturnIf(LMI_RealmdService_LeaveDomain_Args_InitFromArgs(
+ &args, cb, in, 1, 0));
+
+ r = LMI_RealmdService_LeaveDomain(
+ cb,
+ mi,
+ cc,
+ &self,
+ &args.Domain,
+ &args.User,
+ &args.Password,
+ &args.OptionNames,
+ &args.OptionValues,
+ &st);
+
+ if (!KOkay(st))
+ return st;
+
+ if (!r.exists)
+ KReturn(ERR_FAILED);
+
+ KReturnIf(LMI_RealmdService_LeaveDomain_Args_SetArgs(
+ &args, 0, 1, out));
+ KReturnUint32Data(cr, &r);
+ CMReturnDone(cr);
+
+ KReturn(OK);
+ }
KReturn(ERR_METHOD_NOT_FOUND);
}
diff --git a/LMI_RealmdServiceProvider.c b/LMI_RealmdServiceProvider.c
index 8a3c7c4..ba1a6d5 100644
--- a/LMI_RealmdServiceProvider.c
+++ b/LMI_RealmdServiceProvider.c
@@ -58,7 +58,7 @@ static CMPIStatus LMI_RealmdServiceEnumInstances(
LMI_InitRealmdServiceKeys(LMI_RealmdService, &lmi_realmd_service, name_space, host_name);
- 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);
n_items = g_variant_iter_n_children(iter);
@@ -233,39 +233,39 @@ KUint32 LMI_RealmdService_Discover(
gint32 relevance = 0;
gchar **paths = NULL;
gchar *path, **pp;
- CMPICount i, n_items;
+ CMPICount i, n_paths;
- 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 (!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_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, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
#ifdef RDCP_DEBUG
- print_paths(paths, "LMI_Realm_Discover: target=%s, paths:", Target->chars);
+ print_paths(paths, "%s: target=%s, paths:", __FUNCTION__, Target->chars);
#endif
- for (pp = paths, path = *pp++, n_items = 0; path; path = *pp++, n_items++);
+ for (pp = paths, path = *pp++, n_paths = 0; path; path = *pp++, n_paths++);
- if (!KRefA_Init(DiscoveredRealms, cb, n_items)) {
- KUint32_Set(&result, 1);
+ if (!KRefA_Init(DiscoveredRealms, cb, n_paths)) {
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -277,7 +277,7 @@ KUint32 LMI_RealmdService_Discover(
*status = LMI_RealmdRealmRef_InitFromDBusPath(&realmdrealm_ref, cb,
LMI_RealmdServiceRef_NameSpace((LMI_RealmdServiceRef*)self), path);
if (status->rc != CMPI_RC_OK) {
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
@@ -285,7 +285,7 @@ KUint32 LMI_RealmdService_Discover(
goto exit;
}
if (!KRefA_Set(DiscoveredRealms, i, realmdrealm_op)) {
- KUint32_Set(&result, 1);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
goto exit;
}
}
@@ -295,13 +295,275 @@ KUint32 LMI_RealmdService_Discover(
if (options) {
g_variant_unref(options);
}
+ if (paths) {
+ g_strfreev(paths);
+ }
+
+ return result;
+}
+
+// FIXME
+static gboolean
+get_credential_supported_owner(GVariant *supported, const gchar *cred_type, const gchar **cred_owner_return)
+{
+ GVariantIter iter;
+ const gchar *type;
+ const gchar *owner;
+
+ g_variant_iter_init (&iter, supported);
+ while (g_variant_iter_loop (&iter, "(&s&s)", &type, &owner)) {
+ if (g_str_equal (cred_type, type)) {
+ *cred_owner_return = owner;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+is_credential_supported (GVariant *supported, const gchar *cred_type, const gchar *cred_owner)
+{
+ GVariantIter iter;
+ const gchar *type;
+ const gchar *owner;
+
+ g_variant_iter_init(&iter, supported);
+ while (g_variant_iter_loop (&iter, "(&s&s)", &type, &owner)) {
+ if (g_str_equal(cred_type, type) &&
+ g_str_equal(cred_owner, owner)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+KUint32 LMI_RealmdService_Join_Leave_Domain(
+ bool join,
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdServiceRef* self,
+ const KString* Domain,
+ const KString* User,
+ const KString* Password,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status)
+{
+ const gchar *method_name = NULL;
+ const gchar *supported_credentials_property = NULL;
+ GError *g_error = NULL;
+ KUint32 result = KUINT32_INIT;
+ gint32 relevance = 0;
+ gchar **paths = NULL;
+ gchar *dbus_path, **pp;
+ CMPICount n_paths;
+ const gchar *cred_type = NULL;
+ const gchar *cred_owner = NULL;
+ GVariant *supported_creds = NULL;
+ GVariant *realm_props = NULL;
+ GVariant *kerberos_membership_props = NULL;
+ GVariant *credentials = NULL;
+ GVariant *options = NULL;
+
+ KUint32_Set(&result, LMI_REALMD_RESULT_SUCCESS);
+ CMSetStatus(status, CMPI_RC_OK);
+
+ /* Assure we can communicate with DBus */
+ 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 (join) {
+ method_name = "Join";
+ supported_credentials_property = "SupportedJoinCredentials";
+ } else {
+ method_name = "Leave";
+ supported_credentials_property = "SupportedLeaveCredentials";
+ }
+
+ /* Call Discover to obtain list of DBus object paths for domain */
+ 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, Domain->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__, Domain->chars);
+#endif
+ for (pp = paths, dbus_path = *pp++, n_paths = 0; dbus_path; dbus_path = *pp++, n_paths++);
+
+ if (n_paths < 1) {
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED, "Domain (%s) does not exist", Domain->chars);
+ KUint32_Set(&result, LMI_REALMD_RESULT_NO_SUCH_DOMAIN);
+ goto exit;
+ }
+
+ dbus_path = paths[0];
+
+ /* Lookup the realm properties so we can determine the supported DBus interfaces */
+ GetDBusProperies(realm_props, dbus_path, REALM_DBUS_REALM_INTERFACE, status);
+ if (!SupportsDBusInterface(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);
+ goto exit;
+ }
+
+ GetDBusProperies(kerberos_membership_props, dbus_path,
+ REALM_DBUS_KERBEROS_MEMBERSHIP_INTERFACE, status);
+
+ if (!g_variant_lookup(kerberos_membership_props, supported_credentials_property, "@a(ss)",
+ &supported_creds)) {
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED,
+ "Domain (%s) did not supply supported %s credentials",
+ Domain->chars, method_name);
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+
+ if (!User->exists || User->null) {
+ /* No User */
+ if (!Password->exists || Password->null) {
+ /* No User, No Password: automatic */
+ cred_type = "automatic";
+ if (!get_credential_supported_owner(supported_creds, cred_type, &cred_owner)) {
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED,
+ "Domain (%s) does not support automatic %s credentials",
+ Domain->chars, method_name);
+ KUint32_Set(&result, LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_PROVIDED_CREDENTIALS);
+ goto exit;
+ }
+
+ credentials = g_variant_new ("(ssv)", cred_type, cred_owner,
+ g_variant_new_string (""));
+
+ } else {
+ /* No User, Password: one time password using secret */
+ cred_type = "secret";
+ if (!get_credential_supported_owner(supported_creds, cred_type, &cred_owner)) {
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED,
+ "Domain (%s) does not support secret %s credentials",
+ Domain->chars, method_name);
+ KUint32_Set(&result, LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_PROVIDED_CREDENTIALS);
+ goto exit;
+ }
+ credentials = g_variant_new("(ssv)", cred_type, cred_owner,
+ g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
+ Password->chars,
+ strlen(Password->chars), 1));
+ }
+ } else {
+ /* User */
+ if (!Password->exists || Password->null) {
+ /* User, No Password: invalid combination */
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_INVALID_PARAMETER,
+ "Must provide a password when User is provided");
+ KUint32_Set(&result, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ } else {
+ /* User, Password: password auth */
+ cred_type = "password";
+ cred_owner = "administrator";
+ if (!is_credential_supported(supported_creds, cred_type, cred_owner)) {
+ SetCMPIStatus(cb, status, CMPI_RC_ERR_FAILED,
+ "Domain (%s) does not support password with administrator ownership credentials",
+ Domain->chars);
+ KUint32_Set(&result, LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_PROVIDED_CREDENTIALS);
+ goto exit;
+ }
+ credentials = g_variant_new("(ssv)", cred_type, cred_owner,
+ g_variant_new("(ss)", User->chars, Password->chars));
+
+ }
+ }
+
+ if (join) {
+ 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, LMI_REALMD_RESULT_FAILED);
+ goto exit;
+ }
+ } else {
+ 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 (realm_props) {
+ g_variant_unref(realm_props);
+ }
+
+ if (kerberos_membership_props) {
+ g_variant_unref(kerberos_membership_props);
+ }
+
+ if (options) {
+ g_variant_unref(options);
+ }
if (paths) {
g_strfreev(paths);
}
+ if (credentials) {
+ g_variant_unref(credentials);
+ }
return result;
}
+KEXTERN KUint32 LMI_RealmdService_JoinDomain(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdServiceRef* self,
+ const KString* Domain,
+ const KString* User,
+ const KString* Password,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status)
+{
+ return LMI_RealmdService_Join_Leave_Domain(true, cb, mi, context, self,
+ Domain, User, Password,
+ OptionNames, OptionValues,
+ status);
+}
+
+KEXTERN KUint32 LMI_RealmdService_LeaveDomain(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_RealmdServiceRef* self,
+ const KString* Domain,
+ const KString* User,
+ const KString* Password,
+ const KStringA* OptionNames,
+ const KStringA* OptionValues,
+ CMPIStatus* status)
+{
+ return LMI_RealmdService_Join_Leave_Domain(false, cb, mi, context, self,
+ Domain, User, Password,
+ OptionNames, OptionValues,
+ status);
+}
KONKRET_REGISTRATION(
"root/cimv2",
diff --git a/LMI_ServiceAffectsRealmdRealmProvider.c b/LMI_ServiceAffectsRealmdRealmProvider.c
index 6cddbd7..58785b7 100644
--- a/LMI_ServiceAffectsRealmdRealmProvider.c
+++ b/LMI_ServiceAffectsRealmdRealmProvider.c
@@ -56,7 +56,7 @@ static CMPIStatus LMI_ServiceAffectsRealmdRealmEnumInstances(
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)) {
diff --git a/mof/LMI_Realmd.mof b/mof/LMI_Realmd.mof
index 8a86aa3..8f2e77b 100644
--- a/mof/LMI_Realmd.mof
+++ b/mof/LMI_Realmd.mof
@@ -67,6 +67,67 @@ class LMI_RealmdService : CIM_Service
[In ( false ), Out, Description (
"Array of references to discovered realms")]
LMI_RealmdRealm REF DiscoveredRealms[]);
+
+ // FIXME - proof of concept simplfied API starts here
+
+ [Description (
+ "The name of the domain that this computer is a member of "
+ "or NULL if not a member of any domain.")]
+ string Domain;
+
+ [Description (
+ "Join the computer to a domain.")]
+ uint32 JoinDomain(
+ [In, Description (
+ "The name of the domain to join.")]
+ string Domain,
+ [In, Description (
+ "The administrative user who is authorizing joining the domain. "
+ "Or NULL for a one time password based join.")]
+ string User,
+ [In, Description (
+ "Either NULL for an automatic join, a one time password, or the "
+ "password for the administrative user in the User parameter.")]
+ string Password,
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionValues array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionNames[],
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionNames array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionValues[]);
+
+ [Description (
+ "Make the computer leave its joined domain.")]
+ uint32 LeaveDomain(
+ [In, Description (
+ "The name of the domain to join.")]
+ string Domain,
+ [In, Description (
+ "The administrative user who is authorizing joining the domain. "
+ "Or NULL for a one time password based join.")]
+ string User,
+ [In, Description (
+ "Either NULL for an automatic join, a one time password, or the "
+ "password for the administrative user in the User parameter.")]
+ string Password,
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionValues array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionNames[],
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionNames array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionValues[]);
};
[ Description (
@@ -385,6 +446,45 @@ class LMI_RealmdKerberosRealm : LMI_RealmdRealm
"located at the same index. In this way a (name,value) tuple "
"can be constructed.")]
string OptionValues[]);
+
+ [Description (
+ "")]
+ uint32 Leave(
+ [In, Description (
+ "Credential type, see LMI_RealmdKerberosRealm description"),
+ ValueMap { "1", "2", "3", "4"},
+ Values { "ccache", "password", "secrect", "automatic" }]
+ uint32 Type,
+ [In, Description (
+ "Credential owner, see LMI_RealmdKerberosRealm description"),
+ ValueMap { "1", "2", "3", "4"},
+ Values { "administrator", "user", "computer", "none" }]
+ uint32 Owner,
+ [In, Description (
+ "The name may contain a realm in the standard kerberos format. "
+ "If a realm is missing, it will default to this realm. "
+ "Used when the Type is password.")]
+ string Name,
+ [In, Description (
+ "Authentication password. "
+ "Used when the Type is password.")]
+ string Password,
+ [In, Description (
+ "Binary data when the Type is ccache or secret"),
+ OctetString]
+ uint8 Data[],
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionValues array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionNames[],
+ [In, ArrayType ( "Indexed" ), Description (
+ "This array is correlated with the OptionNames array. "
+ "Each entry is related to the entries in the other array "
+ "located at the same index. In this way a (name,value) tuple "
+ "can be constructed.")]
+ string OptionValues[]);
};
[ Association,
diff --git a/rdcp_dbus.c b/rdcp_dbus.c
index 316af4a..c1cc93c 100644
--- a/rdcp_dbus.c
+++ b/rdcp_dbus.c
@@ -1771,9 +1771,9 @@ dbus_change_login_policy_call(DBusConnection *bus, const gchar *dbus_path, const
/*----------------------------------------------------------------------------*/
/**
- * dbus_join_marshal:
+ * dbus_join_leave_marshal:
* @dbus_path The DBus object path of the object supporting the kerberos
- * membership interface on which the Join call will be made.
+ * membership interface on which the Join/Leave call will be made.
* @credentials A GVariant encoding the credentials according the the credential
* type. See the Realmd DBus interface for specifics.
* @options dictionary of option {key,values}
@@ -1781,20 +1781,21 @@ dbus_change_login_policy_call(DBusConnection *bus, const gchar *dbus_path, const
* if error then this will be NULL.
* @g_error initialized to error info when FALSE is returned.
*
- * Marshal a realm Join method call.
+ * Since the Join() & Leave() methods share identical signatures (differing
+ * only in their method name) we use a common routine.
*
* Returns: return TRUE if successful, @msg_return will point to DBusMessage,
* FALSE if error with @g_error initialized. @msg_return will be NULL.
*/
static gboolean
-dbus_join_marshal(const gchar* dbus_path,
+dbus_join_leave_marshal(const char *method, const gchar* dbus_path,
GVariant *credentials, GVariant *options,
DBusMessage **msg_return, GError **g_error)
{
- const char *method = "Join";
DBusMessage *msg = NULL;
DBusMessageIter iter;
+ g_return_val_if_fail (method != NULL, FALSE);
g_return_val_if_fail (dbus_path != NULL, FALSE);
g_return_val_if_fail (credentials != NULL, FALSE);
g_return_val_if_fail (options != NULL, FALSE);
@@ -1832,17 +1833,20 @@ dbus_join_marshal(const gchar* dbus_path,
}
/**
- * dbus_join_unmarshal:
- * @reply DBus method reply from Join call
+ * dbus_join_leave_unmarshal:
+ * @reply DBus method reply from Join/Leave call
* @g_error initialized to error info when FALSE is returned.
*
- * Parses the DBus reply message from the Join call.
+ * Since the Join() & Leave() methods share identical signatures (differing
+ * only in their method name) we use a common routine.
+ *
+ * Parses the DBus reply message from the Join/Leave call.
*
* Returns: return TRUE if successful, FALSE if error with @g_error initialized.
*/
static gboolean
-dbus_join_unmarshal(DBusMessage *reply, GError **g_error)
+dbus_join_leave_unmarshal(DBusMessage *reply, GError **g_error)
{
g_return_val_if_fail (reply != NULL, FALSE);
@@ -1852,27 +1856,31 @@ dbus_join_unmarshal(DBusMessage *reply, GError **g_error)
}
/**
- * dbus_join_call:
+ * dbus_join_leave_call:
* @dbus_path The DBus object path of the object supporting the kerberos
- * membership interface on which the Join call will be made.
+ * membership interface on which the Join/Leave call will be made.
* @credentials A GVariant encoding the credentials according the the credential
* type. See the Realmd DBus interface for specifics.
* @options dictionary of option {key,values}
* @g_error initialized to error info when FALSE is returned.
*
- * Marshal a realm Join method call, call it synchronously,
+ * Since the Join() & Leave() methods share identical signatures (differing
+ * only in their method name) we use a common routine.
+ *
+ * Marshal a realm Join/Leave method call, call it synchronously,
* unmarsh it's reply and return the OUT parameters.
*
* Returns: return TRUE if successful, FALSE if error with @g_error initialized
*/
gboolean
-dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
- GVariant *credentials, GVariant *options, GError **g_error)
+dbus_join_leave_call(const char *method, DBusConnection *bus, const gchar *dbus_path,
+ GVariant *credentials, GVariant *options, GError **g_error)
{
DBusError dbus_error;
DBusMessage *msg = NULL;
DBusMessage* reply = NULL;
+ g_return_val_if_fail (method != NULL, FALSE);
g_return_val_if_fail (bus != NULL, FALSE);
g_return_val_if_fail (dbus_path != NULL, FALSE);
g_return_val_if_fail (credentials != NULL, FALSE);
@@ -1880,7 +1888,7 @@ dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
g_return_val_if_fail (g_error == NULL || *g_error == NULL, FALSE);
dbus_error_init(&dbus_error);
- if (!dbus_join_marshal(dbus_path, credentials, options, &msg, g_error)) {
+ if (!dbus_join_leave_marshal(method, dbus_path, credentials, options, &msg, g_error)) {
RETURN_DBUS_ERROR(g_error, dbus_error);
}
@@ -1890,7 +1898,7 @@ dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
}
dbus_message_unref(msg);
- if (!dbus_join_unmarshal(reply, g_error)) {
+ if (!dbus_join_leave_unmarshal(reply, g_error)) {
dbus_message_unref(reply);
return FALSE;
}
@@ -1902,6 +1910,58 @@ dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
/*----------------------------------------------------------------------------*/
/**
+ * dbus_join_call:
+ * @dbus_path The DBus object path of the object supporting the kerberos
+ * membership interface on which the Join call will be made.
+ * @credentials A GVariant encoding the credentials according the the credential
+ * type. See the Realmd DBus interface for specifics.
+ * @options dictionary of option {key,values}
+ * @g_error initialized to error info when FALSE is returned.
+ *
+ * Marshal a realm Join method call, call it synchronously,
+ * unmarsh it's reply and return the OUT parameters.
+ *
+ * Returns: return TRUE if successful, FALSE if error with @g_error initialized
+ */
+gboolean
+dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
+ GVariant *credentials, GVariant *options, GError **g_error)
+{
+
+ return dbus_join_leave_call("Join", bus, dbus_path, credentials,
+ options, g_error);
+
+}
+
+
+/**
+ * dbus_leave_call:
+ * @dbus_path The DBus object path of the object supporting the kerberos
+ * membership interface on which the Leave call will be made.
+ * @credentials A GVariant encoding the credentials according the the credential
+ * type. See the Realmd DBus interface for specifics.
+ * @options dictionary of option {key,values}
+ * @g_error initialized to error info when FALSE is returned.
+ *
+ * Marshal a realm Leave method call, call it synchronously,
+ * unmarsh it's reply and return the OUT parameters.
+ *
+ * Returns: return TRUE if successful, FALSE if error with @g_error initialized
+ */
+gboolean
+dbus_leave_call(DBusConnection *bus, const gchar *dbus_path,
+ GVariant *credentials, GVariant *options, GError **g_error)
+{
+
+ return dbus_join_leave_call("Leave", bus, dbus_path, credentials,
+ options, g_error);
+
+}
+
+
+/*----------------------------------------------------------------------------*/
+
+/**
* rdcp_dbus_initialize:
* @g_error initialized to error info when FALSE is returned.
*
diff --git a/rdcp_dbus.h b/rdcp_dbus.h
index 54c9a63..21c9086 100644
--- a/rdcp_dbus.h
+++ b/rdcp_dbus.h
@@ -36,6 +36,10 @@ dbus_join_call(DBusConnection *bus, const gchar *dbus_path,
GVariant *credentials, GVariant *options, GError **g_error);
gboolean
+dbus_leave_call(DBusConnection *bus, const gchar *dbus_path,
+ GVariant *credentials, GVariant *options, GError **g_error);
+
+gboolean
rdcp_dbus_initialize(GError **g_error);
#ifdef RDCP_DEBUG
@@ -46,10 +50,10 @@ rdcp_dbus_initialize(GError **g_error);
#define PrintDBusProperties(dbus_properties, dbus_path, dbus_interface)
#endif
-#define GetDBusProperies(dbus_props, dbus_path, dbus_interface) \
+#define GetDBusProperies(dbus_props, dbus_path, dbus_interface, status) \
{ \
if (!get_dbus_properties(system_bus, dbus_path, dbus_interface, &dbus_props, &g_error)) { \
- handle_g_error(&g_error, _cb, &status, CMPI_RC_ERR_FAILED, \
+ handle_g_error(&g_error, _cb, status, CMPI_RC_ERR_FAILED, \
"get_dbus_properties failed, path=%s interface=%s", \
dbus_path, dbus_interface); \
goto exit; \
diff --git a/rdcp_error.c b/rdcp_error.c
index 623f0f7..f688eaf 100644
--- a/rdcp_error.c
+++ b/rdcp_error.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include "rdcp_util.h"
#include "rdcp_error.h"
GQuark
@@ -18,11 +19,104 @@ rdcp_error_code_to_string(rdcp_error_codes ec)
static char buf[80];
switch(ec) {
- case RDCP_ERROR_INTERNAL: return "RDCP_ERROR_INTERNAL";
- case RDCP_ERROR_INVALID_ARG: return "RDCP_ERROR_INVALID_ARG";
- case RDCP_ERROR_DBUS: return "RDCP_ERROR_DBUS";
+ case RDCP_ERROR_INTERNAL: return "RDCP_ERROR_INTERNAL";
+ case RDCP_ERROR_INVALID_ARG: return "RDCP_ERROR_INVALID_ARG";
+ case RDCP_ERROR_INVALID_INSTANCE_ID: return "RDCP_ERROR_INVALID_INSTANCE_ID";
+ case RDCP_ERROR_DBUS: return "RDCP_ERROR_DBUS";
default:
snprintf(buf, sizeof(buf), "unknown error code (%d)", ec);
return buf;
}
}
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * handle_g_error:
+ * @g_error pointer to non-NULL GError pointer describing problem
+ * @mb CMPI message broker
+ * @st CMPI status result
+ * @rc CMPI return code
+ * @format printf-style format string, may be #NULL if no additional
+ * message is desired.
+ *
+ * Sets @st status to the @rc return code and an optional printf
+ * styles formatted message which is prepended to the error message
+ * contained in the g_error. It frees the g_error.
+ *
+ * Returns: the @st status passed in.
+ */
+CMPIStatus
+handle_g_error(GError **g_error, const CMPIBroker* mb, CMPIStatus* st, CMPIrc rc,
+ const gchar *format, ...)
+{
+ CMPIStatus failsafe_status;
+ GString *message;
+ va_list va;
+
+ CMSetStatus(&failsafe_status, CMPI_RC_ERR_FAILED);
+ g_return_val_if_fail (g_error != NULL && *g_error != NULL, failsafe_status);
+ g_return_val_if_fail (st != NULL, failsafe_status);
+
+ message = g_string_sized_new(DEFAULT_STATUS_MSG_SIZE);
+ g_string_append_printf(message, "%s: ", ORGID);
+
+ if (format) {
+ va_start(va, format);
+ g_string_append_vprintf(message, format, va);
+ va_end(va);
+ g_string_append(message, ": ");
+ }
+
+ g_string_append_printf(message, "(%s) ", rdcp_error_code_to_string((*g_error)->code));
+ g_string_append(message, (*g_error)->message);
+ g_error_free(*g_error);
+ *g_error = NULL;
+
+ CMSetStatusWithChars(mb, st, rc, message->str);
+ g_string_free(message, TRUE);
+
+ return *st;
+}
+
+
+/**
+ * SetCMPIStatus:
+ * @mb CMPI message broker
+ * @st CMPI status result
+ * @rc CMPI return code
+ * @format printf-style format string, may be #NULL if no additional
+ * message is desired.
+ *
+ * Sets @st status to the @rc return code and an optional printf
+ * style formatted message.
+ *
+ * Returns: the @st status passed in.
+ */
+CMPIStatus
+SetCMPIStatus(const CMPIBroker* mb, CMPIStatus* st, CMPIrc rc,
+ const gchar *format, ...)
+{
+ CMPIStatus failsafe_status;
+ GString *message = NULL;
+ va_list va;
+
+ CMSetStatus(&failsafe_status, CMPI_RC_ERR_FAILED);
+ g_return_val_if_fail (st != NULL, failsafe_status);
+
+ if (format) {
+ message = g_string_sized_new(DEFAULT_STATUS_MSG_SIZE);
+ g_string_append_printf(message, "%s: ", ORGID);
+
+ va_start(va, format);
+ g_string_append_vprintf(message, format, va);
+ va_end(va);
+
+ CMSetStatusWithChars(mb, st, rc, message->str);
+ g_string_free(message, TRUE);
+ } else {
+ CMSetStatus(st, rc);
+ }
+
+ return *st;
+}
diff --git a/rdcp_error.h b/rdcp_error.h
index 5bb0721..ff60d5b 100644
--- a/rdcp_error.h
+++ b/rdcp_error.h
@@ -17,4 +17,22 @@ typedef enum {
const char *
rdcp_error_code_to_string(rdcp_error_codes ec);
+#define LMI_REALMD_RESULT_SUCCESS 0
+#define LMI_REALMD_RESULT_FAILED 1
+#define LMI_REALMD_RESULT_NO_SUCH_DOMAIN 2
+#define LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_PROVIDED_CREDENTIALS 3
+#define LMI_REALMD_RESULT_DOMAIN_DOES_NOT_SUPPORT_JOINING 4
+
+#define DEFAULT_STATUS_MSG_SIZE 128
+
+CMPIStatus
+handle_g_error(GError **g_error, const CMPIBroker* cb, CMPIStatus* status, CMPIrc rc,
+ const gchar *format, ...)
+ __attribute__ ((format (printf, 5, 6)));
+
+CMPIStatus
+SetCMPIStatus(const CMPIBroker* mb, CMPIStatus* st, CMPIrc rc,
+ const gchar *format, ...)
+ __attribute__ ((format (printf, 4, 5)));
+
#endif /* __RDCP_ERROR_H__ */
diff --git a/rdcp_util.c b/rdcp_util.c
index 53696e1..5f745e6 100644
--- a/rdcp_util.c
+++ b/rdcp_util.c
@@ -79,59 +79,6 @@ print_paths(gchar **paths, gchar *format, ...) {
}
}
-/*----------------------------------------------------------------------------*/
-
-/**
- * handle_g_error:
- * @g_error pointer to non-NULL GError pointer describing problem
- * @mb CMPI message broker
- * @st CMPI status result
- * @rc CMPI return code
- * @format printf-style format string, may be #NULL if no additional
- * message is desired.
- *
- * Sets @st status to the @rc return code and an optional printf
- * styles formatted message which is prepended to the error message
- * contained in the g_error. It frees the g_error.
- *
- * Returns: the @st status passed in.
- */
-CMPIStatus
-handle_g_error(GError **g_error, const CMPIBroker* mb, CMPIStatus* st, CMPIrc rc,
- const gchar *format, ...)
-{
- CMPIStatus failsafe_status;
- GString *message;
- va_list va;
-
- CMSetStatus (&failsafe_status, CMPI_RC_ERR_FAILED);
- g_return_val_if_fail (g_error != NULL && *g_error != NULL, failsafe_status);
- g_return_val_if_fail (st != NULL, failsafe_status);
-
- message = g_string_new("");
- g_string_append_printf(message, "%s: ", ORGID);
-
- if (format) {
- va_start(va, format);
- g_string_append_vprintf(message, format, va);
- va_end(va);
- }
-
- if (format) {
- g_string_append(message, ": ");
- }
- g_string_append_printf(message, "(%s) ", rdcp_error_code_to_string((*g_error)->code));
- g_string_append(message, (*g_error)->message);
- g_error_free(*g_error);
- *g_error = NULL;
-
- CMSetStatusWithChars(mb, st, rc, message->str);
-
- g_printerr("%s\n", message->str);
- g_string_free(message, TRUE);
-
- return *st;
-}
diff --git a/rdcp_util.h b/rdcp_util.h
index 9a8e565..eb7e533 100644
--- a/rdcp_util.h
+++ b/rdcp_util.h
@@ -80,11 +80,6 @@ void
print_paths(gchar **paths, gchar *format, ...)
__attribute__ ((format (printf, 2, 3)));
-CMPIStatus
-handle_g_error(GError **g_error, const CMPIBroker* cb, CMPIStatus* status, CMPIrc rc,
- const gchar *format, ...)
- __attribute__ ((format (printf, 5, 6)));
-
gboolean
build_g_variant_options_from_KStringA(const KStringA *keys, const KStringA *values,
GVariant **g_variant_return, GError **g_error);