GNUPG-1-9-BRANCH gnupg/tools (ChangeLog symcryptrun.c)
cvs user marcus
cvs at cvs.gnupg.org
Sat Jun 4 14:36:06 CEST 2005
Date: Saturday, June 4, 2005 @ 14:57:26
Author: marcus
Path: /cvs/gnupg/gnupg/tools
Tag: GNUPG-1-9-BRANCH
Modified: ChangeLog symcryptrun.c
2005-06-04 Marcus Brinkmann <marcus at g10code.de>
* symcryptrun.c (main): Allow any number of arguments, don't use
first argument as input file name. Pass extra arguments to
confucius_main.
(confucius_main): Accept new arguments argc and argv and pass them
to confucius_process.
(confucius_process): Accept new arguments argc and argv and pass
them to the confucius process.
---------------+
ChangeLog | 10 ++++++++++
symcryptrun.c | 54 +++++++++++++++++++++++++++++-------------------------
2 files changed, 39 insertions(+), 25 deletions(-)
Index: gnupg/tools/ChangeLog
diff -u gnupg/tools/ChangeLog:1.25.2.78 gnupg/tools/ChangeLog:1.25.2.79
--- gnupg/tools/ChangeLog:1.25.2.78 Wed Jun 1 17:46:00 2005
+++ gnupg/tools/ChangeLog Sat Jun 4 14:57:26 2005
@@ -1,3 +1,13 @@
+2005-06-04 Marcus Brinkmann <marcus at g10code.de>
+
+ * symcryptrun.c (main): Allow any number of arguments, don't use
+ first argument as input file name. Pass extra arguments to
+ confucius_main.
+ (confucius_main): Accept new arguments argc and argv and pass them
+ to confucius_process.
+ (confucius_process): Accept new arguments argc and argv and pass
+ them to the confucius process.
+
2005-06-01 Werner Koch <wk at g10code.com>
* symcryptrun.c: Include mkdtemp.h.
Index: gnupg/tools/symcryptrun.c
diff -u gnupg/tools/symcryptrun.c:1.1.2.9 gnupg/tools/symcryptrun.c:1.1.2.10
--- gnupg/tools/symcryptrun.c:1.1.2.9 Wed Jun 1 17:46:00 2005
+++ gnupg/tools/symcryptrun.c Sat Jun 4 14:57:26 2005
@@ -486,15 +486,10 @@
requested. If it is oDecrypt, decryption is requested. INFILE and
OUTFILE are the temporary files used in the process. */
int
-confucius_process (int mode, char *infile, char *outfile)
+confucius_process (int mode, char *infile, char *outfile,
+ int argc, char *argv[])
{
- char *const args[] = { opt.program,
- mode == oEncrypt ? "-m1" : "-m2",
- "-q", infile,
- "-z", outfile,
- "-s", opt.keyfile,
- mode == oEncrypt ? "-af" : "-f",
- NULL };
+ char **args;
int cstderr[2];
int master;
int slave;
@@ -523,9 +518,29 @@
return 1;
}
+ args = malloc (sizeof (char *) * (10 + argc));
+ if (!args)
+ {
+ log_error (_("cannot allocate args vector\n"));
+ return 1;
+ }
+ args[0] = opt.program;
+ args[1] = (mode == oEncrypt) ? "-m1" : "-m2";
+ args[2] = "-q";
+ args[3] = infile;
+ args[4] = "-z";
+ args[5] = outfile;
+ args[6] = "-s";
+ args[7] = opt.keyfile;
+ args[8] = (mode == oEncrypt) ? "-af" : "-f";
+ args[9 + argc] = NULL;
+ while (argc--)
+ args[9 + argc] = argv[argc];
+
if (pipe (cstderr) < 0)
{
log_error (_("could not create pipe: %s\n"), strerror (errno));
+ free (args);
return 1;
}
@@ -534,6 +549,7 @@
log_error (_("could not create pty: %s\n"), strerror (errno));
close (cstderr[0]);
close (cstderr[1]);
+ free (args);
return -1;
}
@@ -551,6 +567,7 @@
close (slave);
close (cstderr[0]);
close (cstderr[1]);
+ free (args);
return 1;
}
else if (pid == 0)
@@ -587,6 +604,7 @@
close (slave);
close (cstderr[1]);
+ free (args);
/* Listen on the output FDs. */
do
@@ -753,7 +771,7 @@
requested. If it is oDecrypt, decryption is requested. The other
parameters are taken from the global option data. */
int
-confucius_main (int mode)
+confucius_main (int mode, int argc, char *argv[])
{
int res;
char *tmpdir;
@@ -811,7 +829,7 @@
/* Run the engine and thus create the output file, handling
passphrase retrieval. */
- res = confucius_process (mode, infile, outfile);
+ res = confucius_process (mode, infile, outfile, argc, argv);
if (res)
{
remove_file (outfile, mode == oDecrypt);
@@ -962,20 +980,6 @@
xfree (configname);
configname = NULL;
- /* With --inputfile an argument is not allowed, without only one
- optional argument is allowed. */
- if (argc > 1)
- log_error (_("too many arguments\n"));
- else if (opt.input && argc)
- log_error (_("no argument allowed when using option \"%s\"\n"),
- "--inputfile");
-
- if (argc)
- {
- opt.input = *argv;
- argv++; argc--;
- }
-
if (!mode)
log_error (_("either %s or %s must be given\n"),
"--decrypt", "--encrypt");
@@ -1001,7 +1005,7 @@
res = 1;
}
else if (!strcmp (opt.class, "confucius"))
- res = confucius_main (mode);
+ res = confucius_main (mode, argc, argv);
else
{
log_error (_("class %s is not supported\n"), opt.class);
More information about the Gnupg-commits
mailing list