1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

2002-04-24 Marcus Brinkmann <marcus@g10code.de>

* configure.ac: Check for locale.h.

agent/
2002-04-24  Marcus Brinkmann  <marcus@g10code.de>

	* agent.h (struct opt): Add members display, ttyname, ttytype,
	lc_ctype, and lc_messages.
	* gpg-agent.c (enum cmd_and_opt_values): Add oDisplay, oTTYname,
	oTTYtype, oLCctype, and LCmessages.
	(main): Handle these options.
	* command.c (option_handler): New function.
	(register_commands): Register option handler.
	* query.c (start_pinentry): Pass the various display and tty
	options to the pinentry.

sm/
2002-04-24  Marcus Brinkmann  <marcus@g10code.de>

	* gpgsm.h (struct opt): New members display, ttyname, ttytype,
	lc_ctype, lc_messages.
	* gpgsm.c (enum cmd_and_opt_values): New members oDisplay,
	oTTYname, oTTYtype, oLCctype, oLCmessages.
	(opts): New entries for these options.
	(main): Handle these new options.
	* call-agent.c (start_agent): Set the various display and tty
	parameter after resetting.
This commit is contained in:
Marcus Brinkmann 2002-04-24 21:52:47 +00:00
parent 7cadd7c840
commit ee6bb32a8b
9 changed files with 266 additions and 8 deletions

View file

@ -1,3 +1,14 @@
2002-04-24 Marcus Brinkmann <marcus@g10code.de>
* gpgsm.h (struct opt): New members display, ttyname, ttytype,
lc_ctype, lc_messages.
* gpgsm.c (enum cmd_and_opt_values): New members oDisplay,
oTTYname, oTTYtype, oLCctype, oLCmessages.
(opts): New entries for these options.
(main): Handle these new options.
* call-agent.c (start_agent): Set the various display and tty
parameter after resetting.
2002-04-18 Werner Koch <wk@gnupg.org>
* certreqgen.c (gpgsm_genkey): Write status output on success.

View file

@ -26,8 +26,10 @@
#include <unistd.h>
#include <time.h>
#include <assert.h>
#include <gcrypt.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include "gpgsm.h"
#include "../assuan/assuan.h"
@ -133,6 +135,11 @@ start_agent (void)
int rc;
char *infostr, *p;
ASSUAN_CONTEXT ctx;
char *dft_display = NULL;
char *dft_ttyname = NULL;
char *dft_ttytype = NULL;
char *old_lc = NULL;
char *dft_lc = NULL;
if (agent_ctx)
return 0; /* fixme: We need a context for each thread or serialize
@ -144,9 +151,8 @@ start_agent (void)
{
const char *pgmname;
const char *argv[3];
log_info (_("no running gpg-agent - starting one\n"));
if (fflush (NULL))
{
log_error ("error flushing pending output: %s\n", strerror (errno));
@ -204,7 +210,6 @@ start_agent (void)
}
}
if (rc)
{
log_error ("can't connect to the agent: %s\n", assuan_strerror (rc));
@ -214,6 +219,92 @@ start_agent (void)
if (DBG_AGENT)
log_debug ("connection to agent established\n");
rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
if (rc)
return map_assuan_err (rc);
dft_display = getenv ("DISPLAY");
if (opt.display || dft_display)
{
char *optstr;
if (asprintf (&optstr, "OPTION display=%s",
opt.display ? opt.display : dft_display) < 0)
return GNUPG_Out_Of_Core;
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
}
if (!opt.ttyname && ttyname (1))
dft_ttyname = ttyname (1);
if (opt.ttyname || dft_ttyname)
{
char *optstr;
if (asprintf (&optstr, "OPTION ttyname=%s",
opt.ttyname ? opt.ttyname : dft_ttyname) < 0)
return GNUPG_Out_Of_Core;
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
}
dft_ttytype = getenv ("TERM");
if (!rc && (opt.ttytype || (dft_ttyname && dft_ttytype)))
{
char *optstr;
if (asprintf (&optstr, "OPTION ttytype=%s",
opt.ttyname ? opt.ttytype : dft_ttytype) < 0)
return GNUPG_Out_Of_Core;
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
}
#ifdef LC_CTYPE
old_lc = setlocale (LC_CTYPE, NULL);
dft_lc = setlocale (LC_CTYPE, "");
#endif
if (!rc && (opt.lc_ctype || (dft_ttyname && dft_lc)))
{
char *optstr;
if (asprintf (&optstr, "OPTION lc-ctype=%s",
opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0)
return GNUPG_Out_Of_Core;
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
}
#ifdef LC_CTYPE
if (old_lc)
setlocale (LC_CTYPE, old_lc);
#endif
#ifdef LC_MESSAGES
old_lc = setlocale (LC_MESSAGES, NULL);
dft_lc = setlocale (LC_MESSAGES, "");
#endif
if (!rc && (opt.lc_messages || (dft_ttyname && dft_lc)))
{
char *optstr;
if (asprintf (&optstr, "OPTION lc-messages=%s",
opt.lc_messages ? opt.lc_messages : dft_lc) < 0)
return GNUPG_Out_Of_Core;
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
if (rc)
return map_assuan_err (rc);
}
#ifdef LC_MESSAGES
if (old_lc)
setlocale (LC_MESSAGES, old_lc);
#endif
return 0;
}

View file

@ -83,7 +83,14 @@ enum cmd_and_opt_values {
oDebugWait,
oEnableSpecialFilenames,
oAgentProgram,
oDisplay,
oTTYname,
oTTYtype,
oLCctype,
oLCmessages,
oDirmngrProgram,
@ -340,6 +347,11 @@ static ARGPARSE_OPTS opts[] = {
{ oNoOptions, "no-options", 0, "@" }, /* shortcut for --options /dev/null */
{ oHomedir, "homedir", 2, "@" }, /* defaults to "~/.gnupg" */
{ oAgentProgram, "agent-program", 2 , "@" },
{ oDisplay, "display", 2, "@" },
{ oTTYname, "ttyname", 2, "@" },
{ oTTYtype, "ttytype", 2, "@" },
{ oLCctype, "lc-ctype", 2, "@" },
{ oLCmessages, "lc-messages", 2, "@" },
{ oDirmngrProgram, "dirmngr-program", 2 , "@" },
{ oNoBatch, "no-batch", 0, "@" },
@ -842,6 +854,11 @@ main ( int argc, char **argv)
case oNoOptions: break; /* no-options */
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break;
case oDisplay: opt.display = pargs.r.ret_str; break;
case oTTYname: opt.ttyname = pargs.r.ret_str; break;
case oTTYtype: opt.ttytype = pargs.r.ret_str; break;
case oLCctype: opt.lc_ctype = pargs.r.ret_str; break;
case oLCmessages: opt.lc_messages = pargs.r.ret_str; break;
case oDirmngrProgram: opt.dirmngr_program = pargs.r.ret_str; break;
case oNoDefKeyring: default_keyring = 0; break;

View file

@ -39,6 +39,12 @@ struct {
const char *homedir; /* configuration directory name */
const char *agent_program;
const char *display;
const char *ttyname;
const char *ttytype;
const char *lc_ctype;
const char *lc_messages;
const char *dirmngr_program;
char *outfile; /* name of output file */