From 298575c651829afd0959483a970053811a49dbc5 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Fri, 1 Aug 1997 15:28:31 +0000 Subject: [PATCH] check for and print expiry information in the `kdc_rep' git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2677 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kuser/kinit.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/kuser/kinit.c b/kuser/kinit.c index 832ba621a..f13077f41 100644 --- a/kuser/kinit.c +++ b/kuser/kinit.c @@ -71,6 +71,30 @@ usage (void) exit (1); } +/* + * Check expiration information + */ + +static void +print_expire (krb5_context context, + krb5_kdc_rep *k) +{ + int i; + LastReq *lr = &k->part2.last_req; + + for (i = 0; i < lr->len; ++i) { + if (lr->val[i].lr_type == 6) { + printf ("Your password will expire at %s", + ctime(&lr->val[i].lr_value)); + return; + } + } + + if (k->part2.key_expiration) + printf ("Your password/account will expire at %s", + ctime(k->part2.key_expiration)); +} + int main (int argc, char **argv) { @@ -84,6 +108,7 @@ main (int argc, char **argv) int c; char *realm; char pwbuf[128]; + krb5_kdc_rep kdc_rep; union { krb5_flags i; @@ -197,12 +222,15 @@ main (int argc, char **argv) pwbuf, ccache, &cred, - NULL); + &kdc_rep); memset(pwbuf, 0, sizeof(pwbuf)); if (ret) errx (1, "krb5_get_in_tkt_with_password: %s", krb5_get_err_text(context, ret)); + print_expire (context, &kdc_rep); + + krb5_free_kdc_rep (context, &kdc_rep); krb5_free_principal (context, principal); krb5_free_principal (context, server); krb5_free_ccache (context, ccache);