1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-09 23:39:51 +02:00
Commit Graph

783 Commits

Author SHA1 Message Date
Werner Koch
c98995efef
build: Require latest released libraries
* agent/protect.c (OCB_MODE_SUPPORTED): Remove macro.
(do_encryption): Always support OCB.
(do_decryption): Ditto.
(agent_unprotect): Ditto.
* dirmngr/server.c (is_tor_running): Unconditionally build this.
--

Although not technically required, it is easier to require them to
avoid bug reports due to too old library versions.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-14 10:48:34 +02:00
Werner Koch
27d158ead4
tests: Add a gettime test for sizeof (time_t) > 4.
* common/t-gettime.c (test_isotime2epoch): Add 4 more tests.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-04 10:00:34 +02:00
Werner Koch
442efa9b3f
doc: Describe filter expressions.
* doc/gpg.texi: Remove some superfluous .E.
(FILTER EXPRESSIONS): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-02 16:18:50 +02:00
Werner Koch
681c6ef757
common: Add function to select records etc.
* common/recsel.c, common/recsel.h: New.
* common/t-recsel.c: New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-01 16:27:43 +02:00
Werner Koch
6446a6b3df
common: Smart up register_mem_cleanup_func.
* common/init.c (register_mem_cleanup_func): Avoid double registration.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-01 16:27:43 +02:00
Justus Winter
49fdd0887c common: Annotate semi-static allocation.
* common/argparse.c (optfile_parse): Allow string arguments to leak.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-01 14:16:18 +02:00
Justus Winter
d2d19063d3 common: Fix memory leak.
* common/iobuf.c (iobuf_set_partial_body_length_mode): Only create
context if necessary.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 18:50:16 +02:00
Justus Winter
9037c23979 common: Fix memory leak.
* common/simple-pwquery.c (agent_open): Free socket path.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-30 18:50:16 +02:00
Justus Winter
c14ef10fc3 common: Fix memory leaks.
* common/ccparray.c (ccparray_put): Free old array.
* common/stringhelp.c (do_make_filename): Free 'home'.
* common/t-convert.c: Fix trivial memory leaks.
* common/t-iobuf.c: Likewise.
* common/t-mbox-util.c: Likewise.
* common/t-name-value.c: Likewise.
* common/t-stringhelp.c: Likewise.
* common/t-strlist.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 18:21:50 +02:00
Werner Koch
1ddf5b846f
common: New function rfctimestamp.
* common/gettime.c (rfctimestamp): New.
--

It is surprisingly hard to create an RFC-2822 compliant Date value.
The problem is that strftime uses the current locale but the RFC
requires that the English names are used.  This code is pretty simply
and avoid the extra problem of figuring out the correct timezone;
instead UTC is used.  For the planned use case this is anyway better.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-28 15:53:59 +02:00
Werner Koch
781e614e3b
common: Add missing header file for clarity.
* common/zb32.c: Include zb32.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-28 15:53:59 +02:00
Justus Winter
d36f664bfd common: Close input stream.
* common/exechelp-posix.c (gnupg_spawn_process): Also close the input
stream in the child.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 15:01:57 +02:00
Justus Winter
8f79c31b4d common: Fix copying data from the spawned child.
Fixes intermittent gpgtar failures.

* common/exectool.c (copy_buffer_do_copy): Initialize 'nwritten'.
(gnupg_exec_tool_stream): Loop until all data is copied.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-28 14:38:35 +02:00
Werner Koch
c229ba4d8b
common: Fix possible small memory leak in b64dec.c.
* common/b64dec.c (b64dec_finish): Always release TITLE.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 20:01:15 +02:00
Werner Koch
3ead21da80
common: Add dedicated private key functions to name-value.c.
* common/name-value.c (struct name_value_container): Add field
'private_key_mode'.
(my_error): New.  Use instead of gpg_error.
(nvc_new_private_key): New.
(nve_release): Add arg 'private_key_mode'.
(nvc_release): Call nve_release with private_key_mode flag.
(nvc_delete): Ditto.
(_nvc_add): Do no special case "Key:" in non-private_key_mode.
(nvc_get_private_key): Return error in non-private_key_mode.
(nvc_set_private_key): Ditto.
(nvc_parse):  Factor all code out to ...
(do_nvc_parse): new.  Add arg 'for_private_key'.
(nvc_parse_private_key): New.
* agent/findkey.c (write_extended_private_key): Replace nvc_parse by
nvc_parse_private_key.
(read_key_file): Ditto.

