mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpgtar: New option --with-log
* tools/gpgtar.c: New option --with-log. * tools/gpgtar.h (opt): Add field with_log. * tools/gpgtar-extract.c (gpgtar_extract): Move directory string building up. Add option --log-file if needed. * tools/gpgtar-create.c (gpgtar_create): Make tmpbuf static becuase it is used outside of its scope. * tools/gpgtar-list.c (gpgtar_list): Ditto.
This commit is contained in:
parent
92c8ae720e
commit
ed53d41b4c
@ -2025,6 +2025,11 @@ This option is passed directly to @command{gpg}.
|
|||||||
Write special status strings to the file descriptor @var{n}.
|
Write special status strings to the file descriptor @var{n}.
|
||||||
See the file DETAILS in the documentation for a listing of them.
|
See the file DETAILS in the documentation for a listing of them.
|
||||||
|
|
||||||
|
@item --with-log
|
||||||
|
@opindex with-log
|
||||||
|
When extracting an encrypted tarball also write a log file with the
|
||||||
|
gpg output to a file named after the extraction directory with the
|
||||||
|
suffix ".log".
|
||||||
|
|
||||||
@item --set-filename @var{file}
|
@item --set-filename @var{file}
|
||||||
@opindex set-filename
|
@opindex set-filename
|
||||||
|
@ -1160,7 +1160,7 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
|
|||||||
ccparray_put (&ccp, "--require-compliance");
|
ccparray_put (&ccp, "--require-compliance");
|
||||||
if (opt.status_fd != -1)
|
if (opt.status_fd != -1)
|
||||||
{
|
{
|
||||||
char tmpbuf[40];
|
static char tmpbuf[40];
|
||||||
|
|
||||||
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
||||||
ccparray_put (&ccp, tmpbuf);
|
ccparray_put (&ccp, tmpbuf);
|
||||||
|
@ -325,9 +325,46 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
struct tarinfo_s tarinfo_buffer;
|
struct tarinfo_s tarinfo_buffer;
|
||||||
tarinfo_t tarinfo = &tarinfo_buffer;
|
tarinfo_t tarinfo = &tarinfo_buffer;
|
||||||
pid_t pid = (pid_t)(-1);
|
pid_t pid = (pid_t)(-1);
|
||||||
|
char *logfilename = NULL;
|
||||||
|
|
||||||
|
|
||||||
memset (&tarinfo_buffer, 0, sizeof tarinfo_buffer);
|
memset (&tarinfo_buffer, 0, sizeof tarinfo_buffer);
|
||||||
|
|
||||||
|
if (opt.directory)
|
||||||
|
dirname = xtrystrdup (opt.directory);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opt.filename)
|
||||||
|
{
|
||||||
|
dirprefix = strrchr (opt.filename, '/');
|
||||||
|
if (dirprefix)
|
||||||
|
dirprefix++;
|
||||||
|
else
|
||||||
|
dirprefix = opt.filename;
|
||||||
|
}
|
||||||
|
else if (filename)
|
||||||
|
{
|
||||||
|
dirprefix = strrchr (filename, '/');
|
||||||
|
if (dirprefix)
|
||||||
|
dirprefix++;
|
||||||
|
else
|
||||||
|
dirprefix = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dirprefix || !*dirprefix)
|
||||||
|
dirprefix = "GPGARCH";
|
||||||
|
|
||||||
|
dirname = create_directory (dirprefix);
|
||||||
|
if (!dirname)
|
||||||
|
{
|
||||||
|
err = gpg_error (GPG_ERR_GENERAL);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt.verbose)
|
||||||
|
log_info ("extracting to '%s/'\n", dirname);
|
||||||
|
|
||||||
if (decrypt)
|
if (decrypt)
|
||||||
{
|
{
|
||||||
strlist_t arg;
|
strlist_t arg;
|
||||||
@ -341,11 +378,17 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
ccparray_put (&ccp, "--require-compliance");
|
ccparray_put (&ccp, "--require-compliance");
|
||||||
if (opt.status_fd != -1)
|
if (opt.status_fd != -1)
|
||||||
{
|
{
|
||||||
char tmpbuf[40];
|
static char tmpbuf[40];
|
||||||
|
|
||||||
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
||||||
ccparray_put (&ccp, tmpbuf);
|
ccparray_put (&ccp, tmpbuf);
|
||||||
}
|
}
|
||||||
|
if (opt.with_log)
|
||||||
|
{
|
||||||
|
ccparray_put (&ccp, "--log-file");
|
||||||
|
logfilename = xstrconcat (dirname, ".log", NULL);
|
||||||
|
ccparray_put (&ccp, logfilename);
|
||||||
|
}
|
||||||
ccparray_put (&ccp, "--output");
|
ccparray_put (&ccp, "--output");
|
||||||
ccparray_put (&ccp, "-");
|
ccparray_put (&ccp, "-");
|
||||||
ccparray_put (&ccp, "--decrypt");
|
ccparray_put (&ccp, "--decrypt");
|
||||||
@ -396,41 +439,6 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (opt.directory)
|
|
||||||
dirname = xtrystrdup (opt.directory);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opt.filename)
|
|
||||||
{
|
|
||||||
dirprefix = strrchr (opt.filename, '/');
|
|
||||||
if (dirprefix)
|
|
||||||
dirprefix++;
|
|
||||||
else
|
|
||||||
dirprefix = opt.filename;
|
|
||||||
}
|
|
||||||
else if (filename)
|
|
||||||
{
|
|
||||||
dirprefix = strrchr (filename, '/');
|
|
||||||
if (dirprefix)
|
|
||||||
dirprefix++;
|
|
||||||
else
|
|
||||||
dirprefix = filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dirprefix || !*dirprefix)
|
|
||||||
dirprefix = "GPGARCH";
|
|
||||||
|
|
||||||
dirname = create_directory (dirprefix);
|
|
||||||
if (!dirname)
|
|
||||||
{
|
|
||||||
err = gpg_error (GPG_ERR_GENERAL);
|
|
||||||
goto leave;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt.verbose)
|
|
||||||
log_info ("extracting to '%s/'\n", dirname);
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
err = gpgtar_read_header (stream, tarinfo, &header, &extheader);
|
err = gpgtar_read_header (stream, tarinfo, &header, &extheader);
|
||||||
@ -470,6 +478,7 @@ gpgtar_extract (const char *filename, int decrypt)
|
|||||||
free_strlist (extheader);
|
free_strlist (extheader);
|
||||||
xfree (header);
|
xfree (header);
|
||||||
xfree (dirname);
|
xfree (dirname);
|
||||||
|
xfree (logfilename);
|
||||||
if (stream != es_stdin)
|
if (stream != es_stdin)
|
||||||
es_fclose (stream);
|
es_fclose (stream);
|
||||||
return err;
|
return err;
|
||||||
|
@ -477,7 +477,7 @@ gpgtar_list (const char *filename, int decrypt)
|
|||||||
ccparray_put (&ccp, "--require-compliance");
|
ccparray_put (&ccp, "--require-compliance");
|
||||||
if (opt.status_fd != -1)
|
if (opt.status_fd != -1)
|
||||||
{
|
{
|
||||||
char tmpbuf[40];
|
static char tmpbuf[40];
|
||||||
|
|
||||||
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%d", opt.status_fd);
|
||||||
ccparray_put (&ccp, tmpbuf);
|
ccparray_put (&ccp, tmpbuf);
|
||||||
|
@ -81,6 +81,7 @@ enum cmd_and_opt_values
|
|||||||
oAnswerNo,
|
oAnswerNo,
|
||||||
oStatusFD,
|
oStatusFD,
|
||||||
oRequireCompliance,
|
oRequireCompliance,
|
||||||
|
oWithLog,
|
||||||
|
|
||||||
/* Compatibility with gpg-zip. */
|
/* Compatibility with gpg-zip. */
|
||||||
oGpgArgs,
|
oGpgArgs,
|
||||||
@ -124,6 +125,7 @@ static gpgrt_opt_t opts[] = {
|
|||||||
ARGPARSE_s_n (oAnswerNo, "no", "@"),
|
ARGPARSE_s_n (oAnswerNo, "no", "@"),
|
||||||
ARGPARSE_s_i (oStatusFD, "status-fd", "@"),
|
ARGPARSE_s_i (oStatusFD, "status-fd", "@"),
|
||||||
ARGPARSE_s_n (oRequireCompliance, "require-compliance", "@"),
|
ARGPARSE_s_n (oRequireCompliance, "require-compliance", "@"),
|
||||||
|
ARGPARSE_s_n (oWithLog, "with-log", "@"),
|
||||||
|
|
||||||
ARGPARSE_group (302, N_("@\nTar options:\n ")),
|
ARGPARSE_group (302, N_("@\nTar options:\n ")),
|
||||||
|
|
||||||
@ -391,6 +393,7 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
|
|||||||
case oAnswerNo: opt.answer_no = 1; break;
|
case oAnswerNo: opt.answer_no = 1; break;
|
||||||
case oStatusFD: opt.status_fd = pargs->r.ret_int; break;
|
case oStatusFD: opt.status_fd = pargs->r.ret_int; break;
|
||||||
case oRequireCompliance: opt.require_compliance = 1; break;
|
case oRequireCompliance: opt.require_compliance = 1; break;
|
||||||
|
case oWithLog: opt.with_log = 1; break;
|
||||||
|
|
||||||
case oGpgArgs:;
|
case oGpgArgs:;
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ struct
|
|||||||
int answer_no;
|
int answer_no;
|
||||||
int status_fd;
|
int status_fd;
|
||||||
int require_compliance;
|
int require_compliance;
|
||||||
|
int with_log;
|
||||||
} opt;
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user