summaryrefslogtreecommitdiff
path: root/x11/kdelibs3/patches/patch-bd
blob: a65920f3383d78afff7abd70be4daee7142f36ae (plain)
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
$NetBSD: patch-bd,v 1.13 2008/05/17 02:28:17 markd Exp $

--- kio/kssl/kopenssl.cc.orig	2006-07-22 20:16:39.000000000 +1200
+++ kio/kssl/kopenssl.cc
@@ -96,9 +96,14 @@ static int  (*K_BIO_write) (BIO *b, cons
 static int (*K_PEM_ASN1_write_bio) (int (*)(),const char *,BIO *,char *,
                                    const EVP_CIPHER *,unsigned char *,int ,
                                             pem_password_cb *, void *) = 0L;
+#if OPENSSL_VERSION_NUMBER < 0x00909000L
 static ASN1_METHOD* (*K_X509_asn1_meth) (void) = 0L;
 static int (*K_ASN1_i2d_fp)(int (*)(),FILE *,unsigned char *) = 0L;
 static int (*K_i2d_ASN1_HEADER)(ASN1_HEADER *, unsigned char **) = 0L;
+#else
+static int (*K_ASN1_item_i2d_fp)(ASN1_ITEM *,FILE *,unsigned char *) = 0L;
+static ASN1_ITEM *K_NETSCAPE_X509_it = 0L;
+#endif
 static int (*K_X509_print_fp)  (FILE *, X509*) = 0L;
 static int (*K_i2d_PKCS12)  (PKCS12*, unsigned char**) = 0L;
 static int (*K_i2d_PKCS12_fp)  (FILE *, PKCS12*) = 0L;
@@ -217,7 +222,7 @@ void KOpenSSLProxy::destroy() {
   _me = 0L;
 }
 
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
 #include <qdir.h>
 #include <qstring.h>
 #include <qstringlist.h>
@@ -240,10 +245,20 @@ static QString findMostRecentLib(QString
        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);
+	       int maj;
+               if (endmaj == -1) {
+	               int maj = numberpart.toInt(&ok);
+		       if (!ok)
+		               continue;
+	               if (maj <= bestmaj)
+		               continue;
+		       bestmaj = maj;
+		       bestmin = -1;
+                       best = (*it);
+                       continue;
+               }
+               maj = numberpart.left(endmaj).toInt(&ok);
                if (!ok)
                        continue;
                int min = numberpart.mid(endmaj+1).toInt(&ok);
@@ -280,42 +295,23 @@ KConfig *cfg;
 
    delete cfg;
 
-#ifdef __OpenBSD__
-   {
-   QString libname = findMostRecentLib("/usr/lib" KDELIBSUFF, "crypto");
-   if (!libname.isNull())
-         _cryptoLib = ll->globalLibrary(libname.latin1());
-   }
-#elif defined(__CYGWIN__)
-   libpaths << "/usr/bin/"             
-   		<< "/usr/local/bin"             
-   		<< "/usr/local/openssl/bin"     
-   		<< "/opt/openssl/bin"           
-   		<< "/opt/kde3/bin"              
-   		<< "";                          
-                                       
-   libnamess << "cygssl-0.9.7.dll"     
-		 << "cygssl.dll"                    
-		 << "libssl.dll"                    
-		 << "";                         
-                                       
-   libnamesc << "cygcrypto.dll"        
-		 << "libcrypto.dll"                 
-		 << "";                         
-#else
    libpaths
-            #ifdef _AIX
+#ifdef _AIX
             << "/opt/freeware/lib/"
-	    #endif
+#endif
 	    << "/usr/lib" KDELIBSUFF "/"
+	    << "/usr/pkg/lib/"
+#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
 	    << "/usr/ssl/lib" KDELIBSUFF "/"
 	    << "/usr/local/lib" KDELIBSUFF "/"
             << "/usr/local/openssl/lib" KDELIBSUFF "/"
             << "/usr/local/ssl/lib" KDELIBSUFF "/"
 	    << "/opt/openssl/lib" KDELIBSUFF "/"
 	    << "/lib" KDELIBSUFF "/"
+#endif
             << "";
     
+#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
 // FIXME: #define here for the various OS types to optimize
    libnamess
 	     #ifdef hpux
@@ -355,6 +351,11 @@ KConfig *cfg;
    for (QStringList::Iterator it = libpaths.begin();
                               it != libpaths.end();
                               ++it) {
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+	QString libname = findMostRecentLib(*it, "crypto");
+	if (!libname.isNull())
+		_cryptoLib = ll->globalLibrary(libname.latin1());
+#else
       for (QStringList::Iterator shit = libnamesc.begin();
                                  shit != libnamesc.end();
                                  ++shit) {
@@ -368,6 +369,7 @@ KConfig *cfg;
             _cryptoLib = ll->globalLibrary(alib.latin1());
          if (_cryptoLib) break;
       }
+#endif
       if (_cryptoLib) break;
    }
 
@@ -404,9 +406,14 @@ KConfig *cfg;
       K_BIO_ctrl = (long (*) (BIO *,int,long,void *)) _cryptoLib->symbol("BIO_ctrl");
       K_BIO_write = (int (*) (BIO *b, const void *data, int len)) _cryptoLib->symbol("BIO_write");
       K_PEM_ASN1_write_bio = (int (*)(int (*)(), const char *,BIO*, char*, const EVP_CIPHER *, unsigned char *, int, pem_password_cb *, void *)) _cryptoLib->symbol("PEM_ASN1_write_bio");
+#if OPENSSL_VERSION_NUMBER < 0x00909000L
       K_X509_asn1_meth = (ASN1_METHOD* (*)(void)) _cryptoLib->symbol("X509_asn1_meth");
       K_ASN1_i2d_fp = (int (*)(int (*)(), FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_i2d_fp");
       K_i2d_ASN1_HEADER = (int (*)(ASN1_HEADER *, unsigned char **)) _cryptoLib->symbol("i2d_ASN1_HEADER");
+#else
+      K_ASN1_item_i2d_fp = (int (*)(ASN1_ITEM *, FILE*, unsigned char *)) _cryptoLib->symbol("ASN1_item_i2d_fp");
+      K_NETSCAPE_X509_it = (ASN1_ITEM *) _cryptoLib->symbol("NETSCAPE_X509_it");
+#endif
       K_X509_print_fp = (int (*)(FILE*, X509*)) _cryptoLib->symbol("X509_print_fp");
       K_i2d_PKCS12 = (int (*)(PKCS12*, unsigned char**)) _cryptoLib->symbol("i2d_PKCS12");
       K_i2d_PKCS12_fp = (int (*)(FILE *, PKCS12*)) _cryptoLib->symbol("i2d_PKCS12_fp");
@@ -497,16 +504,14 @@ 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) {
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+      QString libname = findMostRecentLib(*it, "ssl");
+      if (!libname.isNull())
+           _sslLib = ll->globalLibrary(libname.latin1());
+#else
       for (QStringList::Iterator shit = libnamess.begin();
                                  shit != libnamess.end();
                                  ++shit) {
@@ -520,10 +525,10 @@ KConfig *cfg;
          	_sslLib = ll->globalLibrary(alib.latin1());
          if (_sslLib) break;
       }
+#endif
       if (_sslLib) break;
    }
-#endif
-
+   
    if (_sslLib) {
 #ifdef KSSL_HAVE_SSL
       // stand back from your monitor and look at this.  it's fun! :)
@@ -957,6 +962,8 @@ int KOpenSSLProxy::PEM_write_bio_X509(BI
 }
 
 
+#if OPENSSL_VERSION_NUMBER < 0x00909000L
+
 ASN1_METHOD *KOpenSSLProxy::X509_asn1_meth(void) {
    if (K_X509_asn1_meth) return (K_X509_asn1_meth)();
    else return 0L;
@@ -968,6 +975,13 @@ int KOpenSSLProxy::ASN1_i2d_fp(FILE *out
         return (K_ASN1_i2d_fp)((int (*)())K_i2d_ASN1_HEADER, out, x);
    else return -1;
 }
+#else
+int KOpenSSLProxy::ASN1_i2d_fp(FILE *out,unsigned char *x) {
+   if (K_ASN1_item_i2d_fp && K_NETSCAPE_X509_it)
+        return (K_ASN1_item_i2d_fp)(K_NETSCAPE_X509_it, out, x);
+   else return -1;
+}
+#endif
 
 
 int KOpenSSLProxy::X509_print(FILE *fp, X509 *x) {