* common/t-name-value.c (private_key_mode): New variable.
(my_nvc_new): New.  Replace all callers.
(test_key_extraction): Take mode in account.
(run_tests): Ditto.
(run_modification_tests): Ditto.
(parse): Ditto.
(main): Add option --parse and rename --parse to --parse-key.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 13:17:25 +02:00
Werner Koch
d74d23d860
common: Rename external symbols in name-value.c.
* common/name-value.c, common/name-value.h: Rename symbol prefixes
from "pkc_" to "nvc_" and from "pke_" to "nve_".  Change all callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 12:12:50 +02:00
Werner Koch
b841a883a2
common: Rename private-keys.c to name-value.c
* common/private-keys.c: Rename to name-value.c.
* common/private-keys.h: Rename to name-value.h.  Chage all users.
* common/t-private-keys.c: Rename to t-name-value.c.
* common/Makefile.am: Adjust accordingly.
--

The module is cool enough to be used for other purposes as well.  Thus
we better change the name.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 11:55:46 +02:00
Werner Koch
e430ff6ad0
common: Change license of b64dec.c and b64enc.c to LGPLv2.1+
--

The code as solely been written by employees of g10 Code.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 09:38:12 +02:00
Werner Koch
3694579bc4
common: Add PGP armor decoding to b64dec.
* common/b64dec.c (decoder_states): Add new states.
(b64dec_proc): Handle PGP armored format.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-23 09:38:12 +02:00
Werner Koch
955baf0436
gpg: Add experimental support for an issuer fpr.
* common/openpgpdefs.h (SIGSUBPKT_ISSUER_FPR): New.
* g10/build-packet.c (build_sig_subpkt_from_sig): Add arg PKSK and
insert the issuer fpr if needed.
* g10/sign.c (write_signature_packets): Pass signing key.
(make_keysig_packet): Ditto.
(update_keysig_packet): Ditto.
* g10/parse-packet.c (dump_sig_subpkt): Print issuer fpr.
(parse_one_sig_subpkt): Detect issuer fpr.
(can_handle_critical): Add issuer fpr.
* g10/mainproc.c (check_sig_and_print): Try to get key via fingerprint.
* g10/gpgv.c (keyserver_import_fprint): New stub.
* g10/test-stubs.c (keyserver_import_fprint): New stub.
--

This support is enabled with the --rfc4880bis option and intended to
test to recently proposed issuer fpr.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-20 23:59:18 +02:00
Werner Koch
5ddccf4fc6
doc: Consistently use 'keyserver'.
--
GnuPG-bug-id: 2383

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-14 09:06:44 +02:00
Werner Koch
2494ce190b
common: Fix bad printf format in t-stringhelp.c
--
2016-06-12 13:43:55 +02:00
Werner Koch
5ba99d9302
common: New function split_fields.
* common/stringhelp.c (split_fields): New.
* common/t-stringhelp.c: Include assert.h.
(test_split_fields): New.
(main): Call test.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-11 12:09:48 +02:00
Werner Koch
8127043d54
Explicitly restrict socket permissions.
* agent/gpg-agent.c (create_server_socket): Call chmod before listen.
* scd/scdaemon.c (create_server_socket): Ditto.
* dirmngr/dirmngr.c (main): Ditto.
--

This is just in case of a improperly set umask.  Note that a connect
requires a write permissions.
2016-06-08 16:18:02 +02:00
Werner Koch
6790115fd9
w32: Fix recent build regression.
* common/homedir.c (_gnupg_socketdir_internal) [W32]: Add definition
for NAME.
* g10/gpg.c (main) [W32]:  Fix use og gnupg_homedir.

