diff --git a/tests/openpgp/gpgtar.test b/tests/openpgp/gpgtar.test index f71a88381..124ba404c 100755 --- a/tests/openpgp/gpgtar.test +++ b/tests/openpgp/gpgtar.test @@ -24,6 +24,7 @@ TESTFILES="$plain_files $data_files" TESTDIR=gpgtar.d FILELIST="${TESTDIR}/filelist" +PPFILE="${TESTDIR}/passphrase" GPG=../../g10/gpg2 GPGARGS="$opt_always --no-permission-warning" @@ -46,6 +47,7 @@ do_test() rm -rf -- "${TESTDIR}" mkdir "${TESTDIR}" + echo frob >"$PPFILE" $TOOL --gpg "$GPG" --gpg-args "$GPGARGS" $CREATE_FLAGS \ --output "${TESTDIR}/test.tar.pgp" $TESTFILES @@ -69,6 +71,7 @@ do_test() } for TOOL in "$GPGTAR" "$GPGZIP" +#for TOOL in "$GPGZIP" do do_test "$TOOL" \ "--encrypt --recipient $usrname2" \ @@ -84,6 +87,11 @@ do "--sign --local-user $usrname3" \ "--list-archive" \ "--decrypt" + + do_test "$TOOL" \ + "--gpg-args --passphrase-file=$PPFILE --symmetric" \ + "--gpg-args --passphrase-file=$PPFILE --list-archive" \ + "--gpg-args --passphrase-file=$PPFILE --decrypt" done # Success! diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c index d5e3becf5..d8d1d54f1 100644 --- a/tools/gpgtar-create.c +++ b/tools/gpgtar-create.c @@ -896,9 +896,16 @@ gpgtar_create (char **inpattern, int encrypt, int sign) if (err) goto leave; + /* '--encrypt' may be combined with '--symmetric', but 'encrypt' + is set either way. Clear it if no recipients are specified. + XXX: Fix command handling. */ + if (opt.symmetric && opt.recipients == NULL) + encrypt = 0; + argv = xtrycalloc (strlist_length (opt.gpg_arguments) + 2 * strlist_length (opt.recipients) - + 1 + !!encrypt + !!sign + 2 * !!opt.user, + + 1 + !!encrypt + !!sign + 2 * !!opt.user + + !!opt.symmetric, sizeof *argv); if (argv == NULL) { @@ -915,6 +922,8 @@ gpgtar_create (char **inpattern, int encrypt, int sign) argv[i++] = "--local-user"; argv[i++] = opt.user; } + if (opt.symmetric) + argv[i++] = "--symmetric"; for (arg = opt.recipients; arg; arg = arg->next) { argv[i++] = "--recipient"; @@ -925,7 +934,8 @@ gpgtar_create (char **inpattern, int encrypt, int sign) argv[i++] = NULL; assert (i == strlist_length (opt.gpg_arguments) + 2 * strlist_length (opt.recipients) - + 1 + !!encrypt + !!sign + 2 * !!opt.user); + + 1 + !!encrypt + !!sign + 2 * !!opt.user + + !!opt.symmetric); err = sh_exec_tool_stream (opt.gpg_program, argv, outstream, cipher_stream); diff --git a/tools/gpgtar.c b/tools/gpgtar.c index 800165462..46d06bd48 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -322,7 +322,6 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts) break; case oSymmetric: - log_info ("note: ignoring option --symmetric\n"); set_cmd (&cmd, aEncrypt); opt.symmetric = 1; break;