chiark / gitweb /
gnupg2.git
6 years agodirmngr: Ignore warning alerts in the GNUTLS handshake.
Werner Koch [Fri, 17 Mar 2017 11:46:09 +0000 (12:46 +0100)]
dirmngr: Ignore warning alerts in the GNUTLS handshake.

* dirmngr/http.c (send_request) [GNUTLS]: Don't bail out on warning
alerts.
--

GnuPG-bug-id: 2833
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 69c521df422a6c9a6b0a93e45c9373a8b6ceb28e)

Gbp-Pq: Name 0051-dirmngr-Ignore-warning-alerts-in-the-GNUTLS-handshak.patch

6 years agogpg: Flush stdout before printing stats with --check-sigs.
Werner Koch [Mon, 13 Mar 2017 16:42:08 +0000 (17:42 +0100)]
gpg: Flush stdout before printing stats with --check-sigs.

* g10/keylist.c (print_signature_stats): Flush stdout.
(list_keyblock_colon): Use es_flush instead of fflush.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 9a77b3b6e41f97b1209ad61c04b3dd33242ecae8)

Gbp-Pq: Name 0050-gpg-Flush-stdout-before-printing-stats-with-check-si.patch

6 years agodoc: Add a note to the trust model direct.
Werner Koch [Wed, 8 Mar 2017 09:46:09 +0000 (10:46 +0100)]
doc: Add a note to the trust model direct.

* doc/gpg.texi (GPG Configuration Options): Add note.  Chnage Index
from trust-mode:foo to trust-model:foo.

(cherry picked from commit f0257b4a86b73f5b956028e68590b6d2a23ea4da)

Gbp-Pq: Name 0049-doc-Add-a-note-to-the-trust-model-direct.patch

6 years agogpg: Fix attempt to double free an UID structure.
Werner Koch [Sun, 5 Mar 2017 22:24:15 +0000 (23:24 +0100)]
gpg: Fix attempt to double free an UID structure.

* g10/getkey.c (get_best_pubkey_byname): Set released .UID to NULL.
--

Phil Pennock reported an assertion failure when doing

  % gpg --auto-key-locate dane --locate-keys someone
  gpg: Ohhhh jeeee: Assertion "uid->ref > 0" in \
         free_user_id failed (free-packet.c:310)

on his keyring.  This patch is not tested but a good guess.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 4a130bbc2c2f4be6e8c6357512a943f435ade28f)

Gbp-Pq: Name 0048-gpg-Fix-attempt-to-double-free-an-UID-structure.patch

6 years agogpg: Fix possible segv when attribute packets are filtered.
Werner Koch [Fri, 3 Mar 2017 08:50:40 +0000 (09:50 +0100)]
gpg: Fix possible segv when attribute packets are filtered.

* g10/import.c (impex_filter_getval): Handle PKT_ATTRIBUTE the same as
PKT_USER_ID
(apply_drop_sig_filter): Ditto.
--

The old code was plainly wrong in that it considered PKT_ATTRIBUTE to
use a PKT_signature object.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5f6f3f5cae8a95ed469129f9677782c17951dab3)

Gbp-Pq: Name 0047-gpg-Fix-possible-segv-when-attribute-packets-are-fil.patch

6 years agog10: Signal an error when trying to revoke non-existant UID.
Justus Winter [Thu, 2 Mar 2017 10:39:00 +0000 (11:39 +0100)]
g10: Signal an error when trying to revoke non-existant UID.

* g10/keyedit.c (keyedit_quick_revuid): Signal an error when trying to
revoke non-existant UID.
* tests/openpgp/quick-key-manipulation.scm: Test that.

GnuPG-bug-id: 2962
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 62d21a4ab4029b32ea129f1cf3a0e1f22e2fb7b0)

Gbp-Pq: Name 0046-g10-Signal-an-error-when-trying-to-revoke-non-exista.patch

6 years agocommon,tools: Always escape newlines when escaping data.
Justus Winter [Wed, 1 Mar 2017 16:47:47 +0000 (17:47 +0100)]
common,tools: Always escape newlines when escaping data.

* common/stringhelp.c (do_percent_escape): Always escape newlines.
* tools/gpgconf-comp.c (gc_percent_escape): Likewise.
--
Newlines always pose a problem for a line-based communication format.

GnuPG-bug-id: 2387
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit e064c75b08a523f738108428fe0c417a46e66238)

Gbp-Pq: Name 0045-common-tools-Always-escape-newlines-when-escaping-da.patch

6 years agogpg: Make --export-options work with --export-secret-keys.
Werner Koch [Wed, 1 Mar 2017 13:41:47 +0000 (14:41 +0100)]
gpg: Make --export-options work with --export-secret-keys.

