mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +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:
parent
7cadd7c840
commit
ee6bb32a8b
9 changed files with 266 additions and 8 deletions
|
@ -1,3 +1,15 @@
|
|||
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.
|
||||
|
||||
2002-04-05 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* protect-tool.c (show_file): New. Used as default action.
|
||||
|
|
|
@ -36,6 +36,11 @@ struct {
|
|||
int batch; /* batch mode */
|
||||
const char *homedir; /* configuration directory name */
|
||||
const char *pinentry_program;
|
||||
char *display;
|
||||
char *ttyname;
|
||||
char *ttytype;
|
||||
char *lc_ctype;
|
||||
char *lc_messages;
|
||||
const char *scdaemon_program;
|
||||
int no_grab; /* don't let the pinentry grab the keyboard */
|
||||
unsigned long def_cache_ttl;
|
||||
|
|
|
@ -494,6 +494,58 @@ cmd_learn (ASSUAN_CONTEXT ctx, char *line)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value)
|
||||
{
|
||||
CTRL ctrl = assuan_get_pointer (ctx);
|
||||
|
||||
if (!strcmp (key, "display"))
|
||||
{
|
||||
if (opt.display)
|
||||
free (opt.display);
|
||||
opt.display = strdup (value);
|
||||
if (!opt.display)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
}
|
||||
else if (!strcmp (key, "ttyname"))
|
||||
{
|
||||
if (opt.ttyname)
|
||||
free (opt.ttyname);
|
||||
opt.ttyname = strdup (value);
|
||||
if (!opt.ttyname)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
}
|
||||
else if (!strcmp (key, "ttytype"))
|
||||
{
|
||||
if (opt.ttytype)
|
||||
free (opt.ttytype);
|
||||
opt.ttytype = strdup (value);
|
||||
if (!opt.ttytype)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
}
|
||||
else if (!strcmp (key, "lc-ctype"))
|
||||
{
|
||||
if (opt.lc_ctype)
|
||||
free (opt.lc_ctype);
|
||||
opt.lc_ctype = strdup (value);
|
||||
if (!opt.lc_ctype)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
}
|
||||
else if (!strcmp (key, "lc-messages"))
|
||||
{
|
||||
if (opt.lc_messages)
|
||||
free (opt.lc_messages);
|
||||
opt.lc_messages = strdup (value);
|
||||
if (!opt.lc_messages)
|
||||
return ASSUAN_Out_Of_Core;
|
||||
}
|
||||
else
|
||||
return ASSUAN_Invalid_Option;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Tell the assuan library about our commands */
|
||||
static int
|
||||
|
@ -533,6 +585,7 @@ register_commands (ASSUAN_CONTEXT ctx)
|
|||
return rc;
|
||||
}
|
||||
assuan_register_reset_notify (ctx, reset_notify);
|
||||
assuan_register_option_handler (ctx, option_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,8 +67,13 @@ enum cmd_and_opt_values
|
|||
oLogFile,
|
||||
oServer,
|
||||
oBatch,
|
||||
|
||||
|
||||
oPinentryProgram,
|
||||
oDisplay,
|
||||
oTTYname,
|
||||
oTTYtype,
|
||||
oLCctype,
|
||||
oLCmessages,
|
||||
oScdaemonProgram,
|
||||
oDefCacheTTL,
|
||||
|
||||
|
@ -94,6 +99,12 @@ static ARGPARSE_OPTS opts[] = {
|
|||
{ oLogFile, "log-file" ,2, N_("use a log file for the server")},
|
||||
|
||||
{ oPinentryProgram, "pinentry-program", 2 , "path to PIN Entry program" },
|
||||
{ oDisplay, "display", 2, "set the display" },
|
||||
{ oTTYname, "ttyname", 2, "set the tty terminal node name" },
|
||||
{ oTTYtype, "ttytype", 2, "set the tty terminal type" },
|
||||
{ oLCctype, "lc-ctype", 2, "set the tty LC_CTYPE value" },
|
||||
{ oLCmessages, "lc-messages", 2, "set the tty LC_MESSAGES value" },
|
||||
|
||||
{ oScdaemonProgram, "scdaemon-program", 2 , "path to SCdaemon program" },
|
||||
{ oDefCacheTTL, "default-cache-ttl", 4,
|
||||
"|N|expire cached PINs after N seconds"},
|
||||
|
@ -374,6 +385,11 @@ main (int argc, char **argv )
|
|||
case oServer: pipe_server = 1; break;
|
||||
|
||||
case oPinentryProgram: opt.pinentry_program = pargs.r.ret_str; break;
|
||||
case oDisplay: opt.display = xstrdup (pargs.r.ret_str); break;
|
||||
case oTTYname: opt.ttyname = xstrdup (pargs.r.ret_str); break;
|
||||
case oTTYtype: opt.ttytype = xstrdup (pargs.r.ret_str); break;
|
||||
case oLCctype: opt.lc_ctype = xstrdup (pargs.r.ret_str); break;
|
||||
case oLCmessages: opt.lc_messages = xstrdup (pargs.r.ret_str); break;
|
||||
case oScdaemonProgram: opt.scdaemon_program = pargs.r.ret_str; break;
|
||||
case oDefCacheTTL: opt.def_cache_ttl = pargs.r.ret_ulong; break;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ start_pinentry (void)
|
|||
int rc;
|
||||
const char *pgmname;
|
||||
ASSUAN_CONTEXT ctx;
|
||||
const char *argv[3];
|
||||
const char *argv[5];
|
||||
|
||||
if (entry_ctx)
|
||||
return 0; /* No need to serialize things becuase the agent is
|
||||
|
@ -81,7 +81,14 @@ start_pinentry (void)
|
|||
pgmname++;
|
||||
|
||||
argv[0] = pgmname;
|
||||
argv[1] = NULL;
|
||||
if (opt.display)
|
||||
{
|
||||
argv[1] = "--display";
|
||||
argv[2] = opt.display;
|
||||
argv[3] = NULL;
|
||||
}
|
||||
else
|
||||
argv[1] = NULL;
|
||||
|
||||
/* connect to the pinentry and perform initial handshaking */
|
||||
rc = assuan_pipe_connect (&ctx, opt.pinentry_program, (char**)argv, 0);
|
||||
|
@ -100,7 +107,47 @@ start_pinentry (void)
|
|||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
|
||||
if (opt.ttyname)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION ttyname=%s", opt.ttyname) < 0 )
|
||||
return GNUPG_Out_Of_Core;
|
||||
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
free (optstr);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
}
|
||||
if (opt.ttytype)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION ttytype=%s", opt.ttytype) < 0 )
|
||||
return GNUPG_Out_Of_Core;
|
||||
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
}
|
||||
if (opt.lc_ctype)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION lc-ctype=%s", opt.lc_ctype) < 0 )
|
||||
return GNUPG_Out_Of_Core;
|
||||
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
}
|
||||
if (opt.lc_messages)
|
||||
{
|
||||
char *optstr;
|
||||
if (asprintf (&optstr, "OPTION lc-messages=%s", opt.lc_messages) < 0 )
|
||||
return GNUPG_Out_Of_Core;
|
||||
rc = assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
if (rc)
|
||||
return map_assuan_err (rc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue