]>
Commit | Line | Data |
---|---|---|
0b72d562 | 1 | --- postfix-2.0.16.orig/conf/dynamicmaps.cf 1970-01-01 01:00:00.000000000 +0100 |
2 | +++ postfix-2.0.16/conf/dynamicmaps.cf 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
3 | @@ -0,0 +1,9 @@ |
4 | +# Postfix dynamic maps configuration file. | |
5 | +# | |
6 | +# The first match found is the one that is used. The only wildcard | |
7 | +# allowed is '*', which matches everything. The first %s is expanded | |
8 | +# to the map type. | |
9 | +# | |
10 | +#type location of .so file name of open function | |
11 | +#==== ================================ ===================== | |
12 | +* /usr/lib/postfix/dict_%s.so dict_%s_open | |
0b72d562 | 13 | --- postfix-2.0.16.orig/src/dns/Makefile.in 2003-09-14 02:03:59.000000000 +0200 |
14 | +++ postfix-2.0.16/src/dns/Makefile.in 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
15 | @@ -15,7 +15,7 @@ |
16 | LIB_DIR = ../../lib | |
17 | INC_DIR = ../../include | |
18 | ||
19 | -.c.o:; $(CC) $(CFLAGS) -c $*.c | |
20 | +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c | |
21 | ||
22 | all: $(LIB) | |
23 | ||
0b72d562 | 24 | @@ -27,12 +27,10 @@ |
25 | tests: test | |
9d756e3c JB |
26 | |
27 | $(LIB): $(OBJS) | |
28 | - $(AR) $(ARFL) $(LIB) $? | |
29 | - $(RANLIB) $(LIB) | |
30 | + gcc -shared -Wl,-soname,libpostfix-dns.so.1 -o $(LIB) $(OBJS) | |
31 | ||
32 | $(LIB_DIR)/$(LIB): $(LIB) | |
33 | cp $(LIB) $(LIB_DIR) | |
34 | - $(RANLIB) $(LIB_DIR)/$(LIB) | |
35 | ||
36 | update: $(LIB_DIR)/$(LIB) $(HDRS) | |
37 | -for i in $(HDRS); \ | |
0b72d562 | 38 | --- postfix-2.0.16.orig/src/global/mail_conf.c 2002-01-14 17:24:35.000000000 +0100 |
39 | +++ postfix-2.0.16/src/global/mail_conf.c 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
40 | @@ -175,6 +175,13 @@ |
41 | path = concatenate(var_config_dir, "/", "main.cf", (char *) 0); | |
42 | dict_load_file(CONFIG_DICT, path); | |
43 | myfree(path); | |
44 | + | |
45 | +#ifndef NO_DYNAMIC_MAPS | |
46 | + path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0); | |
47 | + dict_open_dlinfo(path); | |
48 | + myfree(path); | |
49 | +#endif | |
50 | + | |
51 | } | |
52 | ||
53 | /* mail_conf_eval - expand macros in string */ | |
0b72d562 | 54 | --- postfix-2.0.16.orig/src/global/mail_params.c 2003-11-08 19:49:41.000000000 +0100 |
55 | +++ postfix-2.0.16/src/global/mail_params.c 2003-11-08 19:52:14.000000000 +0100 | |
7e195e4d TO |
56 | @@ -148,6 +148,8 @@ |
57 | #ifdef HAS_DB | |
58 | #include <dict_db.h> | |
59 | #endif | |
9d756e3c JB |
60 | +#include <safe_open.h> |
61 | +#include <mymalloc.h> | |
0b72d562 | 62 | |
9d756e3c | 63 | /* Global library. */ |
0b72d562 | 64 | |
65 | @@ -257,6 +259,7 @@ | |
9d756e3c JB |
66 | char *var_debug_peer_list; |
67 | int var_debug_peer_level; | |
68 | char *var_reject_reply_msg_access_denied; | |
69 | +int var_command_maxtime; | |
70 | int var_fault_inj_code; | |
0b72d562 | 71 | char *var_bounce_service; |
72 | char *var_cleanup_service; | |
73 | @@ -439,6 +442,38 @@ | |
9d756e3c JB |
74 | (long) var_sgid_gid); |
75 | } | |
76 | ||
77 | +static char *read_file(const char *name) | |
78 | +{ | |
79 | + char *ret; | |
80 | + VSTRING *why=vstring_alloc(1); | |
81 | + VSTRING *new_name=vstring_alloc(1); | |
82 | + VSTREAM *vp=safe_open(name, O_RDONLY, 0, NULL, -1, -1, why); | |
83 | + | |
84 | + /* | |
85 | + * Ugly macros to make complex expressions less unreadable. | |
86 | + */ | |
87 | +#define SKIP(start, var, cond) \ | |
88 | + for (var = start; *var && (cond); var++); | |
89 | + | |
90 | +#define TRIM(s) { \ | |
91 | + char *p; \ | |
92 | + for (p = (s) + strlen(s); p > (s) && ISSPACE(p[-1]); p--); \ | |
93 | + *p = 0; \ | |
94 | + } | |
95 | + | |
96 | + if (!vp) { | |
97 | + msg_fatal("%s: unable to open: %s",name,vstring_str(why)); | |
98 | + } | |
99 | + vstring_get_nonl(new_name,vp); | |
100 | + vstream_fclose(vp); | |
101 | + SKIP(vstring_str(new_name),ret,ISSPACE(*ret)); | |
102 | + ret=mystrdup(ret); | |
103 | + TRIM(ret); | |
104 | + vstring_free(why); | |
105 | + vstring_free(new_name); | |
106 | + return ret; | |
107 | +} | |
108 | + | |
109 | /* mail_params_init - configure built-in parameters */ | |
110 | ||
111 | void mail_params_init() | |
0b72d562 | 112 | @@ -601,6 +636,9 @@ |
9d756e3c JB |
113 | * Variables that are needed by almost every program. |
114 | */ | |
115 | get_mail_conf_str_table(other_str_defaults); | |
116 | + if (*var_myorigin=='/') { | |
117 | + var_myorigin=read_file(var_myorigin); | |
118 | + } | |
119 | get_mail_conf_int_table(other_int_defaults); | |
120 | get_mail_conf_bool_table(bool_defaults); | |
121 | get_mail_conf_time_table(time_defaults); | |
0b72d562 | 122 | --- postfix-2.0.16.orig/src/global/Makefile.in 2003-11-08 19:49:41.000000000 +0100 |
123 | +++ postfix-2.0.16/src/global/Makefile.in 2003-11-08 19:52:14.000000000 +0100 | |
124 | @@ -83,8 +83,9 @@ | |
9d756e3c JB |
125 | LIB_DIR = ../../lib |
126 | INC_DIR = ../../include | |
0b72d562 | 127 | MAKES = |
128 | +LDAPSO = dict_ldap.so | |
9d756e3c JB |
129 | |
130 | -.c.o:; $(CC) $(CFLAGS) -c $*.c | |
131 | +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c | |
132 | ||
133 | all: $(LIB) | |
134 | ||
0b72d562 | 135 | @@ -94,14 +95,21 @@ |
9d756e3c JB |
136 | test: $(TESTPROG) |
137 | ||
9d756e3c JB |
138 | $(LIB): $(OBJS) |
139 | - $(AR) $(ARFL) $(LIB) $? | |
140 | - $(RANLIB) $(LIB) | |
0b72d562 | 141 | + gcc -shared -Wl,-soname,libpostfix-global.so.1 -o $(LIB) $(OBJS) |
142 | + | |
143 | +$(LDAPSO): dict_ldap.o | |
144 | + gcc -shared -Wl,-soname,dict_ldap.so -o $@ $? -lldap -llber -L../../lib -lutil -L. -lglobal | |
145 | + | |
146 | +dict_ldap.c: ../util/dict_ldap.c | |
147 | + ln -f $? $@ | |
9d756e3c JB |
148 | |
149 | $(LIB_DIR)/$(LIB): $(LIB) | |
150 | cp $(LIB) $(LIB_DIR) | |
151 | - $(RANLIB) $(LIB_DIR)/$(LIB) | |
152 | ||
153 | -update: $(LIB_DIR)/$(LIB) $(HDRS) | |
0b72d562 | 154 | +$(LIB_DIR)/$(LDAPSO): $(LDAPSO) |
155 | + cp $(LDAPSO) $(LIB_DIR) | |
9d756e3c | 156 | + |
0b72d562 | 157 | +update: $(LIB_DIR)/$(LIB) $(LIB_DIR)/${LDAPSO} $(HDRS) |
9d756e3c JB |
158 | -for i in $(HDRS); \ |
159 | do \ | |
160 | cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \ | |
0b72d562 | 161 | @@ -333,7 +341,7 @@ |
162 | lint $(DEFS) $(SRCS) $(LINTFIX) | |
9d756e3c JB |
163 | |
164 | clean: | |
0b72d562 | 165 | - rm -f *.o $(LIB) *core $(TESTPROG) junk |
166 | + rm -f *.o $(LIB) $(LDAPSO) dict_ldap.c *core $(TESTPROG) junk | |
9d756e3c JB |
167 | rm -rf printfck |
168 | ||
169 | tidy: clean | |
0b72d562 | 170 | @@ -508,6 +516,8 @@ |
171 | dict_proxy.o: mail_params.h | |
172 | dict_proxy.o: clnt_stream.h | |
173 | dict_proxy.o: dict_proxy.h | |
174 | +dict_ldap.o: dict_ldap.c | |
175 | +dict_ldap.o: ../../include/sys_defs.h | |
176 | domain_list.o: domain_list.c | |
177 | domain_list.o: ../../include/sys_defs.h | |
178 | domain_list.o: ../../include/match_list.h | |
179 | --- postfix-2.0.16.orig/src/master/Makefile.in 2003-09-14 02:04:02.000000000 +0200 | |
180 | +++ postfix-2.0.16/src/master/Makefile.in 2003-11-08 19:52:14.000000000 +0100 | |
181 | @@ -23,7 +23,7 @@ | |
182 | INC_DIR = ../../include | |
183 | BIN_DIR = ../../libexec | |
184 | ||
185 | -.c.o:; $(CC) $(CFLAGS) -c $*.c | |
186 | +.c.o:; $(CC) `for i in $(LIB_OBJ); do [ $$i = $@ ] && echo -fPIC; done` $(CFLAGS) -c $*.c | |
187 | ||
188 | all: $(PROG) $(LIB) | |
189 | ||
190 | @@ -38,12 +38,10 @@ | |
191 | tests: test | |
192 | ||
193 | $(LIB): $(LIB_OBJ) | |
194 | - $(AR) $(ARFL) $(LIB) $? | |
195 | - $(RANLIB) $(LIB) | |
196 | + gcc -shared -Wl,-soname,libpostfix-master.so.1 -o $(LIB) $(LIB_OBJ) | |
197 | ||
198 | $(LIB_DIR)/$(LIB): $(LIB) | |
199 | cp $(LIB) $(LIB_DIR)/$(LIB) | |
200 | - $(RANLIB) $(LIB_DIR)/$(LIB) | |
201 | ||
202 | $(BIN_DIR)/$(PROG): $(PROG) | |
203 | cp $(PROG) $(BIN_DIR) | |
204 | --- postfix-2.0.16.orig/src/util/dict.h 2003-01-05 02:03:28.000000000 +0100 | |
205 | +++ postfix-2.0.16/src/util/dict.h 2003-11-08 19:52:14.000000000 +0100 | |
206 | @@ -80,6 +80,20 @@ | |
9d756e3c JB |
207 | */ |
208 | extern ARGV *dict_mapnames(void); | |
209 | ||
210 | +#ifndef NO_DYNAMIC_MAPS | |
211 | + /* | |
212 | + * Interface for dynamic map loading. | |
213 | + */ | |
214 | +typedef struct { | |
215 | + const char *pattern; | |
216 | + const char *soname; | |
217 | + const char *openfunc; | |
218 | +} DLINFO; | |
219 | + | |
220 | +extern void dict_open_dlinfo(const char *path); | |
221 | +extern DLINFO *dict_open_dlfind(const char *type); | |
222 | +#endif | |
223 | + | |
224 | /* | |
225 | * High-level interface, with logical dictionary names. | |
226 | */ | |
0b72d562 | 227 | --- postfix-2.0.16.orig/src/util/dict_open.c 2003-11-08 19:49:41.000000000 +0100 |
228 | +++ postfix-2.0.16/src/util/dict_open.c 2003-11-08 19:52:14.000000000 +0100 | |
229 | @@ -158,6 +158,9 @@ | |
9d756e3c JB |
230 | #include <strings.h> |
231 | #endif | |
232 | ||
233 | +#include <sys/stat.h> | |
234 | +#include <unistd.h> | |
235 | + | |
236 | /* Utility library. */ | |
237 | ||
238 | #include <argv.h> | |
0b72d562 | 239 | @@ -182,6 +185,14 @@ |
9d756e3c JB |
240 | #include <split_at.h> |
241 | #include <htable.h> | |
242 | ||
243 | +#ifndef NO_DYNAMIC_MAPS | |
244 | +#include <load_lib.h> | |
245 | +#include <vstring.h> | |
246 | +#include <vstream.h> | |
247 | +#include <vstring_vstream.h> | |
248 | +#include <mvect.h> | |
249 | +#endif | |
250 | + | |
251 | /* | |
252 | * lookup table for available map types. | |
253 | */ | |
0b72d562 | 254 | @@ -213,6 +224,7 @@ |
9d756e3c JB |
255 | #ifdef HAS_NETINFO |
256 | DICT_TYPE_NETINFO, dict_ni_open, | |
257 | #endif | |
258 | +#ifndef MAX_DYNAMIC_MAPS | |
259 | #ifdef HAS_LDAP | |
260 | DICT_TYPE_LDAP, dict_ldap_open, | |
261 | #endif | |
0b72d562 | 262 | @@ -222,6 +234,7 @@ |
9d756e3c JB |
263 | #ifdef HAS_PCRE |
264 | DICT_TYPE_PCRE, dict_pcre_open, | |
265 | #endif | |
266 | +#endif /* MAX_DYNAMIC_MAPS */ | |
267 | #ifdef HAS_POSIX_REGEXP | |
268 | DICT_TYPE_REGEXP, dict_regexp_open, | |
269 | #endif | |
0b72d562 | 270 | @@ -275,8 +288,38 @@ |
9d756e3c JB |
271 | |
272 | if (dict_open_hash == 0) | |
273 | dict_open_init(); | |
274 | - if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) | |
275 | - msg_fatal("unsupported dictionary type: %s", dict_type); | |
276 | + if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) { | |
277 | +#ifndef NO_DYNAMIC_MAPS | |
278 | + struct stat st; | |
279 | + VSTRING *lib, *func; | |
280 | + LIB_FN fn[2]; | |
281 | + DICT *(*open) (const char *, int, int); | |
282 | + DLINFO *dl=dict_open_dlfind(dict_type); | |
283 | + if (!dl) | |
284 | +#endif | |
285 | + msg_fatal("%s: unsupported dictionary type: %s", myname, dict_type); | |
286 | +#ifndef NO_DYNAMIC_MAPS | |
287 | + lib=vstring_alloc(1); | |
288 | + vstring_sprintf(lib,dl->soname,dict_type); | |
289 | + if (stat(vstring_str(lib),&st) < 0) { | |
290 | + msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)", | |
291 | + myname, dict_type, vstring_str(lib), dict_type); | |
292 | + } | |
293 | + func=vstring_alloc(1); | |
294 | + vstring_sprintf(func,dl->openfunc,dict_type); | |
295 | + fn[0].name = vstring_str(func); | |
296 | + fn[0].ptr = (void**)&open; | |
297 | + fn[1].name = NULL; | |
298 | + load_library_symbols(vstring_str(lib), fn, NULL); | |
299 | + dict_open_register(dict_type, open); | |
300 | + dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type); | |
301 | + vstring_free(lib); | |
302 | + vstring_free(func); | |
303 | +#endif | |
304 | + } | |
305 | + if (msg_verbose>1) { | |
306 | + msg_info("%s: calling %s open routine",myname,dict_type); | |
307 | + } | |
308 | if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0) | |
309 | msg_fatal("opening %s:%s %m", dict_type, dict_name); | |
310 | if (msg_verbose) | |
0b72d562 | 311 | @@ -323,6 +366,76 @@ |
9d756e3c JB |
312 | return mapnames; |
313 | } | |
0b72d562 | 314 | |
9d756e3c JB |
315 | +#ifndef NO_DYNAMIC_MAPS |
316 | +static DLINFO *dict_dlinfo; | |
317 | + | |
318 | +void dict_open_dlinfo(const char *path) | |
319 | +{ | |
320 | + char *myname="dict_open_dlinfo"; | |
321 | + VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0); | |
322 | + VSTRING *buf = vstring_alloc(100); | |
323 | + char *cp; | |
324 | + ARGV *argv; | |
325 | + MVECT vector; | |
326 | + int nelm=0; | |
327 | + int linenum=0; | |
328 | + | |
329 | + dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL); | |
330 | + | |
331 | + if (!conf_fp) { | |
332 | + msg_warn("%s: cannot open %s. No dynamic maps will be allowed.", | |
333 | + myname, path); | |
334 | + } else { | |
335 | + while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) { | |
336 | + cp = vstring_str(buf); | |
337 | + linenum++; | |
338 | + if (*cp == '#' || *cp == '\0') | |
339 | + continue; | |
340 | + argv = argv_split(cp, " \t"); | |
341 | + if (argv->argc != 3) { | |
342 | + msg_fatal("%s: Expected \"pattern .so-name function\" at line %d", | |
343 | + myname, linenum); | |
344 | + } | |
345 | + if (argv->argv[1][0] != '/') { | |
346 | + msg_fatal("%s: .so name must begin with a \"/\" at line %d", | |
347 | + myname, linenum); | |
348 | + } | |
349 | + if (nelm >= vector.nelm) { | |
350 | + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3); | |
351 | + } | |
352 | + dict_dlinfo[nelm].pattern = mystrdup(argv->argv[0]); | |
353 | + dict_dlinfo[nelm].soname = mystrdup(argv->argv[1]); | |
354 | + dict_dlinfo[nelm].openfunc = mystrdup(argv->argv[2]); | |
355 | + nelm++; | |
356 | + argv_free(argv); | |
357 | + } | |
358 | + } | |
359 | + if (nelm >= vector.nelm) { | |
360 | + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1); | |
361 | + } | |
362 | + dict_dlinfo[nelm].pattern = NULL; | |
363 | + dict_dlinfo[nelm].soname = NULL; | |
364 | + dict_dlinfo[nelm].openfunc = NULL; | |
365 | + if (conf_fp) | |
366 | + vstream_fclose(conf_fp); | |
367 | + vstring_free(buf); | |
368 | +} | |
369 | + | |
370 | +DLINFO *dict_open_dlfind(const char *type) | |
371 | +{ | |
372 | + DLINFO *dp; | |
373 | + | |
374 | + if (!dict_dlinfo) | |
375 | + return NULL; | |
376 | + | |
377 | + for (dp=dict_dlinfo; dp->pattern; dp++) { | |
378 | + if (strcmp(dp->pattern,type)==0 || strcmp(dp->pattern,"*")==0) | |
379 | + return dp; | |
380 | + } | |
381 | + return NULL; | |
382 | +} | |
383 | +#endif /* !NO_DYNAMIC_MAPS */ | |
0b72d562 | 384 | + |
9d756e3c JB |
385 | #ifdef TEST |
386 | ||
0b72d562 | 387 | /* |
388 | --- postfix-2.0.16.orig/src/util/load_lib.c 1970-01-01 01:00:00.000000000 +0100 | |
389 | +++ postfix-2.0.16/src/util/load_lib.c 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
390 | @@ -0,0 +1,135 @@ |
391 | +/*++ | |
392 | +/* NAME | |
393 | +/* load_lib 3 | |
394 | +/* SUMMARY | |
395 | +/* library loading wrappers | |
396 | +/* SYNOPSIS | |
397 | +/* #include <load_lib.h> | |
398 | +/* | |
399 | +/* extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *); | |
400 | +/* const char *libname; | |
401 | +/* LIB_FN *libfuncs; | |
402 | +/* LIB_FN *libdata; | |
403 | +/* | |
404 | +/* DESCRIPTION | |
405 | +/* This module loads functions from libraries, returnine pointers | |
406 | +/* to the named functions. | |
407 | +/* | |
408 | +/* load_library_symbols() loads all of the desired functions, and | |
409 | +/* returns zero for success, or exits via msg_fatal(). | |
410 | +/* | |
411 | +/* SEE ALSO | |
412 | +/* msg(3) diagnostics interface | |
413 | +/* DIAGNOSTICS | |
414 | +/* Problems are reported via the msg(3) diagnostics routines: | |
415 | +/* library not found, symbols not found, other fatal errors. | |
416 | +/* LICENSE | |
417 | +/* .ad | |
418 | +/* .fi | |
419 | +/* The Secure Mailer license must be distributed with this software. | |
420 | +/* AUTHOR(S) | |
421 | +/* LaMont Jones | |
422 | +/* Hewlett-Packard Company | |
423 | +/* 3404 Harmony Road | |
424 | +/* Fort Collins, CO 80528, USA | |
425 | +/* | |
426 | +/* Wietse Venema | |
427 | +/* IBM T.J. Watson Research | |
428 | +/* P.O. Box 704 | |
429 | +/* Yorktown Heights, NY 10598, USA | |
430 | +/*--*/ | |
431 | + | |
432 | +/* System libraries. */ | |
433 | + | |
434 | +#include "sys_defs.h" | |
435 | +#include <stdlib.h> | |
436 | +#include <stddef.h> | |
437 | +#include <string.h> | |
438 | +#if defined(HAS_DLOPEN) | |
439 | +#include <dlfcn.h> | |
440 | +#elif defined(HAS_SHL_LOAD) | |
441 | +#include <dl.h> | |
442 | +#endif | |
443 | + | |
444 | +/* Application-specific. */ | |
445 | + | |
446 | +#include "msg.h" | |
447 | +#include "load_lib.h" | |
448 | + | |
449 | +extern int load_library_symbols(const char * libname, LIB_FN * libfuncs, LIB_FN * libdata) | |
450 | +{ | |
451 | + char *myname = "load_library_symbols"; | |
452 | + LIB_FN *fn; | |
453 | + | |
454 | +#if defined(HAS_DLOPEN) | |
455 | + void *handle; | |
456 | + char *emsg; | |
457 | + | |
458 | + handle=dlopen(libname,RTLD_NOW); | |
459 | + emsg=dlerror(); | |
460 | + if (emsg) { | |
461 | + msg_fatal("%s: dlopen failure loading %s: %s", myname, libname, emsg); | |
462 | + } | |
463 | + | |
464 | + if (libfuncs) { | |
465 | + for (fn=libfuncs; fn->name; fn++) { | |
466 | + *(fn->ptr) = dlsym(handle,fn->name); | |
467 | + emsg=dlerror(); | |
468 | + if (emsg) { | |
469 | + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname, | |
470 | + fn->name, libname, emsg); | |
471 | + } | |
472 | + if (msg_verbose>1) { | |
473 | + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr))); | |
474 | + } | |
475 | + } | |
476 | + } | |
477 | + | |
478 | + if (libdata) { | |
479 | + for (fn=libdata; fn->name; fn++) { | |
480 | + *(fn->ptr) = dlsym(handle,fn->name); | |
481 | + emsg=dlerror(); | |
482 | + if (emsg) { | |
483 | + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname, | |
484 | + fn->name, libname, emsg); | |
485 | + } | |
486 | + if (msg_verbose>1) { | |
487 | + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr))); | |
488 | + } | |
489 | + } | |
490 | + } | |
491 | +#elif defined(HAS_SHL_LOAD) | |
492 | + shl_t handle; | |
493 | + | |
494 | + handle = shl_load(libname,BIND_IMMEDIATE,0); | |
495 | + | |
496 | + if (libfuncs) { | |
497 | + for (fn=libfuncs; fn->name; fn++) { | |
498 | + if (shl_findsym(&handle,fn->name,TYPE_PROCEDURE,fn->ptr) != 0) { | |
499 | + msg_fatal("%s: shl_findsym failure looking up %s in %s: %m", | |
500 | + myname, fn->name, libname); | |
501 | + } | |
502 | + if (msg_verbose>1) { | |
503 | + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr))); | |
504 | + } | |
505 | + } | |
506 | + } | |
507 | + | |
508 | + if (libdata) { | |
509 | + for (fn=libdata; fn->name; fn++) { | |
510 | + if (shl_findsym(&handle,fn->name,TYPE_DATA,fn->ptr) != 0) { | |
511 | + msg_fatal("%s: shl_findsym failure looking up %s in %s: %m", | |
512 | + myname, fn->name, libname); | |
513 | + } | |
514 | + if (msg_verbose>1) { | |
515 | + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr))); | |
516 | + } | |
517 | + } | |
518 | + } | |
519 | + | |
520 | +#else | |
521 | + msg_fatal("%s: need dlopen or shl_load support for dynamic libraries", | |
522 | + myname); | |
523 | +#endif | |
524 | + return 0; | |
525 | +} | |
0b72d562 | 526 | --- postfix-2.0.16.orig/src/util/load_lib.h 1970-01-01 01:00:00.000000000 +0100 |
527 | +++ postfix-2.0.16/src/util/load_lib.h 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
528 | @@ -0,0 +1,41 @@ |
529 | +#ifndef _LOAD_LIB_H_INCLUDED_ | |
530 | +#define _LOAD_LIB_H_INCLUDED_ | |
531 | + | |
532 | +/*++ | |
533 | +/* NAME | |
534 | +/* load_lib 3h | |
535 | +/* SUMMARY | |
536 | +/* library loading wrappers | |
537 | +/* SYNOPSIS | |
538 | +/* #include "load_lib.h" | |
539 | +/* DESCRIPTION | |
540 | +/* .nf | |
541 | + | |
542 | + /* | |
543 | + * External interface. | |
544 | + */ | |
545 | +/* NULL name terminates list */ | |
546 | +typedef struct LIB_FN { | |
547 | + const char *name; | |
548 | + void **ptr; | |
549 | +} LIB_FN; | |
550 | + | |
551 | +extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *); | |
552 | + | |
553 | +/* LICENSE | |
554 | +/* .ad | |
555 | +/* .fi | |
556 | +/* The Secure Mailer license must be distributed with this software. | |
557 | +/* AUTHOR(S) | |
558 | +/* LaMont Jones | |
559 | +/* Hewlett-Packard Company | |
560 | +/* 3404 Harmony Road | |
561 | +/* Fort Collins, CO 80528, USA | |
562 | +/* | |
563 | +/* Wietse Venema | |
564 | +/* IBM T.J. Watson Research | |
565 | +/* P.O. Box 704 | |
566 | +/* Yorktown Heights, NY 10598, USA | |
567 | +/*--*/ | |
568 | + | |
569 | +#endif | |
0b72d562 | 570 | --- postfix-2.0.16.orig/src/util/Makefile.in 2003-11-08 19:49:41.000000000 +0100 |
571 | +++ postfix-2.0.16/src/util/Makefile.in 2003-11-08 19:55:55.000000000 +0100 | |
572 | @@ -3,7 +3,7 @@ | |
573 | attr_scan0.c attr_scan64.c base64_code.c basename.c binhash.c \ | |
574 | chroot_uid.c clean_env.c close_on_exec.c concatenate.c ctable.c \ | |
575 | dict.c dict_alloc.c dict_db.c dict_dbm.c dict_debug.c dict_env.c \ | |
576 | - dict_ht.c dict_ldap.c dict_mysql.c dict_ni.c dict_nis.c \ | |
577 | + dict_ht.c dict_mysql.c dict_ni.c dict_nis.c \ | |
578 | dict_nisplus.c dict_open.c dict_pcre.c dict_regexp.c dict_static.c \ | |
579 | dict_tcp.c dict_unix.c dir_forest.c doze.c duplex_pipe.c \ | |
580 | environ.c events.c exec_command.c fifo_listen.c fifo_trigger.c \ | |
581 | @@ -27,13 +27,13 @@ | |
582 | valid_hostname.c vbuf.c vbuf_print.c vstream.c vstream_popen.c \ | |
583 | vstring.c vstring_vstream.c watchdog.c writable.c write_buf.c \ | |
584 | write_wait.c strcasecmp.c nvtable.c host_port.c sane_connect.c \ | |
585 | - dict_sdbm.c sdbm.c | |
586 | + dict_sdbm.c sdbm.c load_lib.c | |
587 | OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \ | |
588 | attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \ | |
589 | chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \ | |
590 | dict.o dict_alloc.o dict_db.o dict_dbm.o dict_debug.o dict_env.o \ | |
591 | - dict_ht.o dict_ldap.o dict_mysql.o dict_ni.o dict_nis.o \ | |
592 | - dict_nisplus.o dict_open.o dict_pcre.o dict_regexp.o dict_static.o \ | |
593 | + dict_ht.o dict_ni.o dict_nis.o \ | |
594 | + dict_nisplus.o dict_open.o dict_regexp.o dict_static.o \ | |
595 | dict_tcp.o dict_unix.o dir_forest.o doze.o duplex_pipe.o \ | |
596 | environ.o events.o exec_command.o fifo_listen.o fifo_trigger.o \ | |
597 | file_limit.o find_inet.o fsspace.o fullname.o get_domainname.o \ | |
598 | @@ -56,7 +56,7 @@ | |
599 | valid_hostname.o vbuf.o vbuf_print.o vstream.o vstream_popen.o \ | |
600 | vstring.o vstring_vstream.o watchdog.o writable.o write_buf.o \ | |
c0adfb58 TO |
601 | write_wait.o nvtable.o host_port.o sane_connect.o $(STRCASE) \ |
602 | - dict_sdbm.o sdbm.o | |
603 | + dict_sdbm.o sdbm.o load_lib.o | |
0b72d562 | 604 | HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \ |
605 | connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \ | |
606 | dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \ | |
c0adfb58 | 607 | @@ -75,7 +75,7 @@ |
0b72d562 | 608 | timed_wait.h trigger.h username.h valid_hostname.h vbuf.h \ |
609 | vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h \ | |
c0adfb58 TO |
610 | nvtable.h host_port.h sane_connect.h \ |
611 | - dict_sdbm.h sdbm.h | |
612 | + dict_sdbm.h sdbm.h load_lib.h | |
0b72d562 | 613 | TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ |
614 | stream_test.c dup2_pass_on_exec.c | |
615 | WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ | |
616 | @@ -84,6 +84,8 @@ | |
617 | CFLAGS = $(DEBUG) $(OPT) $(DEFS) | |
618 | FILES = Makefile $(SRCS) $(HDRS) | |
619 | INCL = | |
620 | +PCRESO = dict_pcre.so | |
621 | +MYSQLSO = dict_mysql.so | |
622 | LIB = libutil.a | |
623 | TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \ | |
624 | fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \ | |
625 | @@ -96,8 +98,9 @@ | |
626 | ||
627 | LIB_DIR = ../../lib | |
628 | INC_DIR = ../../include | |
629 | +LIBS = $(LIB_DIR)/$(LIB) $(LIB_DIR)/$(PCRESO) $(LIB_DIR)/$(MYSQLSO) | |
630 | ||
631 | -.c.o:; $(CC) $(CFLAGS) -c $*.c | |
632 | +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c | |
633 | ||
634 | all: $(LIB) | |
635 | ||
636 | @@ -106,15 +109,25 @@ | |
637 | ||
638 | test: $(TESTPROG) | |
639 | ||
640 | +$(PCRESO): dict_pcre.o | |
641 | + gcc -shared -Wl,-soname,dict_pcre.so -o $@ $? -lpcre -L. -lutil | |
642 | + | |
643 | +$(MYSQLSO): dict_mysql.o | |
644 | + gcc -shared -Wl,-soname,dict_mysql.so -o $@ $? -lmysqlclient -L. -lutil | |
645 | + | |
646 | $(LIB): $(OBJS) | |
647 | - $(AR) $(ARFL) $(LIB) $? | |
648 | - $(RANLIB) $(LIB) | |
649 | + gcc -shared -Wl,-soname,libpostfix-util.so.1 -o $(LIB) $(OBJS) -ldl | |
650 | ||
651 | $(LIB_DIR)/$(LIB): $(LIB) | |
652 | cp $(LIB) $(LIB_DIR) | |
653 | - $(RANLIB) $(LIB_DIR)/$(LIB) | |
654 | ||
655 | -update: $(LIB_DIR)/$(LIB) $(HDRS) | |
656 | +$(LIB_DIR)/$(PCRESO): $(PCRESO) | |
657 | + cp $(PCRESO) $(LIB_DIR) | |
658 | + | |
659 | +$(LIB_DIR)/$(MYSQLSO): $(MYSQLSO) | |
660 | + cp $(MYSQLSO) $(LIB_DIR) | |
661 | + | |
662 | +update: $(LIBS) $(HDRS) | |
663 | -for i in $(HDRS); \ | |
664 | do \ | |
665 | cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \ | |
666 | @@ -136,7 +149,8 @@ | |
667 | lint $(SRCS) | |
668 | ||
669 | clean: | |
670 | - rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp | |
671 | + rm -f *.o $(LIB) $(PCRESO) $(MYSQLSO) *core $(TESTPROG) \ | |
672 | + junk $(MAKES) *.tmp | |
673 | rm -rf printfck | |
674 | ||
675 | tidy: clean | |
676 | --- postfix-2.0.16.orig/src/util/sys_defs.h 2003-11-08 19:49:41.000000000 +0100 | |
677 | +++ postfix-2.0.16/src/util/sys_defs.h 2003-11-08 19:52:14.000000000 +0100 | |
678 | @@ -501,6 +501,7 @@ | |
9d756e3c JB |
679 | #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT |
680 | #define PREPEND_PLUS_TO_OPTSTRING | |
681 | #define HAS_POSIX_REGEXP | |
682 | +#define HAS_DLOPEN | |
7e195e4d TO |
683 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
684 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
685 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 686 | @@ -529,6 +530,7 @@ |
7e195e4d TO |
687 | #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT /* unverified */ |
688 | #define PREPEND_PLUS_TO_OPTSTRING | |
9d756e3c JB |
689 | #define HAS_POSIX_REGEXP |
690 | +#define HAS_DLOPEN | |
7e195e4d TO |
691 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
692 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
693 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 694 | @@ -567,6 +569,7 @@ |
9d756e3c JB |
695 | #define USE_STATFS |
696 | #define STATFS_IN_SYS_VFS_H | |
697 | #define HAS_POSIX_REGEXP | |
698 | +#define HAS_SHL_LOAD | |
7e195e4d TO |
699 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
700 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
701 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 702 | @@ -602,6 +605,7 @@ |
9d756e3c JB |
703 | #define USE_STATFS |
704 | #define STATFS_IN_SYS_VFS_H | |
705 | #define HAS_POSIX_REGEXP | |
706 | +#define HAS_SHL_LOAD | |
7e195e4d TO |
707 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
708 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
709 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" |