* g10/export.c (export_seckeys): Add arg OPTIONS and pass it to
do_export.
(export_secsubkeys): Ditto.
* g10/gpg.c (main): Pass opt.export_options to export_seckeys and
export_secsubkeys
--

Back in the old days we did not used the export options for secret
keys export because of a lot of duplicated code and that the old
secring.gpg was anyway smaller that the pubring.gpg.  With 2.1 it was
pretty easy to enable it.

Reported-by: Peter Lebbing
GnuPG-bug-id: 2973
(cherry picked from commit 891ab23411b7f20ef37d8bde81d9857b083235df)

Gbp-Pq: Name 0044-gpg-Make-export-options-work-with-export-secret-keys.patch

6 years agogpg: Allow creating keys using an existing ECC key.
Werner Koch [Wed, 1 Mar 2017 12:36:01 +0000 (13:36 +0100)]
gpg: Allow creating keys using an existing ECC key.

* common/sexputil.c (get_pk_algo_from_canon_sexp): Remove arg R_ALGO.
Change to return the algo id.  Reimplement using get_pk_algo_from_key.
* g10/keygen.c (check_keygrip): Adjust for change.
* sm/certreqgen-ui.c (check_keygrip): Ditto.
--

GnuPG-bug-id: 2976
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 2bbdeb8ee87a6c7ec211be16391a11b7c6030bed)

Gbp-Pq: Name 0043-gpg-Allow-creating-keys-using-an-existing-ECC-key.patch

6 years agogpg,tools: Make auto-key-retrieve configurable via gpgconf.
Justus Winter [Tue, 28 Feb 2017 13:59:11 +0000 (14:59 +0100)]
gpg,tools: Make auto-key-retrieve configurable via gpgconf.

* g10/gpg.c (gpgconf_list): Add 'auto-key-retrieve'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit d379a0174cca595204b32da9a66c513a1304e6d0)

Gbp-Pq: Name 0042-gpg-tools-Make-auto-key-retrieve-configurable-via-gp.patch

6 years agogpg,tools: Make trust-model configurable via gpgconf.
Justus Winter [Tue, 28 Feb 2017 12:15:42 +0000 (13:15 +0100)]
gpg,tools: Make trust-model configurable via gpgconf.

* g10/gpg.c (gpgconf_list): Add 'trust-model'.
* tools/gpgconf-comp.c (gc_options_gpg): Likewise.

GnuPG-bug-id: 2381
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit ebeccd73eb85f9027f0985d77dfe901266c6ddef)

Gbp-Pq: Name 0041-gpg-tools-Make-trust-model-configurable-via-gpgconf.patch

6 years agogpgv,w32: Fix --status-fd.
Werner Koch [Tue, 28 Feb 2017 08:35:41 +0000 (09:35 +0100)]
gpgv,w32: Fix --status-fd.

* g10/gpgv.c (main): Use translate_sys2libc_fd_int for --status-fd.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 8a67dc4c4324b617b5a3fea51c59c674488544d6)

Gbp-Pq: Name 0040-gpgv-w32-Fix-status-fd.patch

6 years agodirmngr: Avoid PTR lookup for hosts in a pool
Werner Koch [Wed, 15 Feb 2017 16:03:57 +0000 (17:03 +0100)]
dirmngr: Avoid PTR lookup for hosts in a pool

* dirmngr/ks-engine-hkp.c (add_host): Don't to a PTR lookup for hosts
in a pool.
--

GnuPG-bug-id: 2928
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit da2ba20868093e3054d18adc2b1bc56cb23e4ba7)

Gbp-Pq: Name 0039-dirmngr-Avoid-PTR-lookup-for-hosts-in-a-pool.patch

6 years agogpg: Make --export-ssh-key work for the primary key.
Werner Koch [Tue, 14 Feb 2017 09:55:13 +0000 (10:55 +0100)]
gpg: Make --export-ssh-key work for the primary key.

* g10/export.c (export_ssh_key): Also check the primary key.
--

If no suitable subkey was found for export, we now check whether the
primary key is suitable for export and export this one.  Without this
change it was only possible to export the primary key by using the '!'
suffix in the key specification.

Also added a sample key for testing this.

GnuPG-bug-id: 2957
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit b456e5be91dc064fc9509ea86edab113721ed299)

Gbp-Pq: Name 0038-gpg-Make-export-ssh-key-work-for-the-primary-key.patch

