1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-21 15:01:41 +02:00

Paul's LFS pacthes and started with pipemode

This commit is contained in:
Werner Koch 2000-11-11 17:17:52 +00:00
parent 91451a22c6
commit 99e70f7ac7
26 changed files with 1283 additions and 769 deletions

View File

@ -33,6 +33,9 @@ Niklas Hernaeus <nh@df.lth.se> Disclaimer
Nils Ellmenreich <nils 'at' infosun.fmi.uni-passau.de> Assignment
(configure.in, cipher/rndlinux.c, FAQ)
Paul Eggert <eggert@twinsun.com>
(configuration macros for LFS)
Pedro Morais <morais@poli.org> Translations [pt_BR]
Rémi Guyomarch <rguyom@mail.dotcom.fr> Assignment
@ -50,7 +53,7 @@ Walter Koch <koch@hsp.de> Translations [de]
Werner Koch <wk@gnupg.org> Assignment
(started the whole thing)
Yosiaki IIDA <iida@secom.ne.jp> Translations [ja]
Yosiaki IIDA <iida@ring.gr.jp> Translations [ja]

View File

@ -1,3 +1,18 @@
2000-11-11 Paul Eggert <eggert@twinsun.com>
Actually Paul's patches are dated 2000-20-17; I applied them today
and merged some ChangeLog entries (wk@gnupg.org).
* configure.in (AC_SYS_LARGEFILE): Add.
(try_large_file): Remove. All uses removed.
(AC_CHECK_FUNCS): Remove fopen64 and fstat64.
* acinclude.m4 (AC_SYS_LARGEFILE_TEST_INCLUDES,
AC_SYS_LARGEFILE_MACRO_VALUE, AC_SYS_LARGEFILE): New macros,
taken from GNU tar.
* configure.in (AC_CHECK_FUNCS): Add fseeko.
2000-10-17 Werner Koch <wk@gnupg.org>
* configure.in: Disabled fopen64 checks for Solaris and HPUX.

2
NEWS
View File

@ -1,4 +1,6 @@
* Better LFS support.
* New option --ignore-crc-error
Noteworthy changes in version 1.0.4 (2000-10-17)

4
THANKS
View File

@ -27,6 +27,7 @@ Daniel Eisenbud eisenbud@cs.swarthmore.edu
Daniel Koening dan@mail.isis.de
Daniel Resare daniel@resare.com
Dave Dykstra dwd@bell-labs.com
David C Niemi niemi@tuxers.net
David Champion dgc@uchicago.edu
David Ellement ellement@sdd.hp.com
David Hallinan hallinan@rtd.com
@ -47,6 +48,7 @@ Frank Tobin ftobin@uiuc.edu
Gabriel Rosenkoetter gr@eclipsed.net
Gaël Quéri gqueri@mail.dotcom.fr
Giampaolo Tomassoni g.tomassoni@libero.it
Gilbert Fernandes gilbert_fernandes@hotmail.com
Greg Louis glouis@dynamicro.on.ca
Greg Troxel gdt@ir.bbn.com
Gregory Steuck steuck@iname.com
@ -147,7 +149,7 @@ Walter Koch koch@hsp.de
Wayne Chapeskie waynec@spinnaker.com
Werner Koch wk@gnupg.org
Wim Vandeputte bunbun@reptile.rug.ac.be
Yosiaki IIDA iida@secom.ne.jp
Yosiaki IIDA iida@ring.gr.jp
Yoshihiro Kajiki kajiki@ylug.org
nbecker@hns.com

16
TODO
View File

@ -1,4 +1,16 @@
* Add Dave's UTS patches
* Don't display the "no secret for decryption available"
** Check whether the use of -u and --clearsign created 2 signatures.
removed dups from the skclist.
* Replace mkinstalldir etc. with nnewer copies.
* We need another special packet at the end of a clearsign message to mark
it's end and allow for multiple signature for one message.
* option to set the signature expiration time for key sigs.
* Option to warn when a non MDC message is decrypted?
@ -39,6 +51,10 @@
Scheduled for 1.1
-----------------
* David C Niemi pointed out that the code for --no-default-keyring does not
work as expected, because in g10/g10.c sec_nring will be set in the option
switch but later checked to see whether there are any keyrings.
* export by user-IDs does only export the first matching name which leads
to a problem in cases where there are 2 keys with identically user-IDs.

View File

@ -1 +1 @@
1.0.4-1
1.0.4b

View File

