Support --locate-keys feature of gpg.

This commit is contained in:
Werner Koch 2008-05-07 15:41:14 +00:00
parent 14d099181c
commit b72c001283
7 changed files with 73 additions and 51 deletions

4
NEWS
View File

@ -1,6 +1,10 @@
Noteworthy changes in version 1.1.7 (unreleased)
------------------------------------------------
* Using GPGME_KEYLIST_MODE_LOCAL combined with
GPGME_KEYLIST_MODE_EXTERN is now supported; it uses the
--locate-keys feature of gpg (>= 2.0.10).
* The encoding of gpgme_data_t objects can affect the output encoding
of export, sign and encrypt operations now (the same operations
that are also affected by the ASCII mode switch). We believe this

4
TODO
View File

@ -148,6 +148,10 @@ Hey Emacs, this is -*- outline -*- mode!
** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
** Some error values should identify the source more correctly (mostly error
values derived from status messages).
** In rungpg.c we need to check the version of the engine
This requires a way to get the cached version number from the
engine layer.
* Tests
** Write a fake gpg-agent so that we can supply known passphrases to

View File

@ -2180,10 +2180,10 @@ is the default.
@item GPGME_KEYLIST_MODE_EXTERN
The @code{GPGME_KEYLIST_MODE_EXTERN} symbol specifies that an external
source should be searched for keys in the keylisting
operation. The type of external source is dependant on the crypto
engine used. For example, it can be a remote keyserver or LDAP
certificate server.
source should be searched for keys in the keylisting operation. The
type of external source is dependant on the crypto engine used and
whether it is combined with @code{GPGME_KEYLIST_MODE_LOCAL}. For
example, it can be a remote keyserver or LDAP certificate server.
@item GPGME_KEYLIST_MODE_SIGS
The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key
@ -2208,7 +2208,7 @@ At least one of @code{GPGME_KEYLIST_MODE_LOCAL} and
@code{GPGME_KEYLIST_MODE_EXTERN} must be specified. For future binary
compatibility, you should get the current mode with
@code{gpgme_get_keylist_mode} and modify it by setting or clearing the
appropriate bits, and then using that calulcated value in the
appropriate bits, and then using that calculated value in the
@code{gpgme_set_keylisting_mode} operation. This will leave all other
bits in the mode value intact (in particular those that are not used
in the current version of the library).

View File

@ -1,3 +1,14 @@
2008-05-07 Werner Koch <wk@g10code.com>
* engine-gpgconf.c (gpgconf_write): Change argv[0] to a
self-explaining string. Needs a proper fix, though.
* rungpg.c (gpg_keylist, gpg_keylist_ext): Factor common code out
to ..
(gpg_build_keylist_options): .. new. Allow combination of extern
and intern mode.
(gpg_new): DFT_TTYNAME is an array, thus check the first character.
2008-05-06 Werner Koch <wk@g10code.com>
* version.c (extract_version_string): New.

View File

@ -628,7 +628,7 @@ gpgconf_write (void *engine, char *arg1, char *arg2, gpgme_data_t conf)
/* _gpgme_engine_new guarantees that this is not NULL. */
argv[0] = gpgconf->file_name;
argv[0] = "/home/marcus/g10/install/bin/gpgconf";
argv[0] = "/nowhere/path-needs-to-be-fixed/gpgconf";
if (_gpgme_io_pipe (rp, 0) < 0)
return gpg_error_from_syserror ();

View File

@ -72,7 +72,7 @@ extern "C" {
AM_PATH_GPGME macro) check that this header matches the installed
library. Warning: Do not edit the next line. configure will do
that for you! */
#define GPGME_VERSION "1.1.7-svn1307"
#define GPGME_VERSION "1.1.7-svn1311"

View File