6 years agodirmngr: Do a DNS lookup even if it is missing from nsswitch.conf.
Werner Koch [Mon, 13 Feb 2017 19:09:26 +0000 (20:09 +0100)]
dirmngr: Do a DNS lookup even if it is missing from nsswitch.conf.

* dirmngr/dns-stuff.c (libdns_init): Do not print error message for a
missing nsswitch.conf.  Make sure that tehre is a DNS entry.
--

GnuPG-bug-id: 2948
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit dee026d761ae3d7594c3dbc5b3fa842df53cc189)

Gbp-Pq: Name 0037-dirmngr-Do-a-DNS-lookup-even-if-it-is-missing-from-n.patch

6 years agogpgconf: No ENOENT warning with --change-options et al.
Werner Koch [Mon, 13 Feb 2017 18:38:53 +0000 (19:38 +0100)]
gpgconf: No ENOENT warning with --change-options et al.

* tools/gpgconf-comp.c (retrieve_options_from_program): Check ERRNO
before printing a warning.
--

It is common that a conf files does not exist - thus we should not
print a warning.

GnuPG-bug-id: 2944

BTW: The error messages in gpgconf should be reworked to match those
of the other components.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 30dac0486b6357e84fbe79c612eea940b654e4d1)

Gbp-Pq: Name 0036-gpgconf-No-ENOENT-warning-with-change-options-et-al.patch

6 years agogpg: Print a warning if no command has been given.
Werner Koch [Mon, 13 Feb 2017 12:09:51 +0000 (13:09 +0100)]
gpg: Print a warning if no command has been given.

* g10/gpg.c (main): Print in the default case.
--

GnuPG-bug-id: 2943
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 810adfd47801fc01e45fb71af9f05c91f7890cdb)

Gbp-Pq: Name 0035-gpg-Print-a-warning-if-no-command-has-been-given.patch

6 years agogpg: Fix memory leak in the error case of signature creation.
Werner Koch [Fri, 10 Feb 2017 16:16:07 +0000 (17:16 +0100)]
gpg: Fix memory leak in the error case of signature creation.

* g10/sign.c (write_signature_packets): Free SIG.  Also replace
xcalloc by xtrycalloc.
--

If do_sign fails SIG was not released.  Note that in the good case SIG
is transferred to PKT and freed by free_packet.

Reported-by: Stephan Müller
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5996c7bf99f3a681393fd9589276399ebc956cff)

Gbp-Pq: Name 0034-gpg-Fix-memory-leak-in-the-error-case-of-signature-c.patch

6 years agocommon: Avoid warning about implicit declaration of gnupg_fd_valid.
Daniel Kahn Gillmor [Wed, 8 Feb 2017 17:05:08 +0000 (12:05 -0500)]
common: Avoid warning about implicit declaration of gnupg_fd_valid.

* 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 <dkg@fifthhorseman.net>
(cherry picked from commit 8810314e377a9cb6612150a57cf99260ed0bb9f6)

Gbp-Pq: Name 0033-common-Avoid-warning-about-implicit-declaration-of-g.patch

6 years agogpg,common: Make sure that all fd given are valid.
Justus Winter [Wed, 8 Feb 2017 12:49:41 +0000 (13:49 +0100)]
gpg,common: Make sure that all fd given are valid.

* 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 <justus@g10code.com>
(cherry picked from commit 6823ed46584e753de3aba48a00ab738ab009a860)

Gbp-Pq: Name 0032-gpg-common-Make-sure-that-all-fd-given-are-valid.patch

6 years agogpg: Fix aliases --list-key, --list-sig, and --check-sig.
Daniel Kahn Gillmor [Sat, 4 Feb 2017 06:23:32 +0000 (01:23 -0500)]
gpg: Fix aliases --list-key, --list-sig, and --check-sig.

* g10/gpg.c (opts): Define commands with ARGPARSE_c
instead of ARGPARSE_s_n.

--

These three entries are commands, but they're being treated as a
string-based option for some reason.  However, if you try to use them
concurrently with another command like --clearsign, you'll get "gpg:
conflicting commands".

Furthermore, because they're marked as options, their flags differ
from the commands that they alias, they cause ambiguity in
abbreviation (e.g. try "gpg --list-ke") which should have been fixed
by 7249ab0f95d1f6cb8ee61eefedc79801bb56398f.

Marking them explicitly as commands for argparse should be more
accurate and should resolve the abbreviation ambiguity issue.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
gpg: fix aliases --list-key, --list-sig, and --check-sig.

* g10/gpg.c: ARGPARSE_OPTS opts[]: define commands with ARGPARSE_c
instead of ARGPARSE_s_n.

--

These three entries are commands, but they're being treated as a
string-based option for some reason.  However, if you try to use them
concurrently with another command like --clearsign, you'll get "gpg:
conflicting commands".

