summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2012-10-10 18:08:45 +0200
committerMichal Minar <miminar@redhat.com>2012-10-10 18:08:45 +0200
commit95dec00b1efbeb4c756d4141f08f7daf0bb0189c (patch)
tree5bb9d0dca1f460f1c4a342a86a8d8629dcfcec87 /src
parent5372a149e57d0a7e6c9435f137992292f840c078 (diff)
parent16906287ddf54c76137f6a536743e1f6abb04038 (diff)
downloadopenlmi-providers-95dec00b1efbeb4c756d4141f08f7daf0bb0189c.tar.gz
openlmi-providers-95dec00b1efbeb4c756d4141f08f7daf0bb0189c.tar.xz
openlmi-providers-95dec00b1efbeb4c756d4141f08f7daf0bb0189c.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/cura-providers
Diffstat (limited to 'src')
-rw-r--r--src/account/LMI_AccountManagementServiceProvider.c6
-rw-r--r--src/account/LMI_AccountProvider.c63
2 files changed, 42 insertions, 27 deletions
diff --git a/src/account/LMI_AccountManagementServiceProvider.c b/src/account/LMI_AccountManagementServiceProvider.c
index dd91d1c..ff09653 100644
--- a/src/account/LMI_AccountManagementServiceProvider.c
+++ b/src/account/LMI_AccountManagementServiceProvider.c
@@ -319,18 +319,15 @@ KUint32 LMI_AccountManagementService_CreateAccount(
CMPIStatus* status)
{
/* TODO - Use embedded instance? */
-/* TODO - convert errmsg to array and don't use malloc/free */
/* TODO - password creation */
/* XXX - split to functions and/or macros */
- char *errmsg = NULL;
+ char errmsg[256];
#define FAIL(MSG, ERROR, STATUS, RETVAL)\
- errmsg = malloc(256 * sizeof(char));\
snprintf(errmsg, 256, (MSG), (ERROR));\
KSetStatus2(cb, status, STATUS, errmsg);\
KUint32_Set(&result, (RETVAL));\
- free(errmsg);
KUint32 result = KUINT32_INIT;
struct lu_context *luc = NULL;
@@ -508,7 +505,6 @@ KUint32 LMI_AccountManagementService_CreateAccount(
FAIL("Error setting ownership of homedir: %s\n", strerror(errno),
ERR_FAILED, 3);
goto clean;
- errmsg = malloc(256 * sizeof(char));
}
}
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c
index 04f4857..e765d6b 100644
--- a/src/account/LMI_AccountProvider.c
+++ b/src/account/LMI_AccountProvider.c
@@ -61,9 +61,8 @@ static CMPIStatus LMI_AccountEnumInstances(
const char *nameSpace = KNameSpace(cop);
const char *hostname = get_system_name();
char *uid = NULL;
- long expire, last_change, min_lifetime, max_lifetime;
+ long last_change, min_lifetime, max_lifetime, warn, inactive, expire;
time_t last_login;
- CMPIUint64 binTime = 0;
CMPIStatus *rc = NULL;
char *password = NULL;
@@ -105,13 +104,47 @@ static CMPIStatus LMI_AccountEnumInstances(
CMNewDateTimeFromBinary(_cb, DAYSTOMS(last_change),false, rc));
min_lifetime = aux_lu_get_long(lue, LU_SHADOWMIN) + last_change;
- max_lifetime = aux_lu_get_long(lue, LU_SHADOWMAX) + last_change;
+ max_lifetime = aux_lu_get_long(lue, LU_SHADOWMAX);
- LMI_Account_Set_PasswordMinLifetime(&la,
- CMNewDateTimeFromBinary(_cb, DAYSTOMS(min_lifetime), false, rc));
+ LMI_Account_Set_PasswordPossibleChange(&la,
+ CMNewDateTimeFromBinary(_cb, DAYSTOMS(min_lifetime),
+ false, rc));
- LMI_Account_Set_PasswordMaxLifetime(&la,
- CMNewDateTimeFromBinary(_cb, DAYSTOMS(max_lifetime), false, rc));
+ if (max_lifetime != 0 && max_lifetime != 99999)
+ {
+ max_lifetime += last_change;
+ LMI_Account_Set_PasswordExpiration(&la,
+ CMNewDateTimeFromBinary(_cb, DAYSTOMS(max_lifetime), false, rc));
+ warn = aux_lu_get_long(lue, LU_SHADOWWARNING);
+ LMI_Account_Set_PasswordExpirationWarning(&la,
+ CMNewDateTimeFromBinary(_cb, DAYSTOMS(max_lifetime - warn),
+ false, rc));
+ inactive = aux_lu_get_long(lue, LU_SHADOWINACTIVE);
+ if (inactive != -1)
+ {
+ LMI_Account_Set_PasswordInactivation(&la,
+ CMNewDateTimeFromBinary(_cb,
+ DAYSTOMS(max_lifetime + inactive), false, rc));
+ }
+ }
+ else
+ {
+ LMI_Account_Null_PasswordExpiration(&la);
+ LMI_Account_Null_PasswordExpirationWarning(&la);
+ LMI_Account_Null_PasswordInactivation(&la);
+ }
+
+ expire = aux_lu_get_long(lue, LU_SHADOWEXPIRE);
+ if (expire != -1)
+ {
+ LMI_Account_Set_AccountExpiration(&la,
+ CMNewDateTimeFromBinary(_cb,
+ DAYSTOMS(expire), false, rc));
+ }
+ else
+ {
+ LMI_Account_Null_AccountExpiration(&la);
+ }
last_login = aux_utmp_latest(aux_lu_get_str(lue, LU_USERNAME));
@@ -121,26 +154,11 @@ static CMPIStatus LMI_AccountEnumInstances(
CMNewDateTimeFromBinary(_cb, last_login * 1000000, false, rc));
}
- binTime = DAYSTOMS(aux_lu_get_long(lue, LU_SHADOWMIN));
-
password = aux_lu_get_str(lue, LU_SHADOWPASSWORD);
LMI_Account_Init_UserPassword(&la, 1);
LMI_Account_Set_UserPassword(&la, 0, password);
/* Assume all passwords (encrypted or not) are in ascii encoding */
LMI_Account_Set_UserPasswordEncoding(&la, 2);
- if(strstr(password, ""))
-
- expire = aux_lu_get_long(lue, LU_SHADOWEXPIRE);
- if (expire != -1)
- {
- binTime = DAYSTOMS(expire);
- LMI_Account_Set_PasswordExpiration(&la,
- CMNewDateTimeFromBinary(_cb, binTime, false, rc));
- }
- else
- {
- LMI_Account_Null_PasswordExpiration(&la);
- }
KReturnInstance(cr, la);
lu_ent_free(lue);
@@ -400,6 +418,7 @@ KUint32 LMI_Account_RequestStateChange(
return result;
}
+
KONKRET_REGISTRATION(
"root/cimv2",
"LMI_Account",