@ -486,7 +486,7 @@ gpg_new (void **engine, const char *file_name, const char *home_dir)
rc = gpg_error_from_errno (errno);
else
{
if (dft_ttyname)
if (*dft_ttyname)
{
rc = add_arg (gpg, "--ttyname");
if (!rc)
@ -1872,20 +1872,12 @@ gpg_keylist_preprocess (char *line, char **r_line)
}
static gpgme_error_t
gpg_keylist (void *engine, const char *pattern, int secret_only,
gpgme_keylist_mode_t mode)
static gpg_error_t
gpg_keylist_build_options (engine_gpg_t gpg, int secret_only,
gpgme_keylist_mode_t mode)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
gpg_error_t err;
if (mode & GPGME_KEYLIST_MODE_EXTERN)
{
if ((mode & GPGME_KEYLIST_MODE_LOCAL)
|| secret_only)
return gpg_error (GPG_ERR_NOT_SUPPORTED);
}
err = add_arg (gpg, "--with-colons");
if (!err)
err = add_arg (gpg, "--fixed-list-mode");
@ -1893,7 +1885,8 @@ gpg_keylist (void *engine, const char *pattern, int secret_only,
err = add_arg (gpg, "--with-fingerprint");
if (!err)
err = add_arg (gpg, "--with-fingerprint");
if (!err && (mode & GPGME_KEYLIST_MODE_SIGS)
if (!err
&& (mode & GPGME_KEYLIST_MODE_SIGS)
&& (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS))
{
err = add_arg (gpg, "--list-options");
@ -1902,22 +1895,51 @@ gpg_keylist (void *engine, const char *pattern, int secret_only,
}
if (!err)
{
if (mode & GPGME_KEYLIST_MODE_EXTERN)
if ( (mode & GPGME_KEYLIST_MODE_EXTERN) )
{
err = add_arg (gpg, "--search-keys");
gpg->colon.preprocess_fnc = gpg_keylist_preprocess;
if (secret_only)
err = gpg_error (GPG_ERR_NOT_SUPPORTED);
else if ( (mode & GPGME_KEYLIST_MODE_LOCAL))
{
/* The local+extern mode is special. It works only with
gpg >= 2.0.10. FIXME: We should check that we have
such a version to that we can return a proper error
code. The problem is that we don't know the context
here and thus can't accesses the cached version
number for the engine info structure. */
err = add_arg (gpg, "--locate-keys");
if ((mode & GPGME_KEYLIST_MODE_SIGS))
err = add_arg (gpg, "--with-sig-check");
}
else
{
err = add_arg (gpg, "--search-keys");
gpg->colon.preprocess_fnc = gpg_keylist_preprocess;
}
}
else
{
err = add_arg (gpg, secret_only ? "--list-secret-keys"
: ((mode & GPGME_KEYLIST_MODE_SIGS)
? "--check-sigs" : "--list-keys"));
}
{
err = add_arg (gpg, secret_only ? "--list-secret-keys"
: ((mode & GPGME_KEYLIST_MODE_SIGS)
? "--check-sigs" : "--list-keys"));
}
}
/* Tell the gpg object about the data. */
if (!err)
err = add_arg (gpg, "--");
return err;
}
static gpgme_error_t
gpg_keylist (void *engine, const char *pattern, int secret_only,
gpgme_keylist_mode_t mode)
{
engine_gpg_t gpg = engine;
gpgme_error_t err;
err = gpg_keylist_build_options (gpg, secret_only, mode);
if (!err && pattern && *pattern)
err = add_arg (gpg, pattern);
@ -1938,26 +1960,7 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only,
if (reserved)
return gpg_error (GPG_ERR_INV_VALUE);
err = add_arg (gpg, "--with-colons");
if (!err)
err = add_arg (gpg, "--fixed-list-mode");
if (!err)
err = add_arg (gpg, "--with-fingerprint");
if (!err)
err = add_arg (gpg, "--with-fingerprint");
if (!err && (mode & GPGME_KEYLIST_MODE_SIGS)
&& (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS))
{
err = add_arg (gpg, "--list-options");
if (!err)
err = add_arg (gpg, "show-sig-subpackets=\"20,26\"");
}
if (!err)
err = add_arg (gpg, secret_only ? "--list-secret-keys"
: ((mode & GPGME_KEYLIST_MODE_SIGS)
? "--check-sigs" : "--list-keys"));
if (!err)
err = add_arg (gpg, "--");
err = gpg_keylist_build_options (gpg, secret_only, mode);
if (pattern)
{