aboutsummaryrefslogtreecommitdiffstats
path: root/agent/cache.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-09-04agent: Fix timer round-up check when inserting an entry into cache.NIIBE Yutaka1-1/+1
* agent/cache.c (insert_to_timer_list): Round up when >= a half second. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-09-01agent: Fix timer list management.NIIBE Yutaka1-2/+6
* agent/cache.c (insert_to_timer_list): Update TV_SEC of the top entry when inserted. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-09-01agent: Fix the previous commit.NIIBE Yutaka1-3/+0
* agent/cache.c (remove_from_timer_list_new): Fix cut&paste error. TV_SEC field should not be touched. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-08-31agent: Introduce management of timer to expire cache entries.NIIBE Yutaka1-84/+284
* agent/cache.c (struct timer_s): New. (struct cache_item_s): Add a member filed T for timer. (the_timer_list, the_timer_list_new): New. (insert_to_timer_list_new, insert_to_timer_list): New. (remove_from_timer_list, remove_from_timer_list_new): New. (housekeeping): Remove. (compute_expiration, update_expiration): New. (do_expire): New. (TIMERTICK_INTERVAL): Remove. (agent_cache_expiration): Use timer list to manage the expiration of cache entries. (agent_flush_cache): Call update_expiration when needed. (agent_put_cache): Don't call housekeeping any more, but update_expiration for an entry in question. (agent_get_cache): Likewise. -- GnuPG-bug-id: 6681 Signed-off-by: NIIBE Yutaka <[email protected]>
2023-08-30agent: Better interaction between main loop and cache expiration.NIIBE Yutaka1-11/+34
* agent/agent.h (agent_cache_housekeeping): Remove. (agent_cache_expiration): New. * agent/cache.c (agent_cache_housekeeping): Remove. (agent_cache_expiration): New. * agent/gpg-agent.c (TIMERTICK_INTERVAL): Remove. (handle_tick): Remove. (handle_connections): Call agent_cache_expiration and use the timeout value determined by the call. -- GnuPG-bug-id: 6681 Signed-off-by: NIIBE Yutaka <[email protected]>
2020-10-09agent: Fix SEGV when debuging for cache enabled.NIIBE Yutaka1-1/+1
* agent/cache.c (agent_get_cache): Avoid dereferencing NULL. Signed-off-by: NIIBE Yutaka <[email protected]>
2020-02-18Spelling cleanup.Daniel Kahn Gillmor1-1/+1
No functional changes, just fixing minor spelling issues. --- Most of these were identified from the command line by running: codespell \ --ignore-words-list fpr,stati,keyserver,keyservers,asign,cas,iff,ifset \ --skip '*.po,ChangeLog*,help.*.txt,*.jpg,*.eps,*.pdf,*.png,*.gpg,*.asc' \ doc g13 g10 kbx agent artwork scd tests tools am common dirmngr sm \ NEWS README README.maint TODO Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2020-01-09scd: Use a scdaemon internal key to protect the PIN cache IPC.Werner Koch1-1/+2
* agent/call-scd.c (handle_pincache_put): Do not decrypt. (handle_pincache_get): New. (inq_needpin): Call it. * scd/command.c (set_key_for_pincache): New. (pincache_put): Restructure and set key. (pincache_get): Ditto. -- This change does away with encrypting and decrypting the cached PIN in the agent. There is no need for this we can simply cache the cryptogram and let scdaemon decrypt after retrieving it from the agent. This way we do not need to share a key between gpg-agent and scdaemon and further the cached content is invalid after the scdaemon process has been replaced. Signed-off-by: Werner Koch <[email protected]>
2020-01-07agent: First changes to support a PIN cache for scdaemon.Werner Koch1-14/+41
* agent/agent.h (CACHE_MODE_PIN): New. * agent/cache.c (housekeeping): Special handling of new new mode. (agent_flush_cache): Ditto. Add arg 'pincache_only' and change caller. (agent_put_cache): Support new mode. (agent_get_cache): Ditto. * agent/call-scd.c (wait_child_thread): Flush the entire PIN cache. (start_scd): Ditto. (agent_card_killscd): Ditto. (handle_pincache_put): New. Uses a dummy encryption key for now. (pincache_put_cb): New. (inq_needpin): Prepare for PINCACHE_GET inquiry. (learn_status_cb): Handle the PINENTRY_PUT status line. (get_serialno_cb): Ditto (agent_card_pksign): Ditto. (padding_info_cb): Ditto. (agent_card_readcert): Ditto. (agent_card_readkey): Ditto. (agent_card_writekey): Ditto. (card_getattr_cb): Ditto. (card_cardlist_cb): Ditto. (card_keyinfo_cb): Ditto. (pass_status_thru): Ditto. -- Take care: This is not finished. Signed-off-by: Werner Koch <[email protected]>
2019-05-14agent: Replace most assert by log_assert.Werner Koch1-1/+0
--
2018-07-02agent: New commands PUT_SECRET and GET_SECRET.Werner Koch1-10/+24
* agent/agent.h (CACHE_MODE_DATA): New const. * agent/cache.c (DEF_CACHE_TTL_DATA): new. (housekeeping): Tweak for CACHE_MODE_DATA. (cache_mode_equal): Ditto. (agent_get_cache): Ditto. (agent_put_cache): Implement CACHE_MODE_DATA. * agent/command.c (MAXLEN_PUT_SECRET): New. (parse_ttl): New. (cmd_get_secret): New. (cmd_put_secret): New. (register_commands): Register new commands. -- These commands allow to store secrets in memory for the lifetime of the gpg-agent process. Signed-off-by: Werner Koch <[email protected]>
2018-03-27agent: Make the request origin a part of the cache items.Werner Koch1-16/+22
* agent/cache.c (agent_put_cache): Add arg 'ctrl' and change all callers to pass it. (agent_get_cache): Ditto. * agent/cache.c (struct cache_items_s): Add field 'restricted'. (housekeeping): Adjust debug output. (agent_flush_cache): Ditto. (agent_put_cache): Ditto. Take RESTRICTED into account. (agent_get_cache): Ditto. -- If requests are coming from different sources they should not share the same cache. This way we make sure that a Pinentry pops up for a remote request to a key we have already used locally. GnuPG-bug-id: 3858 Signed-off-by: Werner Koch <[email protected]>
2018-03-06agent: Also evict cached items via a timer.Werner Koch1-0/+20
* agent/cache.c (agent_cache_housekeeping): New func. * agent/gpg-agent.c (handle_tick): Call it. -- This change mitigates the risk of having cached items in a post mortem dump. GnuPG-bug-id: 3829 Signed-off-by: Werner Koch <[email protected]>
2017-04-06agent: Serialize access to passphrase cache.NIIBE Yutaka1-36/+37
* agent/cache.c (encryption_lock): Remove. (cache_lock): New. Now, we have coarse grain lock to serialize entire cache access. (initialize_module_cache): Use CACHE_LOCK. (init_encryption, new_data): Remove ENCRYPTION_LOCK. (agent_flush_cache, agent_put_cache, agent_get_cache): Lock the cache. -- GnuPG-bug-id: 3027 Signed-off-by: NIIBE Yutaka <[email protected]>
2017-02-01Fix explanation of commit e175152ef7515921635bf1e00383e812668d13fc.Werner Koch1-3/+5
--
2017-01-30Explain commit e175152ef7515921635bf1e00383e812668d13fc.Werner Koch1-1/+9
--
2017-01-25agent: Fix double free.Justus Winter1-2/+15
* agent/cache.c (agent_store_cache_hit): Make sure the update is atomic. -- Previously, the function freed the last key, and duplicated the new key after doing that. There is a chance, however, that calling the allocator surrenders control to a different thread, causing a double free if a different thread also calls this function. To make sure the update is atomic under the non-preemptive thread model, we must make sure not to surrender control to a different thread. Therefore, we avoid calling the allocator during the update. Signed-off-by: Justus Winter <[email protected]>
2016-11-05Change all http://www.gnu.org in license notices to https://Werner Koch1-1/+1
--
2016-07-18agent: Fix passphrase cache lookups.Justus Winter1-2/+11
CACHE_MODE_ANY is supposed to match any cache mode except CACHE_MODE_IGNORE, but the code used '==' to compare cache modes. * agent/cache.c (cache_mode_equal): New function. (agent_set_cache): Use the new function to compare cache modes. (agent_get_cache): Likewise. * tests/openpgp/Makefile.am (TESTS): Add new test. * tests/openpgp/issue2015.scm: New file. GnuPG-bug-id: 2015 Signed-off-by: Justus Winter <[email protected]>
2015-11-17Fix typos found using codespell.Justus Winter1-1/+1
* agent/cache.c: Fix typos. * agent/call-pinentry.c: Likewise. * agent/call-scd.c: Likewise. * agent/command-ssh.c: Likewise. * agent/command.c: Likewise. * agent/divert-scd.c: Likewise. * agent/findkey.c: Likewise. * agent/gpg-agent.c: Likewise. * agent/w32main.c: Likewise. * common/argparse.c: Likewise. * common/audit.c: Likewise. * common/audit.h: Likewise. * common/convert.c: Likewise. * common/dotlock.c: Likewise. * common/exechelp-posix.c: Likewise. * common/exechelp-w32.c: Likewise. * common/exechelp-w32ce.c: Likewise. * common/exechelp.h: Likewise. * common/helpfile.c: Likewise. * common/i18n.h: Likewise. * common/iobuf.c: Likewise. * common/iobuf.h: Likewise. * common/localename.c: Likewise. * common/logging.c: Likewise. * common/openpgp-oid.c: Likewise. * common/session-env.c: Likewise. * common/sexputil.c: Likewise. * common/sysutils.c: Likewise. * common/t-sexputil.c: Likewise. * common/ttyio.c: Likewise. * common/util.h: Likewise. * dirmngr/cdblib.c: Likewise. * dirmngr/certcache.c: Likewise. * dirmngr/crlcache.c: Likewise. * dirmngr/dirmngr-client.c: Likewise. * dirmngr/dirmngr.c: Likewise. * dirmngr/dirmngr_ldap.c: Likewise. * dirmngr/dns-stuff.c: Likewise. * dirmngr/http.c: Likewise. * dirmngr/ks-engine-hkp.c: Likewise. * dirmngr/ks-engine-ldap.c: Likewise. * dirmngr/ldap-wrapper.c: Likewise. * dirmngr/ldap.c: Likewise. * dirmngr/misc.c: Likewise. * dirmngr/ocsp.c: Likewise. * dirmngr/validate.c: Likewise. * g10/encrypt.c: Likewise. * g10/getkey.c: Likewise. * g10/gpg.c: Likewise. * g10/gpgv.c: Likewise. * g10/import.c: Likewise. * g10/keydb.c: Likewise. * g10/keydb.h: Likewise. * g10/keygen.c: Likewise. * g10/keyid.c: Likewise. * g10/keylist.c: Likewise. * g10/keyring.c: Likewise. * g10/mainproc.c: Likewise. * g10/misc.c: Likewise. * g10/options.h: Likewise. * g10/packet.h: Likewise. * g10/parse-packet.c: Likewise. * g10/pkclist.c: Likewise. * g10/pkglue.c: Likewise. * g10/plaintext.c: Likewise. * g10/server.c: Likewise. * g10/sig-check.c: Likewise. * g10/sqlite.c: Likewise. * g10/tdbio.c: Likewise. * g10/test-stubs.c: Likewise. * g10/tofu.c: Likewise. * g10/trust.c: Likewise. * g10/trustdb.c: Likewise. * g13/create.c: Likewise. * g13/mountinfo.c: Likewise. * kbx/keybox-blob.c: Likewise. * kbx/keybox-file.c: Likewise. * kbx/keybox-init.c: Likewise. * kbx/keybox-search-desc.h: Likewise. * kbx/keybox-search.c: Likewise. * kbx/keybox-update.c: Likewise. * scd/apdu.c: Likewise. * scd/app-openpgp.c: Likewise. * scd/app-p15.c: Likewise. * scd/app.c: Likewise. * scd/ccid-driver.c: Likewise. * scd/command.c: Likewise. * scd/iso7816.c: Likewise. * sm/base64.c: Likewise. * sm/call-agent.c: Likewise. * sm/call-dirmngr.c: Likewise. * sm/certchain.c: Likewise. * sm/gpgsm.c: Likewise. * sm/import.c: Likewise. * sm/keydb.c: Likewise. * sm/minip12.c: Likewise. * sm/qualified.c: Likewise. * sm/server.c: Likewise. * tools/gpg-check-pattern.c: Likewise. * tools/gpgconf-comp.c: Likewise. * tools/gpgkey2ssh.c: Likewise. * tools/gpgparsemail.c: Likewise. * tools/gpgtar.c: Likewise. * tools/rfc822parse.c: Likewise. * tools/symcryptrun.c: Likewise. Signed-off-by: Justus Winter <[email protected]>
2014-09-17gpg: Improve passphrase caching.Werner Koch1-1/+28
* agent/cache.c (last_stored_cache_key): New. (agent_get_cache): Allow NULL for KEY. (agent_store_cache_hit): New. * agent/findkey.c (unprotect): Call new function and try to use the last stored key. * g10/revoke.c (create_revocation): Add arg CACHE_NONCE and pass to make_keysig_packet. (gen_standard_revoke): Add arg CACHE_NONCE and pass to create_revocation. * g10/keygen.c (do_generate_keypair): Call gen_standard_revoke with cache nonce. -- This patch adds two features: 1. The key for the last passphrase successfully used for unprotecting a key is stored away. On a cache miss the stored away passphrase is tried as well. This helps for the common GPG use case of having a signing and encryption (sub)key with the same passphrase. See the code for more comments. 2. The now auto-generated revocation certificate does not anymore popup a passphrase prompt. Thus for standard key generation the passphrase needs to be given only once (well, two with the confirmation).
2012-06-05Change all quotes in strings and comments to the new GNU standard.Werner Koch1-7/+7
The asymmetric quotes used by GNU in the past (`...') don't render nicely on modern systems. We now use two \x27 characters ('...'). The proper solution would be to use the correct Unicode symmetric quotes here. However this has the disadvantage that the system requires Unicode support. We don't want that today. If Unicode is available a generated po file can be used to output proper quotes. A simple sed script like the one used for en@quote is sufficient to change them. The changes have been done by applying sed -i "s/\`\([^'\`]*\)'/'\1'/g" to most files and fixing obvious problems by hand. The msgid strings in the po files were fixed with a similar command.
2012-01-25Port to npth.Marcus Brinkmann1-19/+33
* configure.ac: Don't check for PTH but for NPTH. (AH_BOTTOM): Remove PTH_SYSCALL_SOFT. (have_pth): Rename to ... (have_npth): ... this. (USE_GNU_NPTH): Rename to ... (USE_GNU_PTH): ... this. * m4/npth.m4: New file. * agent/Makefile.am, agent/cache.c, agent/call-pinentry.c, agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c, agent/trustlist.c, common/Makefile.am, common/estream.c, common/exechelp-posix.c, common/exechelp-w32.c, common/exechelp-w32ce.c, common/http.c, common/init.c, common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c, dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c, dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am, g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am, scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c, scd/scdaemon.c, tools/Makefile.am: Port to npth.
2011-02-04Nuked almost all trailing white space.post-nuke-of-trailing-wsWerner Koch1-6/+5
We better do this once and for all instead of cluttering all future commits with diffs of trailing white spaces. In the majority of cases blank or single lines are affected and thus this change won't disturb a git blame too much. For future commits the pre-commit scripts checks that this won't happen again.
2010-11-29Init cache encryption on the fly.Werner Koch1-20/+50
add some debug code
2010-10-26Re-implemented GPG's --passwd command and improved it.Werner Koch1-1/+1
2010-09-13Fix standard directories for Wince.Werner Koch1-1/+1
Typo fix.
2010-09-02Obscure the cached passphrases.Werner Koch1-123/+170
2010-09-01s/CACHE_MODE_IMPGEN/CACHE_MODE_NONCE/.Werner Koch1-4/+4
Prepare for more use cases of the cache nonce.
2010-09-01Use passphrase caching for import and genkey.Werner Koch1-11/+25
2009-05-15Fix bug #1053Werner Koch1-2/+2
Add option --qualitybar to command GET_PASSPHRASE.
2007-07-04Changed to GPLv3.Werner Koch1-4/+2
Removed intl/.
2006-06-20Updated FSF's address.Werner Koch1-1/+2
2005-07-27Removed directories which are only used by the 1.9 branchWerner Koch1-314/+0
2005-06-16gcc-4 defaults forced me to edit many many files to get rid of theWerner Koch1-6/+14
char * vs. unsigned char * warnings. The GNU coding standards used to say that these mismatches are okay and better than a bunch of casts. Obviously this has changed now.
2005-06-07New debugging optionhs, updates to the manual.Werner Koch1-10/+26
2005-01-04(agent_put_cache): Fix the test for using the defaultWerner Koch1-4/+5
TTL.
2004-12-21* preset-passphrase.c (preset_passphrase): Handle --passphrase.Werner Koch1-4/+5
* Makefile.am (gpg_preset_passphrase_LDADD): Reorder libs so that pwquery may use stuff from jnlib. Conditionally add -lwsock2 (gpg_protect_tool_LDADD): Ditto. * preset-passphrase.c (main): Use default_homedir(). (main) [W32]: Initialize sockets. * simple-pwquery.c (agent_open) [W32]: Implement for W32. (readline) [W32]: Use recv instead of read. (writen) [W32]: Use send instead of write. (my_stpcpy): Define a stpcpy replacement so that this file continues to be self-contained. (agent_send_all_options) [W32]: Don't call ttyname. * gnupg-badge-openpgp.eps, gnupg-badge-openpgp.jpg: New * gnupg.texi: Add a logo. * sysnotes.texi: New. * gpgsm.c (main): Use default_homedir(). (main) [W32]: Default to disabled CRL checks. * gpgconf-comp.c (get_config_pathname) [DOSISH]: Detect absolute pathnames with a drive letter.
2004-08-20* gpg-agent.c: New option --max-cache-ttl. Suggested by AlexanderWerner Koch1-2/+3
Belopolsky. * cache.c (housekeeping): Use it here instead of the hardwired default of 1 hour.
2003-01-09This commit was manufactured by cvs2svn to create branchRepo Admin1-0/+314
'GNUPG-1-9-BRANCH'.
2003-01-09Updated from latest NewPG projectWerner Koch1-1/+1
2002-10-19This commit was manufactured by cvs2svn to create branchRepo Admin1-314/+0
'GNUPG-1-9-BRANCH'.
2002-09-26* gpg-agent.c (handle_signal): Flush cache on SIGHUP.Werner Koch1-0/+29
* cache.c (agent_flush_cache): New. * gpg-agent.c, agent.h: Add --keep-display and --keep-tty. * query.c (start_pinentry): Implement them. The option passing needs more thoughts.
2002-05-23* no-pth.c, Makefile.am: Removed.Werner Koch1-18/+64
* call-scd.c: Seirialized all scdaeom access when using Pth. * cache.c: Made the cache Pth-thread-safe. (agent_unlock_cache_entry): New. * findkey.c (unprotect): Unlock the returned cache value. * command.c (cmd_get_passphrase): Ditto. * gpg-agent.c (main): Register pth_read/write with Assuan.
2002-05-14sm/Werner Koch1-4/+4
* gpgsm.c: New option --faked-system-time * sign.c (gpgsm_sign): And use it here. * certpath.c (gpgsm_validate_path): Ditto. common/ * gettime.c: New. agent/ * cache.c (housekeeping, agent_put_cache): Use our time() wrapper. / * doc/: New * configure.ac, Makefile.am: Added doc/
2002-04-27Debug message cleanups.Werner Koch1-1/+3
Fixed passphrase caching.
2002-03-18Doc fixes, moved some fizmes to TODO, fixed minor bugs.Werner Koch1-1/+1
2002-02-06* cache.c (housekeeping): Fixed linking in the remove case.Werner Koch1-2/+4
2002-02-01* cache.c: Add a few debug outputs.Werner Koch1-0/+15
* protect.c (agent_private_key_type): New. * agent.h: Add PRIVATE_KEY_ enums. * findkey.c (agent_key_from_file): Use it to decide whether we have to unprotect a key. (unprotect): Cache the passphrase. * findkey.c (agent_key_from_file,agent_key_available): The key files do now require a ".key" suffix to make a script's life easier. * genkey.c (store_key): Ditto.
2002-01-31* genkey.c (store_key): Protect the key.Werner Koch1-2/+2
(agent_genkey): Ask for the passphrase. * findkey.c (unprotect): Actually unprotect the key. * query.c (agent_askpin): Add an optional start_err_text.