1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Allow tilde expansion for the foo-program options.

* agent/gpg-agent.c (parse_rereadable_options): Use make_filename_try
for opt.pinentry_program.  Change definition accordingly.
* g10/gpg.c (main): Use make_filename for agent_program,
dirmngr_program, and keyboxd_program. Change definition accordingly.
* sm/gpgsm.c (main): Ditto.
* tools/gpg-card.c (parse_arguments): Ditto.
* tools/gpg-connect-agent.c (main): Ditto.
* tools/gpg-wks-client.c (parse_arguments): Likewise.  Do it also for
option --output.
(process_confirmation_request): Print a note for a successful sent.
--

GnuPG-bug-id: 7017
This commit is contained in:
Werner Koch 2024-02-27 10:35:46 +01:00
parent adf4db6e20
commit 962058f704
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
11 changed files with 70 additions and 33 deletions

View File

@ -86,8 +86,8 @@ struct
/* Enable pinentry debugging (--debug 1024 should also be used). */ /* Enable pinentry debugging (--debug 1024 should also be used). */
int debug_pinentry; int debug_pinentry;
/* Filename of the program to start as pinentry. */ /* Filename of the program to start as pinentry (malloced). */
const char *pinentry_program; char *pinentry_program;
/* Filename of the program to handle daemon tasks. */ /* Filename of the program to handle daemon tasks. */
const char *daemon_program[DAEMON_MAX_TYPE]; const char *daemon_program[DAEMON_MAX_TYPE];

View File

@ -864,6 +864,7 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread)
opt.debug = 0; opt.debug = 0;
opt.no_grab = 1; opt.no_grab = 1;
opt.debug_pinentry = 0; opt.debug_pinentry = 0;
xfree (opt.pinentry_program);
opt.pinentry_program = NULL; opt.pinentry_program = NULL;
opt.pinentry_touch_file = NULL; opt.pinentry_touch_file = NULL;
xfree (opt.pinentry_invisible_char); xfree (opt.pinentry_invisible_char);
@ -924,7 +925,10 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread)
case oNoGrab: opt.no_grab |= 1; break; case oNoGrab: opt.no_grab |= 1; break;
case oGrab: opt.no_grab |= 2; break; case oGrab: opt.no_grab |= 2; break;
case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break; case oPinentryProgram:
xfree (opt.pinentry_program);
opt.pinentry_program = make_filename_try (pargs->r.ret_str, NULL);
break;
case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break; case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break;
case oPinentryInvisibleChar: case oPinentryInvisibleChar:
xfree (opt.pinentry_invisible_char); xfree (opt.pinentry_invisible_char);

View File

@ -3592,9 +3592,18 @@ main (int argc, char **argv)
case oPersonalCompressPreferences: case oPersonalCompressPreferences:
pers_compress_list=pargs.r.ret_str; pers_compress_list=pargs.r.ret_str;
break; break;
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; case oAgentProgram:
case oKeyboxdProgram: opt.keyboxd_program = pargs.r.ret_str; break; xfree (opt.agent_program);
case oDirmngrProgram: opt.dirmngr_program = pargs.r.ret_str; break; opt.agent_program = make_filename (pargs.r.ret_str, NULL);
break;
case oKeyboxdProgram:
xfree (opt.keyboxd_program);
opt.keyboxd_program = make_filename (pargs.r.ret_str, NULL);
break;
case oDirmngrProgram:
xfree (opt.dirmngr_program);
opt.dirmngr_program = make_filename (pargs.r.ret_str, NULL);
break;
case oDisableDirmngr: opt.disable_dirmngr = 1; break; case oDisableDirmngr: opt.disable_dirmngr = 1; break;
case oWeakDigest: case oWeakDigest:
additional_weak_digest(pargs.r.ret_str); additional_weak_digest(pargs.r.ret_str);

View File