Furthermore, because they're marked as options, their flags differ
from the commands that they alias, they cause ambiguity in
abbreviation (e.g. try "gpg --list-ke") which should have been fixed
by 7249ab0f95d1f6cb8ee61eefedc79801bb56398f.

Marking them explicitly as commands for argparse should be more
accurate and should resolve the abbreviation ambiguity issue.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
(cherry picked from commit f31120a5aa40b6e4e89d41d1d5d34e0f7da173b4)

Gbp-Pq: Name 0031-gpg-Fix-aliases-list-key-list-sig-and-check-sig.patch

6 years agoscd: Fix factory-reset.
NIIBE Yutaka [Fri, 17 Feb 2017 08:30:05 +0000 (03:30 -0500)]
scd: Fix factory-reset.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Backport from master branch:

    99d4dfe83
    e2792813a
    031e3fa7b

Additionally, fix another bug when tested with 2.1.18-7 with PC/SC.

Gbp-Pq: Name 0030-scd-Fix-factory-reset.patch

6 years agoscd: Fix use case of PC/SC.
NIIBE Yutaka [Mon, 13 Feb 2017 02:09:13 +0000 (11:09 +0900)]
scd: Fix use case of PC/SC.

* scd/apdu.c (apdu_open_reader): Add an argument APP_EMPTY.
When CCID driver fails to open, try PC/SC if APP is nothing.
* scd/app.c (select_application): Supply arg if APP is nothing.

--

After scanning available card readers by CCID driver, scdaemon should
try PC/SC service if no APP is registered yet.  Also, when the slot
is allocated for PC/SC (ccid.handle==NULL), it should not call
ccid_compare_BAI, otherwise scdaemon crashes.

Debian-bug-id: 852702, 854005, 854595, 854616

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Gbp-Pq: Name 0029-scd-Fix-use-case-of-PC-SC.patch

6 years agoscd: Backport two fixes from master.
NIIBE Yutaka [Sat, 4 Feb 2017 23:34:08 +0000 (08:34 +0900)]
scd: Backport two fixes from master.

* scd/app.c (app_new_register): Initialize by -1, so that it can detect
an error correctly when card reader can't power-on the card initially.
* scd/command.c (open_card_with_request): Release APP before the scan.

--
The first one-liner patch handles an erroneous card.

The second patch handles the case when we repeatedly do
signing/decrypting by a single session of scdaemon.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Gbp-Pq: Name 0028-scd-Backport-two-fixes-from-master.patch

6 years agodoc: Clarify abbreviation of --help.
Daniel Kahn Gillmor [Sat, 4 Feb 2017 06:28:08 +0000 (01:28 -0500)]
doc: Clarify abbreviation of --help.

* doc/gpg.texi: clarify abbreviation of --help.

Debian-bug-id: 852979
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
(cherry picked from commit f2b276dffbe2435b17abf2b3c51684d3636f3f11)

Gbp-Pq: Name 0027-doc-Clarify-abbreviation-of-help.patch

6 years agogpg: More diagnostics for a launched pinentry.
Werner Koch [Fri, 3 Feb 2017 11:04:52 +0000 (12:04 +0100)]
gpg: More diagnostics for a launched pinentry.

* agent/call-pinentry.c (start_pinentry): Call getinfo/ttyinfo.
* g10/server.c (gpg_proxy_pinentry_notify): Simplify the output so
that we do not change the code when adding new fields to
PINENTRY_LAUNCHED.
--

This patch changes the --verbose output of gpg to show
for example

  gpg: pinentry launched (5228 gtk2 1.0.1-beta10 \
  /dev/pts/4 xterm localhost:10.0)

the used tty, its type, and the value of DISPLAY in addiion to the
pid, flavor, and version.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 7052a0d77cf8f3a445b252a809d29be445788625)

Gbp-Pq: Name 0026-gpg-More-diagnostics-for-a-launched-pinentry.patch

6 years agogpg: Don't assume that strtoul interprets "" as 0.
Neal H. Walfield [Thu, 2 Feb 2017 14:48:45 +0000 (15:48 +0100)]
gpg: Don't assume that strtoul interprets "" as 0.

* g10/tofu.c (show_statistics): If there are not records, return 0
instead of NULL.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2853

According to SUSv3:

  If the subject sequence is empty or does not have the expected form,
  no conversion is performed
  ...
  If no conversion could be performed, 0 is returned and errno may be
  set to [EINVAL].

  http://pubs.opengroup.org/onlinepubs/007908799/xsh/strtol.html

