mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* 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:
parent
6e522257a9
commit
cad9562436
34 changed files with 166 additions and 486 deletions
|
@ -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>
|
||||
|
||||
* dynload.h: s/__inline__/inline/.
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
|
||||
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 = \
|
||||
util.h i18n.h \
|
||||
|
@ -49,18 +51,6 @@ libcommon_a_SOURCES = \
|
|||
estream.c estream.h
|
||||
|
||||
|
||||
libcommon_a_LIBADD = @LIBOBJS@
|
||||
|
||||
libsimple_pwquery_a_SOURCES = \
|
||||
simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h
|
||||
|
||||
libsimple_pwquery_a_LIBADD = @LIBOBJS@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -25,7 +25,13 @@
|
|||
#include <time.h> /* We need time_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)
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/*-- replacement functions from funcname.c --*/
|
||||
#if !HAVE_VASPRINTF
|
||||
#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
|
||||
|
||||
/*-- Simple replacement functions. */
|
||||
#ifndef HAVE_TTYNAME
|
||||
char *ttyname (int fd);
|
||||
#endif
|
||||
#ifndef HAVE_MKDTEMP
|
||||
char *mkdtemp (char *template);
|
||||
#endif
|
||||
/* Systems without ttyname (W32) will merely return NULL. */
|
||||
static inline char *
|
||||
ttyname (int fd)
|
||||
{
|
||||
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 digitp(p) (*(p) >= '0' && *(p) <= '9')
|
||||
#define hexdigitp(a) (digitp (a) \
|
||||
|
|
|
@ -43,7 +43,7 @@ xasprintf (const char *fmt, ...)
|
|||
return p;
|
||||
}
|
||||
|
||||
/* Same as above bit return NULL on memory failure. */
|
||||
/* Same as above but return NULL on memory failure. */
|
||||
char *
|
||||
xtryasprintf (const char *fmt, ...)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue