[Pkg-gnupg-commit] [gnupg2] 01/03: more upstream patches
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Oct 27 17:06:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 74372b2b5dcebf9a32f8c5f23ef8a547f544ddea
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date: Thu Oct 27 12:43:36 2016 -0400
more upstream patches
---
.../0104-common-Fix-gnupg_inotify_has_name.patch | 81 ++++++++++
.../0105-dirmngr-report-actual-socket-name.patch | 63 ++++++++
...t-common-move-get_socket_name-into-common.patch | 168 +++++++++++++++++++++
...lement-supervised-command-for-systemd-etc.patch | 119 +++++++++++++++
.../0108-g10-ECDH-shared-point-format.patch | 67 ++++++++
...-0x41-prefix-for-x-coordinate-only-result.patch | 62 ++++++++
.../0110-g10-Fix-ECDH-clarifying-the-format.patch | 68 +++++++++
.../0111-dirmngr-Fix-error-return-for-ADNS.patch | 29 ++++
.../patches/0112-dirmngr-More-ADNS-error-fix.patch | 47 ++++++
...on-Fix-gnupg_inotify_has_name-differently.patch | 83 ++++++++++
.../0114-dirmngr-ADNS-error-handling-fix.patch | 48 ++++++
...ve-debug-output-from-gnupg_get_socket_nam.patch | 41 +++++
...gr-Do-not-implement-supervised-in-Windows.patch | 69 +++++++++
debian/patches/series | 13 ++
14 files changed, 958 insertions(+)
diff --git a/debian/patches/0104-common-Fix-gnupg_inotify_has_name.patch b/debian/patches/0104-common-Fix-gnupg_inotify_has_name.patch
new file mode 100644
index 0000000..7af9c98
--- /dev/null
+++ b/debian/patches/0104-common-Fix-gnupg_inotify_has_name.patch
@@ -0,0 +1,81 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 10:16:48 +0900
+Subject: common: Fix gnupg_inotify_has_name.
+
+* common/sysutils.c (gnupg_inotify_has_name): Take care of the
+alignment.
+
+--
+
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ common/sysutils.c | 36 ++++++++++++++++++++++--------------
+ 1 file changed, 22 insertions(+), 14 deletions(-)
+
+diff --git a/common/sysutils.c b/common/sysutils.c
+index 6c8bd3b..70749cc 100644
+--- a/common/sysutils.c
++++ b/common/sysutils.c
+@@ -1014,40 +1014,48 @@ int
+ gnupg_inotify_has_name (int fd, const char *name)
+ {
+ #if USE_NPTH && HAVE_INOTIFY_INIT
+- union {
+- struct inotify_event ev;
+- char _buf[sizeof (struct inotify_event) + 255 + 1];
+- } buf;
+- struct inotify_event *evp;
++#define BUFSIZE_FOR_INOTIFY (sizeof (struct inotify_event) + 255 + 1)
++ char buf[BUFSIZE_FOR_INOTIFY];
++ char *p;
+ int n;
+
+- n = npth_read (fd, &buf, sizeof buf);
++ n = npth_read (fd, buf, sizeof buf);
++ p = buf;
+ /* log_debug ("notify read: n=%d\n", n); */
+- evp = &buf.ev;
+ while (n >= sizeof (struct inotify_event))
+ {
++ struct inotify_event ev;
++ const char *ev_name;
++
++ memcpy (&ev, p, sizeof (struct inotify_event));
++
++ if (ev.len > 255 + 1) /* Something goes wrong, skip this data. */
++ break;
++
++ ev_name = p + sizeof (struct inotify_event);
++ p += sizeof (struct inotify_event) + ev.len;
++ n -= sizeof (struct inotify_event) + ev.len;
++
+ /* log_debug (" mask=%x len=%u name=(%s)\n", */
+- /* evp->mask, (unsigned int)evp->len, evp->len? evp->name:""); */
+- if ((evp->mask & IN_UNMOUNT))
++ /* ev.mask, (unsigned int)ev.len, ev.len? ev.name:""); */
++ if ((ev.mask & IN_UNMOUNT))
+ {
+ /* log_debug (" found (dir unmounted)\n"); */
+ return 3; /* Directory was unmounted. */
+ }
+- if ((evp->mask & IN_DELETE_SELF))
++ if ((ev.mask & IN_DELETE_SELF))
+ {
+ /* log_debug (" found (dir removed)\n"); */
+ return 2; /* Directory was removed. */
+ }
+- if ((evp->mask & IN_DELETE))
++ if ((ev.mask & IN_DELETE))
+ {
+- if (evp->len >= strlen (name) && !strcmp (evp->name, name))
++ if (ev.len >= strlen (name) && !strcmp (ev_name, name))
+ {
+ /* log_debug (" found (file removed)\n"); */
+ return 1; /* File was removed. */
+ }
+ }
+- n -= sizeof (*evp) + evp->len;
+- evp = (struct inotify_event *)((char*)evp + sizeof (*evp) + evp->len);
+ }
+
+ #else /*!(USE_NPTH && HAVE_INOTIFY_INIT)*/
diff --git a/debian/patches/0105-dirmngr-report-actual-socket-name.patch b/debian/patches/0105-dirmngr-report-actual-socket-name.patch
new file mode 100644
index 0000000..58e8396
--- /dev/null
+++ b/debian/patches/0105-dirmngr-report-actual-socket-name.patch
@@ -0,0 +1,63 @@
+From: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
+Date: Wed, 26 Oct 2016 16:37:06 -0400
+Subject: dirmngr: report actual socket name.
+
+* dirmngr/dirmngr.[ch] (dirmngr_get_current_socket_name): new function
+to report known socket name.
+* dirmngr/server.c (cmd_getinfo): use dirmngr_get_current_socket_name
+to report correct socket name.
+
+--
+
+This fixes the output of 'getinfo socket_name' when dirmngr is invoked
+with --socket-name.
+
+Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
+---
+ dirmngr/dirmngr.c | 9 +++++++++
+ dirmngr/dirmngr.h | 1 +
+ dirmngr/server.c | 2 +-
+ 3 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
+index cf5061c..d0b31a4 100644
+--- a/dirmngr/dirmngr.c
++++ b/dirmngr/dirmngr.c
+@@ -2074,3 +2074,12 @@ handle_connections (assuan_fd_t listen_fd)
+ cleanup ();
+ log_info ("%s %s stopped\n", strusage(11), strusage(13));
+ }
++
++const char*
++dirmngr_get_current_socket_name (void)
++{
++ if (socket_name)
++ return socket_name;
++ else
++ return dirmngr_socket_name ();
++}
+diff --git a/dirmngr/dirmngr.h b/dirmngr/dirmngr.h
+index 6127386..613633f 100644
+--- a/dirmngr/dirmngr.h
++++ b/dirmngr/dirmngr.h
+@@ -183,6 +183,7 @@ void dirmngr_exit( int ); /* Wrapper for exit() */
+ void dirmngr_init_default_ctrl (ctrl_t ctrl);
+ void dirmngr_deinit_default_ctrl (ctrl_t ctrl);
+ void dirmngr_sighup_action (void);
++const char* dirmngr_get_current_socket_name (void);
+
+
+ /*-- Various housekeeping functions. --*/
+diff --git a/dirmngr/server.c b/dirmngr/server.c
+index fe87bbe..2f88ff2 100644
+--- a/dirmngr/server.c
++++ b/dirmngr/server.c
+@@ -2217,7 +2217,7 @@ cmd_getinfo (assuan_context_t ctx, char *line)
+ }
+ else if (!strcmp (line, "socket_name"))
+ {
+- const char *s = dirmngr_socket_name ();
++ const char *s = dirmngr_get_current_socket_name ();
+ err = assuan_send_data (ctx, s, strlen (s));
+ }
+ else if (!strcmp (line, "tor"))
diff --git a/debian/patches/0106-agent-common-move-get_socket_name-into-common.patch b/debian/patches/0106-agent-common-move-get_socket_name-into-common.patch
new file mode 100644
index 0000000..98c3b73
--- /dev/null
+++ b/debian/patches/0106-agent-common-move-get_socket_name-into-common.patch
@@ -0,0 +1,168 @@
+From: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
+Date: Wed, 26 Oct 2016 16:37:07 -0400
+Subject: agent,common: move get_socket_name() into common.
+
+* 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 <dkg at fifthhorseman.net>
+---
+ agent/gpg-agent.c | 50 ++------------------------------------------------
+ common/sysutils.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
+ common/sysutils.h | 1 +
+ 3 files changed, 52 insertions(+), 48 deletions(-)
+
+diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
+index 8f4dade..d74ea2b 100644
+--- a/agent/gpg-agent.c
++++ b/agent/gpg-agent.c
+@@ -576,52 +576,6 @@ remove_socket (char *name, char *redir_name)
+ }
+
+
+-/* Return a malloc'ed string that is the path to the passed
+- * unix-domain socket (or return NULL if this is not a valid
+- * unix-domain socket). We use a plain int here because it is only
+- * used on Linux.
+- *
+- * FIXME: This function needs to be moved to libassuan. */
+-#ifndef HAVE_W32_SYSTEM
+-static char *
+-get_socket_name (int fd)
+-{
+- struct sockaddr_un un;
+- socklen_t len = sizeof(un);
+- char *name = NULL;
+-
+- if (getsockname (fd, (struct sockaddr*)&un, &len) != 0)
+- log_error ("could not getsockname(%d): %s\n", fd,
+- gpg_strerror (gpg_error_from_syserror ()));
+- else if (un.sun_family != AF_UNIX)
+- log_error ("file descriptor %d is not a unix-domain socket\n", fd);
+- else if (len <= offsetof (struct sockaddr_un, sun_path))
+- log_error ("socket name not present for file descriptor %d\n", fd);
+- else if (len > sizeof(un))
+- log_error ("socket name for file descriptor %d was truncated "
+- "(passed %zu bytes, wanted %u)\n", fd, sizeof(un), len);
+- else
+- {
+- size_t namelen = len - offsetof (struct sockaddr_un, sun_path);
+-
+- log_debug ("file descriptor %d has path %s (%zu octets)\n", fd,
+- un.sun_path, namelen);
+- name = xtrymalloc (namelen + 1);
+- if (!name)
+- log_error ("failed to allocate memory for name of fd %d: %s\n",
+- fd, gpg_strerror (gpg_error_from_syserror ()));
+- else
+- {
+- memcpy (name, un.sun_path, namelen);
+- name[namelen] = 0;
+- }
+- }
+-
+- return name;
+-}
+-#endif /*!HAVE_W32_SYSTEM*/
+-
+-
+ /* Discover which inherited file descriptors correspond to which
+ * services/sockets offered by gpg-agent, using the LISTEN_FDS and
+ * LISTEN_FDNAMES convention. The understood labels are "ssh",
+@@ -730,7 +684,7 @@ map_supervised_sockets (gnupg_fd_t *r_fd,
+ log_fatal ("file descriptor 3 must be valid in --supervised mode"
+ " if LISTEN_FDNAMES is not set\n");
+ *r_fd = 3;
+- socket_name = get_socket_name (3);
++ socket_name = gnupg_get_socket_name (3);
+ }
+ else if (fd_count != nfdnames)
+ {
+@@ -752,7 +706,7 @@ map_supervised_sockets (gnupg_fd_t *r_fd,
+ fd = 3 + i;
+ if (**tbl[j].fdaddr == -1)
+ {
+- name = get_socket_name (fd);
++ name = gnupg_get_socket_name (fd);
+ if (name)
+ {
+ **tbl[j].fdaddr = fd;
+diff --git a/common/sysutils.c b/common/sysutils.c
+index 70749cc..2927a85 100644
+--- a/common/sysutils.c
++++ b/common/sysutils.c
+@@ -62,6 +62,9 @@
+ # include <winsock2.h>
+ # endif
+ # include <windows.h>
++#else /*!HAVE_W32_SYSTEM*/
++# include <sys/socket.h>
++# include <sys/un.h>
+ #endif
+ #ifdef HAVE_INOTIFY_INIT
+ # include <sys/inotify.h>
+@@ -1067,3 +1070,49 @@ gnupg_inotify_has_name (int fd, const char *name)
+
+ return 0; /* Not found. */
+ }
++
++
++/* Return a malloc'ed string that is the path to the passed
++ * unix-domain socket (or return NULL if this is not a valid
++ * unix-domain socket). We use a plain int here because it is only
++ * used on Linux.
++ *
++ * FIXME: This function needs to be moved to libassuan. */
++#ifndef HAVE_W32_SYSTEM
++char *
++gnupg_get_socket_name (int fd)
++{
++ struct sockaddr_un un;
++ socklen_t len = sizeof(un);
++ char *name = NULL;
++
++ if (getsockname (fd, (struct sockaddr*)&un, &len) != 0)
++ log_error ("could not getsockname(%d): %s\n", fd,
++ gpg_strerror (gpg_error_from_syserror ()));
++ else if (un.sun_family != AF_UNIX)
++ log_error ("file descriptor %d is not a unix-domain socket\n", fd);
++ else if (len <= offsetof (struct sockaddr_un, sun_path))
++ log_error ("socket name not present for file descriptor %d\n", fd);
++ else if (len > sizeof(un))
++ log_error ("socket name for file descriptor %d was truncated "
++ "(passed %zu bytes, wanted %u)\n", fd, sizeof(un), len);
++ else
++ {
++ size_t namelen = len - offsetof (struct sockaddr_un, sun_path);
++
++ log_debug ("file descriptor %d has path %s (%zu octets)\n", fd,
++ un.sun_path, namelen);
++ name = xtrymalloc (namelen + 1);
++ if (!name)
++ log_error ("failed to allocate memory for name of fd %d: %s\n",
++ fd, gpg_strerror (gpg_error_from_syserror ()));
++ else
++ {
++ memcpy (name, un.sun_path, namelen);
++ name[namelen] = 0;
++ }
++ }
++
++ return name;
++}
++#endif /*!HAVE_W32_SYSTEM*/
+diff --git a/common/sysutils.h b/common/sysutils.h
+index ea92e4c..7105107 100644
+--- a/common/sysutils.h
++++ b/common/sysutils.h
+@@ -66,6 +66,7 @@ char *gnupg_mkdtemp (char *template);
+ int gnupg_setenv (const char *name, const char *value, int overwrite);
+ int gnupg_unsetenv (const char *name);
+ char *gnupg_getcwd (void);
++char *gnupg_get_socket_name (int fd);
+
+ gpg_error_t gnupg_inotify_watch_socket (int *r_fd, const char *socket_name);
+ int gnupg_inotify_has_name (int fd, const char *name);
diff --git a/debian/patches/0107-dirmngr-Implement-supervised-command-for-systemd-etc.patch b/debian/patches/0107-dirmngr-Implement-supervised-command-for-systemd-etc.patch
new file mode 100644
index 0000000..2d01012
--- /dev/null
+++ b/debian/patches/0107-dirmngr-Implement-supervised-command-for-systemd-etc.patch
@@ -0,0 +1,119 @@
+From: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
+Date: Wed, 26 Oct 2016 16:37:08 -0400
+Subject: dirmngr: Implement --supervised command (for systemd, etc).
+
+* dirmngr/dirmngr.c (main): Add new --supervised command, which is a
+mode designed for running under a process supervision system like
+systemd or runit.
+* doc/dirmngr.texi: document --supervised option.
+
+--
+
+"dirmngr --supervised" is a way to invoke dirmngr such that a system
+supervisor like systemd can provide socket-activated startup, log
+management, and scheduled shutdown.
+
+When running in this mode, dirmngr:
+
+ * Does not open its own listening socket; rather, it expects to be
+ given a listening socket on file descriptor 3.
+
+ * Does not detach from the invoking process, staying in the
+ foreground instead.
+
+Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
+---
+ dirmngr/dirmngr.c | 40 ++++++++++++++++++++++++++++++++++++++++
+ doc/dirmngr.texi | 7 +++++++
+ 2 files changed, 47 insertions(+)
+
+diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
+index d0b31a4..9689c9b 100644
+--- a/dirmngr/dirmngr.c
++++ b/dirmngr/dirmngr.c
+@@ -88,6 +88,7 @@ enum cmd_and_opt_values {
+
+ aServer,
+ aDaemon,
++ aSupervised,
+ aListCRLs,
+ aLoadCRL,
+ aFetchCRL,
+@@ -149,6 +150,7 @@ static ARGPARSE_OPTS opts[] = {
+
+ ARGPARSE_c (aServer, "server", N_("run in server mode (foreground)") ),
+ ARGPARSE_c (aDaemon, "daemon", N_("run in daemon mode (background)") ),
++ ARGPARSE_c (aSupervised, "supervised", N_("run under supervision (e.g. systemd)")),
+ ARGPARSE_c (aListCRLs, "list-crls", N_("list the contents of the CRL cache")),
+ ARGPARSE_c (aLoadCRL, "load-crl", N_("|FILE|load CRL from FILE into cache")),
+ ARGPARSE_c (aFetchCRL, "fetch-crl", N_("|URL|fetch a CRL from URL")),
+@@ -814,6 +816,7 @@ main (int argc, char **argv)
+ {
+ case aServer:
+ case aDaemon:
++ case aSupervised:
+ case aShutdown:
+ case aFlush:
+ case aListCRLs:
+@@ -993,6 +996,43 @@ main (int argc, char **argv)
+ start_command_handler (ASSUAN_INVALID_FD);
+ shutdown_reaper ();
+ }
++ else if (cmd == aSupervised)
++ {
++ /* In supervised mode, we expect file descriptor 3 to be an
++ already opened, listening socket.
++
++ We will also not detach from the controlling process or close
++ stderr; the supervisor should handle all of that. */
++ struct stat statbuf;
++ if (fstat (3, &statbuf) == -1 && errno ==EBADF)
++ {
++ log_error ("file descriptor 3 must be already open in --supervised mode\n");
++ dirmngr_exit (1);
++ }
++ socket_name = gnupg_get_socket_name (3);
++
++ /* Now start with logging to a file if this is desired. */
++ if (logfile)
++ {
++ log_set_file (logfile);
++ log_set_prefix (NULL, (GPGRT_LOG_WITH_PREFIX
++ |GPGRT_LOG_WITH_TIME
++ |GPGRT_LOG_WITH_PID));
++ current_logfile = xstrdup (logfile);
++ }
++ else
++ log_set_prefix (NULL, 0);
++
++ thread_init ();
++ cert_cache_init ();
++ crl_cache_init ();
++#if USE_LDAP
++ ldap_wrapper_launch_thread ();
++#endif /*USE_LDAP*/
++ handle_connections (3);
++ assuan_sock_close (3);
++ shutdown_reaper ();
++ }
+ else if (cmd == aDaemon)
+ {
+ assuan_fd_t fd;
+diff --git a/doc/dirmngr.texi b/doc/dirmngr.texi
+index 41c6b84..7be2c37 100644
+--- a/doc/dirmngr.texi
++++ b/doc/dirmngr.texi
+@@ -85,6 +85,13 @@ Run in background daemon mode and listen for commands on a socket.
+ Note that this also changes the default home directory and enables the
+ internal certificate validation code. This mode is deprecated.
+
++ at item --supervised
++ at opindex supervised
++Run in the foreground, sending logs to stderr, and listening on file
++descriptor 3, which must already be bound to a listening socket. This
++is useful when running under systemd or other similar process
++supervision schemes.
++
+ @item --list-crls
+ @opindex list-crls
+ List the contents of the CRL cache on @code{stdout}. This is probably
diff --git a/debian/patches/0108-g10-ECDH-shared-point-format.patch b/debian/patches/0108-g10-ECDH-shared-point-format.patch
new file mode 100644
index 0000000..8fe5d1d
--- /dev/null
+++ b/debian/patches/0108-g10-ECDH-shared-point-format.patch
@@ -0,0 +1,67 @@
+From: Arnaud Fontaine <arnaud.fontaine at ssi.gouv.fr>
+Date: Tue, 25 Oct 2016 13:43:08 +0200
+Subject: g10: ECDH shared point format.
+
+* g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Improve handling of
+ECDH shared point format.
+
+--
+This handles the case where the result comes from scdaemon.
+
+Signed-off-by: Arnaud Fontaine <arnaud.fontaine at ssi.gouv.fr>
+---
+ g10/ecdh.c | 32 ++++++++++++++++++++++++--------
+ 1 file changed, 24 insertions(+), 8 deletions(-)
+
+diff --git a/g10/ecdh.c b/g10/ecdh.c
+index af1d844..886427b 100644
+--- a/g10/ecdh.c
++++ b/g10/ecdh.c
+@@ -132,14 +132,30 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
+ return err;
+ }
+
++ /* Expected size of the x component */
+ secret_x_size = (nbits+7)/8;
+- log_assert (nbytes >= secret_x_size);
+- if ((nbytes & 1))
+- /* Remove the "04" prefix of non-compressed format. */
+- memmove (secret_x, secret_x+1, secret_x_size);
+- if (nbytes - secret_x_size)
+- memset (secret_x+secret_x_size, 0, nbytes-secret_x_size);
+
++ if (nbytes > secret_x_size)
++ {
++ /* Uncompressed format expected, so it must start with 04 */
++ if (secret_x[0] != (byte)0x04)
++ {
++ return gpg_error (GPG_ERR_BAD_DATA);
++ }
++
++ /* Remove the "04" prefix of non-compressed format. */
++ memmove (secret_x, secret_x+1, secret_x_size);
++
++ /* Zeroize the y component following */
++ if (nbytes > secret_x_size)
++ memset (secret_x+secret_x_size, 0, nbytes-secret_x_size);
++ }
++ else if (nbytes < secret_x_size)
++ {
++ /* Raw share secret (x coordinate), without leading zeros */
++ memmove (secret_x+(secret_x_size - nbytes), secret_x, nbytes);
++ memset (secret_x, 0, secret_x_size - nbytes);
++ }
+ if (DBG_CRYPTO)
+ log_printhex ("ECDH shared secret X is:", secret_x, secret_x_size );
+ }
+@@ -235,8 +251,8 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
+ return err;
+ }
+ gcry_md_write(h, "\x00\x00\x00\x01", 4); /* counter = 1 */
+- gcry_md_write(h, secret_x, secret_x_size); /* x of the point X */
+- gcry_md_write(h, message, message_size);/* KDF parameters */
++ gcry_md_write(h, secret_x, secret_x_size); /* x of the point X */
++ gcry_md_write(h, message, message_size); /* KDF parameters */
+
+ gcry_md_final (h);
+
diff --git a/debian/patches/0109-scd-Add-0x41-prefix-for-x-coordinate-only-result.patch b/debian/patches/0109-scd-Add-0x41-prefix-for-x-coordinate-only-result.patch
new file mode 100644
index 0000000..7b9788f
--- /dev/null
+++ b/debian/patches/0109-scd-Add-0x41-prefix-for-x-coordinate-only-result.patch
@@ -0,0 +1,62 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 11:56:18 +0900
+Subject: scd: Add 0x41 prefix for x-coordinate only result.
+
+* scd/app-openpgp.c (do_decipher): When it's x-coordinate only, add the
+prefix 0x41.
+
+--
+Card should return fixed size bytes, either in format of
+(04 || X || Y) or (X, x-coordinate only).
+
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ scd/app-openpgp.c | 33 +++++++++++++++++++++------------
+ 1 file changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
+index 4e042e7..d75721f 100644
+--- a/scd/app-openpgp.c
++++ b/scd/app-openpgp.c
+@@ -4406,20 +4406,29 @@ do_decipher (app_t app, const char *keyidstr,
+ indata, indatalen, le_value, padind,
+ outdata, outdatalen);
+ xfree (fixbuf);
+- if (app->app_local->keyattr[1].key_type == KEY_TYPE_ECC
+- && (app->app_local->keyattr[1].ecc.flags & ECC_FLAG_DJB_TWEAK))
+- { /* Add the prefix 0x40 */
+- fixbuf = xtrymalloc (*outdatalen + 1);
+- if (!fixbuf)
+- {
++ if (app->app_local->keyattr[1].key_type == KEY_TYPE_ECC)
++ {
++ unsigned char prefix = 0;
++
++ if (app->app_local->keyattr[1].ecc.flags & ECC_FLAG_DJB_TWEAK)
++ prefix = 0x40;
++ else if ((*outdatalen % 2) == 0) /* No 0x04 -> x-coordinate only */
++ prefix = 0x41;
++
++ if (prefix)
++ { /* Add the prefix */
++ fixbuf = xtrymalloc (*outdatalen + 1);
++ if (!fixbuf)
++ {
++ xfree (*outdata);
++ return gpg_error_from_syserror ();
++ }
++ fixbuf[0] = prefix;
++ memcpy (fixbuf+1, *outdata, *outdatalen);
+ xfree (*outdata);
+- return gpg_error_from_syserror ();
++ *outdata = fixbuf;
++ *outdatalen = *outdatalen + 1;
+ }
+- fixbuf[0] = 0x40;
+- memcpy (fixbuf+1, *outdata, *outdatalen);
+- xfree (*outdata);
+- *outdata = fixbuf;
+- *outdatalen = *outdatalen + 1;
+ }
+
+ if (gpg_err_code (rc) == GPG_ERR_CARD /* actual SW is 0x640a */
diff --git a/debian/patches/0110-g10-Fix-ECDH-clarifying-the-format.patch b/debian/patches/0110-g10-Fix-ECDH-clarifying-the-format.patch
new file mode 100644
index 0000000..84a451e
--- /dev/null
+++ b/debian/patches/0110-g10-Fix-ECDH-clarifying-the-format.patch
@@ -0,0 +1,68 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 12:59:49 +0900
+Subject: g10: Fix ECDH, clarifying the format.
+
+* g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Returns error when
+it's short. Clarify the format. Handle other prefixes correctly.
+
+--
+With the scdaemon's change, there is no case NBYTES < SECRET_X_SIZE.
+This fixes the break of ECDH with X25519.
+
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ g10/ecdh.c | 38 ++++++++++++++++++++------------------
+ 1 file changed, 20 insertions(+), 18 deletions(-)
+
+diff --git a/g10/ecdh.c b/g10/ecdh.c
+index 886427b..dd47544 100644
+--- a/g10/ecdh.c
++++ b/g10/ecdh.c
+@@ -135,27 +135,29 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
+ /* Expected size of the x component */
+ secret_x_size = (nbits+7)/8;
+
+- if (nbytes > secret_x_size)
++ /* Extract X from the result. It must be in the format of:
++ 04 || X || Y
++ 40 || X
++ 41 || X
++
++ Since it always comes with the prefix, it's larger than X. In
++ old experimental version of libgcrypt, there is a case where it
++ returns X with no prefix of 40, so, nbytes == secret_x_size
++ is allowed. */
++ if (nbytes < secret_x_size)
+ {
+- /* Uncompressed format expected, so it must start with 04 */
+- if (secret_x[0] != (byte)0x04)
+- {
+- return gpg_error (GPG_ERR_BAD_DATA);
+- }
++ xfree (secret_x);
++ return gpg_error (GPG_ERR_BAD_DATA);
++ }
+
+- /* Remove the "04" prefix of non-compressed format. */
+- memmove (secret_x, secret_x+1, secret_x_size);
++ /* Remove the prefix. */
++ if ((nbytes & 1))
++ memmove (secret_x, secret_x+1, secret_x_size);
++
++ /* Clear the rest of data. */
++ if (nbytes - secret_x_size)
++ memset (secret_x+secret_x_size, 0, nbytes-secret_x_size);
+
+- /* Zeroize the y component following */
+- if (nbytes > secret_x_size)
+- memset (secret_x+secret_x_size, 0, nbytes-secret_x_size);
+- }
+- else if (nbytes < secret_x_size)
+- {
+- /* Raw share secret (x coordinate), without leading zeros */
+- memmove (secret_x+(secret_x_size - nbytes), secret_x, nbytes);
+- memset (secret_x, 0, secret_x_size - nbytes);
+- }
+ if (DBG_CRYPTO)
+ log_printhex ("ECDH shared secret X is:", secret_x, secret_x_size );
+ }
diff --git a/debian/patches/0111-dirmngr-Fix-error-return-for-ADNS.patch b/debian/patches/0111-dirmngr-Fix-error-return-for-ADNS.patch
new file mode 100644
index 0000000..1180366
--- /dev/null
+++ b/debian/patches/0111-dirmngr-Fix-error-return-for-ADNS.patch
@@ -0,0 +1,29 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 14:49:17 +0900
+Subject: dirmngr: Fix error return for ADNS.
+
+* dirmngr/dns-stuff.c (resolve_name_adns): Use RET for return value.
+
+--
+There are cases where libadns returns an error without setting the
+variable ERRNO.
+
+GnuPG-bug-id: 2745
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ dirmngr/dns-stuff.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
+index ac295b0..284ef09 100644
+--- a/dirmngr/dns-stuff.c
++++ b/dirmngr/dns-stuff.c
+@@ -278,7 +278,7 @@ resolve_name_adns (const char *name, unsigned short port,
+ my_protect ();
+ if (ret)
+ {
+- err = gpg_error_from_syserror ();
++ err = ret;
+ log_error ("DNS query failed: %s\n", gpg_strerror (err));
+ goto leave;
+ }
diff --git a/debian/patches/0112-dirmngr-More-ADNS-error-fix.patch b/debian/patches/0112-dirmngr-More-ADNS-error-fix.patch
new file mode 100644
index 0000000..b3f8359
--- /dev/null
+++ b/debian/patches/0112-dirmngr-More-ADNS-error-fix.patch
@@ -0,0 +1,47 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 15:01:42 +0900
+Subject: dirmngr: More ADNS error fix.
+
+* dirmngr/dns-stuff.c (get_dns_cert, getsrv, get_dns_cname): Fix return
+value.
+
+--
+GnuPG-bug-id: 2745
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ dirmngr/dns-stuff.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
+index 284ef09..28a500c 100644
+--- a/dirmngr/dns-stuff.c
++++ b/dirmngr/dns-stuff.c
+@@ -682,8 +682,8 @@ get_dns_cert (const char *name, int want_certtype,
+ my_protect ();
+ if (ret)
+ {
+- err = gpg_error_from_syserror ();
+- /* log_error ("DNS query failed: %s\n", strerror (errno)); */
++ err = ret;
++ /* log_error ("DNS query failed: %s\n", strerror (err)); */
+ adns_finish (state);
+ return err;
+ }
+@@ -1036,7 +1036,7 @@ getsrv (const char *name,struct srventry **list)
+ my_protect ();
+ if (rc)
+ {
+- log_error ("DNS query failed: %s\n", strerror (errno));
++ log_error ("DNS query failed: %s\n", strerror (rc));
+ adns_finish (state);
+ return -1;
+ }
+@@ -1281,7 +1281,7 @@ get_dns_cname (const char *name, char **r_cname)
+ my_protect ();
+ if (rc)
+ {
+- err = gpg_error_from_syserror ();
++ err = rc;
+ log_error ("DNS query failed: %s\n", gpg_strerror (err));
+ adns_finish (state);
+ return err;
diff --git a/debian/patches/0113-common-Fix-gnupg_inotify_has_name-differently.patch b/debian/patches/0113-common-Fix-gnupg_inotify_has_name-differently.patch
new file mode 100644
index 0000000..264d10a
--- /dev/null
+++ b/debian/patches/0113-common-Fix-gnupg_inotify_has_name-differently.patch
@@ -0,0 +1,83 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 15:37:47 +0900
+Subject: common: Fix gnupg_inotify_has_name, differently.
+
+* 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 <gniibe at fsij.org>
+---
+ common/sysutils.c | 36 +++++++++++++++---------------------
+ 1 file changed, 15 insertions(+), 21 deletions(-)
+
+diff --git a/common/sysutils.c b/common/sysutils.c
+index 2927a85..944ae16 100644
+--- a/common/sysutils.c
++++ b/common/sysutils.c
+@@ -1018,47 +1018,41 @@ gnupg_inotify_has_name (int fd, const char *name)
+ {
+ #if USE_NPTH && HAVE_INOTIFY_INIT
+ #define BUFSIZE_FOR_INOTIFY (sizeof (struct inotify_event) + 255 + 1)
+- char buf[BUFSIZE_FOR_INOTIFY];
+- char *p;
++ union {
++ struct inotify_event ev;
++ char _buf[sizeof (struct inotify_event) + 255 + 1];
++ } buf;
++ struct inotify_event *evp;
+ int n;
+
+- n = npth_read (fd, buf, sizeof buf);
+- p = buf;
++ n = npth_read (fd, &buf, sizeof buf);
+ /* log_debug ("notify read: n=%d\n", n); */
++ evp = &buf.ev;
+ while (n >= sizeof (struct inotify_event))
+ {
+- struct inotify_event ev;
+- const char *ev_name;
+-
+- memcpy (&ev, p, sizeof (struct inotify_event));
+-
+- if (ev.len > 255 + 1) /* Something goes wrong, skip this data. */
+- break;
+-
+- ev_name = p + sizeof (struct inotify_event);
+- p += sizeof (struct inotify_event) + ev.len;
+- n -= sizeof (struct inotify_event) + ev.len;
+-
+ /* log_debug (" mask=%x len=%u name=(%s)\n", */
+- /* ev.mask, (unsigned int)ev.len, ev.len? ev.name:""); */
+- if ((ev.mask & IN_UNMOUNT))
++ /* evp->mask, (unsigned int)evp->len, evp->len? evp->name:""); */
++ if ((evp->mask & IN_UNMOUNT))
+ {
+ /* log_debug (" found (dir unmounted)\n"); */
+ return 3; /* Directory was unmounted. */
+ }
+- if ((ev.mask & IN_DELETE_SELF))
++ if ((evp->mask & IN_DELETE_SELF))
+ {
+ /* log_debug (" found (dir removed)\n"); */
+ return 2; /* Directory was removed. */
+ }
+- if ((ev.mask & IN_DELETE))
++ if ((evp->mask & IN_DELETE))
+ {
+- if (ev.len >= strlen (name) && !strcmp (ev_name, name))
++ if (evp->len >= strlen (name) && !strcmp (evp->name, name))
+ {
+ /* log_debug (" found (file removed)\n"); */
+ return 1; /* File was removed. */
+ }
+ }
++ n -= sizeof (*evp) + evp->len;
++ evp = (struct inotify_event *)(void *)
++ ((char *)evp + sizeof (*evp) + evp->len);
+ }
+
+ #else /*!(USE_NPTH && HAVE_INOTIFY_INIT)*/
diff --git a/debian/patches/0114-dirmngr-ADNS-error-handling-fix.patch b/debian/patches/0114-dirmngr-ADNS-error-handling-fix.patch
new file mode 100644
index 0000000..a5b0e00
--- /dev/null
+++ b/debian/patches/0114-dirmngr-ADNS-error-handling-fix.patch
@@ -0,0 +1,48 @@
+From: NIIBE Yutaka <gniibe at fsij.org>
+Date: Thu, 27 Oct 2016 16:22:26 +0900
+Subject: dirmngr: ADNS error handling fix.
+
+* dirmngr/dns-stuff.c (resolve_name_adns, get_dns_cert, get_dns_cname):
+Use gpg_error and gpg_err_code_from_errno to compose the error value.
+
+--
+This fixes commits 6f1d8123d61b3efac94b4c61ee75bd947790ba42.
+
+Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
+---
+ dirmngr/dns-stuff.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
+index 28a500c..4bd3a87 100644
+--- a/dirmngr/dns-stuff.c
++++ b/dirmngr/dns-stuff.c
+@@ -278,7 +278,7 @@ resolve_name_adns (const char *name, unsigned short port,
+ my_protect ();
+ if (ret)
+ {
+- err = ret;
++ err = gpg_error (gpg_err_code_from_errno (ret));
+ log_error ("DNS query failed: %s\n", gpg_strerror (err));
+ goto leave;
+ }
+@@ -682,8 +682,8 @@ get_dns_cert (const char *name, int want_certtype,
+ my_protect ();
+ if (ret)
+ {
+- err = ret;
+- /* log_error ("DNS query failed: %s\n", strerror (err)); */
++ err = gpg_error (gpg_err_code_from_errno (ret));
++ /* log_error ("DNS query failed: %s\n", gpg_strerror (err)); */
+ adns_finish (state);
+ return err;
+ }
+@@ -1281,7 +1281,7 @@ get_dns_cname (const char *name, char **r_cname)
+ my_protect ();
+ if (rc)
+ {
+- err = rc;
++ err = gpg_error (gpg_err_code_from_errno (rc));
+ log_error ("DNS query failed: %s\n", gpg_strerror (err));
+ adns_finish (state);
+ return err;
diff --git a/debian/patches/0115-common-Remove-debug-output-from-gnupg_get_socket_nam.patch b/debian/patches/0115-common-Remove-debug-output-from-gnupg_get_socket_nam.patch
new file mode 100644
index 0000000..0a3a0ec
--- /dev/null
+++ b/debian/patches/0115-common-Remove-debug-output-from-gnupg_get_socket_nam.patch
@@ -0,0 +1,41 @@
+From: Werner Koch <wk at gnupg.org>
+Date: Thu, 27 Oct 2016 09:13:36 +0200
+Subject: common: Remove debug output from gnupg_get_socket_name.
+
+* common/sysutils.c (gnupg_get_socket_name): Remove debug message and
+use my_error_from_syserror.
+
+Signed-off-by: Werner Koch <wk at gnupg.org>
+---
+ common/sysutils.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/common/sysutils.c b/common/sysutils.c
+index 944ae16..bcafad6 100644
+--- a/common/sysutils.c
++++ b/common/sysutils.c
+@@ -1082,7 +1082,7 @@ gnupg_get_socket_name (int fd)
+
+ if (getsockname (fd, (struct sockaddr*)&un, &len) != 0)
+ log_error ("could not getsockname(%d): %s\n", fd,
+- gpg_strerror (gpg_error_from_syserror ()));
++ gpg_strerror (my_error_from_syserror ()));
+ else if (un.sun_family != AF_UNIX)
+ log_error ("file descriptor %d is not a unix-domain socket\n", fd);
+ else if (len <= offsetof (struct sockaddr_un, sun_path))
+@@ -1094,12 +1094,12 @@ gnupg_get_socket_name (int fd)
+ {
+ size_t namelen = len - offsetof (struct sockaddr_un, sun_path);
+
+- log_debug ("file descriptor %d has path %s (%zu octets)\n", fd,
+- un.sun_path, namelen);
++ /* log_debug ("file descriptor %d has path %s (%zu octets)\n", fd, */
++ /* un.sun_path, namelen); */
+ name = xtrymalloc (namelen + 1);
+ if (!name)
+ log_error ("failed to allocate memory for name of fd %d: %s\n",
+- fd, gpg_strerror (gpg_error_from_syserror ()));
++ fd, gpg_strerror (my_error_from_syserror ()));
+ else
+ {
+ memcpy (name, un.sun_path, namelen);
diff --git a/debian/patches/0116-dirmngr-Do-not-implement-supervised-in-Windows.patch b/debian/patches/0116-dirmngr-Do-not-implement-supervised-in-Windows.patch
new file mode 100644
index 0000000..9efe14a
--- /dev/null
+++ b/debian/patches/0116-dirmngr-Do-not-implement-supervised-in-Windows.patch
@@ -0,0 +1,69 @@
+From: Werner Koch <wk at gnupg.org>
+Date: Thu, 27 Oct 2016 09:27:03 +0200
+Subject: dirmngr: Do not implement --supervised in Windows.
+
+* dirmngr/dirmngr.c (opts) [W32]: Remove --supervised.
+(main) [W32]: Ditto.
+
+Signed-off-by: Werner Koch <wk at gnupg.org>
+---
+ dirmngr/dirmngr.c | 10 +++++++---
+ doc/dirmngr.texi | 2 +-
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
+index 9689c9b..6e76ffc 100644
+--- a/dirmngr/dirmngr.c
++++ b/dirmngr/dirmngr.c
+@@ -150,7 +150,9 @@ static ARGPARSE_OPTS opts[] = {
+
+ ARGPARSE_c (aServer, "server", N_("run in server mode (foreground)") ),
+ ARGPARSE_c (aDaemon, "daemon", N_("run in daemon mode (background)") ),
+- ARGPARSE_c (aSupervised, "supervised", N_("run under supervision (e.g. systemd)")),
++#ifndef HAVE_W32_SYSTEM
++ ARGPARSE_c (aSupervised, "supervised", N_("run in supervised mode")),
++#endif
+ ARGPARSE_c (aListCRLs, "list-crls", N_("list the contents of the CRL cache")),
+ ARGPARSE_c (aLoadCRL, "load-crl", N_("|FILE|load CRL from FILE into cache")),
+ ARGPARSE_c (aFetchCRL, "fetch-crl", N_("|URL|fetch a CRL from URL")),
+@@ -996,6 +998,7 @@ main (int argc, char **argv)
+ start_command_handler (ASSUAN_INVALID_FD);
+ shutdown_reaper ();
+ }
++#ifndef HAVE_W32_SYSTEM
+ else if (cmd == aSupervised)
+ {
+ /* In supervised mode, we expect file descriptor 3 to be an
+@@ -1004,9 +1007,9 @@ main (int argc, char **argv)
+ We will also not detach from the controlling process or close
+ stderr; the supervisor should handle all of that. */
+ struct stat statbuf;
+- if (fstat (3, &statbuf) == -1 && errno ==EBADF)
++ if (fstat (3, &statbuf) == -1 && errno == EBADF)
+ {
+- log_error ("file descriptor 3 must be already open in --supervised mode\n");
++ log_error ("file descriptor 3 must be validin --supervised mode\n");
+ dirmngr_exit (1);
+ }
+ socket_name = gnupg_get_socket_name (3);
+@@ -1033,6 +1036,7 @@ main (int argc, char **argv)
+ assuan_sock_close (3);
+ shutdown_reaper ();
+ }
++#endif /*HAVE_W32_SYSTEM*/
+ else if (cmd == aDaemon)
+ {
+ assuan_fd_t fd;
+diff --git a/doc/dirmngr.texi b/doc/dirmngr.texi
+index 7be2c37..04494a5 100644
+--- a/doc/dirmngr.texi
++++ b/doc/dirmngr.texi
+@@ -90,7 +90,7 @@ internal certificate validation code. This mode is deprecated.
+ Run in the foreground, sending logs to stderr, and listening on file
+ descriptor 3, which must already be bound to a listening socket. This
+ is useful when running under systemd or other similar process
+-supervision schemes.
++supervision schemes. This option is not supported on Windows.
+
+ @item --list-crls
+ @opindex list-crls
diff --git a/debian/patches/series b/debian/patches/series
index 000b470..aec3aa3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -101,3 +101,16 @@
0101-common-Use-GPG_ERR_INV_VALUE-instead-of-GPG_ERR_EINV.patch
0102-agent-Avoid-double-error-message.patch
0103-dirmngr-Fix-hang-due-to-deferred-thread-initializati.patch
+0104-common-Fix-gnupg_inotify_has_name.patch
+0105-dirmngr-report-actual-socket-name.patch
+0106-agent-common-move-get_socket_name-into-common.patch
+0107-dirmngr-Implement-supervised-command-for-systemd-etc.patch
+0108-g10-ECDH-shared-point-format.patch
+0109-scd-Add-0x41-prefix-for-x-coordinate-only-result.patch
+0110-g10-Fix-ECDH-clarifying-the-format.patch
+0111-dirmngr-Fix-error-return-for-ADNS.patch
+0112-dirmngr-More-ADNS-error-fix.patch
+0113-common-Fix-gnupg_inotify_has_name-differently.patch
+0114-dirmngr-ADNS-error-handling-fix.patch
+0115-common-Remove-debug-output-from-gnupg_get_socket_nam.patch
+0116-dirmngr-Do-not-implement-supervised-in-Windows.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list