aboutsummaryrefslogtreecommitdiffstats
path: root/common (follow)
Commit message (Collapse)AuthorAgeFilesLines
* common: Avoid warning about implicit declaration of gnupg_fd_valid.Daniel Kahn Gillmor2017-02-081-0/+1
| | | | | | | | | | | | | | | * common/logging.c: Add #include "sysutils.h". -- Without this, we see: logging.c:573:9: warning: implicit declaration of function \ ‘gnupg_fd_valid’ [-Wimplicit-function-declaration] if (! gnupg_fd_valid (fd)) ^~~~~~~~~~~~~~ Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* gpg,common: Make sure that all fd given are valid.Justus Winter2017-02-083-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/sysutils.c (gnupg_fd_valid): New function. * common/sysutils.h (gnupg_fd_valid): New declaration. * common/logging.c (log_set_file): Use the new function. * g10/cpr.c (set_status_fd): Likewise. * g10/gpg.c (main): Likewise. * g10/keylist.c (read_sessionkey_from_fd): Likewise. * g10/passphrase.c (set_attrib_fd): Likewise. * tests/openpgp/Makefile.am (XTESTS): Add the new test. * tests/openpgp/issue2941.scm: New file. -- Consider a situation where the user passes "--status-fd 3" but file descriptor 3 is not open. During the course of executing the rest of the commands, it's possible that gpg itself will open some files, and file descriptor 3 will get allocated. In this situation, the status information will be appended directly to whatever file happens to have landed on fd 3 (the trustdb? the keyring?). This is a potential data destruction issue for all writable file descriptor options: --status-fd --attribute-fd --logger-fd It's also a potential issue for readable file descriptor options, but the risk is merely weird behavior, and not data corruption: --override-session-key-fd --passphrase-fd --command-fd Fixes this by checking whether the fd is valid early on before using it. GnuPG-bug-id: 2941 Signed-off-by: Justus Winter <[email protected]>
* Update copyright notices for 2017.Werner Koch2017-01-232-3/+3
| | | | | | | | -- Also some http:// -> https:// fixes. Signed-off-by: Werner Koch <[email protected]>
* Fix format string errors and some missing error case initialization.Werner Koch2017-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * common/logging.c (do_logv): Remove extra parentheses in comparison. * dirmngr/dns-stuff.c (resolve_addr_libdns): Init RES so that dns_res_close is given a defined value in the error case. * dirmngr/http.c (cookie_read, cookie_write) [HTTP_USE_NTBTLS]: Fix format string char. * dirmngr/ks-engine-hkp.c (ks_hkp_help): Remove duplicate "const". * dirmngr/ks-engine-http.c (ks_http_help): Ditto. * dirmngr/ks-engine-kdns.c (ks_kdns_help): Ditto. * dirmngr/ks-engine-ldap.c (ks_ldap_help): Ditto. * scd/app-p15.c (send_keypairinfo, do_getattr): Fix format string char. * tools/gpgconf-comp.c (gpg_agent_runtime_change): Init PID for the error case. (scdaemon_runtime_change): Ditto. (dirmngr_runtime_change): Ditto. * tools/gpgconf.c (query_swdb): Init VALUE_SIZE_UL. Signed-off-by: Werner Koch <[email protected]>
* common: Fix buffer copy code again.Werner Koch2017-01-191-20/+14
| | | | | | | | | | | | * common/exectool.c (my_error_from_errno): Remove. (copy_buffer_do_copy): Do without var RC. (copy_buffer_flush): Ditto. Use ERRNO instead of es_write return code. (gnupg_exec_tool): Correctly return errors from es_read. -- Fixes-commit: 55c9212a2338bf0b07c8cf3a69bcedaa28d48d43 Signed-off-by: Werner Koch <[email protected]>
* gpg: Allow to freeze faked system time.Damien Goutte-Gattat2017-01-191-1/+1
| | | | | | | | | | | | | | | | * g10/gpg.c (main): If the parameter for --faked-system-time ends with a '!', freeze time at the specified point. * common/gettime.c (gnupg_set_time): Allow to freeze the time at an arbitrary time instead of only the current time. * doc/gpg.texi: Update documentation for --faked-system-time. -- This patch allows the user to modify the behavior of the --faked-system-time option: by appending a '!' to the parameter, time in GnuPG will be frozen at the specified time, instead of advancing normally from that time onward. Signed-off-by: Damien Goutte-Gattat <[email protected]>
* common: Clarify use of vars in buffer copy code.Werner Koch2017-01-191-16/+26
| | | | | | | | | | | | | | | * common/exectool.c (my_error_from_errno): New. (copy_buffer_do_copy): Use separate vars for errno values and gpg-error values for clarity. s/assert/log_assert/. (copy_buffer_flush): Ditto. (gnupg_exec_tool_stream): Use gpg_err_code when testing. -- NB: It is surprising that es_write seems not to set ERRNO but only returns the ERRNO value. Need to check whether this is really the case. Signed-off-by: Werner Koch <[email protected]>
* common: Fix flushing copy buffers.Justus Winter2017-01-181-7/+19
| | | | | | | | | * common/exectool.c (copy_buffer_flush): Write and flush the data, but do not hide EAGAIN from the caller. (gnupg_exec_tool_stream): Retry on EAGAIN. GnuPG-bug-id: 2425 Signed-off-by: Justus Winter <[email protected]>
* common: Remove unused function tty_print_string.Werner Koch2017-01-172-83/+46
| | | | | | | | * common/ttyio.c (tty_print_string): Rename to ... (do_print_string): this. Make local. Simplify FP case by using print_utf8_buffer. Change caller. Signed-off-by: Werner Koch <[email protected]>
* tests: Fix t-gettime for a time_t of 64 and a long of 32 bit.Werner Koch2017-01-121-4/+13
| | | | | | | | | | | | * configure.ac (AC_CHECK_HEADERS): Add stdint.h. * common/t-gettime.c: Include stdint.h. (UINTMAX_C): Define replacement. (test_isotime2epoch): Use UINTMAX_C for the >32 bit constants. -- This is for example the case on 32 bit OpenBSD. Signed-off-by: Werner Koch <[email protected]>
* common: New function log_debug_with_string.Werner Koch2017-01-112-37/+106
| | | | | | | | | | | | | | | * common/logging.c (do_logv): Factor some code out to ... (print_prefix): new. (log_logv): Add arg EXTRASTRING and print it. Change all callers to pass NULL for it. (log_debug_with_string): New. Uses EXTRASTRING. -- This function can be used to print a human readable buffer in addition to a log message to the log stream. This function will keep all lines together and prefix them with ">> ". Signed-off-by: Werner Koch <[email protected]>
* common: Avoid unnecessary ambiguity in argparse.Daniel Kahn Gillmor2017-01-111-1/+3
| | | | | | | | | | | | | * common/argparse.c (find_long_option): Avoid unnecessary ambiguity. -- If two struct ARGPARSE_OPTS share a prefix in their long_opt name, but have the exact same short_opt and flags, they are aliases and not distinct options. Avoid reporting this as an ambiguity, so that (for example) both --clearsign and --clear-sign can be invoked as --clear. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Debian-Bug-Id: 850475
* common: Fix fallback code.Justus Winter2017-01-102-2/+2
| | | | | | | | * common/logging.c (_log_assert): Fix the variant for compilers that do not support __FUNCTION__. * common/logging.h (_log_assert): Likewise. Signed-off-by: Justus Winter <[email protected]>
* agent,w32: Fix annoying output to DebugView.Werner Koch2017-01-061-5/+8
| | | | | | | | | * 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]>
* Silence two -Wlogical-op warnings.Werner Koch2017-01-051-2/+2
| | | | | | | | * common/tlv.c (parse_ber_header): Avoid compiler warning about a duplicate condition. * tools/gpgtar-create.c (pattern_valid_p): Likewise. Signed-off-by: Werner Koch <[email protected]>
* common: Turn assertions into expressions.Justus Winter2017-01-021-8/+8
| | | | | | | * common/logging.h (log_assert): Turn this into an expression so it can be used in expressions. Signed-off-by: Justus Winter <[email protected]>
* Replace use of variable-length-arrays.Werner Koch2017-01-021-2/+4
| | | | | | | | | | | | | * common/t-iobuf.c (main): Replace variable-length-array. * g10/gpgcompose.c (mksubpkt_callback): Ditto. (encrypted): Ditto. * g10/t-stutter.c (log_hexdump): Ditto. (oracle_test): Ditto. * g10/tofu.c (get_policy): Ditto. Use "%zu" for size_t. * scd/app-openpgp.c (ecc_writekey): Replace variable-length-array. Check for zero length OID_LEN. Signed-off-by: Werner Koch <[email protected]>
* tests: Avoid skipping exectool tests.Werner Koch2016-12-201-18/+31
| | | | | | | | | | | | | | * common/t-exectool.c (test_executing_true): Try also /usr/bin/true. (test_executing_false): Try also /usr/bin/false. -- Reported-by: Nelson H. F. Beebe I then ran a test on all our test lab systems, and found that /bin/false is missing on DragonFlyBSD, FreeBSD, GhostBSD, HardenedBSD, Mac OS X, MidnightBSD, Minix, one version of MirBSD, NetBSD, OpenBSD, PacBSD, PCBSD, and TrueOS. Signed-off-by: Werner Koch <[email protected]>
* Remove unused debug flags and add "dns" and "network".Werner Koch2016-12-191-0/+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]>
* common: Support locating components in the build tree.Justus Winter2016-12-142-17/+65
| | | | | | | | | | | | | | | | | | | | | | | | | * common/homedir.c (gnupg_build_directory): New variable. (gnupg_module_name_called): Likewise. (gnupg_set_builddir): New function. (gnupg_set_builddir_from_env): Likewise. (gnupg_module_name): Support locating components in the build tree. * common/util.h (gnupg_set_builddir): New prototype. * tests/openpgp/defs.scm (tools): Drop 'gpg and 'gpg-agent. (tool): Rename to 'tool-hardcoded. (gpg-conf): New function, with accessors for the results. (gpg-components): New variable. (tool): New function. * tools/gpgconf.c (enum cmd_and_opt_values): New key. (opts): New option '--build-prefix'. (main): Handle new option. -- This change makes sure that the components from the build tree are used, and not some older installed version in PATH. It also lets us make GPGME use components from the build tree, making it possible to execute GPGME's test suite with them. Signed-off-by: Justus Winter <[email protected]>
* common: Fix typo.Justus Winter2016-12-141-1/+1
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* common: Add replacements for error codes from gpg-error 1.26.Werner Koch2016-12-141-1/+13
| | | | Signed-off-by: Werner Koch <[email protected]>
* common: Skip the Byte Order Mark in conf files.Werner Koch2016-12-081-1/+19
| | | | | | * common/argparse.c (optfile_parse): Detect and skip the UTF-8 BOM. Signed-off-by: Werner Koch <[email protected]>
* gpg: New option --default-new-key-algo.Werner Koch2016-12-022-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/openpgp-oid.c (openpgp_is_curve_supported): Add optional arg R_ALGO and change all callers. * common/util.h (GPG_ERR_UNKNOWN_FLAG): New error code. * g10/options.h (struct opt): Add field DEF_NEW_KEY_ALGO. * g10/gpg.c (oDefaultNewKeyAlgo): New enum. (opts): New option "--default-new-key-algo". (main): Set the option. * g10/keygen.c: Remove DEFAULT_STD_ FUTURE_STD_ constants and replace them by ... (DEFAULT_STD_KEY_PARAM, FUTURE_STD_KEY_PARAM): new string constants. (get_keysize_range): Remove arg R_DEF and return that value instead. Change all callers. (gen_rsa): Use get_keysize_range instead of the removed DEFAULT_STD_KEYSIZE. (parse_key_parameter_part): New function. (parse_key_parameter_string): New function. (quick_generate_keypair): Refactor using parse_key_parameter_string. (generate_keypair): Ditto. (parse_algo_usage_expire): Ditto. -- This new option is intended to be used in the forthcoming --set-profile command of gpgconf. It allows to provide a gpg configuration with custom defaults for a new key using the simple commands which use the default algorithm set. Signed-off-by: Werner Koch <[email protected]>
* gpg,sm: Merge the two versions of check_special_filename.Werner Koch2016-11-294-41/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * sm/gpgsm.c (check_special_filename): Move to .. * common/sysutils.c (check_special_filename): here. Add arg NOTRANSLATE. (allow_special_filenames): New local var. (enable_special_filenames): New public functions. * sm/gpgsm.c (allow_special_filenames): Remove var. (main): Call enable_special_filenames instead of setting the var. (open_read, open_es_fread, open_es_fwrite): Call check_special_filename with 0 for NOTRANSLATE. * common/iobuf.c (special_names_enabled): Remove var. (iobuf_enable_special_filenames): Remove func. (check_special_filename): Remove func. (iobuf_is_pipe_filename): Call new version of the function with NOTRANSLATE set. (do_open): Ditto. * g10/gpg.c (main): Call enable_special_filenames instead of iobuf_enable_special_filenames. * g10/gpgv.c (main): Ditto. -- Note that we keep the iobuf.c:translate_file_handle because it is a bit different (for whatever reasons) than the translate function from sysutils. Signed-off-by: Werner Koch <[email protected]>
* common: Rename keybox_file_rename to gnupg_rename_file.Werner Koch2016-11-162-0/+72
| | | | | | | * kbx/keybox-util.c (keybox_file_rename): Rename to ... * common/sysutils.c (gnupg_rename_file): this. Change all callers. Signed-off-by: Werner Koch <[email protected]>
* common,w32: Simplify locking.Justus Winter2016-11-081-49/+0
| | | | | | | | * common/asshelp.c (lock_spawning): Use the same code on Windows that we use on all other platforms. (unlock_spawning): Likewise. Signed-off-by: Justus Winter <[email protected]>
* Change all http://www.gnu.org in license notices to https://Werner Koch2016-11-05123-123/+123
| | | | --
* common: Improve compare_string_versions.Werner Koch2016-11-022-45/+83
| | | | | | | | | | | | | | | * common/stringhelp.c: Include limits.h. (compare_version_strings): Change semantics to behave like strcmp. Include the patch lebel in the comparison. Allow checking a single version string. * common/t-stringhelp.c (test_compare_version_strings): Adjust test vectors and a few new vectors. * g10/call-agent.c (warn_version_mismatch): Adjust to new sematics. * g10/call-dirmngr.c (warn_version_mismatch): Ditto. * sm/call-agent.c (warn_version_mismatch): Ditto. * sm/call-dirmngr.c (warn_version_mismatch): Ditto. Signed-off-by: Werner Koch <[email protected]>
* common: New function gnupg_usleep.Werner Koch2016-10-312-1/+46
| | | | | | | | | | | * configure.ac (HAVE_NANOSLEEP): Test for nanosleep. * common/sysutils.c: Always include time.h. (gnupg_usleep): New. -- This function has been compiled from nPth and Libassuan. Signed-off-by: Werner Koch <[email protected]>
* common: Add GNUPG_MODULE_NAME_GPGV.Werner Koch2016-10-272-0/+8
| | | | | | | * common/util.h (GNUPG_MODULE_NAME_GPGV): New. * common/homedir.c (gnupg_module_name): Implement. Signed-off-by: Werner Koch <[email protected]>
* Fix typos.Justus Winter2016-10-273-3/+3
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* common: Remove debug output from gnupg_get_socket_name.Werner Koch2016-10-271-4/+4
| | | | | | | * common/sysutils.c (gnupg_get_socket_name): Remove debug message and use my_error_from_syserror. Signed-off-by: Werner Koch <[email protected]>
* common: Fix gnupg_inotify_has_name, differently.NIIBE Yutaka2016-10-271-21/+15
| | | | | | | | | | | * common/sysutils.c (gnupg_inotify_has_name): Use void * to stop the warning. -- According to the man page of inotify(7), it is aligned by null bytes. So, bc28f320fa6f5b9fcdb73dba5e6c582daf7992c5 is reverted. Signed-off-by: NIIBE Yutaka <[email protected]>
* agent,common: move get_socket_name() into common.Daniel Kahn Gillmor2016-10-272-0/+50
| | | | | | | | | | * 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]>
* common: Fix gnupg_inotify_has_name.NIIBE Yutaka2016-10-271-14/+22
| | | | | | | | | * common/sysutils.c (gnupg_inotify_has_name): Take care of the alignment. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* common: Use GPG_ERR_INV_VALUE instead of GPG_ERR_EINVAL.Werner Koch2016-10-261-1/+1
| | | | | | | | | | | | * common/sysutils.c (gnupg_inotify_watch_socket): Return GPG_ERR_INV_VALUE for a missing socket name and set proper error source. -- By using a different value we can easier see whether the error is due to a system call or from GnuPG code. Signed-off-by: Werner Koch <[email protected]>
* common: avoid segfaultDaniel Kahn Gillmor2016-10-261-0/+3
| | | | | | | * common/sysutils.c (gnupg_inotify_watch_socket): return EINVAL if socket_name is NULL, rather than segfaulting -- Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* common: Use strconcat in gnupg_setenv.Werner Koch2016-10-251-22/+22
| | | | | | | | * common/sysutils.c (gnupg_setenv): Replace malloc+stpcpy by strconcat. Indent cpp conditionals. (gnupg_unsetenv): Indent cpp conditionals. Signed-off-by: Werner Koch <[email protected]>
* common: Fix openpgp_is_curve_supported.NIIBE Yutaka2016-10-241-2/+2
| | | | | | | | | | * common/openpgp-oid.c (openpgp_is_curve_supported): Support both of canonical name of the curve and alias. -- Only alias (the name for print) was allowed before this change. Signed-off-by: NIIBE Yutaka <[email protected]>
* Fix use cases of snprintf.NIIBE Yutaka2016-10-211-4/+2
| | | | | | | | | | | * agent/call-pinentry.c, agent/call-scd.c, agent/command.c, build-aux/speedo/w32/g4wihelp.c, common/get-passphrase.c, dirmngr/dirmngr.c, g10/call-agent.c, g10/cpr.c, g10/keygen.c, g10/openfile.c, g10/passphrase.c, scd/app-openpgp.c, scd/scdaemon.c, sm/call-agent.c, sm/call-dirmngr.c, sm/certreqgen.c: Fix assuming C99. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* common,w32: Fix setting environment variables on Windows.Justus Winter2016-10-201-39/+62
| | | | | | | | | * common/sysutils.c (gnupg_setenv): Also update the environment block maintained by the C runtime. (gnupg_unsetenv): Likewise. * tests/gpgscm/ffi.c (do_setenv): Fix error handling. Signed-off-by: Justus Winter <[email protected]>
* common: Fix copying data to estreams.Justus Winter2016-10-181-5/+7
| | | | | | | * common/exectool.c (copy_buffer_do_copy): Correctly account for partially written data in the event of errors. Signed-off-by: Justus Winter <[email protected]>
* common,w32: Communicate with child in non-blocking mode.Justus Winter2016-10-181-3/+4
| | | | | | | | * common/exechelp-w32.c (gnupg_spawn_process): Open streams in non-blocking mode if requested. Fixes-commit: 83811e3f1f0c615b2b63bafdb49a35a0fc198088 Signed-off-by: Justus Winter <[email protected]>
* common,w32: Extend gnupg_create_inbound_pipe et al.Justus Winter2016-10-181-10/+27
| | | | | | | | | | | | * common/exechelp-w32.c (do_create_pipe): Rename, add arguments, and create a stream if reqested. (gnupg_create_inbound_pipe): Use the extended function to open the stream if requested. (gnupg_create_outbound_pipe): Likewise. (gnupg_create_pipe): Update call site. Fixes-commit: 5d991e333a1885adc40abd9d00c01fec4bd5d9d7 Signed-off-by: Justus Winter <[email protected]>
* common,w32: Make use of default_errsource in exechelp.Justus Winter2016-10-181-7/+21
| | | | | | | | * common/exechelp-posix.c (my_error_from_syserror, my_error): New. Use them instead of gpg_error and gpg_error_from_syserror. Fixes-commit: 96c7901ec1c79be732570811223d3ea54875abfe Signed-off-by: Justus Winter <[email protected]>
* agent: Move inotify code to common and improve it.Werner Koch2016-10-152-0/+131
| | | | | | | | | | | | | | | | | | | | | | | * common/sysutils.c: Include sys/inotify.h. (my_error_from_syserror, my_error): New. (gnupg_inotify_watch_socket): New. (gnupg_inotify_has_name): New. * agent/gpg-agent.c: Do not include sys/inotify.h. (my_inotify_is_name): Remove. (handle_connections): Remove HAVE_INOTIFY_INIT protected code and use the new functions. -- When removing not a simple socket file but the entire directory the old code missed most events and thus did not worked properly. IN_DELETE_SELF has also been added to the watch list to detect a removal of the directory. However, in all tests that event was not triggered. The only way it could be triggered was by not watching the socket dir but an arbitary directory and rmdir that. GnuPG-bug-id: 2756 Signed-off-by: Werner Koch <[email protected]>
* agent, dirmngr, scd: Fix init_common_subsystems.NIIBE Yutaka2016-10-071-11/+0
| | | | | | | | | | | * common/init.c (_init_common_subsystems): Don't call gpgrt_set_syscall_clamp in this function. * agent/gpg-agent.c, dirmngr/dirmngr.c, scd/scdaemon.c: Call gpgrt_set_syscall_clamp after npth_init. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* common: Avoid pointer arithmetic on string literals.Justus Winter2016-10-062-4/+4
| | | | | * common/gettime.c (rfctimestamp): Use indexing instead. * common/signal.c (got_fatal_signal): Likewise.
* build: Fix build against libiconv.Justus Winter2016-09-301-1/+1
| | | | | | | | * agent/Makefile.am: Add INCICONV and LIBICONV. * common/Makefile.am: Likewise. * tools/Makefile.am: Likewise. Signed-off-by: Justus Winter <[email protected]>