2 ** Copyright 1998 - 2005 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
24 #include "courierauthdebug.h"
27 int auth_shadow_pre(const char *userid
, const char *service
,
28 int (*callback
)(struct authinfo
*, void *),
36 memset(&auth
, 0, sizeof(auth
));
38 if ((pw
=getpwnam(userid
)) == NULL
)
40 if (errno
== ENOMEM
) return 1;
44 if ((spw
=getspnam(userid
)) == NULL
)
46 if (errno
== ENOMEM
) return 1;
50 today
= (long)time(NULL
)/(24L*60*60);
52 if ((spw
->sp_expire
> 0) && (today
> spw
->sp_expire
))
54 DPRINTF("authshadow: %s - account expired", userid
);
55 return -1; /* account expired */
58 if ((spw
->sp_lstchg
!= -1) && (spw
->sp_max
!= -1) &&
59 ((spw
->sp_lstchg
+ spw
->sp_max
) < today
))
61 DPRINTF("authshadow: %s - password expired", userid
);
62 return -1; /* password expired */
65 auth
.sysusername
=userid
;
66 auth
.sysgroupid
=pw
->pw_gid
;
67 auth
.homedir
=pw
->pw_dir
;
69 auth
.fullname
=pw
->pw_gecos
;
70 auth
.passwd
=spw
->sp_pwdp
;
72 courier_authdebug_authinfo("DEBUG: authshadow: ", &auth
, 0, pw
->pw_passwd
);
73 return ((*callback
)(&auth
, arg
));