@ -126,9 +126,9 @@ struct
int marginals_needed; int marginals_needed;
int completes_needed; int completes_needed;
int max_cert_depth; int max_cert_depth;
const char *agent_program; char *agent_program;
const char *keyboxd_program; char *keyboxd_program;
const char *dirmngr_program; char *dirmngr_program;
int disable_dirmngr; int disable_dirmngr;
const char *def_new_key_algo; const char *def_new_key_algo;

View File

@ -1335,8 +1335,19 @@ main ( int argc, char **argv)
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oChUid: break; /* Command line only (see above). */ case oChUid: break; /* Command line only (see above). */
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break;
case oKeyboxdProgram: opt.keyboxd_program = pargs.r.ret_str; break; case oAgentProgram:
xfree (opt.agent_program);
opt.agent_program = make_filename (pargs.r.ret_str, NULL);
break;
case oKeyboxdProgram:
xfree (opt.keyboxd_program);
opt.keyboxd_program = make_filename (pargs.r.ret_str, NULL);
break;
case oDirmngrProgram:
xfree (opt.dirmngr_program);
opt.dirmngr_program = make_filename (pargs.r.ret_str, NULL);
break;
case oDisplay: case oDisplay:
set_opt_session_env ("DISPLAY", pargs.r.ret_str); set_opt_session_env ("DISPLAY", pargs.r.ret_str);
@ -1354,7 +1365,6 @@ main ( int argc, char **argv)
case oLCctype: opt.lc_ctype = 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 oLCmessages: opt.lc_messages = xstrdup (pargs.r.ret_str); break;
case oDirmngrProgram: opt.dirmngr_program = pargs.r.ret_str; break;
case oDisableDirmngr: opt.disable_dirmngr = 1; break; case oDisableDirmngr: opt.disable_dirmngr = 1; break;
case oPreferSystemDirmngr: /* Obsolete */; break; case oPreferSystemDirmngr: /* Obsolete */; break;
case oProtectToolProgram: case oProtectToolProgram:

View File

@ -60,16 +60,16 @@ struct
int use_keyboxd; /* Use the external keyboxd as storage backend. */ int use_keyboxd; /* Use the external keyboxd as storage backend. */
const char *config_filename; /* Name of the used config file. */ const char *config_filename; /* Name of the used config file. */
const char *agent_program; char *agent_program;
const char *keyboxd_program; char *keyboxd_program;
session_env_t session_env; session_env_t session_env;
char *lc_ctype; char *lc_ctype;
char *lc_messages; char *lc_messages;
int autostart; int autostart;
const char *dirmngr_program; char *dirmngr_program;
int disable_dirmngr; /* Do not do any dirmngr calls. */ int disable_dirmngr; /* Do not do any dirmngr calls. */
const char *protect_tool_program; const char *protect_tool_program;
char *outfile; /* name of output file */ char *outfile; /* name of output file */

View File

@ -220,9 +220,15 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
} }
break; break;
case oGpgProgram: opt.gpg_program = pargs->r.ret_str; break; case oGpgProgram:
case oGpgsmProgram: opt.gpgsm_program = pargs->r.ret_str; break; opt.gpg_program = make_filename (pargs->r.ret_str, NULL);
case oAgentProgram: opt.agent_program = pargs->r.ret_str; break; break;
case oGpgsmProgram:
opt.gpgsm_program = make_filename (pargs->r.ret_str, NULL);
break;
case oAgentProgram:
opt.agent_program = make_filename (pargs->r.ret_str, NULL);
break;
case oStatusFD: case oStatusFD:
gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1)); gnupg_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1));

View File

@ -34,9 +34,9 @@ struct
unsigned int debug; unsigned int debug;
int quiet; int quiet;
int with_colons; int with_colons;
const char *gpg_program; char *gpg_program;
const char *gpgsm_program; char *gpgsm_program;
const char *agent_program; char *agent_program;
int autostart; int autostart;
int no_key_lookup; /* Assume --no-key-lookup for "list". */ int no_key_lookup; /* Assume --no-key-lookup for "list". */

