summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent/gpg-agent.c46
-rw-r--r--common/ChangeLog6
-rw-r--r--common/asshelp.c26
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/openpgp/Makefile.am6
-rwxr-xr-xtests/openpgp/defs.inc25
-rw-r--r--tests/openpgp/gpg-agent.conf.tmpl3
-rw-r--r--tools/ChangeLog8
-rw-r--r--tools/gpg-connect-agent.c127
-rw-r--r--tools/gpgconf-comp.c30
-rw-r--r--tools/gpgconf.c3
11 files changed, 87 insertions, 195 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 5cd7108cb..b526af7e3 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -850,8 +850,31 @@ main (int argc, char **argv )
/*log_info ("NOTE: this is a development version!\n");*/
#endif
+#ifdef ENABLE_NLS
+ /* gpg-agent usually does not output any messages because it runs in
+ the background. For log files it is acceptable to have messages
+ always encoded in utf-8. We switch here to utf-8, so that
+ commands like --help still give native messages. It is far
+ easier to switch only once instead of for every message and it
+ actually helps when more then one thread is active (avoids an
+ extra copy step). */
+ bind_textdomain_codeset (PACKAGE_GT, "UTF-8");
+#endif
+
+ if (!pipe_server && !is_daemon && !gpgconf_list)
+ {
+ /* We have been called without any options and thus we merely
+ check whether an agent is already running. We do this right
+ here so that we don't clobber a logfile with this check but
+ print the status directly to stderr. */
+ opt.debug = 0;
+ set_debug ();
+ check_for_running_agent (0, 0);
+ agent_exit (0);
+ }
+
set_debug ();
-
+
if (atexit (cleanup))
{
log_error ("atexit failed\n");
@@ -939,27 +962,6 @@ main (int argc, char **argv )
agent_exit (0);
}
- /* If this has been called without any options, we merely check
- whether an agent is already running. We do this here so that we
- don't clobber a logfile but print it directly to stderr. */
- if (!pipe_server && !is_daemon)
- {
- log_set_prefix (NULL, JNLIB_LOG_WITH_PREFIX);
- check_for_running_agent (0, 0);
- agent_exit (0);
- }
-
-#ifdef ENABLE_NLS
- /* gpg-agent usually does not output any messages because it runs in
- the background. For log files it is acceptable to have messages
- always encoded in utf-8. We switch here to utf-8, so that
- commands like --help still give native messages. It is far
- easier to switch only once instead of for every message and it
- actually helps when more then one thread is active (avoids an
- extra copy step). */
- bind_textdomain_codeset (PACKAGE_GT, "UTF-8");
-#endif
-
/* Now start with logging to a file if this is desired. */
if (logfile)
{
diff --git a/common/ChangeLog b/common/ChangeLog
index 7fa83fef9..156cfa1cb 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,9 @@
+2010-10-14 Werner Koch <wk@g10code.com>
+
+ * asshelp.c (start_new_gpg_agent): Print a notice once the agent
+ has been started.
+ (start_new_dirmngr): Likewise.
+
2010-10-13 Werner Koch <wk@g10code.com>
* miscellaneous.c (parse_version_number, parse_version_string)
diff --git a/common/asshelp.c b/common/asshelp.c
index 15f6b4005..b44b803b0 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -422,14 +422,19 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
int i;
if (verbose)
- log_info (_("waiting %d seconds for the %s "
- "to come up\n"), 5, "agent" );
+ log_info (_("waiting %d seconds for the agent "
+ "to come up\n"), 5);
for (i=0; i < 5; i++)
{
gnupg_sleep (1);
err = assuan_socket_connect (ctx, sockname, 0, 0);
if (!err)
- break;
+ {
+ if (verbose && !debug)
+ log_info (_("connection to agent"
+ " established\n"));
+ break;
+ }
}
}
}
@@ -513,7 +518,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
}
if (debug)
- log_debug ("connection to agent established\n");
+ log_debug (_("connection to agent established\n"));
err = assuan_transact (ctx, "RESET",
NULL, NULL, NULL, NULL, NULL, NULL);
@@ -606,14 +611,19 @@ start_new_dirmngr (assuan_context_t *r_ctx,
int i;
if (verbose)
- log_info (_("waiting %d seconds for the %s to come up\n"),
- 5, "dirmngr" );
+ log_info (_("waiting %d seconds for the dirmngr to come up\n"),
+ 5);
for (i=0; i < 5; i++)
{
gnupg_sleep (1);
err = assuan_socket_connect (ctx, sockname, 0, 0);
if (!err)
- break;
+ {
+ if (verbose && !debug)
+ log_info (_("connection to the dirmngr"
+ " established\n"));
+ break;
+ }
}
}
}
@@ -637,7 +647,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
}
if (debug)
- log_debug ("connection to the dirmngr established\n");
+ log_debug (_("connection to the dirmngr established\n"));
*r_ctx = ctx;
return 0;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c4693c01d..e9f3df232 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,7 +46,7 @@ EXTRA_DIST = runtest inittests $(testscripts) \
samplekeys/cert_g10code_test1.pem \
samplekeys/cert_g10code_theo1.pem
-# We used to run $(testscripts) here but tehse asschk scripts ares not
+# We used to run $(testscripts) here but these asschk scripts ares not
# completely reliable in all enviromnets and thus we better disable
# them. The tests are anyway way to minimal. We will eventually
# write new tests based on gpg-connect-agent which has a full fledged
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index 0900e8f3e..ba1a65529 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -16,15 +16,14 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# Process this file with automake to create Makefile.in
-GPG_IMPORT = ../../g10/gpg2 --homedir . \
+GPG_IMPORT = ../../g10/gpg2 --homedir $(abs_builddir) \
--quiet --yes --no-permission-warning --import
# Programs required before we can run these tests.
required_pgms = ../../g10/gpg2 ../../agent/gpg-agent \
../../tools/gpg-connect-agent
-TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= LC_ALL=C \
- ../../agent/gpg-agent --quiet --daemon sh
+TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO= LC_ALL=C
TESTS = version.test mds.test \
decrypt.test decrypt-dsa.test \
@@ -68,7 +67,6 @@ distclean-local:
prepared.stamp: ./pubring.gpg ./secring.gpg ./plain-1 ./plain-2 ./plain-3 \
./pubring.pkr ./secring.skr ./gpg_dearmor $(DATA_FILES)
$(GPG_IMPORT) $(srcdir)/pubdemo.asc
- cat $(srcdir)/gpg-agent.conf.tmpl > gpg-agent.conf
echo timestamp >./prepared.stamp
# We need to depend on a couple of programs so that the tests don't
diff --git a/tests/openpgp/defs.inc b/tests/openpgp/defs.inc
index 3e46ebd61..1158fb0cd 100755
--- a/tests/openpgp/defs.inc
+++ b/tests/openpgp/defs.inc
@@ -1,6 +1,6 @@
# Definitions for the OpenPGP test scripts -*- sh -*-
# Copyright 1998,1999,2000,2001,2002,2003,2004,2005,2006,
-# 2007 Free Software Foundation, Inc.
+# 2007, 2010 Free Software Foundation, Inc.
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. This file is
@@ -161,26 +161,27 @@ pgmname=`basename $0`
[ -z "$srcdir" ] && fatal "not called from make"
-# Make sure we have a valid option files even with VPATH builds.
-for f in gpg.conf ; do
- if [ -f ./$f ]; then
- :
- elif [ -f $srcdir/$f.tmpl ]; then
- cat $srcdir/$f.tmpl >$f
- fi
-done
-
# Always work in the current directory. We set GNUPGHOME only if it
# has not been set already. Usually it is set through the Makefile's
# TESTS_ENVIRONMENT macro.
if [ -z "$GNUPGHOME" ]; then
- GNUPGHOME=`pwd`
+ GNUPGHOME=`/bin/pwd`
export GNUPGHOME
-elif [ "$GNUPGHOME" != `pwd` ]; then
+elif [ "$GNUPGHOME" != `/bin/pwd` ]; then
echo "$pgmname: GNUPGHOME not set to the cwd" $* >&2
exit 1
fi
+# Make sure we have a valid option files even with VPATH builds.
+for f in gpg.conf gpg-agent.conf ; do
+ if [ -f ./$f ]; then
+ :
+ elif [ -f $srcdir/$f.tmpl ]; then
+ cat $srcdir/$f.tmpl >$f
+ fi
+done
+
+# (--no-permission-warning makes only sense on the commandline)
GPG="../../g10/gpg2 --no-permission-warning "
echo "Test: $pgmname" > ${pgmname}.log
diff --git a/tests/openpgp/gpg-agent.conf.tmpl b/tests/openpgp/gpg-agent.conf.tmpl
index 18e15206b..3833e0a8f 100644
--- a/tests/openpgp/gpg-agent.conf.tmpl
+++ b/tests/openpgp/gpg-agent.conf.tmpl
@@ -1,2 +1,3 @@
-no-use-standard-socket
+use-standard-socket
+
diff --git a/tools/ChangeLog b/tools/ChangeLog
index f841ac13a..de148ba56 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-14 Werner Koch <wk@g10code.com>
+
+ * gpg-connect-agent.c (start_agent): Rewrite using the
+ start_new_gpg_agent function.
+
+ * gpgconf-comp.c (gpg_agent_runtime_change): Use gpg-connect-agent
+ on all platforms.
+
2010-10-06 Werner Koch <wk@g10code.com>
* watchgnupg.c (print_version): Add option --time-only.
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index 8210df598..652f288c5 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -2156,131 +2156,28 @@ read_and_print_response (assuan_context_t ctx, int withhash, int *r_goterr)
static assuan_context_t
start_agent (void)
{
- int rc = 0;
- char *infostr, *p;
+ gpg_error_t err;
assuan_context_t ctx;
session_env_t session_env;
- infostr = getenv ("GPG_AGENT_INFO");
- if (!infostr || !*infostr)
- {
- char *sockname;
-
- rc = assuan_new (&ctx);
- if (rc)
- {
- log_error ("assuan_new failed: %s\n", gpg_strerror (rc));
- exit (1);
- }
-
- /* Check whether we can connect at the standard socket. */
- sockname = make_filename (opt.homedir, "S.gpg-agent", NULL);
- rc = assuan_socket_connect (ctx, sockname, 0, 0);
-
-#ifdef HAVE_W32_SYSTEM
- /* If we failed to connect under Windows, we fire up the agent. */
- if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
- {
- const char *agent_program;
- const char *argv[3];
- int save_rc = rc;
-
- if (opt.verbose)
- log_info (_("no running gpg-agent - starting one\n"));
- agent_program = gnupg_module_name (GNUPG_MODULE_NAME_AGENT);
-
- argv[0] = "--daemon";
- argv[1] = "--use-standard-socket";
- argv[2] = NULL;
-
- rc = gnupg_spawn_process_detached (agent_program, argv, NULL);
- if (rc)
- log_debug ("failed to start agent `%s': %s\n",
- agent_program, gpg_strerror (rc));
- else
- {
- /* Give the agent some time to prepare itself. */
- gnupg_sleep (3);
- /* Now try again to connect the agent. */
- rc = assuan_new (&ctx);
- if (rc)
- {
- log_error ("assuan_new failed: %s\n", gpg_strerror (rc));
- exit (1);
- }
-
- rc = assuan_socket_connect (ctx, sockname, 0, 0);
- }
- if (rc)
- rc = save_rc;
- }
-#endif /*HAVE_W32_SYSTEM*/
- xfree (sockname);
- }
- else
- {
- int prot;
- int pid;
-
- infostr = xstrdup (infostr);
- if ( !(p = strchr (infostr, PATHSEP_C)) || p == infostr)
- {
- log_error (_("malformed GPG_AGENT_INFO environment variable\n"));
- xfree (infostr);
- exit (1);
- }
- *p++ = 0;
- pid = atoi (p);
- while (*p && *p != PATHSEP_C)
- p++;
- prot = *p? atoi (p+1) : 0;
- if (prot != 1)
- {
- log_error (_("gpg-agent protocol version %d is not supported\n"),
- prot);
- xfree (infostr);
- exit (1);
- }
-
- rc = assuan_new (&ctx);
- if (rc)
- {
- log_error ("assuan_new failed: %s\n", gpg_strerror (rc));
- exit (1);
- }
-
- rc = assuan_socket_connect (ctx, infostr, pid, 0);
- xfree (infostr);
- }
-
- if (rc)
- {
- log_error ("can't connect to the agent: %s\n", gpg_strerror (rc));
- exit (1);
- }
-
- if (opt.verbose)
- log_info ("connection to agent established\n");
-
- rc = assuan_transact (ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
- if (rc)
- {
- log_error (_("error sending %s command: %s\n"), "RESET",
- gpg_strerror (rc));
- exit (1);
- }
-
session_env = session_env_new ();
if (!session_env)
log_fatal ("error allocating session environment block: %s\n",
strerror (errno));
- rc = send_pinentry_environment (ctx, GPG_ERR_SOURCE_DEFAULT,
- NULL, NULL, session_env);
+ err = start_new_gpg_agent (&ctx,
+ GPG_ERR_SOURCE_DEFAULT,
+ opt.homedir,
+ NULL,
+ NULL, NULL,
+ session_env,
+ !opt.quiet, 0,
+ NULL, NULL);
+
session_env_release (session_env);
- if (rc)
+ if (err)
{
- log_error (_("error sending standard options: %s\n"), gpg_strerror (rc));
+ log_error (_("error sending standard options: %s\n"), gpg_strerror (err));
exit (1);
}
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 1718a08a5..d0372469d 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1032,35 +1032,6 @@ struct error_line_s
static void
gpg_agent_runtime_change (void)
{
-#ifndef HAVE_W32_SYSTEM
- char *agent = getenv ("GPG_AGENT_INFO");
- char *pid_str;
- unsigned long pid_long;
- char *tail;
- pid_t pid;
-
- if (!agent)
- return;
-
- pid_str = strchr (agent, ':');
- if (!pid_str)
- return;
-
- pid_str++;
- errno = 0;
- pid_long = strtoul (pid_str, &tail, 0);
- if (errno || (*tail != ':' && *tail != '\0'))
- return;
-
- pid = (pid_t) pid_long;
-
- /* Check for overflow. */
- if (pid_long != (unsigned long) pid)
- return;
-
- /* Ignore any errors here. */
- kill (pid, SIGHUP);
-#else
gpg_error_t err;
const char *pgmname;
const char *argv[2];
@@ -1077,7 +1048,6 @@ gpg_agent_runtime_change (void)
gc_error (0, 0, "error running `%s%s': %s",
pgmname, " reloadagent", gpg_strerror (err));
gnupg_release_process (pid);
-#endif /*!HAVE_W32_SYSTEM*/
}
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index 222bc48f8..d6c333792 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -50,7 +50,6 @@ enum cmd_and_opt_values
aCheckConfig,
aListDirs,
aReload
-
};
@@ -72,7 +71,7 @@ static ARGPARSE_OPTS opts[] =
N_("list global configuration file") },
{ aCheckConfig, "check-config", 256,
N_("check global configuration file") },
- { aReload, "reload", 256, "@" },
+ { aReload, "reload", 256, N_("reload all or a given component")},
{ 301, NULL, 0, N_("@\nOptions:\n ") },