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:
@@ -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).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -124,6 +124,24 @@ out:
|
|||||||
return ret;
|
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
|
* 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;
|
LastReq *lr = &rep->enc_part.last_req;
|
||||||
krb5_timestamp sec;
|
krb5_timestamp sec;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
krb5_boolean reported = FALSE;
|
||||||
|
|
||||||
krb5_timeofday (context, &sec);
|
krb5_timeofday (context, &sec);
|
||||||
|
|
||||||
@@ -148,26 +167,30 @@ print_expire (krb5_context context,
|
|||||||
7 * 24 * 60 * 60);
|
7 * 24 * 60 * 60);
|
||||||
|
|
||||||
for (i = 0; i < lr->len; ++i) {
|
for (i = 0; i < lr->len; ++i) {
|
||||||
if (abs(lr->val[i].lr_type) == LR_PW_EXPTIME
|
if (lr->val[i].lr_value <= t) {
|
||||||
&& lr->val[i].lr_value <= t) {
|
switch (abs(lr->val[i].lr_type)) {
|
||||||
char *p;
|
case LR_PW_EXPTIME :
|
||||||
time_t tmp = lr->val[i].lr_value;
|
report_expiration(context, prompter, data,
|
||||||
|
"Your password will expire at ",
|
||||||
asprintf (&p, "Your password will expire at %s", ctime(&tmp));
|
lr->val[i].lr_value);
|
||||||
(*prompter) (context, data, NULL, p, 0, NULL);
|
reported = TRUE;
|
||||||
free (p);
|
break;
|
||||||
return;
|
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) {
|
&& *rep->enc_part.key_expiration <= t) {
|
||||||
char *p;
|
report_expiration(context, prompter, data,
|
||||||
time_t t = *rep->enc_part.key_expiration;
|
"Your password/account will expire at ",
|
||||||
|
*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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user