* libmisc/isexpired.c: ARGSUSED is no more needed (shadow is always supported).

* libmisc/isexpired.c: Avoid implicit conversion of pointers to booleans.
	* libmisc/isexpired.c: Add brackets and parenthesis.
This commit is contained in:
nekral-guest 2008-05-26 00:14:10 +00:00
parent c6364944d4
commit fc6d8e933b
2 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/isexpired.c: ARGSUSED is no more needed (shadow is
always supported).
* libmisc/isexpired.c: Avoid implicit conversion of pointers to
booleans.
* libmisc/isexpired.c: Add brackets and parenthesis.
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/sulog.c (sulog): The success argument is a bool.

View File

@ -2,6 +2,7 @@
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
* Copyright (c) 1996 - 1997, Marek Michałkiewicz
* Copyright (c) 2001 - 2005, Tomasz Kłoczko
* Copyright (c) 2008 , Nicolas François
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,14 +52,15 @@
* isexpired calculates the expiration date based on the
* password expiration criteria.
*/
/*ARGSUSED*/ int isexpired (const struct passwd *pw, const struct spwd *sp)
int isexpired (const struct passwd *pw, const struct spwd *sp)
{
long now;
now = time ((time_t *) 0) / SCALE;
if (!sp)
if (NULL == sp) {
sp = pwd_to_spwd (pw);
}
/*
* Quick and easy - there is an expired account field
@ -77,11 +79,13 @@
* if /etc/shadow doesn't exist, getspnam() still succeeds and
* returns sp_lstchg==0 (must change password) instead of -1!
*/
if (sp->sp_lstchg == 0 && !strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING))
if ((sp->sp_lstchg == 0) &&
(strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) {
return 1;
}
if (sp->sp_lstchg > 0 && sp->sp_max >= 0 && sp->sp_inact >= 0 &&
now >= sp->sp_lstchg + sp->sp_max + sp->sp_inact)
now >= (sp->sp_lstchg + sp->sp_max + sp->sp_inact))
return 2;
/*
@ -100,7 +104,8 @@
* the password has expired.
*/
if (now >= sp->sp_lstchg + sp->sp_max)
if (now >= (sp->sp_lstchg + sp->sp_max))
return 1;
return 0;
}