* 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.

* gpg-agent.c: Include setenv.h.

* 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.

* mkdtemp.c: Removed.
* exec.c: Include mkdtemp.h

* keybox-file.c (ftello) [!HAVE_FSEEKO]: New replacement
function.  Copied from ../common/ftello.c.
* keybox-update.c (fseeko) [!HAVE_FSEEKO]: New replacement
function.  Copied from ../common/iobuf.c.

* scdaemon.c: Include mkdtemp.h.

* misc.c: Include setenv.h.

* symcryptrun.c: Include mkdtemp.h.
This commit is contained in:
Werner Koch 2005-06-01 15:46:01 +00:00
parent 6e522257a9
commit cad9562436
34 changed files with 166 additions and 486 deletions

View File

@ -1,3 +1,15 @@
2005-06-01 Werner Koch <wk@g10code.com>
* 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 <wk@g10code.com> 2005-05-15 Werner Koch <wk@g10code.com>
* configure.ac: Remove option --disable-threads; require the use * configure.ac: Remove option --disable-threads; require the use

View File

@ -19,7 +19,7 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4 -I gl/m4
AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = dist-bzip2
EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS
@ -59,7 +59,7 @@ else
tests = tests tests = tests
endif endif
SUBDIRS = m4 intl jnlib common ${kbx} \ SUBDIRS = m4 intl gl jnlib common ${kbx} \
${gpg} ${sm} ${agent} ${scd} tools po doc ${tests} ${gpg} ${sm} ${agent} ${scd} tools po doc ${tests}
dist-hook: dist-hook:

View File

@ -1,3 +1,7 @@
2005-06-01 Werner Koch <wk@g10code.com>
* gpg-agent.c: Include setenv.h.
2005-05-31 Werner Koch <wk@g10code.com> 2005-05-31 Werner Koch <wk@g10code.com>
* agent.h (out_of_core): s/__inline__/inine. Noted by Ray Link. * agent.h (out_of_core): s/__inline__/inine. Noted by Ray Link.

View File

@ -21,7 +21,7 @@
bin_PROGRAMS = gpg-agent bin_PROGRAMS = gpg-agent
libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase
AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/intl AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
include $(top_srcdir)/am/cmacros.am include $(top_srcdir)/am/cmacros.am
@ -44,7 +44,7 @@ gpg_agent_SOURCES = \
learncard.c learncard.c
gpg_agent_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \ gpg_agent_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a ../common/libcommon.a \
$(LIBGCRYPT_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \ $(LIBGCRYPT_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \
-lgpg-error @LIBINTL@ -lgpg-error @LIBINTL@

View File

@ -48,6 +48,7 @@
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
#include "../jnlib/w32-afunix.h" #include "../jnlib/w32-afunix.h"
#endif #endif
#include "setenv.h"
enum cmd_and_opt_values enum cmd_and_opt_values

View File

@ -152,8 +152,8 @@ EOF
fi fi
echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..." echo "Running aclocal -I m4 -I gl/m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
$ACLOCAL -I m4 $ACLOCAL_FLAGS $ACLOCAL -I m4 -I gl/m4 $ACLOCAL_FLAGS
echo "Running autoheader..." echo "Running autoheader..."
$AUTOHEADER $AUTOHEADER
echo "Running automake --gnu ..." echo "Running automake --gnu ..."

View File

@ -1,3 +1,13 @@
2005-06-01 Werner Koch <wk@g10code.com>
* 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 <wk@g10code.com> 2005-05-31 Werner Koch <wk@g10code.com>
* dynload.h: s/__inline__/inline/. * dynload.h: s/__inline__/inline/.

View File

@ -21,7 +21,9 @@
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a noinst_LIBRARIES = libcommon.a libsimple-pwquery.a
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(PTH_CFLAGS) AM_CPPFLAGS = -I$(top_srcdir)/gl
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(PTH_CFLAGS)
libcommon_a_SOURCES = \ libcommon_a_SOURCES = \
util.h i18n.h \ util.h i18n.h \
@ -49,18 +51,6 @@ libcommon_a_SOURCES = \
estream.c estream.h estream.c estream.h
libcommon_a_LIBADD = @LIBOBJS@
libsimple_pwquery_a_SOURCES = \ libsimple_pwquery_a_SOURCES = \
simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h
libsimple_pwquery_a_LIBADD = @LIBOBJS@

View File

@ -1,41 +0,0 @@
/* fseeko.c - libc replacement function
* Copyright (C) 2001 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h> /* Defines off_t under W32. */
int
fseeko (FILE *stream, off_t off, int whence)
{
return fseek (stream, off, whence);
}

View File

@ -1,46 +0,0 @@
/* ftello.c - libc replacement function
* Copyright (C) 2001 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h> /* Defines off_t under W32. */
off_t
ftello (FILE *stream)
{
long int off;
off = ftell (stream);
if (off == -1)
return (off_t)-1;
return off;
}

View File

@ -1,97 +0,0 @@
/* mkdtemp.c - libc replacement function
* Copyright (C) 2001 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* This is a replacement function for mkdtemp in case the platform
we're building on (like mine!) doesn't have it. */
#include <config.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <gcrypt.h>
#ifdef MKDIR_TAKES_ONE_ARG
# undef mkdir
# define mkdir(a,b) mkdir(a)
#endif
char *
mkdtemp (char *template)
{
int attempts,idx,count=0;
unsigned char *ch;
idx=strlen(template);
/* Walk backwards to count all the Xes */
while(idx>0 && template[idx-1]=='X')
{
count++;
idx--;
}
if(count==0)
{
errno=EINVAL;
return NULL;
}
ch=&template[idx];
/* Try 4 times to make the temp directory */
for(attempts=0;attempts<4;attempts++)
{
int remaining=count;
char *marker=ch;
unsigned char *randombits;
idx=0;
randombits = gcry_xmalloc (4*remaining);
gcry_create_nonce (randombits, 4*remaining);
while(remaining>1)
{
sprintf(marker,"%02X",randombits[idx++]);
marker+=2;
remaining-=2;
}
/* Any leftover Xes? get_random_bits rounds up to full bytes,
so this is safe. */
if(remaining>0)
sprintf(marker,"%X",randombits[idx]&0xF);
gcry_free (randombits);
if(mkdir(template,0700)==0)
break;
}
if(attempts==4)
return NULL; /* keeps the errno from mkdir, whatever it is */
return template;
}

View File

@ -1,31 +0,0 @@
/* putc_unlocked.c - Replacement for putc_unlocked.
* Copyright (C) 2002 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
int
putc_unlocked (int c, FILE *stream)
{
return putc (c, stream);
}

View File

@ -1,76 +0,0 @@
/* strsep.c - Replacement for strsep().
* Copyright (C) 1992, 1993, 1996, 1997, 1998, 1999,
* 2004 Free Software Foundation, Inc.
*
* This file is part of the GNU C Library.
*
* The GNU C Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* The GNU C Library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the GNU C Library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*/
/* Code taken from glibc-2.3.2/sysdeps/generic/strsep.c and slightly
modified for use with GnuPG. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
char *
strsep (char **stringp, const char *delim)
{
char *begin, *end;
begin = *stringp;
if (begin == NULL)
return NULL;
/* A frequent case is when the delimiter string contains only one
character. Here we don't need to call the expensive `strpbrk'
function and instead work using `strchr'. */
if (delim[0] == '\0' || delim[1] == '\0')
{
char ch = delim[0];
if (ch == '\0')
end = NULL;
else
{
if (*begin == ch)
end = begin;
else if (*begin == '\0')
end = NULL;
else
end = strchr (begin + 1, ch);
}
}
else
/* Find the end of the token. */
end = strpbrk (begin, delim);
if (end)
{
/* Terminate the token and set *STRINGP past NUL character. */
*end++ = '\0';
*stringp = end;
}
else
/* No more delimiters; this is the last token. */
*stringp = NULL;
return begin;
}

View File

@ -1,32 +0,0 @@
/* ttyname.c - Replacement for ttyname.
* Copyright (C) 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 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* This one is a simple dummy and suitable for Dosish systems. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
char *
ttyname (int fd)
{
return NULL;
}

View File

@ -25,7 +25,13 @@
#include <time.h> /* We need time_t. */ #include <time.h> /* We need time_t. */
#include <gpg-error.h> /* we need gpg-error_t. */ #include <gpg-error.h> /* we need gpg-error_t. */
/* to pass hash functions to libksba we need to cast it */ /* Common GNUlib includes (-I ../gl/). */
#include "strpbrk.h"
#include "strsep.h"
#include "vasprintf.h"
/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) #define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
/* get all the stuff from jnlib */ /* get all the stuff from jnlib */
@ -152,24 +158,26 @@ char *make_printable_string (const byte *p, size_t n, int delim);
int is_file_compressed (const char *s, int *ret_rc); int is_file_compressed (const char *s, int *ret_rc);
/*-- replacement functions from funcname.c --*/
#if !HAVE_VASPRINTF /*-- Simple replacement functions. */
#include <stdarg.h>
int vasprintf (char **result, const char *format, va_list args);
int asprintf (char **result, const char *format, ...) JNLIB_GCC_A_PRINTF(2,3);
#endif
#ifndef HAVE_STRSEP
char *strsep (char **stringp, const char *delim);
#endif
#ifndef HAVE_TTYNAME #ifndef HAVE_TTYNAME
char *ttyname (int fd); /* Systems without ttyname (W32) will merely return NULL. */
#endif static inline char *
#ifndef HAVE_MKDTEMP ttyname (int fd)
char *mkdtemp (char *template); {
#endif return NULL
};
#endif /* !HAVE_TTYNAME */
#ifndef HAVE_ISASCII
static inline int
isascii (int c)
{
return (((c) & ~0x7f) == 0);
}
#endif /* !HAVE_ISASCII */
/*-- some macros to replace ctype ones and avoid locale problems --*/ /*-- Macros to replace ctype ones to avoid locale problems. --*/
#define spacep(p) (*(p) == ' ' || *(p) == '\t') #define spacep(p) (*(p) == ' ' || *(p) == '\t')
#define digitp(p) (*(p) >= '0' && *(p) <= '9') #define digitp(p) (*(p) >= '0' && *(p) <= '9')
#define hexdigitp(a) (digitp (a) \ #define hexdigitp(a) (digitp (a) \

