Skip to content

Commit 9e20651

Browse files
lib/, man/, src/: Remove support for 'sp_lstchg'
Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 75c2e35 commit 9e20651

File tree

10 files changed

+8
-143
lines changed

10 files changed

+8
-143
lines changed

lib/age.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -133,50 +133,3 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
133133

134134
exit (EXIT_FAILURE);
135135
/*@notreached@*/}
136-
137-
/*
138-
* agecheck - see if warning is needed for password expiration
139-
*
140-
* agecheck sees how many days until the user's password is going
141-
* to expire and warns the user of the pending password expiration.
142-
*/
143-
144-
void agecheck (/*@null@*/const struct spwd *sp)
145-
{
146-
long now = time(NULL) / DAY;
147-
long remain;
148-
149-
if (NULL == sp) {
150-
return;
151-
}
152-
153-
/*
154-
* The last, max, and warn fields must be supported or the
155-
* warning period cannot be calculated.
156-
*/
157-
158-
if ( (-1 == sp->sp_lstchg)
159-
|| (-1 == sp->sp_max)
160-
|| (-1 == sp->sp_warn)) {
161-
return;
162-
}
163-
164-
if (0 == sp->sp_lstchg) {
165-
(void) puts (_("You must change your password."));
166-
return;
167-
}
168-
169-
remain = addsl(sp->sp_lstchg, sp->sp_max, -now);
170-
171-
if (remain <= sp->sp_warn) {
172-
if (remain > 1) {
173-
(void) printf (_("Your password will expire in %ld days.\n"),
174-
remain);
175-
} else if (1 == remain) {
176-
(void) puts (_("Your password will expire tomorrow."));
177-
} else if (remain == 0) {
178-
(void) puts (_("Your password will expire today."));
179-
}
180-
}
181-
}
182-

lib/prototypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ extern int add_groups (const char *);
4343
#endif
4444

4545
/* age.c */
46-
extern void agecheck (/*@null@*/const struct spwd *);
4746
extern int expire (const struct passwd *, /*@null@*/const struct spwd *);
4847

4948
/* isexpired.c */

lib/shadow/shadow/sgetspent.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,7 @@ sgetspent(const char *s)
6565
spwd.sp_namp = fields[0];
6666
spwd.sp_pwdp = fields[1];
6767

68-
/*
69-
* Get the last changed date. For all of the integer fields,
70-
* we check for proper format. It is an error to have an
71-
* incorrectly formatted number.
72-
*/
73-
74-
if (streq(fields[2], ""))
75-
spwd.sp_lstchg = -1;
76-
else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1)
77-
return NULL;
68+
spwd.sp_lstchg = -1;
7869

7970
/*
8071
* Get the minimum period between password changes.

man/shadow.5.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,7 @@
104104
<emphasis role="bold">date of last password change</emphasis>
105105
</term>
106106
<listitem>
107-
<para>
108-
The date of the last password change, expressed as the number
109-
of days since 1970-01-01 00:00:00 UTC.
110-
</para>
111-
<para>
112-
The value 0 indicates that the user must change their password
113-
the next time they log in to the system.
114-
</para>
115-
<para>
116-
An empty field means that password aging features are
117-
disabled.
118-
</para>
107+
<para>This field should be empty.</para>
119108
</listitem>
120109
</varlistentry>
121110
<varlistentry>

src/login.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,6 @@ int main (int argc, char **argv)
12111211
printf (".\n");
12121212
}
12131213
#endif /* ENABLE_LASTLOG */
1214-
agecheck (spwd);
1215-
12161214
mailcheck (); /* report on the status of mail */
12171215
#endif /* !USE_PAM */
12181216
} else {

src/passwd.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -418,28 +418,6 @@ static void check_password (const struct passwd *pw, const struct spwd *sp)
418418
closelog ();
419419
exit (E_NOPERM);
420420
}
421-
422-
/*
423-
* Passwords may only be changed after sp_min time is up.
424-
*/
425-
if (sp->sp_lstchg > 0) {
426-
long now, ok;
427-
now = time(NULL) / DAY;
428-
ok = sp->sp_lstchg;
429-
if ( (sp->sp_min > 0)
430-
&& __builtin_add_overflow(ok, sp->sp_min, &ok)) {
431-
ok = LONG_MAX;
432-
}
433-
434-
if (now < ok) {
435-
(void) fprintf (stderr,
436-
_("The password for %s cannot be changed yet.\n"),
437-
pw->pw_name);
438-
SYSLOG ((LOG_WARN, "now < minimum age for '%s'", pw->pw_name));
439-
closelog ();
440-
exit (E_NOPERM);
441-
}
442-
}
443421
}
444422