@ -720,4 +720,86 @@ if test $gnupg_cv_mkdir_takes_one_arg = yes ; then
fi
])
dnl AC_SYS_LARGEFILE is stolen from tar.
dnl This can be removed once the official successor to autoconf 2.13 is out.
#serial 12
dnl By default, many hosts won't let programs access large files;
dnl one must use special compiler options to get large-file access to work.
dnl For more details about this brain damage please see:
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl Written by Paul Eggert <eggert@twinsun.com>.
dnl Internal subroutine of AC_SYS_LARGEFILE.
dnl AC_SYS_LARGEFILE_TEST_INCLUDES
AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
[[#include <sys/types.h>
int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
]])
dnl Internal subroutine of AC_SYS_LARGEFILE.
dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR,
dnl COMMENT, INCLUDES,FUNCTION-BODY)
AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
[AC_CACHE_CHECK([for $1 value needed for large files], $3,
[$3=no
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
$5
,
[$6],
,
[AC_TRY_COMPILE([#define $1 $2]
AC_SYS_LARGEFILE_TEST_INCLUDES
$5
,
[$6],
[$3=$2])])])
if test "[$]$3" != no; then
AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
fi])
AC_DEFUN(AC_SYS_LARGEFILE,
[AC_ARG_ENABLE(largefile,
[ --disable-largefile omit support for large files])
if test "$enable_largefile" != no; then
AC_CACHE_CHECK([for special C compiler options needed for large files],
ac_cv_sys_largefile_CC,
[ac_cv_sys_largefile_CC=no
if test "$GCC" != yes; then
# IRIX 6.2 and later do not support large files by default,
# so use the C compiler's -n32 option if that helps.
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
[ac_save_CC="$CC"
CC="$CC -n32"
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
ac_cv_sys_largefile_CC=' -n32')
CC="$ac_save_CC"])
fi])
if test "$ac_cv_sys_largefile_CC" != no; then
CC="$CC$ac_cv_sys_largefile_CC"
fi
AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
ac_cv_sys_file_offset_bits,
[Number of bits in a file offset, on hosts where this is settable.])
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
ac_cv_sys_largefile_source,
[Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
[#include <stdio.h>], [return !ftello;])
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
ac_cv_sys_large_files,
[Define for large files, on AIX-style hosts.])
AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
ac_cv_sys_xopen_source,
[Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
[#include <stdio.h>], [return !ftello;])
fi
])
dnl *-*wedit:notab*-* Please keep this as the last line.

View File

@ -155,6 +155,7 @@ dnl AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_PROG_CC
AC_PROG_CPP
AC_ISC_POSIX
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_PROG_AWK
AC_CHECK_PROG(DOCBOOK_TO_MAN, docbook-to-man, yes, no)
@ -166,7 +167,6 @@ MPI_OPT_FLAGS=""
try_gettext=yes
try_gdbm=yes
try_large_file=yes
case "${target}" in
*-*-mingw32*)
# special stuff for Windoze NT
@ -206,7 +206,6 @@ case "${target}" in
if test -z "$GCC" ; then
CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
fi
try_large_file="no"
;;
*-dec-osf4*)
if test -z "$GCC" ; then
@ -217,9 +216,6 @@ case "${target}" in
;;
m68k-atari-mint)
;;
*-solaris*)
try_large_file="no"
;;
*)
;;
esac
@ -424,11 +420,7 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS(strerror stpcpy strlwr stricmp tcgetattr rand strtoul mmap)
AC_CHECK_FUNCS(memmove gettimeofday getrusage gethrtime setrlimit clock_gettime)
AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask)
if test $try_large_file = "yes"; then
AC_CHECK_FUNCS(fopen64 fstat64)
fi
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask fseeko)
GNUPG_CHECK_MLOCK
GNUPG_FUNC_MKDIR_TAKES_ONE_ARG

View File

@ -1412,6 +1412,14 @@ used by anonymous recipients (created by using --throw-keyid) and might come
handy in case where an encrypted message contains a bogus key ID.
</para></listitem></varlistentry>
<varlistentry>
<term>--enable-special-filenames</term>
<listitem><para>
This options enables a mode in which filenames of the form
<filename>-&amp;n</>, where n is a non-negative decimal number,
refer to the file descriptor n and not to a file with that name.
</para></listitem></varlistentry>
</variablelist>
</refsect1>

View File