It appears that MacOS X sets errno to EINVAL, but glibc doesn't.
Hence, we map NULL to 0 explicitly.

(cherry picked from commit 407f5f9baea5591f148974240a87dfb43e5efef3)

Gbp-Pq: Name 0025-gpg-Don-t-assume-that-strtoul-interprets-as-0.patch

6 years agogpg: Ensure TOFU bindings associated with UTKs are registered as usual
Neal H. Walfield [Thu, 2 Feb 2017 13:24:38 +0000 (14:24 +0100)]
gpg: Ensure TOFU bindings associated with UTKs are registered as usual

* g10/tofu.c (get_trust): Call get_policy before short-circuiting the
policy lookup for ultimately trusted keys to make sure the binding is
added to the bindings table, if necessary.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2929
(cherry picked from commit 769272ba87f282a69e8d5f9bb27c86e6bec4496b)

Gbp-Pq: Name 0024-gpg-Ensure-TOFU-bindings-associated-with-UTKs-are-re.patch

6 years agogpg: If there is a TOFU conflict, elide the too few message warning.
Neal H. Walfield [Thu, 2 Feb 2017 12:26:17 +0000 (13:26 +0100)]
gpg: If there is a TOFU conflict, elide the too few message warning.

* g10/tofu.c (tofu_get_validity): If there was a conflict, don't also
print out a warning about too few messages.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit a08c781739e7561093f32b732c4991f2bd817ec2)

Gbp-Pq: Name 0023-gpg-If-there-is-a-TOFU-conflict-elide-the-too-few-me.patch

6 years agogpg: Only print out TOFU statistics for conflicts in interactive mode
Neal H. Walfield [Thu, 2 Feb 2017 12:24:57 +0000 (13:24 +0100)]
gpg: Only print out TOFU statistics for conflicts in interactive mode

* g10/tofu.c (get_trust): Add arguments POLICYP and CONFLICT_SETP.  If
they are not NULL, return the policy and conflict set (if there is
one), respectively.  Update callers.  If MAY_ASK is FALSE, don't print
out the statistics.
(tofu_register_encryption): If there is a conflict and we haven't yet
printed the statistics about the conflicting bindings, do so now.
(tofu_get_validity): Likewise.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2914
(cherry picked from commit 027b81b35fe36692005b8dba22d9eb2db05e8c80)

Gbp-Pq: Name 0022-gpg-Only-print-out-TOFU-statistics-for-conflicts-in-.patch

6 years agogpg: Add newline to output.
Neal H. Walfield [Thu, 2 Feb 2017 10:00:51 +0000 (11:00 +0100)]
gpg: Add newline to output.

* g10/tofu.c (ask_about_binding): Add newline to output.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit 74268180e5a3acc827f3a369f1fe5971f3bbe285)

Gbp-Pq: Name 0021-gpg-Add-newline-to-output.patch

6 years agogpg: Remove period at end of warning.
Neal H. Walfield [Fri, 6 Jan 2017 10:51:08 +0000 (11:51 +0100)]
gpg: Remove period at end of warning.

* g10/tofu.c (tofu_register_encryption): Remove period at end of
warning.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
(cherry picked from commit 6f9d8a956b2ca0f5a0eb7acc656fc17af2f2de47)

Gbp-Pq: Name 0020-gpg-Remove-period-at-end-of-warning.patch

6 years agodirmngr: New option --no-use-tor and internal changes.
Werner Koch [Wed, 1 Feb 2017 16:54:14 +0000 (17:54 +0100)]
dirmngr: New option --no-use-tor and internal changes.

* dirmngr/dns-stuff.c (disable_dns_tormode): New.
* dirmngr/dirmngr.c (oNoUseTor): New const.
(opts): New option --no-use-tor.
(tor_mode): New var.
(parse_rereadable_options): Change to use TOR_MODE.
(dirmngr_use_tor): New.
(set_tor_mode): Call disable_dns_tormode.  Implement oNoUseTor.
* dirmngr/dirmngr.h (opt): Remove field 'use_tor'.  Replace all
references by a call to dirmngr_use_tor().
* dirmngr/server.c (cmd_getinfo): Distinguish between default and
enforced TOR_MODE.
--

This patch replaces the global variable opt.use_tar by a function
testing a file local mode flag.  This patch prepares for a
use-tor-if-available mode.

GnuPG-bug-id: 2935
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 7440119e729d3fdedda8a9b44b70f8959beea8d7)

Gbp-Pq: Name 0019-dirmngr-New-option-no-use-tor-and-internal-changes.patch

