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

5456 Commits

Author SHA1 Message Date
Werner Koch
64e8708339
Avoid incompatible pointer assignment warnings on Windows.
* common/logging.c (fun_writer): Use gpgrt_ssize_t instead of ssize_t.
* dirmngr/server.c (data_line_cookie_write): Ditto.
* sm/certdump.c (format_name_writer): Ditto.
* sm/server.c (data_line_cookie_write): Ditto.
* dirmngr/http.c (cookie_read, cookie_write): Ditto.
--

See the release notes of libgpg-error 1.15 for background info on
gpgrt_ssize_t.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-27 18:32:17 +01:00
Werner Koch
100f34e869
dirmngr: Avoid a declarations after statements.
* tools/gpgtar.c (parse_arguments): Use a block for a local varibale
definition.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-27 17:12:56 +01:00
Werner Koch
6501741d2c
dirmngr: Avoid casting away a const from an char**.
* dirmngr/ldap.c (start_cert_fetch_ldap): Do not use pointers from
global variables.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-27 17:10:59 +01:00
Werner Koch
da5a232199
dirmngr: Allow testing for a running Tor via "getinfo tor".
* dirmngr/server.c (cmd_getinfo): Print an S line if Tor is not
running.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-27 12:21:45 +01:00
Werner Koch
82f6abb480
g13: Fix commit 1a045b13.
* g13/g13.c (main): Use existsing function.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-26 18:10:05 +01:00
Werner Koch
61941a9849
common: Fix off-by-one access in the new format_text.
* common/stringhelp.c (format_text): Use existsing fucntion to trim
trailing spaces.  Fix off-by-one access.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-26 18:05:27 +01:00
Werner Koch
d226e67856
dirmngr: Improve output of "getinfo tor".
* dirmngr/server.c (cmd_getinfo): Print a message along with OK.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-26 18:05:27 +01:00
Werner Koch
f95cff1cc9
dirmngr: Let Libassuan employ nPth wrappers for connect.
* dirmngr/http.c (my_unprotect, my_protect): Remove.
(connect_server): Do not use these wrappers.
--

