[PATCH] 1.1.42 / Win32 MinGW compilation errors.
Ludovic LANGE
llange@users.sourceforge.net
Fri, 29 Aug 2003 12:02:54 +0200
This is a multi-part message in MIME format.
--------------060403050109020101080501
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
This is part 2 of my (successful) tentative to compile libgcrypt to MinGW.
This (attached) patch needs to be applied. it takes care of the following :
* In random.c, use a gatherer in the Windows case.
* In rndw32.c, one include missing, two prototypes that weren't renamed.
* In secmem.c (Note 1) Get rid of getuid / geteuid
* build-dll was slightly modified.
- Note 1 : In secmem.c, I just defined out getuid / geteuid. This is of
course not the right way to do it, but I'm no autoconf expert and I
wanted to make sure that it actually worked. Of course this part needs
autodetection and can not be applied as is. (The problem seems that
MinGW does not define nor geteuid nor getuid)
Best regards,
Ludovic LANGE
--------------060403050109020101080501
Content-Type: text/plain;
name="libgcrypt-1.1.42-mingw.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="libgcrypt-1.1.42-mingw.diff"
diff -ruN libgcrypt-1.1.42/cipher/random.c libgcrypt-1.1.42.new/cipher/random.c
--- libgcrypt-1.1.42/cipher/random.c Tue Jul 15 00:36:44 2003
+++ libgcrypt-1.1.42.new/cipher/random.c Thu Aug 28 15:40:11 2003
@@ -778,6 +778,11 @@
return fnc;
#endif
+#if USE_RNDW32
+ fnc = rndw32_gather_random;
+ return fnc;
+#endif
+
log_fatal (_("no entropy gathering module detected\n"));
return NULL;
diff -ruN libgcrypt-1.1.42/cipher/rndw32.c libgcrypt-1.1.42.new/cipher/rndw32.c
--- libgcrypt-1.1.42/cipher/rndw32.c Mon Jun 9 15:50:37 2003
+++ libgcrypt-1.1.42.new/cipher/rndw32.c Thu Aug 28 15:41:58 2003
@@ -53,7 +53,7 @@
#include <string.h>
#include <windows.h>
-
+#include <winioctl.h>
#include "types.h"
#include "g10lib.h"
@@ -710,8 +710,8 @@
}
-static int
-gather_random( void (*add)(const void*, size_t, int), int requester,
+int
+rndw32_gather_random( void (*add)(const void*, size_t, int), int requester,
size_t length, int level )
{
static int is_initialized;
@@ -761,8 +761,8 @@
}
-static int
-gather_random_fast( void (*add)(const void*, size_t, int), int requester )
+int
+rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester )
{
static int addedFixedItems = 0;
diff -ruN libgcrypt-1.1.42/src/secmem.c libgcrypt-1.1.42.new/src/secmem.c
--- libgcrypt-1.1.42/src/secmem.c Tue Jul 15 00:55:36 2003
+++ libgcrypt-1.1.42.new/src/secmem.c Thu Aug 28 14:05:40 2003
@@ -248,7 +248,9 @@
uid_t uid;
int err;
+#if 0
uid = getuid ();
+#endif
#ifdef HAVE_BROKEN_MLOCK
if (uid)
@@ -267,14 +269,15 @@
if (err && errno)
err = errno;
#endif
-
- if (uid && ! geteuid ())
+#if 0
+ if (uid && ! getuid ())
{
/* check that we really dropped the privs.
* Note: setuid(0) should always fail */
- if (setuid (uid) || getuid () != geteuid () || !setuid (0))
+ if (setuid (uid) || getuid () != getuid () || !setuid (0))
log_fatal ("failed to reset uid: %s\n", strerror (errno));
}
+#endif
if (err)
{
@@ -421,13 +424,15 @@
uid_t uid;
disable_secmem = 1;
+#if 0
uid = getuid ();
- if (uid != geteuid ())
+ if (uid != getuid ())
{
- if (setuid (uid) || getuid () != geteuid () || !setuid (0))
+ if (setuid (uid) || getuid () != getuid () || !setuid (0))
log_fatal ("failed to drop setuid\n");
}
#endif
+#endif
}
else
{
@@ -436,10 +441,14 @@
if (! pool_okay)
{
init_pool (n);
- if (! geteuid ())
+#if 0
+ if (! getuid ())
+#endif
lock_pool (pool, n);
+#if 0
else
log_info ("Secure memory is not locked into core\n");
+#endif
}
else
log_error ("Oops, secure memory pool already initialized\n");
diff -ruN libgcrypt-1.1.42/w32-dll/build-dll libgcrypt-1.1.42.new/w32-dll/build-dll
--- libgcrypt-1.1.42/w32-dll/build-dll Thu Jan 1 01:00:00 1970
+++ libgcrypt-1.1.42.new/w32-dll/build-dll Thu Aug 28 13:40:27 2003
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Run this to generate the libgcrypt W32 DLL
+#
+# Copyright (C) 2001, 2002 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 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.
+
+AS=as
+OBJS=
+
+grep "#define HAVE_DOSISH_SYSTEM" ../config.h
+if [ $? = 1 ]; then
+ exit
+fi
+
+for i in $(ls ../cipher/*.o); do
+ OBJS="$OBJS $i"
+done
+for i in $(ls ../mpi/*.o); do
+ OBJS="$OBJS $i"
+done
+for i in $(ls ../src/*.o); do
+ OBJS="$OBJS $i"
+done
+
+# add asm code which is postfixed with .lo
+OBJS="$OBJS ../mpi/mpih-sub1.lo ../mpi/mpih-add1.lo ../mpi/mpih-lshift.lo"
+OBJS="$OBJS ../mpi/mpih-mul2.lo ../mpi/mpih-mul1.lo ../mpi/mpih-rshift.lo"
+OBJS="$OBJS ../mpi/mpih-mul3.lo"
+
+# echo 'running dlltool the first time' >&2
+# dlltool --no-delete \
+# --as $AS \
+# --def libgcrypt.def \
+# --output-exp libgcrypt.exp \
+# --output-lib libgcrypt.imp \
+# --dllname libgcrypt.dll $OBJS
+# echo 'doing dummy link to create the base file' >&2
+# gcc -mdll -Wl,--base-file -Wl,libgcrypt.base \
+# -o libgcrypt.dll libgcrypt.exp $OBJS
+# echo 'running dlltool the second time' >&2
+# dlltool --no-delete \
+# --as $AS \
+# --def libgcrypt.def \
+# --output-exp libgcrypt.exp \
+# --output-lib libgcrypt.imp \
+# --base-file libgcrypt.base \
+# --dllname libgcrypt.dll $OBJS
+#
+# echo 'doing final link' >&2
+# gcc -mdll -o libgcrypt.dll libgcrypt.exp $OBJS
+# strip libgcrypt.dll
+#
+# dlltool --def libgcrypt.def \
+# --as $AS \
+# --dllname libgcrypt.dll \
+# --output-lib libgcrypt.lib
+#
+#echo 'clean up'
+#rm -f dh.o dh.s dt.o dt.s
+#rm -f libgcrypt.base libgcrypt.exp libgcrypt.imp tlibgcrypt.exp
+
+echo "$OBJS"
+gcc -shared -o libgcrypt.dll $OBJS -L/usr/local/lib -lgpg-error -Wl,--out-implib,libgcrypt.a -Wl,--enable-auto-image-base
+
--------------060403050109020101080501--