diff options
| author | Justus Winter <[email protected]> | 2015-11-30 17:39:00 +0000 |
|---|---|---|
| committer | Justus Winter <[email protected]> | 2015-12-04 11:52:40 +0000 |
| commit | 45c814f348c89acd8d21d0607ffcf68e5c5c399e (patch) | |
| tree | d1a22fe0ab0d9c5181d1b5cbae5b383cbeccdf0d /tools/gpgtar-create.c | |
| parent | tools/gpgtar: Use the new exectool helper. (diff) | |
| download | gnupg-45c814f348c89acd8d21d0607ffcf68e5c5c399e.tar.gz gnupg-45c814f348c89acd8d21d0607ffcf68e5c5c399e.zip | |
tools/gpgtar: Implement signing.
* tests/openpgp/gpgtar.test: Test signing.
* tools/gpgtar-create.c (gpgtar_create): Add 'sign' option, add the
appropriate gpg arguments to implement signing and selecting the local
user.
* tools/gpgtar.c (parse_options): We do handle '--local-user' now.
(main): Handle signing, encrypting, and doing both when creating an
archive.
* tools/gpgtar.h (gpgtar_create): Update prototype.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tools/gpgtar-create.c')
| -rw-r--r-- | tools/gpgtar-create.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c index 8975fc6ba..d5e3becf5 100644 --- a/tools/gpgtar-create.c +++ b/tools/gpgtar-create.c @@ -741,7 +741,7 @@ write_eof_mark (estream_t stream) INPATTERN is NULL take the pattern as null terminated strings from stdin. */ gpg_error_t -gpgtar_create (char **inpattern, int encrypt) +gpgtar_create (char **inpattern, int encrypt, int sign) { gpg_error_t err = 0; struct scanctrl_s scanctrl_buffer; @@ -865,7 +865,7 @@ gpgtar_create (char **inpattern, int encrypt) if (outstream == es_stdout) es_set_binary (es_stdout); - if (encrypt) + if (encrypt || sign) { cipher_stream = outstream; outstream = es_fopenmem (0, "rwb"); @@ -886,7 +886,7 @@ gpgtar_create (char **inpattern, int encrypt) if (err) goto leave; - if (encrypt) + if (encrypt || sign) { int i; strlist_t arg; @@ -898,7 +898,7 @@ gpgtar_create (char **inpattern, int encrypt) argv = xtrycalloc (strlist_length (opt.gpg_arguments) + 2 * strlist_length (opt.recipients) - + 2, + + 1 + !!encrypt + !!sign + 2 * !!opt.user, sizeof *argv); if (argv == NULL) { @@ -906,7 +906,15 @@ gpgtar_create (char **inpattern, int encrypt) goto leave; } i = 0; - argv[i++] = "--encrypt"; + if (encrypt) + argv[i++] = "--encrypt"; + if (sign) + argv[i++] = "--sign"; + if (opt.user) + { + argv[i++] = "--local-user"; + argv[i++] = opt.user; + } for (arg = opt.recipients; arg; arg = arg->next) { argv[i++] = "--recipient"; @@ -917,7 +925,7 @@ gpgtar_create (char **inpattern, int encrypt) argv[i++] = NULL; assert (i == strlist_length (opt.gpg_arguments) + 2 * strlist_length (opt.recipients) - + 2); + + 1 + !!encrypt + !!sign + 2 * !!opt.user); err = sh_exec_tool_stream (opt.gpg_program, argv, outstream, cipher_stream); |
