Changeset: 3c5420ab2e81 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3c5420ab2e81
Modified Files:
MonetDB.spec
clients/mapilib/mapi.c
configure.ag
monetdb5/mal/mal_authorize.mx
Branch: Apr2011
Log Message:
Changed OpenSSL version test into a feature test.
With these changes it is possible to compile MonetDB on CentOS 5.6.
CentOS does seem to support the necessary hash algorithms (especially
SHA512) even though it uses OpenSSL 0.9.8e (where we demanded 0.9.8f
or better).
It is not possible to build an RPM for CentOS since some other
necessary packages (for building an RPM, not for compiling and running
mserver5 and mclient) are missing. In particular, the packages
geos-devel, libcurl-devel, libuuid-devel, perl-devel, and rubygems are
not available for CentOS 5.6.
Also, it is probably necessary to run the bootstrap script on a
different system since autoconf on CentOS is also too old.
diffs (truncated from 460 to 300 lines):
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -37,7 +37,7 @@
BuildRequires: libcurl-devel
BuildRequires: libuuid-devel
BuildRequires: libxml2-devel
-BuildRequires: openssl-devel >= 0.9.8f
+BuildRequires: openssl-devel
BuildRequires: pcre-devel >= 4.5
BuildRequires: perl
BuildRequires: perl-devel
@@ -145,7 +145,7 @@
Group: Applications/Databases
Requires: %{name}-client = %{version}-%{release}
Requires: %{name}-stream-devel = %{version}-%{release}
-Requires: openssl-devel >= 0.9.8f
+Requires: openssl-devel
%description client-devel
MonetDB is a database management system that is developed from a
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2474,28 +2474,49 @@
strncpy(key, mid->password, n);
+#ifdef HAVE_RIPEMD160
if (strcmp(serverhash, "RIPEMD160") == 0) {
RIPEMD160((unsigned char *) key, n, md);
len = 40;
- } else if (strcmp(serverhash, "SHA512") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA512
+ if (strcmp(serverhash, "SHA512") == 0) {
SHA512((unsigned char *) key, n, md);
len = 128;
- } else if (strcmp(serverhash, "SHA384") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA384
+ if (strcmp(serverhash, "SHA384") == 0) {
SHA384((unsigned char *) key, n, md);
len = 96;
- } else if (strcmp(serverhash, "SHA256") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA256
+ if (strcmp(serverhash, "SHA256") == 0) {
SHA256((unsigned char *) key, n, md);
len = 64;
- } else if (strcmp(serverhash, "SHA224") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA224
+ if (strcmp(serverhash, "SHA224") == 0) {
SHA224((unsigned char *) key, n, md);
len = 56;
- } else if (strcmp(serverhash, "SHA1") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA1
+ if (strcmp(serverhash, "SHA1") == 0) {
SHA1((unsigned char *) key, n, md);
len = 40;
- } else if (strcmp(serverhash, "MD5") == 0) {
+ } else
+#endif
+#ifdef HAVE_MD5
+ if (strcmp(serverhash, "MD5") == 0) {
MD5((unsigned char *) key, n, md);
len = 32;
- } else {
+ } else
+#endif
+ {
snprintf(buf, BLOCK, "server requires
unknown hash '%s'", serverhash);
close_connection(mid);
return mapi_setError(mid, buf,
"mapi_start_talking", MERROR);
@@ -2533,6 +2554,7 @@
/* TODO: make this actually obey the separation by commas, and
* only allow full matches */
+#ifdef HAVE_RIPEMD160
if (strstr(hashes, "RIPEMD160") != NULL) {
/* The RIPEMD160 hash algorithm is a 160 bit hash. In
order to
* use in a string, a hexadecimal representation of the
bit
@@ -2559,7 +2581,10 @@
md[8], md[9], md[10], md[11],
md[12], md[13], md[14], md[15],
md[16], md[17], md[18], md[19]);
- } else if (strstr(hashes, "SHA1") != NULL) {
+ } else
+#endif
+#ifdef HAVE_SHA1
+ if (strstr(hashes, "SHA1") != NULL) {
/* The SHA-1 RSA hash algorithm is a 160 bit hash. In
order to
* use in a string, a hexadecimal representation of the
bit
* sequence is used.
@@ -2585,7 +2610,10 @@
md[8], md[9], md[10], md[11],
md[12], md[13], md[14], md[15],
md[16], md[17], md[18], md[19]);
- } else if (strstr(hashes, "MD5") != NULL) {
+ } else
+#endif
+#ifdef HAVE_MD5
+ if (strstr(hashes, "MD5") != NULL) {
/* The MD5 hash algorithm is a 128 bit hash. In order
to
* use in a string, a hexadecimal representation of the
bit
* sequence is used.
@@ -2610,8 +2638,10 @@
md[4], md[5], md[6], md[7],
md[8], md[9], md[10], md[11],
md[12], md[13], md[14], md[15]);
+ } else
+#endif
#ifdef HAVE_CRYPT
- } else if (pversion == 8 && strstr(hashes, "crypt") != NULL) {
+ if (pversion == 8 && strstr(hashes, "crypt") != NULL) {
/* The crypt hash algorithm uses UNIX crypt, a
modification of
* DES which uses a 2-char wide salt. Because crypt
only cares
* about the first eight characters of the given
password, the
@@ -2644,8 +2674,9 @@
assert(cr != NULL);
hash = malloc(sizeof(char) * ( /*{crypt} */ 7 +
strlen(cr) + 1));
sprintf(hash, "{crypt}%s", cr);
+ } else
#endif
- } else if (pversion == 8 && strstr(hashes, "plain") != NULL) {
+ if (pversion == 8 && strstr(hashes, "plain") != NULL) {
/* The plain text algorithm, doesn't really hash at
all. It's
* the easiest algorithm, as it just appends the
challenge to
* the password and returns it.
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2127,8 +2127,8 @@
dnl OpenSSL library
dnl required for MonetDB5 (and SQL), optional otherwise
-PKG_CHECK_MODULES([openssl], [openssl >= 0.9.8f],
- [have_openssl=yes; AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have the
OpenSSL library])],
+PKG_CHECK_MODULES([openssl], [openssl],
+ [have_openssl=yes],
[have_openssl=no])
case "$enable_monetdb5-$have_openssl" in
yes-no)
@@ -2140,7 +2140,33 @@
disable_monetdb5="(OpenSSL library not found but required for
MonetDB5)"
fi
;;
+*-yes)
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $openssl_LIBS"
+ AC_CHECK_FUNCS([MD5 RIPEMD160 SHA1 SHA224 SHA256 SHA384 SHA512])
+ LIBS="$save_LIBS"
+ if eval test \"x\$ac_cv_func_$MONETDB5_PASSWDHASH\" != x"yes"; then
+ case "$enable_monetdb5" in
+ yes)
+ AC_MSG_ERROR([OpenSSL library found but checksum
algorithm required for MonetDB5 not found])
+ ;;
+ auto)
+ enable_monetdb5=no
+ if test "x$disable_monetdb5" = x; then
+ disable_monetdb5="(OpenSSL library found but
checksum algorithm required for MonetDB5 not found)"
+ fi
+ ;;
+ *)
+ AC_MSG_WARN([OpenSSL library found but required
checksum algorithm not found, so disabling])
+ ;;
+ esac
+ have_openssl=no
+ fi
+ ;;
esac
+if test x"$have_openssl" = x"yes"; then
+ AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have the OpenSSL library])
+fi
dnl PCRE library
dnl required for MonetDB5 (and SQL), optional otherwise
diff --git a/monetdb5/mal/mal_authorize.mx b/monetdb5/mal/mal_authorize.mx
--- a/monetdb5/mal/mal_authorize.mx
+++ b/monetdb5/mal/mal_authorize.mx
@@ -1088,6 +1088,7 @@
return(MAL_SUCCEED);
}
+#ifdef HAVE_MD5
/**
* Returns a GDKmalloced string representing the hex representation of
* the MD5 hash of the given string.
@@ -1108,7 +1109,9 @@
return(MAL_SUCCEED);
}
+#endif
+#ifdef HAVE_SHA1
/**
* Returns a GDKmalloced string representing the hex representation of
* the SHA-1 hash of the given string.
@@ -1129,7 +1132,9 @@
return(MAL_SUCCEED);
}
+#endif
+#if defined(HAVE_SHA224) || defined(HAVE_SHA256) || defined(HAVE_SHA384) ||
defined(HAVE_SHA512)
/**
* Returns a GDKmalloced string representing the hex representation of
* the SHA-2 hash with number of bits of the given string.
@@ -1139,10 +1144,8 @@
unsigned char md[64]; /* should be SHA512_DIGEST_LENGTH */
switch (*number) {
+#ifdef HAVE_SHA224
case 224:
-#ifdef OPENSSL_NO_SHA256
- throw(MAL, "AUTHSHA2Sum", "SHA224 support not compiled
in");
-#else
SHA224((unsigned char*)*string, *len, md);
*ret = GDKmalloc(sizeof(char) * (28 * 2 + 1));
sprintf(*ret,
@@ -1158,10 +1161,8 @@
);
break;
#endif
+#ifdef HAVE_SHA256
case 256:
-#ifdef OPENSSL_NO_SHA256
- throw(MAL, "AUTHSHA2Sum", "SHA256 support not compiled
in");
-#else
SHA256((unsigned char*)*string, *len, md);
*ret = GDKmalloc(sizeof(char) * (32 * 2 + 1));
sprintf(*ret,
@@ -1179,10 +1180,8 @@
);
break;
#endif
+#ifdef HAVE_SHA384
case 384:
-#ifdef OPENSSL_NO_SHA512
- throw(MAL, "AUTHSHA2Sum" "SHA384 support not compiled
in");
-#else
SHA384((unsigned char*)*string, *len, md);
*ret = GDKmalloc(sizeof(char) * (48 * 2 + 1));
sprintf(*ret,
@@ -1204,10 +1203,8 @@
);
break;
#endif
+#ifdef HAVE_SHA512
case 512:
-#ifdef OPENSSL_NO_SHA512
- throw(MAL, "AUTHSHA2Sum" "SHA512 support not compiled
in");
-#else
SHA512((unsigned char*)*string, *len, md);
*ret = GDKmalloc(sizeof(char) * (64 * 2 + 1));
sprintf(*ret,
@@ -1242,7 +1239,9 @@
return(MAL_SUCCEED);
}
+#endif
+#ifdef HAVE_RIPEMD160
/**
* Returns a GDKmalloced string representing the hex representation of
* the RIPEMD-160 hash of the given string.
@@ -1263,6 +1262,7 @@
return(MAL_SUCCEED);
}
+#endif
/**
* Returns a GDKmalloced string representing the hex representation of
@@ -1271,25 +1271,46 @@
str
AUTHBackendSum(str *ret, str *string, int *len) {
int bits;
+#ifdef HAVE_RIPEMD160
if (strcmp(MONETDB5_PASSWDHASH, "RIPEMD160") == 0) {
AUTHRIPEMD160Sum(ret, string, len);
- } else if (strcmp(MONETDB5_PASSWDHASH, "SHA512") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA512
+ if (strcmp(MONETDB5_PASSWDHASH, "SHA512") == 0) {
bits = 512;
AUTHSHA2Sum(ret, string, len, &bits);
- } else if (strcmp(MONETDB5_PASSWDHASH, "SHA384") == 0) {
+ } else
+#endif
+#ifdef HAVE_SHA384
+ if (strcmp(MONETDB5_PASSWDHASH, "SHA384") == 0) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list