aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-12-27 15:08:20 +0000
committerWerner Koch <[email protected]>2013-12-27 15:08:20 +0000
commit02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b (patch)
treec2286910441497fa7af0debbeca2da61f61617d0 /src
parentDocument API change for GPGME_EVENT_DONE from 2009. (diff)
downloadgpgme-02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b.tar.gz
gpgme-02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b.zip
Locate engine names only at runtime and prefer GnuPG-2.
* configure.ac (NEED_GPG_VERSION, NEED_GPGSM_VERSION) (NEED_G13_VERSION, NEED_GPGCONF_VERSION): Remove vars and all related checks. Do not check for any engine version. (HAVE_ASSUAN): Remove AM conditional. * src/Makefile.am: Remove separate component vars and always build all engines but uiserver. * src/dirinfo.c (WANT_GPGCONF_NAME): New. (struct dirinfo): Add field gpgconf_name. (_gpgme_get_default_gpgconf_name): Use WANT_GPGCONF_NAME. (get_gpgconf_item): Set gpgconf name and adjust for _gpgme_get_*_path now returning a malloced string. * src/engine.c (engine_ops): Always init all engines except for uiserver. * src/posix-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (walk_path): New. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path ): Re-implement using walk_path. * src/w32-util.c (_gpgme_get_gpgsm_path, _gpgme_get_g13_path): Remove unused functions. (_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Return a malloced string. * src/engine-g13.c (g13_get_req_version): Use a hardwired string with the required version. This info belongs into this file. * src/engine-gpg.c (gpg_get_req_version): Ditto. * src/engine-gpgconf.c (gpgconf_get_req_version): Ditto. * src/engine-gpgsm.c (gpgsm_get_req_version): Ditto. * tests/t-engine-info.c: Replace now useless test by an info output. * tests/gpg/Makefile.am (GPG, GPG_AGENT): Hardwire gpg and gpg-agent. * tests/gpgsm/Makefile.am (GPGSM): Hardwire gpgsm. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--src/Makefile.am30
-rw-r--r--src/dirinfo.c16
-rw-r--r--src/engine-backend.h8
-rw-r--r--src/engine-g13.c2
-rw-r--r--src/engine-gpg.c4
-rw-r--r--src/engine-gpgconf.c2
-rw-r--r--src/engine-gpgsm.c2
-rw-r--r--src/engine.c16
-rw-r--r--src/posix-util.c73
-rw-r--r--src/sys-util.h6
-rw-r--r--src/util.h12
-rw-r--r--src/w32-util.c74
12 files changed, 81 insertions, 164 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f951039..abc014c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,30 +66,6 @@ if HAVE_W32CE_SYSTEM
system_components += w32-ce.h w32-ce.c
endif
-if HAVE_GPGSM
-gpgsm_components = engine-gpgsm.c
-else
-gpgsm_components =
-endif
-
-if HAVE_ASSUAN
-assuan_components = assuan-support.c engine-assuan.c
-else
-assuan_components =
-endif
-
-if HAVE_GPGCONF
-gpgconf_components = engine-gpgconf.c
-else
-gpgconf_components =
-endif
-
-if HAVE_G13
-g13_components = engine-g13.c
-else
-g13_components =
-endif
-
if HAVE_UISERVER
uiserver_components = engine-uiserver.c
else
@@ -113,11 +89,11 @@ main_sources = \
sign.c passphrase.c progress.c \
key.c keylist.c trust-item.c trustlist.c \
import.c export.c genkey.c delete.c edit.c getauditlog.c \
- opassuan.c passwd.c \
+ opassuan.c passwd.c assuan-support.c \
engine.h engine-backend.h engine.c engine-gpg.c status-table.c \
- $(gpgsm_components) $(assuan_components) $(gpgconf_components) \
+ engine-gpgsm.c engine-assuan.c engine-gpgconf.c \
$(uiserver_components) \
- $(g13_components) vfs-mount.c vfs-create.c \
+ engine-g13.c vfs-mount.c vfs-create.c \
gpgconf.c \
sema.h priv-io.h $(system_components) sys-util.h dirinfo.c \
debug.c debug.h gpgme.c version.c error.c
diff --git a/src/dirinfo.c b/src/dirinfo.c
index 27c0dd76..2e387fa1 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -38,6 +38,7 @@ enum
{
WANT_HOMEDIR,
WANT_AGENT_SOCKET,
+ WANT_GPGCONF_NAME,
WANT_GPG_NAME,
WANT_GPGSM_NAME,
WANT_G13_NAME,
@@ -49,6 +50,7 @@ static struct {
int valid; /* Cached information is valid. */
char *homedir;
char *agent_socket;
+ char *gpgconf_name;
char *gpg_name;
char *gpgsm_name;
char *g13_name;
@@ -194,13 +196,14 @@ get_gpgconf_item (int what)
LOCK (dirinfo_lock);
if (!dirinfo.valid)
{
- const char *pgmname;
+ char *pgmname;
pgmname = _gpgme_get_gpgconf_path ();
if (pgmname && access (pgmname, F_OK))
{
_gpgme_debug (DEBUG_INIT,
"gpgme_dinfo: gpgconf='%s' [not installed]\n", pgmname);
+ free (pgmname);
pgmname = NULL; /* Not available. */
}
else
@@ -212,12 +215,13 @@ get_gpgconf_item (int what)
GnuPG-1. */
pgmname = _gpgme_get_gpg_path ();
if (pgmname)
- dirinfo.gpg_name = strdup (pgmname);
+ dirinfo.gpg_name = pgmname;
}
else
{
read_gpgconf_dirs (pgmname, 0);
read_gpgconf_dirs (pgmname, 1);
+ dirinfo.gpgconf_name = pgmname;
}
/* Even if the reading of the directories failed (e.g. due to an
too old version gpgconf or no gpgconf at all), we need to
@@ -249,6 +253,7 @@ get_gpgconf_item (int what)
{
case WANT_HOMEDIR: result = dirinfo.homedir; break;
case WANT_AGENT_SOCKET: result = dirinfo.agent_socket; break;
+ case WANT_GPGCONF_NAME: result = dirinfo.gpgconf_name; break;
case WANT_GPG_NAME: result = dirinfo.gpg_name; break;
case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break;
case WANT_G13_NAME: result = dirinfo.g13_name; break;
@@ -294,14 +299,11 @@ _gpgme_get_default_g13_name (void)
return get_gpgconf_item (WANT_G13_NAME);
}
-/* Return the default gpgconf file name. Returns NULL if not known.
- Because gpgconf is the binary used to retrieved all these default
- names, this function is merely a simple wrapper around the function
- used to locate this binary. */
+/* Return the default gpgconf file name. Returns NULL if not known. */
const char *
_gpgme_get_default_gpgconf_name (void)
{
- return _gpgme_get_gpgconf_path ();
+ return get_gpgconf_item (WANT_GPGCONF_NAME);
}
/* Return the default UI-server socket name. Returns NULL if not
diff --git a/src/engine-backend.h b/src/engine-backend.h
index a4c0eb27..a768652c 100644
--- a/src/engine-backend.h
+++ b/src/engine-backend.h
@@ -128,18 +128,10 @@ struct engine_ops
extern struct engine_ops _gpgme_engine_ops_gpg; /* OpenPGP. */
-#ifdef ENABLE_GPGSM
extern struct engine_ops _gpgme_engine_ops_gpgsm; /* CMS. */
-#endif
-#ifdef ENABLE_GPGCONF
extern struct engine_ops _gpgme_engine_ops_gpgconf; /* gpg-conf. */
-#endif
-#ifdef ENABLE_ASSUAN
extern struct engine_ops _gpgme_engine_ops_assuan; /* Low-level Assuan. */
-#endif
-#ifdef ENABLE_G13
extern struct engine_ops _gpgme_engine_ops_g13; /* Crypto VFS. */
-#endif
#ifdef ENABLE_UISERVER
extern struct engine_ops _gpgme_engine_ops_uiserver;
#endif
diff --git a/src/engine-g13.c b/src/engine-g13.c
index b97e0b44..f0910159 100644
--- a/src/engine-g13.c
+++ b/src/engine-g13.c
@@ -107,7 +107,7 @@ g13_get_version (const char *file_name)
static const char *
g13_get_req_version (void)
{
- return NEED_G13_VERSION;
+ return "2.1.0";
}
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index 3bc9f660..2f59bb9a 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -1,7 +1,7 @@
/* engine-gpg.c - Gpg Engine.
Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2009, 2010, 2012 g10 Code GmbH
+ 2009, 2010, 2012, 2013 g10 Code GmbH
This file is part of GPGME.
@@ -303,7 +303,7 @@ gpg_get_version (const char *file_name)
static const char *
gpg_get_req_version (void)
{
- return NEED_GPG_VERSION;
+ return "1.4.0";
}
diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c
index 1d457bb9..47cde669 100644
--- a/src/engine-gpgconf.c
+++ b/src/engine-gpgconf.c
@@ -68,7 +68,7 @@ gpgconf_get_version (const char *file_name)
static const char *
gpgconf_get_req_version (void)
{
- return NEED_GPGCONF_VERSION;
+ return "2.0.4";
}
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index cee20e31..24cd34d9 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -127,7 +127,7 @@ gpgsm_get_version (const char *file_name)
static const char *
gpgsm_get_req_version (void)
{
- return NEED_GPGSM_VERSION;
+ return "2.0.4";
}
diff --git a/src/engine.c b/src/engine.c
index 09f379c7..80febea5 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -46,26 +46,10 @@ struct engine
static struct engine_ops *engine_ops[] =
{
&_gpgme_engine_ops_gpg, /* OpenPGP. */
-#ifdef ENABLE_GPGSM
&_gpgme_engine_ops_gpgsm, /* CMS. */
-#else
- NULL,
-#endif
-#ifdef ENABLE_GPGCONF
&_gpgme_engine_ops_gpgconf, /* gpg-conf. */
-#else
- NULL,
-#endif
-#ifdef ENABLE_ASSUAN
&_gpgme_engine_ops_assuan, /* Low-Level Assuan. */
-#else
- NULL,
-#endif
-#ifdef ENABLE_G13
&_gpgme_engine_ops_g13, /* Crypto VFS. */
-#else
- NULL,
-#endif
#ifdef ENABLE_UISERVER
&_gpgme_engine_ops_uiserver /* UI-Server. */
#else
diff --git a/src/posix-util.c b/src/posix-util.c
index fd445070..d4e4e3f4 100644
--- a/src/posix-util.c
+++ b/src/posix-util.c
@@ -30,47 +30,60 @@
#include "util.h"
#include "sys-util.h"
-const char *
-_gpgme_get_gpg_path (void)
-{
-#ifdef GPG_PATH
- return GPG_PATH;
-#else
- return NULL;
-#endif
-}
-const char *
-_gpgme_get_gpgsm_path (void)
+/* Find an executable program PGM along the envvar PATH. */
+static char *
+walk_path (const char *pgm)
{
-#ifdef GPGSM_PATH
- return GPGSM_PATH;
-#else
+ const char *path, *s;
+ char *fname, *p;
+
+ path = getenv ("PATH");
+ if (!path)
+ path = "/bin:/usr/bin:.";
+
+ fname = malloc (strlen (path) + 1 + strlen (pgm) + 1);
+ if (!fname)
+ return NULL;
+
+ for (;;)
+ {
+ for (s=path, p=fname; *s && *s != ':'; s++, p++)
+ *p = *s;
+ if (*p != '/')
+ *p++ = '/';
+ strcpy (p, pgm);
+ if (!access (fname, X_OK))
+ return fname;
+ if (!*s)
+ break;
+ path = s + 1;
+ }
+
+ free (fname);
return NULL;
-#endif
}
-const char *
-_gpgme_get_gpgconf_path (void)
+
+/* Return the full file name of the GPG binary. This function is used
+ if gpgconf was not found and thus it can be assumed that gpg2 is
+ not installed. This function is only called by get_gpgconf_item
+ and may not be called concurrently. */
+char *
+_gpgme_get_gpg_path (void)
{
-#ifdef GPGCONF_PATH
- return GPGCONF_PATH;
-#else
- return NULL;
-#endif
+ return walk_path ("gpg");
}
-const char *
-_gpgme_get_g13_path (void)
+
+/* This function is only called by get_gpgconf_item and may not be
+ called concurrently. */
+char *
+_gpgme_get_gpgconf_path (void)
{
-#ifdef G13_PATH
- return G13_PATH;
-#else
- return NULL;
-#endif
+ return walk_path ("gpgconf");
}
-
/* See w32-util.c */
int
_gpgme_get_conf_int (const char *key, int *value)
diff --git a/src/sys-util.h b/src/sys-util.h
index f6506d33..3686f897 100644
--- a/src/sys-util.h
+++ b/src/sys-util.h
@@ -21,9 +21,7 @@
#define SYS_UTIL_H
/*-- {posix,w32}-util.c --*/
-const char *_gpgme_get_gpg_path (void);
-const char *_gpgme_get_gpgsm_path (void);
-const char *_gpgme_get_gpgconf_path (void);
-const char *_gpgme_get_g13_path (void);
+char *_gpgme_get_gpg_path (void);
+char *_gpgme_get_gpgconf_path (void);
#endif /* SYS_UTIL_H */
diff --git a/src/util.h b/src/util.h
index c4329801..57c8b138 100644
--- a/src/util.h
+++ b/src/util.h
@@ -151,25 +151,13 @@ const char *_gpgme_get_w32spawn_path (void);
char *_gpgme_w32ce_get_debug_envvar (void);
#endif /*HAVE_W32CE_SYSTEM*/
-/*-- Error codes not yet available in current gpg-error.h. --*/
-#ifndef GPG_ERR_UNFINISHED
-#define GPG_ERR_UNFINISHED 199
-#endif
-#ifndef GPG_ERR_NOT_OPERATIONAL
-#define GPG_ERR_NOT_OPERATIONAL 176
-#endif
-#ifndef GPG_ERR_MISSING_ISSUER_CERT
-#define GPG_ERR_MISSING_ISSUER_CERT 185
-#endif
-#ifdef ENABLE_ASSUAN
#include <assuan.h>
/* System hooks for assuan integration. */
extern struct assuan_system_hooks _gpgme_assuan_system_hooks;
extern struct assuan_malloc_hooks _gpgme_assuan_malloc_hooks;
int _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
unsigned int cat, const char *msg);
-#endif
#endif /* UTIL_H */
diff --git a/src/w32-util.c b/src/w32-util.c
index 4cee1cb6..31a58bbd 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -374,7 +374,7 @@ find_program_in_inst_dir (const char *inst_dir, const char *name)
/* If an installation directory has been passed, this overrides a
location given bu the registry. The idea here is that we prefer
- a a program installed alongside with gpgme. We don't want the
+ a program installed alongside with gpgme. We don't want the
registry to override this to have a better isolation of an gpgme
aware applications for other effects. Note that the "Install
Directory" registry item has been used for ages in Gpg4win and
@@ -424,72 +424,36 @@ find_program_at_standard_place (const char *name)
}
-const char *
+/* Return the full file name of the GPG binary. This function is used
+ if gpgconf was not found and thus it can be assumed that gpg2 is
+ not installed. This function is only called by get_gpgconf_item
+ and may not be called concurrently. */
+char *
_gpgme_get_gpg_path (void)
{
- static char *gpg_program;
+ char *gpg;
const char *inst_dir;
inst_dir = _gpgme_get_inst_dir ();
- LOCK (get_path_lock);
- if (!gpg_program)
- gpg_program = find_program_in_inst_dir (inst_dir, "gpg.exe");
- if (!gpg_program)
- gpg_program = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe");
- UNLOCK (get_path_lock);
- return gpg_program;
+ gpg = find_program_in_inst_dir (inst_dir, "gpg.exe");
+ if (!gpg)
+ gpg = find_program_at_standard_place ("GNU\\GnuPG\\gpg.exe");
+ return gpg;
}
-
-const char *
-_gpgme_get_gpgsm_path (void)
-{
- static char *gpgsm_program;
- const char *inst_dir;
-
- inst_dir = _gpgme_get_inst_dir ();
- LOCK (get_path_lock);
- if (!gpgsm_program)
- gpgsm_program = find_program_in_inst_dir (inst_dir, "gpgsm.exe");
- if (!gpgsm_program)
- gpgsm_program = find_program_at_standard_place ("GNU\\GnuPG\\gpgsm.exe");
- UNLOCK (get_path_lock);
- return gpgsm_program;
-}
-
-
-const char *
+/* This function is only called by get_gpgconf_item and may not be
+ called concurrently. */
+char *
_gpgme_get_gpgconf_path (void)
{
- static char *gpgconf_program;
- const char *inst_dir;
-
- inst_dir = _gpgme_get_inst_dir ();
- LOCK (get_path_lock);
- if (!gpgconf_program)
- gpgconf_program = find_program_in_inst_dir (inst_dir, "gpgconf.exe");
- if (!gpgconf_program)
- gpgconf_program
- = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe");
- UNLOCK (get_path_lock);
- return gpgconf_program;
-}
-
-
-const char *
-_gpgme_get_g13_path (void)
-{
- static char *g13_program;
+ char *gpgconf;
const char *inst_dir;
inst_dir = _gpgme_get_inst_dir ();
- LOCK (get_path_lock);
- if (!g13_program)
- g13_program = find_program_in_inst_dir (inst_dir, "g13.exe");
- if (!g13_program)
- g13_program = find_program_at_standard_place ("GNU\\GnuPG\\g13.exe");
- UNLOCK (get_path_lock);
- return g13_program;
+ gpgconf = find_program_in_inst_dir (inst_dir, "gpgconf.exe");
+ if (!gpgconf)
+ gpgconf = find_program_at_standard_place ("GNU\\GnuPG\\gpgconf.exe");
+ return gpgconf;
}