summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2012-09-20 12:26:23 +0200
committerRoman Rakus <rrakus@redhat.com>2012-09-20 12:26:23 +0200
commitedf5473aa4f54a5698a0f1f2d80532444df27092 (patch)
treecdb8cede9ce7f67d5032e3ae5b3c4d9e6eab8138 /src
parent9c10f3bbe51fdd7f72e1ae7f89a3574a5e91c796 (diff)
downloadopenlmi-providers-edf5473aa4f54a5698a0f1f2d80532444df27092.tar.gz
openlmi-providers-edf5473aa4f54a5698a0f1f2d80532444df27092.tar.xz
openlmi-providers-edf5473aa4f54a5698a0f1f2d80532444df27092.zip
account: delete instance on LMI_Account
Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/account/LMI_AccountProvider.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c
index 0b10c44..79f138b 100644
--- a/src/account/LMI_AccountProvider.c
+++ b/src/account/LMI_AccountProvider.c
@@ -173,7 +173,46 @@ static CMPIStatus LMI_AccountDeleteInstance(
const CMPIResult* cr,
const CMPIObjectPath* cop)
{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+ LMI_Account acc;
+ const char* username = NULL;
+ char errmsg[256];
+ struct lu_context *luc = NULL;
+ struct lu_error *error = NULL;
+ struct lu_ent *lue = NULL;
+
+ LMI_Account_InitFromObjectPath(&acc, _cb, cop);
+ username = acc.Name.chars;
+
+ luc = lu_start(NULL, 0, NULL, NULL, lu_prompt_console_quiet, NULL, &error);
+ if (!luc)
+ {
+ fprintf(stderr, "Error initializing: %s\n", lu_strerror(error));
+ exit(1);
+ }
+
+ lue = lu_ent_new();
+
+ if (!lu_user_lookup_name(luc, username, lue, &error))
+ {
+ snprintf(errmsg, 256, "Non existing user: %s\n", username);
+ lu_ent_free(lue);
+ lu_end(luc);
+ CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, errmsg);
+ }
+
+ if (!lu_user_delete(luc, lue, &error))
+ {
+ snprintf(errmsg, 256, "User %s could not be deleted: %s\n", username,
+ lu_strerror(error));
+ lu_ent_free(lue);
+ lu_end(luc);
+ CMReturnWithChars(_cb, CMPI_RC_ERR_FAILED, errmsg);
+ }
+
+ lu_ent_free(lue);
+ lu_end(luc);
+
+ CMReturn(CMPI_RC_OK);
}
static CMPIStatus LMI_AccountExecQuery(