View File

@ -43,7 +43,7 @@ xasprintf (const char *fmt, ...)
return p; return p;
} }
/* Same as above bit return NULL on memory failure. */ /* Same as above but return NULL on memory failure. */
char * char *
xtryasprintf (const char *fmt, ...) xtryasprintf (const char *fmt, ...)
{ {

View File

@ -337,6 +337,7 @@ AC_PROG_RANLIB
AC_CHECK_TOOL(AR, ar, :) AC_CHECK_TOOL(AR, ar, :)
AC_PATH_PROG(PERL,"perl") AC_PATH_PROG(PERL,"perl")
AC_ISC_POSIX AC_ISC_POSIX
gl_EARLY
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
AC_CHECK_PROG(DOCBOOK_TO_MAN, docbook-to-man, yes, no) AC_CHECK_PROG(DOCBOOK_TO_MAN, docbook-to-man, yes, no)
AM_CONDITIONAL(HAVE_DOCBOOK_TO_MAN, test "$ac_cv_prog_DOCBOOK_TO_MAN" = yes) AM_CONDITIONAL(HAVE_DOCBOOK_TO_MAN, test "$ac_cv_prog_DOCBOOK_TO_MAN" = yes)
@ -794,23 +795,21 @@ AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times gmtime_r)
AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime) AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale) AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo) AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo)
AC_CHECK_FUNCS(fseeko ftello ttyname isascii)
AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>]) AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
# gnulib checks
gl_SOURCE_BASE(gl)
gl_M4_BASE(gl/m4)
gl_MODULES(setenv strsep mkdtemp vasprintf xsize)
gl_INIT
# These are needed by libjnlib - fixme: we should have macros for them # These are needed by libjnlib - fixme: we should have macros for them
AC_CHECK_FUNCS(memicmp stpcpy strlwr strtoul memmove stricmp strtol) AC_CHECK_FUNCS(memicmp stpcpy strlwr strtoul memmove stricmp strtol)
AC_CHECK_FUNCS(getrusage setrlimit stat setlocale) AC_CHECK_FUNCS(getrusage setrlimit stat setlocale)
AC_CHECK_FUNCS(flockfile funlockfile fopencookie funopen) AC_CHECK_FUNCS(flockfile funlockfile fopencookie funopen)
AC_REPLACE_FUNCS(vasprintf)
AC_REPLACE_FUNCS(mkdtemp)
AC_REPLACE_FUNCS(fseeko ftello)
AC_REPLACE_FUNCS(isascii)
AC_REPLACE_FUNCS(putc_unlocked)
AC_REPLACE_FUNCS(strsep)
AC_REPLACE_FUNCS(ttyname)
# #
# check for gethrtime and run a testprogram to see whether # check for gethrtime and run a testprogram to see whether
@ -989,7 +988,7 @@ fi
if test "$GCC" = yes; then if test "$GCC" = yes; then
if test "$USE_MAINTAINER_MODE" = "yes"; then if test "$USE_MAINTAINER_MODE" = "yes"; then
CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
CFLAGS="$CFLAGS -Wformat-nonliteral" CFLAGS="$CFLAGS -Wno-format-y2k -Wformat-security"
else else
CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wall"
fi fi
@ -1126,6 +1125,7 @@ AC_CONFIG_FILES([ m4/Makefile
Makefile Makefile
po/Makefile.in po/Makefile.in
intl/Makefile intl/Makefile
gl/Makefile
jnlib/Makefile jnlib/Makefile
common/Makefile common/Makefile
kbx/Makefile kbx/Makefile

View File

@ -1,3 +1,8 @@
2005-06-01 Werner Koch <wk@g10code.com>
* mkdtemp.c: Removed.
* exec.c: Include mkdtemp.h
2004-12-21 Werner Koch <wk@g10code.com> 2004-12-21 Werner Koch <wk@g10code.com>
* gpgv.c, g10.c (main): Use default_hoemdir (). * gpgv.c, g10.c (main): Use default_hoemdir ().

View File

@ -21,14 +21,14 @@
EXTRA_DIST = options.skel EXTRA_DIST = options.skel
AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/include \ AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common \
-I$(top_srcdir)/intl -I$(top_srcdir)/include -I$(top_srcdir)/intl
include $(top_srcdir)/am/cmacros.am include $(top_srcdir)/am/cmacros.am
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) AM_CFLAGS = $(LIBGCRYPT_CFLAGS)
needed_libs = ../common/libcommon.a ../jnlib/libjnlib.a needed_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a
bin_PROGRAMS = gpg2 gpgv2 bin_PROGRAMS = gpg2 gpgv2

View File

@ -39,6 +39,7 @@
#include "i18n.h" #include "i18n.h"
#include "iobuf.h" #include "iobuf.h"
#include "util.h" #include "util.h"
#include "mkdtemp.h"
#include "exec.h" #include "exec.h"
#ifdef NO_EXEC #ifdef NO_EXEC
@ -55,10 +56,6 @@ int set_exec_path(const char *path,int method) { return GPG_ERR_GENERAL; }
#else /* ! NO_EXEC */ #else /* ! NO_EXEC */
#ifndef HAVE_MKDTEMP
char *mkdtemp(char *template);
#endif
#if defined (_WIN32) #if defined (_WIN32)
/* This is a nicer system() for windows that waits for programs to /* This is a nicer system() for windows that waits for programs to
return before returning control to the caller. I hate helpful return before returning control to the caller. I hate helpful

View File

@ -1,98 +0,0 @@
/* mkdtemp.c - libc replacement function
* Copyright (C) 2001 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* This is a replacement function for mkdtemp in case the platform
we're building on (like mine!) doesn't have it. */
#include <config.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include "types.h"
#include "cipher.h"
#ifdef MKDIR_TAKES_ONE_ARG
# undef mkdir
# define mkdir(a,b) mkdir(a)
#endif
char *mkdtemp(char *template)
{
unsigned int attempts,idx,count=0;
byte *ch;
idx=strlen(template);
/* Walk backwards to count all the Xes */
while(idx>0 && template[idx-1]=='X')
{
count++;
idx--;
}
if(count==0)
{
errno=EINVAL;
return NULL;
}
ch=&template[idx];
/* Try 4 times to make the temp directory */
for(attempts=0;attempts<4;attempts++)
{
unsigned int remaining=count;
char *marker=ch;
byte *randombits;
idx=0;
/* Using really random bits is probably overkill here. The
worst thing that can happen with a directory name collision
is that the function will return an error. */
randombits=get_random_bits(4*remaining,0,0);
while(remaining>1)
{
sprintf(marker,"%02X",randombits[idx++]);
marker+=2;
remaining-=2;
}
/* Any leftover Xes? get_random_bits rounds up to full bytes,
so this is safe. */
if(remaining>0)
sprintf(marker,"%X",randombits[idx]&0xF);
xfree (randombits);
if(mkdir(template,0700)==0)
break;
}
if(attempts==4)
return NULL; /* keeps the errno from mkdir, whatever it is */
return template;
}

View File

@ -1,3 +1,10 @@
2005-06-01 Werner Koch <wk@g10code.com>
* keybox-file.c (ftello) [!HAVE_FSEEKO]: New replacement
function. Copied from ../common/ftello.c.
* keybox-update.c (fseeko) [!HAVE_FSEEKO]: New replacement
function. Copied from ../common/iobuf.c.
2004-12-18 Werner Koch <wk@g10code.com> 2004-12-18 Werner Koch <wk@g10code.com>
* keybox-defs.h (map_assuan_err): Define in terms of * keybox-defs.h (map_assuan_err): Define in terms of

View File

@ -23,7 +23,7 @@ localedir = $(datadir)/locale
INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
EXTRA_DIST = mkerrors EXTRA_DIST = mkerrors
AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/intl \ AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl \
$(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS)
noinst_LIBRARIES = libkeybox.a noinst_LIBRARIES = libkeybox.a
@ -45,6 +45,7 @@ libkeybox_a_SOURCES = $(common_sources)
# Note that libcommon is only required to resolve the LIBOBJS. # Note that libcommon is only required to resolve the LIBOBJS.
kbxutil_SOURCES = kbxutil.c $(common_sources) kbxutil_SOURCES = kbxutil.c $(common_sources)
kbxutil_LDADD = ../jnlib/libjnlib.a $(KSBA_LIBS) $(LIBGCRYPT_LIBS) \ kbxutil_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a \
$(KSBA_LIBS) $(LIBGCRYPT_LIBS) \
-lgpg-error $(LIBINTL) ../common/libcommon.a -lgpg-error $(LIBINTL) ../common/libcommon.a

View File

@ -27,6 +27,22 @@
#include "keybox-defs.h" #include "keybox-defs.h"
#if !defined(HAVE_FTELLO) && !defined(ftello)
static off_t
ftello (FILE *stream)
{
long int off;
off = ftell (stream);
if (off == -1)
return (off_t)-1;
return off;
}
#endif /* !defined(HAVE_FTELLO) && !defined(ftello) */
/* Read a block at the current postion and return it in r_blob. /* Read a block at the current postion and return it in r_blob.
r_blob may be NULL to simply skip the current block */ r_blob may be NULL to simply skip the current block */
int int

View File

@ -31,6 +31,38 @@
#define EXTSEP_S "." #define EXTSEP_S "."
#if !defined(HAVE_FSEEKO) && !defined(fseeko)
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long) ((unsigned long) -1 >> 1))
#endif
#ifndef LONG_MIN
# define LONG_MIN (-1 - LONG_MAX)
#endif
/****************
* A substitute for fseeko, for hosts that don't have it.
*/
static int
fseeko (FILE * stream, off_t newpos, int whence)
{
while (newpos != (long) newpos)
{
long pos = newpos < 0 ? LONG_MIN : LONG_MAX;
if (fseek (stream, pos, whence) != 0)
return -1;
newpos -= pos;
whence = SEEK_CUR;
}
return fseek (stream, (long) newpos, whence);
}
#endif /* !defined(HAVE_FSEEKO) && !defined(fseeko) */
static int static int
create_tmp_file (const char *template, create_tmp_file (const char *template,
char **r_bakfname, char **r_tmpfname, FILE **r_fp) char **r_bakfname, char **r_tmpfname, FILE **r_fp)

