]>
Commit | Line | Data |
---|---|---|
9709d782 ER |
1 | --- Makefile.in 2004-03-27 06:50:00.000000000 +0000 |
2 | +++ Makefile.in 2004-03-27 06:50:00.000000000 +0000 | |
3 | @@ -62,6 +62,10 @@ | |
4 | INSTALL_DATA = @INSTALL_DATA@ | |
5 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | |
6 | ||
7 | +# Stuff for SSL | |
8 | +XSSL_LIBS = @SSL_LIBS@ | |
9 | +XSSL_INCLUDE = @SSL_INCLUDE@ | |
10 | + | |
11 | # Stuff for Tcl | |
12 | TCLLIB = @TCLLIB@ | |
13 | TCLLIBFN = @TCLLIBFN@ | |
14 | @@ -95,7 +99,8 @@ | |
15 | MAKE_MODEGG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(MOD_CC)' 'LD=$(MOD_LD)' \ | |
16 | 'STRIP=$(MOD_STRIP)' 'RANLIB=$(RANLIB)' 'CFLGS=$(CFLGS)' \ | |
17 | 'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \ | |
18 | -'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(standard build)' 'MODOBJS=' | |
19 | +'XSSL_LIBS=$(XSSL_LIBS)' 'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' \ | |
20 | +'XSSL_INCLUDE=$(XSSL_INCLUDE)' 'EGGBUILD=' 'MODOBJS=' | |
21 | ||
22 | MAKE_MODULES = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(SHLIB_CC)' 'LD=$(SHLIB_LD)' \ | |
23 | 'STRIP=$(SHLIB_STRIP)' 'CFLGS=$(CFLGS)' 'XLIBS=$(XLIBS)' \ | |
24 | @@ -105,12 +110,13 @@ | |
25 | 'STRIP=$(STRIP)' 'RANLIB=$(RANLIB)' 'CFLGS=$(CFLGS) -DSTATIC' \ | |
26 | 'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \ | |
27 | 'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(static version)' \ | |
28 | -'MODOBJS=mod/*.o' | |
29 | +'XSSL_INCLUDE=$(XSSL_INCLUDE)' 'XSSL_LIBS=$(XSSL_LIBS)' 'MODOBJS=mod/*.o' | |
30 | ||
31 | MAKE_DEBEGG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(MOD_CC)' 'LD=$(MOD_LD)' \ | |
32 | 'STRIP=touch' 'RANLIB=$(RANLIB)' 'CFLGS=$(DEBCFLGS) $(CFLGS)' \ | |
33 | 'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' \ | |
34 | -'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(debug version)' 'MODOBJS=' | |
35 | +'XSSL_LIBS=$(XSSL_LIBS)' 'XLIBS=$(XLIBS)' 'EGGEXEC=$(EGGEXEC)' \ | |
36 | +'XSSL_INCLUDE=$(XSSL_INCLUDE)' 'EGGBUILD=(debug version)' 'MODOBJS=' | |
37 | ||
38 | MAKE_DEBMODULES = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(SHLIB_CC)' 'LD=$(SHLIB_LD)' \ | |
39 | 'XLIBS=$(XLIBS)' 'STRIP=touch' 'CFLGS=$(DEBCFLGS) $(CFLGS)' \ | |
40 | @@ -119,7 +125,8 @@ | |
41 | MAKE_SDEBUG = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \ | |
42 | 'STRIP=touch' 'RANLIB=$(RANLIB)' 'CFLGS=$(DEBCFLGS) $(CFLGS) -DSTATIC' \ | |
43 | 'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \ | |
44 | -'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(static debug version)' 'MODOBJS=mod/*.o' | |
45 | +'XSSL_INCLUDE=$(XSSL_INCLUDE)' 'XSSL_LIBS=$(XSSL_LIBS)' 'EGGEXEC=$(EGGEXEC)' \ | |
46 | +'EGGBUILD=(static and debug version)' 'MODOBJS=mod/*.o' | |
47 | ||
48 | MAKE_DEPEND = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' | |
49 | ||
50 | --- aclocal.m4 2004-03-27 06:50:00.000000000 +0000 | |
4200e9d6 | 51 | +++ aclocal.m4 2012-03-31 19:46:26.881862392 +0300 |
9709d782 | 52 | @@ -37,6 +37,64 @@ |
6e8c346a | 53 | ]) |
e3a05f4b | 54 | |
9709d782 | 55 | |
e3a05f4b AG |
56 | +dnl EGG_SSL_CRAP() |
57 | +dnl | |
58 | +AC_DEFUN(EGG_SSL_CRAP, [dnl | |
9709d782 | 59 | +#ssl checks |
e3a05f4b AG |
60 | +AC_MSG_CHECKING(whether to include SSL support) |
61 | +AC_ARG_WITH(ssl, | |
62 | +[ --with-ssl[=PATH] Include SSL support (DIR is OpenSSL's install dir).], | |
63 | +[ | |
64 | + case "$withval" in | |
65 | + no) | |
66 | + AC_MSG_RESULT(no) ;; | |
67 | + yes) | |
68 | + AC_MSG_RESULT(yes) | |
69 | + AC_CHECK_LIB(ssl,SSL_accept,[AC_DEFINE(EGG_SSL_EXT) | |
70 | + SSL_LIBS="-lssl -lcrypto"],[AC_MSG_ERROR([You requested SSL support, but OpenSSL was not found. Please supply a pathname to OpenSSL])],-lcrypto) | |
71 | + ;; | |
72 | + *) | |
73 | +dnl A whole whack of possible places where this might be | |
74 | + test -f $withval/openssl/ssl.h && SSL_INCLUDE="$withval" | |
75 | + test -f $withval/include/openssl/ssl.h && SSL_INCLUDE="$withval/include" | |
76 | + | |
77 | + test -f $withval/lib/libssl.a && SSL_LIB="$withval/lib" | |
78 | + test -f $withval/lib/ssl/libssl.a && SSL_LIB="$withval/lib/ssl" | |
79 | + test -f $withval/lib/openssl/libssl.a && SSL_LIB="$withval/lib/openssl/ssl" | |
80 | + test -f $withval/libssl.a && SSL_LIB="$withval" | |
81 | + test -f $withval/ssl/libssl.a && SSL_LIB="$withval/ssl" | |
82 | + test -f $withval/openssl/libssl.a && SSL_LIB="$withval/openssl" | |
83 | + | |
84 | + test -f $withval/lib/libcrypto.a && CRYPTO_LIB="$withval/lib" | |
85 | + test -f $withval/lib/ssl/libcrypto.a && CRYPTO_LIB="$withval/lib/ssl" | |
86 | + test -f $withval/lib/openssl/libcrypto.a && CRYPTO_LIB="$withval/lib/openssl/ssl" | |
87 | + test -f $withval/libcrypto.a && CRYPTO_LIB="$withval" | |
88 | + test -f $withval/ssl/libcrypto.a && CRYPTO_LIB="$withval/ssl" | |
89 | + test -f $withval/openssl/libcrypto.a && CRYPTO_LIB="$withval/openssl" | |
90 | + | |
91 | + if test -n "$SSL_INCLUDE" && test -n "$SSL_LIB" && test -n "$CRYPTO_LIB"; then | |
92 | + SSL_LIBS="-lssl -lcrypto -L$SSL_LIB -L$CRYPTO_LIB"; | |
4200e9d6 | 93 | + AC_DEFINE([EGG_SSL_EXT], [], [SSL support]) |
e3a05f4b AG |
94 | + AC_MSG_RESULT(yes) |
95 | + else | |
96 | + AC_MSG_RESULT(no) | |
97 | + AC_MSG_ERROR([You requested SSL support, but OpenSSL was not found. Please supply a pathname to OpenSSL]) | |
98 | + fi ;; | |
99 | + esac | |
100 | +],[ | |
101 | + AC_MSG_RESULT(will try to find) | |
102 | + AC_CHECK_LIB(ssl,SSL_accept,[AC_DEFINE(EGG_SSL_EXT) | |
103 | + SSL_LIBS="-lssl -lcrypto"],[AC_MSG_ERROR([OpenSSL was not found. Please supply a pathname to OpenSSL])],-lcrypto) | |
6e8c346a | 104 | + AC_CHECK_HEADERS("openssl/ssl.h",,[AC_MSG_ERROR([OpenSSL was not found. Please supply a pathname to OpenSSL])],) |
e3a05f4b | 105 | + |
6e8c346a AG |
106 | + AC_SUBST(SSL_LIBS)dnl |
107 | + AC_SUBST(SSL_INCLUDE)dnl | |
108 | +]) | |
e3a05f4b | 109 | + |
9709d782 | 110 | +#end of ssl checks |
6e8c346a | 111 | +])dnl |
e3a05f4b | 112 | + |
9709d782 | 113 | + |
6e8c346a AG |
114 | dnl EGG_MSG_CONFIGURE_END() |
115 | dnl | |
9709d782 ER |
116 | AC_DEFUN([EGG_MSG_CONFIGURE_END], |
117 | --- config.h.in 2004-03-27 06:50:00.000000000 +0000 | |
118 | +++ config.h.in 2004-03-27 06:50:00.000000000 +0000 | |
119 | @@ -62,6 +62,9 @@ | |
120 | */ | |
121 | #undef HAVE_DECL_TZNAME | |
e3a05f4b | 122 | |
6e8c346a | 123 | +/* Defines ssl mode */ |
9709d782 | 124 | +#undef EGG_SSL_EXT |
e3a05f4b | 125 | + |
6e8c346a AG |
126 | /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. |
127 | */ | |
128 | #undef HAVE_DIRENT_H | |
9709d782 ER |
129 | --- configure.ac 2004-03-27 06:50:00.000000000 +0000 |
130 | +++ configure.ac 2004-03-27 06:50:00.000000000 +0000 | |
131 | @@ -151,6 +151,7 @@ | |
132 | /usr/local/pkgs/tcl/include /sys/include \ | |
133 | /usr/pkg/lib /beos/system/include /beos/devel/include $HOME" | |
e3a05f4b AG |
134 | |
135 | +EGG_SSL_CRAP | |
e3a05f4b | 136 | |
9709d782 ER |
137 | # We save the cache (if used) here to speed things up if we can't find Tcl. |
138 | AC_CACHE_SAVE | |
139 | --- src/Makefile.in 2004-03-27 06:50:00.000000000 +0000 | |
140 | +++ src/Makefile.in 2004-03-27 06:50:00.000000000 +0000 | |
141 | @@ -11,6 +11,8 @@ | |
142 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ | |
143 | INSTALL_DATA = @INSTALL_DATA@ | |
144 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | |
e3a05f4b AG |
145 | +XSSL_LIBS = @SSL_LIBS@ |
146 | +XSSL_INCLUDE = @SSL_INCLUDE@ | |
e3a05f4b | 147 | |
9709d782 ER |
148 | CC = @CC@ |
149 | LD = @CC@ | |
150 | @@ -37,7 +39,7 @@ | |
151 | @echo "Linking eggdrop $(EGGBUILD)." | |
152 | @echo "" | |
153 | @touch mod/mod.xlibs | |
154 | - $(LD) -o ../$(EGGEXEC) $(eggdrop_objs) $(MODOBJS) $(XLIBS) md5/md5c.o compat/*.o `cat mod/mod.xlibs` | |
155 | + $(LD) -o ../$(EGGEXEC) $(eggdrop_objs) $(MODOBJS) $(XLIBS) md5/md5c.o compat/*.o `cat mod/mod.xlibs` $(XSSL_LIBS) $(XSSL_INCLUDE) | |
156 | $(STRIP) ../$(EGGEXEC) | |
157 | @echo "" | |
158 | @echo "Successful compile: $(EGGEXEC)" | |
159 | --- src/dcc.c 2004-03-27 06:50:00.000000000 +0000 | |
160 | +++ src/dcc.c 2004-03-27 06:50:00.000000000 +0000 | |
e3a05f4b AG |
161 | @@ -32,7 +32,11 @@ |
162 | #include "tandem.h" | |
163 | ||
164 | /* Includes for botnet md5 challenge/response code <cybah> */ | |
165 | +#ifndef EGG_SSL_EXT | |
166 | #include "md5/md5.h" | |
167 | +#else | |
168 | +#include "openssl/md5.h" | |
169 | +#endif | |
170 | ||
171 | extern struct userrec *userlist; | |
172 | extern struct chanset_t *chanset; | |
9709d782 ER |
173 | --- src/dccutil.c 2004-03-27 06:50:00.000000000 +0000 |
174 | +++ src/dccutil.c 2004-03-27 06:50:00.000000000 +0000 | |
e3a05f4b AG |
175 | @@ -33,6 +33,7 @@ |
176 | #include "chan.h" | |
177 | #include "modules.h" | |
178 | #include "tandem.h" | |
179 | +#include "net.h" | |
180 | ||
181 | extern struct dcc_t *dcc; | |
9709d782 ER |
182 | extern int dcc_total, dcc_flood_thr, backgrd, copy_to_tmp, max_socks; |
183 | --- src/eggdrop.h 2004-03-27 06:50:00.000000000 +0000 | |
184 | +++ src/eggdrop.h 2004-03-27 06:50:00.000000000 +0000 | |
185 | @@ -678,15 +678,6 @@ | |
186 | ClientData cd; | |
187 | }; | |
188 | ||
189 | -typedef struct sock_list { | |
e3a05f4b AG |
190 | - int sock; |
191 | - short flags; | |
9709d782 ER |
192 | - union { |
193 | - struct sock_handler sock; | |
194 | - struct tclsock_handler tclsock; | |
195 | - } handler; | |
e3a05f4b | 196 | -} sock_list; |
8eb15d2d | 197 | - |
e3a05f4b AG |
198 | enum { |
199 | EGG_OPTION_SET = 1, /* Set option(s). */ | |
8eb15d2d | 200 | EGG_OPTION_UNSET = 2 /* Unset option(s). */ |
9709d782 ER |
201 | --- src/main.c 2004-03-27 06:50:00.000000000 +0000 |
202 | +++ src/main.c 2004-03-27 06:50:00.000000000 +0000 | |
203 | @@ -164,6 +164,10 @@ | |
e3a05f4b AG |
204 | int cx_ptr = 0; |
205 | #endif | |
206 | ||
207 | +#ifdef EGG_SSL_EXT | |
9709d782 ER |
208 | +void init_ssl(); |
209 | +int clean_ssl(); | |
e3a05f4b AG |
210 | +#endif |
211 | ||
212 | void fatal(const char *s, int recoverable) | |
213 | { | |
9709d782 | 214 | @@ -174,6 +178,9 @@ |
e3a05f4b AG |
215 | for (i = 0; i < dcc_total; i++) |
216 | if (dcc[i].sock >= 0) | |
217 | killsock(dcc[i].sock); | |
6e8c346a | 218 | + #ifdef EGG_SSL_EXT |
9709d782 | 219 | + clean_ssl(); |
6e8c346a | 220 | + #endif |
e3a05f4b AG |
221 | unlink(pid_file); |
222 | if (!recoverable) { | |
223 | bg_send_quit(BG_ABORT); | |
9709d782 ER |
224 | @@ -1029,6 +1036,9 @@ |
225 | init_userent(); | |
226 | init_misc(); | |
227 | init_bots(); | |
228 | +#ifdef EGG_SSL_EXT | |
229 | + init_ssl(); | |
230 | +#endif | |
231 | init_modules(); | |
232 | if (backgrd) | |
233 | bg_prepare_split(); | |
234 | --- src/md5/md5.h 2004-03-27 06:50:00.000000000 +0000 | |
235 | +++ src/md5/md5.h 2004-03-27 06:50:00.000000000 +0000 | |
236 | @@ -5,6 +5,9 @@ | |
237 | * Written by Solar Designer <solar@openwall.com> in 2001, and placed in | |
238 | * the public domain. See md5c.c for more information. | |
239 | */ | |
240 | +#include "../config.h" | |
241 | +#ifndef EGG_SSL_EXT | |
242 | + | |
6e8c346a | 243 | |
9709d782 ER |
244 | #ifndef _MD5_H |
245 | #define _MD5_H | |
246 | @@ -24,3 +27,4 @@ | |
247 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); | |
248 | ||
249 | #endif | |
250 | +#endif | |
251 | --- src/md5/md5c.c 2004-03-27 06:50:00.000000000 +0000 | |
252 | +++ src/md5/md5c.c 2004-03-27 06:50:00.000000000 +0000 | |
6e8c346a | 253 | @@ -17,9 +17,23 @@ |
e3a05f4b | 254 | |
e3a05f4b AG |
255 | #include <string.h> |
256 | ||
6e8c346a | 257 | +#ifndef EGG_SSL_EXT |
e3a05f4b | 258 | #include "md5.h" |
6e8c346a AG |
259 | +#else |
260 | +#include "openssl/md5.h" | |
261 | +#endif | |
262 | + | |
263 | #include "compat/compat.h" | |
e3a05f4b | 264 | |
6e8c346a | 265 | +typedef unsigned long MD5_u32plus; |
e3a05f4b | 266 | + |
6e8c346a AG |
267 | +typedef struct { |
268 | + MD5_u32plus lo, hi; | |
269 | + MD5_u32plus a, b, c, d; | |
270 | + unsigned char buffer[64]; | |
271 | + MD5_u32plus block[16]; | |
272 | +} MD5_CTX; | |
273 | + | |
274 | /* | |
275 | * The basic MD5 functions. | |
276 | * | |
9709d782 ER |
277 | --- src/mod/compress.mod/compress.c 2004-03-27 06:50:00.000000000 +0000 |
278 | +++ src/mod/compress.mod/compress.c 2004-03-27 06:50:00.000000000 +0000 | |
279 | @@ -36,6 +36,8 @@ | |
280 | #include "src/mod/module.h" | |
281 | #include "share.mod/share.h" | |
282 | ||
283 | +#include <zlib.h> | |
284 | + | |
285 | #ifdef HAVE_MMAP | |
286 | # undef panic | |
287 | # include <sys/types.h> | |
288 | --- src/mod/irc.mod/chan.c 2004-03-27 06:50:00.000000000 +0000 | |
289 | +++ src/mod/irc.mod/chan.c 2004-03-27 06:50:00.000000000 +0000 | |
290 | @@ -991,10 +991,10 @@ | |
e3a05f4b AG |
291 | q = strchr(p, ' '); |
292 | if (q != NULL) { | |
293 | *q = 0; | |
294 | - set_key(chan, p); | |
295 | + set_keyegg(chan, p); | |
296 | strcpy(p, q + 1); | |
297 | } else { | |
298 | - set_key(chan, p); | |
299 | + set_keyegg(chan, p); | |
300 | *p = 0; | |
301 | } | |
302 | } | |
9709d782 ER |
303 | --- src/mod/irc.mod/irc.c 2004-03-27 06:50:00.000000000 +0000 |
304 | +++ src/mod/irc.mod/irc.c 2004-03-27 06:50:00.000000000 +0000 | |
305 | @@ -256,7 +256,7 @@ | |
e3a05f4b AG |
306 | |
307 | /* Set the key. | |
308 | */ | |
309 | -static void set_key(struct chanset_t *chan, char *k) | |
310 | +static void set_keyegg(struct chanset_t *chan, char *k) | |
311 | { | |
312 | nfree(chan->channel.key); | |
313 | if (k == NULL) { | |
9709d782 ER |
314 | --- src/mod/irc.mod/irc.h 2004-03-27 06:50:00.000000000 +0000 |
315 | +++ src/mod/irc.mod/irc.h 2004-03-27 06:50:00.000000000 +0000 | |
316 | @@ -68,7 +68,7 @@ | |
e3a05f4b | 317 | |
9709d782 | 318 | static void reset_chan_info(struct chanset_t *, int); |
e3a05f4b AG |
319 | static void recheck_channel(struct chanset_t *, int); |
320 | -static void set_key(struct chanset_t *, char *); | |
321 | +static void set_keyegg(struct chanset_t *, char *); | |
322 | static void maybe_revenge(struct chanset_t *, char *, char *, int); | |
323 | static int detect_chan_flood(char *, char *, char *, struct chanset_t *, int, | |
324 | char *); | |
9709d782 ER |
325 | --- src/mod/irc.mod/mode.c 2004-03-27 06:50:00.000000000 +0000 |
326 | +++ src/mod/irc.mod/mode.c 2004-03-27 06:50:00.000000000 +0000 | |
327 | @@ -1209,7 +1209,7 @@ | |
328 | if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) | |
329 | return 0; | |
e3a05f4b AG |
330 | if (ms2[0] == '+') { |
331 | - set_key(chan, op); | |
332 | + set_keyegg(chan, op); | |
333 | if (channel_active(chan)) | |
334 | got_key(chan, nick, from, op); | |
335 | } else { | |
9709d782 | 336 | @@ -1220,7 +1220,7 @@ |
e3a05f4b AG |
337 | !chan_master(user) && !match_my_nick(nick)) |
338 | add_mode(chan, '+', 'k', chan->key_prot); | |
339 | } | |
340 | - set_key(chan, NULL); | |
9709d782 | 341 | + set_keyegg(chan, NULL); |
e3a05f4b AG |
342 | } |
343 | break; | |
9709d782 | 344 | case 'o': |
cf5e9f16 ER |
345 | --- src/mod/module.h~ 2012-03-31 15:38:27.000000000 +0300 |
346 | +++ src/mod/module.h 2012-03-31 15:44:10.254563119 +0300 | |
347 | @@ -473,8 +473,13 @@ | |
348 | /* 284 - 287 */ | |
349 | #define quiet_reject (*(int *)(global[284])) | |
350 | #define file_readable ((int (*) (char *))global[285]) | |
351 | +#ifdef EGG_SSL_EXT | |
352 | +#define net_switch_to_ssl ((int (*)(int))global[286]) | |
087b73fb | 353 | +#define ssl_use (*(int *)global[287]) /* kyotou */ |
cf5e9f16 | 354 | +#else |
6e8c346a AG |
355 | /* IPv6 leftovers: 286 */ |
356 | /* IPv6 leftovers: 287 */ | |
cf5e9f16 | 357 | +#endif |
6e8c346a | 358 | /* 288 - 291 */ |
9709d782 | 359 | /* IPv6 leftovers: 288 */ |
6e8c346a | 360 | #define strip_mirc_codes ((void (*)(int, char *))global[289]) |
9709d782 ER |
361 | --- src/mod/server.mod/servmsg.c 2004-03-27 06:50:00.000000000 +0000 |
362 | +++ src/mod/server.mod/servmsg.c 2004-03-27 06:50:00.000000000 +0000 | |
363 | @@ -1360,6 +1360,14 @@ | |
e3a05f4b AG |
364 | fatal("NO SERVERS WILL ACCEPT MY CONNECTION.", 0); |
365 | } else { | |
366 | dcc[servidx].sock = serv; | |
6e8c346a | 367 | + #ifdef EGG_SSL_EXT |
9709d782 | 368 | + if (ssl_use) { |
6e8c346a AG |
369 | + if (net_switch_to_ssl(serv)==0) { |
370 | + putlog(LOG_SERV, "*", "SSL %s %s (Error while switching to SSL)", IRC_FAILEDCONNECT, dcc[servidx].host); | |
9709d782 | 371 | + lostdcc(servidx); |
6e8c346a | 372 | + } |
9709d782 | 373 | + } |
6e8c346a | 374 | + #endif |
e3a05f4b AG |
375 | /* Queue standard login */ |
376 | dcc[servidx].timeval = now; | |
377 | SERVER_SOCKET.timeout_val = &server_timeout; | |
9709d782 ER |
378 | --- src/modules.c 2004-03-27 06:50:00.000000000 +0000 |
379 | +++ src/modules.c 2004-03-27 06:50:00.000000000 +0000 | |
6e8c346a | 380 | @@ -29,9 +29,17 @@ |
e3a05f4b AG |
381 | #include "main.h" |
382 | #include "modules.h" | |
383 | #include "tandem.h" | |
384 | + | |
385 | +#ifndef EGG_SSL_EXT | |
386 | #include "md5/md5.h" | |
387 | +#else | |
388 | +#include "openssl/md5.h" | |
389 | +#endif | |
390 | + | |
e3a05f4b | 391 | #include "users.h" |
e3a05f4b | 392 | |
6e8c346a AG |
393 | +#include "net.h" |
394 | + | |
395 | #ifndef STATIC | |
396 | # ifdef MOD_USE_SHL | |
397 | # include <dl.h> | |
9709d782 | 398 | @@ -94,6 +102,10 @@ |
e3a05f4b AG |
399 | password_timeout, force_expire, protect_readonly, reserved_port_min, |
400 | reserved_port_max, copy_to_tmp, quiet_reject; | |
6e8c346a | 401 | |
e3a05f4b | 402 | +#ifdef EGG_SSL_EXT |
9709d782 | 403 | +extern int ssl_use; |
e3a05f4b | 404 | +#endif |
6e8c346a | 405 | + |
e3a05f4b AG |
406 | extern party_t *party; |
407 | extern time_t now, online_since; | |
6e8c346a | 408 | extern tand_t *tandbot; |
9709d782 | 409 | @@ -128,6 +140,10 @@ |
6e8c346a AG |
410 | } |
411 | #endif /* STATIC */ | |
e3a05f4b AG |
412 | |
413 | +#ifdef EGG_SSL_EXT | |
414 | +int net_switch_to_ssl(int); | |
415 | +#endif | |
9709d782 | 416 | + |
e3a05f4b | 417 | |
6e8c346a AG |
418 | /* The null functions */ |
419 | void null_func() | |
cf5e9f16 ER |
420 | @@ -561,8 +576,13 @@ |
421 | /* 284 - 287 */ | |
422 | (Function) & quiet_reject, /* int */ | |
423 | (Function) file_readable, | |
424 | +#ifdef EGG_SSL_EXT | |
425 | + (Function) net_switch_to_ssl, /* 286 */ | |
087b73fb | 426 | + (Function) &ssl_use, /* 287 kyotou */ |
cf5e9f16 | 427 | +#else |
6e8c346a AG |
428 | (Function) 0, /* IPv6 leftovers: 286 */ |
429 | (Function) 0, /* IPv6 leftovers: 287 */ | |
cf5e9f16 | 430 | +#endif |
6e8c346a | 431 | /* 288 - 291 */ |
6e8c346a | 432 | (Function) 0, /* IPv6 leftovers: 288 */ |
6e8c346a | 433 | (Function) strip_mirc_codes, |
9709d782 ER |
434 | --- src/net.c 2004-03-27 06:50:00.000000000 +0000 |
435 | +++ src/net.c 2004-03-27 06:50:00.000000000 +0000 | |
8eb15d2d | 436 | @@ -52,6 +52,18 @@ |
e3a05f4b AG |
437 | # endif |
438 | #endif | |
439 | ||
440 | +#ifdef EGG_SSL_EXT | |
6e8c346a AG |
441 | +# ifndef EGG_SSL_INCS |
442 | +# include <openssl/ssl.h> | |
443 | +# include <openssl/err.h> | |
444 | +# include <openssl/rand.h> | |
445 | +# define EGG_SSL_INCS 1 | |
446 | +# endif | |
e3a05f4b AG |
447 | +#endif |
448 | + | |
449 | +#include "net.h" | |
6e8c346a | 450 | + |
e3a05f4b AG |
451 | + |
452 | extern struct dcc_t *dcc; | |
453 | extern int backgrd, use_stderr, resolve_timeout, dcc_total; | |
454 | extern unsigned long otraffic_irc_today, otraffic_bn_today, otraffic_dcc_today, | |
9709d782 ER |
455 | @@ -64,7 +76,11 @@ |
456 | int firewallport = 1080; /* Default port of socks 4/5 firewalls. */ | |
6e8c346a AG |
457 | char botuser[21] = "eggdrop"; /* Username of the user running the bot. */ |
458 | int dcc_sanitycheck = 0; /* Do some sanity checking on dcc connections. */ | |
9709d782 | 459 | - |
e3a05f4b AG |
460 | +#ifdef EGG_SSL_EXT |
461 | +SSL_CTX *ssl_ctx=NULL; | |
462 | +char *tls_rand_file = NULL; | |
9709d782 | 463 | +int ssl_use = 0; |
e3a05f4b | 464 | +#endif |
6e8c346a | 465 | sock_list *socklist = NULL; /* Enough to be safe. */ |
9709d782 ER |
466 | sigjmp_buf alarmret; /* Env buffer for alarm() returns. */ |
467 | ||
468 | @@ -87,6 +103,73 @@ | |
6e8c346a | 469 | return ret; |
e3a05f4b AG |
470 | } |
471 | ||
472 | +#ifdef EGG_SSL_EXT | |
473 | +int seed_PRNG(void) | |
474 | +{ | |
475 | + char stackdata[1024]; | |
476 | + static char rand_file[300]; | |
477 | + FILE *fh; | |
6e8c346a | 478 | + |
e3a05f4b AG |
479 | +#if OPENSSL_VERSION_NUMBER >= 0x00905100 |
480 | + if (RAND_status()) | |
9709d782 | 481 | + return 0; /* PRNG already good seeded */ |
e3a05f4b AG |
482 | +#endif |
483 | + /* if the device '/dev/urandom' is present, OpenSSL uses it by default. | |
484 | + * check if it's present, else we have to make random data ourselfs. | |
485 | + */ | |
486 | + if ((fh = fopen("/dev/urandom", "r"))) { | |
9709d782 ER |
487 | + fclose(fh); |
488 | + return 0; | |
e3a05f4b AG |
489 | + } |
490 | + if (RAND_file_name(rand_file, sizeof(rand_file))) | |
9709d782 | 491 | + tls_rand_file = rand_file; |
e3a05f4b | 492 | + else |
9709d782 | 493 | + return 1; |
e3a05f4b | 494 | + if (!RAND_load_file(rand_file, 1024)) { |
9709d782 ER |
495 | + /* no .rnd file found, create new seed */ |
496 | + unsigned int c; | |
497 | + c = time(NULL); | |
498 | + RAND_seed(&c, sizeof(c)); | |
499 | + c = getpid(); | |
500 | + RAND_seed(&c, sizeof(c)); | |
501 | + RAND_seed(stackdata, sizeof(stackdata)); | |
e3a05f4b AG |
502 | + } |
503 | +#if OPENSSL_VERSION_NUMBER >= 0x00905100 | |
504 | + if (!RAND_status()) | |
9709d782 | 505 | + return 2; /* PRNG still badly seeded */ |
e3a05f4b AG |
506 | +#endif |
507 | + return 0; | |
508 | +} | |
6e8c346a | 509 | + |
9709d782 ER |
510 | +void init_ssl() |
511 | +{ | |
512 | + int i; | |
513 | + struct threaddata *td = threaddata(); | |
514 | + | |
515 | + for (i = 0; i < td->MAXSOCKS; i++) { | |
516 | + td->socklist[i].ssl = NULL; | |
517 | + } | |
e3a05f4b | 518 | + |
e3a05f4b AG |
519 | + SSL_load_error_strings(); |
520 | + OpenSSL_add_ssl_algorithms(); | |
521 | + ssl_ctx=SSL_CTX_new(SSLv23_client_method()); | |
6e8c346a AG |
522 | + if (!ssl_ctx) |
523 | + fatal("SSL_CTX_new() failed",0); | |
e3a05f4b | 524 | + if (seed_PRNG()) |
6e8c346a | 525 | + fatal("Wasn't able to properly seed the PRNG!",0); |
9709d782 ER |
526 | +} |
527 | + | |
528 | +int clean_ssl() { | |
e3a05f4b | 529 | + if (ssl_ctx) { |
9709d782 ER |
530 | + SSL_CTX_free(ssl_ctx); |
531 | + ssl_ctx = NULL; | |
532 | + } | |
e3a05f4b | 533 | + if (tls_rand_file) |
9709d782 | 534 | + RAND_write_file(tls_rand_file); |
e3a05f4b | 535 | + return 0; |
9709d782 | 536 | +} |
e3a05f4b | 537 | +#endif |
8eb15d2d | 538 | + |
e3a05f4b AG |
539 | int expmem_net() |
540 | { | |
8eb15d2d | 541 | int i, tot = 0; |
9709d782 ER |
542 | @@ -249,6 +332,7 @@ |
543 | td->socklist[i].handler.sock.outbuflen = 0; | |
544 | td->socklist[i].flags = options; | |
545 | td->socklist[i].sock = sock; | |
546 | + td->socklist[i].ssl = NULL; | |
547 | return i; | |
548 | } | |
549 | } | |
550 | @@ -345,6 +429,13 @@ | |
6e8c346a | 551 | |
9709d782 ER |
552 | for (i = 0; i < td->MAXSOCKS; i++) { |
553 | if ((td->socklist[i].sock == sock) && !(td->socklist[i].flags & SOCK_UNUSED)) { | |
e3a05f4b | 554 | +#ifdef EGG_SSL_EXT |
9709d782 ER |
555 | + if (td->socklist[i].ssl) { |
556 | + SSL_shutdown(td->socklist[i].ssl); | |
557 | + SSL_free(td->socklist[i].ssl); | |
558 | + td->socklist[i].ssl = NULL; | |
6e8c346a | 559 | + } |
9709d782 ER |
560 | +#endif |
561 | if (!(td->socklist[i].flags & SOCK_TCL)) { /* nothing to free for tclsocks */ | |
562 | close(td->socklist[i].sock); | |
563 | if (td->socklist[i].handler.sock.inbuf != NULL) { | |
564 | @@ -508,6 +599,65 @@ | |
e3a05f4b AG |
565 | return sock; |
566 | } | |
567 | ||
568 | +#ifdef EGG_SSL_EXT | |
569 | +int net_switch_to_ssl(int sock) { | |
570 | +int err; | |
571 | +int i=0; | |
9709d782 ER |
572 | +struct threaddata *td = threaddata(); |
573 | + | |
e3a05f4b | 574 | + debug0("net_switch_to_ssl()"); |
9709d782 ER |
575 | + while (i < td->MAXSOCKS) { |
576 | + if (td->socklist[i].sock==sock) { | |
e3a05f4b AG |
577 | + break; |
578 | + } | |
579 | + i++; | |
580 | + } | |
9709d782 | 581 | + if (i == td->MAXSOCKS) { |
e3a05f4b AG |
582 | + debug0("Error while swithing to SSL - sock not found in list"); |
583 | + return 0; | |
584 | + } | |
585 | + | |
9709d782 | 586 | + if (td->socklist[i].ssl) { |
e3a05f4b AG |
587 | + debug0("Error while swithing to SSL - already in ssl"); |
588 | + return 0; | |
589 | + } | |
9709d782 ER |
590 | + td->socklist[i].ssl = SSL_new(ssl_ctx); |
591 | + if (!td->socklist[i].ssl) { | |
e3a05f4b AG |
592 | + debug0("Error while swithing to SSL - SSL_new() error"); |
593 | + return 0; | |
594 | + } | |
595 | + | |
9709d782 ER |
596 | + SSL_set_fd(td->socklist[i].ssl, td->socklist[i].sock); |
597 | + err = SSL_connect(td->socklist[i].ssl); | |
598 | + | |
e3a05f4b AG |
599 | + while (err <= 0) { |
600 | + int errs; | |
9709d782 | 601 | + errs=SSL_get_error(td->socklist[i].ssl,err); |
e3a05f4b AG |
602 | + if ((errs!=SSL_ERROR_WANT_READ)&&(errs!=SSL_ERROR_WANT_WRITE)&& |
603 | + (errs!=SSL_ERROR_WANT_X509_LOOKUP)) { | |
604 | + putlog(LOG_DEBUG,"*", "SSL_connect() = %d, %s", err, | |
605 | + (char *)ERR_error_string(ERR_get_error(), NULL)); | |
9709d782 ER |
606 | + SSL_shutdown(td->socklist[i].ssl); |
607 | + SSL_free(td->socklist[i].ssl); | |
608 | + td->socklist[i].ssl = NULL; | |
609 | + return 0; | |
e3a05f4b AG |
610 | + } |
611 | + usleep(1000); | |
9709d782 | 612 | + err = SSL_connect(td->socklist[i].ssl); |
e3a05f4b AG |
613 | + } |
614 | + | |
615 | + if (err==1) { | |
9709d782 | 616 | + debug0("SSL_connect() success"); |
e3a05f4b AG |
617 | + return 1; |
618 | + } | |
9709d782 ER |
619 | + debug0("Error while SSL_connect()"); |
620 | + SSL_shutdown(td->socklist[i].ssl); | |
621 | + SSL_free(td->socklist[i].ssl); | |
622 | + td->socklist[i].ssl = NULL; | |
e3a05f4b AG |
623 | + return 0; |
624 | +} | |
625 | +#endif | |
626 | + | |
9709d782 ER |
627 | /* Ordinary non-binary connection attempt */ |
628 | int open_telnet(char *server, int port) | |
629 | { | |
630 | @@ -715,6 +865,9 @@ | |
631 | for (i = 0; i < slistmax; i++) { | |
632 | if (!tclonly && ((!(slist[i].flags & (SOCK_UNUSED | SOCK_TCL))) && | |
633 | ((FD_ISSET(slist[i].sock, &fdr)) || | |
e3a05f4b | 634 | +#ifdef EGG_SSL_EXT |
9709d782 | 635 | + ((slist[i].ssl)&&(SSL_pending(slist[i].ssl))) || |
6e8c346a | 636 | +#endif |
9709d782 ER |
637 | ((slist[i].sock == STDOUT) && (!backgrd) && |
638 | (FD_ISSET(STDIN, &fdr)))))) { | |
639 | if (slist[i].flags & (SOCK_LISTEN | SOCK_CONNECT)) { | |
640 | @@ -739,7 +892,33 @@ | |
641 | if ((slist[i].sock == STDOUT) && !backgrd) | |
e3a05f4b AG |
642 | x = read(STDIN, s, grab); |
643 | else | |
9709d782 | 644 | - x = read(slist[i].sock, s, grab); |
e3a05f4b | 645 | +#ifdef EGG_SSL_EXT |
9709d782 ER |
646 | + { |
647 | + if (slist[i].ssl) { | |
648 | + x = SSL_read(slist[i].ssl, s, grab); | |
649 | + | |
650 | + if (x < 0) { | |
651 | + int err = SSL_get_error(slist[i].ssl, x); | |
652 | + x = -1; | |
653 | + | |
654 | + switch (err) { | |
655 | + case SSL_ERROR_WANT_READ: | |
656 | + errno = EAGAIN; | |
657 | + break; | |
658 | + case SSL_ERROR_WANT_WRITE: | |
659 | + errno = EAGAIN; | |
660 | + break; | |
661 | + case SSL_ERROR_WANT_X509_LOOKUP: | |
662 | + errno = EAGAIN; | |
663 | + break; | |
664 | + } | |
665 | + } | |
666 | + } else | |
667 | + x = read(slist[i].sock, s, grab); | |
668 | + } | |
e3a05f4b | 669 | +#else |
9709d782 | 670 | + x = read(slist[i].sock, s, grab); |
6e8c346a | 671 | +#endif |
e3a05f4b AG |
672 | if (x <= 0) { /* eof */ |
673 | if (errno != EAGAIN) { /* EAGAIN happens when the operation would | |
674 | * block on a non-blocking socket, if the | |
9709d782 ER |
675 | @@ -1046,6 +1225,26 @@ |
676 | socklist[i].handler.sock.outbuflen += len; | |
e3a05f4b AG |
677 | return; |
678 | } | |
679 | +#ifdef EGG_SSL_EXT | |
680 | + if (socklist[i].ssl) { | |
681 | + x=SSL_write(socklist[i].ssl,s,len); | |
682 | + if (x < 0) { | |
683 | + int err = SSL_get_error(socklist[i].ssl, x); | |
684 | + x = -1; | |
685 | + switch (err) { | |
686 | + case SSL_ERROR_WANT_READ: | |
6e8c346a | 687 | + errno = EAGAIN; |
e3a05f4b AG |
688 | + break; |
689 | + case SSL_ERROR_WANT_WRITE: | |
690 | + errno = EAGAIN; | |
691 | + break; | |
692 | + case SSL_ERROR_WANT_X509_LOOKUP: | |
693 | + errno = EAGAIN; | |
694 | + break; | |
695 | + } | |
6e8c346a | 696 | + } |
e3a05f4b | 697 | + } else |
9709d782 | 698 | +#endif |
e3a05f4b AG |
699 | /* Try. */ |
700 | x = write(z, s, len); | |
701 | if (x == -1) | |
9709d782 ER |
702 | @@ -1113,6 +1312,29 @@ |
703 | (socklist[i].handler.sock.outbuf != NULL) && (FD_ISSET(socklist[i].sock, &wfds))) { | |
e3a05f4b AG |
704 | /* Trick tputs into doing the work */ |
705 | errno = 0; | |
706 | +#ifdef EGG_SSL_EXT | |
6e8c346a | 707 | + if (socklist[i].ssl) { |
9709d782 ER |
708 | + x = write(socklist[i].sock, socklist[i].handler.sock.outbuf, |
709 | + socklist[i].handler.sock.outbuflen); | |
710 | + | |
711 | + if (x < 0) { | |
712 | + int err = SSL_get_error(socklist[i].ssl, x); | |
713 | + x = -1; | |
714 | + | |
715 | + switch (err) { | |
716 | + case SSL_ERROR_WANT_READ: | |
717 | + errno = EAGAIN; | |
718 | + break; | |
719 | + case SSL_ERROR_WANT_WRITE: | |
720 | + errno = EAGAIN; | |
721 | + break; | |
722 | + case SSL_ERROR_WANT_X509_LOOKUP: | |
723 | + errno = EAGAIN; | |
724 | + break; | |
725 | + } | |
726 | + } | |
e3a05f4b | 727 | + } else |
6e8c346a | 728 | +#endif |
9709d782 | 729 | x = write(socklist[i].sock, socklist[i].handler.sock.outbuf, socklist[i].handler.sock.outbuflen); |
e3a05f4b AG |
730 | if ((x < 0) && (errno != EAGAIN) |
731 | #ifdef EBADSLT | |
9709d782 ER |
732 | --- src/net.h 1970-01-01 01:00:00.000000000 +0100 |
733 | +++ src/net.h 2004-03-27 06:50:00.000000000 +0000 | |
734 | @@ -0,0 +1,26 @@ | |
e3a05f4b AG |
735 | +#ifndef _EGG_NET_H |
736 | +#define _EGG_NET_H | |
737 | +#ifdef EGG_SSL_EXT | |
738 | +# ifndef EGG_SSL_INCS | |
739 | +# include <openssl/ssl.h> | |
740 | +# include <openssl/err.h> | |
741 | +# include <openssl/rand.h> | |
742 | +# define EGG_SSL_INCS 1 | |
743 | +# endif | |
744 | +#endif | |
745 | + | |
746 | +/* This is used by the net module to keep track of sockets and what's | |
747 | + * queued on them | |
748 | + */ | |
9709d782 ER |
749 | +typedef struct sock_list { |
750 | + int sock; | |
e3a05f4b | 751 | +#ifdef EGG_SSL_EXT |
6e8c346a | 752 | + SSL *ssl; |
e3a05f4b | 753 | +#endif |
9709d782 ER |
754 | + short flags; |
755 | + union { | |
756 | + struct sock_handler sock; | |
757 | + struct tclsock_handler tclsock; | |
758 | + } handler; | |
e3a05f4b | 759 | +} sock_list; |
e3a05f4b | 760 | +#endif /* _EGG_NET_H */ |
9709d782 ER |
761 | --- src/patch.h 2004-03-27 06:50:00.000000000 +0000 |
762 | +++ src/patch.h 2004-03-27 06:50:00.000000000 +0000 | |
8eb15d2d | 763 | @@ -36,7 +36,9 @@ |
6e8c346a AG |
764 | * |
765 | * | |
e3a05f4b | 766 | */ |
6e8c346a | 767 | -/* PATCH GOES HERE */ |
e3a05f4b | 768 | +#ifdef EGG_SSL_EXT |
9709d782 | 769 | + patch("SSL"); |
e3a05f4b AG |
770 | +#endif |
771 | /* | |
772 | * | |
773 | * | |
9709d782 ER |
774 | --- src/proto.h 2004-03-27 06:50:00.000000000 +0000 |
775 | +++ src/proto.h 2004-03-27 06:50:00.000000000 +0000 | |
776 | @@ -33,6 +33,7 @@ | |
e3a05f4b | 777 | |
9709d782 ER |
778 | #include "lush.h" |
779 | #include "misc_file.h" | |
780 | +#include "net.h" | |
e3a05f4b | 781 | |
9709d782 ER |
782 | #define dprintf dprintf_eggdrop |
783 | ||
784 | --- src/tcl.c 2004-03-27 06:50:00.000000000 +0000 | |
785 | +++ src/tcl.c 2004-03-27 06:50:00.000000000 +0000 | |
786 | @@ -44,6 +44,9 @@ | |
787 | ||
788 | ||
789 | extern time_t online_since; | |
8eb15d2d | 790 | +#ifdef EGG_SSL_EXT |
9709d782 | 791 | +extern int ssl_use; |
6e8c346a | 792 | +#endif |
9709d782 | 793 | |
e3a05f4b AG |
794 | extern char origbotname[], botuser[], motdfile[], admin[], userfile[], |
795 | firewall[], helpdir[], notify_new[], hostname[], myip[], moddir[], | |
9709d782 | 796 | @@ -553,6 +556,9 @@ |
e3a05f4b AG |
797 | {"enable-simul", &enable_simul, 0}, /* compat */ |
798 | {"debug-output", &debug_output, 0}, /* compat */ | |
799 | {"use-console-r", &use_console_r, 0}, /* compat */ | |
8eb15d2d | 800 | +#ifdef EGG_SSL_EXT |
9709d782 | 801 | + {"use-ssl", &ssl_use, 0}, |
e3a05f4b AG |
802 | +#endif |
803 | {NULL, NULL, 0} | |
804 | }; | |
805 | ||
9709d782 ER |
806 | --- src/tclhash.h 2004-03-27 06:50:00.000000000 +0000 |
807 | +++ src/tclhash.h 2004-03-27 06:50:00.000000000 +0000 | |
808 | @@ -25,6 +25,7 @@ | |
809 | #ifndef _EGG_TCLHASH_H | |
810 | #define _EGG_TCLHASH_H | |
811 | ||
812 | +#include "net.h" | |
813 | ||
814 | #define TC_DELETED 0x0001 /* This command/trigger was deleted. */ | |
815 | ||
816 | --- src/tclmisc.c 2004-03-27 06:50:00.000000000 +0000 | |
817 | +++ src/tclmisc.c 2004-03-27 06:50:00.000000000 +0000 | |
8eb15d2d | 818 | @@ -26,7 +26,12 @@ |
e3a05f4b AG |
819 | #include "main.h" |
820 | #include "modules.h" | |
821 | #include "tandem.h" | |
822 | + | |
8eb15d2d | 823 | +#ifndef EGG_SSL_EXT |
9709d782 | 824 | #include "md5/md5.h" |
8eb15d2d | 825 | +#else |
826 | +#include "openssl/md5.h" | |
827 | +#endif | |
6e8c346a | 828 | |
e3a05f4b | 829 | #ifdef TIME_WITH_SYS_TIME |
6e8c346a | 830 | # include <sys/time.h> |