@ -1,5 +1,36 @@
2000-11-11 Paul Eggert <eggert@twinsun.com>
Clean up the places in the code that incorrectly use "long" or
"unsigned long" for file offsets. The correct type to use is
"off_t". The difference is important on large-file hosts,
where "off_t" is longer than "long".
* keydb.h (struct keyblock_pos_struct.offset):
Use off_t, not ulong, for file offsets.
* packet.h (dbg_search_packet, dbg_copy_some_packets,
search_packet, copy_some_packets): Likewise.
* parse-packet.c (parse, dbg_search_packet, search_packet,
dbg_copy_some_packets, copy_some_packets): Likewise.
* ringedit.c (keyring_search): Likewise.
* parse-packet.c (parse): Do not use %lu to report file
offsets in error diagnostics; it's not portable.
* ringedit.c (keyring_search): Likewise.
2000-11-09 Werner Koch <wk@gnupg.org>
* g10.c (main): New option --enable-special-filenames.
2000-11-07 Werner Koch <wk@gnupg.org>
* g10.c (main): New command --pipemode.
* pipemode.c: New.
2000-10-23 Werner Koch <wk@gnupg.org>
* armor.c (armor_filter): Changed output of hdrlines, so that a CR
is emitted for DOS systems.
* keygen.c (read_parameter_file): Add a cast for isspace().
* status.c (myread): Use SIGINT instead of SIGHUP for DOS.

View File

@ -65,6 +65,7 @@ gpg_SOURCES = g10.c \
tdbio.h \
delkey.c \
keygen.c \
pipemode.c \
helptext.c
gpgv_SOURCES = gpgv.c \

View File

@ -928,8 +928,15 @@ armor_filter( void *opaque, int control,
iobuf_writestr(a, LF );
}
if( afx->hdrlines )
iobuf_writestr(a, afx->hdrlines);
if ( afx->hdrlines ) {
for ( s = afx->hdrlines; *s; s++ ) {
#ifdef HAVE_DOSISH_SYSTEM
if ( *s == '\n' )
iobuf_put( a, '\r');
#endif
iobuf_put(a, *s );
}
}
iobuf_writestr(a, LF );
afx->status++;
afx->idx = 0;

View File

