diff options
Diffstat (limited to 'contrib/findssl.sh')
-rw-r--r-- | contrib/findssl.sh | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/contrib/findssl.sh b/contrib/findssl.sh new file mode 100644 index 000000000..87a4abce2 --- /dev/null +++ b/contrib/findssl.sh | |||
@@ -0,0 +1,159 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # findssl.sh | ||
4 | # Search for all instances of OpenSSL headers and libraries | ||
5 | # and print their versions. | ||
6 | # Intended to help diagnose OpenSSH's "OpenSSL headers do not | ||
7 | # match your library" errors. | ||
8 | # | ||
9 | # Written by Darren Tucker (dtucker at zip dot com dot au) | ||
10 | # This file is placed in the public domain. | ||
11 | # | ||
12 | # $Id: findssl.sh,v 1.1 2003/06/24 10:22:10 dtucker Exp $ | ||
13 | # 2002-07-27: Initial release. | ||
14 | # 2002-08-04: Added public domain notice. | ||
15 | # 2003-06-24: Incorporated readme, set library paths. First cvs version. | ||
16 | # | ||
17 | # "OpenSSL headers do not match your library" are usually caused by | ||
18 | # OpenSSH's configure picking up an older version of OpenSSL headers | ||
19 | # or libraries. You can use the following # procedure to help identify | ||
20 | # the cause. | ||
21 | # | ||
22 | # The output of configure will tell you the versions of the OpenSSL | ||
23 | # headers and libraries that were picked up, for example: | ||
24 | # | ||
25 | # checking OpenSSL header version... 90604f (OpenSSL 0.9.6d 9 May 2002) | ||
26 | # checking OpenSSL library version... 90602f (OpenSSL 0.9.6b [engine] 9 Jul 2001) | ||
27 | # checking whether OpenSSL's headers match the library... no | ||
28 | # configure: error: Your OpenSSL headers do not match your library | ||
29 | # | ||
30 | # Now run findssl.sh. This should identify the headers and libraries | ||
31 | # present and their versions. You should be able to identify the | ||
32 | # libraries and headers used and adjust your CFLAGS or remove incorrect | ||
33 | # versions. The output will show OpenSSL's internal version identifier | ||
34 | # and should look something like: | ||
35 | |||
36 | # $ ./findssl.sh | ||
37 | # Searching for OpenSSL header files. | ||
38 | # 0x0090604fL /usr/include/openssl/opensslv.h | ||
39 | # 0x0090604fL /usr/local/ssl/include/openssl/opensslv.h | ||
40 | # | ||
41 | # Searching for OpenSSL shared library files. | ||
42 | # 0x0090602fL /lib/libcrypto.so.0.9.6b | ||
43 | # 0x0090602fL /lib/libcrypto.so.2 | ||
44 | # 0x0090581fL /usr/lib/libcrypto.so.0 | ||
45 | # 0x0090602fL /usr/lib/libcrypto.so | ||
46 | # 0x0090581fL /usr/lib/libcrypto.so.0.9.5a | ||
47 | # 0x0090600fL /usr/lib/libcrypto.so.0.9.6 | ||
48 | # 0x0090600fL /usr/lib/libcrypto.so.1 | ||
49 | # | ||
50 | # Searching for OpenSSL static library files. | ||
51 | # 0x0090602fL /usr/lib/libcrypto.a | ||
52 | # 0x0090604fL /usr/local/ssl/lib/libcrypto.a | ||
53 | # | ||
54 | # In this example, I gave configure no extra flags, so it's picking up | ||
55 | # the OpenSSL header from /usr/include/openssl (90604f) and the library | ||
56 | # from /usr/lib/ (90602f). | ||
57 | |||
58 | # | ||
59 | # Adjust these to suit your compiler. | ||
60 | # You may also need to set the *LIB*PATH environment variables if | ||
61 | # DEFAULT_LIBPATH is not correct for your system. | ||
62 | # | ||
63 | CC=gcc | ||
64 | STATIC=-static | ||
65 | |||
66 | # | ||
67 | # Set up conftest C source | ||
68 | # | ||
69 | rm -f findssl.log | ||
70 | cat >conftest.c <<EOD | ||
71 | #include <stdio.h> | ||
72 | int main(){printf("0x%08xL\n", SSLeay());} | ||
73 | EOD | ||
74 | |||
75 | # | ||
76 | # Set default library paths if not already set | ||
77 | # | ||
78 | DEFAULT_LIBPATH=/usr/lib:/usr/local/lib | ||
79 | LIBPATH=${LIBPATH:=$DEFAULT_LIBPATH} | ||
80 | LD_LIBRARY_PATH=${LD_LIBRARY_PATH:=$DEFAULT_LIBPATH} | ||
81 | LIBRARY_PATH=${LIBRARY_PATH:=$DEFAULT_LIBPATH} | ||
82 | export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH | ||
83 | |||
84 | # | ||
85 | # Search for OpenSSL headers and print versions | ||
86 | # | ||
87 | echo Searching for OpenSSL header files. | ||
88 | if [ -x "`which locate`" ] | ||
89 | then | ||
90 | headers=`locate opensslv.h` | ||
91 | else | ||
92 | headers=`find / -name opensslv.h -print 2>/dev/null` | ||
93 | fi | ||
94 | |||
95 | for header in $headers | ||
96 | do | ||
97 | ver=`awk '/OPENSSL_VERSION_NUMBER/{printf \$3}' $header` | ||
98 | echo "$ver $header" | ||
99 | done | ||
100 | echo | ||
101 | |||
102 | # | ||
103 | # Search for shared libraries. | ||
104 | # Relies on shared libraries looking like "libcrypto.s*" | ||
105 | # | ||
106 | echo Searching for OpenSSL shared library files. | ||
107 | if [ -x "`which locate`" ] | ||
108 | then | ||
109 | libraries=`locate libcrypto.s` | ||
110 | else | ||
111 | libraries=`find / -name 'libcrypto.s*' -print 2>/dev/null` | ||
112 | fi | ||
113 | |||
114 | for lib in $libraries | ||
115 | do | ||
116 | (echo "Trying libcrypto $lib" >>findssl.log | ||
117 | dir=`dirname $lib` | ||
118 | LIBPATH="$dir:$LIBPATH" | ||
119 | LD_LIBRARY_PATH="$dir:$LIBPATH" | ||
120 | LIBRARY_PATH="$dir:$LIBPATH" | ||
121 | export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH | ||
122 | ${CC} -o conftest conftest.c $lib 2>>findssl.log | ||
123 | if [ -x ./conftest ] | ||
124 | then | ||
125 | ver=`./conftest 2>/dev/null` | ||
126 | rm -f ./conftest | ||
127 | echo "$ver $lib" | ||
128 | fi) | ||
129 | done | ||
130 | echo | ||
131 | |||
132 | # | ||
133 | # Search for static OpenSSL libraries and print versions | ||
134 | # | ||
135 | echo Searching for OpenSSL static library files. | ||
136 | if [ -x "`which locate`" ] | ||
137 | then | ||
138 | libraries=`locate libcrypto.a` | ||
139 | else | ||
140 | libraries=`find / -name libcrypto.a -print 2>/dev/null` | ||
141 | fi | ||
142 | |||
143 | for lib in $libraries | ||
144 | do | ||
145 | libdir=`dirname $lib` | ||
146 | echo "Trying libcrypto $lib" >>findssl.log | ||
147 | ${CC} ${STATIC} -o conftest conftest.c -L${libdir} -lcrypto 2>>findssl.log | ||
148 | if [ -x ./conftest ] | ||
149 | then | ||
150 | ver=`./conftest 2>/dev/null` | ||
151 | rm -f ./conftest | ||
152 | echo "$ver $lib" | ||
153 | fi | ||
154 | done | ||
155 | |||
156 | # | ||
157 | # Clean up | ||
158 | # | ||
159 | rm -f conftest.c | ||