Correct patch to detect most recent libcrypto/libssl

This commit is contained in:
espie 2001-08-21 14:20:08 +00:00
parent fa759efd73
commit a73b3cf436

View File

@ -1,28 +1,99 @@
$OpenBSD: patch-kssl_kopenssl_cc,v 1.1 2001/08/20 23:40:18 espie Exp $
--- kssl/kopenssl.cc.orig Mon Aug 20 01:49:42 2001
+++ kssl/kopenssl.cc Mon Aug 20 01:50:16 2001
@@ -135,21 +135,12 @@ KConfig *cfg;
$OpenBSD: patch-kssl_kopenssl_cc,v 1.2 2001/08/21 14:20:08 espie Exp $
--- kssl/kopenssl.cc.orig Sun Jul 29 06:55:41 2001
+++ kssl/kopenssl.cc Tue Aug 21 16:11:26 2001
@@ -117,6 +117,51 @@ void KOpenSSLProxy::destroy() {
_me = NULL;
}
+#ifdef __OpenBSD__
+#include <qdir.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+static QString findMostRecentLib(QString dir, QString name)
+{
+ // Grab all shared libraries in the directory
+ QString filter = "lib"+name+".so.*";
+ QDir d(dir, filter);
+ if (!d.exists())
+ return NULL;
+ QStringList l = d.entryList();
+
+ // Find the best one
+ int bestmaj = -1;
+ int bestmin = -1;
+ QString best = NULL;
+ // where do we start
+ uint s = filter.length()-1;
+ for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ QString numberpart = (*it).mid(s);
+ uint endmaj = numberpart.find('.');
+ if (endmaj == -1)
+ continue;
+ bool ok;
+ int maj = numberpart.left(endmaj).toInt(&ok);
+ if (!ok)
+ continue;
+ int min = numberpart.mid(endmaj+1).toInt(&ok);
+ if (!ok)
+ continue;
+ if (maj > bestmaj || (maj == bestmaj && min > bestmin)) {
+ bestmaj = maj;
+ bestmin = min;
+ best = (*it);
+ }
+ }
+ if (best.isNull())
+ return NULL;
+ else
+ return dir+"/"+best;
+}
+#endif
+
KOpenSSLProxy::KOpenSSLProxy() {
KLibLoader *ll = KLibLoader::self();
@@ -135,6 +180,13 @@ KConfig *cfg;
delete cfg;
- libpaths << "/usr/lib/"
- << "/usr/local/lib/"
- << "/usr/local/openssl/lib/"
- << "/usr/local/ssl/lib/"
- << "/opt/openssl/lib/"
- << "";
+ libpaths << "/usr/lib/";
+#ifdef __OpenBSD__
+ {
+ QString libname = findMostRecentLib("/usr/lib", "crypto");
+ if (!libname.isNull())
+ _cryptoLib = ll->globalLibrary(libname.latin1());
+ }
+#else
libpaths << "/usr/lib/"
<< "/usr/local/lib/"
<< "/usr/local/openssl/lib/"
@@ -163,6 +215,7 @@ KConfig *cfg;
}
if (_cryptoLib) break;
}
+#endif
// FIXME: #define here for the various OS types to optimize
- libnamess << "libssl.so.0"
- << "libssl.so"
- << "libssl.sl";
+ libnamess << "libssl.so.5.1";
- libnamesc << "libcrypto.so.0"
- << "libcrypto.so"
- << "libcrypto.sl";
+ libnamesc << "libcrypto.so.5.1";
if (_cryptoLib) {
#ifdef HAVE_SSL
@@ -210,6 +263,13 @@ KConfig *cfg;
#endif
}
+#ifdef __OpenBSD__
+ {
+ QString libname = findMostRecentLib("/usr/lib", "ssl");
+ if (!libname.isNull())
+ _sslLib = ll->globalLibrary(libname.latin1());
+ }
+#else
for (QStringList::Iterator it = libpaths.begin();
it != libpaths.end();
++it) {
@@ -222,6 +282,7 @@ KConfig *cfg;
}
if (_sslLib) break;
}
+#endif
if (_sslLib) {
#ifdef HAVE_SSL