Since Libassuan version 2.4.2 the macro ASSUAN_SYSTEM_NPTH_IMPL
protects the low-level connect calls with npth_unprotect and
npth_protect.  This is better than the high-level kludge we used here.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-11-26 18:05:26 +01:00
Justus Winter
676b2d7081 tools/gpgtar: Add '--dry-run'.
* tools/gpgtar-extract.c (extract_{regular,directory}): Honor
'--dry-run'.
* tools/gpgtar.c (enum cmd_and_opt_values): New value.
(opts): Add '--dry-run'.
(parse_arguments): Handle '--dry-run'.
* tools/gpgtar.h (opt): Add field 'dry_run'.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-26 17:05:12 +01:00
Justus Winter
69a8440f44 tools/gpgtar: Handle '--gpg-args'.
* tools/gpgtar-create.c (gpgtar_create): Use given arguments.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (gpgtar_list): Likewise.
* tools/gpgtar.c (enum cmd_and_opt_values): New value.
(opts): Add 'gpg-args'.
(parse_arguments): Handle arguments.
* tools/gpgtar.h (opt): Add field 'gpg_arguments'.
* tests/openpgp/gpgtar.test: Simplify accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-26 15:36:52 +01:00
Justus Winter
1a045b1324 common: Make the GPG arguments configurable in call-gpg.
* common/call-gpg.c (start_gpg): Add parameter 'gpg_arguments'.
(_gpg_encrypt, gpg_encrypt_blob, gpg_encrypt_stream): Likewise.
(_gpg_decrypt, gpg_decrypt_blob, gpg_decrypt_stream): Likewise.
* common/call-gpg.h: Adapt prototypes.
* g13/create.c (encrypt_keyblob): Adapt callsite.
* g13/g13-common.h (opt): Add field 'gpg_arguments'.
* g13/g13.c (main): Construct default arguments.
* g13/mount.c (decrypt_keyblob): Adapt callsite.
* tools/gpgtar-create.c (gpgtar_create): Likewise.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (gpgtar_list): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-26 15:01:40 +01:00
Justus Winter
2eb3248058 tools/gpgtar: Handle '--tar-args' for compatibility with gpg-zip.
* tools/gpgtar.c (enum cmd_and_opt_values): New value.
(opts): Add new group for tar options, rearrange a little, add
'--tar-args'.
(tar_opts): New variable.
(shell_parse_stringlist): New function.
(shell_parse_argv): Likewise.
(parse_arguments): Add option argument, handle '--tar-args'.
(main): Fix invokation of 'parse_arguments'.
* tests/openpgp/gpgtar.test: Simplify decryption.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-26 14:28:22 +01:00
Justus Winter
35c0c8b211 tools/gpgtar: Rework argument parsing.
* tools/gpgtar.c (main): Move argument parsing into its own function.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-26 11:46:35 +01:00
Justus Winter
556e8c4426 tests: Add tests for gpgtar and gpg-zip.
* tests/openpgp/Makefile.am (TESTS): Add new file.
* tests/openpgp/gpgtar.test: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 18:38:45 +01:00
Justus Winter
127aba9a4d tools/gpgtar: Handle '--directory' argument.
* tools/gpgtar-extract.c (gpgtar_extract): Only generate a directory
name if none is given via arguments.
* tools/gpgtar.c (enum cmd_and_opt_values): New constant.
(opts): Add argument.
(main): Parse argument.
* tools/gpgtar.h (opt): New field 'directory'.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 18:29:22 +01:00
Justus Winter
89e104eb38 tools/gpgtar: Handle '--gpg' argument.
* tools/gpgtar-create.c (gpgtar_create): Use given gpg program.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (gpgtar_list): Likewise.
* tools/gpgtar.c (enum cmd_and_opt_values): New constant.
(opts): Add argument.
(main): Handle argument.
* tools/gpgtar.h (opt): Add field 'gpg_program'.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 14:57:14 +01:00
Justus Winter
f76fb047c1 tools/gpgtar: Improve error handling.
* tools/gpgtar-create.c (gpgtar_create): Return an error code, fix
error handling.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (read_header): Return an error code.
(gpgtar_list): Return an error code, fix error handling.
(gpgtar_read_header): Return an error code.
* tools/gpgtar.c: Add missing include.
(main): Print an generic error message if a command failed and no
error has been printed yet.
* tools/gpgtar.h (gpgtar_{create,extract,list,read_header}): Fix the
prototypes accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 14:34:16 +01:00
Justus Winter
40dbee86f3 tools: Add encryption and decryption support to gpgtar.
* tools/Makefile.am: Amend CFLAGS and LDADD.
* tools/gpgtar-create.c (gpgtar_create): Add encrypt flag and encrypt
stream if requested.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise for decryption.
* tools/gpgtar-list.c (gpgtar_list): Likewise.
* tools/gpgtar.c (main): Initialize npth and assuan.  Parse recipient
and local user, and note which flags are currently ignored.  Adapt
calls to gpgtar_list and friends.
(tar_and_encrypt): Drop stub function and prototype.
(decrypt_and_untar): Likewise.
(decrypt_and_list): Likewise.
* tools/gpgtar.h (gpgtar_{create,extract,list}): Add encryption or
decryption argument.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 12:19:50 +01:00
Justus Winter
03bf88f32c common: Add stream interface to call-pgp.
* common/call-gpg.c (struct writer_thread_parms): Add field 'stream'.
(writer_thread_main): Support reading from a stream.
(start_writer): Add stream argument.
(struct reader_thread_parms): Add field 'stream'.
(reader_thread_main): Support writing to a stream.
(start_reader): Add stream argument.
(_gpg_encrypt): Add stream api.
(gpg_encrypt_blob): Adapt accordingly.
(gpg_encrypt_stream): New function.
(_gpg_decrypt): Add stream api.
(gpg_decrypt_blob): Adapt accordingly.
(gpg_decrypt_stream): New function.
* common/call-gpg.h (gpg_encrypt_stream): New prototype.
(gpg_decrypt_stream): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 12:19:50 +01:00
Justus Winter
cb18d80230 common: Refactor the call-gpg code.
* common/call-gpg.c (gpg_{en,de}crypt_blob): Move most of the code
into two new functions, _gpg_encrypt and _gpg_decrypt.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 12:19:50 +01:00
Justus Winter
ba1a5cc17d g13: Move 'call-gpg.c' to common.
* common/Makefile.am (common_sources): Add files.
* g13/call-gpg.c: Move to 'common' and adapt slightly.  Add a
parameter to let callees override the gpg program to execute.
* g13/call-gpg.h: Likewise.
* g13/Makefile.am (g13_SOURCES): Drop files.
* g13/create.c (encrypt_keyblob): Hand in the gpg program to execute.
* g13/mount.c (decrypt_keyblob): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-25 12:19:50 +01:00
Neal H. Walfield
e9c16fee25 gpg: When comparing keyids, use the keyid, not the fingerprint's suffix.
* g10/keyedit.c (menu_select_key): Use spacep and hexdigitp instead of
inline tests.  Don't compare P to the suffix of the fingerprint.  If P
appears to be a keyid, do an exact compare against the keyid.  If it
appears to be a fingerprint, do an exact compare against the
fingerprint.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-24 13:03:24 +01:00
Neal H. Walfield
19362a8dd7 gpg: Reflow long texts.
* common/stringhelp.c (format_text): New function.
* common/t-stringhelp.c (stresc): New function.
(test_format_text): New function.  Test format_text.
* g10/tofu.c (get_trust): Use format_text to reflow long texts.
(show_statistics): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-23 22:23:38 +01:00
Neal H. Walfield
5b84b0d660 common: Extend utf8_charcount to include the string's length.
* common/stringhelp.c (utf8_charcount): Take additional parameter,
len.  Process at most LEN bytes.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-23 22:23:37 +01:00
Justus Winter
b75e1b3d8b dirmngr: Fix http lookups when libadns is used.
* dirmngr/dns-stuff.c (resolve_name_adns): Fill in the port.
--
Previously, sin_port was set to zero, making connect fail.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 15:53:41 +01:00
Justus Winter
946faaff04 dirmngr: Fix SRV record lookups when using the system resolver.
* dirmngr/dns-stuff.c (getsrv): Fix error handling.
--
This fixes hkp server pools not using SRV records.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 15:52:50 +01:00
Justus Winter
73c1a86ad9 dirmngr: Honor ports specified in SRV records.
* dirmngr/ks-engine-hkp.c (struct hostinfo_s): New field 'port'.
(create_new_hostinfo): Initialize 'port'.
(add_host): Add host parameter and update the hosttable entry.
(map_host): Return port if known, adjust calls to 'add_host'.
(make_host_part): Let 'map_host' specify the port if known.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 14:00:48 +01:00
Justus Winter
c9f5aa1579 dirmngr: Support hkp server pools using SRV records.
* dirmngr/ks-engine-hkp.c (map_host): Handle SRV records.
--
Signed-off-by: Justus Winter <justus@g10code.com>
GnuPG-bug-id: 1788
2015-11-23 14:00:48 +01:00
Justus Winter
3f52f6bcac dirmngr: Refactor 'map_host'.
* dirmngr/ks-engine-hkp.c (add_host): New function.
(map_host): Use the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 14:00:47 +01:00
Justus Winter
23ea641ba2 dirmngr: Fix pool detection.
* dirmngr/ks-engine-hkp (arecords_is_pool): Fix counting IP addresses.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 14:00:47 +01:00
Justus Winter
2b43a05158 dirmngr: Refactor 'map_host'.
* dirmngr/ks-engine-hkp.c (arecords_is_pool): New function.
(map_host): Use the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-23 13:47:47 +01:00
Justus Winter
a9e0b1dd6c dirmngr: Start dirmngr on demand.
* common/asshelp.h: Include 'util.h'.
* dirmngr/dirmngr-client.c (main): Use 'start_new_dirmngr' to connect
to the dirmngr.
(start_dirmngr): Drop now unused declaration and function.
--
Signed-off-by: Justus Winter <justus@g10code.com>
GnuPG-bug-id: 1843
2015-11-23 13:41:15 +01:00
Neal H. Walfield
770c06ed4e gpg: If sqlite is not available, don't build things depending on it.
* configure.ac: Define the automake conditional SQLITE3.
* tests/openpgp/Makefile.am (TESTS): Move the sqlite3 dependent tests
to...
(sqlite3_dependent_tests): ... this new variable.  If SQLITE3 is not
defined, then clear this variable.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-23 12:42:31 +01:00
Neal H. Walfield
b64b33bb80 gpg: Allow updating the expiration time of multiple subkeys at once.
* g10/keyedit.c (menu_expire): Allow updating the expiration time of
multiple subkeys at once.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 1944
2015-11-23 12:16:33 +01:00
Neal H. Walfield
19f099463c gpg: Don't crash if key is not passed an argument.
* g10/keyedit.c (menu_select_key): Don't crash if P is NULL.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-23 11:21:24 +01:00
Neal H. Walfield
178af9c3f5 gpg: Fail if the search description passed to --gen-revoke is ambiguous.
* g10/revoke.c (gen_revoke): Error out if the search description is
ambiguous.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-20 13:00:19 +01:00
Neal H. Walfield
f8a65ac96b gpg: Refactor print_seckey_info.
* g10/keylist.c (print_seckey_info): Break formatting functionality
into...
(format_seckey_info): ... this new function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-20 12:52:04 +01:00
Neal H. Walfield
46e128d44a gpg: Improve an error message.
* g10/revoke.c (gen_revoke): Provide a more descriptive error message
if searching for a key fails.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 1987
2015-11-20 12:17:13 +01:00
Justus Winter
6b14df5525 dirmngr: Improve error handling.
* dirmngr/crlcache.c (crl_cache_cert_isvalid): Add missing break.
--
Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 17:53:18 +01:00
Justus Winter
b223cde311 dirmngr: Fix memory leak.
* dirmngr/ldap.c (start_cert_fetch_ldap): Avoid leaking all malloc'ed
arguments.
--
Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 17:53:18 +01:00
Justus Winter
a1650b1edf agent: Improve error handling.
* agent/trustlist.c (istrusted_internal): Initialize 'err'.
--
There is a plausible path of execution so that a branch condition uses
the uninitialized value.

Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 16:18:20 +01:00
Justus Winter
eb957ffc47 common: Avoid undefined behavior.
* common/iobuf.c (iobuf_esopen): Initialize 'len' as 'file_es_filter'
will make use of it.
--
Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 16:13:55 +01:00
Justus Winter
52f7f195b1 g10: Avoid undefined behavior.
* g10/trust.c (clean_one_uid): Avoid a computation involving an
uninitialized value.
--
Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 15:48:01 +01:00
Justus Winter
6a37b45a7f scd: Improve error handling.
* scd/app-openpgp.c (get_public_key): Improve error handling.
--
Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 15:46:29 +01:00
Justus Winter
f596f8defa dirmngr: Fix typo.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-19 15:08:42 +01:00
Justus Winter
eb54fca4bf dirmngr: Gracefully handle premature termination of TLS streams.
* dirmngr/http.c (close_tls_session): New function.
(session_unref): Use the new function to close the TLS stream.
(cookie_read): If the stream terminated prematurely, close it and
return a short read.
--
With this patch, I was able to update all the keys in the Debian
keyring over hkps.

