From 66f5fc4322c578717ef208aa1e969d05e5a9a570 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 30 Oct 2010 15:27:51 +0100 Subject: [PATCH] hcrypto: Use system wide libroken Use the system wide libroken, rather than building our own bits locally, for libafshcrypto. Change-Id: I93eaa3a1d6b9290e30c0892a3313a8eaa639d52a Reviewed-on: http://gerrit.openafs.org/3206 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/crypto/hcrypto/Makefile.in | 113 ++------------------- src/crypto/hcrypto/NTMakefile | 33 +------ src/crypto/hcrypto/config.h | 26 +---- src/crypto/hcrypto/engine.c | 1 + src/crypto/hcrypto/getarg.h | 2 +- src/crypto/hcrypto/krb5-types.h | 15 ++- src/crypto/hcrypto/roken.h | 169 -------------------------------- 7 files changed, 30 insertions(+), 329 deletions(-) delete mode 100644 src/crypto/hcrypto/roken.h diff --git a/src/crypto/hcrypto/Makefile.in b/src/crypto/hcrypto/Makefile.in index ea2ae1e44..ea73d68c6 100644 --- a/src/crypto/hcrypto/Makefile.in +++ b/src/crypto/hcrypto/Makefile.in @@ -37,7 +37,7 @@ MODULE_INCLUDE=-I${srcdir} -I${TOP_INCDIR}/hcrypto -I$(UPSTREAM)/hcrypto SHLIBOBJ= libafshcrypto.${SHLIB_SUFFIX}.${LIBMAJOR}.${LIBMINOR} -all: $(ROKEN_HEADERS) ${HEADERS} ${TOP_LIBDIR}/${SHLIBOBJ} \ +all: ${HEADERS} ${TOP_LIBDIR}/${SHLIBOBJ} \ ${TOP_LIBDIR}/libafshcrypto.a \ ${TOP_LIBDIR}/libafshcrypto_lwp.a @@ -53,19 +53,17 @@ dest: libafshcrypto.a ${SHLIBOBJ} clean: $(RM) -f ${OBJECTS} ${SHLIBOBJ} libafshcrypto.a libafshcrypto.exp \ - test_cipher test_cipher.o hex.o + test_cipher test_cipher.o COMMON_OBJS= aes.o camellia.o camellia-ntt.o des.o engine.o evp.o \ evp-hcrypto.o evp-cc.o hmac.o md2.o md4.o md5.o pkcs5.o \ rand-egd.o rand-timer.o rand-unix.o rand.o rc2.o rc4.o \ rijndael-alg-fst.o rnd_keys.o sha.o sha256.o sha512.o ui.o \ - validate.o \ - cloexec.o ct.o issuid.o net_read.o net_write.o snprintf.o \ - warnerr.o + validate.o -OBJECTS = $(COMMON_OBJS) rand-fortuna.o $(ROKEN_LIBOBJS) +OBJECTS = $(COMMON_OBJS) rand-fortuna.o -LWP_OBJS = $(COMMON_OBJS) rand-fortuna_lwp.o $(ROKEN_LIBOBJS) +LWP_OBJS = $(COMMON_OBJS) rand-fortuna_lwp.o LWPRULE=$(CC) $(AFS_CPPFLAGS) $(COMMON_CFLAGS) $(XCFLAGS) $(ARCHFLAGS) \ -I$(TOP_INCDIR)/hcrypto -I$(UPSTREAM)/hcrypto -c $? @@ -77,7 +75,7 @@ ${TOP_LIBDIR}/${SHLIBOBJ}: ${SHLIBOBJ} ${SHLIBOBJ}: ${OBJECTS} libafshcrypto.map ${TOP_OBJDIR}/src/config/shlib-build -d $(srcdir) -l libafshcrypto \ -M ${LIBMAJOR} -m ${LIBMINOR} -- \ - ${OBJECTS} ${MT_LIBS} + ${OBJECTS} -L$(TOP_LIBDIR) -lrokenafs ${MT_LIBS} libafshcrypto.a: ${OBJECTS} $(RM) -f $@ @@ -89,8 +87,8 @@ libafshcrypto_lwp.a: $(LWP_OBJS) $(AR) crv $@ $(LWP_OBJS) $(RANLIB) $@ -test_cipher: test_cipher.o hex.o libafshcrypto.a - $(AFS_LDRULE) test_cipher.o hex.o libafshcrypto.a +test_cipher: test_cipher.o libafshcrypto.a + $(AFS_LDRULE) test_cipher.o libafshcrypto.a $(LIB_roken) ${TOP_INCDIR}/hcrypto/aes.h: ${UPSTREAM}/hcrypto/aes.h ${INSTALL_DATA} $? $@ @@ -248,101 +246,6 @@ validate.o: ${UPSTREAM}/hcrypto/validate.c test_cipher.o: ${UPSTREAM}/hcrypto/test_cipher.c $(AFS_CCRULE) $(UPSTREAM)/hcrypto/test_cipher.c -# These bits of libroken are new functionality, rather than compatibility -# code. Where they should go eventually is unclear. - -cloexec.o: ${UPSTREAM}/roken/cloexec.c - $(AFS_CCRULE) $(UPSTREAM)/roken/cloexec.c - -ct.o: ${UPSTREAM}/roken/ct.c - $(AFS_CCRULE) $(UPSTREAM)/roken/ct.c - -hex.o: ${UPSTREAM}/roken/hex.c - $(AFS_CCRULE) $(UPSTREAM)/roken/hex.c - -issuid.o: ${UPSTREAM}/roken/issuid.c - $(AFS_CCRULE) $(UPSTREAM)/roken/issuid.c - -net_read.o: ${UPSTREAM}/roken/net_read.c - $(AFS_CCRULE) $(UPSTREAM)/roken/net_read.c - -net_write.o: ${UPSTREAM}/roken/net_write.c - $(AFS_CCRULE) $(UPSTREAM)/roken/net_write.c - -# The upstream snprintf.c has some pointer warnings in it -CFLAGS_snprintf.o = @CFLAGS_NOERROR@ - -snprintf.o: ${UPSTREAM}/roken/snprintf.c - $(AFS_CCRULE) $(UPSTREAM)/roken/snprintf.c - -# These bits of libroken are compatibility functions. They should get moved -# out into a new libroken top level target, which allows the use of an -# existing libroken, if one is available. - - -daemon.o: ${UPSTREAM}/roken/daemon.c - $(AFS_CCRULE) $(UPSTREAM)/roken/daemon.c - -ecalloc.o: ${UPSTREAM}/roken/ecalloc.c - $(AFS_CCRULE) $(UPSTREAM)/roken/ecalloc.c - -emalloc.o: ${UPSTREAM}/roken/emalloc.c - $(AFS_CCRULE) $(UPSTREAM)/roken/emalloc.c - -erealloc.o: ${UPSTREAM}/roken/erealloc.c - $(AFS_CCRULE) $(UPSTREAM)/roken/erealloc.c - -err.h: ${UPSTREAM}/roken/err.hin - cp $? $@ - -err.o: ${UPSTREAM}/roken/err.c - $(AFS_CCRULE) $(UPSTREAM)/roken/err.c - -errx.o: ${UPSTREAM}/roken/errx.c - $(AFS_CCRULE) $(UPSTREAM)/roken/errx.c - -getopt.o: ${UPSTREAM}/roken/getopt.c - $(AFS_CCRULE) $(UPSTREAM)/roken/getopt.c - -getprogname.o: ${UPSTREAM}/roken/getprogname.c - $(AFS_CCRULE) $(UPSTREAM)/roken/getprogname.c - -socket.o: ${UPSTREAM}/roken/socket.c - $(AFS_CCRULE) $(UPSTREAM)/roken/socket.c - -strlcat.o: ${UPSTREAM}/roken/strlcat.c - $(AFS_CCRULE) $(UPSTREAM)/roken/strlcat.c - -strlcpy.o: ${UPSTREAM}/roken/strlcpy.c - $(AFS_CCRULE) $(UPSTREAM)/roken/strlcpy.c - -strnlen.o: ${UPSTREAM}/roken/strnlen.c - $(AFS_CCRULE) $(UPSTREAM)/roken/strnlen.c - -verr.o: ${UPSTREAM}/roken/verr.c - $(AFS_CCRULE) $(UPSTREAM)/roken/verr.c - -verrx.o: ${UPSTREAM}/roken/verrx.c - $(AFS_CCRULE) $(UPSTREAM)/roken/verrx.c - -vsyslog.o: ${UPSTREAM}/roken/vsyslog.c - $(AFS_CCRULE) $(UPSTREAM)/roken/vsyslog.c - -vwarn.o: ${UPSTREAM}/roken/vwarn.c - $(AFS_CCRULE) $(UPSTREAM)/roken/vwarn.c - -vwarnx.o: ${UPSTREAM}/roken/vwarnx.c - $(AFS_CCRULE) $(UPSTREAM)/roken/vwarnx.c - -warn.o: ${UPSTREAM}/roken/warn.c - $(AFS_CCRULE) $(UPSTREAM)/roken/warn.c - -warnerr.o: ${UPSTREAM}/roken/warnerr.c - $(AFS_CCRULE) $(UPSTREAM)/roken/warnerr.c - -warnx.o: ${UPSTREAM}/roken/warnx.c - $(AFS_CCRULE) $(UPSTREAM)/roken/warnx.c - # LWP Targets rand-fortuna_lwp.o: ${UPSTREAM}/hcrypto/rand-fortuna.c diff --git a/src/crypto/hcrypto/NTMakefile b/src/crypto/hcrypto/NTMakefile index c3ba794a4..86525150d 100644 --- a/src/crypto/hcrypto/NTMakefile +++ b/src/crypto/hcrypto/NTMakefile @@ -7,17 +7,14 @@ RELDIR=crypto\hcrypto !include ..\..\config\NTMakefile.$(SYS_NAME) !include ..\..\config\NTMakefile.version -AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -I$(SRC)\external\heimdal\hcrypto -DHAVE_CONFIG_H=1 - -ROKEN = $(SRC)\external\heimdal\roken +AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -I$(SRC)\external\heimdal\hcrypto -DHAVE_CONFIG_H=1 -DKRB5 HCRYPTO = $(SRC)\external\heimdal\hcrypto INCFILEDIR = $(DESTDIR)\include\hcrypto INCFILES = \ - $(INCFILEDIR)\engine.h \ - $(INCFILEDIR)\err.h + $(INCFILEDIR)\engine.h HCRYPTO_INCFILES = \ $(INCFILEDIR)\aes.h \ @@ -65,22 +62,6 @@ HCRYPTO_OBJS = $(OUT)\aes.obj \ $(OUT)\ui.obj \ $(OUT)\validate.obj -ROKEN_OBJS = \ - $(OUT)\cloexec.obj \ - $(OUT)\ct.obj \ - $(OUT)\err.obj \ - $(OUT)\errx.obj \ - $(OUT)\getprogname.obj \ - $(OUT)\issuid.obj \ - $(OUT)\snprintf.obj \ - $(OUT)\verr.obj \ - $(OUT)\verrx.obj \ - $(OUT)\vwarn.obj \ - $(OUT)\vwarnx.obj \ - $(OUT)\warn.obj \ - $(OUT)\warnerr.obj \ - $(OUT)\warnx.obj - # This is a horrible hack that is required to get # around the fact that the OpenAFS build system copies # its own des.h into the top-level OpenAFS include @@ -89,9 +70,6 @@ ROKEN_OBJS = \ des.h: $(HCRYPTO)\des.h $(COPY) $** $@ -$(ROKEN_OBJS):$(ROKEN)\$$(@B).c - $(C2OBJ) $** -I$(ROKEN) - $(HCRYPTO_OBJS):$(HCRYPTO)\$$(@B).c $(C2OBJ) $** -I$(HCRYPTO) @@ -101,17 +79,14 @@ $(HCRYPTO_INCFILES):$(HCRYPTO)\$$(@B).h $(INCFILES):$$(@B).h $(COPY) $** $(INCFILEDIR) -err.h: $(ROKEN)\err.hin - $(COPY) $** $@ - !if !defined(NMAKE) NTMAKE = nmake /nologo /f ntmakefile !endif DLLLIBS = \ -# $(DESTDIR)\lib\afs\afsreg.lib + $(DESTDIR)\lib\afsroken.lib -$(LIBFILE): $(LOCAL_OBJS) $(HCRYPTO_OBJS) $(ROKEN_OBJS) $(DLLLIBS) +$(LIBFILE): $(LOCAL_OBJS) $(HCRYPTO_OBJS) $(DLLLIBS) $(DLLCONLINK) /DEF:afshcrypto.def shell32.lib $(_VC_MANIFEST_EMBED_DLL) $(DLLPREP) diff --git a/src/crypto/hcrypto/config.h b/src/crypto/hcrypto/config.h index 0dc3176e9..db3118c6c 100644 --- a/src/crypto/hcrypto/config.h +++ b/src/crypto/hcrypto/config.h @@ -25,29 +25,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef AFS_NT40_ENV -#include -#include -#include -#include -#include -#endif - -#ifdef HAVE_TERMIOS_H -#include -#endif - -#ifdef HAVE_DIRENT_H -#include +#if HAVE_STDINT_H +#include #endif #if defined(AFS_NT40_ENV) @@ -62,4 +41,3 @@ # define inline __inline __attribute__((always_inline)) #endif -#include "roken.h" \ No newline at end of file diff --git a/src/crypto/hcrypto/engine.c b/src/crypto/hcrypto/engine.c index 61c07ce61..aef0103f5 100644 --- a/src/crypto/hcrypto/engine.c +++ b/src/crypto/hcrypto/engine.c @@ -6,6 +6,7 @@ #include #include +#include int ENGINE_finish(const ENGINE *dummy) { diff --git a/src/crypto/hcrypto/getarg.h b/src/crypto/hcrypto/getarg.h index 011fac1ce..e8908065b 100644 --- a/src/crypto/hcrypto/getarg.h +++ b/src/crypto/hcrypto/getarg.h @@ -32,6 +32,6 @@ arg_printusage (struct getargs *args, } static inline void -print_version(const char *str) { +rk_print_version(const char *str) { return; } diff --git a/src/crypto/hcrypto/krb5-types.h b/src/crypto/hcrypto/krb5-types.h index d1ab56ad5..f96bcc84f 100644 --- a/src/crypto/hcrypto/krb5-types.h +++ b/src/crypto/hcrypto/krb5-types.h @@ -1 +1,14 @@ -/* This file intentionally left blank */ +#ifdef AFS_NT40_ENV +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +#endif diff --git a/src/crypto/hcrypto/roken.h b/src/crypto/hcrypto/roken.h deleted file mode 100644 index e8455a3b5..000000000 --- a/src/crypto/hcrypto/roken.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef OPENAFS_ROKEN_H -#define OPENAFS_ROKEN_H - -#ifdef AFS_NT40_ENV -#include - -#ifdef _MSC_VER -/* Declarations for Microsoft Visual C runtime in Windows */ -#include - -#include - -#ifndef __BITS_TYPES_DEFINED__ -#define __BITS_TYPES_DEFINED__ - -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; -typedef uint64_t u_int64_t; - -#endif /* __BITS_TYPES_DEFINED__ */ - -#ifndef HAVE_SSIZE_T -#ifdef _WIN64 -typedef __int64 ssize_t; -#else -typedef int ssize_t; -#endif -#endif - -/* The MSVC implementation of snprintf is not C99 compliant. */ -#define snprintf rk_snprintf -#define vsnprintf rk_vsnprintf -#define vasnprintf rk_vasnprintf -#define vasprintf rk_vasprintf -#define asnprintf rk_asnprintf -#define asprintf rk_asprintf - -#endif /* _MSC_VER */ -#endif /* AFS_NT40_ENV */ - -#define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x)) - -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) -#endif - -#ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL __cdecl -#else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL -#endif -#endif - -#ifndef HAVE___ATTRIBUTE__ -#define __attribute__(x) -#endif - -typedef int rk_socket_t; - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - ct_memcmp(const void *, const void *, size_t); - -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec(int); - -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec_file(FILE *); - -ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL - net_write (rk_socket_t, const void *, size_t); - -ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL - net_read (rk_socket_t, void *, size_t); - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void); - -#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) -#ifndef HAVE_SNPRINTF -#define snprintf rk_snprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - rk_snprintf (char *, size_t, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -#endif - -#if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) -#ifndef HAVE_VSNPRINTF -#define vsnprintf rk_vsnprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - rk_vsnprintf (char *, size_t, const char *, va_list) - __attribute__((format (printf, 3, 0))); -#endif - -#if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) -#ifndef HAVE_ASPRINTF -#define asprintf rk_asprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - rk_asprintf (char **, const char *, ...) - __attribute__ ((format (printf, 2, 3))); -#endif - -#if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) -#ifndef HAVE_VASPRINTF -#define vasprintf rk_vasprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - rk_vasprintf (char **, const char *, va_list) - __attribute__((format (printf, 2, 0))); -#endif - -#if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) -#ifndef HAVE_ASNPRINTF -#define asnprintf rk_asnprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - rk_asnprintf (char **, size_t, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -#endif - -#if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) -#ifndef HAVE_VASNPRINTF -#define vasnprintf rk_vasnprintf -#endif -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL - vasnprintf (char **, size_t, const char *, va_list) - __attribute__((format (printf, 3, 0))); -#endif - -#ifndef HAVE_STRLCPY -#define strlcpy rk_strlcpy -ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL - strlcpy (char *, const char *, size_t); -#endif - -#ifndef HAVE_DIRFD -# ifdef HAVE_DIR_DD_FD -# define dirfd(x) ((x)->dd_fd) -# else -# ifndef _WIN32 /* Windows code never calls dirfd */ -# error Missing dirfd() and ->dd_fd -# endif -# endif -#endif - -/* This is a bodge, but it's only used by the tests */ -#define emalloc(x) malloc(x) - -#ifndef HAVE_GETPROGNAME -ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void); -#endif - -#ifndef _PATH_DEVNULL -#define _PATH_DEVNULL "/dev/null" -#endif - - -#endif /* OPENAFS_ROKEN_H */ -- 2.39.5