mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
Use macros for iobuf ioctls.
This commit is contained in:
parent
1b845104ac
commit
40a78fab0c
@ -1,5 +1,13 @@
|
|||||||
2010-03-08 Werner Koch <wk@g10code.com>
|
2010-03-08 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* iobuf.h (iobuf_ioctl_t): New. Use the new macros instead of the
|
||||||
|
hard wired values.
|
||||||
|
* iobuf.c (iobuf_append): Remove.
|
||||||
|
(iobuf_fdopen): Factor code out to ...
|
||||||
|
(do_iobuf_fdopen): ... new.
|
||||||
|
(iobuf_fdopen_nc): New.
|
||||||
|
(iobuf_open_fd_or_name): Implement using iobuf_fdopen_nc.
|
||||||
|
|
||||||
* iobuf.c (INVALID_FD): Replace by GNUPG_INVALID_FD.
|
* iobuf.c (INVALID_FD): Replace by GNUPG_INVALID_FD.
|
||||||
(fp_or_fd_t): Replace by gnupg_fd_t.
|
(fp_or_fd_t): Replace by gnupg_fd_t.
|
||||||
(my_fileno): Replace by the FD2INT macro.
|
(my_fileno): Replace by the FD2INT macro.
|
||||||
@ -250,7 +258,7 @@
|
|||||||
|
|
||||||
* iobuf.c: Port David's changes from 1.4:
|
* iobuf.c: Port David's changes from 1.4:
|
||||||
(fd_cache_invalidate): Pass return code from close back.
|
(fd_cache_invalidate): Pass return code from close back.
|
||||||
(direct_open, iobuf_ioctl): Check that eturn value.
|
(direct_open, iobuf_ioctl): Check that return value.
|
||||||
(fd_cache_synchronize): New.
|
(fd_cache_synchronize): New.
|
||||||
(iobuf_ioctl): Add new sub command 4 (fsync).
|
(iobuf_ioctl): Add new sub command 4 (fsync).
|
||||||
|
|
||||||
|
@ -1159,15 +1159,7 @@ iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode)
|
|||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
a = iobuf_open (fname);
|
a = iobuf_open (fname);
|
||||||
else
|
else
|
||||||
{
|
a = iobuf_fdopen_nc (fd, mode);
|
||||||
int fd2;
|
|
||||||
|
|
||||||
fd2 = dup (fd);
|
|
||||||
if (fd2 == -1)
|
|
||||||
a = NULL;
|
|
||||||
else
|
|
||||||
a = iobuf_fdopen (fd2, mode);
|
|
||||||
}
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,36 +1206,50 @@ iobuf_open (const char *fname)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
|
||||||
* Create a head iobuf for reading or writing from/to a file
|
static iobuf_t
|
||||||
* Returns: NULL if an error occures and sets ERRNO.
|
do_iobuf_fdopen (int fd, const char *mode, int keep_open)
|
||||||
*/
|
|
||||||
iobuf_t
|
|
||||||
iobuf_fdopen (int fd, const char *mode)
|
|
||||||
{
|
{
|
||||||
iobuf_t a;
|
iobuf_t a;
|
||||||
gnupg_fd_t fp;
|
gnupg_fd_t fp;
|
||||||
file_filter_ctx_t *fcx;
|
file_filter_ctx_t *fcx;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
fp = (gnupg_fd_t) fd;
|
fp = INT2FD (fd);
|
||||||
|
|
||||||
a = iobuf_alloc (strchr (mode, 'w') ? 2 : 1, IOBUF_BUFFER_SIZE);
|
a = iobuf_alloc (strchr (mode, 'w') ? 2 : 1, IOBUF_BUFFER_SIZE);
|
||||||
fcx = xmalloc (sizeof *fcx + 20);
|
fcx = xmalloc (sizeof *fcx + 20);
|
||||||
fcx->fp = fp;
|
fcx->fp = fp;
|
||||||
fcx->print_only_name = 1;
|
fcx->print_only_name = 1;
|
||||||
|
fcx->keep_open = keep_open;
|
||||||
sprintf (fcx->fname, "[fd %d]", fd);
|
sprintf (fcx->fname, "[fd %d]", fd);
|
||||||
a->filter = file_filter;
|
a->filter = file_filter;
|
||||||
a->filter_ov = fcx;
|
a->filter_ov = fcx;
|
||||||
file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
|
file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
|
||||||
file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
|
file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
|
||||||
if (DBG_IOBUF)
|
if (DBG_IOBUF)
|
||||||
log_debug ("iobuf-%d.%d: fdopen `%s'\n", a->no, a->subno, fcx->fname);
|
log_debug ("iobuf-%d.%d: fdopen%s `%s'\n",
|
||||||
iobuf_ioctl (a, 3, 1, NULL); /* disable fd caching */
|
a->no, a->subno, keep_open? "_nc":"", fcx->fname);
|
||||||
|
iobuf_ioctl (a, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Create a head iobuf for reading or writing from/to a file Returns:
|
||||||
|
* NULL and sets ERRNO if an error occured. */
|
||||||
|
iobuf_t
|
||||||
|
iobuf_fdopen (int fd, const char *mode)
|
||||||
|
{
|
||||||
|
return do_iobuf_fdopen (fd, mode, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
iobuf_t
|
||||||
|
iobuf_fdopen_nc (int fd, const char *mode)
|
||||||
|
{
|
||||||
|
return do_iobuf_fdopen (fd, mode, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
iobuf_t
|
iobuf_t
|
||||||
iobuf_sockopen (int fd, const char *mode)
|
iobuf_sockopen (int fd, const char *mode)
|
||||||
{
|
{
|
||||||
@ -1263,7 +1269,7 @@ iobuf_sockopen (int fd, const char *mode)
|
|||||||
sock_filter (scx, IOBUFCTRL_INIT, NULL, NULL, &len);
|
sock_filter (scx, IOBUFCTRL_INIT, NULL, NULL, &len);
|
||||||
if (DBG_IOBUF)
|
if (DBG_IOBUF)
|
||||||
log_debug ("iobuf-%d.%d: sockopen `%s'\n", a->no, a->subno, scx->fname);
|
log_debug ("iobuf-%d.%d: sockopen `%s'\n", a->no, a->subno, scx->fname);
|
||||||
iobuf_ioctl (a, 3, 1, NULL); /* disable fd caching */
|
iobuf_ioctl (a, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
#else
|
#else
|
||||||
a = iobuf_fdopen (fd, mode);
|
a = iobuf_fdopen (fd, mode);
|
||||||
#endif
|
#endif
|
||||||
@ -1311,40 +1317,6 @@ iobuf_create (const char *fname)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
|
||||||
* append to an iobuf; if the file does not exist, create it.
|
|
||||||
* cannot be used for stdout.
|
|
||||||
* Note: This is not used.
|
|
||||||
*/
|
|
||||||
#if 0 /* not used */
|
|
||||||
iobuf_t
|
|
||||||
iobuf_append (const char *fname)
|
|
||||||
{
|
|
||||||
iobuf_t a;
|
|
||||||
FILE *fp;
|
|
||||||
file_filter_ctx_t *fcx;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (!fname)
|
|
||||||
return NULL;
|
|
||||||
else if (!(fp = direct_open (fname, "ab")))
|
|
||||||
return NULL;
|
|
||||||
a = iobuf_alloc (2, IOBUF_BUFFER_SIZE);
|
|
||||||
fcx = m_alloc (sizeof *fcx + strlen (fname));
|
|
||||||
fcx->fp = fp;
|
|
||||||
strcpy (fcx->fname, fname);
|
|
||||||
a->real_fname = m_strdup (fname);
|
|
||||||
a->filter = file_filter;
|
|
||||||
a->filter_ov = fcx;
|
|
||||||
file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
|
|
||||||
file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
|
|
||||||
if (DBG_IOBUF)
|
|
||||||
log_debug ("iobuf-%d.%d: append `%s'\n", a->no, a->subno,
|
|
||||||
a->desc?a->desc:"?");
|
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iobuf_t
|
iobuf_t
|
||||||
iobuf_openrw (const char *fname)
|
iobuf_openrw (const char *fname)
|
||||||
@ -1376,12 +1348,15 @@ iobuf_openrw (const char *fname)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
|
iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval)
|
||||||
{
|
{
|
||||||
if (cmd == 1)
|
if (cmd == IOBUF_IOCTL_KEEP_OPEN)
|
||||||
{ /* keep system filepointer/descriptor open */
|
{
|
||||||
|
/* Keep system filepointer/descriptor open. This was used in
|
||||||
|
the past by http.c; this ioctl is not directly used
|
||||||
|
anymore. */
|
||||||
if (DBG_IOBUF)
|
if (DBG_IOBUF)
|
||||||
log_debug ("iobuf-%d.%d: ioctl `%s' keep=%d\n",
|
log_debug ("iobuf-%d.%d: ioctl `%s' keep_open=%d\n",
|
||||||
a ? a->no : -1, a ? a->subno : -1,
|
a ? a->no : -1, a ? a->subno : -1,
|
||||||
a && a->desc ? a->desc : "?",
|
a && a->desc ? a->desc : "?",
|
||||||
intval);
|
intval);
|
||||||
@ -1401,8 +1376,8 @@ iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (cmd == 2)
|
else if (cmd == IOBUF_IOCTL_INVALIDATE_CACHE)
|
||||||
{ /* invalidate cache */
|
{
|
||||||
if (DBG_IOBUF)
|
if (DBG_IOBUF)
|
||||||
log_debug ("iobuf-*.*: ioctl `%s' invalidate\n",
|
log_debug ("iobuf-*.*: ioctl `%s' invalidate\n",
|
||||||
ptrval ? (char *) ptrval : "?");
|
ptrval ? (char *) ptrval : "?");
|
||||||
@ -1413,8 +1388,8 @@ iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd == 3)
|
else if (cmd == IOBUF_IOCTL_NO_CACHE)
|
||||||
{ /* disallow/allow caching */
|
{
|
||||||
if (DBG_IOBUF)
|
if (DBG_IOBUF)
|
||||||
log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n",
|
log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n",
|
||||||
a ? a->no : -1, a ? a->subno : -1,
|
a ? a->no : -1, a ? a->subno : -1,
|
||||||
@ -1436,7 +1411,7 @@ iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (cmd == 4)
|
else if (cmd == IOBUF_IOCTL_FSYNC)
|
||||||
{
|
{
|
||||||
/* Do a fsync on the open fd and return any errors to the caller
|
/* Do a fsync on the open fd and return any errors to the caller
|
||||||
of iobuf_ioctl. Note that we work on a file name here. */
|
of iobuf_ioctl. Note that we work on a file name here. */
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* iobuf.h - I/O buffer
|
/* iobuf.h - I/O buffer
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
|
||||||
|
* 2010 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GNUPG.
|
* This file is part of GNUPG.
|
||||||
*
|
*
|
||||||
@ -25,7 +26,7 @@
|
|||||||
|
|
||||||
#define DBG_IOBUF iobuf_debug_mode
|
#define DBG_IOBUF iobuf_debug_mode
|
||||||
|
|
||||||
|
/* Filter control modes. */
|
||||||
#define IOBUFCTRL_INIT 1
|
#define IOBUFCTRL_INIT 1
|
||||||
#define IOBUFCTRL_FREE 2
|
#define IOBUFCTRL_FREE 2
|
||||||
#define IOBUFCTRL_UNDERFLOW 3
|
#define IOBUFCTRL_UNDERFLOW 3
|
||||||
@ -34,6 +35,17 @@
|
|||||||
#define IOBUFCTRL_CANCEL 6
|
#define IOBUFCTRL_CANCEL 6
|
||||||
#define IOBUFCTRL_USER 16
|
#define IOBUFCTRL_USER 16
|
||||||
|
|
||||||
|
|
||||||
|
/* Command codes for iobuf_ioctl. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
IOBUF_IOCTL_KEEP_OPEN = 1, /* Uses intval. */
|
||||||
|
IOBUF_IOCTL_INVALIDATE_CACHE = 2, /* Uses ptrval. */
|
||||||
|
IOBUF_IOCTL_NO_CACHE = 3, /* Uses intval. */
|
||||||
|
IOBUF_IOCTL_FSYNC = 4 /* Uses ptrval. */
|
||||||
|
} iobuf_ioctl_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct iobuf_struct *iobuf_t;
|
typedef struct iobuf_struct *iobuf_t;
|
||||||
typedef struct iobuf_struct *IOBUF; /* Compatibility with gpg 1.4. */
|
typedef struct iobuf_struct *IOBUF; /* Compatibility with gpg 1.4. */
|
||||||
|
|
||||||
@ -89,11 +101,12 @@ iobuf_t iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname,
|
|||||||
const char *mode);
|
const char *mode);
|
||||||
iobuf_t iobuf_open (const char *fname);
|
iobuf_t iobuf_open (const char *fname);
|
||||||
iobuf_t iobuf_fdopen (int fd, const char *mode);
|
iobuf_t iobuf_fdopen (int fd, const char *mode);
|
||||||
|
iobuf_t iobuf_fdopen_nc (int fd, const char *mode);
|
||||||
iobuf_t iobuf_sockopen (int fd, const char *mode);
|
iobuf_t iobuf_sockopen (int fd, const char *mode);
|
||||||
iobuf_t iobuf_create (const char *fname);
|
iobuf_t iobuf_create (const char *fname);
|
||||||
iobuf_t iobuf_append (const char *fname);
|
iobuf_t iobuf_append (const char *fname);
|
||||||
iobuf_t iobuf_openrw (const char *fname);
|
iobuf_t iobuf_openrw (const char *fname);
|
||||||
int iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval);
|
int iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval);
|
||||||
int iobuf_close (iobuf_t iobuf);
|
int iobuf_close (iobuf_t iobuf);
|
||||||
int iobuf_cancel (iobuf_t iobuf);
|
int iobuf_cancel (iobuf_t iobuf);
|
||||||
|
|
||||||
@ -140,10 +153,10 @@ void iobuf_set_partial_block_mode (iobuf_t a, size_t len);
|
|||||||
void iobuf_skip_rest (iobuf_t a, unsigned long n, int partial);
|
void iobuf_skip_rest (iobuf_t a, unsigned long n, int partial);
|
||||||
|
|
||||||
|
|
||||||
/* get a byte form the iobuf; must check for eof prior to this function
|
/* Get a byte from the iobuf; must check for eof prior to this
|
||||||
* this function returns values in the range 0 .. 255 or -1 to indicate EOF
|
* function. This function returns values in the range 0 .. 255 or -1
|
||||||
* iobuf_get_noeof() does not return -1 to indicate EOF, but masks the
|
* to indicate EOF. iobuf_get_noeof() does not return -1 to indicate
|
||||||
* returned value to be in the range 0 ..255.
|
* EOF, but masks the returned value to be in the range 0 .. 255.
|
||||||
*/
|
*/
|
||||||
#define iobuf_get(a) \
|
#define iobuf_get(a) \
|
||||||
( ((a)->nofast || (a)->d.start >= (a)->d.len )? \
|
( ((a)->nofast || (a)->d.start >= (a)->d.len )? \
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2010-03-08 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
Use macros for iobuf_ioctl commands.
|
||||||
|
|
||||||
2010-02-17 Werner Koch <wk@g10code.com>
|
2010-02-17 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* keygen.c (ask_user_id): Avoid infinite loop in case of invalid
|
* keygen.c (ask_user_id): Avoid infinite loop in case of invalid
|
||||||
|
@ -223,7 +223,7 @@ decrypt_messages (int nfiles, char *files[])
|
|||||||
goto next_file;
|
goto next_file;
|
||||||
fp = iobuf_open(filename);
|
fp = iobuf_open(filename);
|
||||||
if (fp)
|
if (fp)
|
||||||
iobuf_ioctl (fp,3,1,NULL); /* disable fd caching */
|
iobuf_ioctl (fp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
||||||
{
|
{
|
||||||
iobuf_close (fp);
|
iobuf_close (fp);
|
||||||
|
@ -185,7 +185,7 @@ encrypt_simple (const char *filename, int mode, int use_seskey)
|
|||||||
/* Prepare iobufs. */
|
/* Prepare iobufs. */
|
||||||
inp = iobuf_open(filename);
|
inp = iobuf_open(filename);
|
||||||
if (inp)
|
if (inp)
|
||||||
iobuf_ioctl (inp,3,1,NULL); /* disable fd caching */
|
iobuf_ioctl (inp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
if (inp && is_secured_file (iobuf_get_fd (inp)))
|
if (inp && is_secured_file (iobuf_get_fd (inp)))
|
||||||
{
|
{
|
||||||
iobuf_close (inp);
|
iobuf_close (inp);
|
||||||
@ -526,7 +526,7 @@ encrypt_crypt (int filefd, const char *filename,
|
|||||||
/* Prepare iobufs. */
|
/* Prepare iobufs. */
|
||||||
inp = iobuf_open_fd_or_name (filefd, filename, "rb");
|
inp = iobuf_open_fd_or_name (filefd, filename, "rb");
|
||||||
if (inp)
|
if (inp)
|
||||||
iobuf_ioctl (inp, 3, 1, NULL); /* Disable fd caching. */
|
iobuf_ioctl (inp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
if (inp && is_secured_file (iobuf_get_fd (inp)))
|
if (inp && is_secured_file (iobuf_get_fd (inp)))
|
||||||
{
|
{
|
||||||
iobuf_close (inp);
|
iobuf_close (inp);
|
||||||
|
@ -449,8 +449,8 @@ exec_write(struct exec_info **info,const char *program,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fd iobufs are cached?! */
|
/* fd iobufs are cached! */
|
||||||
iobuf_ioctl((*info)->fromchild,3,1,NULL);
|
iobuf_ioctl((*info)->fromchild, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -556,7 +556,7 @@ exec_read(struct exec_info *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Do not cache this iobuf on close */
|
/* Do not cache this iobuf on close */
|
||||||
iobuf_ioctl(info->fromchild,3,1,NULL);
|
iobuf_ioctl(info->fromchild, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,8 @@ import_keys_internal( IOBUF inp, char **fnames, int nnames,
|
|||||||
rc = import( inp2, fname, stats, fpr, fpr_len, options );
|
rc = import( inp2, fname, stats, fpr, fpr_len, options );
|
||||||
iobuf_close(inp2);
|
iobuf_close(inp2);
|
||||||
/* Must invalidate that ugly cache to actually close it. */
|
/* Must invalidate that ugly cache to actually close it. */
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE,
|
||||||
|
0, (char*)fname);
|
||||||
if( rc )
|
if( rc )
|
||||||
log_error("import from `%s' failed: %s\n", fname,
|
log_error("import from `%s' failed: %s\n", fname,
|
||||||
g10_errstr(rc) );
|
g10_errstr(rc) );
|
||||||
|
@ -188,7 +188,7 @@ maybe_create_keyring (char *filename, int force)
|
|||||||
|
|
||||||
iobuf_close (iobuf);
|
iobuf_close (iobuf);
|
||||||
/* Must invalidate that ugly cache */
|
/* Must invalidate that ugly cache */
|
||||||
iobuf_ioctl (NULL, 2, 0, filename);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, filename);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
@ -1981,7 +1981,7 @@ keyedit_menu( const char *username, strlist_t locusr,
|
|||||||
init_packet (pkt);
|
init_packet (pkt);
|
||||||
rc = parse_packet (a, pkt);
|
rc = parse_packet (a, pkt);
|
||||||
iobuf_close (a);
|
iobuf_close (a);
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)fname); /* (invalidate cache). */
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname);
|
||||||
if (!rc
|
if (!rc
|
||||||
&& pkt->pkttype != PKT_SECRET_KEY
|
&& pkt->pkttype != PKT_SECRET_KEY
|
||||||
&& pkt->pkttype != PKT_SECRET_SUBKEY)
|
&& pkt->pkttype != PKT_SECRET_SUBKEY)
|
||||||
|
16
g10/keygen.c
16
g10/keygen.c
@ -2877,7 +2877,7 @@ read_parameter_file( const char *fname )
|
|||||||
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
|
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iobuf_ioctl (fp, 3, 1, NULL); /* No file caching. */
|
iobuf_ioctl (fp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
|
|
||||||
lnr = 0;
|
lnr = 0;
|
||||||
err = NULL;
|
err = NULL;
|
||||||
@ -3018,9 +3018,11 @@ read_parameter_file( const char *fname )
|
|||||||
|
|
||||||
/* Must invalidate that ugly cache to actually close it. */
|
/* Must invalidate that ugly cache to actually close it. */
|
||||||
if (outctrl.pub.fname)
|
if (outctrl.pub.fname)
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)outctrl.pub.fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE,
|
||||||
|
0, (char*)outctrl.pub.fname);
|
||||||
if (outctrl.sec.fname)
|
if (outctrl.sec.fname)
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)outctrl.sec.fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE,
|
||||||
|
0, (char*)outctrl.sec.fname);
|
||||||
|
|
||||||
xfree( outctrl.pub.fname );
|
xfree( outctrl.pub.fname );
|
||||||
xfree( outctrl.pub.newfname );
|
xfree( outctrl.pub.newfname );
|
||||||
@ -3377,7 +3379,8 @@ do_generate_keypair (struct para_data_s *para,
|
|||||||
iobuf_close(outctrl->pub.stream);
|
iobuf_close(outctrl->pub.stream);
|
||||||
outctrl->pub.stream = NULL;
|
outctrl->pub.stream = NULL;
|
||||||
if (outctrl->pub.fname)
|
if (outctrl->pub.fname)
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->pub.fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE,
|
||||||
|
0, (char*)outctrl->pub.fname);
|
||||||
xfree( outctrl->pub.fname );
|
xfree( outctrl->pub.fname );
|
||||||
outctrl->pub.fname = outctrl->pub.newfname;
|
outctrl->pub.fname = outctrl->pub.newfname;
|
||||||
outctrl->pub.newfname = NULL;
|
outctrl->pub.newfname = NULL;
|
||||||
@ -3408,7 +3411,8 @@ do_generate_keypair (struct para_data_s *para,
|
|||||||
iobuf_close(outctrl->sec.stream);
|
iobuf_close(outctrl->sec.stream);
|
||||||
outctrl->sec.stream = NULL;
|
outctrl->sec.stream = NULL;
|
||||||
if (outctrl->sec.fname)
|
if (outctrl->sec.fname)
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->sec.fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE,
|
||||||
|
0, (char*)outctrl->sec.fname);
|
||||||
xfree( outctrl->sec.fname );
|
xfree( outctrl->sec.fname );
|
||||||
outctrl->sec.fname = outctrl->sec.newfname;
|
outctrl->sec.fname = outctrl->sec.newfname;
|
||||||
outctrl->sec.newfname = NULL;
|
outctrl->sec.newfname = NULL;
|
||||||
@ -4187,7 +4191,7 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
|
|||||||
char *fprbuf, *p;
|
char *fprbuf, *p;
|
||||||
|
|
||||||
iobuf_close (fp);
|
iobuf_close (fp);
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)fname);
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname);
|
||||||
log_info (_("NOTE: backup of card key saved to `%s'\n"), fname);
|
log_info (_("NOTE: backup of card key saved to `%s'\n"), fname);
|
||||||
|
|
||||||
fingerprint_from_sk (sk, array, &n);
|
fingerprint_from_sk (sk, array, &n);
|
||||||
|
@ -1255,20 +1255,20 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||||||
/* It's a secret keyring, so let's force a fsync just to be safe on
|
/* It's a secret keyring, so let's force a fsync just to be safe on
|
||||||
filesystems that may not sync data and metadata together
|
filesystems that may not sync data and metadata together
|
||||||
(e.g. ext4). */
|
(e.g. ext4). */
|
||||||
if (secret && iobuf_ioctl (NULL, 4, 0, (char*)tmpfname))
|
if (secret && iobuf_ioctl (NULL, IOBUF_IOCTL_FSYNC, 0, (char*)tmpfname))
|
||||||
{
|
{
|
||||||
rc = gpg_error_from_syserror ();
|
rc = gpg_error_from_syserror ();
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalidate close caches. */
|
/* Invalidate close caches. */
|
||||||
if (iobuf_ioctl (NULL, 2, 0, (char*)tmpfname ))
|
if (iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)tmpfname ))
|
||||||
{
|
{
|
||||||
rc = gpg_error_from_syserror ();
|
rc = gpg_error_from_syserror ();
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)bakfname );
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)bakfname );
|
||||||
iobuf_ioctl (NULL, 2, 0, (char*)fname );
|
iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname );
|
||||||
|
|
||||||
/* first make a backup file except for secret keyrings */
|
/* first make a backup file except for secret keyrings */
|
||||||
if (!secret)
|
if (!secret)
|
||||||
|
@ -305,7 +305,7 @@ open_outfile (int inp_fd, const char *iname, int mode, iobuf_t *a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*a)
|
if (*a)
|
||||||
iobuf_ioctl (*a, 3, 1, NULL); /* Disable fd caching. */
|
iobuf_ioctl (*a, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ verify_one_file( const char *name )
|
|||||||
print_file_status( STATUS_FILE_START, name, 1 );
|
print_file_status( STATUS_FILE_START, name, 1 );
|
||||||
fp = iobuf_open(name);
|
fp = iobuf_open(name);
|
||||||
if (fp)
|
if (fp)
|
||||||
iobuf_ioctl (fp,3,1,NULL); /* disable fd caching */
|
iobuf_ioctl (fp, IOBUF_IOCTL_NO_CACHE, 1, NULL);
|
||||||
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
if (fp && is_secured_file (iobuf_get_fd (fp)))
|
||||||
{
|
{
|
||||||
iobuf_close (fp);
|
iobuf_close (fp);
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2010-03-08 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
Use macros for iobuf_ioctl commands.
|
||||||
|
|
||||||
2009-12-08 Werner Koch <wk@g10code.com>
|
2009-12-08 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* keybox-search-desc.h (keydb_search_desc): Use u32 type for
|
* keybox-search-desc.h (keydb_search_desc): Use u32 type for
|
||||||
|
@ -166,9 +166,9 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* fixme: invalidate close caches (not used with stdio)*/
|
/* fixme: invalidate close caches (not used with stdio)*/
|
||||||
/* iobuf_ioctl (NULL, 2, 0, (char*)tmpfname ); */
|
/* iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)tmpfname ); */
|
||||||
/* iobuf_ioctl (NULL, 2, 0, (char*)bakfname ); */
|
/* iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)bakfname ); */
|
||||||
/* iobuf_ioctl (NULL, 2, 0, (char*)fname ); */
|
/* iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname ); */
|
||||||
|
|
||||||
/* First make a backup file except for secret keyboxes. */
|
/* First make a backup file except for secret keyboxes. */
|
||||||
if (!secret)
|
if (!secret)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user