lib/, src/: Remove SCALE definition
SCALE is always DAY (and has to be always DAY), so replace it with DAY in source code and remove unneeded calculations. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Link: <https://github.com/shadow-maint/shadow/pull/876> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
11091949be
commit
ecc3508877
@@ -139,7 +139,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
|
||||
|
||||
void agecheck (/*@null@*/const struct spwd *sp)
|
||||
{
|
||||
long now = time(NULL) / SCALE;
|
||||
long now = time(NULL) / DAY;
|
||||
long remain;
|
||||
|
||||
if (NULL == sp) {
|
||||
@@ -164,7 +164,6 @@ void agecheck (/*@null@*/const struct spwd *sp)
|
||||
|
||||
remain = sp->sp_lstchg + sp->sp_max - now;
|
||||
if (remain <= sp->sp_warn) {
|
||||
remain /= DAY / SCALE;
|
||||
if (remain > 1) {
|
||||
(void) printf (_("Your password will expire in %ld days.\n"),
|
||||
remain);
|
||||
|
||||
@@ -139,7 +139,6 @@
|
||||
*
|
||||
* DAY - seconds / day
|
||||
* WEEK - seconds / week
|
||||
* SCALE - seconds / aging unit
|
||||
*/
|
||||
|
||||
/* Solaris defines this in shadow.h */
|
||||
@@ -149,8 +148,6 @@
|
||||
|
||||
#define WEEK (7*DAY)
|
||||
|
||||
#define SCALE DAY
|
||||
|
||||
#ifndef PASSWD_FILE
|
||||
#define PASSWD_FILE "/etc/passwd"
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ int isexpired (const struct passwd *pw, /*@null@*/const struct spwd *sp)
|
||||
{
|
||||
long now;
|
||||
|
||||
now = time(NULL) / SCALE;
|
||||
now = time(NULL) / DAY;
|
||||
|
||||
if (NULL == sp) {
|
||||
return 0;
|
||||
@@ -84,7 +84,7 @@ int isexpired (const struct passwd *pw, /*@null@*/const struct spwd *sp)
|
||||
|
||||
if ( (-1 == sp->sp_lstchg)
|
||||
|| (-1 == sp->sp_max)
|
||||
|| (sp->sp_max >= ((10000L * DAY) / SCALE))) {
|
||||
|| (sp->sp_max >= 10000)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ struct spwd *pwd_to_spwd (const struct passwd *pw)
|
||||
* Defaults used if there is no pw_age information.
|
||||
*/
|
||||
sp.sp_min = 0;
|
||||
sp.sp_max = (10000L * DAY) / SCALE;
|
||||
sp.sp_lstchg = gettime () / SCALE;
|
||||
sp.sp_max = 10000;
|
||||
sp.sp_lstchg = gettime () / DAY;
|
||||
if (0 == sp.sp_lstchg) {
|
||||
/* Better disable aging than requiring a password
|
||||
* change */
|
||||
|
||||
Reference in New Issue
Block a user