summaryrefslogtreecommitdiff
path: root/package/mini_httpd/patches/patch-mini_httpd_c
blob: b1b3414d3f9e5586731cd04965fa6183108670db (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
$Id$
--- mini_httpd-1.19.orig/mini_httpd.c	2005-06-29 19:31:17.000000000 +0200
+++ mini_httpd-1.19/mini_httpd.c	2007-01-20 19:48:49.000000000 +0100
@@ -66,8 +66,14 @@
 #endif /* HAVE_SENDFILE */
 
 #ifdef USE_SSL
+# ifdef HAVE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
+# else /* HAVE_OPENSSL */
+#  ifdef HAVE_MATRIXSSL
+#   include "matrixssl_helper.h"
+#  endif /* HAVE_MATRIXSSL */
+# endif /* HAVE_OPENSSL */
 #endif /* USE_SSL */
 
 extern char* crypt( const char* key, const char* setting );
@@ -132,10 +138,10 @@ typedef long long int64_t;
 #define CGI_NICE 10
 #endif /* CGI_NICE */
 #ifndef CGI_PATH
-#define CGI_PATH "/usr/local/bin:/usr/ucb:/bin:/usr/bin"
+#define CGI_PATH "/usr/bin:/bin:/usr/sbin:/sbin"
 #endif /* CGI_PATH */
 #ifndef CGI_LD_LIBRARY_PATH
-#define CGI_LD_LIBRARY_PATH "/usr/local/lib:/usr/lib"
+#define CGI_LD_LIBRARY_PATH "/usr/lib:/lib"
 #endif /* CGI_LD_LIBRARY_PATH */
 #ifndef AUTH_FILE
 #define AUTH_FILE ".htpasswd"
@@ -193,7 +199,13 @@ static int listen4_fd, listen6_fd;
 static int do_ssl;
 static char* certfile;
 static char* cipher;
+#ifdef HAVE_OPENSSL
 static SSL_CTX* ssl_ctx;
+#else /* HAVE_OPENSSL */
+ #ifdef HAVE_MATRIXSSL
+static sslKeys_t* keys;
+ #endif /* HAVE_MATRIXSSL */
+#endif /* HAVE_OPENSSL */
 #endif /* USE_SSL */
 static char cwd[MAXPATHLEN];
 static int got_hup;
@@ -540,6 +552,7 @@ main( int argc, char** argv )
 #ifdef USE_SSL
     if ( do_ssl )
 	{
+# ifdef HAVE_OPENSSL
 	SSL_load_error_strings();
 	SSLeay_add_ssl_algorithms();
 	ssl_ctx = SSL_CTX_new( SSLv23_server_method() );
@@ -559,6 +572,17 @@ main( int argc, char** argv )
 		exit( 1 );
 		}
 	    }
+# else /* HAVE_OPENSSL */
+#  ifdef HAVE_MATRIXSSL
+	matrixSslOpen();
+	if ( matrixSslReadKeys( &keys, certfile, certfile, NULL, NULL ) < 0 )
+	    {
+	    syslog( LOG_CRIT, "can't load certificate and/or private key\n");
+	    (void) fprintf( stderr, "%s: can't load certificate and/or private key\n", argv0 );
+	    exit( 1 );
+	    }
+#  endif /* HAVE_MATRIXSSL */
+# endif /* HAVE_OPENSSL */
 	}
 #endif /* USE_SSL */
 
@@ -1174,6 +1198,7 @@ handle_request( void )
 #ifdef USE_SSL
     if ( do_ssl )
 	{
+# ifdef HAVE_OPENSSL
 	ssl = SSL_new( ssl_ctx );
 	SSL_set_fd( ssl, conn_fd );
 	if ( SSL_accept( ssl ) == 0 )
@@ -1181,6 +1206,16 @@ handle_request( void )
 	    ERR_print_errors_fp( stderr );
 	    exit( 1 );
 	    }
+# else /* HAVE_OPENSSL */
+#  ifdef HAVE_MATRIXSSL
+	ssl = SSL_new(keys);
+	SSL_set_fd( ssl, conn_fd );
+	if ( SSL_accept( ssl ) <= 0 )
+	    {
+	    perror( "SSL_accept" );
+	    }
+#  endif /* HAVE_MATRIXSSL */
+# endif /* HAVE_OPENSSL */
 	}
 #endif /* USE_SSL */