#544379 gpg-agent: infinite cache support

#544379#5
Date:
2009-08-31 04:12:28 UTC
From:
To:
I would like to be able to have gpg-agent cache passphrases infinitly.
Poking around the source I find in agent/cache.c line 41

  int ttl;  /* max. lifetime given in seconds, -1 one means infinite */

and lines 193-198

/* Store DATA of length DATALEN in the cache under KEY and mark it
   with a maximum lifetime of TTL seconds.  If there is already data
   under this key, it will be replaced.  Using a DATA of NULL deletes
   the entry.  A TTL of 0 is replaced by the default TTL and a TTL of
   -1 set infinite timeout.  CACHE_MODE is stored with the cache entry
   and used to select different timeouts.  */

So maybe this should work by specifying -1 for the various *-cache-ttl*
options, but I couldn't get it to work. For me it does the same thing as if
I had specified zero, it prompts me every time.

So this is a wishlist request for infinite timeout support (and documention
on the gpg-agent manpage).

(just in case you are wondering _why_ I would want an infinite timeout...
This is for an automated signing process; I intend to login once after
reboot and specify the passphrase where it will stay in memory until the
machine is powered off.  This is preferrable to leaving the key unlocked on
the machine or the passphrase in a file somewhere.)

Thanks,

#544379#10
Date:
2014-09-18 21:50:42 UTC
From:
To:
Sorry, I hit C-c C-c before finishing :-).

Anyway, as I was saying, the current code converts "unsigned long" to
"int", which is a problem itself.  But the main problem is that the code
doesn't seem to check if the cache entry should be infinite or not (as
promised in the comment you mentioned).

I will see if I can work on a patch for this.

#544379#15
Date:
2014-09-18 21:47:29 UTC
From:
To:
I agree this would be a good feature :-).

However, I investigated the code a little more and came to a few
conclusions.  There is a bug in the current code, because the TTL's are
stored using "unsigned long" types, but when they get passed to the
caching mechanism, it gets converted to "int"