* agent/gpg-agent.c (remove_socket): Remove unused var P.
* scd/scdaemon.c (cleanup): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-08 15:14:06 +02:00
Werner Koch
aab8a0b052
Implement /run/user/UID/gnupg based sockets.
* common/homedir.c: Include sys/stat.h and zb32.h.
(w32_portable_app, w32_bin_is_bin): Change type from int to byte.
(non_default_homedir): New.
(is_gnupg_default_homedir): New.
(default_homedir): Set non_default_homedir.
(gnupg_set_homedir): Set non_default_homedir and make
the_gnupg_homedir and absolute directory name.
(gnupg_homedir): Return an absolute directory name.
(_gnupg_socketdir_internal): New.
(gnupg_socketdir): Implement /run/user/ based sockets.
* tools/gpg-connect-agent.c (get_var_ext): Replace now obsolete
make_filename by xstrdup.
* tools/gpgconf.c (main): Sue gnupg_homedir for the "homedir:" output.
--

If a [/var]/run/user/$(id -u)/ directory exists, a gnupg subdir is
created as needed and the permissions of the directories are checked.
If that all matches that directory name is returned instead of the
homedir.

To cope with non standard homedirs (via GNUPGHOME or --homedir) the
SHA-1 hash of the homedir is computed, left truncated to 120 bits,
zBase-32 encoded, prefixed with "d.", and appended to
"[/var]/run/user/$(id -u)/gnupg/".  If that directory exists and has
proper permissions it is returned as socket dir - if not the homedir
is used.  Due to cleanup issues, this directory will not be
auto-created but needs to be created by the user in advance.

The required permissions are: directory owned by the user, group and
others bits not set.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-08 13:59:28 +02:00
Werner Koch
36550dde99
common: New function gnupg_socketdir.
* common/homedir.c (gnupg_socketdir): New.
* agent/gpg-agent.c (create_socket_name): Use new function instead of
gnupg_homedir.
(check_own_socket): Ditto.
(check_for_running_agent): Ditto.
* agent/preset-passphrase.c (main): Ditto.
* common/asshelp.c (start_new_gpg_agent): Ditto.
* scd/scdaemon.c (create_socket_name): Ditto.
* tools/gpgconf.c (main): Ditto.
* tools/symcryptrun.c (main): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-07 13:48:46 +02:00
Werner Koch
fb88f37c40
common: Remove homedir arg from start_new_{dirmngr,gpg_agent}.
* common/asshelp.c (start_new_gpg_agent): Remove arg 'homedir' in
favor of gnupg_homedir ().  Change all callers.
(start_new_dirmngr): Ditto.
* common/get-passphrase.c (gnupg_prepare_get_passphrase): Remove arg
'homedir'.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-07 13:09:00 +02:00
Werner Koch
22a7ef01aa
Replace use of opt.homedir by accessor functions.
* common/homedir.c (the_gnupg_homedir): New var.
(gnupg_set_homedir): New.
(gnupg_homedir): New.
* g10/options.h (struct opt): Remove 'homedir' and replace all users
by the new accessor functions.
* g13/g13-common.h (struct opt): Ditto.
* scd/scdaemon.h (struct opt): Ditto.
* sm/gpgsm.h (struct opt): Ditto.
* dirmngr/dirmngr.h (struct opt): Ditto.
* agent/preset-passphrase.c (opt_homedir): Ditto.
* agent/protect-tool.c (opt_homedir): Ditto.
--