6 years agogpg: Fix searching for mail addresses in keyrings.
Justus Winter [Wed, 25 Jan 2017 15:33:20 +0000 (16:33 +0100)]
gpg: Fix searching for mail addresses in keyrings.

* g10/keyring.c (compare_name): Fix KEYDB_SEARCH_MODE_MAIL* searches
in keyrings when the UID is a plain addr-spec.
--
Previously, 'gpg --list-key "<foo@example.org>"' failed if 1/ the
keyring format is used and 2/ the key's UID is a plain addr-spec
(cf. RFC2822 section 4.3), e.g. 'foo@example.org'.

GnuPG-bug-id: 2930
Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 3f4f20ee6eff052c88647b820d9ecfdbd8df0f40)

Gbp-Pq: Name 0018-gpg-Fix-searching-for-mail-addresses-in-keyrings.patch

6 years agoagent: Fix double free.
Justus Winter [Wed, 25 Jan 2017 12:51:57 +0000 (13:51 +0100)]
agent: Fix double free.

* 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 <justus@g10code.com>
(cherry picked from commit e175152ef7515921635bf1e00383e812668d13fc)

Gbp-Pq: Name 0017-agent-Fix-double-free.patch

6 years agogpg: Print a warning on Tor problems.
Werner Koch [Tue, 24 Jan 2017 19:45:31 +0000 (20:45 +0100)]
gpg: Print a warning on Tor problems.

* dirmngr/ks-engine-hkp.c (tor_not_running_p): New.
(map_host): Call that to print a warning.
(handle_send_request_error): Ditto and avoid marking the host dead.
Also print a tor_config_problem warning.  Add arg CTRL; adjust callers
to pass that new arg.
* g10/call-dirmngr.c (ks_status_cb): Detect and print the new
warnings.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 770b75a746836773909af25ccb9b480e61cea677)

Gbp-Pq: Name 0016-gpg-Print-a-warning-on-Tor-problems.patch

6 years agodirmngr: Simplify error returning inside http.c.
Werner Koch [Tue, 24 Jan 2017 17:41:43 +0000 (18:41 +0100)]
dirmngr: Simplify error returning inside http.c.

* dirmngr/http.c (connect_server): Change to return an gpg_error_t
and to store socket at the passed address.
(http_raw_connect, send_request): Adjust accordingly.
--

This change removes cruft from the code and allows to return the error
code from the name lookup.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 51e5a5e5a46279809848b4ab4419f35045336010)

Gbp-Pq: Name 0015-dirmngr-Simplify-error-returning-inside-http.c.patch

6 years agodirmngr: New option --disable-ipv4.
Werner Koch [Tue, 24 Jan 2017 15:36:28 +0000 (16:36 +0100)]
dirmngr: New option --disable-ipv4.

* dirmngr/dirmngr.c (oDisableIPv4): New const.
(opts): New option --disable-ipv4.
(parse_rereadable_options): Set that option.
* dirmngr/dirmngr.h (opt): New field 'disable_ipv4'.
* dirmngr/dns-stuff.c (opt_disable_ipv4): bew var.
(set_dns_disable_ipv4): New.
(resolve_name_standard): Skip v4 addresses when OPT_DISABLE_IPV4 is
set.
* dirmngr/ks-engine-hkp.c (map_host): Ditto.
(send_request): Pass HTTP_FLAG_IGNORE_IPv4 if opt.disable_v4 is set.
* dirmngr/crlfetch.c (crl_fetch): Ditto.
* dirmngr/ks-engine-finger.c (ks_finger_fetch): Ditto.
* dirmngr/ks-engine-http.c (ks_http_fetch): Ditto.
* dirmngr/ocsp.c (do_ocsp_request): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 72736af86a501592d974d46ff754a63959e183bd)

Gbp-Pq: Name 0014-dirmngr-New-option-disable-ipv4.patch

6 years agotools: Improve error handling.
Justus Winter [Mon, 23 Jan 2017 13:24:22 +0000 (14:24 +0100)]
tools: Improve error handling.

* tools/gpgconf-comp.c (gp_component_change_options): Improve error
handling when reading from stdin.
--
Previously, errors encountered while reading the configuration changes
were ignored.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit b0348fdb26637b0bcbd68a96c1746a1613b309af)

Gbp-Pq: Name 0013-tools-Improve-error-handling.patch

6 years agotools: Fix memory leak.
Justus Winter [Mon, 23 Jan 2017 10:52:30 +0000 (11:52 +0100)]
tools: Fix memory leak.

* tools/gpgconf-comp.c (change_options_file): Fix leak.
--
Previously, 'src_filename' and 'orig_filename' leaked if creating the
backup file failed.

