mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
tools/gpgtar: Handle '--gpg-args'.
* tools/gpgtar-create.c (gpgtar_create): Use given arguments. * tools/gpgtar-extract.c (gpgtar_extract): Likewise. * tools/gpgtar-list.c (gpgtar_list): Likewise. * tools/gpgtar.c (enum cmd_and_opt_values): New value. (opts): Add 'gpg-args'. (parse_arguments): Handle arguments. * tools/gpgtar.h (opt): Add field 'gpg_arguments'. * tests/openpgp/gpgtar.test: Simplify accordingly. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
1a045b1324
commit
69a8440f44
@ -25,24 +25,30 @@ TESTFILES="$plain_files $data_files"
|
||||
TESTDIR=gpgtar.d
|
||||
FILELIST="${TESTDIR}/filelist"
|
||||
GPG=../../g10/gpg2
|
||||
GPGARGS="--trust-model=always"
|
||||
|
||||
GPGTAR="../../tools/gpgtar"
|
||||
GPGZIP="sh ../../tools/gpg-zip --gpg-args --trust-model=always"
|
||||
GPGZIP="sh ../../tools/gpg-zip"
|
||||
|
||||
for TOOL in "$GPGTAR" "$GPGZIP"
|
||||
do
|
||||
rm -rf -- "${TESTDIR}"
|
||||
mkdir "${TESTDIR}"
|
||||
|
||||
$TOOL --gpg "$GPG" --encrypt --recipient "$usrname2" \
|
||||
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" \
|
||||
--encrypt --recipient "$usrname2" \
|
||||
--output "${TESTDIR}/test.tar.pgp" $TESTFILES
|
||||
|
||||
$TOOL --gpg "$GPG" --list-archive "${TESTDIR}/test.tar.pgp" >"$FILELIST"
|
||||
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" \
|
||||
--list-archive "${TESTDIR}/test.tar.pgp" \
|
||||
>"$FILELIST"
|
||||
for F in $TESTFILES
|
||||
do
|
||||
grep -qe "\\b${F}\\b" "$FILELIST"
|
||||
done
|
||||
|
||||
$TOOL --gpg "$GPG" --tar-args --directory="${TESTDIR}" \
|
||||
$TOOL --gpg "$GPG" --gpg-args "$GPGARGS" \
|
||||
--tar-args --directory="${TESTDIR}" \
|
||||
--decrypt "${TESTDIR}/test.tar.pgp"
|
||||
for F in $TESTFILES
|
||||
do
|
||||
|
@ -894,7 +894,7 @@ gpgtar_create (char **inpattern, int encrypt)
|
||||
|
||||
err = gpg_encrypt_stream (NULL,
|
||||
opt.gpg_program,
|
||||
NULL,
|
||||
opt.gpg_arguments,
|
||||
outstream,
|
||||
opt.recipients,
|
||||
cipher_stream);
|
||||
|
@ -303,7 +303,7 @@ gpgtar_extract (const char *filename, int decrypt)
|
||||
err = gpg_error_from_syserror ();
|
||||
goto leave;
|
||||
}
|
||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, NULL,
|
||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, opt.gpg_arguments,
|
||||
cipher_stream, stream);
|
||||
if (err)
|
||||
goto leave;
|
||||
|
@ -306,7 +306,7 @@ gpgtar_list (const char *filename, int decrypt)
|
||||
err = gpg_error_from_syserror ();
|
||||
goto leave;
|
||||
}
|
||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, NULL,
|
||||
err = gpg_decrypt_stream (NULL, opt.gpg_program, opt.gpg_arguments,
|
||||
cipher_stream, stream);
|
||||
if (err)
|
||||
goto leave;
|
||||
|
@ -75,6 +75,7 @@ enum cmd_and_opt_values
|
||||
oNull,
|
||||
|
||||
/* Compatibility with gpg-zip. */
|
||||
oGpgArgs,
|
||||
oTarArgs,
|
||||
};
|
||||
|
||||
@ -111,6 +112,7 @@ static ARGPARSE_OPTS opts[] = {
|
||||
N_("|FILE|get names to create from FILE")),
|
||||
ARGPARSE_s_n (oNull, "null", N_("-T reads null-terminated names")),
|
||||
|
||||
ARGPARSE_s_s (oGpgArgs, "gpg-args", "@"),
|
||||
ARGPARSE_s_s (oTarArgs, "tar-args", "@"),
|
||||
|
||||
ARGPARSE_end ()
|
||||
@ -340,6 +342,20 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
|
||||
case oOpenPGP: /* Dummy option for now. */ break;
|
||||
case oCMS: /* Dummy option for now. */ break;
|
||||
|
||||
case oGpgArgs:;
|
||||
strlist_t list;
|
||||
if (shell_parse_stringlist (pargs->r.ret_str, &list))
|
||||
log_error ("failed to parse gpg arguments '%s'\n",
|
||||
pargs->r.ret_str);
|
||||
else
|
||||
{
|
||||
if (opt.gpg_arguments)
|
||||
strlist_last (opt.gpg_arguments)->next = list;
|
||||
else
|
||||
opt.gpg_arguments = list;
|
||||
}
|
||||
break;
|
||||
|
||||
case oTarArgs:;
|
||||
int tar_argc;
|
||||
char **tar_argv;
|
||||
|
@ -30,6 +30,7 @@ struct
|
||||
unsigned int debug_level;
|
||||
int quiet;
|
||||
const char *gpg_program;
|
||||
strlist_t gpg_arguments;
|
||||
const char *outfile;
|
||||
strlist_t recipients;
|
||||
const char *user;
|
||||
|
Loading…
x
Reference in New Issue
Block a user