diff options
author | Werner Koch <wk@gnupg.org> | 2009-07-07 12:02:41 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2009-07-07 12:02:41 +0200 |
commit | f6f5430e5014f90b685420447dffe89b220e2663 (patch) | |
tree | 0a8c28fc24f291bbc3a148f7240d1c49421f9077 /g10 | |
parent | * debugging.texi (Common Problems): Add a note about corrupted (diff) | |
download | gnupg2-f6f5430e5014f90b685420447dffe89b220e2663.tar.xz gnupg2-f6f5430e5014f90b685420447dffe89b220e2663.zip |
Reworked passing of envars to Pinentry.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 14 | ||||
-rw-r--r-- | g10/call-agent.c | 3 | ||||
-rw-r--r-- | g10/gpg.c | 34 | ||||
-rw-r--r-- | g10/options.h | 9 |
4 files changed, 48 insertions, 12 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index fcf759041..ca1b53dd6 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,6 +1,18 @@ +2009-07-07 Werner Koch <wk@g10code.com> + + * gpg.c (set_opt_session_env): New. + (main): Allocate opt.session_env. Use it for oDisplay, oTTYname, + oTTYtype and oXauthority. + + * options.h: Include session_env.h. + (opt): Add field SESSION_ENV, remove obsolete fields. + + * call-agent.c (start_agent): Adjust start_new_gpg_agent for + changed args. + 2009-06-24 Werner Koch <wk@g10code.com> - * keyedit.c (menu_select_key): Renmove dead assign to I. + * keyedit.c (menu_select_key): Remove dead assign to I. (menu_select_uid): Ditto. * keyring.c (keyring_search): Remove dead assign to NAME. * card-util.c (card_edit): Remove useless DID_CHECKPIN. diff --git a/g10/call-agent.c b/g10/call-agent.c index 0590514df..071be2a09 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -91,9 +91,8 @@ start_agent (void) GPG_ERR_SOURCE_DEFAULT, opt.homedir, opt.agent_program, - opt.display, opt.ttyname, opt.ttytype, opt.lc_ctype, opt.lc_messages, - opt.xauthority, opt.pinentry_user_data, + opt.session_env, opt.verbose, DBG_ASSUAN, NULL, NULL); if (!rc) @@ -955,6 +955,17 @@ make_username( const char *string ) } +static void +set_opt_session_env (const char *name, const char *value) +{ + gpg_error_t err; + + err = session_env_setenv (opt.session_env, name, value); + if (err) + log_fatal ("error setting session environment: %s\n", + gpg_strerror (err)); +} + /* Setup the debugging. With a LEVEL of NULL only the active debug flags are propagated to the subsystems. With LEVEL set, a specific set of debug flags is set; thus overriding all flags already @@ -1935,6 +1946,10 @@ main (int argc, char **argv) create_dotlock(NULL); /* Register locking cleanup. */ + opt.session_env = session_env_new (); + if (!opt.session_env) + log_fatal ("error allocating session environment block: %s\n", + strerror (errno)); opt.command_fd = -1; /* no command fd */ opt.compress_level = -1; /* defaults to standard compress level */ @@ -2820,12 +2835,23 @@ main (int argc, char **argv) pers_compress_list=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 oDisplay: + set_opt_session_env ("DISPLAY", pargs.r.ret_str); + break; + case oTTYname: + set_opt_session_env ("GPG_TTY", pargs.r.ret_str); + break; + case oTTYtype: + set_opt_session_env ("TERM", pargs.r.ret_str); + break; + case oXauthority: + set_opt_session_env ("XAUTHORITY", 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 oXauthority: opt.xauthority = pargs.r.ret_str; break; + case oGroup: add_group(pargs.r.ret_str); break; case oUnGroup: rm_group(pargs.r.ret_str); break; case oNoGroups: diff --git a/g10/options.h b/g10/options.h index 40bd23029..a99ca22e8 100644 --- a/g10/options.h +++ b/g10/options.h @@ -24,6 +24,7 @@ #include <types.h> #include "main.h" #include "packet.h" +#include "../common/session-env.h" #ifndef EXTERN_UNLESS_MAIN_MODULE /* Norcraft can't cope with common symbols */ @@ -85,13 +86,11 @@ struct int max_cert_depth; const char *homedir; const char *agent_program; - char *display; /* 5 options to be passed to the gpg-agent */ - char *ttyname; - char *ttytype; + + /* Options to be passed to the gpg-agent */ + session_env_t session_env; char *lc_ctype; char *lc_messages; - char *xauthority; - char *pinentry_user_data; int skip_verify; int compress_keys; |