From cdb7e56a986c87b1ce82c69c871f2bc6d0447eb8 Mon Sep 17 00:00:00 2001 From: mdw Date: Fri, 22 Jun 2001 19:39:12 +0000 Subject: [PATCH] New interface to find out whether a key has expired. Also, a bug fix to @key_bytag@ so that it finds expired keys correctly. --- key-misc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/key-misc.c b/key-misc.c index 12a5f21..afd0a4b 100644 --- a/key-misc.c +++ b/key-misc.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: key-misc.c,v 1.2 2000/02/12 18:21:02 mdw Exp $ + * $Id: key-misc.c,v 1.3 2001/06/22 19:39:12 mdw Exp $ * * Simple key management * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: key-misc.c,v $ + * Revision 1.3 2001/06/22 19:39:12 mdw + * New interface to find out whether a key has expired. Also, a bug fix + * to @key_bytag@ so that it finds expired keys correctly. + * * Revision 1.2 2000/02/12 18:21:02 mdw * Overhaul of key management (again). * @@ -174,7 +178,7 @@ key *key_bytag(key_file *f, const char *tag) uint32 id; key_ref *kr = sym_find(&f->bytag, tag, -1, 0, 0); - if (kr && !(KEY_EXPIRED(t, kr->k->exp) && KEY_EXPIRED(t, kr->k->exp))) + if (kr && !(KEY_EXPIRED(t, kr->k->exp) && KEY_EXPIRED(t, kr->k->del))) return (kr->k); id = strtoul(tag, &p, 16); if (!*p) @@ -294,6 +298,19 @@ int key_delete(key_file *f, key *k) return (0); } +/* --- @key_expired@ --- * + * + * Arguments: @key *k@ = pointer to key block + * + * Returns: Zero if the key is OK, nonzero if it's expired. + */ + +int key_expired(key *k) +{ + time_t now = time(0); + return (KEY_EXPIRED(now, k->exp) || KEY_EXPIRED(now, k->del)); +} + /* --- @key_expire@ --- * * * Arguments: @key_file *f@ = pointer to file block -- 2.11.0