View File

@ -1,3 +1,7 @@
2005-06-01 Werner Koch <wk@g10code.com>
* scdaemon.c: Include mkdtemp.h.
2005-05-31 Werner Koch <wk@g10code.com> 2005-05-31 Werner Koch <wk@g10code.com>
* tlv.c [GNUPG_MAJOR_VERSION==1]: Define constants instead of * tlv.c [GNUPG_MAJOR_VERSION==1]: Define constants instead of

View File

@ -23,7 +23,7 @@ if ! HAVE_W32_SYSTEM
pkglib_PROGRAMS = pcsc-wrapper pkglib_PROGRAMS = pcsc-wrapper
endif endif
AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/common AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
include $(top_srcdir)/am/cmacros.am include $(top_srcdir)/am/cmacros.am
@ -43,7 +43,7 @@ scdaemon_SOURCES = \
app.c app-common.h app-help.c $(card_apps) app.c app-common.h app-help.c $(card_apps)
scdaemon_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \ scdaemon_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a ../common/libcommon.a \
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \
$(LIBUSB_LIBS) -lgpg-error $(LIBINTL) $(DL_LIBS) $(LIBUSB_LIBS) -lgpg-error $(LIBINTL) $(DL_LIBS)

View File

@ -51,7 +51,7 @@
#include "../jnlib/w32-afunix.h" #include "../jnlib/w32-afunix.h"
#endif #endif
#include "ccid-driver.h" #include "ccid-driver.h"
#include "mkdtemp.h"
enum cmd_and_opt_values enum cmd_and_opt_values
{ aNull = 0, { aNull = 0,

View File

@ -1,3 +1,7 @@
2005-06-01 Werner Koch <wk@g10code.com>
* misc.c: Include setenv.h.
2005-04-21 Werner Koch <wk@g10code.com> 2005-04-21 Werner Koch <wk@g10code.com>
* gpgsm.c: New options --{enable,disable}-trusted-cert-crl-check. * gpgsm.c: New options --{enable,disable}-trusted-cert-crl-check.

View File

@ -24,7 +24,7 @@ bin_PROGRAMS = gpgsm
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(KSBA_CFLAGS) \ AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(KSBA_CFLAGS) \
$(PTH_CFLAGS) $(PTH_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/common -I$(top_srcdir)/intl AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
include $(top_srcdir)/am/cmacros.am include $(top_srcdir)/am/cmacros.am
@ -52,7 +52,7 @@ gpgsm_SOURCES = \
certreqgen.c certreqgen.c
gpgsm_LDADD = ../jnlib/libjnlib.a ../kbx/libkeybox.a \ gpgsm_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a ../kbx/libkeybox.a \
../common/libcommon.a \ ../common/libcommon.a \
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) -lgpg-error \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) -lgpg-error \
$(LIBINTL) $(PTH_LIBS) $(LIBINTL) $(PTH_LIBS)

View File

@ -31,6 +31,7 @@
#include "gpgsm.h" #include "gpgsm.h"
#include "i18n.h" #include "i18n.h"
#include "setenv.h"
/* Setup the environment so that the pinentry is able to get all /* Setup the environment so that the pinentry is able to get all
required information. This is used prior to an exec of the required information. This is used prior to an exec of the

View File

@ -1,3 +1,7 @@
2005-06-01 Werner Koch <wk@g10code.com>
* symcryptrun.c: Include mkdtemp.h.
2005-05-31 Werner Koch <wk@g10code.com> 2005-05-31 Werner Koch <wk@g10code.com>
* watchgnupg.c: Make sure that PF_LCOAL and AF_LOCAL are defines. * watchgnupg.c: Make sure that PF_LCOAL and AF_LOCAL are defines.

View File

@ -21,7 +21,7 @@ EXTRA_DIST = Manifest watchgnupg.c \
rfc822parse.c rfc822parse.h gpgparsemail.c \ rfc822parse.c rfc822parse.h gpgparsemail.c \
addgnupghome gpgsm-gencert.sh addgnupghome gpgsm-gencert.sh
AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/common AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
include $(top_srcdir)/am/cmacros.am include $(top_srcdir)/am/cmacros.am
AM_CFLAGS = $(GPG_ERROR_CFLAGS) $(LIBASSUAN_CFLAGS) AM_CFLAGS = $(GPG_ERROR_CFLAGS) $(LIBASSUAN_CFLAGS)
@ -43,19 +43,23 @@ endif
gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c
gpgconf_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a @LIBINTL@ gpgconf_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a \
../common/libcommon.a @LIBINTL@
symcryptrun_SOURCES = symcryptrun.c symcryptrun_SOURCES = symcryptrun.c
symcryptrun_LDADD = $(LIBUTIL_LIBS) ../jnlib/libjnlib.a ../common/libcommon.a \ symcryptrun_LDADD = $(LIBUTIL_LIBS) ../gl/libgnu.a ../jnlib/libjnlib.a \
../common/libcommon.a \
../common/libsimple-pwquery.a $(LIBGCRYPT_LIBS) \ ../common/libsimple-pwquery.a $(LIBGCRYPT_LIBS) \
$(GPG_ERROR_LIBS) $(LIBINTL) $(GPG_ERROR_LIBS) $(LIBINTL)
watchgnupg_SOURCES = watchgnupg.c watchgnupg_SOURCES = watchgnupg.c
gpg_connect_agent_SOURCES = gpg-connect-agent.c no-libgcrypt.c gpg_connect_agent_SOURCES = gpg-connect-agent.c no-libgcrypt.c
gpg_connect_agent_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \ gpg_connect_agent_LDADD = ../gl/libgnu.a ../jnlib/libjnlib.a \
../common/libcommon.a \
$(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL)
gpgkey2ssh_SOURCES = gpgkey2ssh.c gpgkey2ssh_SOURCES = gpgkey2ssh.c
gpgkey2ssh_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) gpgkey2ssh_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS)
gpgkey2ssh_LDADD = ../common/libcommon.a $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) gpgkey2ssh_LDADD = ../gl/libgnu.a ../common/libcommon.a \
$(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS)

View File

@ -82,6 +82,7 @@
#define JNLIB_NEED_LOG_LOGV #define JNLIB_NEED_LOG_LOGV
#include "i18n.h" #include "i18n.h"
#include "../common/util.h" #include "../common/util.h"
#include "mkdtemp.h"
/* FIXME: Bah. For spwq_secure_free. */ /* FIXME: Bah. For spwq_secure_free. */
#define SIMPLE_PWQUERY_IMPLEMENTATION 1 #define SIMPLE_PWQUERY_IMPLEMENTATION 1