diff options
Diffstat (limited to 'src/account/LMI_AccountProvider.c')
-rw-r--r-- | src/account/LMI_AccountProvider.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c index 067ef68..04f4857 100644 --- a/src/account/LMI_AccountProvider.c +++ b/src/account/LMI_AccountProvider.c @@ -4,6 +4,8 @@ #include <time.h> #include <stdbool.h> +#include <utmp.h> + #include <glib.h> #include <libuser/entity.h> @@ -59,7 +61,8 @@ static CMPIStatus LMI_AccountEnumInstances( const char *nameSpace = KNameSpace(cop); const char *hostname = get_system_name(); char *uid = NULL; - long expire; + long expire, last_change, min_lifetime, max_lifetime; + time_t last_login; CMPIUint64 binTime = 0; CMPIStatus *rc = NULL; char *password = NULL; @@ -97,9 +100,28 @@ static CMPIStatus LMI_AccountEnumInstances( LU_HOMEDIRECTORY)); LMI_Account_Set_LoginShell(&la, aux_lu_get_str(lue, LU_LOGINSHELL)); + last_change = aux_lu_get_long(lue, LU_SHADOWLASTCHANGE); LMI_Account_Set_PasswordLastChange(&la, - CMNewDateTimeFromBinary(_cb, - DAYSTOMS(aux_lu_get_long(lue, LU_SHADOWLASTCHANGE)),false, rc)); + 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; + + LMI_Account_Set_PasswordMinLifetime(&la, + CMNewDateTimeFromBinary(_cb, DAYSTOMS(min_lifetime), false, rc)); + + LMI_Account_Set_PasswordMaxLifetime(&la, + CMNewDateTimeFromBinary(_cb, DAYSTOMS(max_lifetime), false, rc)); + + last_login = aux_utmp_latest(aux_lu_get_str(lue, LU_USERNAME)); + + if (last_login != -1) + { + LMI_Account_Set_LastLogin(&la, + 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); @@ -171,7 +193,6 @@ static CMPIStatus LMI_AccountModifyInstance( * Set up password expiration */ char* value = NULL; - CMPIStatus* st = NULL; CMPIString* vs = NULL; CMPIArray* ar = NULL; int arsize;/* used for password */ CMPIData data; |