diff --git a/.gitignore b/.gitignore index 04335fa09..63b8c14ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,135 +1,136 @@ Makefile.in aclocal.m4 autom4te.cache/ configure config.h.in config.h config.log config.status common/audit-events.h common/status-codes.h doc/gnupg.info* doc/stamp-vti doc/version.texi po/gnupg2.pot po/POTFILES stamp-h1 Makefile .deps/ keyserver/gpg2keys_mailto keyserver/gpg2keys_test tools/gpg-zip # Files created by make when not using a VPATH build *.o po/en@boldquot.insert-header po/en@boldquot.po po/en@quot.insert-header po/en@quot.po po/stamp-po agent/gpg-agent agent/gpg-preset-passphrase agent/gpg-protect-tool agent/t-protect common/libcommon.a common/libcommonpth.a common/libgpgrl.a common/libsimple-pwquery.a common/t-b64 common/t-convert common/t-exechelp common/t-gettime common/t-helpfile common/t-percent common/t-session-env common/t-sexputil common/t-sysutils doc/FAQ doc/addgnupghome.8 doc/applygnupgdefaults.8 doc/faq.html doc/faq.raw.xref doc/gnupg-card-architecture.eps doc/gnupg-card-architecture.pdf doc/gnupg-card-architecture.png doc/gnupg.7 doc/gpg-agent.1 doc/gpg-connect-agent.1 doc/gpg-preset-passphrase.1 doc/gpg-zip.1 doc/gpg2.1 doc/gpgconf.1 doc/gpgparsemail.1 doc/gpgsm-gencert.sh.1 doc/gpgsm.1 doc/gpgv2.1 doc/scdaemon.1 doc/symcryptrun.1 doc/watchgnupg.1 doc/yat2m doc/yat2m-stamp g10/gpg2 g10/gpgv2 g10/t-rmd160 gl/alloca.h gl/libgnu.a jnlib/libjnlib.a jnlib/t-stringhelp kbx/kbxutil kbx/libkeybox.a keyserver/gpg2keys_curl keyserver/gpg2keys_finger keyserver/gpg2keys_hkp keyserver/gpg2keys_kdns keyserver/gpg2keys_ldap scd/gnupg-pcsc-wrapper scd/scdaemon sm/gpgsm tests/asschk tests/gpg-agent.conf tests/gpgsm.conf tests/inittests.stamp tests/openpgp/data-32000 tests/openpgp/data-500 tests/openpgp/data-80000 tests/openpgp/data-9000 tests/openpgp/gpg-agent.conf tests/openpgp/gpg_dearmor tests/openpgp/plain-1 tests/openpgp/plain-2 tests/openpgp/plain-3 tests/openpgp/plain-large tests/openpgp/prepared.stamp tests/openpgp/pubring.gpg tests/openpgp/pubring.pkr tests/openpgp/secring.gpg tests/openpgp/secring.skr tests/pkits/ReadMe.txt tests/pkits/certpairs/ tests/pkits/certs/ tests/pkits/crls/ tests/pkits/gpg-agent.conf tests/pkits/gpgsm.conf tests/pkits/inittests.stamp tests/pkits/pkcs12/ tests/pkits/pkits.ldif tests/pkits/pkits.schema tests/pkits/policies.txt tests/pkits/smime/ tests/pkits/testdir.stamp tests/pkits/trustlist.txt tests/private-keys-v1.d/ tests/pubring.kbx tests/testdir.stamp tests/trustlist.txt tools/clean-sat tools/gpg-check-pattern tools/gpg-connect-agent tools/gpgconf tools/gpgkey2ssh tools/gpgparsemail tools/gpgsplit tools/make-dns-cert tools/mk-tdata tools/symcryptrun tools/watchgnupg +tools/gpgtar diff --git a/ChangeLog b/ChangeLog index bd265b60c..f7564631a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,1183 +1,1186 @@ 2011-01-11 Werner Koch + * configure.ac: Add option --enable-gpgtar. + (AC_CHECK_FUNCS): Add stat. + * autogen.sh : Remove superfluous --without-included-gettext. 2011-01-10 Werner Koch * configure.ac: Support a git_revision string. 2010-07-19 Werner Koch Release 2.0.16. * configure.ac: Require libgpg-error 1.7 and libksba 1.0.7 to force building with more recent versions. 2010-05-04 Werner Koch * configure.ac: Add option --enable-standard-socket. 2010-03-09 Werner Koch Release 2.0.15. * configure.ac: Add option --disable-ccid-driver. 2010-02-18 Werner Koch Release 2.0.15rc1. * configure.ac: Remove double check for libassuan. 2010-02-11 Marcus Brinkmann From trunk 2009-10-16: * configure.ac: Check for libassuan instead of libassuan-pth. 2009-10-12 Werner Koch From trunk 2009-09-23: * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Update to new API (2, 1.1.0). 2009-12-21 Werner Koch Release 2.0.14. 2009-12-08 Werner Koch * configure.ac (USE_DNS_CERT): Support via ADNS. 2009-12-07 Werner Koch * configure.ac: Check for ADNS before checking for the BIND resolver. (USE_ADNS): Fallback macro for PKA and CERT lookups. 2009-09-04 Werner Koch Release 2.0.13. 2009-06-29 Werner Koch * configure.ac: Take care of --without-adns. Suggested by Arfrever Frehtes Taifersar Arahesis. 2009-06-17 Werner Koch Release 2.0.12. 2009-06-05 David Shaw * configure.ac: Remove Camellia restriction. 2009-04-01 Werner Koch * configure.ac: Test for fsync. 2009-03-18 Werner Koch * configure.ac: Test for getrlimit. 2009-03-03 Werner Koch Release 2.0.11. 2009-01-12 Werner Koch Release 2.0.10. 2008-12-09 Werner Koch Release 2.0.10rc1. 2008-10-17 Werner Koch * configure.ac: Use more warning options with modern GCCs. 2008-09-29 Werner Koch * configure.ac: Require libgcrypt 1.4. 2008-08-27 David Shaw * configure.ac: Use printf for the most portable SVN version detection. * configure.ac: Darwin's /bin/sh has a builtin echo that doesn't understand '-n'. Use tr to trim the carriage return instead. 2008-04-23 Werner Koch * configure.ac: Call gl_HEADER_SYS_SOCKET and gl_TYPE_SOCKLEN_T. 2008-04-07 Werner Koch * configure.ac (ADNSLIBS): Test for adns. (GPGKEYS_KDNS): New. 2008-04-01 Werner Koch * configure.ac: Require curl 7.10 (Oct 1 2002) or later as we use curl_version_info(). (AC_INIT): Fix quoting. 2008-03-27 Werner Koch * Makefile.am (dist_doc_DATA): New. Install README. 2008-03-26 Werner Koch Release 2.0.9. 2008-02-19 Werner Koch * configure.ac: Remove --with-pkits-tests. 2008-02-15 Werner Koch * gl/allocsa.h, gl/m4/allocsa.m4: Replace HAVE_LONG_LONG by HAVE_LONG_LONG_INT. 2008-02-15 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.17. 2007-12-20 Werner Koch Released 2.0.8. 2007-12-17 Werner Koch * configure.ac: Add treatment for HAVE_LDAP_START_TLS_SA. 2007-12-14 Werner Koch Released 2.0.8rc1. 2007-12-12 Werner Koch * configure.ac (USE_CAMELLIA): Define by new option --enable-camellia. 2007-12-03 Werner Koch * configure.ac: Add test gt_LC_MESSAGES.. 2007-10-01 Werner Koch * configure.ac: Require assuan 1.0.4. 2007-09-14 Werner Koch * configure.ac (GNUPG_LIBASSUAN_VERSION): New. 2007-09-10 Werner Koch Released 2.0.7. 2007-08-27 Werner Koch * configure.ac: Remove remaining support for internal regex. Define DISABLE_REGEX automake conditional. Add option --with-regex. * autogen.sh [--build-w32]: Remove --disable-regex. Use --with-regex. 2007-08-16 Werner Koch Released 2.0.6. 2007-08-08 Werner Koch * configure.ac: Use AC_CANONICAL_HOST and not AC_CANONICAL_TARGET. 2007-07-09 Werner Koch * configure.ac (AM_ICONV): Check for it even when building without NLS. 2007-07-05 Werner Koch Released 2.0.5. * configure.ac: Require libassuan 1.0.2. 2007-07-05 Marcus Brinkmann * configure.ac: Invoke AM_LANGINFO_CODESET. 2007-07-04 Werner Koch * Makefile.am (AUTOMAKE_OPTIONS): Add no-dist-gzip. Switched entire package to GPLv3+. * configure.ac: Require libksba 1.0.2. * COPYING: Updated to GPLv3. * COPYING.LIB: New as jnlib/ uses this license. * gl/: Switched to GPLv3+. * intl/ Removed. * configure.ac (AM_GNU_GETTEXT): Add external flag. (AM_ICONV): New. 2007-07-03 Werner Koch * configure.ac [W32]: Use ws2_32 instead of wsock32. 2007-06-25 Werner Koch * gl/mkdtemp.c (gen_tempname) [MKDIR_TAKES_ONE_ARG]: Avoid compiler warning by using the proper config macro. 2007-06-15 Werner Koch * configure.ac: Call AM_PO_SUBDIRS. (W32SOCKLIBS): New. * autogen.sh: Use = and not == in test to be POSIXly correct. : Disable use of regex. 2007-06-14 Werner Koch * configure.ac [AH_BOTTOM]: Remove the hardwired names of modules. 2007-06-12 Werner Koch * configure.ac [AH_BOTTOM]: Define HTTP_NO_WSASTARTUP. 2007-06-11 Werner Koch * am/cmacros.am (libcommonstd, libcommonpth, libcommonstd_ldadd) (libcommonpth_ldadd): Add macros. 2007-06-06 Werner Koch * configure.ac: Add a few notices message so make browsing of the log file easier. (CC_FOR_BUILD): New. 2007-05-30 Werner Koch * configure.ac [W32]: Do not create a symlink to w32-pth.h. Require the installation of the w32pth package. 2007-05-29 Werner Koch * gl/: Updated to a newer version. 2007-05-24 Werner Koch * configure.ac: Use -Wpointer-arith is possible. 2007-05-15 Werner Koch * configure.ac: Renamed the estream macros. Remove -Wformat-nonliteral. * configure.ac: Call ESTREAM_INIT and define the memory allocators for estream_asprintf. (gl_MODULES): Remove vasprintf. 2007-05-09 Werner Koch Released 2.0.4. 2007-05-07 Werner Koch * configure.ac: Require libgcrypt 1.2.2 to avoid compiler warnings. 2007-05-07 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.16.1. 2007-05-07 Werner Koch * configure.ac: Bail out if no C-89 compiler has been found. 2007-05-04 Werner Koch * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add --enable-mailto * configure.ac: Require automake 1.10 (AC_CONFIG_FILES): Rename gpgkeys_ to gpg2keys_. (AM_PROG_CC_C_O): New. 2007-03-08 Werner Koch Released 2.0.3. * autogen.sh: Add option --force. 2007-01-31 Werner Koch Released 2.0.2. 2006-11-30 Werner Koch * configure.ac: Save original LIBS when testing for dlopen. 2006-11-28 Werner Koch Released 2.0.1. 2006-11-23 Werner Koch Released 2.0.1rc1. 2006-11-21 Werner Koch * configure.ac [AH_BOTTOM]: Disable PTH soft mapping. (AC_CHECK_SIZEOF): Check for time_t. (BUILD_INCLUDED_LIBINTL): Remove AM_PO_SUBDIRS as it is not required for C. 2006-11-15 Werner Koch * autogen.sh: Add convenience option --build-amd64. 2006-11-14 Werner Koch * configure.ac (HAVE_ASSUAN_SET_IO_MONITOR): Test for it. 2006-11-11 Werner Koch Released 2.0.0. 2006-11-06 Werner Koch Released 1.9.95. 2006-11-03 Werner Koch * configure.ac: Test for pty.h. From Gentoo. 2006-10-24 Werner Koch Released 1.9.94. 2006-10-20 Werner Koch * Makefile.am (stowinstall): Add convenience target. 2006-10-18 Werner Koch * configure.ac: svn revison magic fixes for old bashs. Suggested by Alain Guibert. 2006-10-18 Werner Koch Released 1.9.93. 2006-10-17 Werner Koch * autogen.sh <--build-w32>: Test also for a host "mingw32". * configure.ac: Removed W32LIBS. Use NETLIBS instead. 2006-10-11 Werner Koch Released 1.9.92. * configure.ac: Require libassuan 0.9.3. 2006-10-09 Werner Koch * acinclude.m4: Moved pth check to m4/gnupg-pth.m4. 2006-10-06 Werner Koch * configure.ac: Also check for libassuan's pth version. 2006-10-04 Werner Koch Released 1.9.91. * configure.ac: Require libassuan 0.9.1 which fixes a problem with gpgsm. 2006-09-27 Werner Koch * gl/strsep.h, gl/strsep.c, gl/m4/strsep.m4: Removed. * gl/strpbrk.h, gl/strpbrk.c, gl/m4/strpbrk.m4: Removed. * gl/Makefile.am: Removed module strsep and strpbrk. * configure.ac: Check for strsep in the context of jnlib. Remove check from gl_MODULES. Moved check for timegm into the jnlib context. 2006-09-27 Marcus Brinkmann * Makefile.am: Fix cut & paste error. 2006-09-25 Werner Koch Released 1.9.90. 2006-09-22 Werner Koch * AUTHORS: Add information about used licenses. 2006-09-20 Werner Koch * Makefile.am (dist-hook): Removed distfiles cruft. (SUBDIRS): Added include 2006-09-18 Werner Koch Released 1.9.23. * configure.ac (--enable-agent-only): Donot build tools and doc (--disable-tools,--disable-doc): New. * Makefile.am (SUBDIRS): Allow to conditional build tools and doc. 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * configure.ac: Build gpg by default. (GNUPG_SYS_SO_PEERCRED): Removed. 2006-09-13 Werner Koch * autogen.sh: Better detection of the cross compiler kit. 2006-09-06 Marcus Brinkmann * configure.ac: New automake conditional RUN_GPG_TESTS. 2006-09-06 Werner Koch * configure.ac: Define _ASSUAN_ONLY_GPG_ERRORS. Require Assuan 0.9 and libgpg-error 1.4 2006-08-31 Werner Koch * configure.ac: Require libksba 1.0 and added API check for it. (GPG_ERR_LOCKED): Removed DECL check as we require 1.2 anyway. (have_libusb): New to give a feedback about CCID support 2006-08-21 Werner Koch * configure.ac: Removed docbook tests. (AC_CONFIG_FILES): Added gpgkeys_test and gpgkeys_mailto. * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Enable gpg. 2006-08-17 Werner Koch * THANKS: Merged with the 1.4 one. 2006-08-16 Werner Koch * configure.ac: Removed test for capabilities and mlock. 2006-08-15 Werner Koch * Makefile.am (keyserver): Enable building of keyserver helpers. * configure.ac: Merged with the current configure from 1.4.5. Require libgpg-error 1.2 and libksba 0.9.16. 2006-07-29 Marcus Brinkmann * README: Spelling fixes. 2006-07-27 Werner Koch Released 1.9.22. * configure.ac: Call AB_INIT. 2006-07-03 Werner Koch * configure.ac: Test for ksba_dn_teststr. 2006-06-30 Werner Koch * keyserver/: New. Taken from 1.4.4 * Makefile.am (SUBDIRS): Include keyserver/. * configure.ac: Include keyserver/. (FAKE_CURL, GPGKEYS_CURL): New. 2006-06-20 Werner Koch Released 1.9.21. 2006-06-08 Marcus Brinkmann * configure.ac (PTH_LIBS): Add --all to pth-config invocation. 2006-05-24 Werner Koch * configure.ac: New option --disable-optimization taked from 1.4.3. 2006-05-23 Werner Koch * configure.ac (ZLIBS): New for zlib link commands. Add bzip2 support. 2006-05-22 Werner Koch * configure.ac (EXEEXT): New. 2006-04-18 Werner Koch * configure.ac (PK_UID_CACHE_SIZE): New. 2006-04-07 Werner Koch * configure.ac: Use new method to include the SVN revison. Now it is the actual global revision number. 2005-12-20 Werner Koch Released 1.9.20. 2005-11-28 Werner Koch * configure.ac: Append the revision to the version string. 2005-11-13 Werner Koch * am/cmacros.am (-DGNUPG_SYSCONFDIR): Define it. 2005-11-11 Werner Koch * configure.ac (NEED_KSBA_VERSION: Require 0.9.13. 2005-09-12 Werner Koch Released 1.9.19. 2005-08-01 Werner Koch Released 1.9.18. * configure.ac: Require libksba 0.9.12 to match new features in gpgsm. 2005-06-20 Werner Koch Released 1.9.17. 2005-06-02 Werner Koch * configure.ac (HAVE_PTH): Define as alias for USE_GNU_PTH. It is used by common/estream.c. 2005-06-01 Werner Koch * configure.ac (gl_INIT): Add gnulib stuff. (fseeko, ftello, ttyname, isascii): Replaced the AC_REPLACE_FUNCS by a simple check. (putc_unlocked): Removed check. Not used. (strsep, mkdtemp, asprintf): Replaced checks by gnulib checks. (xsize): Added will probably come handy soon. (CFLAGS): Use -Wformat-security instead of -Wformat-nonliteral. Add --Wno-format-y2k. * gl/, gl/m4/: New. 2005-05-15 Werner Koch * configure.ac: Remove option --disable-threads; require the use of GNU Pth. 2005-04-27 Werner Koch * configure.ac: Removed OpenSC detection and options. * acinclude.m4: Ditto. 2005-04-21 Werner Koch Released 1.9.16. * configure.ac: Do not build gpg by default. 2005-04-20 Werner Koch * configure.ac: Test whether GPG_ERR_LOCKED is declared and provide a replacement if not. 2005-04-15 Werner Koch * configure.ac: Require libksba 0.9.11. 2005-04-15 Marcus Brinkmann * configure.ac: Check for /usr/bin/shred and define SHRED. * configure.ac: Add --enable-symcryptrun, disabled by default. Define automake variable BUILD_SYMCRYPTRUN. Check for openpty -lutil, define LIBUTIL_LIBS. 2005-03-03 Werner Koch * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Accidently used --ldflags instead of --cflags. Reported by Kazu Yamamoto. 2005-02-03 Werner Koch * AUTHORS: Copied from 1.4 and edited to refelct the changes in 1.9. 2005-01-17 Werner Koch * configure.ac: Make --without-included-regex work as expected. Fixed FTP location info for some libraries. 2005-01-13 Werner Koch Released 1.9.15. * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Link a simple test program to see whether the installation is sane. 2005-01-07 Werner Koch * configure.ac: Require gpg-error 1.0. 2005-01-04 Werner Koch * configure.ac: Remove hack not to build gpg2 for W32. * autogen.sh : Pass option --disable-gpg instead. 2004-12-22 Werner Koch Released 1.9.14. 2004-12-20 Werner Koch * configure.ac: Add PATHSEP_C and PATHSEP_S. For W32 let all directories default to c:/gnupg. Require libassuan 0.6.9. 2004-12-18 Werner Koch * configure.ac (AH_BOTTOM): Define EXEEXT_S. * autogen.sh: Updated --build-w32 feature. 2004-12-15 Werner Koch * Makefile.am (SUBDIRS) [W32]: Do not build in tests/. * acinclude.m4: Add proper macro name quoting for use with automake 1.9. * configure.ac: Add replacement check for ttyname. Removed support for a included zlib. 2004-12-06 Werner Koch * configure.ac (have_w32_system): New. Disable Pth checks for W32. Link jnlib/w32-pth.h to pth.h. 2004-12-03 Werner Koch Released 1.9.13. 2004-11-26 Werner Koch * configure.ac: Replace strsep. Replaced use of "target" by "host". 2004-10-22 Werner Koch Released 1.9.12. * Makefile.am (AUTOMAKE_OPTIONS): Set option to create bzip2 tarball. 2004-10-01 Werner Koch Released 1.9.11. 2004-09-30 Werner Koch * README: Minor updates. 2004-09-30 gettextize * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.14.1. 2004-08-16 Werner Koch * configure.ac: Build Makefile for tests/pkits. New option --with-pkits-tests. 2004-08-05 Werner Koch * configure.ac: Changed tests for libusb to also suuport the stable version 0.1.x. 2004-07-22 Werner Koch Released 1.9.10. * configure.ac: Define AM conditional HAVE_OPENSC. 2004-07-21 Werner Koch * configure.ac: Don't set DIE to no after it might has been set to yes. 2004-07-20 Werner Koch * Makefile.am (sm): Build kbx only if gpgsm is to be build. 2004-07-20 Werner Koch * configure.ac: New option --enable-agent-only. 2004-06-08 Werner Koch Released 1.9.9. 2004-06-06 Werner Koch * configure.ac: Require libksba 0.9.7. 2004-04-29 Werner Koch Released 1.9.8. 2004-04-20 Werner Koch * configure.ac: Remove the fopencookie test. We don't need the dummy function because we conditionally use fopencookie, fpencookie or a replacement at place. 2004-04-02 Thomas Schwinge * autogen.sh: Added ACLOCAL_FLAGS. 2004-04-06 Werner Koch Released 1.9.7. * configure.ac: Require libgcrypt 1.1.94. Introduce PACKAGE_GT and set it to gnupg2. 2004-03-23 Werner Koch * configure.ac: Define SAFE_VERSION_DASH and SAFE_VERSION_DOT. 2004-03-09 Werner Koch * configure.ac (NEED_GPG_ERROR_VERSION): Set to 0.7. 2004-03-06 Werner Koch Released 1.9.6. * configure.ac: Check the Libgcrypt API. 2004-02-25 Werner Koch * configure.ac: New option --disable-threads to inhibit unintentional builds without Pth. 2004-02-21 Werner Koch Released 1.9.5. 2004-02-20 Werner Koch * configure.ac: Fixed URLs in the notice messages. 2004-02-18 Werner Koch * acinclude.m4: Removed macros to detect gpg-error, libgcrypt, libassuan and ksba as they are now distributed in m4/. 2004-02-13 Werner Koch * configure.ac: Require libksba 0.9.4 and libgcrypt 1.1.92. 2004-02-12 Werner Koch * autogen.sh: Removed cruft from debugging. * am/cmacros.am: New. 2004-02-11 Werner Koch * configure.ac: Removed the need for g10defs.h. Reworked the --with-foo-pgm stuff. * autogen.sh (check_version): Removed bashism and simplified. * acinclude.m4 (AM_PATH_OPENSC): Kludge to avoid error output for a bad opensc-config. 2004-01-30 Werner Koch Released 1.9.4. * configure.ac: Require libksba 0.9.3 due to another bug fix there. 2004-01-29 Werner Koch * README: Updated. * configure.ac: Require libksba 0.9.2 due to bug fixes. 2004-01-24 Werner Koch * configure.ac: Now requires libassuan 0.6.3. 2003-12-23 Werner Koch Released 1.9.3. * README-alpha: Removed. * configure.ac, Makefile.am: Add the tests and tools directories. 2003-12-19 Werner Koch * configure.ac: Now require libgcrypt 1.1.91 to help testing the latest libgcrypt changes. Requires libksab 0.9.1. 2003-12-17 Werner Koch * configure.ac: Requires now libassuan 0.6.2. (CFLAGS): Add --Wformat-noliteral in gcc mode. 2003-12-16 Werner Koch * configure.ac: Check for funopen and fopencookie as part of the jnlib checks. 2003-12-09 Werner Koch * configure.ac: Add a min_automake_version. * README.CVS: New. * autogen.sh: Revamped except for the --build-w32 hack. * Makefile.am: Add README.CVS 2003-11-17 Werner Koch Release 1.9.2. * configure.ac: Requires now libassuan 0.6.1. 2003-10-31 Werner Koch * configure.ac (NEED_KSBA_VERSION): Set to 0.9.0 due the changed time interface. 2003-10-21 Werner Koch * configure.ac (PRINTABLE_OS_NAME): Remove special case for The Hurd; Robert Millan reported that the uname test is now sufficient. 2003-10-01 Werner Koch * configure.ac (AH_BOTTOM): Define GNUPG_MAJOR_VERSION. 2003-09-23 Werner Koch Merged most of David Shaw's changes in 1.3 since 2003-06-03. * configure.ac: Drop all TIGER/192 support. (uint64_t): Check for UINT64_C to go along with uint64_t. (getaddrinfo): Check for it. (sigset_t): Check for sigset_t and struct sigaction. This is for Forte c89 on Solaris which seems to define only the function call half of the two pairs by default. (W32LIBS): Include wsock32 in W32LIBS. This is different from NETLIBS so we don't need to force other platforms to pull in the netlibs when they aren't actually needed. 2003-09-06 Werner Koch Released 1.9.1. * configure.ac: Require newer versions of some libraries. 2003-09-02 Werner Koch * configure.ac (HAVE_LIBUSB): Added a simple test for libusb. 2003-08-19 Marcus Brinkmann * configure.ac (AM_PATH_GPG_ERROR): Add missing comma in invocation. 2003-08-06 Werner Koch * configure.ac: Check for libgpg-error. Print infos about missing libraries more nicely. * acinclude.m4 (AM_PATH_GPG_ERROR): Added. 2003-08-05 Werner Koch Released 1.9.0. * configure.ac (GNUPG_DEFAULT_HONMEDIR): Changed back to ~/.gnupg. 2003-07-31 Werner Koch * Makefile.am (DISTCLEANFILES): Add g10defs.h 2003-06-18 Werner Koch * configure.ac (GNUPG_DEFAULT_HOMEDIR): Changed temporary to .gnupg2 to avoid accidential use with production keys. 2003-06-11 Werner Koch * configure.ac: Merged all stuff from current 1.3 version in. * acinclude.m4: Merged required macros from current 1.2 version in. 2003-06-04 Werner Koch * configure.ac, Makefile.am: Enable building of gpg. 2003-04-29 Werner Koch * configure.ac: Build a limited version of scdaemon if libopensc is not available. * configure.ac (ALL_LINUGAS): Removed. * Makefile.am (ACLOCAL_AMFLAGS): New. * configure.ac (AM_GNU_GETTEXT_VERSION): New. Set to 0.11.5. 2003-04-29 gettextize * Makefile.am (SUBDIRS): Add m4. (ACLOCAL_AMFLAGS): New variable. (EXTRA_DIST): Add scripts/config.rpath. * configure.ac (AC_CONFIG_FILES): Add m4/Makefile. 2003-04-29 Werner Koch * assuan/ : Removed. We now use libassuan. * Makefile.am (SUBDIRS): Removed assuan * configure.ac: Check for libassuan. 2003-01-09 Werner Koch * configure.ac (GNUPG_PROTECT_TOOL): New option --with-protect-tool. (NEED_KSBA_VERSION): Does now require 0.4.6. * README: Noted where to find gpg-protect-tool. 2002-10-31 Neal H. Walfield * configure.ac: Check for flockfile and funlockfile. Check for isascii and putc_unlocked replacing them if not found. * configure.ac (PTH_LIBS): If pth is found, add the output of `$PTH_CONFIG --ldflags`, not just `$PTH_CONFIG --libs`. 2002-10-19 Werner Koch * configure.ac: Bumped version number to 1.9.0-cvs. NewPG (Aegypten project) to GnuPG merge. 2002-09-20 Werner Koch Released 0.9.2. 2002-09-05 Neal H. Walfield * configure.ac: Check for makeinfo. 2002-09-03 Neal H. Walfield * autogen.sh (have_version): New function. Generalize and simplify logic for finding and determining the versions of GNU programs. Use it. 2002-08-23 Werner Koch Released 0.9.1. * acinclude.m4 (AM_PATH_LIBGCRYPT): Updated from Libgcrypt. (AM_PATH_OPENSC): Strip non-digits from the micro version. 2002-08-21 Werner Koch Released 0.9.0. * configure.ac: Changed the default homedir to .gnupg. * README-alpha: Removed. 2002-08-19 Werner Koch * acinclude.m4: Removed -lpcsclite from KSBA_LIBS; copy+paste bug. 2002-08-13 Werner Koch * acinclude.m4 (AM_PATH_OPENSC, AM_PATH_KSBA): New. * configure.ac: Use them. 2002-08-10 Werner Koch Released 0.3.10. * configure.ac (NEED_LIBKSBA_VERSION): Require 0.4.4. Add support for gettext. 2002-07-22 Werner Koch * configure.ac: Check for ftello and provide a replacement. 2002-07-01 Werner Koch Released 0.3.9. * README: Short note on how to export in pkcs-12 format. 2002-06-29 Werner Koch * configure.ac: Define --with options to set the default location of the agent, scdaemon, pinentry and dirmngr. 2002-06-27 Werner Koch * README: Short blurb on how to import a PKCS-12 file. * configure.ac (AH_BOTTOM): New to define some constants. 2002-06-25 Werner Koch Released 0.3.8. * configure.ac (NEED_LIBGCRYPT_VERSION): Set to 1.1.8. 2002-06-12 Werner Koch * configure.ac (NEED_LIBKSBA_VERSION): We need 0.4.3 now. 2002-06-04 Werner Koch Released 0.3.7. 2002-05-21 Werner Koch * configure.ac: We now require libgcrypt 1.1.7 and libksba 0.4.2. 2002-05-14 Werner Koch * doc/: New * configure.ac, Makefile.am: Added doc/ 2002-05-03 Werner Koch Released 0.3.6. 2002-04-25 Werner Koch * configure.ac: Check for setlocale. 2002-04-24 Marcus Brinkmann * configure.ac: Check for locale.h. 2002-04-15 Werner Koch Released 0.3.5. * NEWS: Started to describe release notes. * configure.ac (NEED_LIBKSBA_VERSION, NEED_LIBGCRYPT_VERSION): Defined 2002-04-01 Werner Koch Released 0.3.4. 2002-03-18 Werner Koch Released 0.3.3. 2002-03-08 Werner Koch * README: Add some explanation on how to specify a user ID. 2002-03-06 Werner Koch Released 0.3.2. 2002-03-04 Werner Koch Released 0.3.1. * README: Explained some options and files. 2002-02-14 Werner Koch * configure.ac: Fixed status messages related to presence of Pth. 2002-02-13 Werner Koch * acinclude.m4 (GNUPG_SYS_SO_PEERCRED): New. * configure.ac: use it. 2002-02-12 Werner Koch * configure.ac: Check for PTH. Provide replacement fucntions for apsrintf and fopencookie. * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): New. 2002-02-07 Werner Koch Released 0.3.0. * configure.ac: Require libgcrypt 1.1.6. 2002-02-01 Marcus Brinkmann * configure.ac (KSBA_CONFIG): Remove superfluous x in front of variable. 2002-01-26 Werner Koch * configure.ac: Add options to disable the build of some programs and print a configure status at the end. * acinclude.m4 (GNUPG_BUILD_PROGRAM): New. * scd/ : New. Added to Makefile and configure. * configure.ac: Check for libopensc * Makefile.am: Build scd only when libopensc is available 2002-01-23 Werner Koch * configure.ac (mkdtemp): See whether we have to provide a replacement. 2001-12-18 Werner Koch Released 0.0.0. 2001-12-17 Werner Koch * acinclude.m4: Add AM_PATH_LIBGCRYPT macro. * configure.ac: and use it here. Figure out the location of libksba 2001-12-15 Werner Koch * configure.ac (missing_dir): Bail out if asprintf and fopencookie are not available. 2001-12-04 Werner Koch * configure.ac (HAVE_JNLIB_LOGGING): always define it. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009) 2010 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/Makefile.am b/Makefile.am index ecc325797..103375a18 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,86 +1,86 @@ # Makefile.am - main makefile for NewPG/GnuPG # Copyright (C) 2001, 2004 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 # along with this program; if not, see . ## Process this file with automake to produce Makefile.in ACLOCAL_AMFLAGS = -I m4 -I gl/m4 AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip -DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto +DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto --enable-gpgtar EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN DISTCLEANFILES = g10defs.h if BUILD_GPGSM kbx = kbx else kbx = endif if BUILD_GPG gpg = g10 keyserver = keyserver else gpg = keyserver = endif if BUILD_GPGSM sm = sm else sm = endif if BUILD_AGENT agent = agent else agent = endif if BUILD_SCDAEMON scd = scd else scd = endif if BUILD_TOOLS tools = tools else tools = endif if BUILD_DOC doc = doc else doc = endif if HAVE_W32_SYSTEM tests = else tests = tests endif SUBDIRS = m4 gl include jnlib common ${kbx} \ ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${tools} po ${doc} ${tests} dist_doc_DATA = README dist-hook: echo "$(VERSION)" > $(distdir)/VERSION stowinstall: $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/gnupg diff --git a/NEWS b/NEWS index 97ba097c4..a24b4a993 100644 --- a/NEWS +++ b/NEWS @@ -1,790 +1,790 @@ Noteworthy changes in version 2.0.17 (unreleased) ------------------------------------------------- - * Fixed output of "gpgconf --check-options". + * Allow more hash algorithms with the OpenPGP v2 card. - * gpg-agent now tests for a newly created gpg-agent.conf after a HUP. + * The gpg-agent now tests for a new gpg-agent.conf on a HUP. - * Allow more hash algorithms with the OpenPGP v2 card. + * Fixed output of "gpgconf --check-options". * Fixed a bug where Scdaemon sends a signal to Gpg-agent running in non-daemon mode. * Fixed TTY management for pinentries and session variable update problem. Noteworthy changes in version 2.0.16 (2010-07-19) ------------------------------------------------- * If the agent's --use-standard-socket option is active, all tools try to start and daemonize the agent on the fly. In the past this was only supported on W32; on non-W32 systems the new configure option --enable-standard-socket may now be used to use this feature by default. * The gpg-agent commands KILLAGENT and RELOADAGENT are now available on all platforms. * Minor bug fixes. Noteworthy changes in version 2.0.15 (2010-03-09) ------------------------------------------------- * New command --passwd for GPG. * Fixes a regression in 2.0.14 which prevented unprotection of new or changed gpg-agent passphrases. * Make use of libassuan 2.0 which is available as a DSO. Noteworthy changes in version 2.0.14 (2009-12-21) ------------------------------------------------- * The default for --include-cert is now to include all certificates in the chain except for the root certificate. * Numerical values may now be used as an alternative to the debug-level keywords. * The GPGSM --audit-log feature is now more complete. * GPG now supports DNS lookups for SRV, PKA and CERT on W32. * New GPGSM option --ignore-cert-extension. * New and changed passphrases are now created with an iteration count requiring about 100ms of CPU work. Noteworthy changes in version 2.0.13 (2009-09-04) ------------------------------------------------- * GPG now generates 2048 bit RSA keys by default. The default hash algorithm preferences has changed to prefer SHA-256 over SHA-1. 2048 bit DSA keys are now generated to use a 256 bit hash algorithm * The envvars XMODIFIERS, GTK_IM_MODULE and QT_IM_MODULE are now passed to the Pinentry to make SCIM work. * The GPGSM command --gen-key features a --batch mode and implements all features of gpgsm-gencert.sh in standard mode. * New option --re-import for GPGSM's IMPORT server command. * Enhanced writing of existing keys to OpenPGP v2 cards. * Add hack to the internal CCID driver to allow the use of some Omnikey based card readers with 2048 bit keys. * GPG now repeatly asks the user to insert the requested OpenPGP card. This can be disabled with --limit-card-insert-tries=1. * Minor bug fixes. Noteworthy changes in version 2.0.12 (2009-06-17) ------------------------------------------------- * GPGSM now always lists ephemeral certificates if specified by fingerprint or keygrip. * New command "KEYINFO" for GPG_AGENT. GPGSM now also returns information about smartcards. * Made sure not to leak file descriptors if running gpg-agent with a command. Restore the signal mask to solve a problem in Mono. * Changed order of the confirmation questions for root certificates and store negative answers in trustlist.txt. * Better synchronization of concurrent smartcard sessions. * Support 2048 bit OpenPGP cards. * Support Telesec Netkey 3 cards. * The gpg-protect-tool now uses gpg-agent via libassuan. Under Windows the Pinentry will now be put into the foreground. * Changed code to avoid a possible Mac OS X system freeze. Noteworthy changes in version 2.0.11 (2009-03-03) ------------------------------------------------- * Fixed a problem in SCDAEMON which caused unexpected card resets. * SCDAEMON is now aware of the Geldkarte. * The SCDAEMON option --allow-admin is now used by default. * GPGCONF now restarts SCdaemon if necessary. * The default cipher algorithm in GPGSM is now again 3DES. This is due to interoperability problems with Outlook 2003 which still can't cope with AES. Noteworthy changes in version 2.0.10 (2009-01-12) ------------------------------------------------- * [gpg] New keyserver helper gpg2keys_kdns as generic DNS CERT lookup. Run with --help for a short description. Requires the ADNS library. * [gpg] New mechanisms "local" and "nodefault" for --auto-key-locate. Fixed a few problems with this option. * [gpg] New command --locate-keys. * [gpg] New options --with-sig-list and --with-sig-check. * [gpg] The option "-sat" is no longer an alias for --clearsign. * [gpg] The option --fixed-list-mode is now implicitly used and obsolete. * [gpg] New control statement %ask-passphrase for the unattended key generation. * [gpg] The algorithm to compute the SIG_ID status has been changed. * [gpgsm] Now uses AES by default. * [gpgsm] Made --output option work with --export-secret-key-p12. * [gpg-agent] Terminate process if the own listening socket is not anymore served by ourself. * [scdaemon] Made it more robust on W32. * [gpg-connect-agent] Accept commands given as command line arguments. * [w32] Initialized the socket subsystem for all keyserver helpers. * [w32] The sysconf directory has been moved from a subdirectory of the installation directory to %CSIDL_COMMON_APPDATA%/GNU/etc/gnupg. * [w32] The gnupg2.nls directory is not anymore used. The standard locale directory is now used. * [w32] Fixed a race condition between gpg and gpgsm in the use of temporary file names. * The gpg-preset-passphrase mechanism works again. An arbitrary string may now be used for a custom cache ID. * Admin PINs are cached again (bug in 2.0.9). * Support for version 2 OpenPGP cards. * Libgcrypt 1.4 is now required. Noteworthy changes in version 2.0.9 (2008-03-26) ------------------------------------------------ * Gpgsm always tries to locate missing certificates from a running Dirmngr's cache. * Tweaks for Windows. * The Admin PIN for OpenPGP cards may now be entered with the pinpad. * Improved certificate chain construction. * Extended the PKITS framework. * Fixed a bug in the ambigious name detection. * Fixed possible memory corruption while importing OpenPGP keys (bug introduced with 2.0.8). [CVE-2008-1530] * Minor bug fixes. Noteworthy changes in version 2.0.8 (2007-12-20) ------------------------------------------------ * Enhanced gpg-connect-agent with a small scripting language. * New option --list-config for gpgconf. * Fixed a crash in gpgconf. * Gpg-agent now supports the passphrase quality bar of the latest Pinentry. * The envvars XAUTHORITY and PINENTRY_USER_DATA are now passed to the Pinentry. * Fixed the auto creation of the key stub for smartcards. * Fixed a rare bug in decryption using the OpenPGP card. * Creating DSA2 keys is now possible. * New option --extra-digest-algo for gpgsm to allow verification of broken signatures. * Allow encryption with legacy Elgamal sign+encrypt keys with option --rfc2440. * Windows is now a supported platform. * Made sure that under Windows the file permissions of the socket are taken into account. This required a change of our socket emulation code and changed the IPC protocol under Windows. Noteworthy changes in version 2.0.7 (2007-09-10) ------------------------------------------------ * Fixed encryption problem if duplicate certificates are in the keybox. * Made it work on Windows Vista. Note that the entire Windows port is still considered Beta. * Add new options min-passphrase-nonalpha, check-passphrase-pattern, enforce-passphrase-constraints and max-passphrase-days to gpg-agent. * Add command --check-components to gpgconf. Gpgconf now uses the installed versions of the programs and does not anymore search via PATH for them. Noteworthy changes in version 2.0.6 (2007-08-16) ------------------------------------------------ * GPGSM does now grok --default-key. * GPGCONF is now aware of --default-key and --encrypt-to. * GPGSM does again correctly print the serial number as well the the various keyids. This was broken since 2.0.4. * New option --validation-model and support for the chain-model. * Improved Windows support. Noteworthy changes in version 2.0.5 (2007-07-05) ------------------------------------------------ * Switched license to GPLv3. * Basic support for Windows. Run "./autogen.sh --build-w32" to build it. As usual the mingw cross compiling toolchain is required. * Fixed bug when using the --p12-charset without --armor. * The command --gen-key may now be used instead of the gpgsm-gencert.sh script. * Changed key generation to reveal less information about the machine. Bug fixes for gpg2's card key generation. Noteworthy changes in version 2.0.4 (2007-05-09) ------------------------------------------------ * The server mode key listing commands are now also working for systems without the funopen/fopencookie API. * PKCS#12 import now tries several encodings in case the passphrase was not utf-8 encoded. New option --p12-charset for gpgsm. * Improved the libgcrypt logging support in all modules. Noteworthy changes in version 2.0.3 (2007-03-08) ------------------------------------------------ * By default, do not allow processing multiple plaintexts in a single stream. Many programs that called GnuPG were assuming that GnuPG did not permit this, and were thus not using the plaintext boundary status tags that GnuPG provides. This change makes GnuPG reject such messages by default which makes those programs safe again. --allow-multiple-messages returns to the old behavior. [CVE-2007-1263]. * New --verify-option show-primary-uid-only. * gpgconf may now reads a global configuration file to select which options are changeable by a frontend. The new applygnupgdefaults tool may be used by an admin to set default options for all users. * The PIN pad of the Cherry XX44 keyboard is now supported. The DINSIG and the NKS applications are now also aware of PIN pads. Noteworthy changes in version 2.0.2 (2007-01-31) ------------------------------------------------ * Fixed a serious and exploitable bug in processing encrypted packages. [CVE-2006-6235]. * Added --passphrase-repeat to set the number of times GPG will prompt for a new passphrase to be repeated. This is useful to help memorize a new passphrase. The default is 1 repetition. * Using a PIN pad does now also work for the signing key. * A warning is displayed by gpg-agent if a new passphrase is too short. New option --min-passphrase-len defaults to 8. * The status code BEGIN_SIGNING now shows the used hash algorithms. Noteworthy changes in version 2.0.1 (2006-11-28) ------------------------------------------------ * Experimental support for the PIN pads of the SPR 532 and the Kaan Advanced card readers. Add "disable-keypad" scdaemon.conf if you don't want it. Does currently only work for the OpenPGP card and its authentication and decrypt keys. * Fixed build problems on some some platforms and crashes on amd64. * Fixed a buffer overflow in gpg2. [bug#728,CVE-2006-6169] Noteworthy changes in version 2.0.0 (2006-11-11) ------------------------------------------------ * First stable version of a GnuPG integrating OpenPGP and S/MIME. Noteworthy changes in version 1.9.95 (2006-11-06) ------------------------------------------------- * Minor bug fixes. Noteworthy changes in version 1.9.94 (2006-10-24) ------------------------------------------------- * Keys for gpgsm may now be specified using a keygrip. A keygrip is indicated by a prefixing it with an ampersand. * gpgconf now supports switching the CMS cipher algo (e.g. to AES). * New command --gpgconf-test for all major tools. This may be used to check whether the configuration file is sane. Noteworthy changes in version 1.9.93 (2006-10-18) ------------------------------------------------- * In --with-validation mode gpgsm will now also ask whether a root certificate should be trusted. * Link to Pth only if really necessary. * Fixed a pubring corruption bug in gpg2 occurring when importing signatures or keys with insane lengths. * Fixed v3 keyID calculation bug in gpg2. * More tweaks for certificates without extensions. Noteworthy changes in version 1.9.92 (2006-10-11) ------------------------------------------------- * Bug fixes. Noteworthy changes in version 1.9.91 (2006-10-04) ------------------------------------------------- * New "relax" flag for trustlist.txt to allow root CA certificates without BasicContraints. * [gpg2] Removed the -k PGP 2 compatibility hack. -k is now an alias for --list-keys. * [gpg2] Print a warning if "-sat" is used instead of "--clearsign". Noteworthy changes in version 1.9.90 (2006-09-25) ------------------------------------------------- * Made readline work for gpg. * Cleanups und minor bug fixes. * Included translations from gnupg 1.4.5. Noteworthy changes in version 1.9.23 (2006-09-18) ------------------------------------------------- * Regular man pages for most tools are now build directly from the Texinfo source. * The gpg code from 1.4.5 has been fully merged into this release. The configure option --enable-gpg is still required to build this gpg part. For production use of OpenPGP the gpg version 1.4.5 is still recommended. Note, that gpg will be installed under the name gpg2 to allow coexisting with an 1.4.x gpg. * API change in gpg-agent's pkdecrypt command. Thus an older gpgsm may not be used with the current gpg-agent. * The scdaemon will now call a script on reader status changes. * gpgsm now allows file descriptor passing for "INPUT", "OUTPUT" and "MESSAGE". * The gpgsm server may now output a key listing to the output file handle. This needs to be enabled using "OPTION list-to-output=1". * The --output option of gpgsm has now an effect on list-keys. * New gpgsm commands --dump-chain and list-chain. * gpg-connect-agent has new options to utilize descriptor passing. * A global trustlist may now be used. See doc/examples/trustlist.txt. * When creating a new pubring.kbx keybox common certificates are imported. Noteworthy changes in version 1.9.22 (2006-07-27) ------------------------------------------------- * Enhanced pkcs#12 support to allow import from simple keyBags. * Exporting to pkcs#12 now create bag attributes so that Mozilla is able to import the files. * Fixed uploading of certain keys to the smart card. Noteworthy changes in version 1.9.21 (2006-06-20) ------------------------------------------------- * New command APDU for scdaemon to allow using it for general card access. Might be used through gpg-connect-agent by using the SCD prefix command. * Support for the CardMan 4040 PCMCIA reader (Linux 2.6.15 required). * Scdaemon does not anymore reset cards at the end of a connection. * Kludge to allow use of Bundesnetzagentur issued X.509 certificates. * Added --hash=xxx option to scdaemon's PKSIGN command. * Pkcs#12 files are now created with a MAC. This is for better interoperability. * Collected bug fixes and minor other changes. Noteworthy changes in version 1.9.20 (2005-12-20) ------------------------------------------------- * Importing pkcs#12 files created be recent versions of Mozilla works again. * Basic support for qualified signatures. * New debug tool gpgparsemail. Noteworthy changes in version 1.9.19 (2005-09-12) ------------------------------------------------- * The Belgian eID card is now supported for signatures and ssh. Other pkcs#15 cards should work as well. * Fixed bug in --export-secret-key-p12 so that certificates are again included. Noteworthy changes in version 1.9.18 (2005-08-01) ------------------------------------------------- * [gpgsm] Now allows for more than one email address as well as URIs and dnsNames in certificate request generation. A keygrip may be given to create a request from an existing key. * A couple of minor bug fixes. Noteworthy changes in version 1.9.17 (2005-06-20) ------------------------------------------------- * gpg-connect-agent has now features to handle Assuan INQUIRE commands. * Internal changes for OpenPGP cards. New Assuan command WRITEKEY. * GNU Pth is now a hard requirement. * [scdaemon] Support for OpenSC has been removed. Instead a new and straightforward pkcs#15 modules has been written. As of now it does allows only signing using TCOS cards but we are going to enhance it to match all the old capabilities. * [gpg-agent] New option --write-env-file and Assuan command UPDATESTARTUPTTY. * [gpg-agent] New option --default-cache-ttl-ssh to set the TTL for SSH passphrase caching independent from the other passphrases. Noteworthy changes in version 1.9.16 (2005-04-21) ------------------------------------------------- * gpg-agent does now support the ssh-agent protocol and thus allows to use the pinentry as well as the OpenPGP smartcard with ssh. * New tool gpg-connect-agent as a general client for the gpg-agent. * New tool symcryptrun as a wrapper for certain encryption tools. * The gpg tool is not anymore build by default because those gpg versions available in the gnupg 1.4 series are far more matured. Noteworthy changes in version 1.9.15 (2005-01-13) ------------------------------------------------- * Fixed passphrase caching bug. * Better support for CCID readers; the reader from Cherry RS 6700 USB does now work. Noteworthy changes in version 1.9.14 (2004-12-22) ------------------------------------------------- * [gpg-agent] New option --use-standard-socket to allow the use of a fixed socket. gpgsm falls back to this socket if GPG_AGENT_INFO has not been set. * Ported to MS Windows with some functional limitations. * New tool gpg-preset-passphrase. Noteworthy changes in version 1.9.13 (2004-12-03) ------------------------------------------------- * [gpgsm] New option --prefer-system-dirmngr. * Minor cleanups and debugging aids. Noteworthy changes in version 1.9.12 (2004-10-22) ------------------------------------------------- * [scdaemon] Partly rewrote the PC/SC code. * Removed the sc-investigate tool. It is now in a separate package available at ftp://ftp.g10code.com/g10code/gscutils/ . * [gpg-agent] Fixed logging problem. Noteworthy changes in version 1.9.11 (2004-10-01) ------------------------------------------------- * When using --import along with --with-validation, the imported certificates are validated and only imported if they are fully valid. * [gpg-agent] New option --max-cache-ttl. * [gpg-agent] When used without --daemon or --server, gpg-agent now check whether a agent is already running and usable. * Fixed some i18n problems. Noteworthy changes in version 1.9.10 (2004-07-22) ------------------------------------------------- * Fixed a serious bug in the checking of trusted root certificates. * New configure option --enable-agent-pnly allows to build and install just the agent. * Fixed a problem with the log file handling. Noteworthy changes in version 1.9.9 (2004-06-08) ------------------------------------------------ * [gpg-agent] The new option --allow-mark-trusted is now required to allow gpg-agent to add a key to the trustlist.txt after user confirmation. * Creating PKCS#10 requests does now honor the key usage. Noteworthy changes in version 1.9.8 (2004-04-29) ------------------------------------------------ * [scdaemon] Overhauled the internal CCID driver. * [scdaemon] Status files named ~/.gnupg/reader_.status are now written when using the internal CCID driver. * [gpgsm] New commands --dump-{,secret,external}-keys to show a very detailed view of the certificates. * The keybox gets now compressed after 3 hours and ephemeral stored certificates are deleted after about a day. * [gpg] Usability fixes for --card-edit. Note, that this has already been ported back to gnupg-1.3 Noteworthy changes in version 1.9.7 (2004-04-06) ------------------------------------------------ * Instrumented the modules for gpgconf. * Added support for DINSIG card applications. * Include the smimeCapabilities attribute with signed messages. * Now uses the gettext domain "gnupg2" to avoid conflicts with gnupg versions < 1.9. Noteworthy changes in version 1.9.6 (2004-03-06) ------------------------------------------------ * Code cleanups and bug fixes. Noteworthy changes in version 1.9.5 (2004-02-21) ------------------------------------------------ * gpg-protect-tool gets now installed into libexec as it ought to be. Cleaned up the build system to better comply with the coding standards. * [gpgsm] The --import command is now able to autodetect pkcs#12 files and import secret and private keys from this file format. A new command --export-secret-key-p12 is provided to allow exporting of secret keys in PKCS\#12 format. * [gpgsm] The pinentry will now present a description of the key for whom the passphrase is requested. * [gpgsm] New option --with-validation to check the validity of key while listing it. * New option --debug-level={none,basic,advanced,expert,guru} to map the debug flags to sensitive levels on a per program base. Noteworthy changes in version 1.9.4 (2004-01-30) ------------------------------------------------ * Added support for the Telesec NKS 2.0 card application. * Added simple tool addgnupghome to create .gnupg directories from /etc/skel/.gnupg. * Various minor bug fixes and cleanups; mainly gpgsm and gpg-agent related. Noteworthy changes in version 1.9.3 (2003-12-23) ------------------------------------------------ * New gpgsm options --{enable,disable}-ocsp to validate keys using OCSP. This option requires a not yet released DirMngr version. Default is disabled. * The --log-file option may now be used to print logs to a socket. Prefix the socket name with "socket://" to enable this. This does not work on all systems and falls back to stderr if there is a problem with the socket. * The options --encrypt-to and --no-encrypt-to now work the same in gpgsm as in gpg. Note, they are also used in server mode. * Duplicated recipients are now silently removed in gpgsm. Noteworthy changes in version 1.9.2 (2003-11-17) ------------------------------------------------ * On card key generation is no longer done using the --gen-key command but from the menu provided by the new --card-edit command. * PINs are now properly cached and there are only 2 PINs visible. The 3rd PIN (CHV2) is internally syncronized with the regular PIN. * All kind of other internal stuff. Noteworthy changes in version 1.9.1 (2003-09-06) ------------------------------------------------ * Support for OpenSC is back. scdaemon supports a --disable-opensc to disable OpenSC use at runtime, so that PC/SC or ct-API can still be used directly. * Rudimentary support for the SCR335 smartcard reader using an internal driver. Requires current libusb from CVS. * Bug fixes. Noteworthy changes in version 1.9.0 (2003-08-05) ------------------------------------------------ ====== PLEASE SEE README-alpha ======= * gpg has been renamed to gpg2 and gpgv to gpgv2. This is a temporary change to allow co-existing with stable gpg versions. * ~/.gnupg/gpg.conf-1.9.0 is fist tried as config file before the usual gpg.conf. * Removed the -k, -kv and -kvv commands. -k is now an alias to --list-keys. New command -K as alias for --list-secret-keys. * Removed --run-as-shm-coprocess feature. * gpg does now also use libgcrypt, libgpg-error is required. * New gpgsm commands --call-dirmngr and --call-protect-tool. * Changing a passphrase is now possible using "gpgsm --passwd" * The content-type attribute is now recognized and created. * The agent does now reread certain options on receiving a HUP. * The pinentry is now forked for each request so that clients with different environments are supported. When running in daemon mode and --keep-display is not used the DISPLAY variable is ignored. * Merged stuff from the newpg branch and started this new development branch. Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/autogen.sh b/autogen.sh index 2203b8252..be284594c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,212 +1,213 @@ #! /bin/sh # Run this to generate all the initial makefiles, etc. # # Copyright (C) 2003 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure_ac="configure.ac" cvtver () { awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}' } check_version () { if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 echo ' Version '$3' or newer is required.' >&2 [ -n "$4" ] && echo ' Note that this is part of '\`$4\''.' >&2 DIE="yes" return 1 } # Allow to override the default tool names AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} DIE=no FORCE= if test x"$1" = x"--force"; then FORCE=" --force" shift fi # ***** W32 build script ******* # Used to cross-compile for Windows. if test "$1" = "--build-w32"; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift if [ ! -f $tsdir/scripts/config.guess ]; then echo "$tsdir/scripts/config.guess not found" >&2 exit 1 fi build=`$tsdir/scripts/config.guess` [ -z "$w32root" ] && w32root="$HOME/w32root" echo "Using $w32root as standard install directory" >&2 # Locate the cross compiler crossbindir= for host in i586-mingw32msvc i386-mingw32msvc mingw32; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" break; fi done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 echo "Under Debian GNU/Linux, you may install it using" >&2 echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 echo "Stop." >&2 exit 1 fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then echo "Please run a 'make distclean' first" >&2 exit 1 fi fi ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ + --enable-gpgtar \ --with-gpg-error-prefix=${w32root} \ --with-ksba-prefix=${w32root} \ --with-libgcrypt-prefix=${w32root} \ --with-libassuan-prefix=${w32root} \ --with-zlib=${w32root} \ --with-regex=${w32root} \ --with-pth-prefix=${w32root} \ --with-adns=${w32root} "$@" rc=$? exit $rc fi # ***** end W32 build script ******* # ***** AMD64 cross build script ******* # Used to cross-compile for AMD64 (for testing) if test "$1" = "--build-amd64"; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift if [ ! -f $tsdir/scripts/config.guess ]; then echo "$tsdir/scripts/config.guess not found" >&2 exit 1 fi build=`$tsdir/scripts/config.guess` [ -z "$amd64root" ] && amd64root="$HOME/amd64root" echo "Using $amd64root as standard install directory" >&2 # Locate the cross compiler crossbindir= for host in x86_64-linux-gnu amd64-linux-gnu; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" break; fi done if [ -z "$crossbindir" ]; then echo "Cross compiler kit not installed" >&2 echo "Stop." >&2 exit 1 fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then echo "Please run a 'make distclean' first" >&2 exit 1 fi fi $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ --host=${host} --build=${build} \ --with-gpg-error-prefix=${amd64root} \ --with-ksba-prefix=${amd64root} \ --with-libgcrypt-prefix=${amd64root} \ --with-libassuan-prefix=${amd64root} \ --with-zlib=/usr/x86_64-linux-gnu/usr \ --with-pth-prefix=/usr/x86_64-linux-gnu/usr rc=$? exit $rc fi # ***** end AMD64 cross build script ******* # Grep the required versions from configure.ac autoconf_vers=`sed -n '/^AC_PREREQ(/ { s/^.*(\(.*\))/\1/p q }' ${configure_ac}` autoconf_vers_num=`echo "$autoconf_vers" | cvtver` automake_vers=`sed -n '/^min_automake_version=/ { s/^.*="\(.*\)"/\1/p q }' ${configure_ac}` automake_vers_num=`echo "$automake_vers" | cvtver` gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { s/^.*\[\(.*\)])/\1/p q }' ${configure_ac}` gettext_vers_num=`echo "$gettext_vers" | cvtver` if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ] then echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 exit 1 fi if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf fi if check_version $AUTOMAKE $automake_vers_num $automake_vers; then check_version $ACLOCAL $automake_vers_num $autoconf_vers automake fi if check_version $GETTEXT $gettext_vers_num $gettext_vers; then check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext fi if test "$DIE" = "yes"; then cat < + + Estream changes as used gnupg master from 2010-07-19. + + * estream.c (es_fname_get, es_fname_set): New. + (fname_set_internal): New. + (struct estream_internal): Add fields printable_fname and + printable_fname_inuse. + (_es_get_std_stream): Set stream name. + (es_fopen, es_freopen, es_deinitialize): Set fname. + 2011-01-10 Thomas Mraz (wk) * pka.c (get_pka_info) [!USE_ADNS]: Turn ANSWER into a union to avoid aliasing problems with modern compilers. See bug#1307. Reported by Steve Grubb. 2011-01-10 Werner Koch * session-env.c (update_var): Fix same value test. Fixes bug#1311. 2010-09-16 Werner Koch * util.h: Add GPG_ERR_MISSING_ISSUER_CERT. * status.c (get_inv_recpsgnr_code): Ditto. 2010-05-03 Werner Koch * asshelp.c (lock_agent_spawning, unlock_agent_spawning): New. (start_new_gpg_agent): Test for configured standard socket and try to fire up the agent in this case. * exechelp.c (gnupg_spawn_process_detached): Do not reuse PID for the second fork. (gnupg_wait_process): Do not log a message if EXITCODE is given. 2010-03-17 Werner Koch * asshelp.c (start_new_gpg_agent) [W32]: Use a named mutex to avoid starting two agents. 2010-03-12 Werner Koch * status.h (STATUS_ENTER): New. 2010-02-11 Marcus Brinkmann From trunk 2009-10-16, 2009-11-02, 2009-11-05: * Makefile.am (libcommon_a_CFLAGS): Use LIBASSUAN_CFLAGS instead of LIBASSUAN_PTH_CFLAGS. * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return type to gpg_error_t. * asshelp.c (start_new_gpg_agent): Update use of assuan_socket_connect and assuan_pipe_connect. Convert posix FD to assuan FD. [HAVE_W32_SYSTEM]: Add missing argument in assuan_socket_connect invocation. * iobuf.c (iobuf_open_fd_or_name): Fix type of FD in function declaration. 2009-10-13 Werner Koch From trunk 2009-09-23: * asshelp.c (start_new_gpg_agent): Allocate assuan context before starting server. 2009-12-21 Marcus Brinkmann (wk) * Makefile.am (audit-events.h, status.h) [!MAINTAINER_MODE]: No longer include these rules if not in maintainer mode. 2009-12-08 Werner Koch * dns-cert.c: Add support for ADNS. 2009-12-07 Werner Koch * pka.c (get_pka_info): Add support for ADNS. * src.v (getsrv): Add support for ADNS. * srv.c (getsrv): s/xrealloc/xtryrealloc/. 2009-12-04 Werner Koch * Makefile.am (audit-events.h, status-codes.h): Create files in the source dir. Fixes bug#1164. 2009-12-03 Werner Koch From trunk: * audit.c (proc_type_decrypt, proc_type_sign): Implemented. (proc_type_verify): Print hash algo infos. * audit.h (AUDIT_DATA_CIPHER_ALGO, AUDIT_BAD_DATA_CIPHER_ALSO) (AUDIT_NEW_RECP, AUDIT_DECRYPTION_RESULT, AUDIT_RECP_RESULT) (AUDIT_ATTR_HASH_ALGO, AUDIT_SIGNED_BY, AUDIT_SIGNING_DONE): 2009-09-03 Werner Koch Update from libestream: * estream-printf.c: Include stdint.h only if HAVE_STDINT_H is defined. * estream-printf.c: Remove all test code. Use macro DEBUG instead of TEST for debugging. * estream-printf.c (pr_float): Make buffer larger for silly high numbers. 2009-08-11 David Shaw * ttyio.h, ttyio.c (tty_enable_completion): Some ifdefs around HAVE_LIBREADLINE to allow building when readline isn't available. 2009-08-06 Werner Koch * status.h (STATUS_INV_SGNR, STATUS_NO_SGNR): New. * status.c (get_inv_recpsgnr_code): New. 2009-07-23 David Shaw * srv.c (getsrv): Fix type-punning warning. 2009-07-23 Werner Koch * util.h (GPG_ERR_NOT_ENABLED): New. * audit.h (enum): Add AUDIT_CRL_CHECK. * audit.c (proc_type_verify): Show CRL check result. 2009-07-06 Werner Koch * get-passphrase.c (struct agentargs): Add SESSION_ENV and remove obsolete args. (gnupg_prepare_get_passphrase): Ditto. * session-env.c, session-env.h: New. * t-session-env.c: New. * Makefile.am (common_sources, module_tests): Add them. * asshelp.h: Include "session-env.h" * asshelp.c (send_one_option): Add arg PUTENV. (send_pinentry_environment): Replace most args by SESSION_ENV and rewrite fucntion. (start_new_gpg_agent): Likewise. * t-exechelp.c (test_close_all_fds): Remove debug code. 2009-07-01 Werner Koch * sexputil.c (get_pk_algo_from_canon_sexp): New. 2009-06-29 Werner Koch * estream.c (BUFFER_ROUND_TO_BLOCK): Remove unused macro. (es_func_mem_write): Rewrite reallocation part. * estream.c (es_write_sanitized_utf8_buffer): Typo typo fix. 2009-06-25 Werner Koch * estream.c (es_write_sanitized_utf8_buffer): Typo fix. 2009-06-24 Werner Koch * estream.c (es_read_line): In the malloc error case, set MAX_LENGTH to 0 only if requested. * xreadline.c (read_line): Ditto. * estream.c (es_write_sanitized_utf8_buffer): Pass on error from es_fputs. * sexputil.c (get_rsa_pk_from_canon_sexp): Check for error after the loop. Reported by Fabian Keil. 2009-06-22 Werner Koch * estream.c (es_pth_read, es_pth_write) [W32]: New. (ESTREAM_SYS_READ, ESTREAM_SYS_WRITE) [HAVE_PTH]: Use them. 2009-06-03 Werner Koch * estream.c (es_convert_mode): Rewrite and support the "x" flag. 2009-05-28 David Shaw From 1.4: * http.h, http.c (send_request) Pass in a STRLIST for additional headers. Change all callers. 2009-05-27 David Shaw From 1.4: * http.h, http.c (send_request): Pass in srvtag and make its presence sufficient to turn the feature on. (http_open): From here. (http_document): And here. * srv.c (getsrv): Raise maximum packet size to 2048, as PACKETSZ is too small these days. 2009-05-22 Werner Koch * ttyio.c (tty_cleanup_after_signal): New. 2009-05-19 Werner Koch * simple-pwquery.c (agent_open): Use SUN_LEN (JNLIB_NEED_AFLOCAL): Define and include mischelp.h. 2009-05-07 Werner Koch * sexputil.c (get_rsa_pk_from_canon_sexp): New. * t-sexputil.c (test_make_canon_sexp_from_rsa_pk): Extend the test. 2009-04-28 Werner Koch * sexputil.c (make_canon_sexp_from_rsa_pk): New. * t-sexputil.c (test_make_canon_sexp_from_rsa_pk): New. 2009-04-01 Werner Koch * iobuf.c: Port David's changes from 1.4: (fd_cache_invalidate): Pass return code from close back. (direct_open, iobuf_ioctl): Check that eturn value. (fd_cache_synchronize): New. (iobuf_ioctl): Add new sub command 4 (fsync). * iobuf.c (fd_cache_strcmp): New. Taken from 1.4. (fd_cache_invalidate, fd_cache_close, fd_cache_open): Use it. * exechelp.c (gnupg_spawn_process): Implement new flag bit 6. * sysutils.c (gnupg_allow_set_foregound_window): Allow the use of ASFW_ANY. * membuf.c (put_membuf, get_membuf): Wipe memory on out of core. 2009-03-31 Werner Koch * percent.c (percent_unescape, percent_plus_unescape): New. (percent_plus_unescape_inplace, percent_unescape_inplace): New. (do_plus_or_plain_unescape, count_unescape, do_unescape): New. (do_unescape_inplace): New. * t-percent.c (test_percent_plus_escape): Test percent_plus_unescape. * get-passphrase.c, get-passphrase.h: New. * Makefile.am (without_pth_sources): New. 2009-03-18 Werner Koch * exechelp.c: Include sys/resource.h and sys/stat.h. (get_max_open_fds): New. (do_exec): Use it. (get_all_open_fds): New. (close_all_fds): New. (do_exec): Use close_all_fds. * t-exechelp.c: New. 2009-03-13 David Shaw * http.c (do_parse_uri): Properly handle IPv6 literal addresses as per RFC-2732. Adapted from patch by Phil Pennock. 2009-03-12 Werner Koch * gettime.c: Include i18n.h. (dump_isotime): New. 2009-03-06 Werner Koch * sexputil.c (make_canon_sexp): New. 2009-03-03 Werner Koch * exechelp.c (do_exec): Make sure that /dev/null connected FDs are not closed. 2009-01-19 Werner Koch * audit.c (writeout_li): Translate a few more result strings. Fixes bug#970. * convert.c (hex2str): Fix optimization to append a nul character. 2008-12-05 Werner Koch * percent.c, t-percent.c: New. * exechelp.c (gnupg_spawn_process, gnupg_spawn_process_fd) (gnupg_spawn_process_detached) [W32]: Remove debug output. 2008-11-20 Werner Koch * audit.c (writeout_li): Translate OKTEXT. 2008-11-04 Werner Koch * i18n.c (i18n_init) [USE_SIMPLE_GETTEXT]: Adjust for changed w32-gettext.c. * homedir.c (gnupg_localedir): New. 2008-10-20 Werner Koch * http.c (http_register_tls_callback) [!HTTP_USE_GNUTLS]: Mark unused arg. * localename.c (do_nl_locale_name): Ditto. * audit.c (event2str): Silent gcc warning. * sysutils.c (translate_sys2libc_fd): Mark unused arg. (translate_sys2libc_fd_int): Ditto. * iobuf.c (translate_file_handle): Ditto. * asshelp.c (send_one_option): Ditto. * exechelp.c (gnupg_spawn_process): Ditto. * signal.c (got_usr_signal): Ditto * estream.c (es_func_fd_create) [!W32]: Ditto. (es_func_fp_create) [!W32]: Ditto. (es_write_hexstring): Ditto. (dummy_mutex_call_void, dummy_mutex_call_int) [HAVE_PTH]: New. (ESTREAM_MUTEX_LOCK, ESTREAM_MUTEX_UNLOCK, ESTREAM_MUTEX_TRYLOCK) (ESTREAM_MUTEX_INITIALIZE) [HAVE_PTH]: Use dummy calls so to mark unused arg. 2008-10-19 Werner Koch * estream-printf.c (estream_vsnprintf): Fix return value. (check_snprintf): Add a new test. (one_test) [W32]: Disable test. 2008-10-17 Werner Koch * util.h (snprintf) [W32]: Redefine to estream_snprintf. 2008-09-03 Werner Koch * convert.c (hex2str): New. (hex2str_alloc): New. * t-convert.c (test_hex2str): New. 2008-08-19 Werner Koch * iobuf.c: Avoid passing a NULL (iobuf_t)->desc to the log function. Should in general never be NULL, but well. Reported by M. Heneka. 2008-06-26 Werner Koch * estream.c (es_write_sanitized): Loose check for control characters to better cope with utf-8. The range 0x80..0x9f is nowadays not anymore accidently used for control charaters. 2008-06-25 Marcus Brinkmann Revert last three changes related to handle translation. * sysutils.c: (FD_TRANSLATE_MAX, fd_translate, fd_translate_len) (translate_table_init, translate_table_lookup): Removed. * iobuf.c (check_special_filename): Do not use translate_table_lookup. * sysutils.h (translate_table_init, translate_table_lookup): Remove prototypes. 2008-06-19 Werner Koch * sysutils.c: Remove . (fd_translate_max): Use macro for the size. (translate_table_init): Protect read against EINTR and replace isspace by spacep. 2008-06-18 Marcus Brinkmann * sysutils.c (TRANS_MAX): Bump up to 350 to be on the safe side. * sysutils.h (translate_table_init, translate_table_lookup): New prototypes. * sysutils.c: Include . (FD_TRANSLATE_MAX): New macro. (fd_translate, fd_translate_len): New static variables. (translate_table_init, translate_table_lookup): New functions. (translate_sys2libc_fd_int): Translate file descriptor. * iobuf.c (check_special_filename): Translate handle values from special filenames. 2008-06-16 Werner Koch * homedir.c (w32_commondir): New. (gnupg_sysconfdir): Use it. 2008-06-09 Werner Koch * b64dec.c: New. 2008-06-05 Werner Koch * util.h (gnupg_copy_time): Replace strcpy by memcpy. 2008-05-26 Werner Koch * asshelp.c (send_one_option, send_pinentry_environment): use xfree and xtrystrdup. * i18n.c (i18n_switchto_utf8) [USE_SIMPLE_GETTEXT]: Return NULL. * homedir.c (gnupg_module_name): Add GNUPG_MODULE_NAME_CONNECT_AGENT and GNUPG_MODULE_NAME_GPGCONF. 2008-04-21 Werner Koch * http.c (http_wait_response) [W32]: Use DuplicateHandle because it is a socket. (cookie_read) [W32]: Use recv in place of read. 2008-04-08 Werner Koch * i18n.c (i18n_switchto_utf8, i18n_switchback) [USE_SIMPLE_GETTEXT]: Implement. 2008-04-07 Werner Koch * b64enc.c (b64enc_start): Detect PGP mode. (b64enc_finish): Write PGP CRC. * util.h (struct b64state): Add field CRC. * t-b64.c: New. * pka.c (get_pka_info): Use xtrymalloc and check result. 2008-03-25 Werner Koch * localename.c: Strip all W32 code. Include w32help.h. (gnupg_messages_locale_name) [W32]: Use the gettext_localename. 2008-03-17 Werner Koch * iobuf.c (IOBUF_BUFFER_SIZE): Actually use this macro. * simple-pwquery.c (agent_send_all_options): Fix last change. 2008-03-06 Werner Koch * simple-pwquery.c (agent_send_all_options): Add support for XAUTHORITY and PINENTRY_USER_DATA. 2008-02-15 Marcus Brinkmann * exechelp.c (gnupg_spawn_process_fd): Add flag DETACHED_PROCESS unconditionally (required for all callers at the moment). 2008-02-14 Werner Koch * sysutils.c (gnupg_allow_set_foregound_window): New. (WINVER) [W32]: Define. 2008-01-31 Werner Koch * audit.c (audit_print_result): Make sure that the output is always UTF8. 2008-01-27 Werner Koch * exechelp.c (gnupg_spawn_process): Add arg FLAGS and changed all callers to pass 0 for it. 2007-12-13 Werner Koch * sexputil.c (hash_algo_from_sigval): New. * t-sexputil.c: New. * Makefile.am (module_tests): Add it. 2007-12-11 Werner Koch * asshelp.c (send_pinentry_environment): Allow using of old gpg-agents not capabale of the xauthority and pinentry_user_data options. 2007-12-04 Werner Koch * Makefile.am (t_helpfile_LDADD, module_maint_tests): New. * t-helpfile.c: New. * helpfile.c: New. * membuf.h (is_membuf_ready, MEMBUF_ZERO): New. * localename.c: New. Taken from gettext with modifications as done for GpgOL. Export one new function. * util.h (gnupg_messages_locale_name, gnupg_get_help_string): Added. * sysutils.c (gnupg_reopen_std): New. Taken from ../g10/gpg.c. 2007-11-27 Werner Koch * Makefile.am (CLEANFILES): New. * homedir.c (dirmngr_socket_name): Use CSIDL_WINDOWS. 2007-11-15 Werner Koch * asshelp.c (send_pinentry_environment): Add args XAUTHORITY and PINENTRY_USER_DATA. (start_new_gpg_agent): Ditto. 2007-11-07 Werner Koch * status.h: New. * errors.h: Remove. 2007-11-05 Werner Koch * audit.c, audit.h: New. * Makefile.am: Add rules to build audit-events.h. * exaudit.awk: New. * mkstrtable.awk: New. Taken from libgpg-error. 2007-10-19 Werner Koch * i18n.c (i18n_switchto_utf8, i18n_switchback): New. 2007-10-01 Werner Koch * sysutils.h (FD2INT, INT2FD): New. 2007-09-21 Werner Koch * homedir.c (default_homedir): Make registry work. Reported by Marc Mutz. 2007-08-29 Werner Koch * exechelp.c (gnupg_wait_process): Add arg EXITCODE. Changed all callers. (gnupg_create_inbound_pipe): New. * util.h (GNUPG_MODULE_NAME_GPGSM, GNUPG_MODULE_NAME_GPG): New. * homedir.c (gnupg_module_name): Add them 2007-08-28 Werner Koch * gettime.c (check_isotime, add_isotime): New. Originally written for DirMngr by me. (add_days_to_isotime): New. (date2jd, jd2date, days_per_month, days_per_year): New. Taken from my ancient (1988) code used in Wedit (time2.c). 2007-08-27 Werner Koch * util.h (GNUPG_MODULE_NAME_CHECK_PATTERN): New. * homedir.c (gnupg_module_name): Add it. * exechelp.c (w32_fd_or_null) [W32]: New. (gnupg_spawn_process_fd): New. (gnupg_wait_process) [W32]: Close the handle after if the process has returned. 2007-08-22 Werner Koch Updated estream from libestream. * estream.c (mem_malloc, mem_realloc, mem_free): New. Use them instead of the ES_MEM_foo. * estream.c (estream_cookie_mem): Remove members DONT_FREE, APPEND_ZERO, PTR and SIZE. Add MEMORY_LIMIT. Put GROW into a new FLAGS struct. (es_func_mem_create): Remove APPEND_ZERO, DONT_FREE, PTR and SIZE. Add MEMORY_LIMIT. (es_func_mem_write, es_func_mem_seek, es_func_mem_destroy): Revamp. (es_open_memstream): Change API to just take a memory limit and a mode argument. Rename to .. (es_fopenmem): .. this. (HAVE_W32_SYSTEM) [_WIN32]: Define if not defined. (tmpfd) [W32]: Implement directly using the W32 API. (es_fgets): Rewrite without using doreadline. 2007-08-21 Werner Koch * sysutils.c (gnupg_tmpfile): New. * t-sysutils.c: New. * Makefile.am (module_tests): Add t-sysutils. 2007-08-20 Werner Koch * exechelp.c [W32]: Redefine X_OK to F_OK. 2007-08-16 Werner Koch * Makefile.am (t_convert_DEPENDENCIES): Remove ($(PROGRAMS)): Remove. (t_common_ldadd): Use libcommon.a and not the macro. 2007-08-14 Werner Koch * homedir.c (dirmngr_socket_name): New. 2007-08-07 Werner Koch * tlv.c, tlv.h: Move from ../scd/. * tlv.c (parse_sexp, parse_ber_header): Add ERRSOURCE arg and prefix name with a _. * tlv.h: Use macro to convey ERRSOURCE. 2007-08-02 Werner Koch * gc-opt-flags.h: New. 2007-08-01 Werner Koch * estream-printf.c (read_dummy_value): Removed as it is useless now. (read_values): Remove check on !vaargs which is not anymore needed and anyway not portable. Reported by Peter O'Gorman. 2007-07-16 Werner Koch * estream.c (es_func_file_create): Clear NO_CLOSE flag. 2007-07-12 Werner Koch * sysutils.h (gnupg_fd_t): New. * sysutils.c (translate_sys2libc_fd): Use that type instead of int. (translate_sys2libc_fd_int): New. 2007-07-09 Werner Koch * t-gettime.c (test_isotime2epoch): Use time_t and not u32. 2007-07-05 Werner Koch * t-gettime.c: New. * gettime.c (isotime2epoch, epoch2isotime): New. 2007-07-04 Werner Koch * estream.c (es_init_do): Do not throw an error if pth has already been initialized. 2007-06-26 Werner Koch * Makefile.am ($(PROGRAMS)): New. * util.h (init_common_subsystems): Moved to .. * init.h: .. New. * util.h: Include init.h. * homedir.c (standard_homedir): New. (default_homedir) [W32]: Reimplemented in terms of standard_homedir. Fixed memory leak. 2007-06-25 Werner Koch * iobuf.c: Add more documentation and slighly restructured macro defintion for better readability. (FILEP_OR_FD): Rename to fp_or_fd_t. (CLOSE_CACHE): Rename to close_cache_t. * sysutils.c (translate_sys2libc_fd): New using the code from iobuf.c. * iobuf.c: Include sysutils.h. (iobuf_translate_file_handle): Remove. (translate_file_handle): Use new function. * estream-printf.c [TEST]: Header including fixes. (do_format): Do not append a trailing Nul. This avoids spurious Nuls in the es_printf output. (estream_vsnprintf, estream_vasprintf): Take this in account. * estream.h (struct es__stream): Change FLAGS to a bit structure. (ES__FLAG_WRITING): Replace by a bit from FLAGS. * estream.c (struct estream_internal): Rename FLAGS to MODEFLAGS so that they are not confused with the estream flags. (es_initialize, es_create): Add arg MODEFLAGS so that we can setup the intial writemode. Changed all callers to pass them. (es_convert_mode): Set O_BINARY. (es_func_fd_create, es_func_fp_create, es_func_file_create) [W32]: Call setmode if requested. 2007-06-24 Werner Koch * estream.c (do_fpopen, es_fpopen, es_fpopen_nc): New. (es_func_fp_create, es_func_fp_read, es_func_fp_write) (es_func_fp_seek, es_func_fp_destroy): New. 2007-06-22 Werner Koch * estream.c (es_fdopen): Factored code out to.. (do_fdopen): .. new. (es_fdopen_nc): New. (estream_cookie_fd): Add field NO_CLOSE. (es_func_fd_create): Add arg NO_CLOSE and changed all callers. (es_func_fd_destroy): Handle the new flag. * homedir.c (gnupg_libexecdir) [W32]: Factor code out to .. (w32_rootdir): .. new. (gnupg_sysconfdir, gnupg_libdir, gnupg_datadir) [W32]: Return name based on w32_rootdir(). 2007-06-21 Werner Koch * membuf.h (get_membuf_len): New. * membuf.c (init_membuf_secure): Really allocate in secure memory. (put_membuf_str): New. * ttyio.c (tty_getf): New. * util.h (ctrl_t): Declare it here. * asshelp.c (start_new_gpg_agent): New. Based on code from ../sm/call-agent.c 2007-06-20 Werner Koch * sysutils.c (gnupg_sleep): New. * sysutils.h [W32]: Remove _sleep wrapper. Changed all callers to use gnupg_sleep. * exechelp.c (build_w32_commandline_copy): New. (build_w32_commandline): Factored some code out to new function and correctly process a PGMNAME with spaces. (gnupg_spawn_process_detached) [W32]: Implement. 2007-06-14 Werner Koch * simple-pwquery.h (MAP_SPWQ_ERROR_IMPL): New. (SPWQ_NO_PIN_ENTRY): New. * simple-pwquery.c (simple_pw_set_socket): New. (agent_open): Use it if GPG_AGENT_INFO is not set. (simple_pwquery): Extended to allow returning of otehyr error codes. * util.h (GNUPG_MODULE_NAME_AGENT, GNUPG_MODULE_NAME_PINENTRY) (GNUPG_MODULE_NAME_SCDAEMON, GNUPG_MODULE_NAME_DIRMNGR) (GNUPG_MODULE_NAME_PROTECT_TOOL): New. * homedir.c (gnupg_module_name): New. (gnupg_bindir): New. 2007-06-12 Werner Koch * homedir.c (gnupg_sysconfdir): New. (gnupg_libexecdir): New. Taken from g10/misc.c:get_libexecdir. (gnupg_datadir): New. (gnupg_libdir): New. * http.c (connect_server) [W32]: Do not call init_sockets if HTTP_NO_WSASTARTUP is defined. * init.c: New. * estream.c (es_init_do): Init stream lock here because we can't use a static initialization with W32pth. 2007-06-11 Werner Koch * Makefile.am (t_common_ldadd): Use libcommonstd macro. 2007-06-06 Werner Koch * Makefile.am: Include am/cmacros.am. * sysutils.h [W32]: Remove prototypes for the registry access. * w32reg.c: Move to ../jnlib/w32-reg.c. * i18n.c (i18n_init): New. * simple-gettext.c: Remove. * iobuf.c (iobuf_get_filelength): Rename SIZE to EXSIZE to silent shadowing warning. 2007-06-04 Werner Koch * http.c [W32]: Include unistd.h also in this case. (write_server) [W32]: Fixed error code. (init_sockets): Fixed syntax error. (cookie_close): Replace close by sock_close macro. * estream.c [w32]: Do not init Mutex. * Makefile.am (common_sources) [USE_SNS_SRV]: Build srv.c only when needed. * ttyio.c (init_ttyfp) [W32]: Do not use TTYFP. * util.h: Include ../jnlib/dynload.h. * dynload.h: Move to ../jnlib. 2007-05-30 Werner Koch * estream.c (MEM_FREE, MEM_ALLOC, MEM_REALLOC): Prefix with ES_ as windows.h also has such definitions, 2007-05-15 Werner Koch * util.h: Do not include gnulib's vasprintf. Redefine asprintf and vasprintf. * xasprintf.c (xasprintf, xtryasprintf): Use estream_vasprintf. * estream-printf.h, estream-printf.c: New. Taken from current libestream SVN. * Makefile.am (common_sources): Add them. 2007-05-14 Werner Koch * sexp-parse.h (smklen): New. * sexputil.c: Include sexp-parse.h. (make_simple_sexp_from_hexstr): Replace sprintf by smklen. 2007-05-07 Werner Koch * signal.c (got_fatal_signal): Protect SIG from being clobbered by a faulty signal implementaion. Suggested by James Juran. 2007-04-25 Werner Koch * i18n.h (ngettext): New. * simple-gettext.c (ngettext): New. 2007-04-20 Werner Koch * miscellaneous.c (my_gcry_logger, my_gcry_outofcore_handler): Moved from gpg-agent to here. (my_gcry_fatalerror_handler): new. (setup_libgcrypt_logging): New. 2007-03-19 Werner Koch * miscellaneous.c (print_hexstring): New. * estream.c (es_fprintf_unlocked): New. (es_write_sanitized): New. (es_write_hexstring): New. (es_write_sanitized_utf8_buffer) [GNUPG_MAJOR_VERSION]: New. 2007-03-09 David Shaw From STABLE-BRANCH-1-4 * http.c (do_parse_uri): Remove the hkp port 11371 detection. We implement hkp in the keyserver handler, and the support here makes it appear like a bad hkp request actually succeeded. 2007-01-31 Werner Koch * Makefile.am (t_common_ldadd): Add LIBINCONV and LIBINTL. 2007-01-25 Werner Koch * simple-pwquery.c (simple_pwquery): New arg OPT_CHECK. 2006-12-13 David Shaw * Makefile.am (AM_CPPFLAGS): Include intl/ so we can reference the built-in headers. 2006-11-23 Werner Koch * http.c: Include i18n.h 2006-11-21 Werner Koch * estream.c: Remove explicit Pth soft mapping diabling becuase it is now done in config.h. 2006-11-15 Werner Koch * estream.c: Disabled Pth soft mapping. (my_funopen_hook_ret_t): New. (print_fun_writer): Use it here. * iobuf.c (fd_cache_close): Use %d instead of %p for debug output. 2006-11-03 Werner Koch * Makefile.am (t_convert_DEPENDENCIES): Add libcommon. From Gentoo. 2006-10-24 Marcus Brinkmann * Makefile.am (libcommon_a_CFLAGS): Add $(LIBASSUAN_CFLAGS). (libsimple_pwquery_a_CFLAGS): New variable. 2006-10-20 Werner Koch * convert.c (hex2bin): New. 2006-10-17 Werner Koch * estream.c (struct estream_internal, es_initialize) (es_deinitialize, print_fun_writer, es_print): New and modified functions to avoid tempfiles for printf style printing. * Makefile.am (libcommonpth_a_SOURCES): New. We now build a secon version of the library with explicit Pth support. * exechelp.c, estream.c: Make use of WITHOUT_GNU_PTH. 2006-10-08 Werner Koch * gpgrlhelp.c: Trun all functions into dummies if readline is not available. 2006-10-06 Werner Koch * Makefile.am (AM_CFLAGS): Use PTH version of libassuan. * util.h (GNUPG_GCC_A_SENTINEL): Defined for gcc >= 4. 2006-10-04 David Shaw * gpgrlhelp.c: readline requires stdio.h. 2006-10-04 Werner Koch * membuf.c (init_membuf_secure): New. (put_membuf): Make sure that ERRNO is set even if the underlying malloc code does not work properly. (get_membuf): Set ERRNO on error. (get_membuf): Allow to pass LEN as NULL. 2006-10-02 Werner Koch * iobuf.c (iobuf_unread): Removed. This code is not required. Also removed the entire unget buffer stuff. 2006-09-27 Werner Koch * util.h: Do not include strsep.h and strpbrk.h. (isascii): Removed as it is now in jnlib. * iobuf.c (pop_filter, underflow, iobuf_close): Free the unget buffer. 2006-09-27 Florian Weimer (wk) * iobuf.c (iobuf_unread): New. 2006-09-22 Werner Koch * i18n.h: Changed license to an all permissive one. * ttyio.c (tty_get): We need to use readline too. Added two more hooks. 2006-09-21 Werner Koch * ttyio.c (tty_private_set_rl_hooks): New. (tty_enable_completion, tty_disable_completion): Use a hook to enable readline support. Now always available. (tty_cleanup_rl_after_signal): New. * ttyio.h: Removed readline specific stuff. Included util.h. * common-defs.h: New. 2006-09-15 Werner Koch * convert.c: New. (hexcolon2bin): New. (bin2hex, bin2hexcolon, do_binhex): New. * t-convert.c: New 2006-09-14 Werner Koch * util.h (out_of_core): Use new gpg_error_from_syserror function. * http.c (init_sockets): Changed it to require 2.2 unless it is build within gnupg 1 where we require 1.1 (and not anymore allow for 1.0). 2006-09-07 Werner Koch * exechelp.c (gnupg_spawn_process): Factor out post fork code to .. (do_exec): .. new function. Allow passing of -1 for the fds. (gnupg_spawn_process): Terminate gcrypt's secure memory in the child. (gnupg_spawn_process_detached): New. 2006-09-06 Werner Koch * maperror.c: Removed. * util.h (out_of_core): New. 2006-09-04 Werner Koch * http.c (http_get_header): New. (capitalize_header_name, store_header): New. (parse_response): Store headers away. (send_request): Return GPG_ERR_NOT_FOUND if connect_server failed. * http.h: New flag HTTP_FLAG_NEED_HEADER. 2006-08-21 Werner Koch * Makefile.am (libcommon_a_SOURCES): Added keyserver.h * openpgpdefs.h: New. Stripped from ..g10/packet.h. 2006-08-16 Werner Koch * keyserver.h: Moved from ../include to here. * http.c: Include srv.h. * srv.c, srv.h: New. Taken from GnuPG 1.4 2006-08-14 Werner Koch * http.h (struct http_context_s): Moved to implementation. * http.c (http_open): Changed call to return a context. (http_open_document): Ditto. (http_get_read_ptr, http_get_read_ptr, http_get_status_code): New. (do_parse_uri): Replaced strlwr by straight code to ease standalone use of this file. (http_wait_response): Removed arg STATUS_CODE as it is available through an accessor function. Adjusted caller. (http_escape_string): New. * estream.c (es_read_line): Renamed to .. (doreadline): .. this. Changed all callers. (es_read_line): New. This is theusual limited getline variabnt as used at several places. Here taken and adjusted from xreadline.c (es_free): New. 2006-08-11 Werner Koch * http.c: Major internal changes to optionallly support GNUTLS and ESTREAM. (http_open): Move initialization of the stream ... (send_request): .. here. (http_register_tls_callback): New. * estream.c (es_writen): Try to seek only is a seek function has been registered. 2006-08-09 Werner Koch * http.c, http.h: New. Taken from gnupg 1.4.5, merged with changes done for the Dirmngr project (by g10 Code) and cleaned up some stuff. (make_header_line): New. Change all caller to make user of the new * Makefile.am (libcommon_a_SOURCES): Added http.c and http.h. 2006-05-23 Werner Koch * gettime.c (isotimestamp): New. * ttyio.c (tty_get_ttyname): Posixly correct usage of ctermid. * dns-cert.c: New. Taken from 1.4.3's util/cert.c. * dns-cert.h: New. 2006-05-22 Werner Koch * pka.c: New. Taked from 1.4.3. * pka.h: New. * Makefile.am: Added pka. 2006-05-19 Werner Koch * yesno.c (answer_is_yes_no_default, answer_is_yes_no_quit): Updated from 1.4.3. (answer_is_okay_cancel): new. From 1.4.3. * miscellaneous.c (match_multistr): New. Taken from 1.4.3. * ttyio.c (tty_enable_completion, tty_disable_completion): New dummy functions. * ttyio.h: Add prototypes and stubs. 2006-04-19 Werner Koch * iobuf.c (iobuf_get_fd): New. Taken from 1.4.3. (iobuf_is_pipe_filename): New. (pop_filter): Made static. (iobuf_skip_rest): New. Orginal patch by Florian Weimer. Added new argument PARTIAL. (block_filter): Remove the old gpg indeterminate length mode. (block_filter): Properly handle a partial body stream that ends with a 5-byte length that happens to be zero. (iobuf_set_block_mode, iobuf_in_block_mode): Removed as superfluous. (iobuf_get_filelength): New arg OVERFLOW. (iobuf_get_filelength) [W32]: Use GetFileSizeEx if available * miscellaneous.c (is_file_compressed): Take care of OVERFLOW. 2006-04-18 Werner Koch * homedir.c (w32_shgetfolderpath): New. Taken from gpg 1.4.3. (default_homedir): Use it. 2005-10-08 Marcus Brinkmann * signal.c (get_signal_name): Check value of HAVE_DECL_SYS_SIGLIST instead of just if it is defined. 2005-09-28 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS). 2005-07-04 Marcus Brinkmann * simple-pwquery.h (simple_pwclear): New prototype. * simple-pwquery.c (simple_pwclear): New function. 2005-06-15 Werner Koch * miscellaneous.c (make_printable_string): Made P a void*. * sexputil.c (keygrip_from_canon_sexp, cmp_simple_canon_sexp): Fixed signed/unsigned pointer mismatch. (make_simple_sexp_from_hexstr): Ditto. This is all too ugly; I wonder why gcc-4's default is to warn about them and forcing us to use cast the warning away. * iobuf.c (block_filter): Ditto. (iobuf_flush): Ditto. (iobuf_read_line): Ditto. (iobuf_read): Make BUFFER a void *. (iobuf_write): Make BUFFER a const void *. * ttyio.c (tty_print_utf8_string2): Ditto. * estream.c (estream_cookie_mem): Make MEMORY unsigned char*. (es_write): Make BUFFER a void *. (es_writen): Ditto. (es_func_fd_read, es_func_fd_write, es_func_mem_read) (es_func_mem_write): Ditto. (es_read, es_readn): Ditto. (es_func_mem_write): Made MEMORY_NEW an unsigned char *. * estream.h (es_cookie_read_function_t) (es_cookie_write_function_t): Changed buffer arg to void*. 2005-06-03 Werner Koch * estream.c: Use HAVE_CONFIG_H and not USE_CONFIG_H! (es_func_fd_read, es_func_fd_write): Protect against EINTR. 2005-06-01 Werner Koch * Makefile.am (AM_CPPFLAGS): Added. * util.h: Add some includes for gnulib. (ttyname, isascii): Define them inline. * fseeko.c, ftello.c: Removed. * strsep.c, mkdtemp.c: Removed. * ttyname.c, isascii.c: Removed. 2005-05-31 Werner Koch * dynload.h: s/__inline__/inline/. 2005-05-13 Werner Koch * signal.c (got_fatal_signal): Print the signal number if we can't get a name for it. (get_signal_name): Return NULL if no name is available. Fixed conditional for sys_siglist to the correct one. 2005-04-17 Werner Koch * sexputil.c (cmp_simple_canon_sexp): New. (make_simple_sexp_from_hexstr): New. 2005-04-07 Werner Koch * sexputil.c: New. 2005-04-11 Marcus Brinkmann * simple-pwquery.c (simple_pwquery): Use spwq_secure_free. 2005-03-03 Werner Koch * Makefile.am (AM_CFLAGS): Added PTH_CFLAGS. Noted by Kazu Yamamoto. 2005-02-25 Werner Koch * xasprintf.c (xtryasprintf): New. 2005-01-26 Moritz Schulte * Makefile.am (libcommon_a_SOURCES): New source files: estream.c, estream.h. * estream.c, estream.h: New files. 2005-01-03 Werner Koch * asshelp.c (send_pinentry_environment): Fixed changed from 2004-12-18; cut+paste error for lc-messages. 2004-12-21 Werner Koch * simple-pwquery.c (agent_open) [W32]: Implement for W32. (readline) [W32]: Use recv instead of read. (writen) [W32]: Use send instead of write. (my_stpcpy): Define a stpcpy replacement so that this file continues to be self-contained. (agent_send_all_options) [W32]: Don't call ttyname. 2004-12-21 Marcus Brinkmann * simple-pwquery.h (simple_query): Add prototype. * simple-pwquery.c (simple_query): New function. 2004-12-21 Werner Koch * signal.c (got_fatal_signal, got_usr_signal) (got_fatal_signal) [DOSISH]: Don't build. * simple-gettext.c: Include sysutils.h * homedir.c: New. Use CSIDL_APPDATA for W32 as the default home directory. * Makefile.am (libcommon_a_SOURCES): Add it. (EXTRA_DIST): Removed mkerror and mkerrtok. 2004-12-20 Werner Koch * sysutils.h [W32]: Define sleep. * util.h: Add prototype for mkdtemp. * membuf.c (put_membuf): Wipe out buffer after a failed realloc. 2004-12-19 Werner Koch * maperror.c (map_assuan_err_with_source): Oops, args were swapped. 2004-12-18 Werner Koch * maperror.c (map_assuan_err): Renamed to .. (map_assuan_err_with_source): .. this and add arg SOURCE.c * asshelp.c (send_pinentry_environment, send_one_option): Add arg ERRSOURCE. 2004-12-15 Werner Koch * sysutils.h [W32]: Prototypes for registry functions. * w32reg.c: Include sysutils.h * simple-pwquery.c [W32]: Dummy code to allow a build. * exechelp.c [W32]: Implemented for W32 . * ttyname.c: New. * asshelp.c (send_one_option): New. (send_pinentry_environment): Cleaned up and made sure that empty values are not send. 2004-12-07 Werner Koch * asshelp.c (send_pinentry_environment) [W32]: Do not use ttyname. 2004-12-06 Werner Koch * exechelp.h, exechelp.c: New. Based on code from ../sm/import.c. 2004-12-03 Werner Koch * strsep.c: Fixed copyright comments. 2004-11-26 Werner Koch * simple-gettext.c: New taken from gnupg 1.3.x * simple-pwquery.c [_WIN32]: Include winsock2.h. (agent_open): Disable it until we have our AF_UNIX implementation ready. * fseeko.c, ftello.c: Include sys/types for the sake of W32. 2004-11-23 Werner Koch * b64enc.c: Include stdio.h and string.h 2004-08-18 Werner Koch * simple-pwquery.c (simple_pwquery): Handle gpg-error style return code for canceled. 2004-07-20 Werner Koch * maperror.c: Removed header ksba.h. Not required anymore. 2004-06-14 Werner Koch * xreadline.c: New. Based on the iobuf_read_line function. 2004-05-12 Werner Koch * util.h (xtrycalloc_secure,xtrymalloc_secure): New. 2004-05-11 Werner Koch * sysutils.c (disable_core_dumps): Only set the current limit. (enable_core_dumps): New. 2004-04-13 Werner Koch * simple-pwquery.c (copy_and_escape): Relaxed quoting. 2004-04-05 Werner Koch * errors.h (STATUS_NEWSIG): New. 2004-03-11 Werner Koch * dynload.h [__MINGW32__]: Define RTLD_LAZY. 2004-03-09 Werner Koch * maperror.c (map_assuan_err): Map the Locale_Problem item. 2004-03-03 Werner Koch * asshelp.c, asshelp.h: New. (send_pinentry_environment): New. Code taken from ../sm/call-agent.c. 2004-02-19 Werner Koch * simple-pwquery.c (agent_open): Don't mangle INFOSTR. 2004-02-17 Werner Koch * simple-pwquery.c (agent_open): Ignore an empty GPG_AGENT_INFO. * errors.h: Added STATUS_IMPORT_OK. 2004-02-10 Werner Koch * b64enc.c: New. Based on code from ../sm/base64.c. 2004-01-30 Marcus Brinkmann * Makefile.am (libcommon_a_SOURCES): Add xasprintf.c. * miscellaneous.c (xasprintf): Moved to ... * xasprintf (xasprintf): ... here. New file. This allows to use xasprintf without sucking in gpg-error. 2004-01-27 Werner Koch * sexp-parse.h: New; moved from../agent. * util.h (xtoi_4): New. 2003-12-23 Werner Koch * maperror.c (map_assuan_err): Prepared for a new error code. 2003-12-17 Werner Koch * gettime.c (asctimestamp): Add a note on a non-avoidable gcc warning. * util.h [!HAVE_VASPRINTF]: Add printf format attribute to the replacement function. * miscellaneous.c (xasprintf): New. 2003-11-14 Werner Koch * mkdtemp.c (mkdtemp): Use gcry_create_nonce. * cryptmiss.c: Removed. 2003-11-13 Werner Koch * util.h (vasprintf): Also fixed the prototype. * vasprintf.c (vasprintf): ARGS should not be a pointer. Fixed segv on Solaris. Reported by Andrew J. Schorr. 2003-11-12 Werner Koch * maperror.c (map_ksba_err, map_gcry_err, map_kbx_err): Removed. 2003-10-31 Werner Koch * util.h (gnupg_isotime_t): New. (gnupg_copy_time): New. * gettime.c (gnupg_get_isotime): New. 2003-09-23 Werner Koch * iobuf.c (check_special_filename): Replaced is isdigit by digitp to avoid passing negative values and potential locale problems. Problem noted by Christian Biere. * util.h (ascii_isspace): New. 2003-09-18 Werner Koch * ttyio.c (tty_fprintf): New. (tty_print_string, tty_print_utf8_string2) (tty_print_utf8_string): Made P argument const byte*. 2003-08-20 Marcus Brinkmann * maperror.c (map_ksba_err): Map -1. Use gpg_err_make to set the error source. 2003-08-14 Timo Schulz * dynload.h. New. W32 wrapper around the dynload mechanism. 2003-07-15 Werner Koch * simple-pwquery.c, simple-pwquery.h: New; moved from ../agent. * Makefile.am (libsimple_pwquery_a_LIBADD): New. 2003-06-25 Werner Koch * maperror.c (map_to_assuan_status): Directly map 0 to 0. 2003-06-17 Werner Koch * gettime.c (scan_isodatestr,add_days_to_timestamp,strtimevalue) (strtimestamp,asctimestamp): New. Code taken from gnupg 1.3.2 mischelp.c. * yesno.c: New. Code taken from gnupg 1.3.2 mischelp.c * miscellaneous.c: New. * util.h: Include utf8conf.h 2003-06-16 Werner Koch * gettime.c (make_timestamp): New. * ttyio.c: New. Taken from gnupg 1.2. * ttyio.h: Move from ../include. 2003-06-13 Werner Koch * util.h (seterr): Removed macro. (xmalloc_secure,xcalloc_secure): New. 2003-06-11 Werner Koch * iobuf.c (iobuf_writebyte,iobuf_write): Return error code from iobuf_flush. (iobuf_writestr): Ditto. 2003-06-10 Werner Koch * iobuf.c, iobuf.h: New. Taken from current gnupg 1.3 CVS. Run indent on it and adjusted error handling to libgpg-error style. Replaced IOBUF by iobuf_t. Renamed malloc functions. 2003-06-04 Werner Koch * errors.h: Removed all error codes. We keep the status codes for now. * Makefile.am: Do not create errors.c anymore; remove it from the sources. * maperror.c: Don't include error.h. Change all error codes to libgpg-error style. (map_assuan_err): Changed to new Assuan error code convention. (map_to_assuan_status): Likewise. (map_gcry_err,map_kbx_err): Not needed. For now dummy functions. * membuf.c, membuf.h: New. Code taken from ../sm/call-agent.h. * Makefile.am: Added above. 2003-04-29 Werner Koch * util.h (fopencokokie): Removed prototype and struct. * fopencookie.c: Removed. * maperror.c: Use system assuan.h 2002-10-31 Neal H. Walfield * isascii.c: New file. * putc_unlocked.c: Likewise. 2002-10-28 Neal H. Walfield * signal.c (caught_fatal_sig): Remove superfluous zero initializer. (caught_sigusr1): Likewise. 2002-09-04 Neal H. Walfield * vasprintf.c (vasprintf) [va_copy]: Use va_copy. [!va_copy && __va_copy]: Use __va_copy. [!va_copy && !__va_copy]: Only now fall back to using memcpy. 2002-08-21 Werner Koch * errors.h: Added STATUS_IMPORT_PROBLEM. 2002-08-20 Werner Koch * vasprintf.c: Hack to handle NULL for %s. 2002-08-09 Werner Koch * signal.c: New. Taken from GnuPG 1.1.91. 2002-07-23 Werner Koch * util.h (_IO_cookie_io_functions_t): Fixed typo. Noted by Richard Lefebvre. 2002-07-22 Werner Koch * fseeko.c, ftello.c: New. 2002-06-28 Werner Koch * maperror.c (map_to_assuan_status): Map more errorcodes to Bad Certificate. 2002-06-26 Werner Koch * maperror.c (map_to_assuan_status): Map EOF to No_Data_Available. 2002-06-10 Werner Koch * errors.h (gnupg_error_token): Add new prototype. (STATUS_ERROR): New. * mkerrtok: New. * Makefile.am: Use it to create the new error token function. 2002-06-04 Werner Koch * maperror.c (map_to_assuan_status): Map Bad_CA_Certificate. 2002-05-23 Werner Koch * no-pth.c, Makefile.am: Removed. 2002-05-22 Werner Koch * mkdtemp.c: Replaced byte by unsigned char because it is no longer defined in gcrypt.h. 2002-05-21 Werner Koch * maperror.c (map_gcry_err): Add libgcrypt's new S-expression errors. (map_ksba_err): Add a few mappings. 2002-05-14 Werner Koch * gettime.c: New. 2002-05-03 Werner Koch * errors.h: Added STARUS_EXPSIG and STATUS_EXPKEYSIG. 2002-04-15 Werner Koch * cryptmiss.c: New. 2002-02-14 Werner Koch * maperror.c: Add more assuan<->gnupg mappings. 2002-02-12 Werner Koch * fopencookie.c: Dummy function. * vasprintf.c: New. Taken from binutils-2.9.1 and dropped all non ANSI-C stuff. Merged with asprintf version. * no-pth.c: New. 2002-01-23 Werner Koch * mkdtemp.c: Copied from gnupg-1.0.6c and changed to use libgcrypt. 2002-01-19 Werner Koch * sysutils.c: New. This is the misc.c file from gnupg 1.0.6 with the OpenPGP stuff removed. * sysutils.h: New. 2002-01-15 Werner Koch * maperror.c: Add mapping for Not_Trusted. 2002-01-11 Werner Koch * maperror.c (map_assuan_err): Codes for CRL 2002-01-08 Werner Koch * util.h (spacep): New. 2002-01-02 Werner Koch * maperror.c (map_to_assuan_status): New. Merged from ../agent and ../sm. 2001-12-20 Werner Koch * maperror.c (map_gcry_err): Add some mappings. 2001-12-18 Werner Koch * Makefile.am (AM_CPPFLAGS): Include flags for gcrypt and ksba 2001-12-14 Werner Koch * util.h (digitp, hexdigitp): New ctype like macros. (atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New. Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/common/estream.c b/common/estream.c index 401590552..3ab68b5ff 100644 --- a/common/estream.c +++ b/common/estream.c @@ -1,3305 +1,3641 @@ /* estream.c - Extended Stream I/O Library - * Copyright (C) 2004, 2005, 2006, 2007, 2009 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 g10 Code GmbH * * This file is part of Libestream. * * Libestream 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. * * Libestream 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 Libestream; if not, see . + * + * ALTERNATIVELY, Libestream may be distributed under the terms of the + * following license, in which case the provisions of this license are + * required INSTEAD OF the GNU General Public License. If you wish to + * allow use of your version of this file only under the terms of the + * GNU General Public License, and not to allow others to use your + * version of this file under the terms of the following license, + * indicate your decision by deleting this paragraph and the license + * below. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef USE_ESTREAM_SUPPORT_H # include #endif #ifdef HAVE_CONFIG_H # include #endif #if defined(_WIN32) && !defined(HAVE_W32_SYSTEM) # define HAVE_W32_SYSTEM 1 +# if defined(__MINGW32CE__) && !defined (HAVE_W32CE_SYSTEM) +# define HAVE_W32CE_SYSTEM +# endif #endif #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_W32_SYSTEM # include #endif +#ifdef HAVE_W32CE_SYSTEM +# include /* ERRNO replacement. */ +#endif #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ # undef HAVE_PTH # undef USE_GNU_PTH #endif #ifdef HAVE_PTH # include #endif /* This is for the special hack to use estream.c in GnuPG. */ #ifdef GNUPG_MAJOR_VERSION # include "../common/util.h" #endif #ifndef HAVE_MKSTEMP int mkstemp (char *template); #endif #ifndef HAVE_MEMRCHR void *memrchr (const void *block, int c, size_t size); #endif #include #include #ifndef O_BINARY #define O_BINARY 0 #endif +#ifdef HAVE_W32CE_SYSTEM +# define _set_errno(a) gpg_err_set_errno ((a)) +/* Setmode is missing in cegcc but available since CE 5.0. */ +int _setmode (int handle, int mode); +# define setmode(a,b) _setmode ((a),(b)) +#else +# define _set_errno(a) do { errno = (a); } while (0) +#endif + +#ifdef HAVE_W32_SYSTEM +# define IS_INVALID_FD(a) ((void*)(a) == (void*)(-1)) +#else +# define IS_INVALID_FD(a) ((a) == -1) +#endif + + /* Generally used types. */ typedef void *(*func_realloc_t) (void *mem, size_t size); typedef void (*func_free_t) (void *mem); /* Buffer management layer. */ #define BUFFER_BLOCK_SIZE BUFSIZ #define BUFFER_UNREAD_SIZE 16 /* Locking. */ #ifdef HAVE_PTH typedef pth_mutex_t estream_mutex_t; # define ESTREAM_MUTEX_INITIALIZER PTH_MUTEX_INIT # define ESTREAM_MUTEX_LOCK(mutex) \ pth_mutex_acquire (&(mutex), 0, NULL) # define ESTREAM_MUTEX_UNLOCK(mutex) \ pth_mutex_release (&(mutex)) # define ESTREAM_MUTEX_TRYLOCK(mutex) \ ((pth_mutex_acquire (&(mutex), 1, NULL) == TRUE) ? 0 : -1) # define ESTREAM_MUTEX_INITIALIZE(mutex) \ pth_mutex_init (&(mutex)) #else typedef void *estream_mutex_t; static inline void dummy_mutex_call_void (estream_mutex_t mutex) { (void)mutex; } static inline int dummy_mutex_call_int (estream_mutex_t mutex) { (void)mutex; return 0; } # define ESTREAM_MUTEX_INITIALIZER NULL # define ESTREAM_MUTEX_LOCK(mutex) dummy_mutex_call_void ((mutex)) # define ESTREAM_MUTEX_UNLOCK(mutex) dummy_mutex_call_void ((mutex)) # define ESTREAM_MUTEX_TRYLOCK(mutex) dummy_mutex_call_int ((mutex)) # define ESTREAM_MUTEX_INITIALIZE(mutex) dummy_mutex_call_void ((mutex)) #endif /* Primitive system I/O. */ #ifdef HAVE_PTH # define ESTREAM_SYS_READ es_pth_read # define ESTREAM_SYS_WRITE es_pth_write +# define ESTREAM_SYS_YIELD() pth_yield (NULL) #else # define ESTREAM_SYS_READ read # define ESTREAM_SYS_WRITE write +# define ESTREAM_SYS_YIELD() do { } while (0) #endif /* Misc definitions. */ #define ES_DEFAULT_OPEN_MODE (S_IRUSR | S_IWUSR) /* An internal stream object. */ struct estream_internal { unsigned char buffer[BUFFER_BLOCK_SIZE]; unsigned char unread_buffer[BUFFER_UNREAD_SIZE]; estream_mutex_t lock; /* Lock. */ void *cookie; /* Cookie. */ void *opaque; /* Opaque data. */ unsigned int modeflags; /* Flags for the backend. */ + char *printable_fname; /* Malloced filename for es_fname_get. */ off_t offset; es_cookie_read_function_t func_read; es_cookie_write_function_t func_write; es_cookie_seek_function_t func_seek; es_cookie_close_function_t func_close; int strategy; int fd; struct { unsigned int err: 1; unsigned int eof: 1; } indicators; unsigned int deallocate_buffer: 1; + unsigned int is_stdstream:1; /* This is a standard stream. */ + unsigned int stdstream_fd:2; /* 0, 1 or 2 for a standard stream. */ unsigned int print_err: 1; /* Error in print_fun_writer. */ + unsigned int printable_fname_inuse: 1; /* es_fname_get has been used. */ int print_errno; /* Errno from print_fun_writer. */ size_t print_ntotal; /* Bytes written from in print_fun_writer. */ FILE *print_fp; /* Stdio stream used by print_fun_writer. */ }; typedef struct estream_internal *estream_internal_t; #define ESTREAM_LOCK(stream) ESTREAM_MUTEX_LOCK (stream->intern->lock) #define ESTREAM_UNLOCK(stream) ESTREAM_MUTEX_UNLOCK (stream->intern->lock) #define ESTREAM_TRYLOCK(stream) ESTREAM_MUTEX_TRYLOCK (stream->intern->lock) /* Stream list. */ typedef struct estream_list *estream_list_t; struct estream_list { estream_t car; estream_list_t cdr; estream_list_t *prev_cdr; }; static estream_list_t estream_list; static estream_mutex_t estream_list_lock; #define ESTREAM_LIST_LOCK ESTREAM_MUTEX_LOCK (estream_list_lock) #define ESTREAM_LIST_UNLOCK ESTREAM_MUTEX_UNLOCK (estream_list_lock) +/* File descriptors registered to be used as the standard file handles. */ +static int custom_std_fds[3]; +static unsigned char custom_std_fds_valid[3]; + + #ifndef EOPNOTSUPP # define EOPNOTSUPP ENOSYS #endif - +/* Local prototypes. */ +static void fname_set_internal (estream_t stream, const char *fname, int quote); + + + /* Macros. */ /* Calculate array dimension. */ #ifndef DIM #define DIM(array) (sizeof (array) / sizeof (*array)) #endif #define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A')) /* Evaluate EXPRESSION, setting VARIABLE to the return code, if VARIABLE is zero. */ #define SET_UNLESS_NONZERO(variable, tmp_variable, expression) \ do \ { \ tmp_variable = expression; \ if ((! variable) && tmp_variable) \ variable = tmp_variable; \ } \ while (0) /* Malloc wrappers to overcome problems on some older OSes. */ static void * mem_alloc (size_t n) { if (!n) n++; return malloc (n); } static void * mem_realloc (void *p, size_t n) { if (!p) return mem_alloc (n); return realloc (p, n); } static void mem_free (void *p) { if (p) free (p); } /* * List manipulation. */ -/* Add STREAM to the list of registered stream objects. */ +/* Add STREAM to the list of registered stream objects. If + WITH_LOCKED_LIST is true we assumed that the list of streams is + already locked. */ static int -es_list_add (estream_t stream) +es_list_add (estream_t stream, int with_locked_list) { estream_list_t list_obj; int ret; list_obj = mem_alloc (sizeof (*list_obj)); if (! list_obj) ret = -1; else { - ESTREAM_LIST_LOCK; + if (!with_locked_list) + ESTREAM_LIST_LOCK; list_obj->car = stream; list_obj->cdr = estream_list; list_obj->prev_cdr = &estream_list; if (estream_list) estream_list->prev_cdr = &list_obj->cdr; estream_list = list_obj; - ESTREAM_LIST_UNLOCK; + if (!with_locked_list) + ESTREAM_LIST_UNLOCK; ret = 0; } return ret; } /* Remove STREAM from the list of registered stream objects. */ static void -es_list_remove (estream_t stream) +es_list_remove (estream_t stream, int with_locked_list) { estream_list_t list_obj; - ESTREAM_LIST_LOCK; + if (!with_locked_list) + ESTREAM_LIST_LOCK; for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) if (list_obj->car == stream) { *list_obj->prev_cdr = list_obj->cdr; if (list_obj->cdr) list_obj->cdr->prev_cdr = list_obj->prev_cdr; mem_free (list_obj); break; } - ESTREAM_LIST_UNLOCK; + if (!with_locked_list) + ESTREAM_LIST_UNLOCK; } /* Type of an stream-iterator-function. */ typedef int (*estream_iterator_t) (estream_t stream); /* Iterate over list of registered streams, calling ITERATOR for each of them. */ static int es_list_iterate (estream_iterator_t iterator) { estream_list_t list_obj; int ret = 0; ESTREAM_LIST_LOCK; for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) ret |= (*iterator) (list_obj->car); ESTREAM_LIST_UNLOCK; return ret; } /* * I/O Helper * * Unfortunately our Pth emulation for Windows expects system handles * for pth_read and pth_write. We use a simple approach to fix this: * If the function returns an error we fall back to a vanilla read or * write, assuming that we do I/O on a plain file where the operation * can't block. */ #ifdef HAVE_PTH static int es_pth_read (int fd, void *buffer, size_t size) { # ifdef HAVE_W32_SYSTEM int rc = pth_read (fd, buffer, size); if (rc == -1 && errno == EINVAL) rc = read (fd, buffer, size); return rc; # else /*!HAVE_W32_SYSTEM*/ return pth_read (fd, buffer, size); # endif /* !HAVE_W32_SYSTEM*/ } static int es_pth_write (int fd, const void *buffer, size_t size) { # ifdef HAVE_W32_SYSTEM int rc = pth_write (fd, buffer, size); if (rc == -1 && errno == EINVAL) rc = write (fd, buffer, size); return rc; # else /*!HAVE_W32_SYSTEM*/ return pth_write (fd, buffer, size); # endif /* !HAVE_W32_SYSTEM*/ } #endif /*HAVE_PTH*/ +static void +es_deinit (void) +{ + /* Flush all streams. */ + es_fflush (NULL); +} + + /* * Initialization. */ static int es_init_do (void) { -#ifdef HAVE_PTH static int initialized; if (!initialized) { +#ifdef HAVE_PTH if (!pth_init () && errno != EPERM ) return -1; if (pth_mutex_init (&estream_list_lock)) initialized = 1; - } +#else + initialized = 1; #endif + atexit (es_deinit); + } return 0; } /* * I/O methods. */ /* Implementation of Memory I/O. */ /* Cookie for memory objects. */ typedef struct estream_cookie_mem { unsigned int modeflags; /* Open flags. */ unsigned char *memory; /* Allocated data buffer. */ size_t memory_size; /* Allocated size of MEMORY. */ size_t memory_limit; /* Caller supplied maximum allowed allocation size or 0 for no limit. */ size_t offset; /* Current offset in MEMORY. */ size_t data_len; /* Used length of data in MEMORY. */ size_t block_size; /* Block size. */ struct { unsigned int grow: 1; /* MEMORY is allowed to grow. */ } flags; func_realloc_t func_realloc; func_free_t func_free; } *estream_cookie_mem_t; /* Create function for memory objects. DATA is either NULL or a user supplied buffer with the initial conetnt of the memory buffer. If DATA is NULL, DATA_N and DATA_LEN need to be 0 as well. If DATA is not NULL, DATA_N gives the allocated size of DATA and DATA_LEN the used length in DATA. */ static int es_func_mem_create (void *ES__RESTRICT *ES__RESTRICT cookie, unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len, size_t block_size, unsigned int grow, func_realloc_t func_realloc, func_free_t func_free, unsigned int modeflags, size_t memory_limit) { estream_cookie_mem_t mem_cookie; int err; if (!data && (data_n || data_len)) { - errno = EINVAL; + _set_errno (EINVAL); return -1; } mem_cookie = mem_alloc (sizeof (*mem_cookie)); if (!mem_cookie) err = -1; else { mem_cookie->modeflags = modeflags; mem_cookie->memory = data; mem_cookie->memory_size = data_n; mem_cookie->memory_limit = memory_limit; mem_cookie->offset = 0; mem_cookie->data_len = data_len; mem_cookie->block_size = block_size; mem_cookie->flags.grow = !!grow; mem_cookie->func_realloc = func_realloc ? func_realloc : mem_realloc; mem_cookie->func_free = func_free ? func_free : mem_free; *cookie = mem_cookie; err = 0; } return err; } /* Read function for memory objects. */ static ssize_t es_func_mem_read (void *cookie, void *buffer, size_t size) { estream_cookie_mem_t mem_cookie = cookie; ssize_t ret; if (size > mem_cookie->data_len - mem_cookie->offset) size = mem_cookie->data_len - mem_cookie->offset; if (size) { memcpy (buffer, mem_cookie->memory + mem_cookie->offset, size); mem_cookie->offset += size; } ret = size; return ret; } /* Write function for memory objects. */ static ssize_t es_func_mem_write (void *cookie, const void *buffer, size_t size) { estream_cookie_mem_t mem_cookie = cookie; ssize_t ret; size_t nleft; if (!size) return 0; /* A flush is a NOP for memory objects. */ if (mem_cookie->modeflags & O_APPEND) { /* Append to data. */ mem_cookie->offset = mem_cookie->data_len; } assert (mem_cookie->memory_size >= mem_cookie->offset); nleft = mem_cookie->memory_size - mem_cookie->offset; /* If we are not allowed to grow limit the size to the left space. */ if (!mem_cookie->flags.grow && size > nleft) size = nleft; /* Enlarge the memory buffer if needed. */ if (size > nleft) { unsigned char *newbuf; size_t newsize; if (!mem_cookie->memory_size) newsize = size; /* Not yet allocated. */ else newsize = mem_cookie->memory_size + (nleft - size); if (newsize < mem_cookie->offset) { - errno = EINVAL; + _set_errno (EINVAL); return -1; } /* Round up to the next block length. BLOCK_SIZE should always be set; we check anyway. */ if (mem_cookie->block_size) { newsize += mem_cookie->block_size - 1; if (newsize < mem_cookie->offset) { - errno = EINVAL; + _set_errno (EINVAL); return -1; } newsize /= mem_cookie->block_size; newsize *= mem_cookie->block_size; } /* Check for a total limit. */ if (mem_cookie->memory_limit && newsize > mem_cookie->memory_limit) { - errno = ENOSPC; + _set_errno (ENOSPC); return -1; } newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); if (!newbuf) return -1; mem_cookie->memory = newbuf; mem_cookie->memory_size = newsize; assert (mem_cookie->memory_size >= mem_cookie->offset); nleft = mem_cookie->memory_size - mem_cookie->offset; assert (size <= nleft); } memcpy (mem_cookie->memory + mem_cookie->offset, buffer, size); if (mem_cookie->offset + size > mem_cookie->data_len) mem_cookie->data_len = mem_cookie->offset + size; mem_cookie->offset += size; ret = size; return ret; } /* Seek function for memory objects. */ static int es_func_mem_seek (void *cookie, off_t *offset, int whence) { estream_cookie_mem_t mem_cookie = cookie; off_t pos_new; switch (whence) { case SEEK_SET: pos_new = *offset; break; case SEEK_CUR: pos_new = mem_cookie->offset += *offset; break; case SEEK_END: pos_new = mem_cookie->data_len += *offset; break; default: - errno = EINVAL; + _set_errno (EINVAL); return -1; } if (pos_new > mem_cookie->memory_size) { size_t newsize; void *newbuf; if (!mem_cookie->flags.grow) { - errno = ENOSPC; + _set_errno (ENOSPC); return -1; } newsize = pos_new + mem_cookie->block_size - 1; if (newsize < pos_new) { - errno = EINVAL; + _set_errno (EINVAL); return -1; } newsize /= mem_cookie->block_size; newsize *= mem_cookie->block_size; if (mem_cookie->memory_limit && newsize > mem_cookie->memory_limit) { - errno = ENOSPC; + _set_errno (ENOSPC); return -1; } newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); if (!newbuf) return -1; mem_cookie->memory = newbuf; mem_cookie->memory_size = newsize; } if (pos_new > mem_cookie->data_len) { /* Fill spare space with zeroes. */ memset (mem_cookie->memory + mem_cookie->data_len, 0, pos_new - mem_cookie->data_len); mem_cookie->data_len = pos_new; } mem_cookie->offset = pos_new; *offset = pos_new; return 0; } /* Destroy function for memory objects. */ static int es_func_mem_destroy (void *cookie) { estream_cookie_mem_t mem_cookie = cookie; if (cookie) { mem_cookie->func_free (mem_cookie->memory); mem_free (mem_cookie); } return 0; } static es_cookie_io_functions_t estream_functions_mem = { es_func_mem_read, es_func_mem_write, es_func_mem_seek, es_func_mem_destroy }; /* Implementation of fd I/O. */ /* Cookie for fd objects. */ typedef struct estream_cookie_fd { int fd; /* The file descriptor we are using for actual output. */ int no_close; /* If set we won't close the file descriptor. */ } *estream_cookie_fd_t; /* Create function for fd objects. */ static int es_func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close) { estream_cookie_fd_t fd_cookie; int err; fd_cookie = mem_alloc (sizeof (*fd_cookie)); if (! fd_cookie) err = -1; else { #ifdef HAVE_DOSISH_SYSTEM /* Make sure it is in binary mode if requested. */ if ( (modeflags & O_BINARY) ) setmode (fd, O_BINARY); #else (void)modeflags; #endif fd_cookie->fd = fd; fd_cookie->no_close = no_close; *cookie = fd_cookie; err = 0; } return err; } /* Read function for fd objects. */ static ssize_t es_func_fd_read (void *cookie, void *buffer, size_t size) { estream_cookie_fd_t file_cookie = cookie; ssize_t bytes_read; - - do - bytes_read = ESTREAM_SYS_READ (file_cookie->fd, buffer, size); - while (bytes_read == -1 && errno == EINTR); + + if (IS_INVALID_FD (file_cookie->fd)) + { + ESTREAM_SYS_YIELD (); + bytes_read = 0; + } + else + { + do + bytes_read = ESTREAM_SYS_READ (file_cookie->fd, buffer, size); + while (bytes_read == -1 && errno == EINTR); + } return bytes_read; } /* Write function for fd objects. */ static ssize_t es_func_fd_write (void *cookie, const void *buffer, size_t size) - { estream_cookie_fd_t file_cookie = cookie; ssize_t bytes_written; - do - bytes_written = ESTREAM_SYS_WRITE (file_cookie->fd, buffer, size); - while (bytes_written == -1 && errno == EINTR); + if (IS_INVALID_FD (file_cookie->fd)) + { + ESTREAM_SYS_YIELD (); + bytes_written = size; /* Yeah: Success writing to the bit bucket. */ + } + else + { + do + bytes_written = ESTREAM_SYS_WRITE (file_cookie->fd, buffer, size); + while (bytes_written == -1 && errno == EINTR); + } return bytes_written; } /* Seek function for fd objects. */ static int es_func_fd_seek (void *cookie, off_t *offset, int whence) { estream_cookie_fd_t file_cookie = cookie; off_t offset_new; int err; - offset_new = lseek (file_cookie->fd, *offset, whence); - if (offset_new == -1) - err = -1; + if (IS_INVALID_FD (file_cookie->fd)) + { + _set_errno (ESPIPE); + err = -1; + } else { - *offset = offset_new; - err = 0; + offset_new = lseek (file_cookie->fd, *offset, whence); + if (offset_new == -1) + err = -1; + else + { + *offset = offset_new; + err = 0; + } } return err; } /* Destroy function for fd objects. */ static int es_func_fd_destroy (void *cookie) { estream_cookie_fd_t fd_cookie = cookie; int err; if (fd_cookie) { - err = fd_cookie->no_close? 0 : close (fd_cookie->fd); + if (IS_INVALID_FD (fd_cookie->fd)) + err = 0; + else + err = fd_cookie->no_close? 0 : close (fd_cookie->fd); mem_free (fd_cookie); } else err = 0; return err; } static es_cookie_io_functions_t estream_functions_fd = { es_func_fd_read, es_func_fd_write, es_func_fd_seek, es_func_fd_destroy }; /* Implementation of FILE* I/O. */ /* Cookie for fp objects. */ typedef struct estream_cookie_fp { FILE *fp; /* The file pointer we are using for actual output. */ int no_close; /* If set we won't close the file pointer. */ } *estream_cookie_fp_t; /* Create function for fd objects. */ static int es_func_fp_create (void **cookie, FILE *fp, unsigned int modeflags, int no_close) { estream_cookie_fp_t fp_cookie; int err; fp_cookie = mem_alloc (sizeof *fp_cookie); if (!fp_cookie) err = -1; else { #ifdef HAVE_DOSISH_SYSTEM /* Make sure it is in binary mode if requested. */ if ( (modeflags & O_BINARY) ) setmode (fileno (fp), O_BINARY); #else (void)modeflags; #endif fp_cookie->fp = fp; fp_cookie->no_close = no_close; *cookie = fp_cookie; err = 0; } return err; } /* Read function for FILE* objects. */ static ssize_t es_func_fp_read (void *cookie, void *buffer, size_t size) { estream_cookie_fp_t file_cookie = cookie; ssize_t bytes_read; - bytes_read = fread (buffer, 1, size, file_cookie->fp); + if (file_cookie->fp) + bytes_read = fread (buffer, 1, size, file_cookie->fp); + else + bytes_read = 0; if (!bytes_read && ferror (file_cookie->fp)) return -1; return bytes_read; } /* Write function for FILE* objects. */ static ssize_t es_func_fp_write (void *cookie, const void *buffer, size_t size) { estream_cookie_fp_t file_cookie = cookie; size_t bytes_written; - bytes_written = fwrite (buffer, 1, size, file_cookie->fp); + + if (file_cookie->fp) + bytes_written = fwrite (buffer, 1, size, file_cookie->fp); + else + bytes_written = size; /* Successfully written to the bit bucket. */ if (bytes_written != size) return -1; return bytes_written; } /* Seek function for FILE* objects. */ static int es_func_fp_seek (void *cookie, off_t *offset, int whence) { estream_cookie_fp_t file_cookie = cookie; long int offset_new; + if (!file_cookie->fp) + { + _set_errno (ESPIPE); + return -1; + } + if ( fseek (file_cookie->fp, (long int)*offset, whence) ) { - fprintf (stderr, "\nfseek failed: errno=%d (%s)\n", errno,strerror (errno)); - return -1; + /* fprintf (stderr, "\nfseek failed: errno=%d (%s)\n", */ + /* errno,strerror (errno)); */ + return -1; } offset_new = ftell (file_cookie->fp); if (offset_new == -1) { - fprintf (stderr, "\nftell failed: errno=%d (%s)\n", errno,strerror (errno)); - return -1; + /* fprintf (stderr, "\nftell failed: errno=%d (%s)\n", */ + /* errno,strerror (errno)); */ + return -1; } *offset = offset_new; return 0; } -/* Destroy function for fd objects. */ +/* Destroy function for FILE* objects. */ static int es_func_fp_destroy (void *cookie) { estream_cookie_fp_t fp_cookie = cookie; int err; if (fp_cookie) { - fflush (fp_cookie->fp); - err = fp_cookie->no_close? 0 : fclose (fp_cookie->fp); + if (fp_cookie->fp) + { + fflush (fp_cookie->fp); + err = fp_cookie->no_close? 0 : fclose (fp_cookie->fp); + } + else + err = 0; mem_free (fp_cookie); } else err = 0; return err; } static es_cookie_io_functions_t estream_functions_fp = { es_func_fp_read, es_func_fp_write, es_func_fp_seek, es_func_fp_destroy }; /* Implementation of file I/O. */ /* Create function for file objects. */ static int es_func_file_create (void **cookie, int *filedes, const char *path, unsigned int modeflags) { estream_cookie_fd_t file_cookie; int err; int fd; err = 0; fd = -1; file_cookie = mem_alloc (sizeof (*file_cookie)); if (! file_cookie) { err = -1; goto out; } fd = open (path, modeflags, ES_DEFAULT_OPEN_MODE); if (fd == -1) { err = -1; goto out; } #ifdef HAVE_DOSISH_SYSTEM /* Make sure it is in binary mode if requested. */ if ( (modeflags & O_BINARY) ) setmode (fd, O_BINARY); #endif file_cookie->fd = fd; file_cookie->no_close = 0; *cookie = file_cookie; *filedes = fd; out: if (err) mem_free (file_cookie); return err; } -static es_cookie_io_functions_t estream_functions_file = - { - es_func_fd_read, - es_func_fd_write, - es_func_fd_seek, - es_func_fd_destroy - }; - static int es_convert_mode (const char *mode, unsigned int *modeflags) { unsigned int omode, oflags; switch (*mode) { case 'r': omode = O_RDONLY; oflags = 0; break; case 'w': omode = O_WRONLY; oflags = O_TRUNC | O_CREAT; break; case 'a': omode = O_WRONLY; oflags = O_APPEND | O_CREAT; break; default: - errno = EINVAL; + _set_errno (EINVAL); return -1; } for (mode++; *mode; mode++) { switch (*mode) { case '+': omode = O_RDWR; break; case 'b': oflags |= O_BINARY; break; case 'x': oflags |= O_EXCL; break; default: /* Ignore unknown flags. */ break; } } *modeflags = (omode | oflags); return 0; } /* * Low level stream functionality. */ static int es_fill (estream_t stream) { size_t bytes_read = 0; int err; if (!stream->intern->func_read) { - errno = EOPNOTSUPP; + _set_errno (EOPNOTSUPP); err = -1; } else { es_cookie_read_function_t func_read = stream->intern->func_read; ssize_t ret; ret = (*func_read) (stream->intern->cookie, stream->buffer, stream->buffer_size); if (ret == -1) { bytes_read = 0; err = -1; } else { bytes_read = ret; err = 0; } } if (err) stream->intern->indicators.err = 1; else if (!bytes_read) stream->intern->indicators.eof = 1; stream->intern->offset += stream->data_len; stream->data_len = bytes_read; stream->data_offset = 0; return err; } static int es_flush (estream_t stream) { es_cookie_write_function_t func_write = stream->intern->func_write; int err; assert (stream->flags.writing); if (stream->data_offset) { size_t bytes_written; size_t data_flushed; ssize_t ret; if (! func_write) { err = EOPNOTSUPP; goto out; } /* Note: to prevent an endless loop caused by user-provided write-functions that pretend to have written more bytes than they were asked to write, we have to check for "(stream->data_offset - data_flushed) > 0" instead of "stream->data_offset - data_flushed". */ data_flushed = 0; err = 0; while ((((ssize_t) (stream->data_offset - data_flushed)) > 0) && (! err)) { ret = (*func_write) (stream->intern->cookie, stream->buffer + data_flushed, stream->data_offset - data_flushed); if (ret == -1) { bytes_written = 0; err = -1; } else bytes_written = ret; data_flushed += bytes_written; if (err) break; } stream->data_flushed += data_flushed; if (stream->data_offset == data_flushed) { stream->intern->offset += stream->data_offset; stream->data_offset = 0; stream->data_flushed = 0; /* Propagate flush event. */ (*func_write) (stream->intern->cookie, NULL, 0); } } else err = 0; out: if (err) stream->intern->indicators.err = 1; return err; } /* Discard buffered data for STREAM. */ static void es_empty (estream_t stream) { assert (!stream->flags.writing); stream->data_len = 0; stream->data_offset = 0; stream->unread_data_len = 0; } /* Initialize STREAM. */ static void es_initialize (estream_t stream, void *cookie, int fd, es_cookie_io_functions_t functions, unsigned int modeflags) { stream->intern->cookie = cookie; stream->intern->opaque = NULL; stream->intern->offset = 0; stream->intern->func_read = functions.func_read; stream->intern->func_write = functions.func_write; stream->intern->func_seek = functions.func_seek; stream->intern->func_close = functions.func_close; stream->intern->strategy = _IOFBF; stream->intern->fd = fd; stream->intern->print_err = 0; stream->intern->print_errno = 0; stream->intern->print_ntotal = 0; stream->intern->print_fp = NULL; stream->intern->indicators.err = 0; stream->intern->indicators.eof = 0; + stream->intern->is_stdstream = 0; + stream->intern->stdstream_fd = 0; stream->intern->deallocate_buffer = 0; + stream->intern->printable_fname = NULL; + stream->intern->printable_fname_inuse = 0; stream->data_len = 0; stream->data_offset = 0; stream->data_flushed = 0; stream->unread_data_len = 0; /* Depending on the modeflags we set whether we start in writing or reading mode. This is required in case we are working on a - wronly stream which is not seeekable (like stdout). Without this + stream which is not seeekable (like stdout). Without this pre-initialization we would do a seek at the first write call and as this will fail no utput will be delivered. */ if ((modeflags & O_WRONLY) || (modeflags & O_RDWR) ) stream->flags.writing = 1; else stream->flags.writing = 0; } /* Deinitialize STREAM. */ static int es_deinitialize (estream_t stream) { es_cookie_close_function_t func_close; int err, tmp_err; if (stream->intern->print_fp) { int save_errno = errno; fclose (stream->intern->print_fp); stream->intern->print_fp = NULL; - errno = save_errno; + _set_errno (save_errno); } func_close = stream->intern->func_close; err = 0; if (stream->flags.writing) SET_UNLESS_NONZERO (err, tmp_err, es_flush (stream)); if (func_close) SET_UNLESS_NONZERO (err, tmp_err, (*func_close) (stream->intern->cookie)); - + mem_free (stream->intern->printable_fname); + stream->intern->printable_fname = NULL; + stream->intern->printable_fname_inuse = 0; + return err; } /* Create a new stream object, initialize it. */ static int es_create (estream_t *stream, void *cookie, int fd, - es_cookie_io_functions_t functions, unsigned int modeflags) + es_cookie_io_functions_t functions, unsigned int modeflags, + int with_locked_list) { estream_internal_t stream_internal_new; estream_t stream_new; int err; stream_new = NULL; stream_internal_new = NULL; stream_new = mem_alloc (sizeof (*stream_new)); if (! stream_new) { err = -1; goto out; } stream_internal_new = mem_alloc (sizeof (*stream_internal_new)); if (! stream_internal_new) { err = -1; goto out; } stream_new->buffer = stream_internal_new->buffer; stream_new->buffer_size = sizeof (stream_internal_new->buffer); stream_new->unread_buffer = stream_internal_new->unread_buffer; stream_new->unread_buffer_size = sizeof (stream_internal_new->unread_buffer); stream_new->intern = stream_internal_new; ESTREAM_MUTEX_INITIALIZE (stream_new->intern->lock); es_initialize (stream_new, cookie, fd, functions, modeflags); - err = es_list_add (stream_new); + err = es_list_add (stream_new, with_locked_list); if (err) goto out; *stream = stream_new; out: if (err) { if (stream_new) { es_deinitialize (stream_new); mem_free (stream_new); } } return err; } /* Deinitialize a stream object and destroy it. */ static int -es_destroy (estream_t stream) +es_destroy (estream_t stream, int with_locked_list) { int err = 0; if (stream) { - es_list_remove (stream); + es_list_remove (stream, with_locked_list); err = es_deinitialize (stream); mem_free (stream->intern); mem_free (stream); } return err; } /* Try to read BYTES_TO_READ bytes FROM STREAM into BUFFER in unbuffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int es_read_nbf (estream_t ES__RESTRICT stream, unsigned char *ES__RESTRICT buffer, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) { es_cookie_read_function_t func_read = stream->intern->func_read; size_t data_read; ssize_t ret; int err; data_read = 0; err = 0; while (bytes_to_read - data_read) { ret = (*func_read) (stream->intern->cookie, buffer + data_read, bytes_to_read - data_read); if (ret == -1) { err = -1; break; } else if (ret) data_read += ret; else break; } stream->intern->offset += data_read; *bytes_read = data_read; return err; } /* Try to read BYTES_TO_READ bytes FROM STREAM into BUFFER in fully-buffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int es_read_fbf (estream_t ES__RESTRICT stream, unsigned char *ES__RESTRICT buffer, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) { size_t data_available; size_t data_to_read; size_t data_read; int err; data_read = 0; err = 0; while ((bytes_to_read - data_read) && (! err)) { if (stream->data_offset == stream->data_len) { /* Nothing more to read in current container, try to fill container with new data. */ err = es_fill (stream); if (! err) if (! stream->data_len) /* Filling did not result in any data read. */ break; } if (! err) { /* Filling resulted in some new data. */ data_to_read = bytes_to_read - data_read; data_available = stream->data_len - stream->data_offset; if (data_to_read > data_available) data_to_read = data_available; memcpy (buffer + data_read, stream->buffer + stream->data_offset, data_to_read); stream->data_offset += data_to_read; data_read += data_to_read; } } *bytes_read = data_read; return err; } /* Try to read BYTES_TO_READ bytes FROM STREAM into BUFFER in line-buffered-mode, storing the amount of bytes read in *BYTES_READ. */ static int es_read_lbf (estream_t ES__RESTRICT stream, unsigned char *ES__RESTRICT buffer, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) { int err; err = es_read_fbf (stream, buffer, bytes_to_read, bytes_read); return err; } /* Try to read BYTES_TO_READ bytes FROM STREAM into BUFFER, storing *the amount of bytes read in BYTES_READ. */ static int es_readn (estream_t ES__RESTRICT stream, void *ES__RESTRICT buffer_arg, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) { unsigned char *buffer = (unsigned char *)buffer_arg; size_t data_read_unread, data_read; int err; data_read_unread = 0; data_read = 0; err = 0; if (stream->flags.writing) { /* Switching to reading mode -> flush output. */ err = es_flush (stream); if (err) goto out; stream->flags.writing = 0; } /* Read unread data first. */ while ((bytes_to_read - data_read_unread) && stream->unread_data_len) { buffer[data_read_unread] = stream->unread_buffer[stream->unread_data_len - 1]; stream->unread_data_len--; data_read_unread++; } switch (stream->intern->strategy) { case _IONBF: err = es_read_nbf (stream, buffer + data_read_unread, bytes_to_read - data_read_unread, &data_read); break; case _IOLBF: err = es_read_lbf (stream, buffer + data_read_unread, bytes_to_read - data_read_unread, &data_read); break; case _IOFBF: err = es_read_fbf (stream, buffer + data_read_unread, bytes_to_read - data_read_unread, &data_read); break; } out: if (bytes_read) *bytes_read = data_read_unread + data_read; return err; } /* Try to unread DATA_N bytes from DATA into STREAM, storing the amount of bytes successfully unread in *BYTES_UNREAD. */ static void es_unreadn (estream_t ES__RESTRICT stream, const unsigned char *ES__RESTRICT data, size_t data_n, size_t *ES__RESTRICT bytes_unread) { size_t space_left; space_left = stream->unread_buffer_size - stream->unread_data_len; if (data_n > space_left) data_n = space_left; if (! data_n) goto out; memcpy (stream->unread_buffer + stream->unread_data_len, data, data_n); stream->unread_data_len += data_n; stream->intern->indicators.eof = 0; out: if (bytes_unread) *bytes_unread = data_n; } /* Seek in STREAM. */ static int es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence, off_t *ES__RESTRICT offset_new) { es_cookie_seek_function_t func_seek = stream->intern->func_seek; int err, ret; off_t off; if (! func_seek) { - errno = EOPNOTSUPP; + _set_errno (EOPNOTSUPP); err = -1; goto out; } if (stream->flags.writing) { /* Flush data first in order to prevent flushing it to the wrong offset. */ err = es_flush (stream); if (err) goto out; stream->flags.writing = 0; } off = offset; if (whence == SEEK_CUR) { off = off - stream->data_len + stream->data_offset; off -= stream->unread_data_len; } ret = (*func_seek) (stream->intern->cookie, &off, whence); if (ret == -1) { err = -1; goto out; } err = 0; es_empty (stream); if (offset_new) *offset_new = off; stream->intern->indicators.eof = 0; stream->intern->offset = off; out: if (err) stream->intern->indicators.err = 1; return err; } /* Write BYTES_TO_WRITE bytes from BUFFER into STREAM in unbuffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int es_write_nbf (estream_t ES__RESTRICT stream, const unsigned char *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) { es_cookie_write_function_t func_write = stream->intern->func_write; size_t data_written; ssize_t ret; int err; if (bytes_to_write && (! func_write)) { err = EOPNOTSUPP; goto out; } data_written = 0; err = 0; while (bytes_to_write - data_written) { ret = (*func_write) (stream->intern->cookie, buffer + data_written, bytes_to_write - data_written); if (ret == -1) { err = -1; break; } else data_written += ret; } stream->intern->offset += data_written; *bytes_written = data_written; out: return err; } /* Write BYTES_TO_WRITE bytes from BUFFER into STREAM in fully-buffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int es_write_fbf (estream_t ES__RESTRICT stream, const unsigned char *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) { size_t space_available; size_t data_to_write; size_t data_written; int err; data_written = 0; err = 0; while ((bytes_to_write - data_written) && (! err)) { if (stream->data_offset == stream->buffer_size) /* Container full, flush buffer. */ err = es_flush (stream); if (! err) { /* Flushing resulted in empty container. */ data_to_write = bytes_to_write - data_written; space_available = stream->buffer_size - stream->data_offset; if (data_to_write > space_available) data_to_write = space_available; memcpy (stream->buffer + stream->data_offset, buffer + data_written, data_to_write); stream->data_offset += data_to_write; data_written += data_to_write; } } *bytes_written = data_written; return err; } /* Write BYTES_TO_WRITE bytes from BUFFER into STREAM in line-buffered-mode, storing the amount of bytes written in *BYTES_WRITTEN. */ static int es_write_lbf (estream_t ES__RESTRICT stream, const unsigned char *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) { size_t data_flushed = 0; size_t data_buffered = 0; unsigned char *nlp; int err = 0; nlp = memrchr (buffer, '\n', bytes_to_write); if (nlp) { /* Found a newline, directly write up to (including) this character. */ err = es_flush (stream); if (!err) err = es_write_nbf (stream, buffer, nlp - buffer + 1, &data_flushed); } if (!err) { /* Write remaining data fully buffered. */ err = es_write_fbf (stream, buffer + data_flushed, bytes_to_write - data_flushed, &data_buffered); } *bytes_written = data_flushed + data_buffered; return err; } /* Write BYTES_TO_WRITE bytes from BUFFER into STREAM in, storing the amount of bytes written in BYTES_WRITTEN. */ static int es_writen (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) { size_t data_written; int err; data_written = 0; err = 0; if (!stream->flags.writing) { /* Switching to writing mode -> discard input data and seek to position at which reading has stopped. We can do this only if a seek function has been registered. */ if (stream->intern->func_seek) { err = es_seek (stream, 0, SEEK_CUR, NULL); if (err) { if (errno == ESPIPE) err = 0; else goto out; } } } switch (stream->intern->strategy) { case _IONBF: err = es_write_nbf (stream, buffer, bytes_to_write, &data_written); break; case _IOLBF: err = es_write_lbf (stream, buffer, bytes_to_write, &data_written); break; case _IOFBF: err = es_write_fbf (stream, buffer, bytes_to_write, &data_written); break; } out: if (bytes_written) *bytes_written = data_written; if (data_written) if (!stream->flags.writing) stream->flags.writing = 1; return err; } static int es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data, size_t *ES__RESTRICT data_len) { int err; if (stream->flags.writing) { /* Switching to reading mode -> flush output. */ err = es_flush (stream); if (err) goto out; stream->flags.writing = 0; } if (stream->data_offset == stream->data_len) { /* Refill container. */ err = es_fill (stream); if (err) goto out; } if (data) *data = stream->buffer + stream->data_offset; if (data_len) *data_len = stream->data_len - stream->data_offset; err = 0; out: return err; } /* Skip SIZE bytes of input data contained in buffer. */ static int es_skip (estream_t stream, size_t size) { int err; if (stream->data_offset + size > stream->data_len) { - errno = EINVAL; + _set_errno (EINVAL); err = -1; } else { stream->data_offset += size; err = 0; } return err; } static int doreadline (estream_t ES__RESTRICT stream, size_t max_length, char *ES__RESTRICT *ES__RESTRICT line, size_t *ES__RESTRICT line_length) { size_t space_left; size_t line_size; estream_t line_stream; char *line_new; void *line_stream_cookie; char *newline; unsigned char *data; size_t data_len; int err; line_new = NULL; line_stream = NULL; line_stream_cookie = NULL; err = es_func_mem_create (&line_stream_cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, 1, mem_realloc, mem_free, O_RDWR, 0); if (err) goto out; err = es_create (&line_stream, line_stream_cookie, -1, - estream_functions_mem, O_RDWR); + estream_functions_mem, O_RDWR, 0); if (err) goto out; space_left = max_length; line_size = 0; while (1) { if (max_length && (space_left == 1)) break; err = es_peek (stream, &data, &data_len); if (err || (! data_len)) break; if (data_len > (space_left - 1)) data_len = space_left - 1; newline = memchr (data, '\n', data_len); if (newline) { data_len = (newline - (char *) data) + 1; err = es_write (line_stream, data, data_len, NULL); if (! err) { space_left -= data_len; line_size += data_len; es_skip (stream, data_len); break; } } else { err = es_write (line_stream, data, data_len, NULL); if (! err) { space_left -= data_len; line_size += data_len; es_skip (stream, data_len); } } if (err) break; } if (err) goto out; /* Complete line has been written to line_stream. */ if ((max_length > 1) && (! line_size)) { stream->intern->indicators.eof = 1; goto out; } err = es_seek (line_stream, 0, SEEK_SET, NULL); if (err) goto out; if (! *line) { line_new = mem_alloc (line_size + 1); if (! line_new) { err = -1; goto out; } } else line_new = *line; err = es_read (line_stream, line_new, line_size, NULL); if (err) goto out; line_new[line_size] = '\0'; if (! *line) *line = line_new; if (line_length) *line_length = line_size; out: if (line_stream) - es_destroy (line_stream); + es_destroy (line_stream, 0); else if (line_stream_cookie) es_func_mem_destroy (line_stream_cookie); if (err) { if (! *line) mem_free (line_new); stream->intern->indicators.err = 1; } return err; } /* Output fucntion used for estream_format. */ static int print_writer (void *outfncarg, const char *buf, size_t buflen) { estream_t stream = outfncarg; size_t nwritten; int rc; nwritten = 0; rc = es_writen (stream, buf, buflen, &nwritten); stream->intern->print_ntotal += nwritten; return rc; } /* The core of our printf function. This is called in locked state. */ static int es_print (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, va_list ap) { int rc; stream->intern->print_ntotal = 0; rc = estream_format (print_writer, stream, format, ap); if (rc) return -1; return (int)stream->intern->print_ntotal; } static void es_set_indicators (estream_t stream, int ind_err, int ind_eof) { if (ind_err != -1) stream->intern->indicators.err = ind_err ? 1 : 0; if (ind_eof != -1) stream->intern->indicators.eof = ind_eof ? 1 : 0; } static int es_get_indicator (estream_t stream, int ind_err, int ind_eof) { int ret = 0; if (ind_err) ret = stream->intern->indicators.err; else if (ind_eof) ret = stream->intern->indicators.eof; return ret; } static int es_set_buffering (estream_t ES__RESTRICT stream, char *ES__RESTRICT buffer, int mode, size_t size) { int err; /* Flush or empty buffer depending on mode. */ if (stream->flags.writing) { err = es_flush (stream); if (err) goto out; } else es_empty (stream); es_set_indicators (stream, -1, 0); /* Free old buffer in case that was allocated by this function. */ if (stream->intern->deallocate_buffer) { stream->intern->deallocate_buffer = 0; mem_free (stream->buffer); stream->buffer = NULL; } if (mode == _IONBF) stream->buffer_size = 0; else { void *buffer_new; if (buffer) buffer_new = buffer; else { + if (!size) + size = BUFSIZ; buffer_new = mem_alloc (size); if (! buffer_new) { err = -1; goto out; } } stream->buffer = buffer_new; stream->buffer_size = size; if (! buffer) stream->intern->deallocate_buffer = 1; } stream->intern->strategy = mode; err = 0; out: return err; } static off_t es_offset_calculate (estream_t stream) { off_t offset; offset = stream->intern->offset + stream->data_offset; if (offset < stream->unread_data_len) /* Offset undefined. */ offset = 0; else offset -= stream->unread_data_len; return offset; } static void es_opaque_ctrl (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque_new, void **ES__RESTRICT opaque_old) { if (opaque_old) *opaque_old = stream->intern->opaque; if (opaque_new) stream->intern->opaque = opaque_new; } static int es_get_fd (estream_t stream) { return stream->intern->fd; } /* API. */ int es_init (void) { int err; err = es_init_do (); return err; } estream_t es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) { unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; int fd; stream = NULL; cookie = NULL; create_called = 0; err = es_convert_mode (mode, &modeflags); if (err) goto out; err = es_func_file_create (&cookie, &fd, path, modeflags); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, fd, estream_functions_file, modeflags); + err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags, 0); if (err) goto out; + if (stream && path) + fname_set_internal (stream, path, 1); + out: if (err && create_called) - (*estream_functions_file.func_close) (cookie); + (*estream_functions_fd.func_close) (cookie); return stream; } estream_t es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len, unsigned int grow, func_realloc_t func_realloc, func_free_t func_free, const char *ES__RESTRICT mode) { unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; cookie = 0; stream = NULL; create_called = 0; err = es_convert_mode (mode, &modeflags); if (err) goto out; err = es_func_mem_create (&cookie, data, data_n, data_len, BUFFER_BLOCK_SIZE, grow, func_realloc, func_free, modeflags, 0); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags); + err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags, 0); out: if (err && create_called) (*estream_functions_mem.func_close) (cookie); return stream; } estream_t es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode) { unsigned int modeflags; estream_t stream = NULL; void *cookie = NULL; /* Memory streams are always read/write. We use MODE only to get the append flag. */ if (es_convert_mode (mode, &modeflags)) return NULL; modeflags |= O_RDWR; if (es_func_mem_create (&cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, 1, mem_realloc, mem_free, modeflags, memlimit)) return NULL; - if (es_create (&stream, cookie, -1, estream_functions_mem, modeflags)) + if (es_create (&stream, cookie, -1, estream_functions_mem, modeflags, 0)) (*estream_functions_mem.func_close) (cookie); return stream; } estream_t es_fopencookie (void *ES__RESTRICT cookie, const char *ES__RESTRICT mode, es_cookie_io_functions_t functions) { unsigned int modeflags; estream_t stream; int err; stream = NULL; modeflags = 0; err = es_convert_mode (mode, &modeflags); if (err) goto out; - err = es_create (&stream, cookie, -1, functions, modeflags); + err = es_create (&stream, cookie, -1, functions, modeflags, 0); if (err) goto out; out: return stream; } estream_t -do_fdopen (int filedes, const char *mode, int no_close) +do_fdopen (int filedes, const char *mode, int no_close, int with_locked_list) { unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; stream = NULL; cookie = NULL; create_called = 0; err = es_convert_mode (mode, &modeflags); if (err) goto out; err = es_func_fd_create (&cookie, filedes, modeflags, no_close); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, filedes, estream_functions_fd, modeflags); + err = es_create (&stream, cookie, filedes, estream_functions_fd, + modeflags, with_locked_list); out: if (err && create_called) (*estream_functions_fd.func_close) (cookie); return stream; } estream_t es_fdopen (int filedes, const char *mode) { - return do_fdopen (filedes, mode, 0); + return do_fdopen (filedes, mode, 0, 0); } /* A variant of es_fdopen which does not close FILEDES at the end. */ estream_t es_fdopen_nc (int filedes, const char *mode) { - return do_fdopen (filedes, mode, 1); + return do_fdopen (filedes, mode, 1, 0); } estream_t -do_fpopen (FILE *fp, const char *mode, int no_close) +do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list) { unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; stream = NULL; cookie = NULL; create_called = 0; err = es_convert_mode (mode, &modeflags); if (err) goto out; - fflush (fp); + if (fp) + fflush (fp); err = es_func_fp_create (&cookie, fp, modeflags, no_close); if (err) goto out; - + create_called = 1; - err = es_create (&stream, cookie, fileno (fp), estream_functions_fp, - modeflags); + err = es_create (&stream, cookie, fp? fileno (fp):-1, estream_functions_fp, + modeflags, with_locked_list); out: if (err && create_called) (*estream_functions_fp.func_close) (cookie); return stream; } /* Create an estream from the stdio stream FP. This mechanism is useful in case the stdio streams have special properties and may not be mixed with fd based functions. This is for example the case under Windows where the 3 standard streams are associated with the console whereas a duped and fd-opened stream of one of this stream won't be associated with the console. As this messes things up it is easier to keep on using the standard I/O stream as a backend for estream. */ estream_t es_fpopen (FILE *fp, const char *mode) { - return do_fpopen (fp, mode, 0); + return do_fpopen (fp, mode, 0, 0); } /* Same as es_fpopen but does not close FP at the end. */ estream_t es_fpopen_nc (FILE *fp, const char *mode) { - return do_fpopen (fp, mode, 1); + return do_fpopen (fp, mode, 1, 0); +} + + +/* Set custom standard descriptors to be used for stdin, stdout and + stderr. This function needs to be called before any of the + standard streams are accessed. */ +void +_es_set_std_fd (int no, int fd) +{ + ESTREAM_LIST_LOCK; + if (no >= 0 && no < 3 && !custom_std_fds_valid[no]) + { + custom_std_fds[no] = fd; + custom_std_fds_valid[no] = 1; + } + ESTREAM_LIST_UNLOCK; +} + + +/* Return the stream used for stdin, stdout or stderr. */ +estream_t +_es_get_std_stream (int fd) +{ + estream_list_t list_obj; + estream_t stream = NULL; + + fd %= 3; /* We only allow 0, 1 or 2 but we don't want to return an error. */ + ESTREAM_LIST_LOCK; + for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) + if (list_obj->car->intern->is_stdstream + && list_obj->car->intern->stdstream_fd == fd) + { + stream = list_obj->car; + break; + } + if (!stream) + { + /* Standard stream not yet created. We first try to create them + from registered file descriptors. */ + if (!fd && custom_std_fds_valid[0]) + stream = do_fdopen (custom_std_fds[0], "r", 1, 1); + else if (fd == 1 && custom_std_fds_valid[1]) + stream = do_fdopen (custom_std_fds[1], "a", 1, 1); + else if (custom_std_fds_valid[2]) + stream = do_fdopen (custom_std_fds[2], "a", 1, 1); + + if (!stream) + { + /* Second try is to use the standard C streams. */ + if (!fd) + stream = do_fpopen (stdin, "r", 1, 1); + else if (fd == 1) + stream = do_fpopen (stdout, "a", 1, 1); + else + stream = do_fpopen (stderr, "a", 1, 1); + } + + if (!stream) + { + /* Last try: Create a bit bucket. */ + stream = do_fpopen (NULL, fd? "a":"r", 0, 1); + if (!stream) + { + fprintf (stderr, "fatal: error creating a dummy estream" + " for %d: %s\n", fd, strerror (errno)); + abort(); + } + } + + stream->intern->is_stdstream = 1; + stream->intern->stdstream_fd = fd; + if (fd == 2) + es_set_buffering (stream, NULL, _IOLBF, 0); + fname_set_internal (stream, + fd == 0? "[stdin]" : + fd == 1? "[stdout]" : "[stderr]", 0); + } + ESTREAM_LIST_UNLOCK; + return stream; } estream_t es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, estream_t ES__RESTRICT stream) { int err; if (path) { unsigned int modeflags; int create_called; void *cookie; int fd; cookie = NULL; create_called = 0; ESTREAM_LOCK (stream); es_deinitialize (stream); err = es_convert_mode (mode, &modeflags); if (err) goto leave; err = es_func_file_create (&cookie, &fd, path, modeflags); if (err) goto leave; create_called = 1; - es_initialize (stream, cookie, fd, estream_functions_file, modeflags); + es_initialize (stream, cookie, fd, estream_functions_fd, modeflags); leave: if (err) { if (create_called) es_func_fd_destroy (cookie); - es_destroy (stream); + es_destroy (stream, 0); stream = NULL; } else - ESTREAM_UNLOCK (stream); + { + if (stream && path) + fname_set_internal (stream, path, 1); + ESTREAM_UNLOCK (stream); + } } else { /* FIXME? We don't support re-opening at the moment. */ - errno = EINVAL; + _set_errno (EINVAL); es_deinitialize (stream); - es_destroy (stream); + es_destroy (stream, 0); stream = NULL; } return stream; } int es_fclose (estream_t stream) { int err; - err = es_destroy (stream); + err = es_destroy (stream, 0); return err; } int es_fileno_unlocked (estream_t stream) { return es_get_fd (stream); } void es_flockfile (estream_t stream) { ESTREAM_LOCK (stream); } int es_ftrylockfile (estream_t stream) { return ESTREAM_TRYLOCK (stream); } void es_funlockfile (estream_t stream) { ESTREAM_UNLOCK (stream); } int es_fileno (estream_t stream) { int ret; ESTREAM_LOCK (stream); ret = es_fileno_unlocked (stream); ESTREAM_UNLOCK (stream); return ret; } int es_feof_unlocked (estream_t stream) { return es_get_indicator (stream, 0, 1); } int es_feof (estream_t stream) { int ret; ESTREAM_LOCK (stream); ret = es_feof_unlocked (stream); ESTREAM_UNLOCK (stream); return ret; } int es_ferror_unlocked (estream_t stream) { return es_get_indicator (stream, 1, 0); } int es_ferror (estream_t stream) { int ret; ESTREAM_LOCK (stream); ret = es_ferror_unlocked (stream); ESTREAM_UNLOCK (stream); return ret; } void es_clearerr_unlocked (estream_t stream) { es_set_indicators (stream, 0, 0); } void es_clearerr (estream_t stream) { ESTREAM_LOCK (stream); es_clearerr_unlocked (stream); ESTREAM_UNLOCK (stream); } +static int +do_fflush (estream_t stream) +{ + int err; + + if (stream->flags.writing) + err = es_flush (stream); + else + { + es_empty (stream); + err = 0; + } + + return err; +} + + int es_fflush (estream_t stream) { int err; if (stream) { ESTREAM_LOCK (stream); - if (stream->flags.writing) - err = es_flush (stream); - else - { - es_empty (stream); - err = 0; - } + err = do_fflush (stream); ESTREAM_UNLOCK (stream); } else - err = es_list_iterate (es_fflush); + err = es_list_iterate (do_fflush); return err ? EOF : 0; } int es_fseek (estream_t stream, long int offset, int whence) { int err; ESTREAM_LOCK (stream); err = es_seek (stream, offset, whence, NULL); ESTREAM_UNLOCK (stream); return err; } int es_fseeko (estream_t stream, off_t offset, int whence) { int err; ESTREAM_LOCK (stream); err = es_seek (stream, offset, whence, NULL); ESTREAM_UNLOCK (stream); return err; } long int es_ftell (estream_t stream) { long int ret; ESTREAM_LOCK (stream); ret = es_offset_calculate (stream); ESTREAM_UNLOCK (stream); return ret; } off_t es_ftello (estream_t stream) { off_t ret = -1; ESTREAM_LOCK (stream); ret = es_offset_calculate (stream); ESTREAM_UNLOCK (stream); return ret; } void es_rewind (estream_t stream) { ESTREAM_LOCK (stream); es_seek (stream, 0L, SEEK_SET, NULL); es_set_indicators (stream, 0, -1); ESTREAM_UNLOCK (stream); } int _es_getc_underflow (estream_t stream) { int err; unsigned char c; size_t bytes_read; err = es_readn (stream, &c, 1, &bytes_read); return (err || (! bytes_read)) ? EOF : c; } int _es_putc_overflow (int c, estream_t stream) { unsigned char d = c; int err; err = es_writen (stream, &d, 1, NULL); return err ? EOF : c; } int es_fgetc (estream_t stream) { int ret; ESTREAM_LOCK (stream); ret = es_getc_unlocked (stream); ESTREAM_UNLOCK (stream); return ret; } int es_fputc (int c, estream_t stream) { int ret; ESTREAM_LOCK (stream); ret = es_putc_unlocked (c, stream); ESTREAM_UNLOCK (stream); return ret; } int es_ungetc (int c, estream_t stream) { unsigned char data = (unsigned char) c; size_t data_unread; ESTREAM_LOCK (stream); es_unreadn (stream, &data, 1, &data_unread); ESTREAM_UNLOCK (stream); return data_unread ? c : EOF; } int es_read (estream_t ES__RESTRICT stream, void *ES__RESTRICT buffer, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read) { int err; if (bytes_to_read) { ESTREAM_LOCK (stream); err = es_readn (stream, buffer, bytes_to_read, bytes_read); ESTREAM_UNLOCK (stream); } else err = 0; return err; } int es_write (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written) { int err; if (bytes_to_write) { ESTREAM_LOCK (stream); err = es_writen (stream, buffer, bytes_to_write, bytes_written); ESTREAM_UNLOCK (stream); } else err = 0; return err; } size_t es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, estream_t ES__RESTRICT stream) { size_t ret, bytes; int err; if (size * nitems) { ESTREAM_LOCK (stream); err = es_readn (stream, ptr, size * nitems, &bytes); ESTREAM_UNLOCK (stream); ret = bytes / size; } else ret = 0; return ret; } size_t es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t nitems, estream_t ES__RESTRICT stream) { size_t ret, bytes; int err; if (size * nitems) { ESTREAM_LOCK (stream); err = es_writen (stream, ptr, size * nitems, &bytes); ESTREAM_UNLOCK (stream); ret = bytes / size; } else ret = 0; return ret; } char * es_fgets (char *ES__RESTRICT buffer, int length, estream_t ES__RESTRICT stream) { unsigned char *s = (unsigned char*)buffer; int c; if (!length) return NULL; c = EOF; ESTREAM_LOCK (stream); while (length > 1 && (c = es_getc_unlocked (stream)) != EOF && c != '\n') { *s++ = c; length--; } ESTREAM_UNLOCK (stream); if (c == EOF && s == (unsigned char*)buffer) return NULL; /* Nothing read. */ if (c != EOF && length > 1) *s++ = c; *s = 0; return buffer; } +int +es_fputs_unlocked (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) +{ + size_t length; + int err; + + length = strlen (s); + err = es_writen (stream, s, length, NULL); + return err ? EOF : 0; +} + int es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream) { size_t length; int err; length = strlen (s); ESTREAM_LOCK (stream); err = es_writen (stream, s, length, NULL); ESTREAM_UNLOCK (stream); return err ? EOF : 0; } ssize_t es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, estream_t ES__RESTRICT stream) { char *line = NULL; size_t line_n = 0; int err; ESTREAM_LOCK (stream); err = doreadline (stream, 0, &line, &line_n); ESTREAM_UNLOCK (stream); if (err) goto out; if (*n) { /* Caller wants us to use his buffer. */ if (*n < (line_n + 1)) { /* Provided buffer is too small -> resize. */ void *p; p = mem_realloc (*lineptr, line_n + 1); if (! p) err = -1; else { if (*lineptr != p) *lineptr = p; } } if (! err) { memcpy (*lineptr, line, line_n + 1); if (*n != line_n) *n = line_n; } mem_free (line); } else { /* Caller wants new buffers. */ *lineptr = line; *n = line_n; } out: return err ? err : (ssize_t)line_n; } /* Same as fgets() but if the provided buffer is too short a larger one will be allocated. This is similar to getline. A line is considered a byte stream ending in a LF. If MAX_LENGTH is not NULL, it shall point to a value with the maximum allowed allocation. Returns the length of the line. EOF is indicated by a line of length zero. A truncated line is indicated my setting the value at MAX_LENGTH to 0. If the returned value is less then 0 not enough memory was enable or another error occurred; ERRNO is then set accordingly. If a line has been truncated, the file pointer is moved forward to the end of the line so that the next read starts with the next line. Note that MAX_LENGTH must be re-initialzied in this case. The caller initially needs to provide the address of a variable, initialized to NULL, at ADDR_OF_BUFFER and don't change this value anymore with the following invocations. LENGTH_OF_BUFFER should be the address of a variable, initialized to 0, which is also maintained by this function. Thus, both paramaters should be considered the state of this function. Note: The returned buffer is allocated with enough extra space to allow the caller to append a CR,LF,Nul. The buffer should be released using es_free. */ ssize_t es_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length) { int c; char *buffer = *addr_of_buffer; size_t length = *length_of_buffer; size_t nbytes = 0; size_t maxlen = max_length? *max_length : 0; char *p; if (!buffer) { /* No buffer given - allocate a new one. */ length = 256; buffer = mem_alloc (length); *addr_of_buffer = buffer; if (!buffer) { *length_of_buffer = 0; if (max_length) *max_length = 0; return -1; } *length_of_buffer = length; } if (length < 4) { /* This should never happen. If it does, the function has been called with wrong arguments. */ - errno = EINVAL; + _set_errno (EINVAL); return -1; } length -= 3; /* Reserve 3 bytes for CR,LF,EOL. */ ESTREAM_LOCK (stream); p = buffer; while ((c = es_getc_unlocked (stream)) != EOF) { if (nbytes == length) { /* Enlarge the buffer. */ if (maxlen && length > maxlen) { /* We are beyond our limit: Skip the rest of the line. */ while (c != '\n' && (c=es_getc_unlocked (stream)) != EOF) ; *p++ = '\n'; /* Always append a LF (we reserved some space). */ nbytes++; if (max_length) *max_length = 0; /* Indicate truncation. */ break; /* the while loop. */ } length += 3; /* Adjust for the reserved bytes. */ length += length < 1024? 256 : 1024; *addr_of_buffer = mem_realloc (buffer, length); if (!*addr_of_buffer) { int save_errno = errno; mem_free (buffer); *length_of_buffer = 0; if (max_length) *max_length = 0; ESTREAM_UNLOCK (stream); - errno = save_errno; + _set_errno (save_errno); return -1; } buffer = *addr_of_buffer; *length_of_buffer = length; length -= 3; p = buffer + nbytes; } *p++ = c; nbytes++; if (c == '\n') break; } *p = 0; /* Make sure the line is a string. */ ESTREAM_UNLOCK (stream); return nbytes; } /* Wrapper around free() to match the memory allocation system used by estream. Should be used for all buffers returned to the caller by libestream. */ void es_free (void *a) { mem_free (a); } +int +es_vfprintf_unlocked (estream_t ES__RESTRICT stream, + const char *ES__RESTRICT format, + va_list ap) +{ + return es_print (stream, format, ap); +} + + int es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, va_list ap) { int ret; ESTREAM_LOCK (stream); ret = es_print (stream, format, ap); ESTREAM_UNLOCK (stream); return ret; } -static int +int es_fprintf_unlocked (estream_t ES__RESTRICT stream, - const char *ES__RESTRICT format, ...) + const char *ES__RESTRICT format, ...) { int ret; va_list ap; va_start (ap, format); ret = es_print (stream, format, ap); va_end (ap); return ret; } int es_fprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, ...) { int ret; va_list ap; va_start (ap, format); ESTREAM_LOCK (stream); ret = es_print (stream, format, ap); ESTREAM_UNLOCK (stream); va_end (ap); return ret; } /* A variant of asprintf. The function returns the allocated buffer or NULL on error; ERRNO is set in the error case. The caller should use es_free to release the buffer. This function actually belongs into estream-printf but we put it here as a convenience and because es_free is required anyway. */ char * es_asprintf (const char *ES__RESTRICT format, ...) { int rc; va_list ap; char *buf; va_start (ap, format); rc = estream_vasprintf (&buf, format, ap); va_end (ap); if (rc < 0) return NULL; return buf; } /* A variant of vasprintf. The function returns the allocated buffer or NULL on error; ERRNO is set in the error case. The caller should use es_free to release the buffer. This function actually belongs into estream-printf but we put it here as a convenience and because es_free is required anyway. */ char * es_vasprintf (const char *ES__RESTRICT format, va_list ap) { int rc; char *buf; rc = estream_vasprintf (&buf, format, ap); if (rc < 0) return NULL; return buf; } static int tmpfd (void) { #ifdef HAVE_W32_SYSTEM int attempts, n; +#ifdef HAVE_W32CE_SYSTEM + wchar_t buffer[MAX_PATH+9+12+1]; +# define mystrlen(a) wcslen (a) + wchar_t *name, *p; +#else char buffer[MAX_PATH+9+12+1]; +# define mystrlen(a) strlen (a) char *name, *p; +#endif HANDLE file; int pid = GetCurrentProcessId (); unsigned int value; int i; n = GetTempPath (MAX_PATH+1, buffer); - if (!n || n > MAX_PATH || strlen (buffer) > MAX_PATH) + if (!n || n > MAX_PATH || mystrlen (buffer) > MAX_PATH) { - errno = ENOENT; + _set_errno (ENOENT); return -1; } - p = buffer + strlen (buffer); + p = buffer + mystrlen (buffer); +#ifdef HAVE_W32CE_SYSTEM + wcscpy (p, L"_estream"); +#else strcpy (p, "_estream"); +#endif p += 8; /* We try to create the directory but don't care about an error as it may already exist and the CreateFile would throw an error anyway. */ CreateDirectory (buffer, NULL); *p++ = '\\'; name = p; for (attempts=0; attempts < 10; attempts++) { p = name; value = (GetTickCount () ^ ((pid<<16) & 0xffff0000)); for (i=0; i < 8; i++) { *p++ = tohex (((value >> 28) & 0x0f)); value <<= 4; } +#ifdef HAVE_W32CE_SYSTEM + wcscpy (p, L".tmp"); +#else strcpy (p, ".tmp"); +#endif file = CreateFile (buffer, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL); if (file != INVALID_HANDLE_VALUE) { +#ifdef HAVE_W32CE_SYSTEM + int fd = (int)file; +#else int fd = _open_osfhandle ((long)file, 0); if (fd == -1) { CloseHandle (file); return -1; } +#endif return fd; } Sleep (1); /* One ms as this is the granularity of GetTickCount. */ } - errno = ENOENT; + _set_errno (ENOENT); return -1; #else /*!HAVE_W32_SYSTEM*/ FILE *fp; int fp_fd; int fd; fp = NULL; fd = -1; fp = tmpfile (); if (! fp) goto out; fp_fd = fileno (fp); fd = dup (fp_fd); out: if (fp) fclose (fp); return fd; #endif /*!HAVE_W32_SYSTEM*/ } estream_t es_tmpfile (void) { unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; int fd; create_called = 0; stream = NULL; modeflags = O_RDWR | O_TRUNC | O_CREAT; cookie = NULL; fd = tmpfd (); if (fd == -1) { err = -1; goto out; } err = es_func_fd_create (&cookie, fd, modeflags, 0); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags); + err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags, 0); out: if (err) { if (create_called) es_func_fd_destroy (cookie); else if (fd != -1) close (fd); stream = NULL; } return stream; } int es_setvbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf, int type, size_t size) { int err; - if (((type == _IOFBF) || (type == _IOLBF) || (type == _IONBF)) - && (! ((! size) && (type != _IONBF)))) + if ((type == _IOFBF || type == _IOLBF || type == _IONBF) + && (!buf || size || type == _IONBF)) { ESTREAM_LOCK (stream); err = es_set_buffering (stream, buf, type, size); ESTREAM_UNLOCK (stream); } else { - errno = EINVAL; + _set_errno (EINVAL); err = -1; } return err; } void es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf) { ESTREAM_LOCK (stream); es_set_buffering (stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); ESTREAM_UNLOCK (stream); } void es_opaque_set (estream_t stream, void *opaque) { ESTREAM_LOCK (stream); es_opaque_ctrl (stream, opaque, NULL); ESTREAM_UNLOCK (stream); } void * es_opaque_get (estream_t stream) { void *opaque; ESTREAM_LOCK (stream); es_opaque_ctrl (stream, NULL, &opaque); ESTREAM_UNLOCK (stream); return opaque; } + +static void +fname_set_internal (estream_t stream, const char *fname, int quote) +{ + if (stream->intern->printable_fname + && !stream->intern->printable_fname_inuse) + { + mem_free (stream->intern->printable_fname); + stream->intern->printable_fname = NULL; + } + if (stream->intern->printable_fname) + return; /* Can't change because it is in use. */ + + if (*fname != '[') + quote = 0; + else + quote = !!quote; + + stream->intern->printable_fname = mem_alloc (strlen (fname) + quote + 1); + if (fname) + { + if (quote) + stream->intern->printable_fname[0] = '\\'; + strcpy (stream->intern->printable_fname+quote, fname); + } +} + + +/* Set the filename attribute of STREAM. There is no error return. + as long as STREAM is valid. This function is called internally by + functions which open a filename. */ +void +es_fname_set (estream_t stream, const char *fname) +{ + if (fname) + { + ESTREAM_LOCK (stream); + fname_set_internal (stream, fname, 1); + ESTREAM_UNLOCK (stream); + } +} + + +/* Return the filename attribute of STREAM. In case no filename has + been set, "[?]" will be returned. The returned file name is valid + as long as STREAM is valid. */ +const char * +es_fname_get (estream_t stream) +{ + const char *fname; + + ESTREAM_LOCK (stream); + fname = stream->intern->printable_fname; + if (fname) + stream->intern->printable_fname_inuse = 1; + ESTREAM_UNLOCK (stream); + if (!fname) + fname = "[?]"; + return fname; +} + + /* Print a BUFFER to STREAM while replacing all control characters and the characters in DELIMITERS by standard C escape sequences. Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL the number of bytes actually written are stored at this address. */ int es_write_sanitized (estream_t ES__RESTRICT stream, const void * ES__RESTRICT buffer, size_t length, const char * delimiters, size_t * ES__RESTRICT bytes_written) { const unsigned char *p = buffer; size_t count = 0; int ret; ESTREAM_LOCK (stream); for (; length; length--, p++, count++) { if (*p < 0x20 || *p == 0x7f || (delimiters && (strchr (delimiters, *p) || *p == '\\'))) { es_putc_unlocked ('\\', stream); count++; if (*p == '\n') { es_putc_unlocked ('n', stream); count++; } else if (*p == '\r') { es_putc_unlocked ('r', stream); count++; } else if (*p == '\f') { es_putc_unlocked ('f', stream); count++; } else if (*p == '\v') { es_putc_unlocked ('v', stream); count++; } else if (*p == '\b') { es_putc_unlocked ('b', stream); count++; } else if (!*p) { es_putc_unlocked('0', stream); count++; } else { es_fprintf_unlocked (stream, "x%02x", *p); count += 3; } } else { es_putc_unlocked (*p, stream); count++; } } if (bytes_written) *bytes_written = count; ret = es_ferror_unlocked (stream)? -1 : 0; ESTREAM_UNLOCK (stream); return ret; } /* Write LENGTH bytes of BUFFER to STREAM as a hex encoded string. RESERVED must be 0. Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL the number of bytes actually written are stored at this address. */ int es_write_hexstring (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t length, int reserved, size_t *ES__RESTRICT bytes_written ) { int ret; const unsigned char *s; size_t count = 0; (void)reserved; #define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A')) if (!length) return 0; ESTREAM_LOCK (stream); for (s = buffer; length; s++, length--) { es_putc_unlocked ( tohex ((*s>>4)&15), stream); es_putc_unlocked ( tohex (*s&15), stream); count += 2; } if (bytes_written) *bytes_written = count; ret = es_ferror_unlocked (stream)? -1 : 0; ESTREAM_UNLOCK (stream); return ret; #undef tohex } #ifdef GNUPG_MAJOR_VERSION /* Special estream function to print an UTF8 string in the native encoding. The interface is the same as es_write_sanitized, however only one delimiter may be supported. THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG!. */ int es_write_sanitized_utf8_buffer (estream_t stream, const void *buffer, size_t length, const char *delimiters, size_t *bytes_written) { const char *p = buffer; size_t i; /* We can handle plain ascii simpler, so check for it first. */ for (i=0; i < length; i++ ) { if ( (p[i] & 0x80) ) break; } if (i < length) { int delim = delimiters? *delimiters : 0; char *buf; int ret; /*(utf8 conversion already does the control character quoting). */ buf = utf8_to_native (p, length, delim); if (bytes_written) *bytes_written = strlen (buf); ret = es_fputs (buf, stream); xfree (buf); return ret == EOF? ret : (int)i; } else return es_write_sanitized (stream, p, length, delimiters, bytes_written); } #endif /*GNUPG_MAJOR_VERSION*/ diff --git a/common/estream.h b/common/estream.h index d1f94724f..6eb986fd6 100644 --- a/common/estream.h +++ b/common/estream.h @@ -1,316 +1,377 @@ /* estream.h - Extended stream I/O Library - * Copyright (C) 2004, 2005, 2006, 2007 g10 Code GmbH + * Copyright (C) 2004, 2005, 2006, 2007, 2010 g10 Code GmbH * * This file is part of Libestream. * * Libestream 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. * * Libestream 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 Libestream; if not, see . + * + * ALTERNATIVELY, Libestream may be distributed under the terms of the + * following license, in which case the provisions of this license are + * required INSTEAD OF the GNU General Public License. If you wish to + * allow use of your version of this file only under the terms of the + * GNU General Public License, and not to allow others to use your + * version of this file under the terms of the following license, + * indicate your decision by deleting this paragraph and the license + * below. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ESTREAM_H #define ESTREAM_H #include #include #include /* To use this file with libraries the following macro is useful: #define _ESTREAM_EXT_SYM_PREFIX _foo_ This prefixes all external symbols with "_foo_". */ #ifdef _ESTREAM_EXT_SYM_PREFIX #ifndef _ESTREAM_PREFIX #define _ESTREAM_PREFIX1(x,y) x ## y #define _ESTREAM_PREFIX2(x,y) _ESTREAM_PREFIX1(x,y) #define _ESTREAM_PREFIX(x) _ESTREAM_PREFIX2(_ESTREAM_EXT_SYM_PREFIX,x) #endif /*_ESTREAM_PREFIX*/ #define es_fopen _ESTREAM_PREFIX(es_fopen) #define es_mopen _ESTREAM_PREFIX(es_mopen) #define es_fopenmem _ESTREAM_PREFIX(es_fopenmem) #define es_fdopen _ESTREAM_PREFIX(es_fdopen) #define es_fdopen_nc _ESTREAM_PREFIX(es_fdopen_nc) #define es_fpopen _ESTREAM_PREFIX(es_fpopen) #define es_fpopen_nc _ESTREAM_PREFIX(es_fpopen_nc) +#define _es_set_std_fd _ESTREAM_PREFIX(_es_set_std_fd) +#define _es_get_std_stream _ESTREAM_PREFIX(_es_get_std_stream) #define es_freopen _ESTREAM_PREFIX(es_freopen) #define es_fopencookie _ESTREAM_PREFIX(es_fopencookie) #define es_fclose _ESTREAM_PREFIX(es_fclose) #define es_fileno _ESTREAM_PREFIX(es_fileno) #define es_fileno_unlocked _ESTREAM_PREFIX(es_fileno_unlocked) #define es_flockfile _ESTREAM_PREFIX(es_flockfile) #define es_ftrylockfile _ESTREAM_PREFIX(es_ftrylockfile) #define es_funlockfile _ESTREAM_PREFIX(es_funlockfile) #define es_feof _ESTREAM_PREFIX(es_feof) #define es_feof_unlocked _ESTREAM_PREFIX(es_feof_unlocked) #define es_ferror _ESTREAM_PREFIX(es_ferror) #define es_ferror_unlocked _ESTREAM_PREFIX(es_ferror_unlocked) #define es_clearerr _ESTREAM_PREFIX(es_clearerr) #define es_clearerr_unlocked _ESTREAM_PREFIX(es_clearerr_unlocked) #define es_fflush _ESTREAM_PREFIX(es_fflush) #define es_fseek _ESTREAM_PREFIX(es_fseek) #define es_fseeko _ESTREAM_PREFIX(es_fseeko) #define es_ftell _ESTREAM_PREFIX(es_ftell) #define es_ftello _ESTREAM_PREFIX(es_ftello) #define es_rewind _ESTREAM_PREFIX(es_rewind) #define es_fgetc _ESTREAM_PREFIX(es_fgetc) #define es_fputc _ESTREAM_PREFIX(es_fputc) #define _es_getc_underflow _ESTREAM_PREFIX(_es_getc_underflow) #define _es_putc_overflow _ESTREAM_PREFIX(_es_putc_overflow) #define es_ungetc _ESTREAM_PREFIX(es_ungetc) #define es_read _ESTREAM_PREFIX(es_read) #define es_write _ESTREAM_PREFIX(es_write) #define es_write_sanitized _ESTREAM_PREFIX(es_write_sanitized) #define es_write_hexstring _ESTREAM_PREFIX(es_write_hexstring) #define es_fread _ESTREAM_PREFIX(es_fread) #define es_fwrite _ESTREAM_PREFIX(es_fwrite) #define es_fgets _ESTREAM_PREFIX(es_fgets) #define es_fputs _ESTREAM_PREFIX(es_fputs) +#define es_fputs_unlocked _ESTREAM_PREFIX(es_fputs_unlocked) #define es_getline _ESTREAM_PREFIX(es_getline) #define es_read_line _ESTREAM_PREFIX(es_read_line) #define es_free _ESTREAM_PREFIX(es_free) -#define es_fprf _ESTREAM_PREFIX(es_fprf) -#define es_vfprf _ESTREAM_PREFIX(es_vfprf) +#define es_fprintf _ESTREAM_PREFIX(es_fprintf) +#define es_fprintf_unlocked _ESTREAM_PREFIX(es_fprintf_unlocked) +#define es_vfprintf _ESTREAM_PREFIX(es_vfprint) +#define es_vfprintf_unlocked _ESTREAM_PREFIX(es_vfprint_unlocked) #define es_setvbuf _ESTREAM_PREFIX(es_setvbuf) #define es_setbuf _ESTREAM_PREFIX(es_setbuf) #define es_tmpfile _ESTREAM_PREFIX(es_tmpfile) #define es_opaque_set _ESTREAM_PREFIX(es_opaque_set) #define es_opaque_get _ESTREAM_PREFIX(es_opaque_get) +#define es_fname_set _ESTREAM_PREFIX(es_fname_set) +#define es_fname_get _ESTREAM_PREFIX(es_fname_get) #define es_write_sanitized_utf8_buffer \ _ESTREAM_PREFIX(es_write_sanitized_utf8_buffer) #endif /*_ESTREAM_EXT_SYM_PREFIX*/ #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* Forward declaration for the (opaque) internal type. */ struct estream_internal; /* The definition of this struct is entirely private. You must not use it for anything. It is only here so some functions can be implemented as macros. */ struct es__stream { /* The layout of this struct must never change. It may be grown, but only if all functions which access the new members are versioned. */ /* A pointer to the stream buffer. */ unsigned char *buffer; /* The size of the buffer in bytes. */ size_t buffer_size; /* The length of the usable data in the buffer, only valid when in read mode (see flags). */ size_t data_len; /* The current position of the offset pointer, valid in read and write mode. */ size_t data_offset; size_t data_flushed; unsigned char *unread_buffer; size_t unread_buffer_size; /* The number of unread bytes. */ size_t unread_data_len; /* Various flags. */ struct { unsigned int writing: 1; unsigned int reserved: 7; } flags; /* A pointer to our internal data for this stream. */ struct estream_internal *intern; }; /* The opaque type for an estream. */ typedef struct es__stream *estream_t; typedef ssize_t (*es_cookie_read_function_t) (void *cookie, void *buffer, size_t size); typedef ssize_t (*es_cookie_write_function_t) (void *cookie, const void *buffer, size_t size); typedef int (*es_cookie_seek_function_t) (void *cookie, off_t *pos, int whence); typedef int (*es_cookie_close_function_t) (void *cookie); typedef struct es_cookie_io_functions { es_cookie_read_function_t func_read; es_cookie_write_function_t func_write; es_cookie_seek_function_t func_seek; es_cookie_close_function_t func_close; } es_cookie_io_functions_t; #ifndef _ESTREAM_GCC_A_PRINTF #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) # define _ESTREAM_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) #else # define _ESTREAM_GCC_A_PRINTF( f, a ) #endif #endif /*_ESTREAM_GCC_A_PRINTF*/ #ifndef ES__RESTRICT # if defined __GNUC__ && defined __GNUC_MINOR__ # if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 92)) # define ES__RESTRICT __restrict__ # endif # endif #endif #ifndef ES__RESTRICT # define ES__RESTRICT #endif int es_init (void); estream_t es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode); estream_t es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len, unsigned int grow, void *(*func_realloc) (void *mem, size_t size), void (*func_free) (void *mem), const char *ES__RESTRICT mode); estream_t es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode); estream_t es_fdopen (int filedes, const char *mode); estream_t es_fdopen_nc (int filedes, const char *mode); estream_t es_fpopen (FILE *fp, const char *mode); estream_t es_fpopen_nc (FILE *fp, const char *mode); estream_t es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, estream_t ES__RESTRICT stream); estream_t es_fopencookie (void *ES__RESTRICT cookie, const char *ES__RESTRICT mode, es_cookie_io_functions_t functions); int es_fclose (estream_t stream); int es_fileno (estream_t stream); int es_fileno_unlocked (estream_t stream); +void _es_set_std_fd (int no, int fd); +estream_t _es_get_std_stream (int fd); + +#define es_stdin _es_get_std_stream (0) +#define es_stdout _es_get_std_stream (1) +#define es_stderr _es_get_std_stream (2) + + void es_flockfile (estream_t stream); int es_ftrylockfile (estream_t stream); void es_funlockfile (estream_t stream); int es_feof (estream_t stream); int es_feof_unlocked (estream_t stream); int es_ferror (estream_t stream); int es_ferror_unlocked (estream_t stream); void es_clearerr (estream_t stream); void es_clearerr_unlocked (estream_t stream); int es_fflush (estream_t stream); int es_fseek (estream_t stream, long int offset, int whence); int es_fseeko (estream_t stream, off_t offset, int whence); long int es_ftell (estream_t stream); off_t es_ftello (estream_t stream); void es_rewind (estream_t stream); int es_fgetc (estream_t stream); int es_fputc (int c, estream_t stream); int _es_getc_underflow (estream_t stream); int _es_putc_overflow (int c, estream_t stream); #define es_getc_unlocked(stream) \ (((!(stream)->flags.writing) \ && ((stream)->data_offset < (stream)->data_len) \ && (! (stream)->unread_data_len)) \ ? ((int) (stream)->buffer[((stream)->data_offset)++]) \ : _es_getc_underflow ((stream))) #define es_putc_unlocked(c, stream) \ (((stream)->flags.writing \ && ((stream)->data_offset < (stream)->buffer_size) \ && (c != '\n')) \ ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \ : _es_putc_overflow ((c), (stream))) #define es_getc(stream) es_fgetc (stream) #define es_putc(c, stream) es_fputc (c, stream) int es_ungetc (int c, estream_t stream); int es_read (estream_t ES__RESTRICT stream, void *ES__RESTRICT buffer, size_t bytes_to_read, size_t *ES__RESTRICT bytes_read); int es_write (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t bytes_to_write, size_t *ES__RESTRICT bytes_written); int es_write_sanitized (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t length, const char *delimiters, size_t *ES__RESTRICT bytes_written); int es_write_hexstring (estream_t ES__RESTRICT stream, const void *ES__RESTRICT buffer, size_t length, int reserved, size_t *ES__RESTRICT bytes_written); size_t es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, estream_t ES__RESTRICT stream); size_t es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t memb, estream_t ES__RESTRICT stream); char *es_fgets (char *ES__RESTRICT s, int n, estream_t ES__RESTRICT stream); int es_fputs (const char *ES__RESTRICT s, estream_t ES__RESTRICT stream); +int es_fputs_unlocked (const char *ES__RESTRICT s, + estream_t ES__RESTRICT stream); ssize_t es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, estream_t stream); ssize_t es_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length); void es_free (void *a); int es_fprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, ...) _ESTREAM_GCC_A_PRINTF(2,3); +int es_fprintf_unlocked (estream_t ES__RESTRICT stream, + const char *ES__RESTRICT format, ...) + _ESTREAM_GCC_A_PRINTF(2,3); + int es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, va_list ap) _ESTREAM_GCC_A_PRINTF(2,0); +int es_vfprintf_unlocked (estream_t ES__RESTRICT stream, + const char *ES__RESTRICT format, va_list ap) + _ESTREAM_GCC_A_PRINTF(2,0); + int es_setvbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf, int mode, size_t size); void es_setbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf); estream_t es_tmpfile (void); void es_opaque_set (estream_t ES__RESTRICT stream, void *ES__RESTRICT opaque); void *es_opaque_get (estream_t stream); +void es_fname_set (estream_t stream, const char *fname); +const char *es_fname_get (estream_t stream); + #ifdef GNUPG_MAJOR_VERSION int es_write_sanitized_utf8_buffer (estream_t stream, const void *buffer, size_t length, const char *delimiters, size_t *bytes_written); #endif /*GNUPG_MAJOR_VERSION*/ - #ifdef __cplusplus } #endif #endif /*ESTREAM_H*/ diff --git a/configure.ac b/configure.ac index bf1b39fdc..267c9cb7a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,1537 +1,1541 @@ # configure.ac - for GnuPG 2.0 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, # 2006, 2007, 2008, 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 # along with this program; if not, see . # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) min_automake_version="1.10" # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [2.0.17]) m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \ | awk '/^\* / {printf "%s",$3}'])) AC_INIT([gnupg], [my_version[]m4_if(my_issvn,[yes], [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])], [http://bugs.gnupg.org]) # Set development_version to yes if the minor number is odd or you # feel that the default check for a development version is not # sufficient. development_version=no NEED_GPG_ERROR_VERSION=1.7 NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.4.0 NEED_LIBASSUAN_API=2 NEED_LIBASSUAN_VERSION=2.0.0 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.7 PACKAGE=$PACKAGE_NAME PACKAGE_GT=${PACKAGE_NAME}2 VERSION=$PACKAGE_VERSION AC_CONFIG_AUX_DIR(scripts) AC_CONFIG_SRCDIR(sm/gpgsm.c) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AC_CANONICAL_HOST AB_INIT AC_GNU_SOURCE # Some status variables. have_gpg_error=no have_libgcrypt=no have_libassuan=no have_ksba=no have_pth=no have_libusb=no have_adns=no use_bzip2=yes use_exec=yes disable_keyserver_path=no use_ccid_driver=yes use_standard_socket=no GNUPG_BUILD_PROGRAM(gpg, yes) GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(scdaemon, yes) GNUPG_BUILD_PROGRAM(tools, yes) GNUPG_BUILD_PROGRAM(doc, yes) GNUPG_BUILD_PROGRAM(symcryptrun, no) +GNUPG_BUILD_PROGRAM(gpgtar, no) + AC_SUBST(PACKAGE) AC_SUBST(PACKAGE_GT) AC_SUBST(VERSION) AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT", [Name of this package for gettext]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT", [Bug report address]) AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION", [Required version of Libgcrypt]) AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION", [Required version of Libksba]) # The default is to use the modules from this package and the few # other packages in a standard place; i.e where this package gets # installed. With these options it is possible to override these # ${prefix} depended values with fixed paths, which can't be replaced # at make time. See also am/cmacros.am and the defaults in AH_BOTTOM. AC_ARG_WITH(agent-pgm, [ --with-agent-pgm=PATH Use PATH as the default for the agent)], GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" ) AC_SUBST(GNUPG_AGENT_PGM) AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM") show_gnupg_agent_pgm="(default)" test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM" AC_ARG_WITH(pinentry-pgm, [ --with-pinentry-pgm=PATH Use PATH as the default for the pinentry)], GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" ) AC_SUBST(GNUPG_PINENTRY_PGM) AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM") show_gnupg_pinentry_pgm="(default)" test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM" AC_ARG_WITH(scdaemon-pgm, [ --with-scdaemon-pgm=PATH Use PATH as the default for the scdaemon)], GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" ) AC_SUBST(GNUPG_SCDAEMON_PGM) AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM") show_gnupg_scdaemon_pgm="(default)" test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM" AC_ARG_WITH(dirmngr-pgm, [ --with-dirmngr-pgm=PATH Use PATH as the default for the dirmngr)], GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" ) AC_SUBST(GNUPG_DIRMNGR_PGM) AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM") show_gnupg_dirmngr_pgm="(default)" test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM" AC_ARG_WITH(protect-tool-pgm, [ --with-protect-tool-pgm=PATH Use PATH as the default for the protect-tool)], GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" ) AC_SUBST(GNUPG_PROTECT_TOOL_PGM) AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM") show_gnupg_protect_tool_pgm="(default)" test -n "$GNUPG_PROTECT_TOOL_PGM" \ && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM" # Some folks want to use only the agent from this packet. Make it # easier for them by providing the configure option # --enable-only-agent. AC_ARG_ENABLE(agent-only, AC_HELP_STRING([--enable-agent-only],[build only the gpg-agent]), build_agent_only=$enableval) # SELinux support includes tracking of sensitive files to avoid # leaking their contents through processing these files by gpg itself AC_MSG_CHECKING([whether SELinux support is requested]) AC_ARG_ENABLE(selinux-support, AC_HELP_STRING([--enable-selinux-support], [enable SELinux support]), selinux_support=$enableval, selinux_support=no) AC_MSG_RESULT($selinux_support) # Allow disabling of bzib2 support. # It is defined only after we confirm the library is available later AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm]) AC_ARG_ENABLE(bzip2, AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]), use_bzip2=$enableval) AC_MSG_RESULT($use_bzip2) # Configure option to allow or disallow execution of external # programs, like a photo viewer. AC_MSG_CHECKING([whether to enable external program execution]) AC_ARG_ENABLE(exec, AC_HELP_STRING([--disable-exec],[disable all external program execution]), use_exec=$enableval) AC_MSG_RESULT($use_exec) if test "$use_exec" = no ; then AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution]) fi if test "$use_exec" = yes ; then AC_MSG_CHECKING([whether to enable photo ID viewing]) AC_ARG_ENABLE(photo-viewers, [ --disable-photo-viewers disable photo ID viewers], [if test "$enableval" = no ; then AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing]) fi],enableval=yes) gnupg_cv_enable_photo_viewers=$enableval AC_MSG_RESULT($enableval) if test "$gnupg_cv_enable_photo_viewers" = yes ; then AC_MSG_CHECKING([whether to use a fixed photo ID viewer]) AC_ARG_WITH(photo-viewer, [ --with-photo-viewer=FIXED_VIEWER set a fixed photo ID viewer], [if test "$withval" = yes ; then withval=no elif test "$withval" != no ; then AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval", [if set, restrict photo-viewer to this]) fi],withval=no) AC_MSG_RESULT($withval) fi AC_MSG_CHECKING([whether to enable external keyserver helpers]) AC_ARG_ENABLE(keyserver-helpers, [ --disable-keyserver-helpers disable all external keyserver support], [if test "$enableval" = no ; then AC_DEFINE(DISABLE_KEYSERVER_HELPERS,1, [define to disable keyserver helpers]) fi],enableval=yes) gnupg_cv_enable_keyserver_helpers=$enableval AC_MSG_RESULT($enableval) if test "$gnupg_cv_enable_keyserver_helpers" = yes ; then # LDAP is defined only after we confirm the library is available later AC_MSG_CHECKING([whether LDAP keyserver support is requested]) AC_ARG_ENABLE(ldap, AC_HELP_STRING([--disable-ldap],[disable LDAP keyserver interface only]), try_ldap=$enableval, try_ldap=yes) AC_MSG_RESULT($try_ldap) AC_MSG_CHECKING([whether HKP keyserver support is requested]) AC_ARG_ENABLE(hkp, AC_HELP_STRING([--disable-hkp],[disable HKP keyserver interface only]), try_hkp=$enableval, try_hkp=yes) AC_MSG_RESULT($try_hkp) AC_MSG_CHECKING([whether finger key fetching support is requested]) AC_ARG_ENABLE(finger, AC_HELP_STRING([--disable-finger], [disable finger key fetching interface only]), try_finger=$enableval, try_finger=yes) AC_MSG_RESULT($try_finger) AC_MSG_CHECKING([whether generic object key fetching support is requested]) AC_ARG_ENABLE(generic, AC_HELP_STRING([--disable-generic], [disable generic object key fetching interface only]), try_generic=$enableval, try_generic=yes) AC_MSG_RESULT($try_generic) AC_MSG_CHECKING([whether email keyserver support is requested]) AC_ARG_ENABLE(mailto, AC_HELP_STRING([--enable-mailto], [enable email keyserver interface only]), try_mailto=$enableval, try_mailto=no) AC_MSG_RESULT($try_mailto) fi AC_MSG_CHECKING([whether keyserver exec-path is enabled]) AC_ARG_ENABLE(keyserver-path, AC_HELP_STRING([--disable-keyserver-path], [disable the exec-path option for keyserver helpers]), [if test "$enableval" = no ; then disable_keyserver_path=yes fi],enableval=yes) AC_MSG_RESULT($enableval) fi # # Check for the key/uid cache size. This can't be zero, but can be # pretty small on embedded systems. This is used for the gpg part. # AC_MSG_CHECKING([for the size of the key and uid cache]) AC_ARG_ENABLE(key-cache, AC_HELP_STRING([--enable-key-cache=SIZE], [Set key cache to SIZE (default 4096)]),,enableval=4096) if test "$enableval" = "no"; then enableval=5 elif test "$enableval" = "yes" || test "$enableval" = ""; then enableval=4096 fi changequote(,)dnl key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'` changequote([,])dnl if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then AC_MSG_ERROR([invalid key-cache size]) fi AC_MSG_RESULT($key_cache_size) AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size, [Size of the key and UID caches]) # # Check whether we want to use Linux capabilities # AC_MSG_CHECKING([whether use of capabilities is requested]) AC_ARG_WITH(capabilities, [ --with-capabilities use linux capabilities [default=no]], [use_capabilities="$withval"],[use_capabilities=no]) AC_MSG_RESULT($use_capabilities) # # Allow disabling of internal CCID support. # It is defined only after we confirm the library is available later # AC_MSG_CHECKING([whether to enable the internal CCID driver]) AC_ARG_ENABLE(ccid-driver, AC_HELP_STRING([--disable-ccid-driver], [disable the internal CCID driver]), use_ccid_driver=$enableval) AC_MSG_RESULT($use_ccid_driver) # # To avoid double inclusion of config.h which might happen at some # places, we add the usual double inclusion protection at the top of # config.h. # AH_TOP([ #ifndef GNUPG_CONFIG_H_INCLUDED #define GNUPG_CONFIG_H_INCLUDED ]) # # Stuff which goes at the bottom of config.h. # AH_BOTTOM([ /* This is the major version number of GnuPG so that source included files can test for this. Note, that we use 2 here even for GnuPG 1.9.x. */ #define GNUPG_MAJOR_VERSION 2 /* Now to separate file name parts. Please note that the string version must not contain more than one character because the code assumes strlen()==1 */ #ifdef HAVE_DOSISH_SYSTEM #define DIRSEP_C '\\' #define DIRSEP_S "\\" #define EXTSEP_C '.' #define EXTSEP_S "." #define PATHSEP_C ';' #define PATHSEP_S ";" #define EXEEXT_S ".exe" #else #define DIRSEP_C '/' #define DIRSEP_S "/" #define EXTSEP_C '.' #define EXTSEP_S "." #define PATHSEP_C ':' #define PATHSEP_S ":" #define EXEEXT_S "" #endif /* This is the same as VERSION, but should be overridden if the platform cannot handle things like dots '.' in filenames. Set SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION uses for dots and dashes. */ #define SAFE_VERSION VERSION #define SAFE_VERSION_DOT '.' #define SAFE_VERSION_DASH '-' /* Some global constants. */ #ifdef HAVE_DRIVE_LETTERS #define GNUPG_DEFAULT_HOMEDIR "c:/gnupg" #elif defined(__VMS) #define GNUPG_DEFAULT_HOMEDIR "/SYS\$LOGIN/gnupg" #else #define GNUPG_DEFAULT_HOMEDIR "~/.gnupg" #endif #define GNUPG_PRIVATE_KEYS_DIR "private-keys-v1.d" /* For some systems (DOS currently), we hardcode the path here. For POSIX systems the values are constructed by the Makefiles, so that the values may be overridden by the make invocations; this is to comply with the GNU coding standards. */ #ifdef HAVE_DRIVE_LETTERS /* FIXME: We need to use a function to determine these values depending on the actual installation directory. */ #define GNUPG_BINDIR "c:\\gnupg" #define GNUPG_LIBEXECDIR "c:\\gnupg" #define GNUPG_LIBDIR "c:\\gnupg" #define GNUPG_DATADIR "c:\\gnupg" #define GNUPG_SYSCONFDIR "c:\\gnupg" #endif /* Derive some other constants. */ #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID)) #define EXEC_TEMPFILE_ONLY #endif /* We didn't define endianness above, so get it from OS macros. This is intended for making fat binary builds on OS X. */ #if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST) #if defined(__BIG_ENDIAN__) #define BIG_ENDIAN_HOST 1 #elif defined(__LITTLE_ENDIAN__) #define LITTLE_ENDIAN_HOST 1 #else #error "No endianness found" #endif #endif /* Hack used for W32: ldap.m4 also tests for the ASCII version of ldap_start_tls_s because that is the actual symbol used in the library. winldap.h redefines it to our commonly used value, thus we define our usual macro here. */ #ifdef HAVE_LDAP_START_TLS_SA # ifndef HAVE_LDAP_START_TLS_S # define HAVE_LDAP_START_TLS_S 1 # endif #endif /* Tell libgcrypt not to use its own libgpg-error implementation. */ #define USE_LIBGPG_ERROR 1 /* We use jnlib, so tell other modules about it. */ #define HAVE_JNLIB_LOGGING 1 /* Our HTTP code is used in estream mode. */ #define HTTP_USE_ESTREAM 1 /* Under W32 we do an explicit socket initialization, thus we need to avoid the on-demand initialization which would also install an atexit handler. */ #define HTTP_NO_WSASTARTUP /* We always include support for the OpenPGP card. */ #define ENABLE_CARD_SUPPORT 1 /* We don't want the old assuan codes anymore. */ #define _ASSUAN_ONLY_GPG_ERRORS 1 /* We explicitly need to disable PTH's soft mapping as Debian currently enables it by default for no reason. */ #define PTH_SYSCALL_SOFT 0 /* We want to use the libgcrypt provided memory allocation for asprintf. */ #define _ESTREAM_PRINTF_MALLOC gcry_malloc #define _ESTREAM_PRINTF_FREE gcry_free #define _ESTREAM_PRINTF_EXTRA_INCLUDE "util.h" #endif /*GNUPG_CONFIG_H_INCLUDED*/ ]) AM_MAINTAINER_MODE # Checks for programs. AC_MSG_NOTICE([checking for programs]) AC_PROG_MAKE_SET AM_SANITY_CHECK missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AM_PROG_CC_C_O if test "x$ac_cv_prog_cc_c89" = "xno" ; then AC_MSG_ERROR([[No C-89 compiler found]]) fi AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_RANLIB AC_CHECK_TOOL(AR, ar, :) AC_PATH_PROG(PERL,"perl") AC_CHECK_TOOL(WINDRES, windres, :) AC_ISC_POSIX gl_EARLY AC_SYS_LARGEFILE GNUPG_CHECK_FAQPROG GNUPG_CHECK_USTAR # We need to compile and run a program on the build machine. A # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in # the AC archive is broken for autoconf 2.57. Given that tehre is no # newer version of that macro, we assume that it is also broken for # autoconf 2.61 and thus we use a simple but usually sufficient # approach. AC_MSG_CHECKING(for cc for build) if test "$cross_compiling" = "yes"; then CC_FOR_BUILD="${CC_FOR_BUILD-cc}" else CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" fi AC_MSG_RESULT($CC_FOR_BUILD) AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) try_gettext=yes have_dosish_system=no have_w32_system=no use_simple_gettext=no case "${host}" in *-mingw32*) # special stuff for Windoze NT ac_cv_have_dev_random=no AC_DEFINE(USE_ONLY_8DOT3,1, [set this to limit filenames to the 8.3 format]) AC_DEFINE(HAVE_DRIVE_LETTERS,1, [defined if we must run on a stupid file system]) AC_DEFINE(USE_SIMPLE_GETTEXT,1, [because the Unix gettext has too much overhead on MingW32 systems and these systems lack Posix functions, we use a simplified version of gettext]) disable_keyserver_path=yes have_dosish_system=yes have_w32_system=yes try_gettext="no" use_simple_gettext=yes ;; i?86-emx-os2 | i?86-*-os2*emx ) # OS/2 with the EMX environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) have_dosish_system=yes try_gettext="no" ;; i?86-*-msdosdjgpp*) # DOS with the DJGPP environment ac_cv_have_dev_random=no AC_DEFINE(HAVE_DRIVE_LETTERS) have_dosish_system=yes try_gettext="no" ;; *-*-freebsd*) # FreeBSD CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" ;; *-*-hpux*) if test -z "$GCC" ; then CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE" fi ;; *-dec-osf4*) if test -z "$GCC" ; then # Suppress all warnings # to get rid of the unsigned/signed char mismatch warnings. CFLAGS="$CFLAGS -w" fi ;; *-dec-osf5*) if test -z "$GCC" ; then # Use the newer compiler `-msg_disable ptrmismatch1' to # get rid of the unsigned/signed char mismatch warnings. # Using this may hide other pointer mismatch warnings, but # it at least lets other warning classes through CFLAGS="$CFLAGS -msg_disable ptrmismatch1" fi ;; m68k-atari-mint) ;; *) ;; esac if test "$have_dosish_system" = yes; then AC_DEFINE(HAVE_DOSISH_SYSTEM,1, [Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2) with special properties like no file modes]) fi AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes) if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) if test "$disable_keyserver_path" = yes; then AC_DEFINE(DISABLE_KEYSERVER_PATH,1, [Defined to disable exec-path for keyserver helpers]) fi # # Allows enabling the use of a standard socket by default This is # gpg-agent's option --[no-]use-standard-socket. For Windows we force # the use of this. # AC_MSG_CHECKING([whether to use a standard socket by default]) AC_ARG_ENABLE(standard-socket, AC_HELP_STRING([--enable-standard-socket], [use a standard socket for the agent by default]), use_standard_socket=$enableval) tmp="" if test "$use_standard_socket" != yes; then if test "$have_w32_system" = yes; then use_standard_socket=yes tmp=" (forced)" fi fi AC_MSG_RESULT($use_standard_socket$tmp) if test "$use_standard_socket" = yes; then AC_DEFINE(USE_STANDARD_SOCKET,1, [Use a standard socket for the agent by default]) fi # (These need to go after AC_PROG_CC so that $EXEEXT is defined) AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any]) if test x"$try_hkp" = xyes ; then AC_SUBST(GPGKEYS_HKP,"gpg2keys_hkp$EXEEXT") fi if test x"$try_finger" = xyes ; then AC_SUBST(GPGKEYS_FINGER,"gpg2keys_finger$EXEEXT") fi # # Checks for libraries. # AC_MSG_NOTICE([checking for libraries]) # # libgpg-error is a library with error codes shared between GnuPG # related projects. # AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION", have_gpg_error=yes,have_gpg_error=no) # # Libgcrypt is our generic crypto library # AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION", have_libgcrypt=yes,have_libgcrypt=no) # # libassuan is used for IPC # AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", have_libassuan=yes,have_libassuan=no) if test "$have_libassuan" = "yes"; then AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version", [version of the libbassuan library]) fi # # libksba is our X.509 support library # AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no) # # libusb allows us to use the integrated CCID smartcard reader driver. # # FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs. if test "$use_ccid_driver" = yes ; then AC_CHECK_LIB(usb, usb_bulk_write, [ LIBUSB_LIBS="$LIBUSB_LIBS -lusb" AC_DEFINE(HAVE_LIBUSB,1, [defined if libusb is available]) have_libusb=yes ]) AC_CHECK_FUNCS(usb_create_match) fi AC_SUBST(LIBUSB_LIBS) # # Check wether it is necessary to link against libdl. # gnupg_dlopen_save_libs="$LIBS" LIBS="" AC_SEARCH_LIBS(dlopen, c dl,,,) DL_LIBS=$LIBS AC_SUBST(DL_LIBS) LIBS="$gnupg_dlopen_save_libs" # # Checks for symcryptrun: # # libutil has openpty() and login_tty(). AC_CHECK_LIB(util, openpty, [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil" AC_DEFINE(HAVE_LIBUTIL,1, [defined if libutil is available]) ]) AC_SUBST(LIBUTIL_LIBS) # shred is used to clean temporary plain text files. AC_PATH_PROG(SHRED, shred, /usr/bin/shred) AC_DEFINE_UNQUOTED(SHRED, "${SHRED}", [defines the filename of the shred program]) # # Check whether the GNU Pth library is available # Note, that we include a Pth emulation for W32. # GNUPG_PATH_PTH if test "$have_pth" = "yes"; then AC_DEFINE(USE_GNU_PTH, 1, [Defined if the GNU Portable Thread Library should be used]) else AC_MSG_WARN([[ *** *** To support concurrent access to the gpg-agent and the SCdaemon *** we need the support of the GNU Portable Threads Library. *** Download it from ftp://ftp.gnu.org/gnu/pth/ *** On a Debian GNU/Linux system you might want to try *** apt-get install libpth-dev ***]]) fi AC_MSG_NOTICE([checking for networking options]) # # Must check for network library requirements before doing link tests # for ldap, for example. If ldap libs are static (or dynamic and without # ELF runtime link paths), then link will fail and LDAP support won't # be detected. # AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname, [NETLIBS="-lnsl $NETLIBS"])) AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt, [NETLIBS="-lsocket $NETLIBS"])) # # Check for ADNS. # _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(adns, AC_HELP_STRING([--with-adns=DIR], [look for the adns library in DIR]), [if test -d "$withval"; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi]) if test "$with_adns" != "no"; then AC_CHECK_HEADERS(adns.h, AC_CHECK_LIB(adns, adns_init, [have_adns=yes], [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]), [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]) fi if test "$have_adns" = "yes"; then ADNSLIBS="-ladns" fi AC_SUBST(ADNSLIBS) # Newer adns versions feature a free function to be used under W32. AC_CHECK_FUNCS(adns_free) # # Now try for the resolver functions so we can use DNS for SRV, PA and CERT. # if test x"$try_hkp" = xyes || test x"$try_http" = xyes ; then AC_ARG_ENABLE(dns-srv, AC_HELP_STRING([--disable-dns-srv], [disable the use of DNS SRV in HKP and HTTP]), use_dns_srv=$enableval,use_dns_srv=yes) fi AC_ARG_ENABLE(dns-pka, AC_HELP_STRING([--disable-dns-pka], [disable the use of PKA records in DNS]), use_dns_pka=$enableval,use_dns_pka=yes) AC_ARG_ENABLE(dns-cert, AC_HELP_STRING([--disable-dns-cert], [disable the use of CERT records in DNS]), use_dns_cert=$enableval,use_dns_cert=yes) if test x"$use_dns_pka" = xyes || test x"$use_dns_srv" = xyes \ || test x"$use_dns_cert" = xyes; then _dns_save_libs=$LIBS LIBS="" # the double underscore thing is a glibc-ism? AC_SEARCH_LIBS(res_query,resolv bind,, AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no)) AC_SEARCH_LIBS(dn_expand,resolv bind,, AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no)) AC_SEARCH_LIBS(dn_skipname,resolv bind,, AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no)) if test x"$have_resolver" != xno ; then # Make sure that the BIND 4 resolver interface is workable before # enabling any code that calls it. At some point I'll rewrite the # code to use the BIND 8 resolver API. # We might also want to use adns instead. Problem with ADNS is that # it does not support v6. AC_MSG_CHECKING([whether the resolver is usable]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#include #include #include #include ], [[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0); ]])],have_resolver=yes,have_resolver=no) AC_MSG_RESULT($have_resolver) # This is Apple-specific and somewhat bizarre as they changed the # define in bind 8 for some reason. if test x"$have_resolver" != xyes ; then AC_MSG_CHECKING( [whether I can make the resolver usable with BIND_8_COMPAT]) AC_LINK_IFELSE([AC_LANG_PROGRAM([#define BIND_8_COMPAT #include #include #include #include ], [[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0); ]])],[have_resolver=yes ; need_compat=yes]) AC_MSG_RESULT($have_resolver) fi fi if test x"$have_resolver" = xyes ; then DNSLIBS=$LIBS if test x"$use_dns_srv" = xyes ; then AC_DEFINE(USE_DNS_SRV,1,[define to use DNS SRV]) fi if test x"$use_dns_pka" = xyes ; then AC_DEFINE(USE_DNS_PKA,1,[define to use our experimental DNS PKA]) fi if test x"$use_dns_cert" = xyes ; then AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT]) fi if test x"$need_compat" = xyes ; then AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism]) fi else # If we have no resolver library but ADNS (e.g. under W32) enable the # code parts which can be used with ADNS. if test x"$have_adns" = xyes ; then DNSLIBS="$ADNSLIBS" AC_DEFINE(USE_ADNS,1,[Use ADNS as resolver library.]) if test x"$use_dns_srv" = xyes ; then AC_DEFINE(USE_DNS_SRV,1) fi if test x"$use_dns_pka" = xyes ; then AC_DEFINE(USE_DNS_PKA,1) fi if test x"$use_dns_cert" = xyes ; then AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT]) fi else use_dns_srv=no use_dns_pka=no use_dns_cert=no fi fi LIBS=$_dns_save_libs fi AC_SUBST(DNSLIBS) AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes) # # Check for LDAP # if test "$try_ldap" = yes ; then GNUPG_CHECK_LDAP($NETLIBS) fi # # Check for curl. We fake the curl API if libcurl isn't installed. # We require 7.10 or later as we use curl_version_info(). # LIBCURL_CHECK_CONFIG([yes],[7.10],,[fake_curl=yes]) AM_CONDITIONAL(FAKE_CURL,test x"$fake_curl" = xyes) # Generic, for us, means curl if test x"$try_generic" = xyes ; then AC_SUBST(GPGKEYS_CURL,"gpg2keys_curl$EXEEXT") fi # # Check for sendmail # # This isn't necessarily sendmail itself, but anything that gives a # sendmail-ish interface to the outside world. That includes Exim, # Postfix, etc. Basically, anything that can handle "sendmail -t". if test "$try_mailto" = yes ; then AC_ARG_WITH(mailprog, AC_HELP_STRING([--with-mailprog=NAME], [use "NAME -t" for mail transport]), ,with_mailprog=yes) if test x"$with_mailprog" = xyes ; then AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib) if test "$ac_cv_path_SENDMAIL" ; then GPGKEYS_MAILTO="gpg2keys_mailto" fi elif test x"$with_mailprog" != xno ; then AC_MSG_CHECKING([for a mail transport program]) AC_SUBST(SENDMAIL,$with_mailprog) AC_MSG_RESULT($with_mailprog) GPGKEYS_MAILTO="gpg2keys_mailto" fi fi AC_SUBST(GPGKEYS_MAILTO) # # Construct a printable name of the OS # case "${host}" in *-mingw32*) PRINTABLE_OS_NAME="MingW32" ;; *-*-cygwin*) PRINTABLE_OS_NAME="Cygwin" ;; i?86-emx-os2 | i?86-*-os2*emx ) PRINTABLE_OS_NAME="OS/2" ;; i?86-*-msdosdjgpp*) PRINTABLE_OS_NAME="MSDOS/DJGPP" try_dynload=no ;; *-linux*) PRINTABLE_OS_NAME="GNU/Linux" ;; *) PRINTABLE_OS_NAME=`uname -s || echo "Unknown"` ;; esac AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME", [A human readable text with the name of the OS]) # # Checking for iconv # AM_ICONV # # Check for gettext # # This is "GNU gnupg" - The project-id script from gettext # needs this string # AC_MSG_NOTICE([checking for gettext]) AM_PO_SUBDIRS AM_GNU_GETTEXT_VERSION([0.17]) if test "$try_gettext" = yes; then AM_GNU_GETTEXT([external],[need-ngettext]) # gettext requires some extra checks. These really should be part of # the basic AM_GNU_GETTEXT macro. TODO: move other gettext-specific # function checks to here. AC_CHECK_FUNCS(strchr) else USE_NLS=no USE_INCLUDED_LIBINTL=no BUILD_INCLUDED_LIBINTL=no POSUB=po AC_SUBST(USE_NLS) AC_SUBST(USE_INCLUDED_LIBINTL) AC_SUBST(BUILD_INCLUDED_LIBINTL) AC_SUBST(POSUB) fi # We use HAVE_LANGINFO_CODESET in a couple of places. AM_LANGINFO_CODESET # Checks required for our use locales gt_LC_MESSAGES # # SELinux support # if test "$selinux_support" = yes ; then AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support]) fi # # Checks for header files. # AC_MSG_NOTICE([checking for header files]) AC_HEADER_STDC AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h]) AC_CHECK_HEADERS([pty.h pwd.h inttypes.h]) AC_HEADER_TIME # # Checks for typedefs, structures, and compiler characteristics. # AC_MSG_NOTICE([checking for system characteristics]) AC_C_CONST AC_C_INLINE AC_C_VOLATILE AC_TYPE_SIZE_T AC_TYPE_MODE_T AC_TYPE_SIGNAL AC_DECL_SYS_SIGLIST gl_HEADER_SYS_SOCKET gl_TYPE_SOCKLEN_T AC_ARG_ENABLE(endian-check, AC_HELP_STRING([--disable-endian-check], [disable the endian check and trust the OS provided macros]), endiancheck=$enableval,endiancheck=yes) if test x"$endiancheck" = xyes ; then GNUPG_CHECK_ENDIAN fi # fixme: we should get rid of the byte type GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF) GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF) GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF) GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF) GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF) AC_CHECK_SIZEOF(unsigned short) AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(time_t,,[[ #include #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif ]]) # Ensure that we have UINT64_C before we bother to check for uint64_t # Fixme: really needed in gnupg? I think it is only useful in libcgrypt. AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works], AC_COMPILE_IFELSE(AC_LANG_PROGRAM([#include uint64_t foo=UINT64_C(42);]), gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no)) if test "$gnupg_cv_uint64_c_works" = "yes" ; then AC_CHECK_SIZEOF(uint64_t) fi if test "$ac_cv_sizeof_unsigned_short" = "0" \ || test "$ac_cv_sizeof_unsigned_int" = "0" \ || test "$ac_cv_sizeof_unsigned_long" = "0"; then AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]); fi # # Checks for library functions. # AC_MSG_NOTICE([checking for library functions]) AC_CHECK_DECLS(getpagesize) AC_FUNC_FSEEKO AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_FUNCS([strerror strlwr tcgetattr mmap]) AC_CHECK_FUNCS([strcasecmp strncasecmp ctermid times gmtime_r]) AC_CHECK_FUNCS([unsetenv fcntl ftruncate]) AC_CHECK_FUNCS([gettimeofday getrusage getrlimit setrlimit clock_gettime]) AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale]) AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe stat getaddrinfo]) -AC_CHECK_FUNCS([ttyname rand ftello fsync]) +AC_CHECK_FUNCS([ttyname rand ftello fsync stat]) AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include ]) # # These are needed by libjnlib - fixme: we should use a jnlib.m4 # Note: We already checked pwd.h. AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol]) AC_CHECK_FUNCS([memrchr isascii timegm getrusage setrlimit stat setlocale]) AC_CHECK_FUNCS([flockfile funlockfile fopencookie funopen getpwnam getpwuid]) # # gnulib checks # gl_SOURCE_BASE([gl]) gl_M4_BASE([gl/m4]) gl_MODULES([setenv mkdtemp xsize strpbrk]) gl_INIT # # W32 specific test # GNUPG_FUNC_MKDIR_TAKES_ONE_ARG # # Sanity check regex. Tests adapted from mutt. # AC_MSG_CHECKING([whether regular expression support is requested]) AC_ARG_ENABLE(regex, AC_HELP_STRING([--disable-regex], [do not handle regular expressions in trust signatures]), use_regex=$enableval, use_regex=yes) AC_MSG_RESULT($use_regex) if test "$use_regex" = yes ; then _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(regex, AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]), [ if test -d "$withval" ; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ],withval="") # Does the system have regex functions at all? AC_SEARCH_LIBS([regcomp], [regex]) AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no) if test $gnupg_cv_have_regex = no; then use_regex=no else if test x"$cross_compiling" = xyes; then AC_MSG_WARN([cross compiling; assuming regexp libray is not broken]) else AC_CACHE_CHECK([whether your system's regexp library is broken], [gnupg_cv_regex_broken], AC_TRY_RUN([ #include #include main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }], gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes)) if test $gnupg_cv_regex_broken = yes; then AC_MSG_WARN([your regex is broken - disabling regex use]) use_regex=no fi fi fi CPPFLAGS="${_cppflags}" LDFLAGS="${_ldflags}" fi if test "$use_regex" != yes ; then AC_DEFINE(DISABLE_REGEX,1, [Define to disable regular expression support]) fi AM_CONDITIONAL(DISABLE_REGEX, test x"$use_regex" != xyes) # # Do we have zlib? Must do it here because Solaris failed # when compiling a conftest (due to the "-lz" from LIBS). # Note that we combine zlib and bzlib2 in ZLIBS. # _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(zlib, [ --with-zlib=DIR use libz in DIR],[ if test -d "$withval"; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ]) AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, deflateInit2_, ZLIBS="-lz", CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) # # Check whether we can support bzip2 # if test "$use_bzip2" = yes ; then _cppflags="${CPPFLAGS}" _ldflags="${LDFLAGS}" AC_ARG_WITH(bzip2, AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]), [ if test -d "$withval" ; then CPPFLAGS="${CPPFLAGS} -I$withval/include" LDFLAGS="${LDFLAGS} -L$withval/lib" fi ],withval="") # Checking alongside stdio.h as an early version of bzip2 (1.0) # required stdio.h to be included before bzlib.h, and Solaris 9 is # woefully out of date. if test "$withval" != no ; then AC_CHECK_HEADER(bzlib.h, AC_CHECK_LIB(bz2,BZ2_bzCompressInit, [ have_bz2=yes ZLIBS="$ZLIBS -lbz2" AC_DEFINE(HAVE_BZIP2,1, [Defined if the bz2 compression library is available]) ], CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include ]) fi fi AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes") AC_SUBST(ZLIBS) # Check for readline support GNUPG_CHECK_READLINE # # Allow users to append something to the version string without # flagging it as development version. The user version parts is # considered everything after a dash. # if test "$development_version" != yes; then changequote(,)dnl tmp_pat='[a-zA-Z]' changequote([,])dnl if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then development_version=yes fi fi if test "$development_version" = yes; then AC_DEFINE(IS_DEVELOPMENT_VERSION,1, [Defined if this is not a regular release]) fi AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) GNUPG_CHECK_GNUMAKE # Add some extra libs here so that previous tests don't fail for # mysterious reasons - the final link step should bail out. # W32SOCKLIBS is also defined so that if can be used for tools not # requiring any network stuff but linking to code in libcommon which # tracks in winsock stuff (e.g. init_common_subsystems. if test "$have_w32_system" = yes; then W32SOCKLIBS="-lws2_32" NETLIBS="${NETLIBS} ${W32SOCKLIBS}" fi AC_SUBST(NETLIBS) AC_SUBST(W32SOCKLIBS) # # Setup gcc specific options # AC_MSG_NOTICE([checking for cc features]) if test "$GCC" = yes; then # Note that it is okay to use CFLAGS here because this are just # warning options and the user should have a chance of overriding # them. if test "$USE_MAINTAINER_MODE" = "yes"; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security" AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-missing-field-initializers" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers" fi AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wdeclaration-after-statement" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -Wdeclaration-after-statement" fi else CFLAGS="$CFLAGS -Wall" fi AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-pointer-sign" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no) AC_MSG_RESULT($_gcc_psign) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_psign" = xyes ; then CFLAGS="$CFLAGS -Wno-pointer-sign" fi AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wpointer-arith" AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no) AC_MSG_RESULT($_gcc_psign) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_psign" = xyes ; then CFLAGS="$CFLAGS -Wpointer-arith" fi fi # # This is handy for debugging so the compiler doesn't rearrange # things and eliminate variables. # AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable compiler optimization]), [if test $enableval = no ; then CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'` fi]) # # Prepare building of estream # estream_INIT # # Decide what to build # if test "$have_adns" = "yes"; then AC_SUBST(GPGKEYS_KDNS, "gpg2keys_kdns$EXEEXT") fi missing_pth=no if test $have_ksba = no; then build_gpgsm=no build_scdaemon=no fi build_agent_threaded="" if test "$build_agent" = "yes"; then if test $have_pth = no; then build_agent_threaded="(not multi-threaded)" missing_pth=yes fi fi build_scdaemon_extra="" if test "$build_scdaemon" = "yes"; then tmp="" if test $have_pth = no; then build_scdaemon_extra="not multi-threaded" tmp=", " missing_pth=yes fi if test $have_libusb = no; then build_scdaemon_extra="${tmp}without internal CCID driver" tmp=", " fi if test -n "$build_scdaemon_extra"; then build_scdaemon_extra="(${build_scdaemon_extra})" fi fi if test "$build_agent_only" = "yes" ; then build_gpg=no build_gpgsm=no build_scdaemon=no build_tools=no build_doc=no fi AM_CONDITIONAL(BUILD_GPG, test "$build_gpg" = "yes") AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes") AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes") AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes") AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes") AM_CONDITIONAL(BUILD_DOC, test "$build_doc" = "yes") AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes") +AM_CONDITIONAL(BUILD_GPGTAR, test "$build_gpgtar" = "yes") AM_CONDITIONAL(RUN_GPG_TESTS, test x$cross_compiling = xno -a "$build_gpg" = yes ) # # Print errors here so that they are visible all # together and the user can acquire them all together. # die=no if test "$have_gpg_error" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libgpg-error to build this program. ** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libgpg-error *** (at least version $NEED_GPG_ERROR_VERSION is required.) ***]]) fi if test "$have_libgcrypt" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libgcrypt to build this program. ** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/ *** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.) ***]]) fi if test "$have_libassuan" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libassuan to build this program. *** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libassuan/ *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required). ***]]) fi if test "$have_ksba" = "no"; then AC_MSG_NOTICE([[ *** *** You need libksba to build this program. *** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libksba/ *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required). ***]]) fi if test "$missing_pth" = "yes"; then AC_MSG_NOTICE([[ *** *** It is now required to build with support for the *** GNU Portable Threads Library (Pth). Please install this *** library first. The library is for example available at *** ftp://ftp.gnu.org/gnu/pth/ *** On a Debian GNU/Linux system you can install it using *** apt-get install libpth-dev *** To build GnuPG for Windows you need to use the W32PTH *** package; available at: *** ftp://ftp.g10code.com/g10code/w32pth/ ***]]) die=yes fi if test "$die" = "yes"; then AC_MSG_ERROR([[ *** *** Required libraries not found. Please consult the above messages *** and install them before running configure again. ***]]) fi AC_CONFIG_FILES([ m4/Makefile Makefile po/Makefile.in gl/Makefile include/Makefile jnlib/Makefile common/Makefile kbx/Makefile g10/Makefile sm/Makefile agent/Makefile scd/Makefile keyserver/Makefile keyserver/gpg2keys_mailto keyserver/gpg2keys_test tools/gpg-zip tools/Makefile doc/Makefile tests/Makefile tests/openpgp/Makefile tests/pkits/Makefile ]) AC_OUTPUT echo " GnuPG v${VERSION} has been configured as follows: Platform: $PRINTABLE_OS_NAME ($host) OpenPGP: $build_gpg S/MIME: $build_gpgsm Agent: $build_agent $build_agent_threaded Smartcard: $build_scdaemon $build_scdaemon_extra + Gpgtar: $build_gpgtar Protect tool: $show_gnupg_protect_tool_pgm Default agent: $show_gnupg_agent_pgm Default pinentry: $show_gnupg_pinentry_pgm Default scdaemon: $show_gnupg_scdaemon_pgm Default dirmngr: $show_gnupg_dirmngr_pgm " if test x"$use_regex" != xyes ; then echo " Warning: No regular expression support available. OpenPGP trust signatures won't work. gpg-check-pattern will not be build. " fi diff --git a/po/.gitattributes b/po/.gitattributes index 0c8874e0e..17b178c0e 100644 --- a/po/.gitattributes +++ b/po/.gitattributes @@ -1,2 +1,7 @@ +# You should add +#[filter "cleanpo"] +# clean = "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" +# to your config file. + /??.po filter=cleanpo /??_??.po filter=cleanpo diff --git a/tools/ChangeLog b/tools/ChangeLog index 039764df4..f7abab373 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,1076 +1,1084 @@ +2011-01-11 Werner Koch + + * gpgtar.c, gpgtar.h, gpgtar-create.c, gpgtar-extract.c + * gpgtar-list.c: New. Take from GnuPG master and add missing + functions. + * Makefile.am (bin_PROGRAMS): Add gpgtar. + (gpgtar_SOURCES, gpgtar_CFLAGS, gpgtar_LDADD): New. + 2010-08-23 Werner Koch * gpgconf-comp.c (retrieve_options_from_program) (retrieve_options_from_file, copy_file): Do not use ferror after a failed fclose. Note that the stream is in any case invalid after calling fclose and that fclose does set ERRNO. 2010-08-19 Werner Koch * gpgconf.c (main): Fix --check-options. 2010-02-11 Marcus Brinkmann From 2009-09-23, 2009-11-04, 2009-11-05, 2009-12-08: * gpg-connect-agent.c (read_and_print_response): Add arg WITHHASH. (getinfo_pid_cb, read_and_print_response) (main): Pass true for WITHHASH for the HELP command. Update to new Assuan API. Update use of assuan_socket_connect and assuan_pipe_connect. Convert posix fd to assuan fd. 2010-01-10 Werner Koch * symcryptrun.c (utmp.h): Remove header; it is not used. 2009-12-18 Werner Koch * applygnupgdefaults (errorfile): Use mktemp. Fixes bug#1146. 2009-12-07 Werner Koch * no-libgcrypt.c (gcry_strdup): Actually copy the string. 2009-07-21 Werner Koch * gpgsplit.c (my_strusage): Remove i18n stuff. 2009-07-07 Werner Koch * gpg-connect-agent.c (start_agent): Adjust for changed args of send_pinentry_environment. 2009-06-30 Werner Koch * ccidmon.c (parse_line_sniffusb): Take also TAB as delimiter. 2009-06-29 Werner Koch * ccidmon.c (parse_line_sniffusb): New. (main): Add option --sniffusb. 2009-06-08 Werner Koch * gpgconf.c (main): Call gnupg_reopen_std. Should fix bug#1072. 2009-05-19 Werner Koch * watchgnupg.c: Include jnlib/mischelp.h if required. (main): Use SUN_LEN. 2009-04-17 Werner Koch * ccidmon.c: New. 2009-03-03 Werner Koch * gpgconf.c: New command --reload. * gpgconf-comp.c (gc_component_reload): New. 2009-03-02 Werner Koch * gpgconf-comp.c (scdaemon_runtime_change): Killsc d only if it is not running. 2009-02-27 Werner Koch * gpgconf-comp.c (gpg_agent_runtime_change): Declare static. (scdaemon_runtime_change): New. (gc_backend_scdaemon): Register new function. (gc_options_scdaemon): Make most options runtime changable. 2009-01-20 Werner Koch * gpgconf.c (main): Print more directories. 2008-12-09 Werner Koch * gpg-check-pattern.c (main): Call i18n_init before init_common_subsystems. * gpg-connect-agent.c (main): Ditto. * gpgconf.c (main): Ditto. * symcryptrun.c (main): Ditto. 2008-12-08 Werner Koch * gpgkey2ssh.c (main): Change order of output for RSA. Change name of DSA identifier. Reported by Daniel Kahn Gillmor. This is bug#901. 2008-12-05 Werner Koch * gpg-connect-agent.c (opts): Use ARGPARSE_ macros. (start_agent) [W32]: Start agent if not running. 2008-12-03 Werner Koch * gpgconf-comp.c : Add option --card-timeout. Remove unused option --disable-opensc. 2008-10-20 Werner Koch * gpgsplit.c (write_part): Remove unused arg FNAME. Change caller. (do_split): Ditto. * no-libgcrypt.c (gcry_control): Mark unused arg. * gpg-connect-agent.c (do_recvfd): Ditto. * gpgparsemail.c (mime_signed_begin, mime_encrypted_begin): Ditto. (pkcs7_begin): Ditto. 2008-10-01 Werner Koch * gpg-connect-agent.c (main): New command datafile. (read_and_print_response): Print to the defined datafile. 2008-09-30 Werner Koch * gpgconf.c (main) : Print the bindir. 2008-08-06 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpgsm): Change type of keyserver option to GC_ARG_TYPE_LDAP_SERVER. * gpgconf-comp.c (retrieve_options_from_file): Transfer the NO_CHANGE flag from the file name option to the list option. 2008-06-19 Werner Koch * gpgconf-comp.c (GC_ARG_TYPE_ALIAS_LIST): New. (gc_arg_type): Add fallback type. (gc_options_gpg): Add option "group". 2008-06-12 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpgsm): Add option keyserver. 2008-05-26 Marcus Brinkmann * gpgconf-comp.c: Replace pathname by filename everywhere. * gpgconf.c (enum cmd_and_opt_values): Add aListDirs. (opts): Add aListDirs option. (main): Handle aListDirs. * gpgconf.h (gc_percent_escape): New declaration. * gpgconf-comp.c (my_percent_escape): Make non-static and rename to ... (gc_percent_escape): ... this. Change all callers. 2008-05-26 Werner Koch * gpgconf-comp.c (gpg_agent_runtime_change) [W32]: Issue "reloadagent" command to gpg-agent. * gpg-connect-agent.c (main): Allow server command on the command line. 2008-05-20 Marcus Brinkmann * gpgconf.h (gc_component_check_programs): Rename to ... (gc_check_programs): ... this. (gc_component_change_options): Add argument OUT. (gc_component_check_options): New function. * gpgconf.c (enum cmd_and_opt_values): New option aCheckOptions. (opts): Add new option aCheckOptions (aka --check-options). (main): Handle new option aCheckOptions. * gpgconf-comp.c (gc_component_check_programs): Rename to ... (gc_check_programs): ... this. Refactor core of it to ... (gc_component_check_options): ... this new function. (gc_component_change_options): Add new argument OUT. Externally verify all changes. Implement option --dry-run. 2008-05-09 Werner Koch * gpgconf-comp.c (my_dgettext) [USE_SIMPLE_GETTEXT]: Hack to parly support translations. 2008-04-08 Werner Koch * gpgconf-comp.c (gc_options_gpg): Add --auto-key-locate. 2008-03-26 Werner Koch * make-dns-cert.c: Include unistd.h. Use config.h if requested. (cert_key): Protect read against EINTR. (main): Print SVN revision for standalone version. 2008-03-05 Werner Koch * gpg-connect-agent.c (arithmetic_op): Add logical not, or and and. (get_var_ext): Add functions errcode, errsource and errstring. (read_and_print_response): Store server reply in $? variable. (main): Implement IF command. 2008-02-27 Marcus Brinkmann * gpgconf-comp.c (option_check_validity): For now, error out on empty strings. (enum): Add GC_ARG_TYPE_PUB_KEY and GC_ARG_TYPE_SEC_KEY. 2008-02-01 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Fix memcpy. Reported by Marc Mutz. 2008-01-22 Werner Koch * gpgconf-comp.c: Use gnupg domain for honor-http-proxy. Make "LDAP server list" group title translatable. 2008-01-17 Marcus Brinkmann * gpgconf-comp.c (change_options_program): Strip duplicated utf8-strings entries for gnupg backend. Don't create them either. 2007-12-10 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Fix up expert level of group. 2007-12-04 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_components): Do not print a trailing semi-colon to ensure forward compatibility, as this would indicate another empty field. (gc_process_gpgconf_conf): Likewise. 2007-11-15 Werner Koch * gpg-connect-agent.c (start_agent): Adjust changed send_pinentry_environment. 2007-10-24 Werner Koch * gpg-connect-agent.c (substitute_line): Restore temporary nul marker. (main): Add /while command. 2007-10-23 Werner Koch * gpgconf-comp.c (gc_process_gpgconf_conf): Add arg LISTFP. Changed all callers. * gpgconf.h: Add gc_error. * gpgconf.c: Add command --list-config. (get_outfp): New. (main): Make --output work. * gpgconf-comp.c (gc_options_gpg_agent): Replace accidently used GC_BACKEND_SCDAEMON. We should consider to create these tables from plain files. 2007-10-22 Werner Koch * gpgconf-comp.c (retrieve_options_from_program): Replace use of popen by our gnupg_spawn_process_fd. This is required because popen under Windows can't handle long filenames. 2007-10-19 Werner Koch * symcryptrun.c (confucius_get_pass): Use utf8 switching functions. * gpg-connect-agent.c (get_var_ext): New. (substitute_line): Use it. (assign_variable): Implement /slet in terms of get_var_ext. (main): New option -s/--subst. (add_definq): Add arg IS_VAR. Change all callers. (main): Add command /definq. (handle_inquire): Implement new command. (substitute_line_copy): New. (unescape_string, unpercent_string): New. * no-libgcrypt.c (gcry_set_outofcore_handler) (gcry_set_fatalerror_handler, gcry_set_log_handler): New. * Makefile.am (gpg_connect_agent_LDADD): Link to libreadline. * gpgconf-comp.c (retrieve_options_from_file): Don't call fclose with NULL. Fixes bug 842. 2007-10-12 Werner Koch * gpg-connect-agent.c (substitute_line): Allow ${foo} syntax. 2007-10-11 Werner Koch * gpg-connect-agent.c (get_var): Expand environment variables. Suggested by Marc Mutz. (set_var): Return the value. (assign_variable): Add arg syslet. (main): New command /slet. (gnu_getcwd): New. (assign_variable): Add tag cwd, and *dir. 2007-10-02 Werner Koch * no-libgcrypt.c (gcry_malloc_secure): New. * gpg-connect-agent.c (set_var, set_int_var, get_var) (substitute_line, show_variables, assign_variable) (do_open, do_close, do_showopen): New. (main): Add new commands /nosubst, /subst, /let, /showvar, /open, /close and /showopen. (main): New commands /run and /bye. 2007-10-01 Werner Koch * gpg-connect-agent.c (do_sendfd): Use INT2FD for assuan_sendfd. 2007-09-26 Werner Koch * gpg-connect-agent.c (main): Print the first response from the server. 2007-09-14 Werner Koch * gpgconf-comp.c: Make a string translatable. 2007-09-04 Moritz Schulte * gpgsm-gencert.sh: Use printf instead of echo. 2007-09-04 Moritz Schulte * gpgkey2ssh.c: Include sysutils.h so that gnupg_tmpfile() is declared. 2007-08-31 Werner Koch * gpgparsemail.c: Support PGP/MIME signed messages. * gpgconf-comp.c (gc_component_list_components): List the programs names. 2007-08-29 Werner Koch * gpgconf.c: New command --check-programs. * gpgconf-comp.c (gc_component_check_programs): New. (gc_backend): Add member MODULE_NAME and add these module names. (retrieve_options_from_program): Use module name so that we use an absolute file name and don't rely on $PATH. (collect_error_output): New. * no-libgcrypt.c (gcry_control): New. 2007-08-28 Werner Koch * gpgconf-comp.c : Add options --max-passphrase-days and --enable-passphrase-history. 2007-08-27 Werner Koch * gpg-check-pattern.c: New * Makefile.am (libexec_PROGRAMS): Add unless DISABLE_REGEX. 2007-08-24 Werner Koch * gpgconf-comp.c : Add options --check-passphrase-pattern, --min-passphrase-nonalpha and --enforce-passphrase-constraints and move them into a new "passphrase policy" group. (gc_component) [W32]: Enable dirmngr. 2007-08-21 Werner Koch * gpgkey2ssh.c (key_to_blob): Use gnupg_tmpfile(). 2007-08-02 Werner Koch * gpgconf-comp.c: Factor the public GC_OPT_FLAG constants out and include gc-opt-flags.h. 2007-07-17 Werner Koch * gpgconf-comp.c: Add --encrypt-to and --default-key to gpg and gpgsm. 2007-07-16 Marcus Brinkmann * gpg-connect-agent.c (main): Bail out if write fails. 2007-07-05 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Define orig_codeset if [ENABLE_NLS], not [HAVE_LANGINFO_CODESET]. 2007-06-26 Werner Koch * gpgconf-comp.c (key_matches_user_or_group) [W32]: Implement user name matching. (GPGNAME): New. Use it instead of "gpg". (gc_component) [W32]: Disable dirmngr for now. (gc_component_retrieve_options): Ignore components without options. (gc_component_change_options): Ditto. (gc_component_list_options): Ditto. (gc_component_find, gc_component_list_components): Ditto. 2007-06-19 Werner Koch * gpgconf-comp.c (percent_escape): Rename to my_percent_escape. Changed all callers. 2007-06-18 Marcus Brinkmann * gpgconf-comp.c (retrieve_options_from_file): Close LIST_FILE. (copy_file): In error case, save/restore errno. Close SRC and DST. (gc_component_change_options): Catch error from unlink(). Remove target backup file before rename(). 2007-06-15 Marcus Brinkmann * gpgconf-comp.c (copy_file) [HAVE_W32_SYSTEM]: New function. (change_options_file, change_options_program) [HAVE_W32_SYSTEM]: Copy backup file. (gc_component_change_options) [HAVE_W32_SYSTEM]: Non-atomic replace. (gc_process_gpgconf_conf): Rename fname to fname_arg and fname_buffer to fname, initialize fname with fname_arg, discarding const qualifier. 2007-06-15 Werner Koch * Makefile.am (symcryptrun_LDADD): It is LIBICONV and not LIBINCONV. (gpgconf_LDADD, symcryptrun_LDADD): Add W32SOCKLIBS. 2007-06-14 Werner Koch * symcryptrun.c (main): Setup default socket name for simple-pwquery. (MAP_SPWQ_ERROR_IMPL): New. Use it for all spwq error returns. 2007-06-12 Werner Koch * gpgconf-comp.c (gc_process_gpgconf_conf): Replace GNUPG_SYSCONFDIR by a function call. * gpg-connect-agent.c (main): Replace some calls by init_common_subsystems. * gpgconf.c (main): Ditto. * symcryptrun.c (main): Ditto. 2007-06-11 Werner Koch * symcryptrun.c (main) [W32]: Call pth_init. * gpgconf.c (main) [W32]: Call pth_init * gpg-connect-agent.c (main) [W32]: Call pth_init. 2007-06-06 Werner Koch * Makefile.am (bin_PROGRAMS) [W32]: Do not build gpgparsemail. * gpgconf-comp.c [W32]: Do not include pwd.h and grp.h. (key_matches_user_or_group) [W32]: For now always return false. * symcryptrun.c (i18n_init): Remove. * gpgconf.c (i18n_init): Remove. * gpg-connect-agent.c (i18n_init): Remove. 2007-05-19 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Free ORIG_CODESET on error. 2007-05-08 Werner Koch * sockprox.c: New. It needs to be build manually. By Moritz Schulte. 2007-04-20 Werner Koch * symcryptrun.c (my_gcry_logger): Removed. (main): Call setup_libgcrypt_logging. 2007-04-03 Werner Koch * gpgconf-comp.c: Allow changing of --allow-mark-trusted. * gpg-connect-agent.c (main): New option --decode and commands decode and undecode. (read_and_print_response): Implement option. 2007-03-20 Werner Koch * gpgconf-comp.c (gc_options_gpgsm): Add p12-charset. 2007-03-07 Werner Koch * applygnupgdefaults: New. * Makefile.am (sbin_SCRIPTS): Add it 2007-03-06 Werner Koch * gpgconf-comp.c: Include pwd.h and grp.h. (GC_OPT_FLAG_NO_CHANGE): New. (gc_component_change_options): Implement it. (gc_options_gpg_agent): Add options for all ttl values and min-passphrase-length. Apply new flag to some of them. (gc_process_gpgconf_conf, key_matches_user_or_group): New. (gc_component_change_options): Factor some code out to .. (change_one_value): .. new. (gc_component_retrieve_options): Allow -1 for COMPONENT to iterate over al components. * gpgconf.c (main): New commands --check-config and --apply-defaults. Call gc_process_gpgconf_conf. 2007-01-31 Werner Koch * Makefile.am (symcryptrun_LDADD): Add LIBICONV. (gpgkey2ssh_LDADD): Ditto. 2006-12-13 David Shaw * Makefile.am (gpgsplit_LDADD): Link to LIBINTL if we're using the built-in code. 2006-12-07 David Shaw * Makefile.am: Link to iconv for jnlib dependency. 2006-11-23 Werner Koch * Makefile.am (gpg_connect_agent_LDADD): Add NETLIBS. 2006-11-21 Werner Koch * gpgconf-comp.c (list_one_option): Cast print size_t arg. 2006-11-17 Werner Koch * gpgconf-comp.c: Made disable-keypad a basic option. 2006-11-03 Werner Koch * symcryptrun.c: Include signal.h and include pth.h only if test asserts that it exists. 2006-10-23 Werner Koch * gpgconf-comp.c : Add --cipher-algo. 2006-10-20 Werner Koch * gpgsm-gencert.sh: Enhanced the main menu. 2006-10-12 Werner Koch * Makefile.am (gpg-zip, gpgsplit): Do not install due to a conflict with gpg1. 2006-10-11 Werner Koch * gpgsm-gencert.sh: Allow generation of card keys. 2006-10-08 Werner Koch * Makefile.am (gpgkey2ssh_LDADD): Add LIBINTL. Suggested by Andreas Metzler. 2006-09-22 Werner Koch * no-libgcrypt.c: Changed license to a simple all permissive one. 2006-09-20 Werner Koch * Makefile.am: Changes to allow parallel make runs. 2006-09-12 Werner Koch Replaced all call gpg_error_from_errno(errno) by gpg_error_from_syserror(). * gpg-connect-agent.c (read_and_print_response): With verbosity level 2 also print comment lines. 2006-09-06 Werner Koch * gpg-connect-agent.c: Switch everything to new Assuan error code style. * no-libgcrypt.c (out_of_core): Reanmed to ... (out_of_memory): .. this to avoid name clash with util.h. 2006-08-21 Werner Koch * gpgsplit.c: New. Taken from 1.4. Adjusted to GnuPG2. * Makefile.am (noinst_PROGRAMS): New. 2006-06-09 Marcus Brinkmann * Makefile.am (gpgconf_LDADD): Add $(GPG_ERROR_LIBS). (gpgkey2ssh_LDADD): Add ../jnlib/libjnlib.a. 2006-05-23 Werner Koch * gpgparsemail.c: Include config.h if available (stpcpy): Conditional include it. * gpgconf-comp.c (hextobyte): Removed as it is now availble in jnlib. 2005-12-20 Werner Koch * gpgconf-comp.c (gc_options_gpg): Add allow-pka-lookup. 2005-12-14 Werner Koch * Makefile.am (bin_PROGRAMS): Build gpgparsemail. * gpgparsemail.c (pkcs7_begin): New. (parse_message, message_cb): Add support of direct pkcs signatures. 2005-10-19 Werner Koch * gpgconf-comp.c (gc_options_scdaemon): New option --disable-keypad. 2005-09-22 Werner Koch * rfc822parse.c (parse_field): Tread Content-Disposition special. 2005-10-08 Marcus Brinkmann * Makefile.am (watchgnupg_LDADD): New variable. * Makefile.am (gpgconf_LDADD): Add ../gl/libgnu.a after ../common/libcommon.a. (symcryptrun_LDADD, gpg_connect_agent_LDADD, gpgkey2ssh_LDADD): Likewise. 2005-09-29 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(LIBGCRYPT_CFLAGS). 2005-09-06 Werner Koch * rfc822parse.c, rfc822parse.h: Changed license to LGPL. 2005-08-01 Werner Koch * gpgsm-gencert.sh: Allow entering a keygrip to generate a CSR from an existing key. 2005-07-21 Werner Koch * gpgsm-gencert.sh: Reworked to allow for multiple email addresses as well as DNsanmes and URi. Present the parameter file before creating the certificate. 2005-07-04 Marcus Brinkmann * symcryptrun.c (SYMC_BAD_PASSPHRASE, SYMC_CANCELED): New symbols, use instead constants. (hash_string): New function copied from simple-gettext.c. (confucius_get_pass): Take new argument CACHEID. (confucius_process): Calculate cacheid and pass it to confucius_get_pass. Clear passphrase from cache if necessary. 2005-06-16 Werner Koch * gpg-connect-agent.c (read_and_print_response): Made LINELEN a size_t. 2005-06-04 Marcus Brinkmann * symcryptrun.c (main): Allow any number of arguments, don't use first argument as input file name. Pass extra arguments to confucius_main. (confucius_main): Accept new arguments argc and argv and pass them to confucius_process. (confucius_process): Accept new arguments argc and argv and pass them to the confucius process. 2005-06-01 Werner Koch * symcryptrun.c: Include mkdtemp.h. 2005-05-31 Werner Koch * watchgnupg.c: Make sure that PF_LCOAL and AF_LOCAL are defines. Noted by Ray Link. 2005-05-28 Moritz Schulte * gpgkey2ssh.c: New file. * Makefile.am (bin_PROGRAMS): Added gpgkey2ssh. 2005-05-20 Werner Koch * gpg-connect-agent.c (add_definq, show_definq, clear_definq) (handle_inquire): New. (read_and_print_response): Handle INQUIRE command. (main): Implement control commands. 2005-04-21 Werner Koch * symcryptrun.c (main): Optionally allow the input file as command line argument. * gpgconf-comp.c: Add gpgsm option disable-trusted-cert-crl-check. 2005-04-20 Werner Koch * gpgconf-comp.c: Add gpg-agent:disable-scdaemon. 2005-04-19 Marcus Brinkmann * symcryptrun.c: Add --input option. 2005-04-15 Marcus Brinkmann * symcryptrun.c (TEMP_FAILURE_RETRY): Define if not defined. * symcryptrun.c (remove_file): New function. (confucius_copy_file): Accept new argument PLAIN and shred the file if it is set on error. * Makefile.am: Define symcryptrun make variable depending on BUILD_SYMCRYPTUN. (bin_PROGRAMS): Add ${symcryptrun} instead symcryptrun. (symcryptrun_LDADD): Use $(LIBUTIL_LIBS) instead of -lutil. 2005-04-11 Werner Koch * symcryptrun.c (confucius_mktmpdir): Changed to use mkdtmp(3). 2005-04-11 Marcus Brinkmann * symcryptrun.c: Implement config file parsing. * Makefile.am (bin_PROGRAMS): Add symcryptrun. (symcryptrun_SOURCES, symcryptrun_LDADD): New variables. * symcryptrun.c: New file. 2005-03-31 Werner Koch * gpg-connect-agent.c (start_agent): Use PATHSEP_C instead of ':'. 2005-03-09 Werner Koch * gpgconf-comp.c : Add honor-http-proxy. 2005-02-25 Werner Koch * no-libgcrypt.c (gcry_strdup): New. 2005-02-24 Werner Koch * gpg-connect-agent.c: New. * Makefile.am: Add it. 2004-12-21 Werner Koch * gpgconf-comp.c (get_config_pathname) [DOSISH]: Detect absolute pathnames with a drive letter. 2004-12-15 Werner Koch * Makefile.am (bin_PROGRAMS) [W32]: Do not build watchgnupg. * gpgconf-comp.c (gpg_agent_runtime_change) [W32]: No way yet to send a signal. Disable. (change_options_file, change_options_program) [W32]: No link(2), so we disable it. (gc_component_change_options): Use rename instead of link. 2004-12-13 Werner Koch * gpgconf-comp.c : Fixed typo. 2004-11-24 Werner Koch * gpgconf-comp.c : Add --ignore-http-dp, --ignore-ldap-dp and --ignore-ocsp-service-url. 2004-11-23 Werner Koch * gpgconf-comp.c : Add the proxy options. : Add --prefer-system-daemon. 2004-11-11 Werner Koch * watchgnupg.c (main): Fixed test for read error. 2004-10-22 Werner Koch * Makefile.am (bin_SCRIPTS): Add gpgsm-gencert.sh * gpgsm-gencert.sh: Fixed copyright; its part of GnuPG thus FSF. 2004-10-01 Werner Koch * gpgconf-comp.c: Made all strings for --log-file read the same. 2004-10-01 Werner Koch * gpgconf-comp.c (my_dgettext): Also switch codeset and directory for the other used domains (i.e. dirmngr). * gpgconf.c (main): Fixed translation markers. 2004-09-30 Werner Koch * gpgconf.c (i18n_init): Always use LC_ALL. * Makefile.am: Adjusted for gettext 0.14. 2004-09-29 Werner Koch * gpgconf-comp.c: Made the entries fro GROUPs translatable. Include i18n.h. (my_dgettext): Hack to use the gnupg2 domain. 2004-08-09 Moritz Schulte * gpgsm-gencert.sh: New file. 2004-06-16 Werner Koch * rfc822parse.c (rfc822parse_get_field): Add arg VALUEOFF. 2004-06-14 Werner Koch * no-libgcrypt.c (gcry_realloc, gcry_xmalloc, gcry_xcalloc): New. * gpgconf-comp.c (retrieve_options_from_program) (retrieve_options_from_file, change_options_file) (change_options_program, gc_component_change_options): Replaced getline by read_line and test for allocation failure. 2004-05-21 Marcus Brinkmann * gpgconf-comp.c (gc_options_dirmngr): Remove CRL group, put its only option "max-replies" into LDAP group. (gc_component): Change description of dirmngr to "Directory Manager". * gpgconf-comp.c (gc_component_change_options): Move the per-process backup file into a standard location. 2004-05-03 Werner Koch * gpgconf-comp.c: Add --allow-mark-trusted for the gpg-agent. 2004-04-30 Werner Koch * gpgconf-comp.c: Added more runtime flags for the gpg-agent backend. 2004-04-29 Marcus Brinkmann * gpgconf-comp.c (change_options_program): Turn on utf8-strings in the gpgconf specific part of the config file for the GnuPG backend. 2004-04-28 Werner Koch * gpgconf-comp.c: Add --ocsp-signer for the dirmngr backend. 2004-04-20 Marcus Brinkmann * gpgconf-comp.c (gc_options_gpg_agent): Change type of ignore-cache-for-signing option to GC_ARG_TYPE_NONE. 2004-04-07 Werner Koch * gpgconf-comp.c (my_dgettext): Switch the codeset once to utf-8. Allow building with out NLS. 2004-03-23 Marcus Brinkmann * gpgconf-comp.c (gc_options_dirmngr): Set GC_OPT_FLAG_ARG_OPT for "LDAP Server". (change_options_file): Remove assertion that tests that this flag is not present. Handle an empty string in OPTION->new_value. * gpgconf.c (main): Remove obsolete warning. 2004-03-23 Werner Koch * gpgconf-comp.c (gc_options_gpg): New. (gc_component_t, gc_component): Add GC_BACKEND_GPG. (gc_options_dirmngr): Add allow-ocsp. 2004-03-23 Marcus Brinkmann * gpgconf-comp.c (gc_flag): Add missing flags. * gpgconf-comp.c: Include . (gc_backend): Add new member runtime_change. (gpg_agent_runtime_change): New function. (gc_component_change_options): New variable runtime. Initialize it. If an option is changed that has the GC_OPT_FLAG_RUNTIME bit set, also set the corresponding runtime variable. Finally, call the runtime_change callback of the backend if needed. 2004-03-16 Werner Koch * gpgconf-comp.c (gc_options_gpg_agent): Implemented. (gc_options_gpgsm, gc_options_scdaemon): Implemented. (gc_backend_t): Add GC_BACKEND_SCDAEMON. 2004-03-12 Marcus Brinkmann * gpgconf-comp.c (gc_component_change_options): Set the filenames of the option's backend, not of the component. Also use GC_BACKEND_NR, not GC_COMPONENT_NR. 2004-03-09 Werner Koch * gpgconf-comp.c [_riscos_]: Removed special code for RISC OS; we don't want to clutter our code with system dependent stuff. 2004-03-08 Marcus Brinkmann * gpgconf-comp.c (retrieve_options_from_file): Quote each string in the list, not only the first. 2004-02-26 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Do not print empty groups. * gpgconf-comp.c (option_check_validity): Check if option is active. (change_options_file): Implement. * gpgconf-comp.c (retrieve_options_from_program): Remove broken string handling. * gpgconf-comp.c (change_options_program): Support all types of options, including list types. * README.gpgconf: Fix description of arguments. * gpgconf-comp.c (option_check_validity): Rewritten to properly support optional arguments in lists. * README.gpgconf: Add info about optional arg and arg type 0. * gpgconf-comp.c (gc_component_change_options): Parse list of arg type 0 options. (option_check_validity): Add new argument NEW_VALUE_NR. Perform rigorous validity checks. (change_options_program): Disable an option also if we have a new value for it. 2004-02-25 Marcus Brinkmann * gpgconf-comp.c (gc_component_list_options): Correct output for lists of arg type none. (struct gc_option): Add new member new_flags. (option_check_validity): Check OPTION->new_flags beside OPTION->new_value. Add new argument FLAGS. (gc_component_change_options): Support default flag correctly. (change_options_program): Likewise. 2004-02-24 Marcus Brinkmann * README.gpgconf: Revert last change. Add new flags "default", "default desc" and "no arg desc". Add new field ARGDEF. Add new field FLAG to backend interface. * gpgconf-comp.c (struct gc_option): Make flags of type unsigned long. (gc_component_list_options): Adjust type for flags. Add default argument field. (retrieve_options_from_program): Use "1" as value for non-option arguments, not "Y". (gc_component_change_options): Read in flags from input. 2004-02-23 Marcus Brinkmann * README.gpgconf: Change meaning of type 0 options value if it is the empty string or "0". * gpgconf.h (struct): Add member runtime. * gpgconf.c: Add new option oRuntime. (main): Same here. * gpgconf-comp.c (hextobyte): New function. (percent_deescape): New function. (get_config_pathname): Percent deescape pathname if taken from option (default) value. Use default value only if it exists and is not empty. Use empty string otherwise. Don't include leading quote in pathname. (change_options_program): Percent deescape string before writing it out. * gpgconf-comp.c (gc_component_list_options): Do not skip groups on output. 2004-02-18 Werner Koch * gpgconf-comp.c: Added empty components for gpgsm and scdaemon. 2004-02-12 Werner Koch * watchgnupg.c (main): Implement option "--". (print_version): New. * Makefile.am: Include cmacros.am for common flags. 2004-02-03 Werner Koch * addgnupghome: Try to use getent, so that it also works for NIS setups. 2004-01-31 Marcus Brinkmann * gpgconf-comp.c: Some bug fixes, parse only defaults from the program, and read the current values from the configuration file directly. 2004-01-30 Marcus Brinkmann * gpgconf-comp.c (gc_error): New function, use it instead of error() throughout. * gpgconf-comp.c: Use xmalloc, libcommon's asctimestamp and gnupg_get_time, fix error() invocation and use getline() consistently. 2004-01-30 Werner Koch * addgnupghome: Also set the group of copied files. 2004-01-30 Werner Koch * Makefile.am (sbin_SCRIPTS): New, to install addgnupghome. (EXTRA_DIST): Added rfc822parse.c rfc822parse.h gpgparsemail.c which might be useful for debugging. 2004-01-29 Werner Koch * addgnupghome: New. 2004-01-29 Marcus Brinkmann * gpgconf-list.c: File removed. * README.gpgconf: New file. * gpgconf-comp.c: New file. * Makefile.am (gpgconf_SOURCES): Remove gpgconf-list.c, add gpgconf-comp.c. 2004-01-16 Werner Koch * watchgnupg.c (main): Need to use FD_ISSET for the client descriptors too; aiiih. Set the listening socket to non-blocking. 2004-01-10 Werner Koch * Makefile.am: Use GPG_ERROR_CFLAGS 2004-01-05 Werner Koch * Manifest: New. * gpgconf.c, gpgconf.h, gpgconf-list.c: New. A skeleton for now. * no-libgcrypt.c: New. * Makefile.am: Add above. 2003-12-23 Werner Koch * Makefile.am: New. * watchgnupg.c: New. Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/tools/Makefile.am b/tools/Makefile.am index 1d04964c0..e07d8e3e0 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,105 +1,121 @@ # Makefile.am - Tools directory # Copyright (C) 2003, 2007 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 # along with this program; if not, see . EXTRA_DIST = \ Manifest watchgnupg.c \ addgnupghome applygnupgdefaults gpgsm-gencert.sh \ lspgpot mail-signed-keys convert-from-106 sockprox.c \ ccidmon.c AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common include $(top_srcdir)/am/cmacros.am AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) $(LIBASSUAN_CFLAGS) sbin_SCRIPTS = addgnupghome applygnupgdefaults bin_SCRIPTS = gpgsm-gencert.sh if HAVE_USTAR # bin_SCRIPTS += gpg-zip noinst_SCRIPTS = gpg-zip endif if BUILD_SYMCRYPTRUN symcryptrun = symcryptrun else symcryptrun = endif -bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} +if BUILD_GPGTAR + gpgtar = gpgtar +else + gpgtar = +endif + + +bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} ${gpgtar} if !HAVE_W32_SYSTEM bin_PROGRAMS += watchgnupg gpgparsemail endif if !DISABLE_REGEX libexec_PROGRAMS = gpg-check-pattern endif noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert gpgsplit common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a gpgsplit_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \ $(ZLIBS) $(LIBINTL) $(LIBICONV) gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c # jnlib/common sucks in gpg-error, will they, nil they (some compilers # do not eliminate the supposed-to-be-unused-inline-functions). gpgconf_LDADD = $(common_libs) \ $(LIBINTL) $(GPG_ERROR_LIBS) $(LIBICONV) $(W32SOCKLIBS) gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h gpgparsemail_LDADD = symcryptrun_SOURCES = symcryptrun.c symcryptrun_LDADD = $(LIBUTIL_LIBS) $(common_libs) $(pwquery_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) \ $(LIBICONV) $(W32SOCKLIBS) watchgnupg_SOURCES = watchgnupg.c watchgnupg_LDADD = $(NETLIBS) gpg_connect_agent_SOURCES = gpg-connect-agent.c no-libgcrypt.c # FIXME: remove PTH_LIBS (why do we need them at all?) gpg_connect_agent_LDADD = ../common/libgpgrl.a $(common_libs) \ $(LIBASSUAN_LIBS) $(PTH_LIBS) $(GPG_ERROR_LIBS) \ $(LIBREADLINE) $(LIBINTL) $(NETLIBS) $(LIBICONV) gpgkey2ssh_SOURCES = gpgkey2ssh.c gpgkey2ssh_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) # common sucks in jnlib, via use of BUG() in an inline function, which # some compilers do not eliminate. gpgkey2ssh_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) if !DISABLE_REGEX gpg_check_pattern_SOURCES = gpg-check-pattern.c gpg_check_pattern_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) gpg_check_pattern_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \ $(LIBINTL) $(LIBICONV) $(W32SOCKLIBS) endif +gpgtar_SOURCES = \ + gpgtar.c gpgtar.h \ + gpgtar-create.c \ + gpgtar-extract.c \ + gpgtar-list.c \ + no-libgcrypt.c +gpgtar_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS) +gpgtar_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(W32SOCKLIBS) + # Make sure that all libs are build before we use them. This is # important for things like make -j2. $(PROGRAMS): $(common_libs) $(pwquery_libs) ../common/libgpgrl.a diff --git a/tools/gpgtar-create.c b/tools/gpgtar-create.c new file mode 100644 index 000000000..09587e455 --- /dev/null +++ b/tools/gpgtar-create.c @@ -0,0 +1,903 @@ +/* gpgtar-create.c - Create a TAR archive + * 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 + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_W32_SYSTEM +# define WIN32_LEAN_AND_MEAN +# include +# include /* for setmode() */ +#else /*!HAVE_W32_SYSTEM*/ +# include +# include +# include +#endif /*!HAVE_W32_SYSTEM*/ +#include + +#include "i18n.h" +#include "../common/sysutils.h" +#include "gpgtar.h" + +#ifndef HAVE_LSTAT +#define lstat(a,b) stat ((a), (b)) +#endif + + +/* Object to control the file scanning. */ +struct scanctrl_s; +typedef struct scanctrl_s *scanctrl_t; +struct scanctrl_s +{ + tar_header_t flist; + tar_header_t *flist_tail; + int nestlevel; +}; + + + + +/* Given a fresh header object HDR with only the name field set, try + to gather all available info. This is the W32 version. */ +#ifdef HAVE_W32_SYSTEM +static gpg_error_t +fillup_entry_w32 (tar_header_t hdr) +{ + char *p; + wchar_t *wfname; + WIN32_FILE_ATTRIBUTE_DATA fad; + DWORD attr; + + for (p=hdr->name; *p; p++) + if (*p == '/') + *p = '\\'; + wfname = utf8_to_wchar (hdr->name); + for (p=hdr->name; *p; p++) + if (*p == '\\') + *p = '/'; + if (!wfname) + { + log_error ("error utf8-ing `%s': %s\n", hdr->name, w32_strerror (-1)); + return gpg_error_from_syserror (); + } + if (!GetFileAttributesExW (wfname, GetFileExInfoStandard, &fad)) + { + log_error ("error stat-ing `%s': %s\n", hdr->name, w32_strerror (-1)); + xfree (wfname); + return gpg_error_from_syserror (); + } + xfree (wfname); + + attr = fad.dwFileAttributes; + + if ((attr & FILE_ATTRIBUTE_NORMAL)) + hdr->typeflag = TF_REGULAR; + else if ((attr & FILE_ATTRIBUTE_DIRECTORY)) + hdr->typeflag = TF_DIRECTORY; + else if ((attr & FILE_ATTRIBUTE_DEVICE)) + hdr->typeflag = TF_NOTSUP; + else if ((attr & (FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_TEMPORARY))) + hdr->typeflag = TF_NOTSUP; + else + hdr->typeflag = TF_REGULAR; + + /* Map some attributes to USTAR defined mode bits. */ + hdr->mode = 0640; /* User may read and write, group only read. */ + if ((attr & FILE_ATTRIBUTE_DIRECTORY)) + hdr->mode |= 0110; /* Dirs are user and group executable. */ + if ((attr & FILE_ATTRIBUTE_READONLY)) + hdr->mode &= ~0200; /* Clear the user write bit. */ + if ((attr & FILE_ATTRIBUTE_HIDDEN)) + hdr->mode &= ~0707; /* Clear all user and other bits. */ + if ((attr & FILE_ATTRIBUTE_SYSTEM)) + hdr->mode |= 0004; /* Make it readable by other. */ + + /* Only set the size for a regular file. */ + if (hdr->typeflag == TF_REGULAR) + hdr->size = (fad.nFileSizeHigh * (unsigned long long)(MAXDWORD+1) + + fad.nFileSizeLow); + + hdr->mtime = (((unsigned long long)fad.ftLastWriteTime.dwHighDateTime << 32) + | fad.ftLastWriteTime.dwLowDateTime); + if (!hdr->mtime) + hdr->mtime = (((unsigned long long)fad.ftCreationTime.dwHighDateTime << 32) + | fad.ftCreationTime.dwLowDateTime); + hdr->mtime -= 116444736000000000ULL; /* The filetime epoch is 1601-01-01. */ + hdr->mtime /= 10000000; /* Convert from 0.1us to seconds. */ + + return 0; +} +#endif /*HAVE_W32_SYSTEM*/ + + +/* Given a fresh header obje`name, &sbuf)) + { + err = gpg_error_from_syserror (); + log_error ("error stat-ing `%s': %s\n", hdr->name, gpg_strerror (err)); + return err; + } + + if (S_ISREG (sbuf.st_mode)) + hdr->typeflag = TF_REGULAR; + else if (S_ISDIR (sbuf.st_mode)) + hdr->typeflag = TF_DIRECTORY; + else if (S_ISCHR (sbuf.st_mode)) + hdr->typeflag = TF_CHARDEV; + else if (S_ISBLK (sbuf.st_mode)) + hdr->typeflag = TF_BLOCKDEV; + else if (S_ISFIFO (sbuf.st_mode)) + hdr->typeflag = TF_FIFO; + else if (S_ISLNK (sbuf.st_mode)) + hdr->typeflag = TF_SYMLINK; + else + hdr->typeflag = TF_NOTSUP; + + /* FIXME: Save DEV and INO? */ + + /* Set the USTAR defined mode bits using the system macros. */ + if (sbuf.st_mode & S_IRUSR) + hdr->mode |= 0400; + if (sbuf.st_mode & S_IWUSR) + hdr->mode |= 0200; + if (sbuf.st_mode & S_IXUSR) + hdr->mode |= 0100; + if (sbuf.st_mode & S_IRGRP) + hdr->mode |= 0040; + if (sbuf.st_mode & S_IWGRP) + hdr->mode |= 0020; + if (sbuf.st_mode & S_IXGRP) + hdr->mode |= 0010; + if (sbuf.st_mode & S_IROTH) + hdr->mode |= 0004; + if (sbuf.st_mode & S_IWOTH) + hdr->mode |= 0002; + if (sbuf.st_mode & S_IXOTH) + hdr->mode |= 0001; +#ifdef S_IXUID + if (sbuf.st_mode & S_IXUID) + hdr->mode |= 04000; +#endif +#ifdef S_IXGID + if (sbuf.st_mode & S_IXGID) + hdr->mode |= 02000; +#endif +#ifdef S_ISVTX + if (sbuf.st_mode & S_ISVTX) + hdr->mode |= 01000; +#endif + + hdr->nlink = sbuf.st_nlink; + + hdr->uid = sbuf.st_uid; + hdr->gid = sbuf.st_gid; + + /* Only set the size for a regular file. */ + if (hdr->typeflag == TF_REGULAR) + hdr->size = sbuf.st_size; + + hdr->mtime = sbuf.st_mtime; + + return 0; +} +#endif /*!HAVE_W32_SYSTEM*/ + + +/* Add a new entry. The name of a director entry is ENTRYNAME; if + that is NULL, DNAME is the name of the directory itself. Under + Windows ENTRYNAME shall have backslashes replaced by standard + slashes. */ +static gpg_error_t +add_entry (const char *dname, const char *entryname, scanctrl_t scanctrl) +{ + gpg_error_t err; + tar_header_t hdr; + char *p; + size_t dnamelen = strlen (dname); + + assert (dnamelen); + + hdr = xtrycalloc (1, sizeof *hdr + dnamelen + 1 + + (entryname? strlen (entryname) : 0) + 1); + if (!hdr) + return gpg_error_from_syserror (); + + p = stpcpy (hdr->name, dname); + if (entryname) + { + if (dname[dnamelen-1] != '/') + *p++ = '/'; + strcpy (p, entryname); + } + else + { + if (hdr->name[dnamelen-1] == '/') + hdr->name[dnamelen-1] = 0; + } +#ifdef HAVE_DOSISH_SYSTEM + err = fillup_entry_w32 (hdr); +#else + err = fillup_entry_posix (hdr); +#endif + if (err) + xfree (hdr); + else + { + if (opt.verbose) + gpgtar_print_header (hdr, es_stderr); + *scanctrl->flist_tail = hdr; + scanctrl->flist_tail = &hdr->next; + } + + return 0; +} + + +static gpg_error_t +scan_directory (const char *dname, scanctrl_t scanctrl) +{ + gpg_error_t err = 0; + +#ifdef HAVE_W32_SYSTEM + WIN32_FIND_DATAW fi; + HANDLE hd = INVALID_HANDLE_VALUE; + char *p; + + if (!*dname) + return 0; /* An empty directory name has no entries. */ + + { + char *fname; + wchar_t *wfname; + + fname = xtrymalloc (strlen (dname) + 2 + 2 + 1); + if (!fname) + { + err = gpg_error_from_syserror (); + goto leave; + } + if (!strcmp (dname, "/")) + strcpy (fname, "/*"); /* Trailing slash is not allowed. */ + else if (!strcmp (dname, ".")) + strcpy (fname, "*"); + else if (*dname && dname[strlen (dname)-1] == '/') + strcpy (stpcpy (fname, dname), "*"); + else if (*dname && dname[strlen (dname)-1] != '*') + strcpy (stpcpy (fname, dname), "/*"); + else + strcpy (fname, dname); + + for (p=fname; *p; p++) + if (*p == '/') + *p = '\\'; + wfname = utf8_to_wchar (fname); + xfree (fname); + if (!wfname) + { + err = gpg_error_from_syserror (); + log_error (_("error reading directory `%s': %s\n"), + dname, gpg_strerror (err)); + goto leave; + } + hd = FindFirstFileW (wfname, &fi); + if (hd == INVALID_HANDLE_VALUE) + { + err = gpg_error_from_syserror (); + log_error (_("error reading directory `%s': %s\n"), + dname, w32_strerror (-1)); + xfree (wfname); + goto leave; + } + xfree (wfname); + } + + do + { + char *fname = wchar_to_utf8 (fi.cFileName); + if (!fname) + { + err = gpg_error_from_syserror (); + log_error ("error utf8-ing filename: %s\n", w32_strerror (-1)); + break; + } + for (p=fname; *p; p++) + if (*p == '\\') + *p = '/'; + if (!strcmp (fname, "." ) || !strcmp (fname, "..")) + err = 0; /* Skip self and parent dir entry. */ + else if (!strncmp (dname, "./", 2) && dname[2]) + err = add_entry (dname+2, fname, scanctrl); + else + err = add_entry (dname, fname, scanctrl); + xfree (fname); + } + while (!err && FindNextFileW (hd, &fi)); + if (err) + ; + else if (GetLastError () == ERROR_NO_MORE_FILES) + err = 0; + else + { + err = gpg_error_from_syserror (); + log_error (_("error reading directory `%s': %s\n"), + dname, w32_strerror (-1)); + } + + leave: + if (hd != INVALID_HANDLE_VALUE) + FindClose (hd); + +#else /*!HAVE_W32_SYSTEM*/ + DIR *dir; + struct dirent *de; + + if (!*dname) + return 0; /* An empty directory name has no entries. */ + + dir = opendir (dname); + if (!dir) + { + err = gpg_error_from_syserror (); + log_error (_("error reading directory `%s': %s\n"), + dname, gpg_strerror (err)); + return err; + } + + while ((de = readdir (dir))) + { + if (!strcmp (de->d_name, "." ) || !strcmp (de->d_name, "..")) + continue; /* Skip self and parent dir entry. */ + + err = add_entry (dname, de->d_name, scanctrl); + if (err) + goto leave; + } + + leave: + closedir (dir); +#endif /*!HAVE_W32_SYSTEM*/ + return err; +} + + +static gpg_error_t +scan_recursive (const char *dname, scanctrl_t scanctrl) +{ + gpg_error_t err = 0; + tar_header_t hdr, *start_tail, *stop_tail; + + if (scanctrl->nestlevel > 200) + { + log_error ("directories too deeply nested\n"); + return gpg_error (GPG_ERR_RESOURCE_LIMIT); + } + scanctrl->nestlevel++; + + assert (scanctrl->flist_tail); + start_tail = scanctrl->flist_tail; + scan_directory (dname, scanctrl); + stop_tail = scanctrl->flist_tail; + hdr = *start_tail; + for (; hdr && hdr != *stop_tail; hdr = hdr->next) + if (hdr->typeflag == TF_DIRECTORY) + { + if (opt.verbose > 1) + log_info ("scanning directory `%s'\n", hdr->name); + scan_recursive (hdr->name, scanctrl); + } + + scanctrl->nestlevel--; + return err; +} + + +/* Returns true if PATTERN is acceptable. */ +static int +pattern_valid_p (const char *pattern) +{ + if (!*pattern) + return 0; + if (*pattern == '.' && pattern[1] == '.') + return 0; + if (*pattern == '/' || *pattern == DIRSEP_C) + return 0; /* Absolute filenames are not supported. */ +#ifdef HAVE_DRIVE_LETTERS + if (((*pattern >= 'a' && *pattern <= 'z') + || (*pattern >= 'A' && *pattern <= 'Z')) + && pattern[1] == ':') + return 0; /* Drive letter are not allowed either. */ +#endif /*HAVE_DRIVE_LETTERS*/ + + return 1; /* Okay. */ +} + + + +static void +store_xoctal (char *buffer, size_t length, unsigned long long value) +{ + char *p, *pend; + size_t n; + unsigned long long v; + + assert (length > 1); + + v = value; + n = length; + p = pend = buffer + length; + *--p = 0; /* Nul byte. */ + n--; + do + { + *--p = '0' + (v % 8); + v /= 8; + n--; + } + while (v && n); + if (!v) + { + /* Pad. */ + for ( ; n; n--) + *--p = '0'; + } + else /* Does not fit into the field. Store as binary number. */ + { + v = value; + n = length; + p = pend = buffer + length; + do + { + *--p = v; + v /= 256; + n--; + } + while (v && n); + if (!v) + { + /* Pad. */ + for ( ; n; n--) + *--p = 0; + if (*p & 0x80) + BUG (); + *p |= 0x80; /* Set binary flag. */ + } + else + BUG (); + } +} + + +static void +store_uname (char *buffer, size_t length, unsigned long uid) +{ + static int initialized; + static unsigned long lastuid; + static char lastuname[32]; + + if (!initialized || uid != lastuid) + { +#ifdef HAVE_W32_SYSTEM + mem2str (lastuname, uid? "user":"root", sizeof lastuname); +#else + struct passwd *pw = getpwuid (uid); + + lastuid = uid; + initialized = 1; + if (pw) + mem2str (lastuname, pw->pw_name, sizeof lastuname); + else + { + log_info ("failed to get name for uid %lu\n", uid); + *lastuname = 0; + } +#endif + } + mem2str (buffer, lastuname, length); +} + + +static void +store_gname (char *buffer, size_t length, unsigned long gid) +{ + static int initialized; + static unsigned long lastgid; + static char lastgname[32]; + + if (!initialized || gid != lastgid) + { +#ifdef HAVE_W32_SYSTEM + mem2str (lastgname, gid? "users":"root", sizeof lastgname); +#else + struct group *gr = getgrgid (gid); + + lastgid = gid; + initialized = 1; + if (gr) + mem2str (lastgname, gr->gr_name, sizeof lastgname); + else + { + log_info ("failed to get name for gid %lu\n", gid); + *lastgname = 0; + } +#endif + } + mem2str (buffer, lastgname, length); +} + + +static gpg_error_t +build_header (void *record, tar_header_t hdr) +{ + gpg_error_t err; + struct ustar_raw_header *raw = record; + size_t namelen, n; + unsigned long chksum; + unsigned char *p; + + memset (record, 0, RECORDSIZE); + + /* Store name and prefix. */ + namelen = strlen (hdr->name); + if (namelen < sizeof raw->name) + memcpy (raw->name, hdr->name, namelen); + else + { + n = (namelen < sizeof raw->prefix)? namelen : sizeof raw->prefix; + for (n--; n ; n--) + if (hdr->name[n] == '/') + break; + if (namelen - n < sizeof raw->name) + { + /* Note that the N is < sizeof prefix and that the + delimiting slash is not stored. */ + memcpy (raw->prefix, hdr->name, n); + memcpy (raw->name, hdr->name+n+1, namelen - n); + } + else + { + err = gpg_error (GPG_ERR_TOO_LARGE); + log_error ("error storing file `%s': %s\n", + hdr->name, gpg_strerror (err)); + return err; + } + } + + store_xoctal (raw->mode, sizeof raw->mode, hdr->mode); + store_xoctal (raw->uid, sizeof raw->uid, hdr->uid); + store_xoctal (raw->gid, sizeof raw->gid, hdr->gid); + store_xoctal (raw->size, sizeof raw->size, hdr->size); + store_xoctal (raw->mtime, sizeof raw->mtime, hdr->mtime); + + switch (hdr->typeflag) + { + case TF_REGULAR: raw->typeflag[0] = '0'; break; + case TF_HARDLINK: raw->typeflag[0] = '1'; break; + case TF_SYMLINK: raw->typeflag[0] = '2'; break; + case TF_CHARDEV: raw->typeflag[0] = '3'; break; + case TF_BLOCKDEV: raw->typeflag[0] = '4'; break; + case TF_DIRECTORY: raw->typeflag[0] = '5'; break; + case TF_FIFO: raw->typeflag[0] = '6'; break; + default: return gpg_error (GPG_ERR_NOT_SUPPORTED); + } + + memcpy (raw->magic, "ustar", 6); + raw->version[0] = '0'; + raw->version[1] = '0'; + + store_uname (raw->uname, sizeof raw->uname, hdr->uid); + store_gname (raw->gname, sizeof raw->gname, hdr->gid); + +#ifndef HAVE_W32_SYSTEM + if (hdr->typeflag == TF_SYMLINK) + { + int nread; + + nread = readlink (hdr->name, raw->linkname, sizeof raw->linkname -1); + if (nread < 0) + { + err = gpg_error_from_syserror (); + log_error ("error reading symlink `%s': %s\n", + hdr->name, gpg_strerror (err)); + return err; + } + raw->linkname[nread] = 0; + } +#endif /*HAVE_W32_SYSTEM*/ + + /* Compute the checksum. */ + memset (raw->checksum, ' ', sizeof raw->checksum); + chksum = 0; + p = record; + for (n=0; n < RECORDSIZE; n++) + chksum += *p++; + store_xoctal (raw->checksum, sizeof raw->checksum - 1, chksum); + raw->checksum[7] = ' '; + + return 0; +} + + +static gpg_error_t +write_file (estream_t stream, tar_header_t hdr) +{ + gpg_error_t err; + char record[RECORDSIZE]; + estream_t infp; + size_t nread, nbytes; + int any; + + err = build_header (record, hdr); + if (err) + { + if (gpg_err_code (err) == GPG_ERR_NOT_SUPPORTED) + { + log_info ("skipping unsupported file `%s'\n", hdr->name); + err = 0; + } + return err; + } + + if (hdr->typeflag == TF_REGULAR) + { + infp = es_fopen (hdr->name, "rb"); + if (!infp) + { + err = gpg_error_from_syserror (); + log_error ("can't open `%s': %s - skipped\n", + hdr->name, gpg_strerror (err)); + return err; + } + } + else + infp = NULL; + + err = write_record (stream, record); + if (err) + goto leave; + + if (hdr->typeflag == TF_REGULAR) + { + hdr->nrecords = (hdr->size + RECORDSIZE-1)/RECORDSIZE; + any = 0; + while (hdr->nrecords--) + { + nbytes = hdr->nrecords? RECORDSIZE : (hdr->size % RECORDSIZE); + if (!nbytes) + nbytes = RECORDSIZE; + nread = es_fread (record, 1, nbytes, infp); + if (nread != nbytes) + { + err = gpg_error_from_syserror (); + log_error ("error reading file `%s': %s%s\n", + hdr->name, gpg_strerror (err), + any? " (file shrunk?)":""); + goto leave; + } + any = 1; + err = write_record (stream, record); + if (err) + goto leave; + } + nread = es_fread (record, 1, 1, infp); + if (nread) + log_info ("note: file `%s' has grown\n", hdr->name); + } + + leave: + if (err) + es_fclose (infp); + else if ((err = es_fclose (infp))) + log_error ("error closing file `%s': %s\n", hdr->name, gpg_strerror (err)); + + return err; +} + + +static gpg_error_t +write_eof_mark (estream_t stream) +{ + gpg_error_t err; + char record[RECORDSIZE]; + + memset (record, 0, sizeof record); + err = write_record (stream, record); + if (!err) + err = write_record (stream, record); + return err; +} + + + +/* Create a new tarball using the names in the array INPATTERN. If + INPATTERN is NULL take the pattern as null terminated strings from + stdin. */ +void +gpgtar_create (char **inpattern) +{ + gpg_error_t err = 0; + struct scanctrl_s scanctrl_buffer; + scanctrl_t scanctrl = &scanctrl_buffer; + tar_header_t hdr, *start_tail; + estream_t outstream = NULL; + int eof_seen = 0; + +#ifdef HAVE_DOSISH_SYSTEM + if (!inpattern) + setmode (es_fileno (es_stdin), O_BINARY); +#endif + + memset (scanctrl, 0, sizeof *scanctrl); + scanctrl->flist_tail = &scanctrl->flist; + + while (!eof_seen) + { + char *pat, *p; + int skip_this = 0; + + if (inpattern) + { + const char *pattern = *inpattern; + + if (!pattern) + break; /* End of array. */ + inpattern++; + + if (!*pattern) + continue; + + pat = xtrystrdup (pattern); + } + else /* Read null delimited pattern from stdin. */ + { + int c; + char namebuf[4096]; + size_t n = 0; + + for (;;) + { + if ((c = es_getc (es_stdin)) == EOF) + { + if (es_ferror (es_stdin)) + { + err = gpg_error_from_syserror (); + log_error ("error reading `%s': %s\n", + "[stdin]", strerror (errno)); + goto leave; + } + /* Note: The Nul is a delimiter and not a terminator. */ + c = 0; + eof_seen = 1; + } + if (n >= sizeof namebuf - 1) + { + if (!skip_this) + { + skip_this = 1; + log_error ("error reading `%s': %s\n", + "[stdin]", "filename too long"); + } + } + else + namebuf[n++] = c; + if (!c) + { + namebuf[n] = 0; + break; + } + } + + if (skip_this || n < 2) + continue; + + pat = xtrystrdup (namebuf); + } + + if (!pat) + { + err = gpg_error_from_syserror (); + log_error ("memory allocation problem: %s\n", gpg_strerror (err)); + goto leave; + } + for (p=pat; *p; p++) + if (*p == '\\') + *p = '/'; + + if (opt.verbose > 1) + log_info ("scanning `%s'\n", pat); + + start_tail = scanctrl->flist_tail; + if (skip_this || !pattern_valid_p (pat)) + log_error ("skipping invalid name `%s'\n", pat); + else if (!add_entry (pat, NULL, scanctrl) + && *start_tail && ((*start_tail)->typeflag & TF_DIRECTORY)) + scan_recursive (pat, scanctrl); + + xfree (pat); + } + + if (opt.outfile) + { + if (!strcmp (opt.outfile, "-")) + outstream = es_stdout; + else + outstream = es_fopen (opt.outfile, "wb"); + if (!outstream) + { + err = gpg_error_from_syserror (); + log_error (_("can't create `%s': %s\n"), + opt.outfile, gpg_strerror (err)); + goto leave; + } + } + else + { + outstream = es_stdout; + } + +#ifdef HAVE_DOSISH_SYSTEM + if (outstream == es_stdout) + setmode (es_fileno (es_stdout), O_BINARY); +#endif + + for (hdr = scanctrl->flist; hdr; hdr = hdr->next) + { + err = write_file (outstream, hdr); + if (err) + goto leave; + } + err = write_eof_mark (outstream); + + leave: + if (!err) + { + if (outstream != es_stdout) + err = es_fclose (outstream); + else + err = es_fflush (outstream); + outstream = NULL; + } + if (err) + { + log_error ("creating tarball `%s' failed: %s\n", + es_fname_get (outstream), gpg_strerror (err)); + if (outstream && outstream != es_stdout) + es_fclose (outstream); + if (opt.outfile) + remove (opt.outfile); + } + scanctrl->flist_tail = NULL; + while ( (hdr = scanctrl->flist) ) + { + scanctrl->flist = hdr->next; + xfree (hdr); + } +} diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c new file mode 100644 index 000000000..736c7fc4b --- /dev/null +++ b/tools/gpgtar-extract.c @@ -0,0 +1,349 @@ +/* gpgtar-extract.c - Extract from a TAR archive + * 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 + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_W32_SYSTEM +# include /* for setmode() */ +#endif /*HAVE_W32_SYSTEM*/ + +#include "i18n.h" +#include "../common/sysutils.h" +#include "gpgtar.h" + +#ifndef GPG_ERR_LIMIT_REACHED +#define GPG_ERR_LIMIT_REACHED 183 +#endif + + +static gpg_error_t +extract_regular (estream_t stream, const char *dirname, + tar_header_t hdr) +{ + gpg_error_t err; + char record[RECORDSIZE]; + size_t n, nbytes, nwritten; + char *fname; + estream_t outfp = NULL; + + fname = strconcat (dirname, "/", hdr->name, NULL); + if (!fname) + { + err = gpg_error_from_syserror (); + log_error ("error creating filename: %s\n", gpg_strerror (err)); + goto leave; + } + else + err = 0; + + outfp = es_fopen (fname, "wb"); + if (!outfp) + { + err = gpg_error_from_syserror (); + log_error ("error creating `%s': %s\n", fname, gpg_strerror (err)); + goto leave; + } + + for (n=0; n < hdr->nrecords;) + { + err = read_record (stream, record); + if (err) + goto leave; + n++; + nbytes = (n < hdr->nrecords)? RECORDSIZE : (hdr->size % RECORDSIZE); + nwritten = es_fwrite (record, 1, nbytes, outfp); + if (nwritten != nbytes) + { + err = gpg_error_from_syserror (); + log_error ("error writing `%s': %s\n", fname, gpg_strerror (err)); + goto leave; + } + } + /* Fixme: Set permissions etc. */ + + leave: + if (!err && opt.verbose) + log_info ("extracted `%s'\n", fname); + es_fclose (outfp); + if (err && fname && outfp) + { + if (remove (fname)) + log_error ("error removing incomplete file `%s': %s\n", + fname, gpg_strerror (gpg_error_from_syserror ())); + } + xfree (fname); + return err; +} + + +static gpg_error_t +extract_directory (const char *dirname, tar_header_t hdr) +{ + gpg_error_t err; + char *fname; + size_t prefixlen; + + prefixlen = strlen (dirname) + 1; + fname = strconcat (dirname, "/", hdr->name, NULL); + if (!fname) + { + err = gpg_error_from_syserror (); + log_error ("error creating filename: %s\n", gpg_strerror (err)); + goto leave; + } + else + err = 0; + + if (fname[strlen (fname)-1] == '/') + fname[strlen (fname)-1] = 0; + + /* Note that we don't need to care about EEXIST because we always + extract into a new hierarchy. */ + if (gnupg_mkdir (fname, "-rwx------")) + { + err = gpg_error_from_syserror (); + if (gpg_err_code (err) == GPG_ERR_ENOENT) + { + /* Try to create the directory with parents but keep the + original error code in case of a failure. */ + char *p; + int rc = 0; + + for (p = fname+prefixlen; (p = strchr (p, '/')); p++) + { + *p = 0; + rc = gnupg_mkdir (fname, "-rwx------"); + *p = '/'; + if (rc) + break; + } + if (!rc && !gnupg_mkdir (fname, "-rwx------")) + err = 0; + } + if (err) + log_error ("error creating directory `%s': %s\n", + fname, gpg_strerror (err)); + } + + leave: + if (!err && opt.verbose) + log_info ("created `%s/'\n", fname); + xfree (fname); + return err; +} + + +static gpg_error_t +extract (estream_t stream, const char *dirname, tar_header_t hdr) +{ + gpg_error_t err; + size_t n; + + n = strlen (hdr->name); +#ifdef HAVE_DOSISH_SYSTEM + if (strchr (hdr->name, '\\')) + { + log_error ("filename `%s' contains a backslash - " + "can't extract on this system\n", hdr->name); + return gpg_error (GPG_ERR_INV_NAME); + } +#endif /*HAVE_DOSISH_SYSTEM*/ + + if (!n + || strstr (hdr->name, "//") + || strstr (hdr->name, "/../") + || !strncmp (hdr->name, "../", 3) + || (n >= 3 && !strcmp (hdr->name+n-3, "/.." ))) + { + log_error ("filename `%s' as suspicious parts - not extracting\n", + hdr->name); + return gpg_error (GPG_ERR_INV_NAME); + } + + if (hdr->typeflag == TF_REGULAR || hdr->typeflag == TF_UNKNOWN) + err = extract_regular (stream, dirname, hdr); + else if (hdr->typeflag == TF_DIRECTORY) + err = extract_directory (dirname, hdr); + else + { + char record[RECORDSIZE]; + + log_info ("unsupported file type %d for `%s' - skipped\n", + (int)hdr->typeflag, hdr->name); + for (err = 0, n=0; !err && n < hdr->nrecords; n++) + err = read_record (stream, record); + } + return err; +} + + +/* Create a new directory to be used for extracting the tarball. + Returns the name of the directory which must be freed by the + caller. In case of an error a diagnostic is printed and NULL + returned. */ +static char * +create_directory (const char *dirprefix) +{ + gpg_error_t err = 0; + char *prefix_buffer = NULL; + char *dirname = NULL; + size_t n; + int idx; + + /* Remove common suffixes. */ + n = strlen (dirprefix); + if (n > 4 && (!compare_filenames (dirprefix + n - 4, EXTSEP_S "gpg") + || !compare_filenames (dirprefix + n - 4, EXTSEP_S "pgp") + || !compare_filenames (dirprefix + n - 4, EXTSEP_S "asc") + || !compare_filenames (dirprefix + n - 4, EXTSEP_S "pem") + || !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7m") + || !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7e"))) + { + prefix_buffer = xtrystrdup (dirprefix); + if (!prefix_buffer) + { + err = gpg_error_from_syserror (); + goto leave; + } + prefix_buffer[n-4] = 0; + dirprefix = prefix_buffer; + } + + + + for (idx=1; idx < 5000; idx++) + { + xfree (dirname); + dirname = xtryasprintf ("%s_%d_", dirprefix, idx); + if (!dirname) + { + err = gpg_error_from_syserror (); + goto leave; + } + if (!gnupg_mkdir (dirname, "-rwx------")) + goto leave; /* Ready. */ + if (errno != EEXIST && errno != ENOTDIR) + { + err = gpg_error_from_syserror (); + goto leave; + } + } + err = gpg_error (GPG_ERR_LIMIT_REACHED); + + leave: + if (err) + { + log_error ("error creating an extract directory: %s\n", + gpg_strerror (err)); + xfree (dirname); + dirname = NULL; + } + xfree (prefix_buffer); + return dirname; +} + + + +void +gpgtar_extract (const char *filename) +{ + gpg_error_t err; + estream_t stream; + tar_header_t header = NULL; + const char *dirprefix = NULL; + char *dirname = NULL; + + if (filename) + { + if (!strcmp (filename, "-")) + stream = es_stdin; + else + stream = es_fopen (filename, "rb"); + if (!stream) + { + err = gpg_error_from_syserror (); + log_error ("error opening `%s': %s\n", filename, gpg_strerror (err)); + return; + } + } + else + stream = es_stdin; + +#ifdef HAVE_DOSISH_SYSTEM + if (stream == es_stdin) + setmode (es_fileno (es_stdin), O_BINARY); +#endif + + if (filename && stream != es_stdin) + { + dirprefix = strrchr (filename, '/'); + if (dirprefix) + dirprefix++; + else + dirprefix = filename; + } + else if (opt.filename) + { + dirprefix = strrchr (opt.filename, '/'); + if (dirprefix) + dirprefix++; + else + dirprefix = opt.filename; + } + + if (!dirprefix || !*dirprefix) + dirprefix = "GPGARCH"; + + dirname = create_directory (dirprefix); + if (!dirname) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + + if (opt.verbose) + log_info ("extracting to `%s/'\n", dirname); + + for (;;) + { + header = gpgtar_read_header (stream); + if (!header) + goto leave; + + if (extract (stream, dirname, header)) + goto leave; + xfree (header); + header = NULL; + } + + + leave: + xfree (header); + xfree (dirname); + if (stream != es_stdin) + es_fclose (stream); + return; +} diff --git a/tools/gpgtar-list.c b/tools/gpgtar-list.c new file mode 100644 index 000000000..0df7a26dc --- /dev/null +++ b/tools/gpgtar-list.c @@ -0,0 +1,332 @@ +/* gpgtar-list.c - List a TAR archive + * 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 + * along with this program; if not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "i18n.h" +#include "gpgtar.h" + + + +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 + { + log_error ("%s: invalid octal number encountered - assuming 0\n", + filename); + value = 0; + break; + } + } + } + return value; +} + + +static tar_header_t +parse_header (const void *record, const char *filename) +{ + const struct ustar_raw_header *raw = record; + size_t n, namelen, prefixlen; + tar_header_t header; + int use_prefix; + + use_prefix = (!memcmp (raw->magic, "ustar", 5) + && (raw->magic[5] == ' ' || !raw->magic[5])); + + + for (namelen=0; namelen < sizeof raw->name && raw->name[namelen]; namelen++) + ; + if (namelen == sizeof raw->name) + log_info ("%s: warning: name not terminated by a nul byte\n", filename); + for (n=namelen+1; n < sizeof raw->name; n++) + if (raw->name[n]) + { + log_info ("%s: warning: garbage after name\n", filename); + break; + } + + + if (use_prefix && raw->prefix[0]) + { + for (prefixlen=0; (prefixlen < sizeof raw->prefix + && raw->prefix[prefixlen]); prefixlen++) + ; + if (prefixlen == sizeof raw->prefix) + log_info ("%s: warning: prefix not terminated by a nul byte\n", + filename); + for (n=prefixlen+1; n < sizeof raw->prefix; n++) + if (raw->prefix[n]) + { + log_info ("%s: warning: garbage after prefix\n", filename); + 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; + + 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; + default: header->typeflag = TF_UNKNOWN; break; + } + + + /* Compute the number of data records following this header. */ + if (header->typeflag == TF_REGULAR || header->typeflag == TF_UNKNOWN) + header->nrecords = (header->size + RECORDSIZE-1)/RECORDSIZE; + else + header->nrecords = 0; + + + return header; +} + + + +/* Read the next block, assming it is a tar header. Returns a header + object on success or NULL one error. In case of an error an error + message has been printed. */ +static tar_header_t +read_header (estream_t stream) +{ + gpg_error_t err; + char record[RECORDSIZE]; + int i; + + err = read_record (stream, record); + if (err) + return NULL; + + 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) + return NULL; + + 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. */ + return NULL; + } + } + + return parse_header (record, es_fname_get (stream)); +} + + +/* Skip the data records according to HEADER. Prints an error message + on error and return -1. */ +static int +skip_data (estream_t stream, tar_header_t header) +{ + char record[RECORDSIZE]; + unsigned long long n; + + for (n=0; n < header->nrecords; n++) + { + if (read_record (stream, record)) + return -1; + } + + return 0; +} + + + +static void +print_header (tar_header_t header, estream_t out) +{ + unsigned long mask; + char modestr[10+1]; + int i; + + *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; + 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; + + es_fprintf (out, "%s %lu %lu/%lu %12llu %s %s\n", + modestr, header->nlink, header->uid, header->gid, header->size, + isotimestamp (header->mtime), header->name); +} + + + +/* List the tarball FILENAME or, if FILENAME is NULL, the tarball read + from stdin. */ +void +gpgtar_list (const char *filename) +{ + gpg_error_t err; + estream_t stream; + tar_header_t header; + + if (filename) + { + if (!strcmp (filename, "-")) + stream = es_stdin; + else + stream = es_fopen (filename, "rb"); + if (!stream) + { + err = gpg_error_from_syserror (); + log_error ("error opening `%s': %s\n", filename, gpg_strerror (err)); + return; + } + } + else + stream = es_stdin; + +#ifdef HAVE_DOSISH_SYSTEM + if (stream == es_stdin) + setmode (es_fileno (es_stdin), O_BINARY); +#endif + + for (;;) + { + header = read_header (stream); + if (!header) + goto leave; + + print_header (header, es_stdout); + + if (skip_data (stream, header)) + goto leave; + xfree (header); + header = NULL; + } + + + leave: + xfree (header); + if (stream != es_stdin) + es_fclose (stream); + return; +} + +tar_header_t +gpgtar_read_header (estream_t stream) +{ + /*FIXME: Change to return an error code. */ + return read_header (stream); +} + +void +gpgtar_print_header (tar_header_t header, estream_t out) +{ + if (header && out) + print_header (header, out); +} diff --git a/tools/gpgtar.c b/tools/gpgtar.c new file mode 100644 index 000000000..f88964fec --- /dev/null +++ b/tools/gpgtar.c @@ -0,0 +1,538 @@ +/* gpgtar.c - A simple TAR implementation mainly useful for Windows. + * 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 + * along with this program; if not, see . + */ + +/* GnuPG comes with a shell script gpg-zip which creates archive files + in the same format as PGP Zip, which is actually a USTAR format. + That is fine and works nicely on all Unices but for Windows we + don't have a compatible shell and the supply of tar programs is + limited. Given that we need just a few tar option and it is an + open question how many Unix concepts are to be mapped to Windows, + we might as well write our own little tar customized for use with + gpg. So here we go. */ + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_STAT +# include +#endif + +#include "util.h" +#include "i18n.h" +#include "sysutils.h" +#include "../common/openpgpdefs.h" + +#include "gpgtar.h" + + +/* Constants to identify the commands and options. */ +enum cmd_and_opt_values + { + aNull = 0, + aEncrypt = 'e', + aDecrypt = 'd', + aSign = 's', + aList = 't', + + oSymmetric = 'c', + oRecipient = 'r', + oUser = 'u', + oOutput = 'o', + oQuiet = 'q', + oVerbose = 'v', + oFilesFrom = 'T', + oNoVerbose = 500, + + aSignEncrypt, + oSkipCrypto, + oOpenPGP, + oCMS, + oSetFilename, + oNull + }; + + +/* The list of commands and options. */ +static ARGPARSE_OPTS opts[] = { + ARGPARSE_group (300, N_("@Commands:\n ")), + + ARGPARSE_c (aEncrypt, "encrypt", N_("create an archive")), + ARGPARSE_c (aDecrypt, "decrypt", N_("extract an archive")), + ARGPARSE_c (aSign, "sign", N_("create a signed archive")), + ARGPARSE_c (aList, "list-archive", N_("list an archive")), + + ARGPARSE_group (301, N_("@\nOptions:\n ")), + + ARGPARSE_s_n (oSymmetric, "symmetric", N_("use symmetric encryption")), + ARGPARSE_s_s (oRecipient, "recipient", N_("|USER-ID|encrypt for USER-ID")), + ARGPARSE_s_s (oUser, "local-user", + N_("|USER-ID|use USER-ID to sign or decrypt")), + ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")), + ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")), + ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")), + ARGPARSE_s_n (oSkipCrypto, "skip-crypto", N_("skip the crypto processing")), + ARGPARSE_s_s (oSetFilename, "set-filename", "@"), + ARGPARSE_s_s (oFilesFrom, "files-from", + N_("|FILE|get names to create from FILE")), + ARGPARSE_s_n (oNull, "null", N_("-T reads null-terminated names")), + ARGPARSE_s_n (oOpenPGP, "openpgp", "@"), + ARGPARSE_s_n (oCMS, "cms", "@"), + + ARGPARSE_end () +}; + + + +static void tar_and_encrypt (char **inpattern); +static void decrypt_and_untar (const char *fname); +static void decrypt_and_list (const char *fname); + + + + +/* Print usage information and and provide strings for help. */ +static const char * +my_strusage( int level ) +{ + const char *p; + + switch (level) + { + case 11: p = "gpgtar (GnuPG)"; + break; + case 13: p = VERSION; break; + case 17: p = PRINTABLE_OS_NAME; break; + case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; + + case 1: + case 40: + p = _("Usage: gpgtar [options] [files] [directories] (-h for help)"); + break; + case 41: + p = _("Syntax: gpgtar [options] [files] [directories]\n" + "Encrypt or sign files into an archive\n"); + break; + + default: p = NULL; break; + } + return p; +} + + +static void +set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd) +{ + enum cmd_and_opt_values cmd = *ret_cmd; + + if (!cmd || cmd == new_cmd) + cmd = new_cmd; + else if (cmd == aSign && new_cmd == aEncrypt) + cmd = aSignEncrypt; + else if (cmd == aEncrypt && new_cmd == aSign) + cmd = aSignEncrypt; + else + { + log_error (_("conflicting commands\n")); + exit (2); + } + + *ret_cmd = cmd; +} + + + +/* gpgtar main. */ +int +main (int argc, char **argv) +{ + ARGPARSE_ARGS pargs; + const char *fname; + int no_more_options = 0; + enum cmd_and_opt_values cmd = 0; + int skip_crypto = 0; + const char *files_from = NULL; + int null_names = 0; + + assert (sizeof (struct ustar_raw_header) == 512); + + gnupg_reopen_std ("gpgtar"); + set_strusage (my_strusage); + log_set_prefix ("gpgtar", 1); + + /* Make sure that our subsystems are ready. */ + i18n_init(); + init_common_subsystems (); + + /* Parse the command line. */ + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags = ARGPARSE_FLAG_KEEP; + while (!no_more_options && optfile_parse (NULL, NULL, NULL, &pargs, opts)) + { + switch (pargs.r_opt) + { + case oOutput: opt.outfile = pargs.r.ret_str; break; + case oSetFilename: opt.filename = pargs.r.ret_str; break; + case oQuiet: opt.quiet = 1; break; + case oVerbose: opt.verbose++; break; + case oNoVerbose: opt.verbose = 0; break; + case oFilesFrom: files_from = pargs.r.ret_str; break; + case oNull: null_names = 1; break; + + case aList: + case aDecrypt: + case aEncrypt: + case aSign: + set_cmd (&cmd, pargs.r_opt); + break; + + case oSymmetric: + set_cmd (&cmd, aEncrypt); + opt.symmetric = 1; + break; + + case oSkipCrypto: + skip_crypto = 1; + break; + + case oOpenPGP: /* Dummy option for now. */ break; + case oCMS: /* Dummy option for now. */ break; + + default: pargs.err = 2; break; + } + } + + if ((files_from && !null_names) || (!files_from && null_names)) + log_error ("--files-from and --null may only be used in conjunction\n"); + if (files_from && strcmp (files_from, "-")) + log_error ("--files-from only supports argument \"-\"\n"); + + if (log_get_errorcount (0)) + exit (2); + + switch (cmd) + { + case aList: + if (argc > 1) + usage (1); + fname = argc ? *argv : NULL; + if (opt.filename) + log_info ("note: ignoring option --set-filename\n"); + if (files_from) + log_info ("note: ignoring option --files-from\n"); + if (skip_crypto) + gpgtar_list (fname); + else + decrypt_and_list (fname); + break; + + case aEncrypt: + if ((!argc && !null_names) + || (argc && null_names)) + usage (1); + if (opt.filename) + log_info ("note: ignoring option --set-filename\n"); + if (skip_crypto) + gpgtar_create (null_names? NULL :argv); + else + tar_and_encrypt (null_names? NULL : argv); + break; + + case aDecrypt: + if (argc != 1) + usage (1); + if (opt.outfile) + log_info ("note: ignoring option --output\n"); + if (files_from) + log_info ("note: ignoring option --files-from\n"); + fname = argc ? *argv : NULL; + if (skip_crypto) + gpgtar_extract (fname); + else + decrypt_and_untar (fname); + break; + + default: + log_error (_("invalid command (there is no implicit command)\n")); + break; + } + + return log_get_errorcount (0)? 1:0; +} + + +/* Read the next record from STREAM. RECORD is a buffer provided by + the caller and must be at leadt of size RECORDSIZE. The function + return 0 on success and and error code on failure; a diagnostic + printed as well. Note that there is no need for an EOF indicator + because a tarball has an explicit EOF record. */ +gpg_error_t +read_record (estream_t stream, void *record) +{ + gpg_error_t err; + size_t nread; + + nread = es_fread (record, 1, RECORDSIZE, stream); + if (nread != RECORDSIZE) + { + err = gpg_error_from_syserror (); + if (es_ferror (stream)) + log_error ("error reading `%s': %s\n", + es_fname_get (stream), gpg_strerror (err)); + else + log_error ("error reading `%s': premature EOF " + "(size of last record: %zu)\n", + es_fname_get (stream), nread); + } + else + err = 0; + + return err; +} + + +/* Write the RECORD of size RECORDSIZE to STREAM. FILENAME is the + name of the file used for diagnostics. */ +gpg_error_t +write_record (estream_t stream, const void *record) +{ + gpg_error_t err; + size_t nwritten; + + nwritten = es_fwrite (record, 1, RECORDSIZE, stream); + if (nwritten != RECORDSIZE) + { + err = gpg_error_from_syserror (); + log_error ("error writing `%s': %s\n", + es_fname_get (stream), gpg_strerror (err)); + } + else + err = 0; + + return err; +} + + +/* Return true if FP is an unarmored OpenPGP message. Note that this + fucntion reads a few bytes from FP but pushes them back. */ +#if 0 +static int +openpgp_message_p (estream_t fp) +{ + int ctb; + + ctb = es_getc (fp); + if (ctb != EOF) + { + if (es_ungetc (ctb, fp)) + log_fatal ("error ungetting first byte: %s\n", + gpg_strerror (gpg_error_from_syserror ())); + + if ((ctb & 0x80)) + { + switch ((ctb & 0x40) ? (ctb & 0x3f) : ((ctb>>2)&0xf)) + { + case PKT_MARKER: + case PKT_SYMKEY_ENC: + case PKT_ONEPASS_SIG: + case PKT_PUBKEY_ENC: + case PKT_SIGNATURE: + case PKT_COMMENT: + case PKT_OLD_COMMENT: + case PKT_PLAINTEXT: + case PKT_COMPRESSED: + case PKT_ENCRYPTED: + return 1; /* Yes, this seems to be an OpenPGP message. */ + default: + break; + } + } + } + return 0; +} +#endif + + + + +static void +tar_and_encrypt (char **inpattern) +{ + (void)inpattern; + log_error ("tar_and_encrypt has not yet been implemented\n"); +} + + + +static void +decrypt_and_untar (const char *fname) +{ + (void)fname; + log_error ("decrypt_and_untar has not yet been implemented\n"); +} + + + +static void +decrypt_and_list (const char *fname) +{ + (void)fname; + log_error ("decrypt_and_list has not yet been implemented\n"); +} + + + + +/* A wrapper around mkdir which takes a string for the mode argument. + This makes it easier to handle the mode argument which is not + defined on all systems. The format of the modestring is + + "-rwxrwxrwx" + + '-' is a don't care or not set. 'r', 'w', 'x' are read allowed, + write allowed, execution allowed with the first group for the user, + the second for the group and the third for all others. If the + string is shorter than above the missing mode characters are meant + to be not set. */ +int +gnupg_mkdir (const char *name, const char *modestr) +{ +#ifdef HAVE_W32CE_SYSTEM + wchar_t *wname; + (void)modestr; + + wname = utf8_to_wchar (name); + if (!wname) + return -1; + if (!CreateDirectoryW (wname, NULL)) + { + xfree (wname); + return -1; /* ERRNO is automagically provided by gpg-error.h. */ + } + xfree (wname); + return 0; +#elif MKDIR_TAKES_ONE_ARG + (void)modestr; + /* Note: In the case of W32 we better use CreateDirectory and try to + set appropriate permissions. However using mkdir is easier + because this sets ERRNO. */ + return mkdir (name); +#else + mode_t mode = 0; + + if (modestr && *modestr) + { + modestr++; + if (*modestr && *modestr++ == 'r') + mode |= S_IRUSR; + if (*modestr && *modestr++ == 'w') + mode |= S_IWUSR; + if (*modestr && *modestr++ == 'x') + mode |= S_IXUSR; + if (*modestr && *modestr++ == 'r') + mode |= S_IRGRP; + if (*modestr && *modestr++ == 'w') + mode |= S_IWGRP; + if (*modestr && *modestr++ == 'x') + mode |= S_IXGRP; + if (*modestr && *modestr++ == 'r') + mode |= S_IROTH; + if (*modestr && *modestr++ == 'w') + mode |= S_IWOTH; + if (*modestr && *modestr++ == 'x') + mode |= S_IXOTH; + } + return mkdir (name, mode); +#endif +} + +#ifdef HAVE_W32_SYSTEM +/* Return a malloced string encoded in UTF-8 from the wide char input + string STRING. Caller must free this value. Returns NULL and sets + ERRNO on failure. Calling this function with STRING set to NULL is + not defined. */ +char * +wchar_to_utf8 (const wchar_t *string) +{ + int n; + char *result; + + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL); + if (n < 0) + { + errno = EINVAL; + return NULL; + } + + result = xtrymalloc (n+1); + if (!result) + return NULL; + + n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL); + if (n < 0) + { + xfree (result); + errno = EINVAL; + result = NULL; + } + return result; +} + + +/* Return a malloced wide char string from an UTF-8 encoded input + string STRING. Caller must free this value. Returns NULL and sets + ERRNO on failure. Calling this function with STRING set to NULL is + not defined. */ +wchar_t * +utf8_to_wchar (const char *string) +{ + int n; + size_t nbytes; + wchar_t *result; + + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0); + if (n < 0) + { + errno = EINVAL; + return NULL; + } + + nbytes = (size_t)(n+1) * sizeof(*result); + if (nbytes / sizeof(*result) != (n+1)) + { + errno = ENOMEM; + return NULL; + } + result = xtrymalloc (nbytes); + if (!result) + return NULL; + + n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n); + if (n < 0) + { + free (result); + errno = EINVAL; + result = NULL; + } + return result; +} +#endif /*HAVE_W32_SYSTEM*/ diff --git a/tools/gpgtar.h b/tools/gpgtar.h new file mode 100644 index 000000000..579089469 --- /dev/null +++ b/tools/gpgtar.h @@ -0,0 +1,132 @@ +/* gpgtar.h - Global definitions for gpgtar + * 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 + * along with this program; if not, see . + */ + +#ifndef GPGTAR_H +#define GPGTAR_H + +#include "../common/util.h" +#include "../common/estream.h" + +/* We keep all global options in the structure OPT. */ +struct +{ + int verbose; + int quiet; + const char *outfile; + int symmetric; + const char *filename; +} opt; + + +/* The size of a tar record. All IO is done in chunks of this size. + Note that we don't care about blocking because this version of tar + is not expected to be used directly on a tape drive in fact it is + used in a pipeline with GPG and thus any blocking would be + useless. */ +#define RECORDSIZE 512 + + +/* Description of the USTAR header format. */ +struct ustar_raw_header +{ + char name[100]; + char mode[8]; + char uid[8]; + char gid[8]; + char size[12]; + char mtime[12]; + char checksum[8]; + char typeflag[1]; + char linkname[100]; + char magic[6]; + char version[2]; + char uname[32]; + char gname[32]; + char devmajor[8]; + char devminor[8]; + char prefix[155]; + char pad[12]; +}; + + +/* Filetypes as defined by USTAR. */ +typedef enum + { + TF_REGULAR, + TF_HARDLINK, + TF_SYMLINK, + TF_CHARDEV, + TF_BLOCKDEV, + TF_DIRECTORY, + TF_FIFO, + TF_RESERVED, + TF_UNKNOWN, /* Needs to be treated as regular file. */ + TF_NOTSUP /* Not supported (used with --create). */ + } typeflag_t; + + +/* The internal represenation of a TAR header. */ +struct tar_header_s; +typedef struct tar_header_s *tar_header_t; +struct tar_header_s +{ + tar_header_t next; /* Used to build a linked list iof entries. */ + + unsigned long mode; /* The file mode. */ + unsigned long nlink; /* Number of hard links. */ + unsigned long uid; /* The user id of the file. */ + unsigned long gid; /* The group id of the file. */ + unsigned long long size; /* The size of the file. */ + unsigned long long mtime; /* Modification time since Epoch. Note + that we don't use time_t here but a + type which is more likely to be larger + that 32 bit and thus allows to track + times beyond 2106. */ + typeflag_t typeflag; /* The type of the file. */ + + + unsigned long long nrecords; /* Number of data records. */ + + char name[1]; /* Filename (dynamically extended). */ +}; + + +/*-- gpgtar.c --*/ +gpg_error_t read_record (estream_t stream, void *record); +gpg_error_t write_record (estream_t stream, const void *record); + +int gnupg_mkdir (const char *name, const char *modestr); +#ifdef HAVE_W32_SYSTEM +char *wchar_to_utf8 (const wchar_t *string); +wchar_t *utf8_to_wchar (const char *string); +#endif + +/*-- gpgtar-create.c --*/ +void gpgtar_create (char **inpattern); + +/*-- gpgtar-extract.c --*/ +void gpgtar_extract (const char *filename); + +/*-- gpgtar-list.c --*/ +void gpgtar_list (const char *filename); +tar_header_t gpgtar_read_header (estream_t stream); +void gpgtar_print_header (tar_header_t header, estream_t out); + + +#endif /*GPGTAR_H*/