summaryrefslogtreecommitdiffstats
path: root/src/account/LMI_AccountProvider.c
diff options
context:
space:
mode:
authorRoman Rakus <rrakus@redhat.com>2013-05-30 09:58:01 +0200
committerRoman Rakus <rrakus@redhat.com>2013-05-30 09:58:01 +0200
commit08959a97787e4d120010bca1645b547217869374 (patch)
treea59c7a618674e8523241f004982395535d3766fe /src/account/LMI_AccountProvider.c
parentdec0ce45beeb80fd125dd2500c28a0a5d4535625 (diff)
downloadopenlmi-providers-08959a97787e4d120010bca1645b547217869374.tar.gz
openlmi-providers-08959a97787e4d120010bca1645b547217869374.tar.xz
openlmi-providers-08959a97787e4d120010bca1645b547217869374.zip
Account: Correctly handle empty fields in shadow file
libuser returns -1 for empty fields. Handle the -1 on missing places. Added macro definitions for -1 and 99999 values. Fixes Ticket #113: LMI_Account instance enumeration fails with "DateTime is out of range" Signed-off-by: Roman Rakus <rrakus@redhat.com>
Diffstat (limited to 'src/account/LMI_AccountProvider.c')
-rw-r--r--src/account/LMI_AccountProvider.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/account/LMI_AccountProvider.c b/src/account/LMI_AccountProvider.c
index c4a68f7..27be7e1 100644
--- a/src/account/LMI_AccountProvider.c
+++ b/src/account/LMI_AccountProvider.c
@@ -120,16 +120,22 @@ static CMPIStatus LMI_AccountEnumInstances(
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(last_change), false, rc));
-
+ if (last_change != SHADOW_VALUE_EMPTY)
+ {
+ LMI_Account_Set_PasswordLastChange(&la,
+ CMNewDateTimeFromBinary(_cb, DAYSTOMS(last_change), false, rc));
+ }
min_lifetime = aux_lu_get_long(lue, LU_SHADOWMIN);
max_lifetime = aux_lu_get_long(lue, LU_SHADOWMAX);
- LMI_Account_Set_PasswordPossibleChange(&la,
- CMNewDateTimeFromBinary(_cb, DAYSTOMS(min_lifetime), true, rc));
+ if (min_lifetime != SHADOW_VALUE_EMPTY)
+ {
+ LMI_Account_Set_PasswordPossibleChange(&la,
+ CMNewDateTimeFromBinary(_cb, DAYSTOMS(min_lifetime), true, rc));
+ }
- if (max_lifetime != 0 && max_lifetime != 99999)
+ if (max_lifetime != SHADOW_VALUE_EMPTY &&
+ max_lifetime != SHADOW_MAX_DISABLED)
{
LMI_Account_Set_PasswordExpiration(&la,
CMNewDateTimeFromBinary(_cb, DAYSTOMS(max_lifetime), true, rc));
@@ -137,7 +143,7 @@ static CMPIStatus LMI_AccountEnumInstances(
LMI_Account_Set_PasswordExpirationWarning(&la,
CMNewDateTimeFromBinary(_cb, DAYSTOMS(warn), true, rc));
inactive = aux_lu_get_long(lue, LU_SHADOWINACTIVE);
- if (inactive != -1)
+ if (inactive != SHADOW_VALUE_EMPTY)
{
LMI_Account_Set_PasswordInactivation(&la,
CMNewDateTimeFromBinary(_cb, DAYSTOMS(inactive), true, rc));
@@ -151,7 +157,7 @@ static CMPIStatus LMI_AccountEnumInstances(
}
expire = aux_lu_get_long(lue, LU_SHADOWEXPIRE);
- if (expire != -1)
+ if (expire != SHADOW_VALUE_EMPTY)
{
LMI_Account_Set_AccountExpiration(&la,
CMNewDateTimeFromBinary(_cb, DAYSTOMS(expire), false, rc));
@@ -163,7 +169,7 @@ static CMPIStatus LMI_AccountEnumInstances(
last_login = aux_utmp_latest(aux_lu_get_str(lue, LU_USERNAME));
- if (last_login != -1)
+ if (last_login != SHADOW_VALUE_EMPTY)
{
LMI_Account_Set_LastLogin(&la,
CMNewDateTimeFromBinary(_cb, STOMS(last_login), false, rc));