diff options
author | NIIBE Yutaka <[email protected]> | 2025-05-09 02:30:23 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2025-05-13 00:03:09 +0000 |
commit | 5fb338168ed626a6fc882ccd298288f5b121aa4d (patch) | |
tree | 9ef4d5534ef62d62824d4ab40a3d4c98037ee358 /agent/cache.c | |
parent | gpg: Fully implement the group key flag. (diff) | |
download | gnupg-5fb338168ed626a6fc882ccd298288f5b121aa4d.tar.gz gnupg-5fb338168ed626a6fc882ccd298288f5b121aa4d.zip |
agent: Recover the old behavior with max-cache-ttl=0.
* agent/cache.c (compute_expiration): Expire newly created entry when
max-cache-ttl is zero.
--
Fixes-commit: 92de0387f04b1e87a4a49ed063323624f25ac3ef
GnuPG-bug-id: 6681
Suggested-by: Lucas Mulling <[email protected]>
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'agent/cache.c')
-rw-r--r-- | agent/cache.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/agent/cache.c b/agent/cache.c index e8544205f..0a4a6fbbc 100644 --- a/agent/cache.c +++ b/agent/cache.c @@ -330,45 +330,41 @@ compute_expiration (ITEM r) return 1; } - switch (r->cache_mode) + if (r->cache_mode == CACHE_MODE_DATA) { - case CACHE_MODE_DATA: - case CACHE_MODE_PIN: - maxttl = 0; /* No MAX TTL here. */ - break; - case CACHE_MODE_SSH: maxttl = opt.max_cache_ttl_ssh; break; - default: maxttl = opt.max_cache_ttl; break; - } - - if (maxttl) - { - if (r->created + maxttl < current) + /* No MAX TTL here. */ + if (r->ttl >= 0) { - r->t.tv_sec = 0; + r->t.tv_sec = r->ttl; r->t.reason = CACHE_EXPIRE_CREATION; return 1; } - - next = r->created + maxttl - current; + else + return 0; } + else if (r->cache_mode == CACHE_MODE_SSH) + maxttl = opt.max_cache_ttl_ssh; else - next = 0; + maxttl = opt.max_cache_ttl; - if (r->ttl >= 0 && (next == 0 || r->ttl < next)) + if (r->created + maxttl <= current) { - r->t.tv_sec = r->ttl; - r->t.reason = CACHE_EXPIRE_LAST_ACCESS; + r->t.tv_sec = 0; + r->t.reason = CACHE_EXPIRE_CREATION; return 1; } - if (next) + next = r->created + maxttl - current; + if (r->ttl >= 0 && r->ttl < next) { - r->t.tv_sec = next; - r->t.reason = CACHE_EXPIRE_CREATION; + r->t.tv_sec = r->ttl; + r->t.reason = CACHE_EXPIRE_LAST_ACCESS; return 1; } - return 0; + r->t.tv_sec = next; + r->t.reason = CACHE_EXPIRE_CREATION; + return 1; } static void |