aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog6
-rw-r--r--g10/g10.c5
-rw-r--r--g10/passphrase.c13
3 files changed, 24 insertions, 0 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index edc6af54a..e7278e00d 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-05 David Shaw <[email protected]>
+
+ * g10.c (main), passphrase.c (set_passphrase_from_string): New
+ --passphrase command line option. Only useful in very special
+ circumstances.
+
2005-08-05 Werner Koch <[email protected]>
* gpgv.c (keyserver_import_fprint): New stub.
diff --git a/g10/g10.c b/g10/g10.c
index fce9f3ad1..8d53d7df3 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -211,6 +211,7 @@ enum cmd_and_opt_values
oCompressLevel,
oBZ2CompressLevel,
oBZ2DecompressLowmem,
+ oPasswd,
oPasswdFD,
oPasswdFile,
oCommandFD,
@@ -558,6 +559,7 @@ static ARGPARSE_OPTS opts[] = {
/* { aListTrustPath, "list-trust-path",0, "@"}, */
{ aPipeMode, "pipemode", 0, "@" },
{ oKOption, NULL, 0, "@"},
+ { oPasswd, "passphrase",2, "@" },
{ oPasswdFD, "passphrase-fd",1, "@" },
{ oPasswdFile, "passphrase-file",2, "@" },
{ oCommandFD, "command-fd",1, "@" },
@@ -2270,6 +2272,9 @@ main (int argc, char **argv )
case oCompressLevel: opt.compress_level = pargs.r.ret_int; break;
case oBZ2CompressLevel: opt.bz2_compress_level = pargs.r.ret_int; break;
case oBZ2DecompressLowmem: opt.bz2_decompress_lowmem=1; break;
+ case oPasswd:
+ set_passphrase_from_string(pargs.r.ret_str);
+ break;
case oPasswdFD:
pwfd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
opt.use_agent = 0;
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 5f9c7915b..fa10eccec 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -115,6 +115,19 @@ get_last_passphrase()
return p;
}
+/* Here's an interesting question: since this passphrase was passed in
+ on the command line, is there really any point in using secure
+ memory for it? I'm going with 'yes', since it doesn't hurt, and
+ might help in some small way (swapping). */
+
+void
+set_passphrase_from_string(const char *pass)
+{
+ xfree( fd_passwd );
+ fd_passwd = xmalloc_secure(strlen(pass)+1);
+ strcpy(fd_passwd,pass);
+}
+
void
read_passphrase_from_fd( int fd )