Signed-off-by: Justus Winter <justus@g10code.com>
(cherry picked from commit 5b28f025085b386e0ec49535d4cd3f875a414eb0)

Gbp-Pq: Name 0012-tools-Fix-memory-leak.patch

6 years agoagent: Avoid scheduled checks on socket when inotify is working.
Daniel Kahn Gillmor [Tue, 1 Nov 2016 04:57:44 +0000 (00:57 -0400)]
agent: Avoid scheduled checks on socket when inotify is working.

* 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 <dkg@fifthhorseman.net>
Gbp-Pq: Topic gpg-agent-idling
Gbp-Pq: Name 0004-agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch

6 years agoagent: Avoid tight timer tick when possible.
Daniel Kahn Gillmor [Tue, 1 Nov 2016 04:14:10 +0000 (00:14 -0400)]
agent: Avoid tight timer tick when possible.

* 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 <dkg@fifthhorseman.net>
Gbp-Pq: Topic gpg-agent-idling
Gbp-Pq: Name 0003-agent-Avoid-tight-timer-tick-when-possible.patch

6 years agoagent: Allow threads to interrupt main select loop with SIGCONT.
Daniel Kahn Gillmor [Tue, 1 Nov 2016 04:45:23 +0000 (00:45 -0400)]
agent: Allow threads to interrupt main select loop with SIGCONT.

* 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 <dkg@fifthhorseman.net>
Gbp-Pq: Topic gpg-agent-idling
Gbp-Pq: Name 0002-agent-Allow-threads-to-interrupt-main-select-loop-wi.patch

6 years agoagent: Create framework of scheduled timers.
Daniel Kahn Gillmor [Tue, 1 Nov 2016 01:27:36 +0000 (21:27 -0400)]
agent: Create framework of scheduled timers.

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 <dkg@fifthhorseman.net>
Gbp-Pq: Topic gpg-agent-idling
Gbp-Pq: Name 0001-agent-Create-framework-of-scheduled-timers.patch

6 years agodirmngr: Drop useless housekeeping.
Daniel Kahn Gillmor [Sat, 29 Oct 2016 06:15:08 +0000 (02:15 -0400)]
dirmngr: Drop useless housekeeping.

* dirmngr/dirmngr.c (handle_tick, time_for_housekeeping_p,
housekeeping_thread): Remove, no longer needed.
(handle_connections): Drop any attempt at a timeout, since no
housekeeping is necessary.

--

The housekeeping thread no longer does anything, and the main loop was
waking up every 60 seconds for no good reason.  The code is simpler
and the runtime is more efficient if we drop this.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Gbp-Pq: Topic dirmngr-idling
Gbp-Pq: Name 0005-dirmngr-Drop-useless-housekeeping.patch

6 years agodirmngr: Avoid automatically checking upstream swdb.
Daniel Kahn Gillmor [Mon, 21 Nov 2016 04:09:24 +0000 (23:09 -0500)]
dirmngr: Avoid automatically checking upstream swdb.

* dirmngr/dirmngr.c (housekeeping_thread): Avoid automatically
checking upstream's software database.  In Debian, software updates
should be handled by the distro mechanism, and additional upstream
checks only confuse the user.
* doc/dirmngr.texi: document that --allow-version-check does nothing.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Gbp-Pq: Topic dirmngr-idling
Gbp-Pq: Name 0004-dirmngr-Avoid-automatically-checking-upstream-swdb.patch

6 years agodimrngr: Avoid need for hkp housekeeping.
Daniel Kahn Gillmor [Sat, 29 Oct 2016 06:00:50 +0000 (02:00 -0400)]
dimrngr: Avoid need for hkp housekeeping.

* dirmngr/ks-engine-hkp.c (host_is_alive): New function.  Test whether
host is alive and resurrects it if it has been dead long enough.
(select_random_host, map_host, ks_hkp_mark_host): Use host_is_alive
instead of testing hostinfo_t->dead directly.
(ks_hkp_housekeeping): Remove function, no longer needed.
* dirmngr/dirmngr.c (housekeeping_thread): Remove call to
ks_hkp_housekeeping.

--

Rather than resurrecting hosts upon scheduled resurrection times, test
whether hosts should be resurrected as they're inspected for being
dead.  This removes the need for explicit housekeeping, and makes host
resurrections happen "just in time", rather than being clustered on
HOUSEKEEPING_INTERVAL seconds.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Gbp-Pq: Topic dirmngr-idling
Gbp-Pq: Name 0002-dimrngr-Avoid-need-for-hkp-housekeeping.patch

