aboutsummaryrefslogtreecommitdiffstats
path: root/agent/gpg-agent.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-07-20agent: Avoid scheduled checks on socket when inotify is working.Daniel Kahn Gillmor1-0/+2
* agent/gpg-agent.c (handle_connections): When inotify is working, we do not need to schedule a timer to evaluate whether we control our own socket or not. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Gbp-Pq: Topic gpg-agent-idling Gbp-Pq: Name agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch
2019-07-20agent: Avoid tight timer tick when possible.Daniel Kahn Gillmor1-2/+27
* agent/gpg-agent.c (need_tick): Evaluate whether the short-phase handle_tick() is needed. (handle_connections): On each cycle of the select loop, adjust whether we should call handle_tick() or not. (start_connection_thread_ssh, do_start_connection_thread): Signal the main loop when the child terminates. * agent/call-scd.c (start_scd): Call interrupt_main_thread_loop() once the scdaemon thread context has started up. -- With this change, an idle gpg-agent that has no scdaemon running only wakes up once a minute (to check_own_socket). Thanks to Ian Jackson and NIIBE Yutaka who helped me improve some of the blocking and corner cases. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Gbp-Pq: Topic gpg-agent-idling Gbp-Pq: Name agent-Avoid-tight-timer-tick-when-possible.patch
2019-07-20agent: Allow threads to interrupt main select loop with SIGCONT.Daniel Kahn Gillmor1-0/+16
* agent/gpg-agent.c (interrupt_main_thread_loop): New function on non-windows platforms, allows other threads to interrupt the main loop if there's something that the main loop might be interested in. -- For example, the main loop might be interested in changes in program state that affect the timers it expects to see. I don't know how to do this on Windows platforms, but i welcome any proposed improvements. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Gbp-Pq: Topic gpg-agent-idling Gbp-Pq: Name agent-Allow-threads-to-interrupt-main-select-loop-wi.patch
2019-07-20agent: Create framework of scheduled timers.Daniel Kahn Gillmor1-27/+57
agent/gpg-agent.c (handle_tick): Remove intermittent call to check_own_socket. (tv_is_set): Add inline helper function for readability. (handle_connections) Create general table of pending scheduled timeouts. -- handle_tick() does fine-grained, rapid activity. check_own_socket() is supposed to happen at a different interval. Mixing the two of them makes it a requirement that one interval be a multiple of the other, which isn't ideal if there are different delay strategies that we might want in the future. Creating an extensible regular timer framework in handle_connections should make it possible to have any number of cadenced timers fire regularly, without requiring that they happen in cadences related to each other. It should also make it possible to dynamically change the cadence of any regularly-scheduled timeout. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Gbp-Pq: Topic gpg-agent-idling Gbp-Pq: Name agent-Create-framework-of-scheduled-timers.patch
2019-07-20Avoid simple memory dumps via ptraceDaniel Kahn Gillmor1-0/+8
This avoids needing to setgid gpg-agent. It probably doesn't defend against all possible attacks, but it defends against one specific (and easy) one. If there are other protections we should do them too. This will make it slightly harder to debug the agent because the normal user won't be able to attach gdb to it directly while it runs. The remaining options for debugging are: * launch the agent from gdb directly * connect gdb to a running agent as the superuser Upstream bug: https://dev.gnupg.org/T1211 Gbp-Pq: Topic block-ptrace-on-secret-daemons Gbp-Pq: Name Avoid-simple-memory-dumps-via-ptrace.patch
2019-06-24spelling: Fix "synchronize"Daniel Kahn Gillmor1-1/+1
Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2019-05-27agent: Stop scdaemon after reload when disable_scdaemon.NIIBE Yutaka1-0/+3
* agent/call-scd.c (agent_card_killscd): New. * agent/gpg-agent.c (agent_sighup_action): Call agent_card_killscd. -- GnuPG-bug-id: 4326 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-12-11agent: Make the S2K calibration time runtime configurable.Werner Koch1-0/+7
* agent/protect.c (s2k_calibration_time): New file global var. (calibrate_s2k_count): Use it here. (get_calibrated_s2k_count): Replace function static var by ... (s2k_calibrated_count): new file global var. (set_s2k_calibration_time): New function. * agent/gpg-agent.c (oS2KCalibration): New const. (opts): New option --s2k-calibration. (parse_rereadable_options): Parse that option. -- Note that using an unrelistic high value (like 60000) takes quite some time for calibration. GnuPG-bug-id: 3399 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit cbcc8c19541fe8407f3b6588fce1535c64cf6b25)
2018-06-06agent: Add DBUS_SESSION_BUS_ADDRESS et al. to the startup list.Werner Koch1-7/+7
* agent/gpg-agent.c (agent_copy_startup_env): Replace explicit list with the standard list. -- Although the function agent_copy_startup_env is newer than session_env_list_stdenvnames the latter was not used. When DBUS_SESSION_BUS_ADDRESS was added to the latter it was forgotten to add it to the former as well. Having all stdnames here seems to be the Right Thing (tm) to do. GnuPG-bug-id: 3947 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 7ffc1ac7dd95d4cc1897a4c36d5cd628741c12f2)
2018-03-06agent: Also evict cached items via a timer.Werner Koch1-0/+3
* 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-12-12Change backlog from 5 to 64 and provide option --listen-backlog.Werner Koch1-2/+14
* agent/gpg-agent.c (oListenBacklog): New const. (opts): New option --listen-backlog. (listen_backlog): New var. (main): Parse new options. (create_server_socket): Use var instead of 5. * dirmngr/dirmngr.c: Likewise. * scd/scdaemon.c: Likewise. -- GnuPG-bug-id: 3473 Signed-off-by: Werner Koch <[email protected]>
2017-12-07agent: Change intialization of assuan socket system hooks.NIIBE Yutaka1-1/+2
* agent/gpg-agent.c (initialize_modules): Add hook again. (main): Remove setting of the system houk but add scoket system hook setting after assuan initialization. -- Thread initialization is better to be deferred after fork (in case of UNIX). assuan_sock_init should be earlier. Thus, we need to change system hooks for assuan_sock_* interface. Or else, on Windows, it may cause hang on server. Updates-commit: 1524ba9656f0205d8c6ef504f773b832a7a12ab9 GnuPG-bug-id: 3378 Signed-off-by: Werner Koch <[email protected]>
2017-12-06agent: Set assuan system hooks before call of assuan_sock_init.NIIBE Yutaka1-1/+1
* agent/gpg-agent.c (initialize_modules): Move assuan_set_system_hooks. (main): ... here, just before assuan_sock_init. -- In Assuan, global variable SOCK_CTX is used internally, which is initialized by assuan_sock_init. When initialized, system hooks are copied into SOCK_CTX structure. Thus, system hooks should be set, before the call of assuan_sock_init. GnuPG-bug-id: 3378 Signed-off-by: NIIBE Yutaka <[email protected]>
2017-11-24agent: New option --auto-expand-secmem.Werner Koch1-0/+11
* agent/gpg-agent.c (oAutoExpandSecmem): New enum value. (opts): New option --auto-expand-secmem. (main): Implement that option. -- Note that this option has an effect only if Libgcrypt >= 1.8.2 is used. GnuPG-bug-id: 3530
2017-11-20gpg-agent: Avoid getting stuck in shutdown pending state.Werner Koch1-15/+22
* agent/gpg-agent.c (handle_connections): Always check inotify fds. -- I noticed a gpg-agent processed, probably in shutdown_pending state, which was selecting on only these two inotify fds. The select returned immediately but because we did not handle the fds in shutdown_pending state they were not read and the next select call returned one of them immediately again. Actually that should not hanppen because the if (active_connections == 0) break; /* ready */ should have terminated the loop. For unknown reasons (maybe be just a connection thread terminated in a gdb session) that did not happen. By moving the check outside of the shutdown_pending condition and closing the fd after they have been triggered the code should be more robust. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 5d83eb9226c0ce608ec284d8c9bc22ce84a00c25)
2017-11-06agent: New option --s2k-count.Werner Koch1-0/+9
* agent/agent.h (opt): New field 's2k_count'. * agent/gpg-agent.c (oS2KCount): New enum value. (opts): New option --s2k-count. (parse_rereadable_options): Set opt.s2k_count. -- This option is useful to speed up the starting of gpg-agent and in cases where the auto-calibration runs into problems due to a broken time measurement facility. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit f7212f1d11aad5d910d2c77b2e5c6ab31a0e786e)
2017-08-07Simple typo fix.Daniel Kahn Gillmor1-1/+1
* agent/gpg-agent.c: Correct spelling in comment. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2017-08-04agent: Make --no-grab the default.Werner Koch1-3/+13
* agent/gpg-agent.c (oGrab): New const. (opts): New option --grab. Remove description for --no-grab. (parse_rereadable_options): Make --no-grab the default. (finalize_rereadable_options): Allow --grab to override --no-grab. (main) <gpgconflist>: Add "grab". * tools/gpgconf-comp.c (gc_options_gpg_agent): Add "grab". Signed-off-by: Werner Koch <[email protected]>
2017-07-28agent: Make --ssh-fingerprint-digest re-readable.Werner Koch1-6/+15
* agent/gpg-agent.c (main): Move oSSHFingerprintDigest to ... (parse_rereadable_options): here. (opts): Change its description. (main) <aGPGConfList>: Include this option. * tools/gpgconf-comp.c (gc_options_gpg_agent): Add option at expert level. Signed-off-by: Werner Koch <[email protected]>
2017-07-26agent,dirmngr: Check for homedir removal also using stat(2).Werner Koch1-3/+30
* agent/gpg-agent.c (have_homedir_inotify): New var. (reliable_homedir_inotify): New var. (main): Set reliable_homedir_inotify. (handle_tick): Call stat on the homedir. (handle_connections): Mark availibility of the inotify watch. * dirmngr/dirmngr.c (handle_tick): Call stat on the homedir. (TIMERTICK_INTERVAL_SHUTDOWN): New. (handle_connections): Depend tick interval on the shutdown state. -- The stat call is used on systems which do not support inotify and also when we assume that the inotify does not work reliable. Signed-off-by: Werner Koch <[email protected]>
2017-07-26agent: Lengthen timertick interval on Unix to 4 seconds.Werner Koch1-9/+7
* agent/gpg-agent.c (TIMERTICK_INTERVAL): Same value for Windows and Unix. Signed-off-by: Werner Koch <[email protected]>
2017-07-25w32: Also change the directory on daemon startup.Werner Koch1-7/+7
* agent/gpg-agent.c (main): Always to the chdir. * dirmngr/dirmngr.c (main): Ditto. * scd/scdaemon.c (main): Ditto. -- Note that only dirmngr did not call the chdir with --no-detach. thus we kept it this way. Tested gpg-agent by checking the properties shown by procexp. Gnupg-bug-id: 2670 Signed-off-by: Werner Koch <[email protected]>
2017-07-25common: New functions gnupg_daemon_rootdir and gnupg_chdir.Werner Koch1-2/+3
* common/sysutils.c (gnupg_chdir): New. * common/homedir.c (gnupg_daemon_rootdir): New. * agent/gpg-agent.c (main): Use these functions instead chdir("/"). * dirmngr/dirmngr.c (main): Ditto. * scd/scdaemon.c (main): Ditto. -- Signed-off-by: Werner Koch <[email protected]>
2017-07-25Revert "w32: Change directory on daemon startup."Werner Koch1-6/+0
-- This reverts commit 78ebc62604d77600b9865950610717d28c6027a2. Gnupg-bug-id: 2670
2017-07-24w32: Change directory on daemon startup.Marcus Brinkmann1-0/+6
* agent/gpg-agent.c [HAVE_W32_SYSTEM]: Include <direct.h>. (main) [HAVE_W32_SYSTEM]: Change working directory to \. * dirmngr/dirmngr.c [HAVE_W32_SYSTEM]: Include <direct.h>. (main) [HAVE_W32_SYSTEM]: Change working directory to \. * scd/scdaemon.c [HAVE_W32_SYSTEM]: Include <direct.h>. (main) [HAVE_W32_SYSTEM]: Change working directory to \. Signed-off-by: Marcus Brinkmann <[email protected]> GnuPG-bug-id: 2670
2017-07-19Fix usage of ARGPARSE_OPTS.NIIBE Yutaka1-1/+1
* agent/gpg-agent.c, agent/preset-passphrase.c, dirmngr/dirmngr-client.c, dirmngr/dirmngr_ldap.c, kbx/kbxutil.c, tools/gpg-check-pattern.c, tools/gpgconf.c, tools/gpgsplit.c, tools/symcryptrun.c: Use ARGPARSE_end. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-06-28agent: Fix option --debug-waitWerner Koch1-1/+1
* agent/gpg-agent.c (opts): Typo fix. -- Regression-due-to: ccee34736b57a42ec4bdcb0d3181bdc6a08b0fff GnuPG-bug-id: 3225 Signed-off-by: Werner Koch <[email protected]>
2017-06-23agent: Shutdown on removal of the home directory.Werner Koch1-16/+48
* common/sysutils.c (gnupg_inotify_watch_delete_self): New. * agent/gpg-agent.c (handle_connections): Rename my_inotify_fd to sock_inotify_fd. (handle_connections): Add home_inotify_fd to watch the home directory. -- GnuPG-bug-id: 3218 Note that we should add this also to dirmngr. And for non-Linux systems a stat in ticker should be implemented. Signed-off-by: Werner Koch <[email protected]>
2017-05-30agent: Fix memory leaks.NIIBE Yutaka1-1/+6
* agent/divert-scd.c (ask_for_card): Free WANT_KID and WANT_SN_DISP. * agent/gpg-agent.c (create_server_socket): Free UNADDR. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-05-24agent: Make digest algorithms for ssh fingerprints configurable.Justus Winter1-0/+9
* agent/agent.h (opt): New field 'ssh_fingerprint_digest'. * agent/command-ssh.c (data_sign, ssh_identity_register): Honor the option for strings used to communicate with the user. * agent/findkey.c (agent_modify_description): Likewise. * agent/gpg-agent.c (cmd_and_opt_values): New value. (opts): New option '--ssh-fingerprint-digest'. (parse_rereadable_options): Set the default to MD5 for now. (main): Handle the new option. * doc/gpg-agent.texi: Document the new option. -- OpenSSH has transitioned from using MD5 to compute key fingerprints to SHA256. This patch makes the digest used when communicating key fingerprints to the user (e.g. in pinentry dialogs) configurable. For now this patch conservatively defaults to MD5. GnuPG-bug-id: 2106 Signed-off-by: Justus Winter <[email protected]>
2017-05-22agent: Add const qualifier for read-only table.NIIBE Yutaka1-1/+1
* agent/call-pinentry.c (start_pinentry): Add const to tbl. * agent/command-ssh.c (request_specs): Add const. (ssh_key_types): Likewise. (request_spec_lookup): Add const to the return value and SPEC. (ssh_request_process): Likewise. * agent/protect.c (protect_info): Add const. (agent_unprotect): Add const to algotable. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-14agent: Clean up error initialize/return.NIIBE Yutaka1-1/+0
* agent/call-pinentry.c (start_pinentry): Return RC. * agent/command-ssh.c (ssh_handler_request_identities): Don't set ERR. * agent/findkey.c (try_unprotect_cb): Return ERR. (unprotect): Don't set RC. * agent/gpg-agent.c (handle_connections): Don't set fd. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-03gpgconf: Add --enable-extended-key-format for the agent.Werner Koch1-0/+2
* tools/gpgconf-conf.c: Add option. * agent/gpg-agent.c (main) <aGPGConfList>: Add option. Signed-off-by: Werner Koch <[email protected]>
2017-03-24agent: New option --enable-extended-key-format.Werner Koch1-0/+7
* agent/gpg-agent.c (oEnableExtendedKeyFormat): New const. (opts): New option --enable-extended-key-format. (parse_rereadable_options): Set option * agent/findkey.c (write_extended_private_key): Add arg 'update'. (agent_write_private_key): Implement new option. Signed-off-by: Werner Koch <[email protected]>
2017-03-07agent: Resolve conflict of util.h.NIIBE Yutaka1-5/+5
* agent/Makefile.am (AM_CPPFLAGS): Remove -I$(top_srcdir)/common. * agent/call-pinentry.c, agent/call-scd.c: Follow the change. * agent/command-ssh.c, agent/command.c, agent/cvt-openpgp.c: Ditto. * agent/divert-scd.c, agent/findkey.c, agent/genkey.c: Ditto. * agent/gpg-agent.c, agent/pksign.c, agent/preset-passphrase.c: Ditto. * agent/protect-tool.c, agent/protect.c, agent/trustlist.c: Ditto. * agent/w32main.c: Ditto. -- For openpty function, we need to include util.h on some OS. We also have util.h in common/, so this change is needed. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-02-21Clean up word replication.Yuri Chornoivan1-1/+1
-- This fixes extra word repetitions (like "the the" or "is is") in the code and docs. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2017-01-23Update copyright notices for 2017.Werner Koch1-1/+1
-- Also some http:// -> https:// fixes. Signed-off-by: Werner Koch <[email protected]>
2017-01-18agent: Reduce sleep time in the progress callback.Werner Koch1-2/+10
* agent/gpg-agent.c (agent_libgcrypt_progress_cb): Reduce sleep time from 100ms to 1ms or use gpgrt_yield when build against a recent libgpg-error. -- Debian-bug-id: 851298 Signed-off-by: Werner Koch <[email protected]>
2017-01-06agent,w32: Fix annoying output to DebugView.Werner Koch1-2/+6
* agent/gpg-agent.c (startup_fd_list): Do not define for W32. (main) [W32]: Do not call get_all_open_fds. -- GnuPG-bug-id: 2267 Signed-off-by: Werner Koch <[email protected]>
2016-12-19Remove unused debug flags and add "dns" and "network".Werner Koch1-4/+2
* g10/options.h (DBG_CARD_IO_VALUE, DBG_CARD_IO): Remove. * g10/gpg.c (debug_flags): Remove "cardio". * agent/agent.h (DBG_COMMAND_VALUE, DBG_COMMAND): Remove. * agent/gpg-agent.c (debug_flags): Remove "command". * scd/scdaemon.h (DBG_COMMAND_VALUE, DBG_COMMAND): Remove. * scd/scdaemon.c (debug_flags): Remove "command". * dirmngr/dirmngr.h (DBG_DNS_VALUE, DBG_DNS): New. (DBG_NETWORK_VALUE, DNG_NETWORK): New. * dirmngr/dirmngr.c (debug_flags): Add "dns" and "network". -- Note that "dns" and "network" are not yet used but will soon be added to dirmngr. Signed-off-by: Werner Koch <[email protected]>
2016-12-06agent: Respect --enable-large-secmemDaniel Kahn Gillmor1-1/+1
* agent/gpg-agent.c (main): Initialize secmem to the configured buffer size. -- This patch is a step toward addressing GnuPG-bug-id: 2857 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2016-11-29agent,dirmngr: Tiny restructuring.Werner Koch1-1/+6
* agent/gpg-agent.c (handle_connections): Add a comment. * dirmngr/dirmngr.c (main): Move assuan_sock_close of the listening socket to ... (handle_connections): here. Add a comment why we keep the listening socket open during a shutdown. Signed-off-by: Werner Koch <[email protected]>
2016-11-29agent,dirmngr: Handle corner case in shutdown mode.Werner Koch1-0/+6
* agent/gpg-agent.c (handle_connections): Keep on selecting on the inotify fd even when a shutdown is pending. * dirmngr/dirmngr.c (handle_connections): Ditto. Also simplifyy the use of the HAVE_INOTIFY_INIT cpp conditional. -- Without that patch we won't notice a removed socket when a shutdown is pending. This is somewhat related to bug report 2849. Signed-off-by: Werner Koch <[email protected]>
2016-11-29agent,w32: Initialize nPth in server mode.Werner Koch1-0/+5
* agent/gpg-agent.c (main) [W32]: Call initialize_modules in server mode. -- Fixes-commit: 9a707a223a3d45ccf245dee7989ca144e4e6bb49 Signed-off-by: Werner Koch <[email protected]>
2016-11-21agent: Fix npth + daemon mode problem.NIIBE Yutaka1-2/+0
* agent/gpg-agent.c (main): Remove duplicated initialization in daemon mode. -- The commit f57dc2b1e6f28d164f882373535dbcb0d632ca17 fixes a part of problem (for missing initialization of supervised mode). It was actually put in wrong place. Fixes-commit: 9f92b62a51d2d60f038fdbe01602865c5933fa95 Signed-off-by: NIIBE Yutaka <[email protected]>
2016-11-12agent: Improve concurrency when Libgcrypt 1.8 is used.Werner Koch1-9/+15
* agent/gpg-agent.c (thread_init_once): Tell Libgcrypt to reinit the system call clamp. (agent_libgcrypt_progress_cb): Do not sleep if Libgcrypt is recent enough. -- This patch prepares for a feature comming with Libgcrypt 1.8. Signed-off-by: Werner Koch <[email protected]>
2016-11-11agent: Kludge to mitigate blocking calls in Libgcrypt.Werner Koch1-3/+14
* agent/gpg-agent.c (agent_libgcrypt_progress_cb): Sleep for 100ms on "need_entropy". -- During key generation Libgrypt will read from /dev/random which may block. Libgcrypt is not nPth aware and thus the entire process will block. Fortunately there is also a select with a short timeout to run the progress callback. We detect this in gpg-agent and introduce a short delay to give other threads (i.e. connections) an opportunity to run. This alone is not sufficient, an updated Libgpg-error is also required to make the lock functions nPth aware. Signed-off-by: Werner Koch <[email protected]>
2016-11-05Change all http://www.gnu.org in license notices to https://Werner Koch1-1/+1
--
2016-11-02Spelling: correct spelling of "passphrase".Daniel Kahn Gillmor1-2/+2
There were several different variant spellings of "passphrase". This should fix them all for all English text. I did notice that po/it.po contains multiple instances of "passhprase", which also looks suspect to me, but i do not know Italian, so i did not try to correct it. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2016-10-27agent,common: move get_socket_name() into common.Daniel Kahn Gillmor1-48/+2
* agent/gpg-agent.c (get_socket_name): move to ... * common/sysutils.c (gnupg_get_socket_name): ... here. -- This allows us to use the same functionality in dirmngr as well. Signed-off-by: Daniel Kahn Gillmor <[email protected]>