[Pkg-shadow-commits] r2587 - in upstream/trunk: . libmisc src
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Sun Apr 5 21:23:27 UTC 2009
Author: nekral-guest
Date: 2009-04-05 21:23:27 +0000 (Sun, 05 Apr 2009)
New Revision: 2587
Modified:
upstream/trunk/ChangeLog
upstream/trunk/libmisc/pwd2spwd.c
upstream/trunk/src/chpasswd.c
upstream/trunk/src/newusers.c
upstream/trunk/src/passwd.c
upstream/trunk/src/pwck.c
upstream/trunk/src/pwconv.c
upstream/trunk/src/useradd.c
upstream/trunk/src/usermod.c
Log:
* libmisc/pwd2spwd.c, src/chpasswd.c, src/newusers.c,
src/passwd.c, src/pwck.c, src/pwconv.c, src/useradd.c,
src/usermod.c: On Jan 01, 1970, do not set the sp_lstchg field to
0 (which means that the password shall be changed during the next
login), but use -1 (password aging disabled).
* src/passwd.c: Do not check sp_min if sp_lstchg is null or -1.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/ChangeLog 2009-04-05 21:23:27 UTC (rev 2587)
@@ -1,6 +1,15 @@
2009-04-04 Nicolas François <nicolas.francois at centraliens.net>
- * src/chage.c: When no shadow entry exist, thedefault sp_lstchg
+ * libmisc/pwd2spwd.c, src/chpasswd.c, src/newusers.c,
+ src/passwd.c, src/pwck.c, src/pwconv.c, src/useradd.c,
+ src/usermod.c: On Jan 01, 1970, do not set the sp_lstchg field to
+ 0 (which means that the password shall be changed during the next
+ login), but use -1 (password aging disabled).
+ * src/passwd.c: Do not check sp_min if sp_lstchg is null or -1.
+
+2009-04-04 Nicolas François <nicolas.francois at centraliens.net>
+
+ * src/chage.c: When no shadow entry exist, the default sp_lstchg
value should be -1 (no aging) rather than 0 (password must be
changed).
* src/chage.c: For password expiration and inactivity, indicate
Modified: upstream/trunk/libmisc/pwd2spwd.c
===================================================================
--- upstream/trunk/libmisc/pwd2spwd.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/libmisc/pwd2spwd.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -65,6 +65,11 @@
sp.sp_min = 0;
sp.sp_max = (10000L * DAY) / SCALE;
sp.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == sp.sp_lstchg) {
+ /* Better disable aging than requiring a password
+ * change */
+ sp.sp_lstchg = -1;
+ }
}
/*
Modified: upstream/trunk/src/chpasswd.c
===================================================================
--- upstream/trunk/src/chpasswd.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/chpasswd.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -373,7 +373,6 @@
struct passwd newpw;
int errors = 0;
int line = 0;
- long now = (long) time ((time_t *)NULL) / SCALE;
Prog = Basename (argv[0]);
@@ -478,7 +477,12 @@
if (NULL != sp) {
newsp = *sp;
newsp.sp_pwdp = cp;
- newsp.sp_lstchg = now;
+ newsp.sp_lstchg = (long) time ((time_t *)NULL) / SCALE;
+ if (0 == newsp.sp_lstchg) {
+ /* Better disable aging than requiring a
+ * password change */
+ newssp.sp_lstchg = -1;
+ }
} else {
newpw = *pw;
newpw.pw_passwd = cp;
Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/newusers.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -452,6 +452,10 @@
spent.sp_pwdp = pw_encrypt (password, salt);
}
spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == spent.sp_lstchg) {
+ /* Better disable aging than requiring a password change */
+ spent.sp_lstchg = -1;
+ }
spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
/* 10000 is infinity this week */
spent.sp_max = getdef_num ("PASS_MAX_DAYS", 10000);
Modified: upstream/trunk/src/passwd.c
===================================================================
--- upstream/trunk/src/passwd.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/passwd.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -385,11 +385,13 @@
* changed. Passwords which have been inactive too long cannot be
* changed.
*/
- if (sp->sp_pwdp[0] == '!' || exp_status > 1 ||
- (sp->sp_max >= 0 && sp->sp_min > sp->sp_max)) {
+ if ( (sp->sp_pwdp[0] == '!')
+ || (exp_status > 1)
+ || ( (sp->sp_max >= 0)
+ && (sp->sp_min > sp->sp_max))) {
fprintf (stderr,
- _("The password for %s cannot be changed.\n"),
- sp->sp_namp);
+ _("The password for %s cannot be changed.\n"),
+ sp->sp_namp);
SYSLOG ((LOG_WARN, "password locked for '%s'", sp->sp_namp));
closelog ();
exit (E_NOPERM);
@@ -398,17 +400,18 @@
/*
* Passwords may only be changed after sp_min time is up.
*/
- last = sp->sp_lstchg * SCALE;
- ok = last + (sp->sp_min > 0 ? sp->sp_min * SCALE : 0);
+ if (sp->sp_lstchg > 0) {
+ last = sp->sp_lstchg * SCALE;
+ ok = last + (sp->sp_min > 0 ? sp->sp_min * SCALE : 0);
- if (now < ok) {
- fprintf (stderr,
- _
- ("The password for %s cannot be changed yet.\n"),
- pw->pw_name);
- SYSLOG ((LOG_WARN, "now < minimum age for '%s'", pw->pw_name));
- closelog ();
- exit (E_NOPERM);
+ if (now < ok) {
+ fprintf (stderr,
+ _("The password for %s cannot be changed yet.\n"),
+ pw->pw_name);
+ SYSLOG ((LOG_WARN, "now < minimum age for '%s'", pw->pw_name));
+ closelog ();
+ exit (E_NOPERM);
+ }
}
}
@@ -633,6 +636,11 @@
}
if (do_update_age) {
nsp->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == nsp->sp_lstchg) {
+ /* Better disable aging than requiring a password
+ * change */
+ nsp->sp_lstchg = -1;
+ }
}
/*
@@ -640,8 +648,9 @@
* 2.x passwd -f. Solaris 2.x seems to do the same thing (set
* sp_lstchg to 0).
*/
- if (eflg)
+ if (eflg) {
nsp->sp_lstchg = 0;
+ }
if (spw_update (nsp) == 0) {
fprintf (stderr,
Modified: upstream/trunk/src/pwck.c
===================================================================
--- upstream/trunk/src/pwck.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/pwck.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -473,6 +473,12 @@
sp.sp_expire = -1;
sp.sp_flag = SHADOW_SP_FLAG_UNSET;
sp.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == sp.sp_lstchg) {
+ /* Better disable aging than
+ * requiring a password change
+ */
+ sp.sp_lstchg = -1;
+ }
*changed = true;
if (spw_update (&sp) == 0) {
Modified: upstream/trunk/src/pwconv.c
===================================================================
--- upstream/trunk/src/pwconv.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/pwconv.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -203,6 +203,11 @@
}
spent.sp_pwdp = pw->pw_passwd;
spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == spent.sp_lstchg) {
+ /* Better disable aging than requiring a password
+ * change */
+ spent.sp_lstchg = -1;
+ }
if (spw_update (&spent) == 0) {
fprintf (stderr,
_("%s: failed to prepare the new %s entry '%s'\n"),
Modified: upstream/trunk/src/useradd.c
===================================================================
--- upstream/trunk/src/useradd.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/useradd.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -766,6 +766,10 @@
spent->sp_namp = (char *) user_name;
spent->sp_pwdp = (char *) user_pass;
spent->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == spent->sp_lstchg) {
+ /* Better disable aging than requiring a password change */
+ spent->sp_lstchg = -1;
+ }
if (!rflg) {
spent->sp_min = scale_age (getdef_num ("PASS_MIN_DAYS", -1));
spent->sp_max = scale_age (getdef_num ("PASS_MAX_DAYS", -1));
Modified: upstream/trunk/src/usermod.c
===================================================================
--- upstream/trunk/src/usermod.c 2009-04-05 21:23:17 UTC (rev 2586)
+++ upstream/trunk/src/usermod.c 2009-04-05 21:23:27 UTC (rev 2587)
@@ -521,6 +521,11 @@
spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
if (pflg) {
spent->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
+ if (0 == spent->sp_lstchg) {
+ /* Better disable aging than requiring a password
+ * change */
+ spent->sp_lstchg = -1;
+ }
}
}
More information about the Pkg-shadow-commits
mailing list