aboutsummaryrefslogtreecommitdiffstats
path: root/g10/gpg.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <[email protected]>2018-09-23 18:10:17 +0000
committerDaniel Kahn Gillmor <[email protected]>2018-09-23 18:25:01 +0000
commit07c19981da0607dc442fadc4079b1d71fbef8f83 (patch)
tree27f9623a71189b8aac8dd7896f5ca75794dea23e /g10/gpg.c
parentg10: Fix memory leak for --card-status. (diff)
downloadgnupg-dkg/passphrase-env.tar.gz
gnupg-dkg/passphrase-env.zip
gpg: add --passphrase-env VARNAME to read passphrase from environmentdkg/passphrase-env
* g10/keydb.h: declare set_passphrase_from_environment_variable() * g10/passphrase.c: set_passphrase_from_environment_variable() new function * g10/gpg.c: add new --passphrase-env argument, handle it. -- There are problems or difficulties (to varying degrees) with all of the techniques available for sending a passphrase directly to the GnuPG process when --pinentry-mode=loopback: * Passphrases on the command line often leak into the process table. * Passphrases in a file often leak into the disk. * Using an extra file descriptor to send a passphrase works well on platforms that make it easy to allocate and use extra file descriptors, but is pretty awkward on platforms that don't facilitate this. So this patch adds a new form of passphrase-passing, using an environment variable. In POSIX shell, this looks like (for example): mypass="IUuKctdEhH8' gpg --batch --pinentry-mode=loopback\ --passphrase-env=mypass --decrypt < message.txt Hopefully, this is easier to use than --passphrase-fd on platforms or language toolkits that don't facilitate file descriptor manipulation. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
Diffstat (limited to 'g10/gpg.c')
-rw-r--r--g10/gpg.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/g10/gpg.c b/g10/gpg.c
index f04a3400a..36adbaaa2 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -257,6 +257,7 @@ enum cmd_and_opt_values
oBZ2CompressLevel,
oBZ2DecompressLowmem,
oPassphrase,
+ oPassphraseEnv,
oPassphraseFD,
oPassphraseFile,
oPassphraseRepeat,
@@ -709,6 +710,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_c (aRebuildKeydbCaches, "rebuild-keydb-caches", "@"),
ARGPARSE_s_s (oPassphrase, "passphrase", "@"),
+ ARGPARSE_s_s (oPassphraseEnv, "passphrase-env", "@"),
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
ARGPARSE_s_s (oPassphraseFile, "passphrase-file", "@"),
ARGPARSE_s_i (oPassphraseRepeat,"passphrase-repeat", "@"),
@@ -3151,6 +3153,9 @@ main (int argc, char **argv)
case oPassphrase:
set_passphrase_from_string(pargs.r.ret_str);
break;
+ case oPassphraseEnv:
+ set_passphrase_from_environment_variable(pargs.r.ret_str);
+ break;
case oPassphraseFD:
pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0);
break;