aboutsummaryrefslogtreecommitdiffstats
path: root/src/dirinfo.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-02-21 10:22:45 +0000
committerWerner Koch <[email protected]>2014-02-21 10:22:45 +0000
commit651d9e1c6bc1cab248024c3850ef64698247588f (patch)
tree1ef03ae1f09046eae7ae5c31daa48b7394c157b1 /src/dirinfo.c
parentFix type inconsistency between gpgme.h and gpgme.c. (diff)
downloadgpgme-651d9e1c6bc1cab248024c3850ef64698247588f.tar.gz
gpgme-651d9e1c6bc1cab248024c3850ef64698247588f.zip
Always pass correct name to argv[0]. Ignore GPG_AGENT_INFO for gpg2.
* src/dirinfo.c (WANT_GPG_ONE_MODE): New. (struct dirinfo): Add field "gpg_one_mode". (get_gpgconf_item): Set that field and return it if requested. (_gpgme_in_gpg_one_mode): New. * src/engine-gpg.c (build_argv): Check GPG_AGENT_INFO only in gpg-1 mode. * src/dirinfo.c (_gpgme_get_basename): New. * src/engine-g13.c (g13_new): Take argv[0] from the pgmname. * src/engine-gpgsm.c (gpgsm_new): Ditto. * src/engine-gpg.c (build_argv): Ditto. Add arg PGMNAME. (start): Pass PGMNAME to buildargv.
Diffstat (limited to 'src/dirinfo.c')
-rw-r--r--src/dirinfo.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/dirinfo.c b/src/dirinfo.c
index eb29c6bd..8526d392 100644
--- a/src/dirinfo.c
+++ b/src/dirinfo.c
@@ -42,7 +42,8 @@ enum
WANT_GPG_NAME,
WANT_GPGSM_NAME,
WANT_G13_NAME,
- WANT_UISRV_SOCKET
+ WANT_UISRV_SOCKET,
+ WANT_GPG_ONE_MODE
};
/* Values retrieved via gpgconf and cached here. */
@@ -56,6 +57,7 @@ static struct {
char *gpgsm_name;
char *g13_name;
char *uisrv_socket;
+ int gpg_one_mode; /* System is in gpg1 mode. */
} dirinfo;
@@ -223,12 +225,14 @@ get_gpgconf_item (int what)
{
/* Probably gpgconf is not installed. Assume we are using
GnuPG-1. */
+ dirinfo.gpg_one_mode = 1;
pgmname = _gpgme_get_gpg_path ();
if (pgmname)
dirinfo.gpg_name = pgmname;
}
else
{
+ dirinfo.gpg_one_mode = 0;
read_gpgconf_dirs (pgmname, 0);
read_gpgconf_dirs (pgmname, 1);
dirinfo.gpgconf_name = pgmname;
@@ -268,6 +272,7 @@ get_gpgconf_item (int what)
case WANT_GPGSM_NAME: result = dirinfo.gpgsm_name; break;
case WANT_G13_NAME: result = dirinfo.g13_name; break;
case WANT_UISRV_SOCKET: result = dirinfo.uisrv_socket; break;
+ case WANT_GPG_ONE_MODE: result = dirinfo.gpg_one_mode? "1":NULL; break;
}
UNLOCK (dirinfo_lock);
return result;
@@ -323,3 +328,31 @@ _gpgme_get_default_uisrv_socket (void)
{
return get_gpgconf_item (WANT_UISRV_SOCKET);
}
+
+/* Return true if we are in GnuPG-1 mode - ie. no gpgconf and agent
+ being optional. */
+int
+_gpgme_in_gpg_one_mode (void)
+{
+ return !!get_gpgconf_item (WANT_GPG_ONE_MODE);
+}
+
+
+
+/* Helper function to return the basename of the passed filename. */
+const char *
+_gpgme_get_basename (const char *name)
+{
+ const char *s;
+
+ if (!name || !*name)
+ return name;
+ for (s = name + strlen (name) -1; s >= name; s--)
+ if (*s == '/'
+#ifdef HAVE_W32_SYSTEM
+ || *s == '\\' || *s == ':'
+#endif
+ )
+ return s+1;
+ return name;
+}