445423
static /*@observer@*/const char *pw_status (const char *pass)
@@ -667,12 +645,7 @@ static void update_shadow(const struct option_flags *flags)
667645
if (!use_pam)
668646
{
669647
if (do_update_age) {
670-
nsp->sp_lstchg = gettime () / DAY;
671-
if (0 == nsp->sp_lstchg) {
672-
/* Better disable aging than requiring a password
673-
* change */
674-
nsp->sp_lstchg = -1;
675-
}
648+
nsp->sp_lstchg = -1;
676649
}
677650
}
678651

src/pwck.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,7 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags
634634
sp.sp_inact = -1;
635635
sp.sp_expire = -1;
636636
sp.sp_flag = SHADOW_SP_FLAG_UNSET;
637-
sp.sp_lstchg = gettime () / DAY;
638-
if (0 == sp.sp_lstchg) {
639-
/* Better disable aging than
640-
* requiring a password change
641-
*/
642-
sp.sp_lstchg = -1;
643-
}
637+
sp.sp_lstchg = -1;
644638
*changed = true;
645639

646640
if (spw_update (&sp) == 0) {
@@ -833,19 +827,6 @@ static void check_spw_file (bool *errors, bool *changed)
833827
goto delete_spw;
834828
}
835829
}
836-
837-
/*
838-
* Warn if last password change in the future. --marekm
839-
*/
840-
if (!quiet) {
841-
time_t t = time (NULL);
842-
if ( (t != 0)
843-
&& (spw->sp_lstchg > t / DAY)) {
844-
printf (_("user %s: last password change in the future\n"),
845-
spw->sp_namp);
846-
*errors = true;
847-
}
848-
}
849830
}
850831
}
851832

src/pwconv.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,7 @@ int main (int argc, char **argv)
259259
spent.sp_flag = SHADOW_SP_FLAG_UNSET;
260260
}
261261
spent.sp_pwdp = pw->pw_passwd;
262-
spent.sp_lstchg = gettime () / DAY;
263-
if (0 == spent.sp_lstchg) {
264-
/* Better disable aging than requiring a password
265-
* change */
266-
spent.sp_lstchg = -1;
267-
}
262+
spent.sp_lstchg = -1;
268263
if (spw_update (&spent) == 0) {
269264
fprintf (stderr,
270265
_("%s: failed to prepare the new %s entry '%s'\n"),

src/useradd.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,7 @@ static void new_spent (struct spwd *spent)
957957
memzero(spent, sizeof(*spent));
958958
spent->sp_namp = (char *) user_name;
959959
spent->sp_pwdp = (char *) user_pass;
960-
spent->sp_lstchg = gettime () / DAY;
961-
if (0 == spent->sp_lstchg) {
962-
/* Better disable aging than requiring a password change */
963-
spent->sp_lstchg = -1;
964-
}
960+
spent->sp_lstchg = -1;
965961
if (!rflg) {
966962
spent->sp_min = getdef_num ("PASS_MIN_DAYS", -1);
967963
spent->sp_max = getdef_num ("PASS_MAX_DAYS", -1);

src/usermod.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,7 @@ static void new_spent (struct spwd *spent, bool process_selinux)
605605
spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
606606

607607
if (pflg) {
608-
spent->sp_lstchg = gettime () / DAY;
609-
if (0 == spent->sp_lstchg) {
610-
/* Better disable aging than requiring a password
611-
* change. */
612-
spent->sp_lstchg = -1;
613-
}
608+
spent->sp_lstchg = -1;
614609
}
615610
}
616611

@@ -1697,12 +1692,7 @@ static void usr_update(const struct option_flags *flags)
16971692
spent.sp_pwdp = xstrdup (pwent.pw_passwd);
16981693
pwent.pw_passwd = xstrdup (SHADOW_PASSWD_STRING);
16991694

1700-
spent.sp_lstchg = gettime () / DAY;
1701-
if (0 == spent.sp_lstchg) {
1702-
/* Better disable aging than
1703-
* requiring a password change */
1704-
spent.sp_lstchg = -1;
1705-
}
1695+
spent.sp_lstchg = -1;
17061696
spent.sp_min = getdef_num ("PASS_MIN_DAYS", -1);
17071697
spent.sp_max = getdef_num ("PASS_MAX_DAYS", -1);
17081698
spent.sp_warn = getdef_num ("PASS_WARN_AGE", -1);

0 commit comments

Comments
 (0)