Setting max-cache-ttl to 0 does not disable caching

Lucas Mulling lucas.mulling at suse.com
Thu May 8 20:33:50 CEST 2025


Hello,

On Wed May 7, 2025 at 11:20 PM -03, NIIBE Yutaka wrote:
> To disable caching, I think that you can do by:
>
> 	default-cache-ttl 0
>
Can confirm that this works.

> Possible fix to recover the same semantics would be the following.
>
> ==========================
> diff --git a/agent/cache.c b/agent/cache.c
> index e8544205f..fbe1c1f14 100644
> --- a/agent/cache.c
> +++ b/agent/cache.c
> @@ -318,6 +318,7 @@ compute_expiration (ITEM r)
>    unsigned long maxttl;
>    time_t current = gnupg_get_time ();
>    time_t next;
> +  int no_maxttl = 0;
>  
>    if (r->cache_mode == CACHE_MODE_PIN)
>      return 0; /* Don't let it expire - scdaemon explicitly flushes them.  */
> @@ -334,13 +335,16 @@ compute_expiration (ITEM r)
>      {
>      case CACHE_MODE_DATA:
>      case CACHE_MODE_PIN:
> -      maxttl = 0;  /* No MAX TTL here.  */
> +      no_maxttl = 1;
> +      /* 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 (no_maxttl)
> +    next = 0;
> +  else
>      {
>        if (r->created + maxttl < current)
>          {
> @@ -351,8 +355,6 @@ compute_expiration (ITEM r)
>  
>        next = r->created + maxttl - current;
>      }
> -  else
> -    next = 0;
>  
>    if (r->ttl >= 0 && (next == 0 || r->ttl < next))
>      {
Tested the patch but could not make it work by only setting
max-cache-ttl 0



More information about the Gnupg-devel mailing list