@ -107,6 +107,7 @@ enum cmd_and_opt_values { aNull = 0,
aDeArmor,
aEnArmor,
aGenRandom,
aPipeMode,
oTextmode,
oFingerprint,
@ -183,6 +184,7 @@ enum cmd_and_opt_values { aNull = 0,
oDisablePubkeyAlgo,
oAllowNonSelfsignedUID,
oAllowFreeformUID,
oEnableSpecialFilenames,
oNoLiteral,
oSetFilesize,
oHonorHttpProxy,
@ -328,6 +330,7 @@ static ARGPARSE_OPTS opts[] = {
{ aPrintMDs, "print-mds" , 256, "@"}, /* old */
{ aListTrustDB, "list-trustdb",0 , "@"},
{ aListTrustPath, "list-trust-path",0, "@"},
{ aPipeMode, "pipemode", 0, "@" },
{ oKOption, NULL, 0, "@"},
{ oPasswdFD, "passphrase-fd",1, "@" },
{ oCommandFD, "command-fd",1, "@" },
@ -386,6 +389,7 @@ static ARGPARSE_OPTS opts[] = {
{ oNoAutoKeyRetrieve, "no-auto-key-retrieve", 0, "@" },
{ oMergeOnly, "merge-only", 0, "@" },
{ oTryAllSecrets, "try-all-secrets", 0, "@" },
{ oEnableSpecialFilenames, "enable-special-filenames", 0, "@" },
{ oEmu3DESS2KBug, "emulate-3des-s2k-bug", 0, "@"},
{ oEmuMDEncodeBug, "emulate-md-encode-bug", 0, "@"},
{0} };
@ -766,6 +770,7 @@ main( int argc, char **argv )
case aEnArmor: set_cmd( &cmd, aEnArmor); break;
case aExportOwnerTrust: set_cmd( &cmd, aExportOwnerTrust); break;
case aImportOwnerTrust: set_cmd( &cmd, aImportOwnerTrust); break;
case aPipeMode: set_cmd( &cmd, aPipeMode); break;
case oArmor: opt.armor = 1; opt.no_armor=0; break;
case oOutput: opt.outfile = pargs.r.ret_str; break;
@ -940,7 +945,9 @@ main( int argc, char **argv )
case oMergeOnly: opt.merge_only = 1; break;
case oTryAllSecrets: opt.try_all_secrets = 1; break;
case oTrustedKey: register_trusted_key( pargs.r.ret_str ); break;
case oEnableSpecialFilenames:
iobuf_enable_special_filenames (1);
break;
default : pargs.err = configfp? 1:2; break;
}
}
@ -1516,6 +1523,12 @@ main( int argc, char **argv )
import_ownertrust( argc? *argv:NULL );
break;
case aPipeMode:
if ( argc )
wrong_args ("--pipemode");
run_in_pipemode ();
break;
case aListPackets:
opt.list_packets=1;
default:

View File

@ -69,7 +69,7 @@ enum resource_type {
struct keyblock_pos_struct {
int resno; /* resource number */
enum resource_type rt;
ulong offset; /* position information */
off_t offset; /* position information */
unsigned count; /* length of the keyblock in packets */
IOBUF fp; /* used by enum_keyblocks */
int secret; /* working on a secret keyring */

View File

@ -154,6 +154,9 @@ int decrypt_message( const char *filename );
int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
STRLIST files, const char *sigfilename, int textmode );
/*-- pipemode.c --*/
void run_in_pipemode (void);
/*-- signal.c --*/
void init_signals(void);
void pause_on_sigusr( int which );

View File

@ -270,21 +270,31 @@ int list_packets( IOBUF a );
int set_packet_list_mode( int mode );
#if DEBUG_PARSE_PACKET
int dbg_search_packet( IOBUF inp, PACKET *pkt, int pkttype, ulong *retpos, const char* file, int lineno );
int dbg_parse_packet( IOBUF inp, PACKET *ret_pkt, const char* file, int lineno );
int dbg_copy_all_packets( IOBUF inp, IOBUF out, const char* file, int lineno );
int dbg_copy_some_packets( IOBUF inp, IOBUF out, ulong stopoff, const char* file, int lineno );
int dbg_skip_some_packets( IOBUF inp, unsigned n, const char* file, int lineno );
#define search_packet( a,b,c,d ) dbg_search_packet( (a), (b), (c), (d), __FILE__, __LINE__ )
#define parse_packet( a, b ) dbg_parse_packet( (a), (b), __FILE__, __LINE__ )
#define copy_all_packets( a,b ) dbg_copy_all_packets((a),(b), __FILE__, __LINE__ )
#define copy_some_packets( a,b,c ) dbg_copy_some_packets((a),(b),(c), __FILE__, __LINE__ )
#define skip_some_packets( a,b ) dbg_skip_some_packets((a),(b), __FILE__, __LINE__ )
int dbg_search_packet( IOBUF inp, PACKET *pkt, int pkttype, off_t *retpos,
const char* file, int lineno );
int dbg_parse_packet( IOBUF inp, PACKET *ret_pkt,
const char* file, int lineno );
int dbg_copy_all_packets( IOBUF inp, IOBUF out,
const char* file, int lineno );
int dbg_copy_some_packets( IOBUF inp, IOBUF out, off_t stopoff,
const char* file, int lineno );
int dbg_skip_some_packets( IOBUF inp, unsigned n,
const char* file, int lineno );
#define search_packet( a,b,c,d ) \
dbg_search_packet( (a), (b), (c), (d), __FILE__, __LINE__ )
#define parse_packet( a, b ) \
dbg_parse_packet( (a), (b), __FILE__, __LINE__ )
#define copy_all_packets( a,b ) \
dbg_copy_all_packets((a),(b), __FILE__, __LINE__ )
#define copy_some_packets( a,b,c ) \
dbg_copy_some_packets((a),(b),(c), __FILE__, __LINE__ )
#define skip_some_packets( a,b ) \
dbg_skip_some_packets((a),(b), __FILE__, __LINE__ )
#else
int search_packet( IOBUF inp, PACKET *pkt, int pkttype, ulong *retpos );
int search_packet( IOBUF inp, PACKET *pkt, int pkttype, off_t *retpos );
int parse_packet( IOBUF inp, PACKET *ret_pkt);
int copy_all_packets( IOBUF inp, IOBUF out );
int copy_some_packets( IOBUF inp, IOBUF out, ulong stopoff );
int copy_some_packets( IOBUF inp, IOBUF out, off_t stopoff );
int skip_some_packets( IOBUF inp, unsigned n );
#endif

View File

@ -39,7 +39,7 @@ static int mpi_print_mode = 0;
static int list_mode = 0;
static int parse( IOBUF inp, PACKET *pkt, int reqtype,
ulong *retpos, int *skip, IOBUF out, int do_skip
off_t *retpos, int *skip, IOBUF out, int do_skip
#ifdef DEBUG_PARSE_PACKET
,const char *dbg_w, const char *dbg_f, int dbg_l
#endif
@ -158,7 +158,7 @@ parse_packet( IOBUF inp, PACKET *pkt )
*/
#ifdef DEBUG_PARSE_PACKET
int
dbg_search_packet( IOBUF inp, PACKET *pkt, int pkttype, ulong *retpos,
dbg_search_packet( IOBUF inp, PACKET *pkt, int pkttype, off_t *retpos,
const char *dbg_f, int dbg_l )
{
int skip, rc;
@ -170,7 +170,7 @@ dbg_search_packet( IOBUF inp, PACKET *pkt, int pkttype, ulong *retpos,
}
#else
int
search_packet( IOBUF inp, PACKET *pkt, int pkttype, ulong *retpos )
search_packet( IOBUF inp, PACKET *pkt, int pkttype, off_t *retpos )
{
int skip, rc;
@ -215,7 +215,7 @@ copy_all_packets( IOBUF inp, IOBUF out )
*/
#ifdef DEBUG_PARSE_PACKET
int
dbg_copy_some_packets( IOBUF inp, IOBUF out, ulong stopoff,
dbg_copy_some_packets( IOBUF inp, IOBUF out, off_t stopoff,
const char *dbg_f, int dbg_l )
{
PACKET pkt;
@ -230,7 +230,7 @@ dbg_copy_some_packets( IOBUF inp, IOBUF out, ulong stopoff,
}
#else
int
copy_some_packets( IOBUF inp, IOBUF out, ulong stopoff )
copy_some_packets( IOBUF inp, IOBUF out, off_t stopoff )
{
PACKET pkt;
int skip, rc=0;
@ -284,7 +284,7 @@ skip_some_packets( IOBUF inp, unsigned n )
* if OUT is not NULL, a special copymode is used.
*/
static int
parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos,
parse( IOBUF inp, PACKET *pkt, int reqtype, off_t *retpos,
int *skip, IOBUF out, int do_skip
#ifdef DEBUG_PARSE_PACKET
,const char *dbg_w, const char *dbg_f, int dbg_l
@ -309,8 +309,7 @@ parse( IOBUF inp, PACKET *pkt, int reqtype, ulong *retpos,
hdrlen=0;
hdr[hdrlen++] = ctb;
if( !(ctb & 0x80) ) {
log_error("%s: invalid packet (ctb=%02x) near %lu\n",
iobuf_where(inp), ctb, iobuf_tell(inp) );
log_error("%s: invalid packet (ctb=%02x)\n", iobuf_where(inp), ctb );
rc = G10ERR_INVALID_PACKET;
goto leave;
}

231
g10/pipemode.c Normal file
View File

@ -0,0 +1,231 @@
/* pipemode.c - pipemode handler
* Copyright (C) 2000 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 2 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include "options.h"
#include "packet.h"
#include "errors.h"
#include "iobuf.h"
#include "keydb.h"
#include "memory.h"
#include "util.h"
#include "main.h"
#include "status.h"
#include "filter.h"
#define CONTROL_PACKET_SPACE 30
enum pipemode_state_e {
STX_init = 0,
STX_wait_operation,
STX_begin,
STX_text,
STX_wait_init
};
struct pipemode_context_s {
enum pipemode_state_e state;
int operation;
int stop;
};
static size_t
make_control ( byte *buf, int code, int operation )
{
const byte *sesmark;
size_t sesmarklen, n=0;;
sesmark = get_session_marker( &sesmarklen );
if ( sesmarklen > 20 )
BUG();
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
n++; /* length will fixed below */
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
buf[n++] = 2; /* control type: pipemode marker */
buf[n++] = code;
buf[n++] = operation;
buf[1] = n-2;
return n;
}
static int
pipemode_filter( void *opaque, int control,
IOBUF a, byte *buf, size_t *ret_len)
{
size_t size = *ret_len;
struct pipemode_context_s *stx = opaque;
int rc=0;
size_t n = 0;
int esc = 0;
if( control == IOBUFCTRL_UNDERFLOW ) {
*ret_len = 0;
/* reserve some space for one control packet */
if ( size <= CONTROL_PACKET_SPACE )
BUG();
size -= CONTROL_PACKET_SPACE;
while ( n < size ) {
int c = iobuf_get (a);
if (c == -1) {
if ( stx->state != STX_init ) {
log_error ("EOF encountered at wrong state\n");
stx->stop = 1;
return -1;
}
break;
}
if ( esc ) {
switch (c) {
case '@':
if ( stx->state == STX_text ) {
buf[n++] = c;
break;
}
log_error ("@@ not allowed in current state\n");
return -1;
case '<': /* begin of stream part */
if ( stx->state != STX_init ) {
log_error ("nested begin of stream\n");
stx->stop = 1;
return -1;
}
stx->state = STX_wait_operation;
break;
case '>': /* end of stream part */
if ( stx->state != STX_wait_init ) {
log_error ("invalid state for @>\n");
stx->stop = 1;
return -1;
}
stx->state = STX_init;
break;
case 'V': /* operation = verify */
case 'E': /* operation = encrypt */
case 'S': /* operation = sign */
case 'B': /* operation = detach sign */
case 'C': /* operation = clearsign */
case 'D': /* operation = decrypt */
if ( stx->state != STX_wait_operation ) {
log_error ("invalid state for operation code\n");
stx->stop = 1;
return -1;
}
stx->operation = c;
stx->state = STX_begin;
n += make_control ( buf, 1, stx->operation );
goto leave;
case 't': /* plaintext text follows */
if ( stx->state != STX_begin ) {
log_error ("invalid state for @t\n");
stx->stop = 1;
return -1;
}
if ( stx->operation != 'E' ) {
log_error ("invalid operation for @t\n");
stx->stop = 1;
return -1;
}
stx->state = STX_text;
n += make_control ( buf, 2, c );
goto leave;
case '.': /* ready */
if ( stx->state == STX_text )
;
else {
log_error ("invalid state for @.\n");
stx->stop = 1;
return -1;
}
stx->state = STX_wait_init;
n += make_control ( buf, 3, c );
goto leave;
default:
log_error ("invalid escape sequence 0x%02x in stream\n",
c);
stx->stop = 1;
return -1;
}
esc = 0;
}
else if (c == '@')
esc = 1;
else
buf[n++] = c;
}
leave:
if ( !n ) {
stx->stop = 1;
rc = -1; /* eof */
}
*ret_len = n;
}
else if( control == IOBUFCTRL_DESC )
*(char**)buf = "pipemode_filter";
return rc;
}
void
run_in_pipemode(void)
{
IOBUF fp;
armor_filter_context_t afx;
struct pipemode_context_s stx;
int rc;
memset( &afx, 0, sizeof afx);
memset( &stx, 0, sizeof stx);
fp = iobuf_open("-");
iobuf_push_filter (fp, pipemode_filter, &stx );
if( !opt.no_armor )
iobuf_push_filter( fp, armor_filter, &afx );
do {
log_debug ("pipemode: begin proc_packets\n");
rc = proc_packets( NULL, fp );
log_debug ("pipemode: end proc_packets: %s\n", g10_errstr (rc));
} while ( !stx.stop );
}

View File

@ -1106,7 +1106,7 @@ keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf, const char *fname )
int rc;
PACKET pkt;
int save_mode;
ulong offset;
off_t offset;
int pkttype = req->pkttype;
PKT_public_key *req_pk = req->pkt.public_key;
PKT_secret_key *req_sk = req->pkt.secret_key;
@ -1188,9 +1188,9 @@ keyring_read( KBPOS *kbpos, KBNODE *ret_root )
}
if( !kbpos->valid )
log_debug("kbpos not valid in keyring_read, want %d\n", (int)kbpos->offset );
log_debug("kbpos not valid in keyring_read\n" );
if( iobuf_seek( a, kbpos->offset ) ) {
log_error("can't seek to %lu\n", kbpos->offset);
log_error("can't seek\n");
iobuf_close(a);
return G10ERR_KEYRING_OPEN;
}

View File

@ -161,4 +161,3 @@ verify_files( int nfiles, char **files )
}
return 0;
}

View File

@ -1,3 +1,9 @@
2000-11-11 Paul Eggert <eggert@twinsun.com>
* iobuf.h (iobuf_get_filelength): Now returns off_t, not u32.
(struct iobuf_struct, iobuf_set_limit,
iobuf_tell, iobuf_seek): Use off_t, not ulong, for file offsets.
2000-10-12 Werner Koch <wk@gnupg.org>
* mpi.h: Changed the way mpi_limb_t is defined.

View File

@ -40,9 +40,9 @@ typedef struct iobuf_struct *IOBUF;
/* fixme: we should hide most of this stuff */
struct iobuf_struct {
int use; /* 1 input , 2 output, 3 temp */
unsigned long nlimit;
unsigned long nbytes; /* used together with nlimit */
unsigned long ntotal; /* total bytes read (position of stream) */
off_t nlimit;
off_t nbytes; /* used together with nlimit */
off_t ntotal; /* total bytes read (position of stream) */
int nofast; /* used by the iobuf_get() */
void *directfp;
struct {
@ -73,6 +73,7 @@ struct iobuf_struct {
int iobuf_debug_mode;
void iobuf_enable_special_filenames ( int yes );
IOBUF iobuf_alloc(int use, size_t bufsize);
IOBUF iobuf_temp(void);
IOBUF iobuf_temp_with_content( const char *buffer, size_t length );
@ -96,10 +97,10 @@ void iobuf_clear_eof(IOBUF a);
#define iobuf_set_error(a) do { (a)->error = 1; } while(0)
#define iobuf_error(a) ((a)->error)
void iobuf_set_limit( IOBUF a, unsigned long nlimit );
void iobuf_set_limit( IOBUF a, off_t nlimit );
ulong iobuf_tell( IOBUF a );
int iobuf_seek( IOBUF a, ulong newpos );
off_t iobuf_tell( IOBUF a );
int iobuf_seek( IOBUF a, off_t newpos );
int iobuf_readbyte(IOBUF a);
int iobuf_read(IOBUF a, byte *buf, unsigned buflen );
@ -115,7 +116,7 @@ int iobuf_write_temp( IOBUF a, IOBUF temp );
size_t iobuf_temp_to_buffer( IOBUF a, byte *buffer, size_t buflen );
void iobuf_unget_and_close_temp( IOBUF a, IOBUF temp );
u32 iobuf_get_filelength( IOBUF a );
off_t iobuf_get_filelength( IOBUF a );
#define IOBUF_FILELENGTH_LIMIT 0xffffffff
const char *iobuf_get_real_fname( IOBUF a );
const char *iobuf_get_fname( IOBUF a );

View File

@ -1,3 +1,7 @@
2000-10-23 Werner Koch <wk@gnupg.org>
* ja.po: Updated.
2000-10-19 Werner Koch <wk@gnupg.org>
Fixed a typo in all files.
@ -19,7 +23,7 @@ Wed Jul 12 13:32:06 CEST 2000 Werner Koch <wk@>
Small English spelling correction in all files.
Wed Jul 5 13:28:45 CEST 2000 Werner Koch <wk@>
Wed Jul 5 13:28:45 CEST 2000 Werner Koch <wk@openit.de>
* fr.po: Minor changes by Gael

1388
po/ja.po

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,29 @@
2000-11-11 Paul Eggert <eggert@twinsun.com>
* iobuf.c (iobuf_get_filelength): Now returns off_t, not u32.
Remove kludges to worry about large files; the callers check
for files that are too large, and they should already be doing
the right thing in an implementation-independent way.
(fopen, fstat): Remove macros.
* iobuf.c (iobuf_set_limit, iobuf_tell, iobuf_seek):
Use off_t, not ulong, for file offsets.
(<limits.h>): Include if needed.
(LONG_MAX, LONG_MIN): Define a substitute if needed.
(fseeko): Define a substitute if needed.
* iobuf.c (iobuf_seek): Do not use %lu to report file
2000-11-09 Werner Koch <wk@gnupg.org>
* iobuf.c (iobuf_enable_special_filenames): New.
(check_special_filename): New.
(iobuf_open): check for special filenames.
(iobuf_create): Ditto.
2000-10-23 Werner Koch <wk@gnupg.org>
* secmem.c (lock_pool): Don't print warnbing for Windows.
* secmem.c (lock_pool): Don't print warning for Windows.
2000-10-16 Werner Koch <wk@gnupg.org>

View File

@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -35,11 +36,6 @@
#include "util.h"
#include "iobuf.h"
#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64)
#define fopen(a,b) fopen64 ((a),(b))
#define fstat(a,b) fstat64 ((a),(b))
#endif
typedef struct {
FILE *fp; /* open file handle */
@ -65,6 +61,7 @@ typedef struct {
int eof;
} block_filter_ctx_t;
static int special_names_enabled;
static int underflow(IOBUF a);
@ -573,6 +570,32 @@ iobuf_temp_with_content( const char *buffer, size_t length )
return a;
}
void
iobuf_enable_special_filenames ( int yes )
{
special_names_enabled = yes;
}
/*
* see whether the filename has the for "-&nnnn", where n is a
* non-zero number.
* Returns this number or -1 if it is not the case.
*/
static int
check_special_filename ( const char *fname )
{
if ( special_names_enabled
&& fname && *fname == '-' && fname[1] == '&' ) {
int i;
fname += 2;
for (i=0; isdigit (fname[i]); i++ )
;
if ( !fname[i] )
return atoi (fname);
}
return -1;
}
/****************
* Create a head iobuf for reading from a file
@ -586,6 +609,7 @@ iobuf_open( const char *fname )
file_filter_ctx_t *fcx;
size_t len;
int print_only = 0;
int fd;
if( !fname || (*fname=='-' && !fname[1]) ) {
fp = stdin;
@ -595,6 +619,8 @@ iobuf_open( const char *fname )
fname = "[stdin]";
print_only = 1;
}
else if ( (fd = check_special_filename ( fname )) != -1 )
return iobuf_fdopen ( fd, "rb" );
else if( !(fp = fopen(fname, "rb")) )
return NULL;
a = iobuf_alloc(1, 8192 );
@ -655,6 +681,7 @@ iobuf_create( const char *fname )
file_filter_ctx_t *fcx;
size_t len;
int print_only = 0;
int fd;
if( !fname || (*fname=='-' && !fname[1]) ) {
fp = stdout;
@ -664,6 +691,8 @@ iobuf_create( const char *fname )
fname = "[stdout]";
print_only = 1;
}
else if ( (fd = check_special_filename ( fname )) != -1 )
return iobuf_fdopen ( fd, "wb" );
else if( !(fp = fopen(fname, "wb")) )
return NULL;
a = iobuf_alloc(2, 8192 );
@ -686,6 +715,7 @@ iobuf_create( const char *fname )
/****************
* append to an iobuf; if the file does not exist, create it.
* cannot be used for stdout.
* Note: This is not used.
*/
IOBUF
iobuf_append( const char *fname )
@ -1298,7 +1328,7 @@ iobuf_flush_temp( IOBUF temp )
* Setting the limit to 0 disables this feature.
*/
void
iobuf_set_limit( IOBUF a, unsigned long nlimit )
iobuf_set_limit( IOBUF a, off_t nlimit )
{
if( nlimit )
a->nofast |= 1;
@ -1314,25 +1344,16 @@ iobuf_set_limit( IOBUF a, unsigned long nlimit )
/****************
* Return the length of an open file
*/
u32
off_t
iobuf_get_filelength( IOBUF a )
{
#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64)
struct stat64 st;
#else
struct stat st;
#endif
if( a->directfp ) {
FILE *fp = a->directfp;
if( !fstat(fileno(fp), &st) ) {
#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64)
if( st.st_size >= IOBUF_FILELENGTH_LIMIT )
return IOBUF_FILELENGTH_LIMIT;
#endif
return (u32)st.st_size;
}
if( !fstat(fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
return 0;
}
@ -1343,13 +1364,8 @@ iobuf_get_filelength( IOBUF a )
file_filter_ctx_t *b = a->filter_ov;
FILE *fp = b->fp;
if( !fstat(fileno(fp), &st) ) {
#if defined (HAVE_FOPEN64) && defined (HAVE_FSTAT64)
if( st.st_size >= IOBUF_FILELENGTH_LIMIT )
return IOBUF_FILELENGTH_LIMIT;
#endif
if( !fstat(fileno(fp), &st) )
return st.st_size;
}
log_error("fstat() failed: %s\n", strerror(errno) );
break;
}
@ -1360,27 +1376,55 @@ iobuf_get_filelength( IOBUF a )
/****************
* Tell the file position, where the next read will take place
*/
ulong
off_t
iobuf_tell( IOBUF a )
{
return a->ntotal + a->nbytes;
}
#if !defined(HAVE_FSEEKO) && !defined(fseeko)
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long) ((unsigned long) -1 >> 1))
#endif
#ifndef LONG_MIN
# define LONG_MIN (-1 - LONG_MAX)
#endif
/****************
* A substitute for fseeko, for hosts that don't have it.
*/
static int
fseeko( FILE *stream, off_t newpos, int whence )
{
while( newpos != (long) newpos ) {
long pos = newpos < 0 ? LONG_MIN : LONG_MAX;
if( fseek( stream, pos, whence ) != 0 )
return -1;
newpos -= pos;
whence = SEEK_CUR;
}
return fseek( stream, (long)newpos, whence );
}
#endif
/****************
* This is a very limited implementation. It simply discards all internal
* buffering and removes all filters but the first one.
*/
int
iobuf_seek( IOBUF a, ulong newpos )
iobuf_seek( IOBUF a, off_t newpos )
{
file_filter_ctx_t *b = NULL;
if( a->directfp ) {
FILE *fp = a->directfp;
if( fseek( fp, newpos, SEEK_SET ) ) {
log_error("can't seek to %lu: %s\n", newpos, strerror(errno) );
if( fseeko( fp, newpos, SEEK_SET ) ) {
log_error("can't seek: %s\n", strerror(errno) );
return -1;
}
clearerr(fp);
@ -1394,8 +1438,8 @@ iobuf_seek( IOBUF a, ulong newpos )
}
if( !a )
return -1;
if( fseek( b->fp, newpos, SEEK_SET ) ) {
log_error("can't seek to %lu: %s\n", newpos, strerror(errno) );
if( fseeko( b->fp, newpos, SEEK_SET ) ) {
log_error("can't seek: %s\n", strerror(errno) );
return -1;
}
}