mirror of
git://git.gnupg.org/gnupg.git
synced 2024-06-04 22:57:47 +02:00
.
This commit is contained in:
parent
789732e05a
commit
a400cfe14e
|
@ -1,6 +1,16 @@
|
||||||
|
2010-08-26 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* command-ssh.c (open_control_file): Use estream to create the file.
|
||||||
|
|
||||||
|
* findkey.c (agent_write_private_key): Explicitly create file with
|
||||||
|
mode 600.
|
||||||
|
* gpg-agent.c (main): Ditto.
|
||||||
|
* trustlist.c (agent_marktrusted): Explicitly create file with
|
||||||
|
mode 640.
|
||||||
|
|
||||||
2010-08-16 Werner Koch <wk@g10code.com>
|
2010-08-16 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* gpg-agent.c: Repalce remaining printf by es_printf.
|
* gpg-agent.c: Replace remaining printf by es_printf.
|
||||||
|
|
||||||
2010-08-11 Werner Koch <wk@g10code.com>
|
2010-08-11 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
|
|
@ -678,18 +678,16 @@ open_control_file (FILE **r_fp, int append)
|
||||||
fp = fopen (fname, append? "a+":"r");
|
fp = fopen (fname, append? "a+":"r");
|
||||||
if (!fp && errno == ENOENT)
|
if (!fp && errno == ENOENT)
|
||||||
{
|
{
|
||||||
/* Fixme: "x" is a GNU extension. We might want to use the es_
|
estream_t stream = es_fopen (fname, "wx,mode=-rw-r");
|
||||||
functions here. */
|
if (!stream)
|
||||||
fp = fopen (fname, "wx");
|
|
||||||
if (!fp)
|
|
||||||
{
|
{
|
||||||
err = gpg_error (gpg_err_code_from_errno (errno));
|
err = gpg_error_from_syserror ();
|
||||||
log_error (_("can't create `%s': %s\n"), fname, gpg_strerror (err));
|
log_error (_("can't create `%s': %s\n"), fname, gpg_strerror (err));
|
||||||
xfree (fname);
|
xfree (fname);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
fputs (sshcontrolblurb, fp);
|
es_fputs (sshcontrolblurb, stream);
|
||||||
fclose (fp);
|
es_fclose (stream);
|
||||||
fp = fopen (fname, append? "a+":"r");
|
fp = fopen (fname, append? "a+":"r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,7 @@ agent_write_private_key (const unsigned char *grip,
|
||||||
return gpg_error (GPG_ERR_EEXIST);
|
return gpg_error (GPG_ERR_EEXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: On POSIX systems we used include S_IRGRP as well. */
|
fp = es_fopen (fname, force? "wb,mode=-rw" : "wbx,mode=-rw");
|
||||||
fp = es_fopen (fname, force? "wb" : "wbx");
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
gpg_error_t tmperr = gpg_error_from_syserror ();
|
gpg_error_t tmperr = gpg_error_from_syserror ();
|
||||||
|
|
|
@ -1100,7 +1100,7 @@ main (int argc, char **argv )
|
||||||
{
|
{
|
||||||
estream_t fp;
|
estream_t fp;
|
||||||
|
|
||||||
fp = es_fopen (env_file_name, "w");
|
fp = es_fopen (env_file_name, "w,mode=-rw");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
log_error (_("error creating `%s': %s\n"),
|
log_error (_("error creating `%s': %s\n"),
|
||||||
env_file_name, strerror (errno));
|
env_file_name, strerror (errno));
|
||||||
|
|
|
@ -691,7 +691,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
|
||||||
fname = make_filename (opt.homedir, "trustlist.txt", NULL);
|
fname = make_filename (opt.homedir, "trustlist.txt", NULL);
|
||||||
if ( access (fname, F_OK) && errno == ENOENT)
|
if ( access (fname, F_OK) && errno == ENOENT)
|
||||||
{
|
{
|
||||||
fp = es_fopen (fname, "wx");
|
fp = es_fopen (fname, "wx,mode=-rw-r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
|
@ -705,7 +705,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
|
||||||
es_fputs (headerblurb, fp);
|
es_fputs (headerblurb, fp);
|
||||||
es_fclose (fp);
|
es_fclose (fp);
|
||||||
}
|
}
|
||||||
fp = es_fopen (fname, "a+");
|
fp = es_fopen (fname, "a+,mode=-rw-r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
2010-08-26 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* estream.c (es_convert_mode): Rename to parse_mode.
|
||||||
|
(parse_mode): Add arg R_CMODE and parse key value pairs. Use Use
|
||||||
|
664 as the default mode. Change callers.
|
||||||
|
(ES_DEFAULT_OPEN_MODE): Remove.
|
||||||
|
(es_fopen, do_fpopen, do_w32open, es_freopen): Support a creation
|
||||||
|
mode.
|
||||||
|
(es_func_file_create): Rename to func_file_create and add arg CMODE.
|
||||||
|
(es_func_fd_create): Rename to func_fd_create.
|
||||||
|
(es_func_fp_create): Rename to func_fp_create.
|
||||||
|
(es_list_add): Rename to do_list_add.
|
||||||
|
(es_list_remove): Rename to do_list_remove.
|
||||||
|
(es_list_iterate): Rename to do_list_iterate.
|
||||||
|
(es_pth_read): Rename to do_pth_read.
|
||||||
|
(es_deinit): Rename to do_deinit.
|
||||||
|
(es_init_do): Rename to do_init.
|
||||||
|
(es_func_mem_create): Rename to func_mem_create.
|
||||||
|
|
||||||
2010-08-23 Werner Koch <wk@g10code.com>
|
2010-08-23 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* exechelp-w32ce.c: Rewrite all spawn stuff.
|
* exechelp-w32ce.c: Rewrite all spawn stuff.
|
||||||
|
|
177
common/estream.c
177
common/estream.c
|
@ -116,6 +116,14 @@ void *memrchr (const void *block, int c, size_t size);
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
# define S_IRGRP S_IRUSR
|
||||||
|
# define S_IROTH S_IRUSR
|
||||||
|
# define S_IWGRP S_IWUSR
|
||||||
|
# define S_IWOTH S_IWUSR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_W32CE_SYSTEM
|
#ifdef HAVE_W32CE_SYSTEM
|
||||||
# define _set_errno(a) gpg_err_set_errno ((a))
|
# define _set_errno(a) gpg_err_set_errno ((a))
|
||||||
/* Setmode is missing in cegcc but available since CE 5.0. */
|
/* Setmode is missing in cegcc but available since CE 5.0. */
|
||||||
|
@ -188,8 +196,8 @@ dummy_mutex_call_int (estream_mutex_t mutex)
|
||||||
/* Primitive system I/O. */
|
/* Primitive system I/O. */
|
||||||
|
|
||||||
#ifdef HAVE_PTH
|
#ifdef HAVE_PTH
|
||||||
# define ESTREAM_SYS_READ es_pth_read
|
# define ESTREAM_SYS_READ do_pth_read
|
||||||
# define ESTREAM_SYS_WRITE es_pth_write
|
# define ESTREAM_SYS_WRITE do_pth_write
|
||||||
# define ESTREAM_SYS_YIELD() pth_yield (NULL)
|
# define ESTREAM_SYS_YIELD() pth_yield (NULL)
|
||||||
#else
|
#else
|
||||||
# define ESTREAM_SYS_READ read
|
# define ESTREAM_SYS_READ read
|
||||||
|
@ -198,10 +206,6 @@ dummy_mutex_call_int (estream_mutex_t mutex)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Misc definitions. */
|
|
||||||
|
|
||||||
#define ES_DEFAULT_OPEN_MODE (S_IRUSR | S_IWUSR)
|
|
||||||
|
|
||||||
/* A linked list to hold notification functions. */
|
/* A linked list to hold notification functions. */
|
||||||
struct notify_list_s
|
struct notify_list_s
|
||||||
{
|
{
|
||||||
|
@ -369,7 +373,7 @@ map_w32_to_errno (DWORD w32_err)
|
||||||
WITH_LOCKED_LIST is true we assumed that the list of streams is
|
WITH_LOCKED_LIST is true we assumed that the list of streams is
|
||||||
already locked. */
|
already locked. */
|
||||||
static int
|
static int
|
||||||
es_list_add (estream_t stream, int with_locked_list)
|
do_list_add (estream_t stream, int with_locked_list)
|
||||||
{
|
{
|
||||||
estream_list_t list_obj;
|
estream_list_t list_obj;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -397,7 +401,7 @@ es_list_add (estream_t stream, int with_locked_list)
|
||||||
|
|
||||||
/* Remove STREAM from the list of registered stream objects. */
|
/* Remove STREAM from the list of registered stream objects. */
|
||||||
static void
|
static void
|
||||||
es_list_remove (estream_t stream, int with_locked_list)
|
do_list_remove (estream_t stream, int with_locked_list)
|
||||||
{
|
{
|
||||||
estream_list_t list_obj;
|
estream_list_t list_obj;
|
||||||
|
|
||||||
|
@ -422,7 +426,7 @@ typedef int (*estream_iterator_t) (estream_t stream);
|
||||||
/* Iterate over list of registered streams, calling ITERATOR for each
|
/* Iterate over list of registered streams, calling ITERATOR for each
|
||||||
of them. */
|
of them. */
|
||||||
static int
|
static int
|
||||||
es_list_iterate (estream_iterator_t iterator)
|
do_list_iterate (estream_iterator_t iterator)
|
||||||
{
|
{
|
||||||
estream_list_t list_obj;
|
estream_list_t list_obj;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -448,7 +452,7 @@ es_list_iterate (estream_iterator_t iterator)
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_PTH
|
#ifdef HAVE_PTH
|
||||||
static int
|
static int
|
||||||
es_pth_read (int fd, void *buffer, size_t size)
|
do_pth_read (int fd, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
# ifdef HAVE_W32_SYSTEM
|
# ifdef HAVE_W32_SYSTEM
|
||||||
int rc = pth_read (fd, buffer, size);
|
int rc = pth_read (fd, buffer, size);
|
||||||
|
@ -461,7 +465,7 @@ es_pth_read (int fd, void *buffer, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
es_pth_write (int fd, const void *buffer, size_t size)
|
do_pth_write (int fd, const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
# ifdef HAVE_W32_SYSTEM
|
# ifdef HAVE_W32_SYSTEM
|
||||||
int rc = pth_write (fd, buffer, size);
|
int rc = pth_write (fd, buffer, size);
|
||||||
|
@ -477,7 +481,7 @@ es_pth_write (int fd, const void *buffer, size_t size)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
es_deinit (void)
|
do_deinit (void)
|
||||||
{
|
{
|
||||||
/* Flush all streams. */
|
/* Flush all streams. */
|
||||||
es_fflush (NULL);
|
es_fflush (NULL);
|
||||||
|
@ -489,7 +493,7 @@ es_deinit (void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
es_init_do (void)
|
do_init (void)
|
||||||
{
|
{
|
||||||
static int initialized;
|
static int initialized;
|
||||||
|
|
||||||
|
@ -503,7 +507,7 @@ es_init_do (void)
|
||||||
#else
|
#else
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
#endif
|
#endif
|
||||||
atexit (es_deinit);
|
atexit (do_deinit);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +545,7 @@ typedef struct estream_cookie_mem
|
||||||
not NULL, DATA_N gives the allocated size of DATA and DATA_LEN the
|
not NULL, DATA_N gives the allocated size of DATA and DATA_LEN the
|
||||||
used length in DATA. */
|
used length in DATA. */
|
||||||
static int
|
static int
|
||||||
es_func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie,
|
func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie,
|
||||||
unsigned char *ES__RESTRICT data, size_t data_n,
|
unsigned char *ES__RESTRICT data, size_t data_n,
|
||||||
size_t data_len,
|
size_t data_len,
|
||||||
size_t block_size, unsigned int grow,
|
size_t block_size, unsigned int grow,
|
||||||
|
@ -795,9 +799,9 @@ typedef struct estream_cookie_fd
|
||||||
int no_close; /* If set we won't close the file descriptor. */
|
int no_close; /* If set we won't close the file descriptor. */
|
||||||
} *estream_cookie_fd_t;
|
} *estream_cookie_fd_t;
|
||||||
|
|
||||||
/* Create function for fd objects. */
|
/* Create function for objects indentified by a libc file descriptor. */
|
||||||
static int
|
static int
|
||||||
es_func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close)
|
func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close)
|
||||||
{
|
{
|
||||||
estream_cookie_fd_t fd_cookie;
|
estream_cookie_fd_t fd_cookie;
|
||||||
int err;
|
int err;
|
||||||
|
@ -1152,7 +1156,7 @@ typedef struct estream_cookie_fp
|
||||||
|
|
||||||
/* Create function for FILE objects. */
|
/* Create function for FILE objects. */
|
||||||
static int
|
static int
|
||||||
es_func_fp_create (void **cookie, FILE *fp,
|
func_fp_create (void **cookie, FILE *fp,
|
||||||
unsigned int modeflags, int no_close)
|
unsigned int modeflags, int no_close)
|
||||||
{
|
{
|
||||||
estream_cookie_fp_t fp_cookie;
|
estream_cookie_fp_t fp_cookie;
|
||||||
|
@ -1302,10 +1306,10 @@ static es_cookie_io_functions_t estream_functions_fp =
|
||||||
|
|
||||||
/* Implementation of file I/O. */
|
/* Implementation of file I/O. */
|
||||||
|
|
||||||
/* Create function for fd objects. */
|
/* Create function for objects identified by a file name. */
|
||||||
static int
|
static int
|
||||||
es_func_file_create (void **cookie, int *filedes,
|
func_file_create (void **cookie, int *filedes,
|
||||||
const char *path, unsigned int modeflags)
|
const char *path, unsigned int modeflags, unsigned int cmode)
|
||||||
{
|
{
|
||||||
estream_cookie_fd_t file_cookie;
|
estream_cookie_fd_t file_cookie;
|
||||||
int err;
|
int err;
|
||||||
|
@ -1321,7 +1325,7 @@ es_func_file_create (void **cookie, int *filedes,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open (path, modeflags, ES_DEFAULT_OPEN_MODE);
|
fd = open (path, modeflags, cmode);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
err = -1;
|
err = -1;
|
||||||
|
@ -1346,13 +1350,36 @@ es_func_file_create (void **cookie, int *filedes,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
es_convert_mode (const char *mode, unsigned int *modeflags)
|
|
||||||
{
|
|
||||||
unsigned int omode, oflags;
|
|
||||||
|
|
||||||
switch (*mode)
|
|
||||||
|
/* Parse the mode flags of fopen et al. In addition to the POSIX
|
||||||
|
defined mode flags keyword parameters are supported. These are
|
||||||
|
key/value pairs delimited by comma and optional white spaces.
|
||||||
|
Keywords and values may not contain a comma or white space; unknown
|
||||||
|
keyword are skipped. The only supported keyword is mode; for
|
||||||
|
example:
|
||||||
|
|
||||||
|
"wb,mode=-rw-r--"
|
||||||
|
|
||||||
|
Creates a file and gives the new file read and write permissions
|
||||||
|
for the user and read permission for the group. The format of the
|
||||||
|
string is the same as shown by the -l option of the ls(1) command.
|
||||||
|
However the first letter must be a dash and it is allowed to leave
|
||||||
|
out trailing dashes. If this keyword parameter is not given the
|
||||||
|
default mode for creating files is "-rw-rw-r--" (664). Note that
|
||||||
|
the system still applies the current umask to the mode when crating
|
||||||
|
a file.
|
||||||
|
|
||||||
|
Note: R_CMODE is optional because is only required by functions
|
||||||
|
which are able to creat a file. */
|
||||||
|
static int
|
||||||
|
parse_mode (const char *modestr,
|
||||||
|
unsigned int *modeflags, unsigned int *r_cmode)
|
||||||
|
{
|
||||||
|
unsigned int omode, oflags, cmode;
|
||||||
|
int got_cmode = 0;
|
||||||
|
|
||||||
|
switch (*modestr)
|
||||||
{
|
{
|
||||||
case 'r':
|
case 'r':
|
||||||
omode = O_RDONLY;
|
omode = O_RDONLY;
|
||||||
|
@ -1370,9 +1397,9 @@ es_convert_mode (const char *mode, unsigned int *modeflags)
|
||||||
_set_errno (EINVAL);
|
_set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (mode++; *mode; mode++)
|
for (modestr++; *modestr; modestr++)
|
||||||
{
|
{
|
||||||
switch (*mode)
|
switch (*modestr)
|
||||||
{
|
{
|
||||||
case '+':
|
case '+':
|
||||||
omode = O_RDWR;
|
omode = O_RDWR;
|
||||||
|
@ -1383,12 +1410,54 @@ es_convert_mode (const char *mode, unsigned int *modeflags)
|
||||||
case 'x':
|
case 'x':
|
||||||
oflags |= O_EXCL;
|
oflags |= O_EXCL;
|
||||||
break;
|
break;
|
||||||
|
case ',':
|
||||||
|
goto keyvalue;
|
||||||
default: /* Ignore unknown flags. */
|
default: /* Ignore unknown flags. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyvalue:
|
||||||
|
/* Parse key/value pairs (similar to fopen on mainframes). */
|
||||||
|
for (cmode=0; *modestr == ','; modestr += strcspn (modestr, ","))
|
||||||
|
{
|
||||||
|
modestr++;
|
||||||
|
modestr += strspn (modestr, " \t");
|
||||||
|
if (!strncmp (modestr, "mode=", 5))
|
||||||
|
{
|
||||||
|
static struct {
|
||||||
|
char letter;
|
||||||
|
unsigned int value;
|
||||||
|
} table[] = { { '-', 0 },
|
||||||
|
{ 'r', S_IRUSR }, { 'w', S_IWUSR }, { 'x', S_IXUSR },
|
||||||
|
{ 'r', S_IRGRP }, { 'w', S_IWGRP }, { 'x', S_IXGRP },
|
||||||
|
{ 'r', S_IROTH }, { 'w', S_IWOTH }, { 'x', S_IXOTH }};
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
got_cmode = 1;
|
||||||
|
modestr += 5;
|
||||||
|
/* For now we only support a string as used by ls(1) and no
|
||||||
|
octal numbers. The first character must be a dash. */
|
||||||
|
for (idx=0; idx < 10 && *modestr; idx++, modestr++)
|
||||||
|
{
|
||||||
|
if (*modestr == table[idx].letter)
|
||||||
|
cmode |= table[idx].value;
|
||||||
|
else if (*modestr != '-')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*modestr && !strchr (" \t,", *modestr))
|
||||||
|
{
|
||||||
|
_set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!got_cmode)
|
||||||
|
cmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
|
||||||
|
|
||||||
*modeflags = (omode | oflags);
|
*modeflags = (omode | oflags);
|
||||||
|
if (r_cmode)
|
||||||
|
*r_cmode = cmode;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1624,7 +1693,7 @@ es_create (estream_t *stream, void *cookie, es_syshd_t *syshd,
|
||||||
ESTREAM_MUTEX_INITIALIZE (stream_new->intern->lock);
|
ESTREAM_MUTEX_INITIALIZE (stream_new->intern->lock);
|
||||||
es_initialize (stream_new, cookie, syshd, functions, modeflags);
|
es_initialize (stream_new, cookie, syshd, functions, modeflags);
|
||||||
|
|
||||||
err = es_list_add (stream_new, with_locked_list);
|
err = do_list_add (stream_new, with_locked_list);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -1652,7 +1721,7 @@ do_close (estream_t stream, int with_locked_list)
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
es_list_remove (stream, with_locked_list);
|
do_list_remove (stream, with_locked_list);
|
||||||
while (stream->intern->onclose)
|
while (stream->intern->onclose)
|
||||||
{
|
{
|
||||||
notify_list_t tmp = stream->intern->onclose->next;
|
notify_list_t tmp = stream->intern->onclose->next;
|
||||||
|
@ -2204,7 +2273,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
|
||||||
line_stream = NULL;
|
line_stream = NULL;
|
||||||
line_stream_cookie = NULL;
|
line_stream_cookie = NULL;
|
||||||
|
|
||||||
err = es_func_mem_create (&line_stream_cookie, NULL, 0, 0,
|
err = func_mem_create (&line_stream_cookie, NULL, 0, 0,
|
||||||
BUFFER_BLOCK_SIZE, 1,
|
BUFFER_BLOCK_SIZE, 1,
|
||||||
mem_realloc, mem_free,
|
mem_realloc, mem_free,
|
||||||
O_RDWR,
|
O_RDWR,
|
||||||
|
@ -2464,7 +2533,7 @@ es_init (void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = es_init_do ();
|
err = do_init ();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -2474,7 +2543,7 @@ es_init (void)
|
||||||
estream_t
|
estream_t
|
||||||
es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
|
es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
|
||||||
{
|
{
|
||||||
unsigned int modeflags;
|
unsigned int modeflags, cmode;
|
||||||
int create_called;
|
int create_called;
|
||||||
estream_t stream;
|
estream_t stream;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
|
@ -2486,11 +2555,11 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
|
||||||
cookie = NULL;
|
cookie = NULL;
|
||||||
create_called = 0;
|
create_called = 0;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, &cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = es_func_file_create (&cookie, &fd, path, modeflags);
|
err = func_file_create (&cookie, &fd, path, modeflags, cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -2532,11 +2601,11 @@ es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len,
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
create_called = 0;
|
create_called = 0;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = es_func_mem_create (&cookie, data, data_n, data_len,
|
err = func_mem_create (&cookie, data, data_n, data_len,
|
||||||
BUFFER_BLOCK_SIZE, grow,
|
BUFFER_BLOCK_SIZE, grow,
|
||||||
func_realloc, func_free, modeflags, 0);
|
func_realloc, func_free, modeflags, 0);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -2567,12 +2636,12 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode)
|
||||||
|
|
||||||
/* Memory streams are always read/write. We use MODE only to get
|
/* Memory streams are always read/write. We use MODE only to get
|
||||||
the append flag. */
|
the append flag. */
|
||||||
if (es_convert_mode (mode, &modeflags))
|
if (parse_mode (mode, &modeflags, NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
modeflags |= O_RDWR;
|
modeflags |= O_RDWR;
|
||||||
|
|
||||||
|
|
||||||
if (es_func_mem_create (&cookie, NULL, 0, 0,
|
if (func_mem_create (&cookie, NULL, 0, 0,
|
||||||
BUFFER_BLOCK_SIZE, 1,
|
BUFFER_BLOCK_SIZE, 1,
|
||||||
mem_realloc, mem_free, modeflags,
|
mem_realloc, mem_free, modeflags,
|
||||||
memlimit))
|
memlimit))
|
||||||
|
@ -2600,7 +2669,7 @@ es_fopencookie (void *ES__RESTRICT cookie,
|
||||||
stream = NULL;
|
stream = NULL;
|
||||||
modeflags = 0;
|
modeflags = 0;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -2629,11 +2698,11 @@ do_fdopen (int filedes, const char *mode, int no_close, int with_locked_list)
|
||||||
cookie = NULL;
|
cookie = NULL;
|
||||||
create_called = 0;
|
create_called = 0;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = es_func_fd_create (&cookie, filedes, modeflags, no_close);
|
err = func_fd_create (&cookie, filedes, modeflags, no_close);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -2668,7 +2737,7 @@ es_fdopen_nc (int filedes, const char *mode)
|
||||||
estream_t
|
estream_t
|
||||||
do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list)
|
do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list)
|
||||||
{
|
{
|
||||||
unsigned int modeflags;
|
unsigned int modeflags, cmode;
|
||||||
int create_called;
|
int create_called;
|
||||||
estream_t stream;
|
estream_t stream;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
|
@ -2679,13 +2748,13 @@ do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list)
|
||||||
cookie = NULL;
|
cookie = NULL;
|
||||||
create_called = 0;
|
create_called = 0;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, &cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
fflush (fp);
|
fflush (fp);
|
||||||
err = es_func_fp_create (&cookie, fp, modeflags, no_close);
|
err = func_fp_create (&cookie, fp, modeflags, no_close);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -2733,14 +2802,14 @@ estream_t
|
||||||
do_w32open (HANDLE hd, const char *mode,
|
do_w32open (HANDLE hd, const char *mode,
|
||||||
int no_close, int with_locked_list)
|
int no_close, int with_locked_list)
|
||||||
{
|
{
|
||||||
unsigned int modeflags;
|
unsigned int modeflags, cmode;
|
||||||
int create_called = 0;
|
int create_called = 0;
|
||||||
estream_t stream = NULL;
|
estream_t stream = NULL;
|
||||||
void *cookie = NULL;
|
void *cookie = NULL;
|
||||||
int err;
|
int err;
|
||||||
es_syshd_t syshd;
|
es_syshd_t syshd;
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, &cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
@ -2896,7 +2965,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
|
||||||
|
|
||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
unsigned int modeflags;
|
unsigned int modeflags, cmode;
|
||||||
int create_called;
|
int create_called;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -2909,11 +2978,11 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
|
||||||
|
|
||||||
es_deinitialize (stream);
|
es_deinitialize (stream);
|
||||||
|
|
||||||
err = es_convert_mode (mode, &modeflags);
|
err = parse_mode (mode, &modeflags, &cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
err = es_func_file_create (&cookie, &fd, path, modeflags);
|
err = func_file_create (&cookie, &fd, path, modeflags, cmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
|
@ -3165,7 +3234,7 @@ es_fflush (estream_t stream)
|
||||||
ESTREAM_UNLOCK (stream);
|
ESTREAM_UNLOCK (stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
err = es_list_iterate (do_fflush);
|
err = do_list_iterate (do_fflush);
|
||||||
|
|
||||||
return err ? EOF : 0;
|
return err ? EOF : 0;
|
||||||
}
|
}
|
||||||
|
@ -3865,7 +3934,7 @@ es_tmpfile (void)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = es_func_fd_create (&cookie, fd, modeflags, 0);
|
err = func_fd_create (&cookie, fd, modeflags, 0);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
2010-08-25 Werner Koch <wk@g10code.com>
|
2010-08-25 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* gpgtar.c: Add -t as short option for --list-archive.
|
* gpgtar-extract.c (create_directory): Add .p7m as known
|
||||||
|
extension.
|
||||||
|
|
||||||
|
* gpgtar.c: Add -t as short option for --list-archive.
|
||||||
* gpgtar-extract.c (gpgtar_extract): Use filename "-" for stdin.
|
* gpgtar-extract.c (gpgtar_extract): Use filename "-" for stdin.
|
||||||
Fix dirprefix setting.
|
Fix dirprefix setting.
|
||||||
* gpgtar-list.c (gpgtar_list): Ditto.
|
* gpgtar-list.c (gpgtar_list): Ditto.
|
||||||
|
|
|
@ -212,6 +212,7 @@ create_directory (const char *dirprefix)
|
||||||
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pgp")
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pgp")
|
||||||
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "asc")
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "asc")
|
||||||
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pem")
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pem")
|
||||||
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7m")
|
||||||
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7e")))
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7e")))
|
||||||
{
|
{
|
||||||
prefix_buffer = xtrystrdup (dirprefix);
|
prefix_buffer = xtrystrdup (dirprefix);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user