2010-06-07 15:33:02 +02:00
|
|
|
|
/* gpgtar-extract.c - Extract from a TAR archive
|
2022-01-09 18:34:04 +01:00
|
|
|
|
* Copyright (C) 2016-2017, 2019-2022 g10 Code GmbH
|
|
|
|
|
* Copyright (C) 2010, 2012, 2013 Werner Koch
|
2010-06-07 15:33:02 +02:00
|
|
|
|
* Copyright (C) 2010 Free Software Foundation, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2022-01-09 18:34:04 +01:00
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2010-06-07 15:33:02 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2017-03-07 12:21:23 +01:00
|
|
|
|
#include "../common/i18n.h"
|
2022-03-21 13:06:00 +01:00
|
|
|
|
#include <gpg-error.h>
|
|
|
|
|
#include "../common/exechelp.h"
|
2010-06-07 15:33:02 +02:00
|
|
|
|
#include "../common/sysutils.h"
|
2016-05-24 15:54:48 +02:00
|
|
|
|
#include "../common/ccparray.h"
|
2010-06-07 15:33:02 +02:00
|
|
|
|
#include "gpgtar.h"
|
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
static gpg_error_t
|
2023-03-15 11:18:29 +01:00
|
|
|
|
check_suspicious_name (const char *name, tarinfo_t info)
|
2022-01-09 18:34:04 +01:00
|
|
|
|
{
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
n = strlen (name);
|
|
|
|
|
#ifdef HAVE_DOSISH_SYSTEM
|
|
|
|
|
if (strchr (name, '\\'))
|
|
|
|
|
{
|
|
|
|
|
log_error ("filename '%s' contains a backslash - "
|
|
|
|
|
"can't extract on this system\n", name);
|
2023-03-15 11:18:29 +01:00
|
|
|
|
info->skipped_badname++;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
return gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_DOSISH_SYSTEM*/
|
|
|
|
|
|
|
|
|
|
if (!n
|
|
|
|
|
|| strstr (name, "//")
|
|
|
|
|
|| strstr (name, "/../")
|
|
|
|
|
|| !strncmp (name, "../", 3)
|
|
|
|
|
|| (n >= 3 && !strcmp (name+n-3, "/.." )))
|
|
|
|
|
{
|
|
|
|
|
log_error ("filename '%s' has suspicious parts - not extracting\n",
|
|
|
|
|
name);
|
2023-03-15 11:18:29 +01:00
|
|
|
|
info->skipped_suspicious++;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
return gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
extract_regular (estream_t stream, const char *dirname,
|
2022-01-09 18:34:04 +01:00
|
|
|
|
tarinfo_t info, tar_header_t hdr, strlist_t exthdr)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
size_t n, nbytes, nwritten;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
char *fname_buffer = NULL;
|
|
|
|
|
const char *fname;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
estream_t outfp = NULL;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
strlist_t sl;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
fname = hdr->name;
|
|
|
|
|
for (sl = exthdr; sl; sl = sl->next)
|
|
|
|
|
if (sl->flags == 1)
|
|
|
|
|
fname = sl->d;
|
|
|
|
|
|
2023-03-15 11:18:29 +01:00
|
|
|
|
err = check_suspicious_name (fname, info);
|
2022-01-09 18:34:04 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
fname_buffer = strconcat (dirname, "/", fname, NULL);
|
|
|
|
|
if (!fname_buffer)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("error creating filename: %s\n", gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2022-01-09 18:34:04 +01:00
|
|
|
|
fname = fname_buffer;
|
|
|
|
|
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2015-11-26 17:05:12 +01:00
|
|
|
|
if (opt.dry_run)
|
2022-03-04 14:54:17 +01:00
|
|
|
|
outfp = es_fopen ("/dev/null", "wb");
|
2015-11-26 17:05:12 +01:00
|
|
|
|
else
|
2022-03-04 14:54:17 +01:00
|
|
|
|
outfp = es_fopen (fname, "wb,sysopen");
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (!outfp)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (n=0; n < hdr->nrecords;)
|
|
|
|
|
{
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
info->nblocks++;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
n++;
|
2015-03-17 10:48:09 +01:00
|
|
|
|
if (n < hdr->nrecords || (hdr->size && !(hdr->size % RECORDSIZE)))
|
|
|
|
|
nbytes = RECORDSIZE;
|
|
|
|
|
else
|
|
|
|
|
nbytes = (hdr->size % RECORDSIZE);
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
nwritten = es_fwrite (record, 1, nbytes, outfp);
|
|
|
|
|
if (nwritten != nbytes)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error writing '%s': %s\n", fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Fixme: Set permissions etc. */
|
|
|
|
|
|
|
|
|
|
leave:
|
2023-03-15 11:18:29 +01:00
|
|
|
|
if (!err)
|
|
|
|
|
{
|
|
|
|
|
if (opt.verbose)
|
|
|
|
|
log_info ("extracted '%s'\n", fname);
|
|
|
|
|
info->nextracted++;
|
|
|
|
|
}
|
2010-06-07 15:33:02 +02:00
|
|
|
|
es_fclose (outfp);
|
|
|
|
|
if (err && fname && outfp)
|
|
|
|
|
{
|
|
|
|
|
if (gnupg_remove (fname))
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error removing incomplete file '%s': %s\n",
|
2010-06-07 15:33:02 +02:00
|
|
|
|
fname, gpg_strerror (gpg_error_from_syserror ()));
|
|
|
|
|
}
|
2022-01-09 18:34:04 +01:00
|
|
|
|
xfree (fname_buffer);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
2023-03-15 11:18:29 +01:00
|
|
|
|
extract_directory (const char *dirname, tarinfo_t info,
|
|
|
|
|
tar_header_t hdr, strlist_t exthdr)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
const char *name;
|
|
|
|
|
char *fname = NULL;
|
|
|
|
|
strlist_t sl;
|
|
|
|
|
|
|
|
|
|
name = hdr->name;
|
|
|
|
|
for (sl = exthdr; sl; sl = sl->next)
|
|
|
|
|
if (sl->flags == 1)
|
|
|
|
|
name = sl->d;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2023-03-15 11:18:29 +01:00
|
|
|
|
err = check_suspicious_name (name, info);
|
2022-01-09 18:34:04 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
fname = strconcat (dirname, "/", name, NULL);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (!fname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("error creating filename: %s\n", gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2022-01-09 18:34:04 +01:00
|
|
|
|
/* Remove a possible trailing slash. */
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (fname[strlen (fname)-1] == '/')
|
|
|
|
|
fname[strlen (fname)-1] = 0;
|
|
|
|
|
|
2015-11-26 17:05:12 +01:00
|
|
|
|
if (! opt.dry_run && gnupg_mkdir (fname, "-rwx------"))
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2016-10-04 12:44:14 +02:00
|
|
|
|
if (gpg_err_code (err) == GPG_ERR_EEXIST)
|
|
|
|
|
{
|
|
|
|
|
/* Ignore existing directories while extracting. */
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (gpg_err_code (err) == GPG_ERR_ENOENT)
|
|
|
|
|
{
|
|
|
|
|
/* Try to create the directory with parents but keep the
|
|
|
|
|
original error code in case of a failure. */
|
|
|
|
|
int rc = 0;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
char *p;
|
|
|
|
|
size_t prefixlen;
|
|
|
|
|
|
|
|
|
|
/* (PREFIXLEN is the length of the new directory we use to
|
|
|
|
|
* extract the tarball.) */
|
|
|
|
|
prefixlen = strlen (dirname) + 1;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
for (p = fname+prefixlen; (p = strchr (p, '/')); p++)
|
|
|
|
|
{
|
|
|
|
|
*p = 0;
|
|
|
|
|
rc = gnupg_mkdir (fname, "-rwx------");
|
2023-01-26 11:54:44 +01:00
|
|
|
|
if (gpg_err_code (rc) == GPG_ERR_EEXIST)
|
|
|
|
|
rc = 0;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
*p = '/';
|
|
|
|
|
if (rc)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!rc && !gnupg_mkdir (fname, "-rwx------"))
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
if (err)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error creating directory '%s': %s\n",
|
2010-07-16 15:19:45 +02:00
|
|
|
|
fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leave:
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (!err && opt.verbose)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("created '%s/'\n", fname);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
xfree (fname);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
2019-03-06 17:46:40 +01:00
|
|
|
|
extract (estream_t stream, const char *dirname, tarinfo_t info,
|
2022-01-09 18:34:04 +01:00
|
|
|
|
tar_header_t hdr, strlist_t exthdr)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
if (hdr->typeflag == TF_REGULAR || hdr->typeflag == TF_UNKNOWN)
|
2022-01-09 18:34:04 +01:00
|
|
|
|
err = extract_regular (stream, dirname, info, hdr, exthdr);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
else if (hdr->typeflag == TF_DIRECTORY)
|
2023-03-15 11:18:29 +01:00
|
|
|
|
err = extract_directory (dirname, info, hdr, exthdr);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("unsupported file type %d for '%s' - skipped\n",
|
2010-07-16 15:19:45 +02:00
|
|
|
|
(int)hdr->typeflag, hdr->name);
|
2023-03-15 11:18:29 +01:00
|
|
|
|
if (hdr->typeflag == TF_SYMLINK)
|
|
|
|
|
info->skipped_symlinks++;
|
|
|
|
|
else if (hdr->typeflag == TF_HARDLINK)
|
|
|
|
|
info->skipped_hardlinks++;
|
|
|
|
|
else
|
|
|
|
|
info->skipped_other++;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
for (err = 0, n=0; !err && n < hdr->nrecords; n++)
|
2019-03-06 17:46:40 +01:00
|
|
|
|
{
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (!err)
|
|
|
|
|
info->nblocks++;
|
|
|
|
|
}
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a new directory to be used for extracting the tarball.
|
|
|
|
|
Returns the name of the directory which must be freed by the
|
|
|
|
|
caller. In case of an error a diagnostic is printed and NULL
|
|
|
|
|
returned. */
|
|
|
|
|
static char *
|
|
|
|
|
create_directory (const char *dirprefix)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err = 0;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
char *prefix_buffer = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
char *dirname = NULL;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
size_t n;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
int idx;
|
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
/* Remove common suffixes. */
|
|
|
|
|
n = strlen (dirprefix);
|
2013-11-18 14:09:47 +01:00
|
|
|
|
if (n > 4 && (!compare_filenames (dirprefix + n - 4, EXTSEP_S GPGEXT_GPG)
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pgp")
|
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "asc")
|
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pem")
|
2010-08-26 10:47:42 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7m")
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7e")))
|
|
|
|
|
{
|
|
|
|
|
prefix_buffer = xtrystrdup (dirprefix);
|
|
|
|
|
if (!prefix_buffer)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
prefix_buffer[n-4] = 0;
|
|
|
|
|
dirprefix = prefix_buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
for (idx=1; idx < 5000; idx++)
|
|
|
|
|
{
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
dirname = xtryasprintf ("%s_%d_", dirprefix, idx);
|
|
|
|
|
if (!dirname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
if (!gnupg_mkdir (dirname, "-rwx------"))
|
2010-07-16 15:19:45 +02:00
|
|
|
|
goto leave; /* Ready. */
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (errno != EEXIST && errno != ENOTDIR)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-16 15:19:45 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_LIMIT_REACHED);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error creating an extract directory: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
dirname = NULL;
|
|
|
|
|
}
|
2010-07-16 15:19:45 +02:00
|
|
|
|
xfree (prefix_buffer);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
return dirname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-25 13:39:50 +01:00
|
|
|
|
gpg_error_t
|
2015-11-24 18:39:30 +01:00
|
|
|
|
gpgtar_extract (const char *filename, int decrypt)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
2022-03-21 13:06:00 +01:00
|
|
|
|
estream_t stream = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
tar_header_t header = NULL;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
strlist_t extheader = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
const char *dirprefix = NULL;
|
|
|
|
|
char *dirname = NULL;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
struct tarinfo_s tarinfo_buffer;
|
|
|
|
|
tarinfo_t tarinfo = &tarinfo_buffer;
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
gnupg_process_t proc;
|
2022-03-22 10:19:55 +01:00
|
|
|
|
char *logfilename = NULL;
|
2023-03-15 11:18:29 +01:00
|
|
|
|
unsigned long long notextracted;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
|
|
|
|
|
memset (&tarinfo_buffer, 0, sizeof tarinfo_buffer);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
2022-03-22 10:19:55 +01:00
|
|
|
|
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);
|
|
|
|
|
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (decrypt)
|
|
|
|
|
{
|
2015-11-30 16:21:22 +01:00
|
|
|
|
strlist_t arg;
|
2016-05-24 15:54:48 +02:00
|
|
|
|
ccparray_t ccp;
|
2023-06-26 03:17:23 +02:00
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
HANDLE except[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE };
|
|
|
|
|
#else
|
2023-01-18 10:42:53 +01:00
|
|
|
|
int except[2] = { -1, -1 };
|
2023-06-26 03:17:23 +02:00
|
|
|
|
#endif
|
2015-11-30 16:21:22 +01:00
|
|
|
|
const char **argv;
|
|
|
|
|
|
2016-05-24 15:54:48 +02:00
|
|
|
|
ccparray_init (&ccp, 0);
|
2022-03-21 13:06:00 +01:00
|
|
|
|
if (opt.batch)
|
|
|
|
|
ccparray_put (&ccp, "--batch");
|
|
|
|
|
if (opt.require_compliance)
|
|
|
|
|
ccparray_put (&ccp, "--require-compliance");
|
gpg,sm,tools: Use string for option --*-fd.
* g10/gpg.c (opts): Use string for oLoggerFD, oOverrideSessionKeyFD,
oStatusFD, oAttributeFD, oCommandFD, and oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* g10/gpgv.c (opts): Use string for oLoggerFD, and oStatusFD.
(main): Use translate_sys2libc_fdstr.
* sm/gpgsm.c (opts): Use string for oLoggerFD, oStatusFD, and
oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-auth.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
tools/gpg-card.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-pair-tool.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-wks-client.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgconf.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar-create.c (gpgtar_create): Fix for opt.status_fd.
* tools/gpgtar-extract.c (gpgtar_extract): Fix for opt.status_fd.
* tools/gpgtar-list.c (gpgtar_list): Fix for opt.status_fd.
* tools/gpgtar.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar.h (opts): Use string for oStatusFD.
--
GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-06-23 06:10:19 +02:00
|
|
|
|
if (opt.status_fd)
|
2022-03-21 13:06:00 +01:00
|
|
|
|
{
|
2022-03-22 10:19:55 +01:00
|
|
|
|
static char tmpbuf[40];
|
gpg,sm,tools: Use string for option --*-fd.
* g10/gpg.c (opts): Use string for oLoggerFD, oOverrideSessionKeyFD,
oStatusFD, oAttributeFD, oCommandFD, and oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* g10/gpgv.c (opts): Use string for oLoggerFD, and oStatusFD.
(main): Use translate_sys2libc_fdstr.
* sm/gpgsm.c (opts): Use string for oLoggerFD, oStatusFD, and
oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-auth.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
tools/gpg-card.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-pair-tool.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-wks-client.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgconf.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar-create.c (gpgtar_create): Fix for opt.status_fd.
* tools/gpgtar-extract.c (gpgtar_extract): Fix for opt.status_fd.
* tools/gpgtar-list.c (gpgtar_list): Fix for opt.status_fd.
* tools/gpgtar.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar.h (opts): Use string for oStatusFD.
--
GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-06-23 06:10:19 +02:00
|
|
|
|
es_syshd_t hd;
|
2016-05-24 15:54:48 +02:00
|
|
|
|
|
gpg,sm,tools: Use string for option --*-fd.
* g10/gpg.c (opts): Use string for oLoggerFD, oOverrideSessionKeyFD,
oStatusFD, oAttributeFD, oCommandFD, and oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* g10/gpgv.c (opts): Use string for oLoggerFD, and oStatusFD.
(main): Use translate_sys2libc_fdstr.
* sm/gpgsm.c (opts): Use string for oLoggerFD, oStatusFD, and
oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-auth.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
tools/gpg-card.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-pair-tool.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-wks-client.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgconf.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar-create.c (gpgtar_create): Fix for opt.status_fd.
* tools/gpgtar-extract.c (gpgtar_extract): Fix for opt.status_fd.
* tools/gpgtar-list.c (gpgtar_list): Fix for opt.status_fd.
* tools/gpgtar.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar.h (opts): Use string for oStatusFD.
--
GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-06-23 06:10:19 +02:00
|
|
|
|
snprintf (tmpbuf, sizeof tmpbuf, "--status-fd=%s", opt.status_fd);
|
2022-03-21 13:06:00 +01:00
|
|
|
|
ccparray_put (&ccp, tmpbuf);
|
gpg,sm,tools: Use string for option --*-fd.
* g10/gpg.c (opts): Use string for oLoggerFD, oOverrideSessionKeyFD,
oStatusFD, oAttributeFD, oCommandFD, and oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* g10/gpgv.c (opts): Use string for oLoggerFD, and oStatusFD.
(main): Use translate_sys2libc_fdstr.
* sm/gpgsm.c (opts): Use string for oLoggerFD, oStatusFD, and
oPassphraseFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-auth.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
tools/gpg-card.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-pair-tool.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpg-wks-client.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgconf.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar-create.c (gpgtar_create): Fix for opt.status_fd.
* tools/gpgtar-extract.c (gpgtar_extract): Fix for opt.status_fd.
* tools/gpgtar-list.c (gpgtar_list): Fix for opt.status_fd.
* tools/gpgtar.c (opts): Use string for oStatusFD.
(main): Use translate_sys2libc_fdstr.
* tools/gpgtar.h (opts): Use string for oStatusFD.
--
GnuPG-bug-id: 6551
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-06-23 06:10:19 +02:00
|
|
|
|
es_syshd (opt.status_stream, &hd);
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
|
|
|
except[0] = hd.u.handle;
|
|
|
|
|
#else
|
|
|
|
|
except[0] = hd.u.fd;
|
|
|
|
|
#endif
|
2022-03-21 13:06:00 +01:00
|
|
|
|
}
|
2022-03-22 10:19:55 +01:00
|
|
|
|
if (opt.with_log)
|
|
|
|
|
{
|
|
|
|
|
ccparray_put (&ccp, "--log-file");
|
|
|
|
|
logfilename = xstrconcat (dirname, ".log", NULL);
|
|
|
|
|
ccparray_put (&ccp, logfilename);
|
|
|
|
|
}
|
2022-03-21 13:06:00 +01:00
|
|
|
|
ccparray_put (&ccp, "--output");
|
|
|
|
|
ccparray_put (&ccp, "-");
|
2016-05-24 15:54:48 +02:00
|
|
|
|
ccparray_put (&ccp, "--decrypt");
|
|
|
|
|
for (arg = opt.gpg_arguments; arg; arg = arg->next)
|
|
|
|
|
ccparray_put (&ccp, arg->d);
|
2022-03-21 13:06:00 +01:00
|
|
|
|
if (filename)
|
|
|
|
|
{
|
|
|
|
|
ccparray_put (&ccp, "--");
|
|
|
|
|
ccparray_put (&ccp, filename);
|
|
|
|
|
}
|
2016-05-24 15:54:48 +02:00
|
|
|
|
|
|
|
|
|
ccparray_put (&ccp, NULL);
|
|
|
|
|
argv = ccparray_get (&ccp, NULL);
|
|
|
|
|
if (!argv)
|
2015-11-30 16:21:22 +01:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
err = gnupg_process_spawn (opt.gpg_program, argv,
|
|
|
|
|
((filename ? 0 : GNUPG_PROCESS_STDIN_KEEP)
|
|
|
|
|
| GNUPG_PROCESS_STDOUT_PIPE),
|
|
|
|
|
gnupg_spawn_helper, except, &proc);
|
2015-11-30 16:21:22 +01:00
|
|
|
|
xfree (argv);
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
gnupg_process_get_streams (proc, 0, NULL, &stream, NULL);
|
2022-03-21 13:06:00 +01:00
|
|
|
|
es_set_binary (stream);
|
|
|
|
|
}
|
|
|
|
|
else if (filename)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp (filename, "-"))
|
|
|
|
|
stream = es_stdin;
|
|
|
|
|
else
|
|
|
|
|
stream = es_fopen (filename, "rb,sysopen");
|
|
|
|
|
if (!stream)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("error opening '%s': %s\n", filename, gpg_strerror (err));
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
if (stream == es_stdin)
|
|
|
|
|
es_set_binary (es_stdin);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stream = es_stdin;
|
|
|
|
|
es_set_binary (es_stdin);
|
2015-11-24 18:39:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-21 13:06:00 +01:00
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2022-01-09 18:34:04 +01:00
|
|
|
|
err = gpgtar_read_header (stream, tarinfo, &header, &extheader);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
if (err || header == NULL)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
err = extract (stream, dirname, tarinfo, header, extheader);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
if (err)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
free_strlist (extheader);
|
|
|
|
|
extheader = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
xfree (header);
|
|
|
|
|
header = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
if (proc)
|
2022-03-21 13:06:00 +01:00
|
|
|
|
{
|
|
|
|
|
err = es_fclose (stream);
|
|
|
|
|
stream = NULL;
|
|
|
|
|
if (err)
|
|
|
|
|
log_error ("error closing pipe: %s\n", gpg_strerror (err));
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
|
|
|
|
|
err = gnupg_process_wait (proc, 1);
|
|
|
|
|
if (!err)
|
2022-03-21 13:06:00 +01:00
|
|
|
|
{
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
int exitcode;
|
|
|
|
|
|
|
|
|
|
gnupg_process_ctl (proc, GNUPG_PROCESS_GET_EXIT_ID, &exitcode);
|
|
|
|
|
if (exitcode)
|
2022-03-21 13:06:00 +01:00
|
|
|
|
log_error ("running %s failed (exitcode=%d): %s",
|
|
|
|
|
opt.gpg_program, exitcode, gpg_strerror (err));
|
|
|
|
|
}
|
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove.
(check_syscall_func, pre_syscall, post_syscall) : New.
(do_create_socketpair, posix_open_null, call_spawn_cb): New.
(my_exec, spawn_detached, gnupg_spawn_helper): New.
(gnupg_process_spawn, process_kill, gnupg_process_terminate): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_release): New.
(gnupg_process_wait_list): New.
* common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600.
(check_syscall_func, pre_syscall, post_syscall): New.
(gnupg_spawn_process): Remove.
(check_windows_version): New.
(spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New.
(gnupg_process_get_fds, gnupg_process_get_streams): New.
(process_kill, process_vctl, gnupg_process_ctl): New.
(gnupg_process_wait, gnupg_process_terminate): New.
(gnupg_process_release, gnupg_process_wait_list): New.
* common/exechelp.h: Re-write for new API.
* common/exectool.c (gnupg_exec_tool_stream): Follow the change.
* common/asshelp.c (start_new_service): Likewise.
* agent/genkey.c (do_check_passphrase_pattern): Likewise.
* dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC.
(destroy_wrapper): Follow the change of API.
(read_log_data): Follow the change of API, use printable_pid.
(ldap_reaper_thread, ldap_wrapper_release_context): Likewise.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise.
* g10/photoid.c (run_with_pipe): Follow the change of API.
(show_photo): Likewise.
* g13/be-encfs.c (run_umount_helper): Likewise.
(run_encfs_tool): Likewise.
* g13/g13.c: Add including ./common/exechelp.h.
* g13/mount.c: Likewise.
* g13/runner.c: Follow the change of API.
* g13/runner.h: Follow the change of API.
* scd/app.c (setup_env): New.
(report_change): Follow the change of API.
* tests/gpgscm/ffi.c (proc_object_finalize): New.
(proc_object_to_string): New.
(proc_wrap, proc_unwrap): New.
(do_spawn_process): Remove.
(do_process_spawn): New.
(setup_std_fds): New.
(do_spawn_process_fd): Remove.
(do_process_spawn_fd): New.
(do_wait_process): Remove.
(do_process_wait): New.
(do_wait_processes): Remove.
* tests/gpgscm/t-child.scm: Follow the change of API.
* tests/gpgscm/tests.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/tpm2dtests/defs.scm: Likewise.
* tools/gpg-card.c: Likewise.
* tools/gpgconf-comp.c: Likewise.
* tools/gpgconf.c: Likewise.
* tools/gpgtar-create.c: Likewise.
* tools/gpgtar-extract.c: Likewise.
* tools/gpgtar-list.c: Likewise.
--
GnuPG-bug-id: 6275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-11 12:18:21 +02:00
|
|
|
|
gnupg_process_release (proc);
|
|
|
|
|
proc = NULL;
|
2022-03-21 13:06:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
leave:
|
2023-03-15 11:18:29 +01:00
|
|
|
|
notextracted = tarinfo->skipped_badname;
|
|
|
|
|
notextracted += tarinfo->skipped_suspicious;
|
|
|
|
|
notextracted += tarinfo->skipped_symlinks;
|
|
|
|
|
notextracted += tarinfo->skipped_hardlinks;
|
|
|
|
|
notextracted += tarinfo->skipped_other;
|
|
|
|
|
if (opt.status_stream)
|
|
|
|
|
es_fprintf (opt.status_stream, "[GNUPG:] GPGTAR_EXTRACT"
|
|
|
|
|
" %llu %llu %lu %lu %lu %lu %lu\n",
|
|
|
|
|
tarinfo->nextracted,
|
|
|
|
|
notextracted,
|
|
|
|
|
tarinfo->skipped_badname,
|
|
|
|
|
tarinfo->skipped_suspicious,
|
|
|
|
|
tarinfo->skipped_symlinks,
|
|
|
|
|
tarinfo->skipped_hardlinks,
|
|
|
|
|
tarinfo->skipped_other);
|
|
|
|
|
if (notextracted && !opt.quiet)
|
|
|
|
|
{
|
|
|
|
|
log_info ("Number of files not extracted: %llu\n", notextracted);
|
|
|
|
|
if (tarinfo->skipped_badname)
|
|
|
|
|
log_info (" invalid name: %lu\n", tarinfo->skipped_badname);
|
|
|
|
|
if (tarinfo->skipped_suspicious)
|
|
|
|
|
log_info (" suspicious name: %lu\n", tarinfo->skipped_suspicious);
|
|
|
|
|
if (tarinfo->skipped_symlinks)
|
|
|
|
|
log_info (" symlink: %lu\n", tarinfo->skipped_symlinks);
|
|
|
|
|
if (tarinfo->skipped_hardlinks)
|
|
|
|
|
log_info (" hardlink: %lu\n", tarinfo->skipped_hardlinks);
|
|
|
|
|
if (tarinfo->skipped_other)
|
|
|
|
|
log_info (" other reason: %lu\n", tarinfo->skipped_other);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
free_strlist (extheader);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
xfree (header);
|
|
|
|
|
xfree (dirname);
|
2022-03-22 10:19:55 +01:00
|
|
|
|
xfree (logfilename);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (stream != es_stdin)
|
|
|
|
|
es_fclose (stream);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|