summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>2017-08-01 17:41:03 +0200
committerMarcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>2017-08-01 17:41:03 +0200
commitebc65ff459e6c228fb7406e375819a9fe5637abe (patch)
treeb5db1cf2eae3cbc5b9be17ac37696aa97be2aa7d
parentartwork: Add icons. (diff)
downloadgnupg2-ebc65ff459e6c228fb7406e375819a9fe5637abe.tar.xz
gnupg2-ebc65ff459e6c228fb7406e375819a9fe5637abe.zip
g10: Always save standard revocation certificate in file.
* g10/main.h (open_outfile): New parameter NO_OUTFILE. * g10/openfile.c (open_outfile): New parameter NO_OUTFILE. If given, never use opt.outfile. * g10/revoke.c (create_revocation): If FILENAME is true, also set NO_OUTFILE to true (for standard revocation certificates). * g10/dearmor.c, g10/encrypt.c, g10/export.c, g10/revoke.c, g10/sign.c: Adjust all other callers. Signed-off-by: Marcus Brinkmann <mb@g10code.com> GnuPG-bug-id: 3015
-rw-r--r--g10/dearmor.c4
-rw-r--r--g10/encrypt.c4
-rw-r--r--g10/export.c2
-rw-r--r--g10/main.h2
-rw-r--r--g10/openfile.c12
-rw-r--r--g10/revoke.c4
-rw-r--r--g10/sign.c6
7 files changed, 18 insertions, 16 deletions
diff --git a/g10/dearmor.c b/g10/dearmor.c
index 92239ccfd..839227a5b 100644
--- a/g10/dearmor.c
+++ b/g10/dearmor.c
@@ -63,7 +63,7 @@ dearmor_file( const char *fname )
push_armor_filter ( afx, inp );
- if( (rc = open_outfile (-1, fname, 0, 0, &out)) )
+ if( (rc = open_outfile (-1, fname, 0, 0, &out, 0)) )
goto leave;
while( (c = iobuf_get(inp)) != -1 )
@@ -109,7 +109,7 @@ enarmor_file( const char *fname )
}
- if( (rc = open_outfile (-1, fname, 1, 0, &out )) )
+ if( (rc = open_outfile (-1, fname, 1, 0, &out, 0 )) )
goto leave;
afx->what = 4;
diff --git a/g10/encrypt.c b/g10/encrypt.c
index c68d6d5d1..64952800b 100644
--- a/g10/encrypt.c
+++ b/g10/encrypt.c
@@ -276,7 +276,7 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
do_compress = 0;
}
- if ( rc || (rc = open_outfile (-1, filename, opt.armor? 1:0, 0, &out )))
+ if ( rc || (rc = open_outfile (-1, filename, opt.armor? 1:0, 0, &out, 0 )))
{
iobuf_cancel (inp);
xfree (cfx.dek);
@@ -574,7 +574,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
if (opt.textmode)
iobuf_push_filter (inp, text_filter, &tfx);
- rc = open_outfile (outputfd, filename, opt.armor? 1:0, 0, &out);
+ rc = open_outfile (outputfd, filename, opt.armor? 1:0, 0, &out, 0);
if (rc)
goto leave;
diff --git a/g10/export.c b/g10/export.c
index 8f6371b30..b194a2aed 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -352,7 +352,7 @@ do_export (ctrl_t ctrl, strlist_t users, int secret, unsigned int options,
memset( &zfx, 0, sizeof zfx);
- rc = open_outfile (-1, NULL, 0, !!secret, &out );
+ rc = open_outfile (-1, NULL, 0, !!secret, &out, 0 );
if (rc)
return rc;
diff --git a/g10/main.h b/g10/main.h
index 87417ee37..5862cdf27 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -324,7 +324,7 @@ int overwrite_filep( const char *fname );
char *make_outfile_name( const char *iname );
char *ask_outfile_name( const char *name, size_t namelen );
int open_outfile (int inp_fd, const char *iname, int mode,
- int restrictedperm, iobuf_t *a);
+ int restrictedperm, iobuf_t *a, int no_outfile);
char *get_matching_datafile (const char *sigfilename);
iobuf_t open_sigfile (const char *sigfilename, progress_filter_context_t *pfx);
void try_make_homedir( const char *fname );
diff --git a/g10/openfile.c b/g10/openfile.c
index 78f4dbbcb..03b114d58 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -174,13 +174,15 @@ ask_outfile_name( const char *name, size_t namelen )
* If INP_FD is not -1 the function simply creates an IOBUF for that
* file descriptor and ignore INAME and MODE. Note that INP_FD won't
* be closed if the returned IOBUF is closed. With RESTRICTEDPERM a
- * file will be created with mode 700 if possible.
+ * file will be created with mode 700 if possible. If NO_OUTFILE is
+ * true, don't use the outfile option even if it is set.
*/
int
open_outfile (int inp_fd, const char *iname, int mode, int restrictedperm,
- iobuf_t *a)
+ iobuf_t *a, int no_outfile)
{
int rc = 0;
+ const char outfile = no_outfile ? NULL : opt.outfile;
*a = NULL;
if (inp_fd != -1)
@@ -200,7 +202,7 @@ open_outfile (int inp_fd, const char *iname, int mode, int restrictedperm,
log_info (_("writing to '%s'\n"), xname);
}
}
- else if (iobuf_is_pipe_filename (iname) && !opt.outfile)
+ else if (iobuf_is_pipe_filename (iname) && !outfile)
{
*a = iobuf_create (NULL, 0);
if ( !*a )
@@ -218,8 +220,8 @@ open_outfile (int inp_fd, const char *iname, int mode, int restrictedperm,
if (opt.dry_run)
name = NAME_OF_DEV_NULL;
- else if (opt.outfile)
- name = opt.outfile;
+ else if (outfile)
+ name = outfile;
else
{
#ifdef USE_ONLY_8DOT3
diff --git a/g10/revoke.c b/g10/revoke.c
index 1dea6ae12..db3c49562 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -334,7 +334,7 @@ gen_desig_revoke (ctrl_t ctrl, const char *uname, strlist_t locusr)
if( !opt.armor )
tty_printf(_("ASCII armored output forced.\n"));
- if( (rc = open_outfile (-1, NULL, 0, 1, &out )) )
+ if( (rc = open_outfile (-1, NULL, 0, 1, &out, 0 )) )
goto leave;
afx->what = 1;
@@ -461,7 +461,7 @@ create_revocation (ctrl_t ctrl,
afx = new_armor_context ();
- if ((rc = open_outfile (-1, filename, suffix, 1, &out)))
+ if ((rc = open_outfile (-1, filename, suffix, 1, &out, !!filename)))
goto leave;
if (leadintext )
diff --git a/g10/sign.c b/g10/sign.c
index 4cf0cd39a..0e379bcc2 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -889,7 +889,7 @@ sign_file (ctrl_t ctrl, strlist_t filenames, int detached, strlist_t locusr,
log_info(_("writing to '%s'\n"), outfile );
}
else if( (rc = open_outfile (-1, fname,
- opt.armor? 1: detached? 2:0, 0, &out)))
+ opt.armor? 1: detached? 2:0, 0, &out, 0)))
goto leave;
/* prepare to calculate the MD over the input */
@@ -1191,7 +1191,7 @@ clearsign_file (ctrl_t ctrl,
else if( opt.verbose )
log_info(_("writing to '%s'\n"), outfile );
}
- else if ((rc = open_outfile (-1, fname, 1, 0, &out)))
+ else if ((rc = open_outfile (-1, fname, 1, 0, &out, 0)))
goto leave;
iobuf_writestr(out, "-----BEGIN PGP SIGNED MESSAGE-----" LF );
@@ -1340,7 +1340,7 @@ sign_symencrypt_file (ctrl_t ctrl, const char *fname, strlist_t locusr)
cfx.dek->use_mdc = use_mdc (NULL, cfx.dek->algo);
/* now create the outfile */
- rc = open_outfile (-1, fname, opt.armor? 1:0, 0, &out);
+ rc = open_outfile (-1, fname, opt.armor? 1:0, 0, &out, 0);
if (rc)
goto leave;