summaryrefslogtreecommitdiffstats
path: root/src/account
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2013-09-20 17:25:38 +0200
committerRoman Rakus <rrakus@redhat.com>2013-09-20 17:25:38 +0200
commit3370cfe4beb83a31c0fd5f6e5ac6d8b1c3be9fd5 (patch)
tree683f495063135152a4e6ed99a00184eeec0e7f89 /src/account
parentdac5442bb5a5b7828ac36206d6c51b305576bc35 (diff)
downloadopenlmi-providers-3370cfe4beb83a31c0fd5f6e5ac6d8b1c3be9fd5.tar.gz
openlmi-providers-3370cfe4beb83a31c0fd5f6e5ac6d8b1c3be9fd5.tar.xz
openlmi-providers-3370cfe4beb83a31c0fd5f6e5ac6d8b1c3be9fd5.zip
account: Allow to set plain text password
libuser has a mechanism to encrypt password Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src/account')
-rw-r--r--src/account/LMI_AccountManagementServiceProvider.c9
-rw-r--r--src/account/LMI_AccountProvider.c57
2 files changed, 65 insertions, 1 deletions
diff --git a/src/account/LMI_AccountManagementServiceProvider.c b/src/account/LMI_AccountManagementServiceProvider.c
index 1a166d7..3aac63d 100644
--- a/src/account/LMI_AccountManagementServiceProvider.c
+++ b/src/account/LMI_AccountManagementServiceProvider.c
@@ -352,6 +352,7 @@ KUint32 LMI_AccountManagementService_CreateAccount(
const KBoolean* SystemAccount,
const KString* Password,
const KBoolean* DontCreateGroup,
+ const KBoolean* PasswordIsPlain,
KRef* Account,
KRefA* Identities,
CMPIStatus* status)
@@ -515,7 +516,13 @@ KUint32 LMI_AccountManagementService_CreateAccount(
/* Setup password */
if (Password->exists && !Password->null)
{
- if (!lu_user_setpass(luc, lue, Password->chars, TRUE, &error))
+ bool isplain = TRUE;
+ if (PasswordIsPlain->exists && !PasswordIsPlain->null &&
+ PasswordIsPlain->value)
+ {
+ isplain = FALSE;
+ }
+ if (!lu_user_setpass(luc, lue, Password->chars, isplain, &error))
{
FAIL("Error setting password: %s\n", lu_strerror(error),
OK, RET_ACC_PWD);
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c
index 52bc1cf..d8e279a 100644
--- a/src/account/LMI_AccountProvider.c
+++ b/src/account/LMI_AccountProvider.c
@@ -52,6 +52,9 @@
#define CANNOT_DELETE_HOME 4097
#define CANNOT_DELETE_USER 4098
#define CANNOT_DELETE_GROUP 4099
+// Change password
+#define CHANGE_PASSWORD_OK 0
+#define CHANGE_PASSWORD_FAIL 1
static const CMPIBroker* _cb = NULL;
@@ -690,6 +693,60 @@ KUint32 LMI_Account_RequestStateChange(
return result;
}
+KUint32 LMI_Account_ChangePassword(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const LMI_AccountRef* self,
+ const KString* Password,
+ CMPIStatus* status)
+{
+ struct lu_context *luc = NULL;
+ struct lu_error *error = NULL;
+ struct lu_ent *lue = NULL;
+ char *errmsg = NULL;
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, CHANGE_PASSWORD_OK);
+
+ if(!(Password->exists && !Password->null)) {
+ asprintf(&errmsg, "Password parameter has to be set");
+ KUint32_Set(&result, CHANGE_PASSWORD_FAIL);
+ CMSetStatusWithChars(_cb, status, CMPI_RC_ERR_FAILED, errmsg);
+ goto clean;
+ }
+
+ luc = lu_start(NULL, lu_user, NULL, NULL, lu_prompt_console_quiet, NULL,
+ &error);
+ if (!luc) {
+ asprintf(&errmsg, "Error initializing: %s\n", lu_strerror(error));
+ KUint32_Set(&result, CHANGE_PASSWORD_FAIL);
+ CMSetStatusWithChars(_cb, status, CMPI_RC_ERR_FAILED, errmsg);
+ goto clean;
+ }
+
+ lue = lu_ent_new();
+
+ if (!lu_user_lookup_name(luc, self->Name.chars, lue, &error)) {
+ asprintf(&errmsg, "Non existing user: %s\n", self->Name.chars);
+ KUint32_Set(&result, CHANGE_PASSWORD_FAIL);
+ CMSetStatusWithChars(_cb, status, CMPI_RC_ERR_FAILED, errmsg);
+ goto clean;
+ }
+
+ if (!lu_user_setpass(luc, lue, Password->chars, FALSE, &error)) {
+ asprintf(&errmsg, "Cannot change password: %s\n", lu_strerror(error));
+ KUint32_Set(&result, CHANGE_PASSWORD_FAIL);
+ CMSetStatusWithChars(_cb, status, CMPI_RC_ERR_FAILED, errmsg);
+ goto clean;
+ }
+
+clean:
+ free(errmsg);
+ if(luc) lu_end(luc);
+ if(lue) lu_ent_free(lue);
+ return result;
+}
+
KUint32 LMI_Account_DeleteUser(
const CMPIBroker* cb,