(main): just ignore shadow information if getspnam returns NULL
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8310 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
44
appl/su/su.c
44
appl/su/su.c
@@ -312,31 +312,31 @@ main(int argc, char **argv)
|
|||||||
{ struct spwd *sp;
|
{ struct spwd *sp;
|
||||||
long today;
|
long today;
|
||||||
|
|
||||||
sp=getspnam(su_info->pw_name);
|
sp = getspnam(su_info->pw_name);
|
||||||
if (sp==NULL)
|
if (sp != NULL) {
|
||||||
errx(1,"Have not rights to read shadow passwords!");
|
today = time(0)/(24L * 60 * 60);
|
||||||
today = time(0)/(24L * 60 * 60);
|
if (sp->sp_expire > 0) {
|
||||||
if (sp->sp_expire > 0) {
|
if (today >= sp->sp_expire) {
|
||||||
if (today >= sp->sp_expire) {
|
if (login_info->pw_uid)
|
||||||
if (login_info->pw_uid)
|
errx(1,"Your account has expired.");
|
||||||
errx(1,"Your account has expired.");
|
else
|
||||||
else
|
printf("Your account has expired.");
|
||||||
printf("Your account has expired.");
|
|
||||||
}
|
}
|
||||||
else if (sp->sp_expire - today < 14)
|
else if (sp->sp_expire - today < 14)
|
||||||
printf("Your account will expire in %d days.\n",
|
printf("Your account will expire in %d days.\n",
|
||||||
(int)(sp->sp_expire - today));
|
(int)(sp->sp_expire - today));
|
||||||
}
|
}
|
||||||
if (sp->sp_max > 0) {
|
if (sp->sp_max > 0) {
|
||||||
if (today >= sp->sp_lstchg + sp->sp_max) {
|
if (today >= sp->sp_lstchg + sp->sp_max) {
|
||||||
if (login_info->pw_uid)
|
if (login_info->pw_uid)
|
||||||
errx(1,"Your password has expired. Choose a new one.");
|
errx(1,"Your password has expired. Choose a new one.");
|
||||||
else
|
else
|
||||||
printf("Your password has expired. Choose a new one.");
|
printf("Your password has expired. Choose a new one.");
|
||||||
}
|
}
|
||||||
else if (today >= sp->sp_lstchg + sp->sp_max - sp->sp_warn)
|
else if (today >= sp->sp_lstchg + sp->sp_max - sp->sp_warn)
|
||||||
printf("Your account will expire in %d days.\n",
|
printf("Your account will expire in %d days.\n",
|
||||||
(int)(sp->sp_lstchg + sp->sp_max -today));
|
(int)(sp->sp_lstchg + sp->sp_max -today));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user