2010-06-07 13:33:02 +00:00
|
|
|
|
/* gpgtar-list.c - List 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 13:33:02 +00: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 13:33:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2017-03-07 20:21:23 +09:00
|
|
|
|
#include "../common/i18n.h"
|
2022-03-21 13:06:00 +01:00
|
|
|
|
#include <gpg-error.h>
|
2010-06-07 13:33:02 +00:00
|
|
|
|
#include "gpgtar.h"
|
2022-03-21 13:06:00 +01:00
|
|
|
|
#include "../common/sysutils.h"
|
2016-05-24 15:54:48 +02:00
|
|
|
|
#include "../common/ccparray.h"
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned long long
|
|
|
|
|
parse_xoctal (const void *data, size_t length, const char *filename)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char *p = data;
|
|
|
|
|
unsigned long long value;
|
|
|
|
|
|
|
|
|
|
if (!length)
|
|
|
|
|
value = 0;
|
|
|
|
|
else if ( (*p & 0x80))
|
|
|
|
|
{
|
|
|
|
|
/* Binary format. */
|
|
|
|
|
value = (*p++ & 0x7f);
|
|
|
|
|
while (--length)
|
|
|
|
|
{
|
|
|
|
|
value <<= 8;
|
|
|
|
|
value |= *p++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Octal format */
|
|
|
|
|
value = 0;
|
|
|
|
|
/* Skip leading spaces and zeroes. */
|
|
|
|
|
for (; length && (*p == ' ' || *p == '0'); length--, p++)
|
|
|
|
|
;
|
|
|
|
|
for (; length && *p; length--, p++)
|
|
|
|
|
{
|
|
|
|
|
if (*p >= '0' && *p <= '7')
|
|
|
|
|
{
|
|
|
|
|
value <<= 3;
|
|
|
|
|
value += (*p - '0');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-14 09:38:46 +01:00
|
|
|
|
log_error ("%s: invalid octal number encountered - assuming 0\n",
|
2010-06-07 13:33:02 +00:00
|
|
|
|
filename);
|
|
|
|
|
value = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static tar_header_t
|
2019-03-06 17:46:40 +01:00
|
|
|
|
parse_header (const void *record, const char *filename, tarinfo_t info)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
const struct ustar_raw_header *raw = record;
|
|
|
|
|
size_t n, namelen, prefixlen;
|
|
|
|
|
tar_header_t header;
|
|
|
|
|
int use_prefix;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
int anyerror = 0;
|
|
|
|
|
|
|
|
|
|
info->headerblock = info->nblocks - 1;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
2015-12-14 09:38:46 +01:00
|
|
|
|
use_prefix = (!memcmp (raw->magic, "ustar", 5)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
&& (raw->magic[5] == ' ' || !raw->magic[5]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (namelen=0; namelen < sizeof raw->name && raw->name[namelen]; namelen++)
|
|
|
|
|
;
|
|
|
|
|
if (namelen == sizeof raw->name)
|
2019-03-06 17:46:40 +01:00
|
|
|
|
{
|
|
|
|
|
log_info ("%s: warning: name not terminated by a nul\n", filename);
|
|
|
|
|
anyerror = 1;
|
|
|
|
|
}
|
2010-06-07 13:33:02 +00:00
|
|
|
|
for (n=namelen+1; n < sizeof raw->name; n++)
|
|
|
|
|
if (raw->name[n])
|
|
|
|
|
{
|
|
|
|
|
log_info ("%s: warning: garbage after name\n", filename);
|
2019-03-06 17:46:40 +01:00
|
|
|
|
anyerror = 1;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (use_prefix && raw->prefix[0])
|
|
|
|
|
{
|
|
|
|
|
for (prefixlen=0; (prefixlen < sizeof raw->prefix
|
|
|
|
|
&& raw->prefix[prefixlen]); prefixlen++)
|
|
|
|
|
;
|
|
|
|
|
if (prefixlen == sizeof raw->prefix)
|
2019-03-06 17:46:40 +01:00
|
|
|
|
log_info ("%s: warning: prefix not terminated by a nul (block %llu)\n",
|
|
|
|
|
filename, info->headerblock);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
for (n=prefixlen+1; n < sizeof raw->prefix; n++)
|
|
|
|
|
if (raw->prefix[n])
|
|
|
|
|
{
|
|
|
|
|
log_info ("%s: warning: garbage after prefix\n", filename);
|
2019-03-06 17:46:40 +01:00
|
|
|
|
anyerror = 1;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
prefixlen = 0;
|
|
|
|
|
|
|
|
|
|
header = xtrycalloc (1, sizeof *header + prefixlen + 1 + namelen);
|
|
|
|
|
if (!header)
|
|
|
|
|
{
|
|
|
|
|
log_error ("%s: error allocating header: %s\n",
|
|
|
|
|
filename, gpg_strerror (gpg_error_from_syserror ()));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (prefixlen)
|
|
|
|
|
{
|
|
|
|
|
n = prefixlen;
|
|
|
|
|
memcpy (header->name, raw->prefix, n);
|
|
|
|
|
if (raw->prefix[n-1] != '/')
|
|
|
|
|
header->name[n++] = '/';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
n = 0;
|
|
|
|
|
memcpy (header->name+n, raw->name, namelen);
|
|
|
|
|
header->name[n+namelen] = 0;
|
2015-12-14 09:38:46 +01:00
|
|
|
|
|
2010-06-07 13:33:02 +00:00
|
|
|
|
header->mode = parse_xoctal (raw->mode, sizeof raw->mode, filename);
|
|
|
|
|
header->uid = parse_xoctal (raw->uid, sizeof raw->uid, filename);
|
|
|
|
|
header->gid = parse_xoctal (raw->gid, sizeof raw->gid, filename);
|
|
|
|
|
header->size = parse_xoctal (raw->size, sizeof raw->size, filename);
|
|
|
|
|
header->mtime = parse_xoctal (raw->mtime, sizeof raw->mtime, filename);
|
|
|
|
|
/* checksum = */
|
|
|
|
|
switch (raw->typeflag[0])
|
|
|
|
|
{
|
|
|
|
|
case '0': header->typeflag = TF_REGULAR; break;
|
|
|
|
|
case '1': header->typeflag = TF_HARDLINK; break;
|
|
|
|
|
case '2': header->typeflag = TF_SYMLINK; break;
|
|
|
|
|
case '3': header->typeflag = TF_CHARDEV; break;
|
|
|
|
|
case '4': header->typeflag = TF_BLOCKDEV; break;
|
|
|
|
|
case '5': header->typeflag = TF_DIRECTORY; break;
|
|
|
|
|
case '6': header->typeflag = TF_FIFO; break;
|
|
|
|
|
case '7': header->typeflag = TF_RESERVED; break;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
case 'g': header->typeflag = TF_GEXTHDR; break;
|
|
|
|
|
case 'x': header->typeflag = TF_EXTHDR; break;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
default: header->typeflag = TF_UNKNOWN; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compute the number of data records following this header. */
|
2022-01-09 18:34:04 +01:00
|
|
|
|
if (header->typeflag == TF_REGULAR
|
|
|
|
|
|| header->typeflag == TF_EXTHDR
|
|
|
|
|
|| header->typeflag == TF_UNKNOWN)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
header->nrecords = (header->size + RECORDSIZE-1)/RECORDSIZE;
|
|
|
|
|
else
|
|
|
|
|
header->nrecords = 0;
|
2015-12-14 09:38:46 +01:00
|
|
|
|
|
2019-03-06 17:46:40 +01:00
|
|
|
|
if (anyerror)
|
|
|
|
|
{
|
|
|
|
|
log_info ("%s: header block %llu is corrupt"
|
|
|
|
|
" (size=%llu type=%d nrec=%llu)\n",
|
|
|
|
|
filename, info->headerblock,
|
|
|
|
|
header->size, header->typeflag, header->nrecords);
|
|
|
|
|
/* log_printhex (record, RECORDSIZE, " "); */
|
|
|
|
|
}
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-12 18:09:23 -04:00
|
|
|
|
/* Parse the extended header. This function may modify BUFFER. */
|
2022-01-09 18:34:04 +01:00
|
|
|
|
static gpg_error_t
|
|
|
|
|
parse_extended_header (const char *fname,
|
|
|
|
|
char *buffer, size_t buflen, strlist_t *r_exthdr)
|
|
|
|
|
{
|
|
|
|
|
unsigned int reclen;
|
|
|
|
|
unsigned char *p, *record;
|
|
|
|
|
strlist_t sl;
|
|
|
|
|
|
|
|
|
|
while (buflen)
|
|
|
|
|
{
|
|
|
|
|
record = buffer; /* Remember begin of record. */
|
|
|
|
|
reclen = 0;
|
|
|
|
|
for (p = buffer; buflen && digitp (p); buflen--, p++)
|
|
|
|
|
{
|
|
|
|
|
reclen *= 10;
|
|
|
|
|
reclen += (*p - '0');
|
|
|
|
|
}
|
|
|
|
|
if (!buflen || *p != ' ')
|
|
|
|
|
{
|
|
|
|
|
log_error ("%s: malformed record length in extended header\n", fname);
|
|
|
|
|
return gpg_error (GPG_ERR_INV_RECORD);
|
|
|
|
|
}
|
|
|
|
|
p++; /* Skip space. */
|
|
|
|
|
buflen--;
|
|
|
|
|
if (buflen + (p-record) < reclen)
|
|
|
|
|
{
|
|
|
|
|
log_error ("%s: extended header record larger"
|
|
|
|
|
" than total extended header data\n", fname);
|
|
|
|
|
return gpg_error (GPG_ERR_INV_RECORD);
|
|
|
|
|
}
|
|
|
|
|
if (reclen < (p-record)+2 || record[reclen-1] != '\n')
|
|
|
|
|
{
|
|
|
|
|
log_error ("%s: malformed extended header record\n", fname);
|
|
|
|
|
return gpg_error (GPG_ERR_INV_RECORD);
|
|
|
|
|
}
|
|
|
|
|
record[reclen-1] = 0; /* For convenience change LF to a Nul. */
|
|
|
|
|
reclen -= (p-record);
|
|
|
|
|
/* P points to the begin of the keyword and RECLEN is the
|
|
|
|
|
* remaining length of the record excluding the LF. */
|
|
|
|
|
if (memchr (p, 0, reclen-1)
|
|
|
|
|
&& (!strncmp (p, "path=", 5) || !strncmp (p, "linkpath=", 9)))
|
|
|
|
|
{
|
|
|
|
|
log_error ("%s: extended header record has an embedded nul"
|
|
|
|
|
" - ignoring\n", fname);
|
|
|
|
|
}
|
|
|
|
|
else if (!strncmp (p, "path=", 5))
|
|
|
|
|
{
|
|
|
|
|
sl = add_to_strlist_try (r_exthdr, p+5);
|
|
|
|
|
if (!sl)
|
|
|
|
|
return gpg_error_from_syserror ();
|
|
|
|
|
sl->flags = 1; /* Mark as path */
|
|
|
|
|
}
|
|
|
|
|
else if (!strncmp (p, "linkpath=", 9))
|
|
|
|
|
{
|
|
|
|
|
sl = add_to_strlist_try (r_exthdr, p+9);
|
|
|
|
|
if (!sl)
|
|
|
|
|
return gpg_error_from_syserror ();
|
|
|
|
|
sl->flags = 2; /* Mark as linkpath */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer = p + reclen;
|
|
|
|
|
buflen -= reclen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
|
2019-03-06 17:46:40 +01:00
|
|
|
|
/* Read the next block, assuming it is a tar header. Returns a header
|
2022-01-09 18:34:04 +01:00
|
|
|
|
* object on success in R_HEADER, or an error. If the stream is
|
|
|
|
|
* consumed (i.e. end-of-archive), R_HEADER is set to NULL. In case
|
|
|
|
|
* of an error an error message is printed. If the header is an
|
|
|
|
|
* extended header, a string list is allocated and stored at
|
|
|
|
|
* R_EXTHEADER; the caller should provide a pointer to NULL. Such an
|
|
|
|
|
* extended header is fully processed here and the returned R_HEADER
|
|
|
|
|
* has then the next regular header. */
|
2015-11-25 13:39:50 +01:00
|
|
|
|
static gpg_error_t
|
2022-01-09 18:34:04 +01:00
|
|
|
|
read_header (estream_t stream, tarinfo_t info,
|
|
|
|
|
tar_header_t *r_header, strlist_t *r_extheader)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
int i;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
tar_header_t hdr;
|
|
|
|
|
char *buffer;
|
|
|
|
|
size_t buflen, nrec;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (err)
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
info->nblocks++;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
for (i=0; i < RECORDSIZE && !record[i]; i++)
|
|
|
|
|
;
|
|
|
|
|
if (i == RECORDSIZE)
|
|
|
|
|
{
|
|
|
|
|
/* All zero header - check whether it is the first part of an
|
|
|
|
|
end of archive mark. */
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (err)
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
info->nblocks++;
|
2015-11-25 13:39:50 +01:00
|
|
|
|
|
2010-06-07 13:33:02 +00:00
|
|
|
|
for (i=0; i < RECORDSIZE && !record[i]; i++)
|
|
|
|
|
;
|
|
|
|
|
if (i != RECORDSIZE)
|
|
|
|
|
log_info ("%s: warning: skipping empty header\n",
|
|
|
|
|
es_fname_get (stream));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* End of archive - FIXME: we might want to check for garbage. */
|
2015-11-25 13:39:50 +01:00
|
|
|
|
*r_header = NULL;
|
|
|
|
|
return 0;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 17:46:40 +01:00
|
|
|
|
*r_header = parse_header (record, es_fname_get (stream), info);
|
2022-01-09 18:34:04 +01:00
|
|
|
|
if (!*r_header)
|
|
|
|
|
return gpg_error_from_syserror ();
|
|
|
|
|
hdr = *r_header;
|
|
|
|
|
|
|
|
|
|
if (hdr->typeflag != TF_EXTHDR || !r_extheader)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Read the extended header. */
|
|
|
|
|
if (!hdr->nrecords)
|
|
|
|
|
{
|
2024-05-12 18:09:23 -04:00
|
|
|
|
/* More than 64k for an extended header is surely too large. */
|
2022-01-09 18:34:04 +01:00
|
|
|
|
log_info ("%s: warning: empty extended header\n",
|
|
|
|
|
es_fname_get (stream));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (hdr->nrecords > 65536 / RECORDSIZE)
|
|
|
|
|
{
|
2024-05-12 18:09:23 -04:00
|
|
|
|
/* More than 64k for an extended header is surely too large. */
|
2022-01-09 18:34:04 +01:00
|
|
|
|
log_error ("%s: extended header too large - skipping\n",
|
|
|
|
|
es_fname_get (stream));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer = xtrymalloc (hdr->nrecords * RECORDSIZE);
|
|
|
|
|
if (!buffer)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("%s: error allocating space for extended header: %s\n",
|
|
|
|
|
es_fname_get (stream), gpg_strerror (err));
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
buflen = 0;
|
|
|
|
|
|
|
|
|
|
for (nrec=0; nrec < hdr->nrecords;)
|
|
|
|
|
{
|
|
|
|
|
err = read_record (stream, buffer + buflen);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
xfree (buffer);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
info->nblocks++;
|
|
|
|
|
nrec++;
|
|
|
|
|
if (nrec < hdr->nrecords || (hdr->size && !(hdr->size % RECORDSIZE)))
|
|
|
|
|
buflen += RECORDSIZE;
|
|
|
|
|
else
|
|
|
|
|
buflen += (hdr->size % RECORDSIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = parse_extended_header (es_fname_get (stream),
|
|
|
|
|
buffer, buflen, r_extheader);
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
free_strlist (*r_extheader);
|
|
|
|
|
*r_extheader = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xfree (buffer);
|
2024-05-12 18:09:23 -04:00
|
|
|
|
/* Now that the extended header has been read, we read the next
|
2022-01-09 18:34:04 +01:00
|
|
|
|
* header without allowing an extended header. */
|
|
|
|
|
return read_header (stream, info, r_header, NULL);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Skip the data records according to HEADER. Prints an error message
|
|
|
|
|
on error and return -1. */
|
|
|
|
|
static int
|
2019-03-06 17:46:40 +01:00
|
|
|
|
skip_data (estream_t stream, tarinfo_t info, tar_header_t header)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
unsigned long long n;
|
|
|
|
|
|
|
|
|
|
for (n=0; n < header->nrecords; n++)
|
|
|
|
|
{
|
|
|
|
|
if (read_record (stream, record))
|
|
|
|
|
return -1;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
info->nblocks++;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2022-01-09 18:34:04 +01:00
|
|
|
|
print_header (tar_header_t header, strlist_t extheader, estream_t out)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned long mask;
|
|
|
|
|
char modestr[10+1];
|
|
|
|
|
int i;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
strlist_t sl;
|
|
|
|
|
const char *name, *linkname;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
*modestr = '?';
|
|
|
|
|
switch (header->typeflag)
|
|
|
|
|
{
|
|
|
|
|
case TF_REGULAR: *modestr = '-'; break;
|
|
|
|
|
case TF_HARDLINK: *modestr = 'h'; break;
|
|
|
|
|
case TF_SYMLINK: *modestr = 'l'; break;
|
|
|
|
|
case TF_CHARDEV: *modestr = 'c'; break;
|
|
|
|
|
case TF_BLOCKDEV: *modestr = 'b'; break;
|
|
|
|
|
case TF_DIRECTORY:*modestr = 'd'; break;
|
|
|
|
|
case TF_FIFO: *modestr = 'f'; break;
|
|
|
|
|
case TF_RESERVED: *modestr = '='; break;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
case TF_EXTHDR: break;
|
|
|
|
|
case TF_GEXTHDR: break;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
case TF_UNKNOWN: break;
|
|
|
|
|
case TF_NOTSUP: break;
|
|
|
|
|
}
|
|
|
|
|
for (mask = 0400, i = 0; i < 9; i++, mask >>= 1)
|
|
|
|
|
modestr[1+i] = (header->mode & mask)? "rwxrwxrwx"[i]:'-';
|
|
|
|
|
if ((header->typeflag & 04000))
|
|
|
|
|
modestr[3] = modestr[3] == 'x'? 's':'S';
|
|
|
|
|
if ((header->typeflag & 02000))
|
|
|
|
|
modestr[6] = modestr[6] == 'x'? 's':'S';
|
|
|
|
|
if ((header->typeflag & 01000))
|
|
|
|
|
modestr[9] = modestr[9] == 'x'? 't':'T';
|
|
|
|
|
modestr[10] = 0;
|
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
/* FIXME: We do not parse the linkname unless its part of an
|
|
|
|
|
* extended header. */
|
|
|
|
|
name = header->name;
|
|
|
|
|
linkname = header->typeflag == TF_SYMLINK? "?" : NULL;
|
|
|
|
|
|
|
|
|
|
for (sl = extheader; sl; sl = sl->next)
|
|
|
|
|
{
|
|
|
|
|
if (sl->flags == 1)
|
|
|
|
|
name = sl->d;
|
|
|
|
|
else if (sl->flags == 2)
|
|
|
|
|
linkname = sl->d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
es_fprintf (out, "%s %lu %lu/%lu %12llu %s %s%s%s\n",
|
2010-06-07 13:33:02 +00:00
|
|
|
|
modestr, header->nlink, header->uid, header->gid, header->size,
|
2022-01-09 18:34:04 +01:00
|
|
|
|
isotimestamp (header->mtime),
|
|
|
|
|
name,
|
|
|
|
|
linkname? " -> " : "",
|
|
|
|
|
linkname? linkname : "");
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* List the tarball FILENAME or, if FILENAME is NULL, the tarball read
|
|
|
|
|
from stdin. */
|
2015-11-25 13:39:50 +01:00
|
|
|
|
gpg_error_t
|
2015-11-24 18:39:30 +01:00
|
|
|
|
gpgtar_list (const char *filename, int decrypt)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
2022-03-21 13:06:00 +01:00
|
|
|
|
estream_t stream = NULL;
|
2015-11-25 13:39:50 +01:00
|
|
|
|
tar_header_t header = NULL;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
strlist_t extheader = NULL;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
struct tarinfo_s tarinfo_buffer;
|
|
|
|
|
tarinfo_t tarinfo = &tarinfo_buffer;
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_process_t proc = NULL;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
|
|
|
|
|
memset (&tarinfo_buffer, 0, sizeof tarinfo_buffer);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
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 10:17:23 +09: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 10:17:23 +09:00
|
|
|
|
#endif
|
2015-11-30 16:21:22 +01:00
|
|
|
|
const char **argv;
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_spawn_actions_t act = NULL;
|
2015-11-30 16:21:22 +01:00
|
|
|
|
|
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 13:10:19 +09: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 13:10:19 +09: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 13:10:19 +09: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 13:10:19 +09: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
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
err = gpgrt_spawn_actions_new (&act);
|
2024-05-31 15:36:39 +09:00
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
xfree (argv);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_spawn_actions_set_inherit_handles (act, except);
|
2024-05-31 15:36:39 +09:00
|
|
|
|
#else
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_spawn_actions_set_inherit_fds (act, except);
|
2024-05-31 15:36:39 +09:00
|
|
|
|
#endif
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
err = gpgrt_process_spawn (opt.gpg_program, argv,
|
|
|
|
|
((filename ? 0 : GPGRT_PROCESS_STDIN_KEEP)
|
|
|
|
|
| GPGRT_PROCESS_STDOUT_PIPE), act, &proc);
|
|
|
|
|
gpgrt_spawn_actions_release (act);
|
2015-11-30 16:21:22 +01:00
|
|
|
|
xfree (argv);
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_process_get_streams (proc, 0, NULL, &stream, NULL);
|
2022-03-21 13:06:00 +01:00
|
|
|
|
es_set_binary (stream);
|
|
|
|
|
}
|
|
|
|
|
else if (filename) /* No decryption requested. */
|
|
|
|
|
{
|
|
|
|
|
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));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 13:33:02 +00:00
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2022-01-09 18:34:04 +01:00
|
|
|
|
err = read_header (stream, tarinfo, &header, &extheader);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
if (err || header == NULL)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
goto leave;
|
2015-11-25 13:39:50 +01:00
|
|
|
|
|
2022-01-09 18:34:04 +01:00
|
|
|
|
print_header (header, extheader, es_stdout);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
|
2019-03-06 17:46:40 +01:00
|
|
|
|
if (skip_data (stream, tarinfo, header))
|
2010-06-07 13:33:02 +00:00
|
|
|
|
goto leave;
|
2022-01-09 18:34:04 +01:00
|
|
|
|
free_strlist (extheader);
|
|
|
|
|
extheader = NULL;
|
2010-06-07 13:33:02 +00: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 19:18:21 +09: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 19:18:21 +09:00
|
|
|
|
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
err = gpgrt_process_wait (proc, 1);
|
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 19:18:21 +09:00
|
|
|
|
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 19:18:21 +09:00
|
|
|
|
int exitcode;
|
|
|
|
|
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_process_ctl (proc, GPGRT_PROCESS_GET_EXIT_ID, &exitcode);
|
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 19:18:21 +09:00
|
|
|
|
log_error ("running %s failed (exitcode=%d): %s",
|
|
|
|
|
opt.gpg_program, exitcode, gpg_strerror (err));
|
2022-03-21 13:06:00 +01:00
|
|
|
|
}
|
Use gpgrt_process_spawn API from libgpg-error.
* agent/genkey.c (do_check_passphrase_pattern): Use the gpgrt API.
* common/asshelp.c (start_new_service): Ditto.
* common/exechelp.h: Remove gnupg_process_spawn API.
* common/exechelp-posix.c: Remove gnupg_process_spawn implementation.
* common/exechelp-w32.c: Likewise.
* common/exectool.c (gnupg_exec_tool_stream): Use the gpgrt API.
* common/t-exechelp.c (test_pipe_stream): Remove.
* dirmngr/ldap-wrapper.c (destroy_wrapper, ldap_reaper_thread): Use
the gpgrt API.
(ldap_wrapper_connection_cleanup, ldap_wrapper): Ditto.
* dirmngr/ldap.c, g10/call-keyboxd.c: No need to include exechelp.h.
* g10/photoid.c (run_with_pipe, show_photo): Use the gpgrt API.
* g13/be-encfs.c (run_umount_helper, run_encfs_tool): Ditto.
* g13/g13.c, g13/mount.c, g13/runner.c: No need to include exechelp.h.
* scd/apdu.c: No need to include exechelp.h.
* scd/app.c (report_change): Use the gpgrt API.
* sm/export.c, sm/import.c: No need to include exechelp.h.
* tests/gpgscm/ffi.c (proc_object_finalize, proc_wrap)
(do_process_spawn_io, do_process_spawn_fd, do_process_wait): Use the
gpgrt API.
* tools/gpg-auth.c: No need to include exechelp.h.
* tools/gpg-card.c (cmd_gpg): Use the gpgrt API.
* tools/gpg-connect-agent.c: No need to include exechelp.h.
* tools/gpg-mail-tube.c (mail_tube_encrypt, prepare_for_appimage)
(start_gpg_encrypt): Use the gpgrt API.
* tools/gpgconf-comp.c (gpg_agent_runtime_change)
(scdaemon_runtime_change, tpm2daemon_runtime_change)
(dirmngr_runtime_change, keyboxd_runtime_change)
(gc_component_launch, gc_component_check_options)
(retrieve_options_from_program): Ditto.
* tools/gpgconf.c (show_versions_via_dirmngr): Ditto.
* tools/gpgtar-create.c (gpgtar_create): Ditto.
* tools/gpgtar-extract.c (gpgtar_extract): Ditto.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
--
GnuPG-bug-id: 7192
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-09 09:39:15 +09:00
|
|
|
|
gpgrt_process_release (proc);
|
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 19:18:21 +09:00
|
|
|
|
proc = NULL;
|
2022-03-21 13:06:00 +01:00
|
|
|
|
}
|
2010-06-07 13:33:02 +00:00
|
|
|
|
|
|
|
|
|
leave:
|
2022-01-09 18:34:04 +01:00
|
|
|
|
free_strlist (extheader);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
xfree (header);
|
2010-08-25 10:31:47 +00:00
|
|
|
|
if (stream != es_stdin)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
es_fclose (stream);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-21 13:06:00 +01:00
|
|
|
|
|
2015-11-25 13:39:50 +01:00
|
|
|
|
gpg_error_t
|
2022-01-09 18:34:04 +01:00
|
|
|
|
gpgtar_read_header (estream_t stream, tarinfo_t info,
|
|
|
|
|
tar_header_t *r_header, strlist_t *r_extheader)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
2022-01-09 18:34:04 +01:00
|
|
|
|
return read_header (stream, info, r_header, r_extheader);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2022-01-09 18:34:04 +01:00
|
|
|
|
gpgtar_print_header (tar_header_t header, strlist_t extheader, estream_t out)
|
2010-06-07 13:33:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (header && out)
|
2022-01-09 18:34:04 +01:00
|
|
|
|
print_header (header, extheader, out);
|
2010-06-07 13:33:02 +00:00
|
|
|
|
}
|