Added better autoconf handling of gpgpme. Fixes so libfko will compile under FreeBSD (7.0 release anyway).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@68 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
parent
62487d72fd
commit
41127cd7ed
102
configure.ac
102
configure.ac
@ -31,7 +31,7 @@ AC_PROG_LIBTOOL
|
||||
# Checks for header files.
|
||||
#
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([ctype.h netinet/in.h stdlib.h string.h strings.h sys/time.h termios.h unistd.h])
|
||||
AC_CHECK_HEADERS([ctype.h endian.h netinet/in.h stdlib.h string.h strings.h sys/endian.h sys/socket.h sys/time.h termios.h unistd.h])
|
||||
|
||||
# Type checks.
|
||||
#
|
||||
@ -55,8 +55,97 @@ AC_FUNC_REALLOC
|
||||
AC_FUNC_STAT
|
||||
AC_CHECK_FUNCS([bzero gettimeofday memmove memset socket strchr strcspn strdup strncasecmp strndup strrchr strspn])
|
||||
|
||||
# Check for gpgme
|
||||
#AM_PATH_GPGME
|
||||
dnl For finding and checking gpgme (taken from the gpgme.m4 file that
|
||||
dnl comes with gpgme)
|
||||
dnl
|
||||
AC_DEFUN([_AM_PATH_GPGME_CONFIG],
|
||||
[ AC_ARG_WITH(gpgme-prefix,
|
||||
AC_HELP_STRING([--with-gpgme-prefix=PFX],
|
||||
[prefix where GPGME is installed (optional)]),
|
||||
gpgme_config_prefix="$withval", gpgme_config_prefix="")
|
||||
if test "x$gpgme_config_prefix" != x ; then
|
||||
GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
|
||||
fi
|
||||
AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
|
||||
|
||||
if test "$GPGME_CONFIG" != "no" ; then
|
||||
gpgme_version=`$GPGME_CONFIG --version`
|
||||
fi
|
||||
gpgme_version_major=`echo $gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
|
||||
gpgme_version_minor=`echo $gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
|
||||
gpgme_version_micro=`echo $gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
|
||||
])
|
||||
|
||||
dnl AM_PATH_GPGME([MINIMUM-VERSION,
|
||||
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
|
||||
dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
|
||||
dnl
|
||||
AC_DEFUN([AM_PATH_GPGME],
|
||||
[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
|
||||
tmp=ifelse([$1], ,1:0.4.2,$1)
|
||||
if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
|
||||
req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
|
||||
min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
|
||||
else
|
||||
req_gpgme_api=0
|
||||
min_gpgme_version="$tmp"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
|
||||
ok=no
|
||||
if test "$GPGME_CONFIG" != "no" ; then
|
||||
req_major=`echo $min_gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
|
||||
req_minor=`echo $min_gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
|
||||
req_micro=`echo $min_gpgme_version | \
|
||||
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
|
||||
if test "$gpgme_version_major" -gt "$req_major"; then
|
||||
ok=yes
|
||||
else
|
||||
if test "$gpgme_version_major" -eq "$req_major"; then
|
||||
if test "$gpgme_version_minor" -gt "$req_minor"; then
|
||||
ok=yes
|
||||
else
|
||||
if test "$gpgme_version_minor" -eq "$req_minor"; then
|
||||
if test "$gpgme_version_micro" -ge "$req_micro"; then
|
||||
ok=yes
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test $ok = yes; then
|
||||
# If we have a recent GPGME, we should also check that the
|
||||
# API is compatible.
|
||||
if test "$req_gpgme_api" -gt 0 ; then
|
||||
tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
|
||||
if test "$tmp" -gt 0 ; then
|
||||
if test "$req_gpgme_api" -ne "$tmp" ; then
|
||||
ok=no
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test $ok = yes; then
|
||||
GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
|
||||
GPGME_LIBS=`$GPGME_CONFIG --libs`
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
GPGME_CFLAGS=""
|
||||
GPGME_LIBS=""
|
||||
AC_MSG_RESULT(no)
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(GPGME_CFLAGS)
|
||||
AC_SUBST(GPGME_LIBS)
|
||||
])
|
||||
|
||||
AC_ARG_WITH([gpgme],
|
||||
[AS_HELP_STRING([--with-gpgme],
|
||||
[support for gpg encryption using libgpgme @<:@default=check@:>@])],
|
||||
@ -65,15 +154,16 @@ AC_ARG_WITH([gpgme],
|
||||
|
||||
have_gpgme=yes
|
||||
AS_IF([test "x$with_gpgme" != xno],
|
||||
[AC_CHECK_LIB([gpgme], [gpgme_check_version],
|
||||
[],
|
||||
[AM_PATH_GPGME([],
|
||||
[AC_DEFINE([HAVE_LIBGPGME], [1], [Define if you have libgpgme])],
|
||||
[if test "x$with_gpgme" != xcheck; then
|
||||
AC_MSG_FAILURE(
|
||||
[--with-gpgme was given, but test for gpgme failed])
|
||||
else
|
||||
have_gpgme=no
|
||||
fi
|
||||
])], [have_gpgme=no])
|
||||
], [have_gpgme=no])], [have_gpgme=no])
|
||||
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
fko/Makefile
|
||||
|
||||
@ -10,5 +10,9 @@ libfko_source_files = \
|
||||
strlcpy.c fko_state.h fko_context.h gpgme_funcs.c gpgme_funcs.h
|
||||
|
||||
libfko_la_SOURCES = $(libfko_source_files)
|
||||
libfko_la_LDFLAGS = -version-info 0:1:0
|
||||
libfko_la_LDFLAGS = -version-info 0:1:0 $(GPGME_LIBS)
|
||||
|
||||
AM_CPPFLAGS = $(GPGME_CFLAGS)
|
||||
|
||||
include_HEADERS = fko.h
|
||||
|
||||
|
||||
@ -24,14 +24,8 @@
|
||||
#ifndef DIGEST_H
|
||||
#define DIGEST_H 1
|
||||
|
||||
#include <endian.h>
|
||||
#include "fko_common.h"
|
||||
|
||||
/* This should be fine for most linux systems (hopefully).
|
||||
* TODO: We should look into the portability of this. --DSS
|
||||
*/
|
||||
#define BYTEORDER __BYTE_ORDER
|
||||
|
||||
#include "md5.h"
|
||||
#include "sha.h"
|
||||
|
||||
|
||||
@ -51,6 +51,16 @@
|
||||
#define isdigit(c) (c >= 48 && c <= 57)
|
||||
#endif
|
||||
|
||||
/* Work out endianess (sp?)
|
||||
*/
|
||||
#if HAVE_ENDIAN_H /* Should cover most Linux systems */
|
||||
#include <endian.h>
|
||||
#define BYTEORDER __BYTE_ORDER
|
||||
#elif HAVE_SYS_ENDIAN_H /* FreeBSD has a sys/endian.h */
|
||||
#include <sys/endian.h>
|
||||
#define BYTEORDER _BYTE_ORDER
|
||||
#endif
|
||||
|
||||
/* Convenient macros for wrapping sections in 'extern "C" {' constructs.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -131,12 +131,13 @@ fko_decode_spa_data(fko_ctx_t ctx)
|
||||
return(FKO_ERROR_INVALID_DATA);
|
||||
}
|
||||
|
||||
ctx->rand_val = strndup(ndx, FKO_RAND_VAL_SIZE);
|
||||
ctx->rand_val = calloc(1, FKO_RAND_VAL_SIZE+1);
|
||||
if(ctx->rand_val == NULL)
|
||||
{
|
||||
free(tbuf);
|
||||
return(FKO_ERROR_MEMORY_ALLOCATION);
|
||||
}
|
||||
ctx->rand_val = strncpy(ctx->rand_val, ndx, FKO_RAND_VAL_SIZE);
|
||||
|
||||
/* Jump to the next field (username). We need to use the temp buffer
|
||||
* for the base64 decode step.
|
||||
|
||||
30
fko/md5.c
30
fko/md5.c
@ -36,21 +36,23 @@
|
||||
*/
|
||||
#include "md5.h"
|
||||
|
||||
#ifndef HIGHFIRST
|
||||
#define byteReverse(buf, len) /* Nothing */
|
||||
#if BYTEORDER == 1234
|
||||
#define byteReverse(buf, len) /* Nothing */
|
||||
#elif BYTEORDER == 4321
|
||||
/* Note: this code is harmless on little-endian machines.
|
||||
*/
|
||||
void byteReverse(unsigned char *buf, unsigned longs)
|
||||
{
|
||||
uint32 t;
|
||||
do {
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32 *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
}
|
||||
#else
|
||||
/* Note: this code is harmless on little-endian machines.
|
||||
*/
|
||||
void byteReverse(unsigned char *buf, unsigned longs)
|
||||
{
|
||||
uint32 t;
|
||||
do {
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32 *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
}
|
||||
#error "Unsupported Byte Order..."
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
21
fko/md5.h
21
fko/md5.h
@ -34,27 +34,6 @@
|
||||
|
||||
#define MD5_DIGESTSIZE 16
|
||||
|
||||
/* The following tests optimise behaviour on little-endian
|
||||
* machines, where there is no need to reverse the byte order
|
||||
* of 32 bit words in the MD5 computation. By default,
|
||||
* HIGHFIRST is defined, which indicates we're running on a
|
||||
* big-endian (most significant byte first) machine, on which
|
||||
* the byteReverse function in md5.c must be invoked. However,
|
||||
* byteReverse is coded in such a way that it is an identity
|
||||
* function when run on a little-endian machine, so calling it
|
||||
* on such a platform causes no harm apart from wasting time.
|
||||
* If the platform is known to be little-endian, we speed
|
||||
* things up by undefining HIGHFIRST, which defines
|
||||
* byteReverse as a null macro. Doing things in this manner
|
||||
* insures we work on new platforms regardless of their byte
|
||||
* order.
|
||||
*/
|
||||
#define HIGHFIRST
|
||||
|
||||
#ifdef __i386__
|
||||
#undef HIGHFIRST
|
||||
#endif
|
||||
|
||||
typedef struct _MD5Context {
|
||||
uint32 buf[4];
|
||||
uint32 bits[2];
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#ifndef SHA_H
|
||||
#define SHA_H 1
|
||||
|
||||
#include <endian.h>
|
||||
#include "fko_common.h"
|
||||
|
||||
/* Truncate to 32 bits -- should be a null op on 32-bit machines
|
||||
@ -37,10 +36,6 @@
|
||||
#define TRUNC32(x) ((x) & 0xffffffffL)
|
||||
#endif
|
||||
|
||||
/* This should be fine for most systems (hopefully).
|
||||
*/
|
||||
#define BYTEORDER __BYTE_ORDER
|
||||
|
||||
#define SHA_BLOCKSIZE 64
|
||||
#define SHA1_DIGESTSIZE 20
|
||||
#define SHA256_DIGESTSIZE 32
|
||||
|
||||
@ -25,6 +25,9 @@
|
||||
*****************************************************************************
|
||||
*/
|
||||
#include "spa_comm.h"
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Send the SPA data via UDP packet.
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user