Page MenuHome GnuPG

max-cache-ttl appears to be ignored if default-cache-ttl is unset
Closed, ResolvedPublic

Description

If I set max-cache-ttl in gpg-agent.conf to 1 and I don't set default-cache-ttl,
max-cache-ttl appears to be ignored. In agent/gpg-agent.c, there is the
following function:

  static void
  finalize_rereadable_options (void)
  {
    /* It would be too surprising if the max-cache-ttl is lower than the
       default-cache-ttl - thus we silently correct that.  */
    if (opt.def_cache_ttl > opt.max_cache_ttl)
      opt.max_cache_ttl = opt.def_cache_ttl;
    if (opt.def_cache_ttl_ssh > opt.max_cache_ttl_ssh)
      opt.max_cache_ttl_ssh = opt.def_cache_ttl_ssh;
  }

This raises max-cache-ttl to be at least default-cache-ttl. As
default-cache-ttl is unset, it has the default value of 600 and max-cache-ttl is
increased accordingly.

I think think this behavior is wrong. The minimal change (in terms of changes
to the current semantics) is to raise max-cache-ttl only if default-cache-ttl
was actually set. However, I think the better approach is to not do this fixup
at all; I'm surprised that someone thinks the current behavior is not surprising.

Details

Version
2.1

Event Timeline

neal added projects: gnupg, Bug Report.
neal set Version to 2.1.
neal added a subscriber: werner.
neal added a subscriber: neal.

The attached patch fixes this problem, by not adjusting opt.max_cache_ttl or
opt.max_cache_ttl_ssh. Okay to apply?

I've now pushed this patch.