handle LR_PW_EXPTIME and LR_ACCT_EXPTIME in the same way

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10870 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2002-03-10 23:13:10 +00:00
parent 044ce97ca0
commit 1c8fadc0af

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997 - 2001 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997 - 2002 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -124,6 +124,24 @@ out:
return ret;
}
/*
* Print a message (str) to the user about the expiration in `lr'
*/
static void
report_expiration (krb5_context context,
krb5_prompter_fct prompter,
krb5_data *data,
const char *str,
time_t time)
{
char *p;
asprintf (&p, "%s%s", str, ctime(&time));
(*prompter) (context, data, NULL, p, 0, NULL);
free (p);
}
/*
* Parse the last_req data and show it to the user if it's interesting
*/
@@ -139,6 +157,7 @@ print_expire (krb5_context context,
LastReq *lr = &rep->enc_part.last_req;
krb5_timestamp sec;
time_t t;
krb5_boolean reported = FALSE;
krb5_timeofday (context, &sec);
@@ -148,26 +167,30 @@ print_expire (krb5_context context,
7 * 24 * 60 * 60);
for (i = 0; i < lr->len; ++i) {
if (abs(lr->val[i].lr_type) == LR_PW_EXPTIME
&& lr->val[i].lr_value <= t) {
char *p;
time_t tmp = lr->val[i].lr_value;
asprintf (&p, "Your password will expire at %s", ctime(&tmp));
(*prompter) (context, data, NULL, p, 0, NULL);
free (p);
return;
if (lr->val[i].lr_value <= t) {
switch (abs(lr->val[i].lr_type)) {
case LR_PW_EXPTIME :
report_expiration(context, prompter, data,
"Your password will expire at ",
lr->val[i].lr_value);
reported = TRUE;
break;
case LR_ACCT_EXPTIME :
report_expiration(context, prompter, data,
"Your account will expire at ",
lr->val[i].lr_value);
reported = TRUE;
break;
}
}
}
if (rep->enc_part.key_expiration
if (!reported
&& rep->enc_part.key_expiration
&& *rep->enc_part.key_expiration <= t) {
char *p;
time_t t = *rep->enc_part.key_expiration;
asprintf (&p, "Your password/account will expire at %s", ctime(&t));
(*prompter) (context, data, NULL, p, 0, NULL);
free (p);
report_expiration(context, prompter, data,
"Your password/account will expire at ",
*rep->enc_part.key_expiration);
}
}