Initial import from FreeBSD RELENG_4:
[games.git] / crypto / kerberosIV / appl / bsd / sysv_shadow.c
1 /* Author: Wietse Venema <wietse@wzv.win.tue.nl> */
2
3 #include "bsd_locl.h"
4
5 RCSID("$Id: sysv_shadow.c,v 1.8 1997/12/29 19:56:07 bg Exp $");
6
7 #ifdef SYSV_SHADOW
8
9 #include <sysv_shadow.h>
10
11 /* sysv_expire - check account and password expiration times */
12
13 int
14 sysv_expire(struct spwd *spwd)
15 {
16     long    today;
17
18     tzset();
19     today = time(0)/(60*60*24); /* In days since Jan. 1, 1970 */
20
21     if (spwd->sp_expire > 0) {
22         if (today > spwd->sp_expire) {
23             printf("Your account has expired.\n");
24             sleepexit(1);
25         } else if (spwd->sp_expire - today < 14) {
26             printf("Your account will expire in %d days.\n",
27                    (int)(spwd->sp_expire - today));
28             return (0);
29         }
30     }
31     if (spwd->sp_max > 0) {
32         if (today > (spwd->sp_lstchg + spwd->sp_max)) {
33             printf("Your password has expired. Choose a new one.\n");
34             return (1);
35         } else if (spwd->sp_warn > 0
36             && (today > (spwd->sp_lstchg + spwd->sp_max - spwd->sp_warn))) {
37             printf("Your password will expire in %d days.\n",
38                    (int)(spwd->sp_lstchg + spwd->sp_max - today));
39             return (0);
40         }
41     }
42     return (0);
43 }
44
45 #endif /* SYSV_SHADOW */