1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
From: Sergio Durigan Junior <sergiodj@sergiodj.net>
Date: Mon, 30 Jan 2017 16:50:34 -0500
Subject: Fix shared library loading for modules
Upstream uses a system for dlopen'ing shared libraries that is not
very robust. They depend on libraries being installed on full paths,
which can break things when you move from one system to another.
Because of this, a fix had to be implemented downstream in order to
use dlopen's functionality of automatically searching the system
libraries when you pass just the file name to it. This also has the
benefit of not trying to load libraries from /usr/local, which can be
dangerous.
---
modules/crypto.lsp | 23 +----------------------
modules/gsl.lsp | 12 ++----------
modules/mysql.lsp | 15 +--------------
modules/odbc.lsp | 3 +--
modules/postgres.lsp | 29 +----------------------------
modules/sqlite3.lsp | 22 +---------------------
modules/unix.lsp | 16 +---------------
modules/zlib.lsp | 15 +--------------
8 files changed, 9 insertions(+), 126 deletions(-)
diff --git a/modules/crypto.lsp b/modules/crypto.lsp
index 26d7bda..e52af3a 100644
--- a/modules/crypto.lsp
+++ b/modules/crypto.lsp
@@ -41,28 +41,7 @@
(context 'crypto)
-; set library to path-name of the library on your platform OS
-;
-(set 'files '(
- "C:/Program Files/gnuwin32/bin/libeay32.dll" ; XP
- "C:/Program Files (x86)/gnuwin32/bin/libeay32.dll" ; 7
- "/usr/lib/x86_64-linux-gnu/libcrypto.so" ; Ubuntu 12.04 LTS
- "/usr/lib/i386-linux-gnu/libcrypto.so"; Ubuntu 12.04
- "/lib/i386-linux-gnu/libcrypto.so.1.0.0" ; UBUNTU Linux 13.04
- "/usr/lib64/libcrypto.so" ; Fedora, CentOS 6.x
- "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0" ; Debian jessie
- "/usr/lib/libcrypto.so"
- "/usr/lib/libcrypto.so.4"
- "/usr/lib/libcrypto.so.18.0" ; OpenBSD 4.6
- "/usr/lib/libcrypto.so.19.0" ; OpenBSD 5.0
- "/usr/lib/libcrypto.dylib"
- ))
-
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "cannot find crypto library"))))
-
-(set 'option (if (= ostype "Windows") "cdecl"))
+(set 'library "libcrypto.so.1")
(import library "MD5" option)
(import library "RIPEMD160" option)
diff --git a/modules/gsl.lsp b/modules/gsl.lsp
index 3df1601..9711fd2 100644
--- a/modules/gsl.lsp
+++ b/modules/gsl.lsp
@@ -165,22 +165,14 @@
(exit))
; the following assumes the libararies installed in the system library path
-(set 'LIB
- (if
- (= ostype "Windows") "libgsl-0.dll" ; 32-bit or 64-bit
- (= ostype "OSX") "libgsl.dylib" ; 32-bit or 64-bit
- (= ostype "Linux") "/usr/local/lib/libgsl.so" ; 32-bit or 64-bit
- ))
+(set 'LIB "libgsl.so")
; load libgslcblas which contans functions referenced by libgsl
; the symbol cblas_sdsdot is not needed but newLISP versions before
; 10.4.2 can not use the 'import' statement without a function name
; libgslcblas is mainly needed internally by libgsl.
; On windows the library is automatically loaded by libgsl-0.dll.
-(if
- (= ostype "OSX") (import "libgslcblas.dylib" "cblas_sdsdot")
- (= ostype "Linux") (import "/usr/local/lib/libgslcblas.so" "cblas_sdsdot")
-)
+(import "libgslcblas.so" "cblas_sdsdot")
; structs are defined but only needed for debugging, instead use "void*"
(struct 'complex "double" "double") ; complex numbers
diff --git a/modules/mysql.lsp b/modules/mysql.lsp
index d2b8093..a4d2437 100644
--- a/modules/mysql.lsp
+++ b/modules/mysql.lsp
@@ -114,20 +114,7 @@
; fetch-row and keep-type functions depend on this
(set 'NEWLISP64 (not (zero? (& (sys-info -1) 256))))
-(set 'files '(
- "/usr/local/lib/libmysqlclient.so.20.0" ; OpenBSD 4.9
- "/usr/lib/libmysqlclient.so" ; Linux, UNIX
- "/usr/lib/mysql/libmysqlclient.so" ; Linux Fedora
- "/usr/lib64/mysql/libmysqlclient.so" ; Linux Fedora CentOS 6.x
- "/usr/lib/x86_64-linux-gnu/libmysqlclient.so" ; Ubuntu 12.04 LTS
- "/usr/local/mysql/lib/libmysqlclient.so" ; Linux, UNIX
- "/usr/local/mysql/lib/libmysqlclient.dylib" ; MacOS X
- "/usr/lib/libmysqlclient.dylib" ; MacOS X
-))
-
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "cannot find libmysqlclient library"))))
+(set 'library "libmysqlclient.so.18")
(import library "mysql_init")
(import library "mysql_real_connect")
diff --git a/modules/odbc.lsp b/modules/odbc.lsp
index 784736e..f586489 100644
--- a/modules/odbc.lsp
+++ b/modules/odbc.lsp
@@ -39,8 +39,7 @@
; ----------------- import functions from DLL -------------------
-; set to the appropiate library on Unix or Win32
-(define ODBC-library "odbc32.dll")
+(define ODBC-library "libodbc.so")
; Constants used, make sure these constants are Ok on your Operating System or Platform.
; Note, that (define var value) is the same as as saying (set 'var value), it is here more
diff --git a/modules/postgres.lsp b/modules/postgres.lsp
index 0fe5ec5..c620f92 100644
--- a/modules/postgres.lsp
+++ b/modules/postgres.lsp
@@ -128,34 +128,7 @@
(context 'PgSQL)
-; get pg_config if available
-(set 'pg_lib_dir (exec "pg_config --libdir"))
-
-(if pg_lib_dir
- (set 'files
- (list
- (append (first pg_lib_dir) "/libpq.dylib") ; shared Mac OS X libs
- (append (first pg_lib_dir) "/libpq.so") ; loadable elf libs Posix Unix Linux
- (append (first pg_lib_dir) "/libpq.dll") ; Windows lib
- ))
- (set 'files '(
- "/usr/local/lib/libpq.so.5.1" ; OpenBSD 4.6
- "/usr/lib/libpq.so" ; CentOS or other Linux
- "/usr/lib64/libpq.so" ; Linux 64bit
- "/usr/lib/libpq.so.5.1" ; Debian
- "/usr/local/pgsql/lib/libpq.dylib" ; Mac OS X
- "c:/Program Files/PostgreSQL/8.3/bin/libpq.dll" ; Win32
- )))
-
-; find the library file
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "Cannot find libpq library!"))))
-
-; done with these
-(delete 'pg_config)
-(delete 'pg_lib_dir)
-(delete 'files)
+(set 'library "libpq.so.5")
; import functions and throw error if not found
(define (pg_import fun_name)
diff --git a/modules/sqlite3.lsp b/modules/sqlite3.lsp
index 0fa574d..c8eebb2 100644
--- a/modules/sqlite3.lsp
+++ b/modules/sqlite3.lsp
@@ -87,27 +87,7 @@
; fetch-row and keep-type functions depend on this
(set 'NEWLISP64 (not (zero? (& (sys-info -1) 256))))
-; set library to path-name of the library on your platform OS
-;
-(set 'files (list
- "/usr/lib/libsqlite3.so" ; SuSE Linux
- "/usr/local/lib/libsqlite3.so" ; Linux, BSD, Solaris
- "/usr/pkg/lib/libsqlite3.so" ; NetBSD
- "/usr/local/lib/libsqlite3.so.13.3" ; OpenBSD 4.6
- "/usr/lib/libsqlite3.0.dylib" ; Mac OSX Darwin
- "/usr/lib64/libsqlite3.so" ; for 64Bit Fedora CentOS 6 Linux
- "/usr/lib/x86_64-linux-gnu/libsqlite3.so" ; for UBUNTU 64-bit
- "/usr/lib/x86_64-linux-gnu/libsqlite3.so.0"
- "/usr/lib/i386-linux-gnu/libsqlite3.so" ; for UBUNTU 32-bit
- "/usr/lib/i386-linux-gnu/libsqlite3.so.0"
- "sqlite3.dll" ; Windows DLL path and current directory
- (string (env "PROGRAMFILES") "/sqlite3/sqlite3.dll") ; Windows SQLite3 std install
-))
-
-
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "cannot find sqlite3 library"))))
+(set 'library "libsqlite3.so")
(import library "sqlite3_open" "cdecl")
(import library "sqlite3_close" "cdecl")
diff --git a/modules/unix.lsp b/modules/unix.lsp
index 07de71e..13a23bd 100644
--- a/modules/unix.lsp
+++ b/modules/unix.lsp
@@ -39,21 +39,7 @@
(context 'unix)
-(set 'files (list
- "/usr/lib/libc.dylib" ; MacOS/Darwin
- "/usr/lib/libc.so.51.0" ; OpenBSD 4.6
- "/lib/x86_64-linux-gnu/libc.so.6" ; Ubuntu 12.04 LTS
- "/lib/i386-linux-gnu/libc.so.6" ; UBUNTU Linux
- "/lib/i686-linux-gnu/libc.so.6" ; UBUNTU Linux
- "/lib64/libc.so.6" ; CentOS 6.x
- "/lib/libc.so.6" ; UBUNTU Linux 9.04
- "/usr/lib/libc.so" ; Linux, BSD, Solaris
-))
-
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "cannot find standard C library (libc)"))))
-
+(set 'library "libc.so.6")
(unless module-is-loaded
(import library "getuid")
diff --git a/modules/zlib.lsp b/modules/zlib.lsp
index 6bdf360..3cf985c 100644
--- a/modules/zlib.lsp
+++ b/modules/zlib.lsp
@@ -31,20 +31,7 @@
(context 'zlib)
-(set 'files '(
- "/lib/x86_64-linux-gnu/libz.so.1" ; Ubunto 14.04 64bit, & Debian 8 64bit
- "/usr/lib/x86_64-linux-gnu/libz.so.1" ; Ubuntu 12.04 LTS 64bit
- "/lib/i386-linux-gnu/libz.so.1" ; Ubuntu 13.04
- "/usr/lib/libz.so" ; Linux, BSD, Solaris
- "/usr/lib/libz.so.4.1" ; OpenBSD 4.6
- "/usr/lib64/libz.so" ; for 64Bit CentOS 6 Linux
- "/usr/lib/libz.dylib" ; Mac OSX / Darwin
- "libz1.dll" ; MS Windows
-))
-
-(set 'library (files (or
- (find true (map file? files))
- (throw-error "cannot find zlib compression library"))))
+(set 'library "libz.so.1")
(import library "compress")
(import library "uncompress")
|