6 years agodirmngr: hkp: Avoid potential race condition when some hosts die.
Daniel Kahn Gillmor [Sat, 29 Oct 2016 05:25:05 +0000 (01:25 -0400)]
dirmngr: hkp: Avoid potential race condition when some hosts die.

* dirmngr/ks-engine-hkp.c (select_random_host): Use atomic pass
through the host table instead of risking out-of-bounds write.

--

Multiple threads may write to hosttable[x]->dead while
select_random_host() is running.  For example, a housekeeping thread
might clear the ->dead bit on some entries, or another connection to
dirmngr might manually mark a host as alive.

If one or more hosts are resurrected between the two loops over a
given table in select_random_host(), then the allocation of tbl might
not be large enough, resulting in a write past the end of tbl on the
second loop.

This change collapses the two loops into a single loop to avoid this
discrepancy: each host's "dead" bit is now only checked once.

As Werner points out, this isn't currently strictly necessary, since
npth will not switch threads unless a blocking system call is made,
and no blocking system call is made in these two loops.

However, in a subsequent change in this series, we will call a
function in this loop, and that function may sometimes write(2), or
call other functions, which may themselves block.  Keeping this as a
single-pass loop avoids the need to keep track of what might block and
what might not.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Gbp-Pq: Topic dirmngr-idling
Gbp-Pq: Name 0001-dirmngr-hkp-Avoid-potential-race-condition-when-some.patch

6 years agoavoid regenerating defsincdate (use shipped file)
Daniel Kahn Gillmor [Mon, 29 Aug 2016 16:34:42 +0000 (12:34 -0400)]
avoid regenerating defsincdate (use shipped file)

upstream ships doc/defsincdate in its tarballs.  but doc/Makefile.am
tries to rewrite doc/defsincdate if it notices that any of the files
have been modified more recently, and it does so assuming that we're
running from a git repo.

However, we'd rather ship the documents cleanly without regenerating
defsincdate -- we don't have a git repo available (debian builds from
upstream tarballs) and any changes to the texinfo files (e.g. from
debian/patches/) might result in different dates on the files than we
expect after they're applied by dpkg or quilt or whatever, which makes
the datestamp unreproducible.

Gbp-Pq: Topic debian-packaging
Gbp-Pq: Name 0003-avoid-regenerating-defsincdate-use-shipped-file.patch

6 years agoAvoid simple memory dumps via ptrace
Daniel Kahn Gillmor [Wed, 12 Aug 2015 00:28:26 +0000 (20:28 -0400)]
Avoid simple memory dumps via ptrace

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://bugs.gnupg.org/gnupg/issue1211

Gbp-Pq: Topic block-ptrace-on-agent
Gbp-Pq: Name 0002-Avoid-simple-memory-dumps-via-ptrace.patch

6 years agoavoid-beta-warning
Debian GnuPG Maintainers [Tue, 14 Apr 2015 14:02:31 +0000 (10:02 -0400)]
avoid-beta-warning

avoid self-describing as a beta

Using autoreconf against the source as distributed in tarball form
invariably results in a package that thinks it's a "beta" package,
which produces the "THIS IS A DEVELOPMENT VERSION" warning string.

since we use dh_autoreconf, i need this patch to avoid producing
builds that announce themselves as DEVELOPMENT VERSIONs.

See discussion at:

 http://lists.gnupg.org/pipermail/gnupg-devel/2014-November/029065.html

Gbp-Pq: Topic debian-packaging
Gbp-Pq: Name 0001-avoid-beta-warning.patch

6 years agognupg2 (2.1.18-8~deb9u1) stretch; urgency=medium
Daniel Kahn Gillmor [Mon, 18 Sep 2017 20:41:12 +0000 (21:41 +0100)]
gnupg2 (2.1.18-8~deb9u1) stretch; urgency=medium

  * Bugfix update for debian stretch point release.

[dgit import unpatched gnupg2 2.1.18-8~deb9u1]

6 years agoImport gnupg2_2.1.18-8~deb9u1.debian.tar.bz2
Daniel Kahn Gillmor [Mon, 18 Sep 2017 20:41:12 +0000 (21:41 +0100)]
Import gnupg2_2.1.18-8~deb9u1.debian.tar.bz2

[dgit import tarball gnupg2 2.1.18-8~deb9u1 gnupg2_2.1.18-8~deb9u1.debian.tar.bz2]

7 years agoImport gnupg2_2.1.18.orig.tar.bz2
Daniel Kahn Gillmor [Tue, 24 Jan 2017 04:12:35 +0000 (04:12 +0000)]
Import gnupg2_2.1.18.orig.tar.bz2

[dgit import orig gnupg2_2.1.18.orig.tar.bz2]