This will make detection of a non-default homedir easier.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-07 10:59:46 +02:00
Werner Koch
072acb69be
common: New function openpgp_is_curve_supported.
* common/openpgp-oid.c: Include openpgpdefs.h.
(oidtable): Add field pubkey_algo.
(openpgp_is_curve_supported): New.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-02 15:57:59 +02:00
Werner Koch
c9f9fabdcc
common: Add comments on how to enable backtrace().
--
2016-06-02 15:57:59 +02:00
Werner Koch
67a4bc8d53
gpg: New status code NOTATION_FLAGS.
* common/status.h (STATUS_NOTATION_FLAGS: New.
* g10/packet.h (struct notation): Add flags.human.
(notation_t): New typedef.
* g10/build-packet.c (sig_to_notation): Set flags.human.
* g10/keylist.c (show_notation): Write STATUS_NOTATION_FLAGS.
2016-05-31 15:51:18 +02:00
Werner Koch
239a4d5391
common: Add a status callback to gnupg_exec_tool_stream.
* common/exectool.h (exec_tool_status_cb_t): New.
* common/exectool.c: Include missing exectool.h.
(read_and_log_buffer_t): Replace array by pointer.
(gnupg_exec_tool_stream): Add args 'status_cb' and 'status_cb_value'.
Change all callers to pass NULL for them.  Malloc buffer for
FDERRSTATE.
(read_and_log_stderr): Implement status_fd feature.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-28 00:07:09 +02:00
Werner Koch
44a32455c8
common: Allow a second input stream for gnupg_exec_tool_stream.
* common/exechelp-posix.c (do_exec): Add arg 'except' and pass to
close_all_fds.
(gnupg_spawn_process): Add arg 'except'.  Change callers to pass NULL
for it.
* common/exechelp-w32.c (gnupg_spawn_process): Add dummy arg 'except'.
* common/exechelp-w32ce.c (gnupg_spawn_process): Ditto.
* common/exectool.c (copy_buffer_do_copy): Allow NULL for SINK.
(gnupg_exec_tool_stream): Add arg 'inextra'. Change callers to pass
NULL for it.  Allow NULL for OUTPUT.
--

This hack is a first step to allow calling gpg for verification of
signatures.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-27 22:48:31 +02:00
Werner Koch
e6d9a2d07e
common: Simplify the fd closing patch 512c56a.
* common/exechelp-posix.c (get_max_fds): Use /proc/self.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-27 22:22:37 +02:00
Werner Koch
512c56af43
common: Speedup closing fds before an exec.
* common/exechelp-posix.c [__linux__]: Include dirent.h.
(get_max_fds) [__linux__]: Return the actual used highest fd.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-27 22:02:54 +02:00
Werner Koch
5d991e333a
common: Extend gnupg_create_inbound_pipe et al.
* common/exechelp-posix.c (gnupg_create_inbound_pipe): Add args 'r_fp'
and 'nonblock'.
(gnupg_create_outbound_pipe): Ditto.
* common/exechelp-w32.c (gnupg_create_inbound_pipe): Add non yet
functional args 'r_fp' and 'nonblock'.
(gnupg_create_outbound_pipe): Ditto.
* common/exechelp-w32ce.c (gnupg_create_inbound_pipe): Ditto.
(gnupg_create_outbound_pipe): Ditto.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-27 15:41:55 +02:00
Werner Koch
96c7901ec1
common: Make use of default_errsource in exechelp.
* common/exechelp-posix.c (my_error_from_syserror, my_error): New.
Use them instead of gpg_error and gpg_error_from_syserror.
(create_pipe_and_estream): Remove arg ERRSOURCE and fix use of
OUTBOUND which has a wrong name.  Adjust callers.
(gnupg_spawn_process): Remove arg ERRSOURCE and replace by use of
DEFAULT_ERRSOURCE.
* common/exechelp-w32.c (gnupg_spawn_process): Ditto.
* common/exechelp-w32ce.c (gnupg_spawn_process): Ditto.
* common/exectool.c (gnupg_exec_tool_stream):  Do not pass
GPG_ERROR_FROM_SYSERROR.
* tools/gpgconf-comp.c (gc_component_check_options): Ditto.
(retrieve_options_from_program): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-27 15:34:22 +02:00
Werner Koch
2421f7f7ed
common: Add simple dynamic array function.
* common/ccparray.c: New.
* common/ccparray.h: New.
* common/t-ccparray.c: New.
* common/Makefile.am (common_sources): Add files.
(module_tests): Add test file.
(t_ccparray_LDADD): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-24 15:43:16 +02:00
Werner Koch
f7426b73ce
common,w32: Silence an unused arg warning message.
--
2016-05-24 13:04:29 +02:00
Werner Koch
ff71521d96
gpg: Emit new status line KEY_CONSIDERED.
* common/status.h (STATUS_KEY_CONSIDERED): New.
* g10/getkey.c: Include status.h.
(LOOKUP_NOT_SELECTED, LOOKUP_ALL_SUBKEYS_EXPIRED): New.
(finish_lookup): Add arg R_FLAGS.  Count expired and revoked keys and
set flag.  Check a requested usage before checking for expiraion or
revocation.
(print_status_key_considered): New.
(lookup): Print new status.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-17 19:13:19 +02:00
Werner Koch
d00625dae6
Some minor string changes and fixed a printf format.
* g10/build-packet.c (notation_value_to_human_readable_string): Use
%zu for size_t.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-04 11:05:13 +02:00
Werner Koch
9e28617e26
common: Print https URLs in help messages.
* common/argparse.c (strusage): Print https URLS.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-03 15:55:08 +02:00
Werner Koch
33aacc3d4b
tests: Silence output of some tests.
* common/t-exechelp.c (print_open_fds): Silence non-verbose output.
(test_close_all_fds): Ditto.
* common/t-session-env.c (show_stdnames): Indent output.
* g10/test.c (TEST): Silence non-verbose okay output.
(exit_tests): Ditto.
* tools/gpg-zip.in (tar_verbose_opt): Add option --quiet.
* tests/openpgp/gpgtar.test (GPGZIP): Pass option --quiet.
* tests/openpgp/mds.test: Indent MD5 notice.
* tests/openpgp/version.test: Indent --version output.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-03 11:26:06 +02:00
Werner Koch
d73e83c3b6
gpg: Re-format some tofu messages.
* common/status.h (STATUS_TOFU_USER, STATUS_TOFU_STATS)
(STATUS_TOFU_STATS_SHORT, STATUS_TOFU_STATS_LONG): New.
* g10/tofu.c (NO_WARNING_THRESHOLD): New.
(record_binding, tofu_register): Take care of --dry-run.
(show_statistics): Print STATUS_TOFU_USER.  Reformat some messages.
Fix the ngettext/strcmp thing.  Use log_string instead of log_info.
Use NO_WARNING_THRESHOLD constant.
(get_trust): Use format_text and print a compact fingerprint.

--

The use of log_string makes long messages better readable; instead of

  gpg: Warning: if you think you've seen more[...]
  key, then this key might be a forgery!  Car[...]
  address for small variations.  If the key i[...]

we now have

  gpg: Warning: if you think you've seen more[...]
       key, then this key might be a forgery![...]
       address for small variations.  If the [...]

We also put the key information after the message and not between the
user id and the last used info like here:

  gpg: Verified 7 messages signed by "Werner Koch <werner@eifzilla.de>"
       in the past 4 days, 16 hours.
       The most recent message was verified 3 days, 13 hours ago.
       (key: 8061 5870 F5BA D690 3336  [...] 1E42 B367, policy: auto)

This also makes the key info a separate translatable string.

Further a compact version of the fingerprint (hex w/o spaces) is
printed in some messages.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-02 13:18:20 +02:00
Werner Koch
35f4b6aafd
common: Extend log_string to indent lines.
* common/logging.c (do_logv): Add indentation when called via
log_string.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-29 21:45:15 +02:00
Werner Koch
9740dff9f4
common: Improve log_assert.
* common/logging.c (bug_at): Do not i18n the string.
(_log_assert): New.
* common/logging.h (log_assert): Use new function and pass line
information.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-29 11:04:04 +02:00
Werner Koch
b7fa4960c2
common: Minor fixes for the new private-keys.c.
* common/private-keys.c (my_error_from_syserror): New.  Use it in
place of gpg_error_from_syserror.
(_pkc_add, pkc_lookup, pke_next_value): Use ascii_strcasecmp.
(pkc_parse): Use xtrystrdup and append_to_strlist_try as intended.

(_pkc_add): Add braces around if-statement.
--

We should have a macro so that we do not need to define a wrapper
function like my_error_from_syserror in files where it is needed.  I
am not sure about a proper name, "my_" seems to be the easiest
replacement.  Note that the global DEFAULT_ERRSOURCE is relatively new
to replace the need to convey the error source in function calls; we
want that function from common/ return the error source of the main
binary.

We require that a key is ASCII and thus we better use ascii_strcasecmp
to avoid problems with strange locales.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-25 18:14:12 +02:00
Werner Koch
8776abbe02
common: Use new function to print a failure of xtrymalloc.
* common/miscellaneous.c (xoutofcore): New.
* common/strlist.c (append_to_strlist): Use instead of abort.
(append_to_strlist_try): Use xtrymalloc instead of xmalloc.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-25 17:26:57 +02:00
Justus Winter
b8cb0973bc common: Drop unused variables, fix warnings.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-04-21 15:35:37 +02:00