fix dnet-config (remove references to /usr/{include,lib}),
[openwrt.git] / openwrt / package / mini_httpd / patches / 500-matrixssl.patch
1 diff -ruN mini_httpd-1.19-orig/Makefile mini_httpd-1.19-3/Makefile
2 --- mini_httpd-1.19-orig/Makefile 2002-11-02 00:02:57.000000000 +0100
3 +++ mini_httpd-1.19-3/Makefile 2005-03-09 08:52:21.000000000 +0100
4 @@ -14,17 +14,30 @@
5 # http://www.openssl.org/ Make sure the SSL_TREE definition points to the
6 # tree with your OpenSSL installation - depending on how you installed it,
7 # it may be in /usr/local instead of /usr/local/ssl.
8 +
9 +# OpenSSL
10 #SSL_TREE = /usr/local/ssl
11 #SSL_DEFS = -DUSE_SSL
12 #SSL_INC = -I${SSL_TREE}/include
13 #SSL_LIBS = -L${SSL_TREE}/lib -lssl -lcrypto
14 +#SSL_OBJS =
15 +
16 +# MatrixSSL
17 +SSL_TREE =
18 +SSL_DEFS = -DUSE_SSL -DHAVE_MATRIXSSL
19 +SSL_INC =
20 +SSL_LIBS = -lmatrixssl
21 +SSL_OBJS = matrixssl_helper.o
22
23
24 -BINDIR = /usr/local/sbin
25 -MANDIR = /usr/local/man
26 +DESTDIR =
27 +
28 +BINDIR = $(DESTDIR)/usr/sbin
29 +MANDIR = $(DESTDIR)/usr/share/man
30 CC = gcc
31 CDEFS = ${SSL_DEFS} ${SSL_INC}
32 -CFLAGS = -O ${CDEFS}
33 +OFLAGS = -O
34 +CFLAGS = ${OFLAGS} ${CDEFS}
35 #CFLAGS = -g ${CDEFS}
36 -LDFLAGS = -s
37 +LDFLAGS =
38 #LDFLAGS = -g
39 @@ -32,12 +45,15 @@
40
41 all: mini_httpd htpasswd
42
43 -mini_httpd: mini_httpd.o match.o tdate_parse.o
44 - ${CC} ${CFLAGS} ${LDFLAGS} mini_httpd.o match.o tdate_parse.o ${LDLIBS} -o mini_httpd
45 +mini_httpd: mini_httpd.o match.o tdate_parse.o ${SSL_OBJS}
46 + ${CC} ${CFLAGS} ${LDFLAGS} mini_httpd.o match.o tdate_parse.o ${SSL_OBJS} ${LDLIBS} -o mini_httpd
47
48 mini_httpd.o: mini_httpd.c version.h port.h match.h tdate_parse.h mime_encodings.h mime_types.h
49 ${CC} ${CFLAGS} -c mini_httpd.c
50
51 +matrixssl_helper.o: matrixssl_helper.c
52 + ${CC} ${CFLAGS} -c matrixssl_helper.c
53 +
54 match.o: match.c match.h
55 ${CC} ${CFLAGS} -c match.c
56
57 @@ -71,16 +87,18 @@
58 chmod 600 mini_httpd.pem
59
60
61 -install: all
62 - rm -f ${BINDIR}/mini_httpd ${BINDIR}/htpasswd
63 +install: all uninstall
64 -mkdir -p ${BINDIR}
65 cp mini_httpd htpasswd ${BINDIR}
66 - rm -f ${MANDIR}/man8/mini_httpd.8 ${MANDIR}/man1/htpasswd.1
67 -mkdir -p ${MANDIR}/man8
68 cp mini_httpd.8 ${MANDIR}/man8
69 -mkdir -p ${MANDIR}/man1
70 cp htpasswd.1 ${MANDIR}/man1
71
72 +uninstall:
73 + rm -f ${BINDIR}/mini_httpd ${BINDIR}/htpasswd
74 + rm -f ${MANDIR}/man8/mini_httpd.8 ${MANDIR}/man1/htpasswd.1
75 +
76 clean:
77 rm -f mini_httpd mime_encodings.h mime_types.h htpasswd mini_httpd.rnd *.o core core.* *.core
78
79 diff -ruN mini_httpd-1.19-orig/mini_httpd.c mini_httpd-1.19-3/mini_httpd.c
80 --- mini_httpd-1.19-orig/mini_httpd.c 2003-12-03 19:27:22.000000000 +0100
81 +++ mini_httpd-1.19-3/mini_httpd.c 2005-03-09 08:46:28.000000000 +0100
82 @@ -66,8 +66,14 @@
83 #endif /* HAVE_SENDFILE */
84
85 #ifdef USE_SSL
86 +# ifdef HAVE_OPENSSL
87 #include <openssl/ssl.h>
88 #include <openssl/err.h>
89 +# else /* HAVE_OPENSSL */
90 +# ifdef HAVE_MATRIXSSL
91 +# include "matrixssl_helper.h"
92 +# endif /* HAVE_MATRIXSSL */
93 +# endif /* HAVE_OPENSSL */
94 #endif /* USE_SSL */
95
96 extern char* crypt( const char* key, const char* setting );
97 @@ -193,7 +199,13 @@
98 static int do_ssl;
99 static char* certfile;
100 static char* cipher;
101 +#ifdef HAVE_OPENSSL
102 static SSL_CTX* ssl_ctx;
103 +#else /* HAVE_OPENSSL */
104 + #ifdef HAVE_MATRIXSSL
105 +static sslKeys_t* keys;
106 + #endif /* HAVE_MATRIXSSL */
107 +#endif /* HAVE_OPENSSL */
108 #endif /* USE_SSL */
109 static char cwd[MAXPATHLEN];
110 static int got_hup;
111 @@ -540,6 +552,7 @@
112 #ifdef USE_SSL
113 if ( do_ssl )
114 {
115 +# ifdef HAVE_OPENSSL
116 SSL_load_error_strings();
117 SSLeay_add_ssl_algorithms();
118 ssl_ctx = SSL_CTX_new( SSLv23_server_method() );
119 @@ -559,6 +572,17 @@
120 exit( 1 );
121 }
122 }
123 +# else /* HAVE_OPENSSL */
124 +# ifdef HAVE_MATRIXSSL
125 + matrixSslOpen();
126 + if ( matrixSslReadKeys( &keys, certfile, certfile, NULL, NULL < 0) )
127 + {
128 + syslog( LOG_CRIT, "can't load certificate and/or private key\n");
129 + (void) fprintf( stderr, "%s: can't load certificate and/or private key\n", argv0 );
130 + exit( 1 );
131 + }
132 +# endif /* HAVE_MATRIXSSL */
133 +# endif /* HAVE_OPENSSL */
134 }
135 #endif /* USE_SSL */
136
137 @@ -1174,6 +1198,7 @@
138 #ifdef USE_SSL
139 if ( do_ssl )
140 {
141 +# ifdef HAVE_OPENSSL
142 ssl = SSL_new( ssl_ctx );
143 SSL_set_fd( ssl, conn_fd );
144 if ( SSL_accept( ssl ) == 0 )
145 @@ -1181,6 +1206,16 @@
146 ERR_print_errors_fp( stderr );
147 exit( 1 );
148 }
149 +# else /* HAVE_OPENSSL */
150 +# ifdef HAVE_MATRIXSSL
151 + ssl = SSL_new(keys);
152 + SSL_set_fd( ssl, conn_fd );
153 + if ( SSL_accept( ssl ) <= 0 )
154 + {
155 + perror( "SSL_accept" );
156 + }
157 +# endif /* HAVE_MATRIXSSL */
158 +# endif /* HAVE_OPENSSL */
159 }
160 #endif /* USE_SSL */
161
This page took 0.074051 seconds and 5 git commands to generate.