Signed-off-by: Justus Winter <justus@g10code.com>
GnuPG-bug-id: 1950
2015-11-18 15:06:48 +01:00
Neal H. Walfield
84ebf15b06 tools: Fix option parsing for gpg-zip.
* tools/gpg-zip.in: Correctly set GPG when --gpg is specified.
Correctly set TAR when --tar is specified.  Pass TAR_ARGS to tar.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Co-authored-by: Michael Mönch <michael.moench@marktjagd.de>
GnuPG-bug-id 1351
GnuPG-bug-id 1442
2015-11-17 22:15:33 +01:00
Neal H. Walfield
0b86c7463c gpg: Allow selecting subkeys using a keyid.
* g10/keyedit.c (menu_select_key): Take an additional argument, p.
Update callers.  If P is a hex string, then assume that P is a key id
or fingerprint and select subkeys with matching key ids or
fingerprints.
* doc/gpg.texi: Update documentation for the key subcommand.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 1423
Debian-bug-id: 610336
2015-11-17 21:23:16 +01:00
Justus Winter
1e3dbb15af dirmngr: Fix specifying keyservers by IP address.
* dirmngr/ks-engine-hkp.c (map_host): Update the original 'hosttable'
entry instead of creating another one.
--
Previously, if a keyserver was given using its IP address
(e.g. 'hkp://127.0.0.1'), 'map_host' would create two entries in the
'hosttable', one with the name '127.0.0.1', and the second one with
the name 'localhost' and 'v4addr' being set to '127.0.0.1'.  But the
first entry is the one being used for lookups, and since the 'v4' flag
is not set, the 'HTTP_FLAG_IGNORE_IPv4' is used when doing the http
request, making it fail.

Signed-off-by: Justus Winter <justus@g10code.com>
GnuPG-bug-id: 2012
2015-11-17 16:09:45 +01:00
Neal H. Walfield
58e4a492e2 gpg: Change keydb_search to not return legacy keys.
* g10/keyring.c (keyring_search): Take new argument, ignore_legacy.
If set, skip any legacy keys.  Update callers.
* g10/keydb.c (keydb_search): Skip any legacy keys.
(keydb_search_first): Don't skip legacy keys.  Treat them
as an error.
(keydb_search_next): Likewise.
(keydb_search_fpr): Likewise.
* g10/export.c (do_export_stream): Likewise.
* g10/getkey.c (lookup): Likewise.
(have_secret_key_with_kid): Likewise.
* g10/keylist.c (list_all): Likewise.
(keyring_rebuild_cache): Likewise.
* g10/keyserver.c (keyidlist): Likewise.
* g10/trustdb.c (validate_key_list): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2015-11-17 14:53:05 +01:00