View File

@ -126,9 +126,9 @@ struct
int quiet; /* Be extra quiet. */ int quiet; /* Be extra quiet. */
int autostart; /* Start the server if not running. */ int autostart; /* Start the server if not running. */
const char *homedir; /* Configuration directory name */ const char *homedir; /* Configuration directory name */
const char *agent_program; /* Value of --agent-program. */ char *agent_program; /* Value of --agent-program. */
const char *dirmngr_program; /* Value of --dirmngr-program. */ char *dirmngr_program; /* Value of --dirmngr-program. */
const char *keyboxd_program; /* Value of --keyboxd-program. */ char *keyboxd_program; /* Value of --keyboxd-program. */
int hex; /* Print data lines in hex format. */ int hex; /* Print data lines in hex format. */
int decode; /* Decode received data lines. */ int decode; /* Decode received data lines. */
int use_dirmngr; /* Use the dirmngr and not gpg-agent. */ int use_dirmngr; /* Use the dirmngr and not gpg-agent. */
@ -1224,9 +1224,15 @@ main (int argc, char **argv)
case oVerbose: opt.verbose++; break; case oVerbose: opt.verbose++; break;
case oNoVerbose: opt.verbose = 0; break; case oNoVerbose: opt.verbose = 0; break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break; case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break; case oAgentProgram:
case oDirmngrProgram: opt.dirmngr_program = pargs.r.ret_str; break; opt.agent_program = make_filename (pargs.r.ret_str, NULL);
case oKeyboxdProgram: opt.keyboxd_program = pargs.r.ret_str; break; break;
case oDirmngrProgram:
opt.dirmngr_program = make_filename (pargs.r.ret_str, NULL);
break;
case oKeyboxdProgram:
opt.keyboxd_program = make_filename (pargs.r.ret_str, NULL);
break;
case oNoAutostart: opt.autostart = 0; break; case oNoAutostart: opt.autostart = 0; break;
case oNoHistory: opt.no_history = 1; break; case oNoHistory: opt.no_history = 1; break;
case oHex: opt.hex = 1; break; case oHex: opt.hex = 1; break;

View File

@ -240,16 +240,16 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
break; break;
case oGpgProgram: case oGpgProgram:
opt.gpg_program = pargs->r.ret_str; opt.gpg_program = make_filename (pargs->r.ret_str, NULL);
break; break;
case oDirectory: case oDirectory:
opt.directory = pargs->r.ret_str; opt.directory = make_filename (pargs->r.ret_str, NULL);
break; break;
case oSend: case oSend:
opt.use_sendmail = 1; opt.use_sendmail = 1;
break; break;
case oOutput: case oOutput:
opt.output = pargs->r.ret_str; opt.output = make_filename (pargs->r.ret_str, NULL);
break; break;
case oFakeSubmissionAddr: case oFakeSubmissionAddr:
fake_submission_addr = pargs->r.ret_str; fake_submission_addr = pargs->r.ret_str;
@ -1787,6 +1787,8 @@ process_confirmation_request (estream_t msg, const char *mainfpr)
log_info ("no encryption key found - sending response in the clear\n"); log_info ("no encryption key found - sending response in the clear\n");
err = send_confirmation_response (sender, address, nonce, 0, NULL); err = send_confirmation_response (sender, address, nonce, 0, NULL);
} }
if (!err)
log_info ("response sent to '%s' for '%s'\n", sender, address);
leave: leave:
nvc_release (nvc); nvc_release (nvc);

View File

@ -40,9 +40,9 @@ struct
int with_colons; int with_colons;
int no_autostart; int no_autostart;
int add_revocs; int add_revocs;
const char *output; char *output;
const char *gpg_program; char *gpg_program;
const char *directory; char *directory;
const char *default_from; const char *default_from;
strlist_t extra_headers; strlist_t extra_headers;
} opt; } opt;