]>
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> | |
d3456591 | 239 | @@ -181,6 +184,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 | */ | |
d3456591 | 254 | @@ -212,9 +223,11 @@ |
9d756e3c JB |
255 | #ifdef HAS_NETINFO |
256 | DICT_TYPE_NETINFO, dict_ni_open, | |
257 | #endif | |
258 | +#ifndef MAX_DYNAMIC_MAPS | |
9d756e3c JB |
259 | #ifdef HAS_PCRE |
260 | DICT_TYPE_PCRE, dict_pcre_open, | |
261 | #endif | |
262 | +#endif /* MAX_DYNAMIC_MAPS */ | |
263 | #ifdef HAS_POSIX_REGEXP | |
264 | DICT_TYPE_REGEXP, dict_regexp_open, | |
265 | #endif | |
d3456591 | 266 | @@ -269,8 +282,38 @@ |
9d756e3c JB |
267 | |
268 | if (dict_open_hash == 0) | |
269 | dict_open_init(); | |
270 | - if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) | |
271 | - msg_fatal("unsupported dictionary type: %s", dict_type); | |
272 | + if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) { | |
273 | +#ifndef NO_DYNAMIC_MAPS | |
274 | + struct stat st; | |
275 | + VSTRING *lib, *func; | |
276 | + LIB_FN fn[2]; | |
277 | + DICT *(*open) (const char *, int, int); | |
278 | + DLINFO *dl=dict_open_dlfind(dict_type); | |
279 | + if (!dl) | |
280 | +#endif | |
281 | + msg_fatal("%s: unsupported dictionary type: %s", myname, dict_type); | |
282 | +#ifndef NO_DYNAMIC_MAPS | |
283 | + lib=vstring_alloc(1); | |
284 | + vstring_sprintf(lib,dl->soname,dict_type); | |
285 | + if (stat(vstring_str(lib),&st) < 0) { | |
286 | + msg_fatal("%s: unsupported dictionary type: %s (%s not found. Is the postfix-%s package installed?)", | |
287 | + myname, dict_type, vstring_str(lib), dict_type); | |
288 | + } | |
289 | + func=vstring_alloc(1); | |
290 | + vstring_sprintf(func,dl->openfunc,dict_type); | |
291 | + fn[0].name = vstring_str(func); | |
292 | + fn[0].ptr = (void**)&open; | |
293 | + fn[1].name = NULL; | |
294 | + load_library_symbols(vstring_str(lib), fn, NULL); | |
295 | + dict_open_register(dict_type, open); | |
296 | + dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type); | |
297 | + vstring_free(lib); | |
298 | + vstring_free(func); | |
299 | +#endif | |
300 | + } | |
301 | + if (msg_verbose>1) { | |
302 | + msg_info("%s: calling %s open routine",myname,dict_type); | |
303 | + } | |
304 | if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0) | |
305 | msg_fatal("opening %s:%s %m", dict_type, dict_name); | |
306 | if (msg_verbose) | |
d3456591 | 307 | @@ -317,6 +360,76 @@ |
9d756e3c JB |
308 | return mapnames; |
309 | } | |
0b72d562 | 310 | |
9d756e3c JB |
311 | +#ifndef NO_DYNAMIC_MAPS |
312 | +static DLINFO *dict_dlinfo; | |
313 | + | |
314 | +void dict_open_dlinfo(const char *path) | |
315 | +{ | |
316 | + char *myname="dict_open_dlinfo"; | |
317 | + VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0); | |
318 | + VSTRING *buf = vstring_alloc(100); | |
319 | + char *cp; | |
320 | + ARGV *argv; | |
321 | + MVECT vector; | |
322 | + int nelm=0; | |
323 | + int linenum=0; | |
324 | + | |
325 | + dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL); | |
326 | + | |
327 | + if (!conf_fp) { | |
328 | + msg_warn("%s: cannot open %s. No dynamic maps will be allowed.", | |
329 | + myname, path); | |
330 | + } else { | |
331 | + while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) { | |
332 | + cp = vstring_str(buf); | |
333 | + linenum++; | |
334 | + if (*cp == '#' || *cp == '\0') | |
335 | + continue; | |
336 | + argv = argv_split(cp, " \t"); | |
337 | + if (argv->argc != 3) { | |
338 | + msg_fatal("%s: Expected \"pattern .so-name function\" at line %d", | |
339 | + myname, linenum); | |
340 | + } | |
341 | + if (argv->argv[1][0] != '/') { | |
342 | + msg_fatal("%s: .so name must begin with a \"/\" at line %d", | |
343 | + myname, linenum); | |
344 | + } | |
345 | + if (nelm >= vector.nelm) { | |
346 | + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3); | |
347 | + } | |
348 | + dict_dlinfo[nelm].pattern = mystrdup(argv->argv[0]); | |
349 | + dict_dlinfo[nelm].soname = mystrdup(argv->argv[1]); | |
350 | + dict_dlinfo[nelm].openfunc = mystrdup(argv->argv[2]); | |
351 | + nelm++; | |
352 | + argv_free(argv); | |
353 | + } | |
354 | + } | |
355 | + if (nelm >= vector.nelm) { | |
356 | + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1); | |
357 | + } | |
358 | + dict_dlinfo[nelm].pattern = NULL; | |
359 | + dict_dlinfo[nelm].soname = NULL; | |
360 | + dict_dlinfo[nelm].openfunc = NULL; | |
361 | + if (conf_fp) | |
362 | + vstream_fclose(conf_fp); | |
363 | + vstring_free(buf); | |
364 | +} | |
365 | + | |
366 | +DLINFO *dict_open_dlfind(const char *type) | |
367 | +{ | |
368 | + DLINFO *dp; | |
369 | + | |
370 | + if (!dict_dlinfo) | |
371 | + return NULL; | |
372 | + | |
373 | + for (dp=dict_dlinfo; dp->pattern; dp++) { | |
374 | + if (strcmp(dp->pattern,type)==0 || strcmp(dp->pattern,"*")==0) | |
375 | + return dp; | |
376 | + } | |
377 | + return NULL; | |
378 | +} | |
379 | +#endif /* !NO_DYNAMIC_MAPS */ | |
0b72d562 | 380 | + |
9d756e3c JB |
381 | #ifdef TEST |
382 | ||
0b72d562 | 383 | /* |
384 | --- postfix-2.0.16.orig/src/util/load_lib.c 1970-01-01 01:00:00.000000000 +0100 | |
385 | +++ postfix-2.0.16/src/util/load_lib.c 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
386 | @@ -0,0 +1,135 @@ |
387 | +/*++ | |
388 | +/* NAME | |
389 | +/* load_lib 3 | |
390 | +/* SUMMARY | |
391 | +/* library loading wrappers | |
392 | +/* SYNOPSIS | |
393 | +/* #include <load_lib.h> | |
394 | +/* | |
395 | +/* extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *); | |
396 | +/* const char *libname; | |
397 | +/* LIB_FN *libfuncs; | |
398 | +/* LIB_FN *libdata; | |
399 | +/* | |
400 | +/* DESCRIPTION | |
401 | +/* This module loads functions from libraries, returnine pointers | |
402 | +/* to the named functions. | |
403 | +/* | |
404 | +/* load_library_symbols() loads all of the desired functions, and | |
405 | +/* returns zero for success, or exits via msg_fatal(). | |
406 | +/* | |
407 | +/* SEE ALSO | |
408 | +/* msg(3) diagnostics interface | |
409 | +/* DIAGNOSTICS | |
410 | +/* Problems are reported via the msg(3) diagnostics routines: | |
411 | +/* library not found, symbols not found, other fatal errors. | |
412 | +/* LICENSE | |
413 | +/* .ad | |
414 | +/* .fi | |
415 | +/* The Secure Mailer license must be distributed with this software. | |
416 | +/* AUTHOR(S) | |
417 | +/* LaMont Jones | |
418 | +/* Hewlett-Packard Company | |
419 | +/* 3404 Harmony Road | |
420 | +/* Fort Collins, CO 80528, USA | |
421 | +/* | |
422 | +/* Wietse Venema | |
423 | +/* IBM T.J. Watson Research | |
424 | +/* P.O. Box 704 | |
425 | +/* Yorktown Heights, NY 10598, USA | |
426 | +/*--*/ | |
427 | + | |
428 | +/* System libraries. */ | |
429 | + | |
430 | +#include "sys_defs.h" | |
431 | +#include <stdlib.h> | |
432 | +#include <stddef.h> | |
433 | +#include <string.h> | |
434 | +#if defined(HAS_DLOPEN) | |
435 | +#include <dlfcn.h> | |
436 | +#elif defined(HAS_SHL_LOAD) | |
437 | +#include <dl.h> | |
438 | +#endif | |
439 | + | |
440 | +/* Application-specific. */ | |
441 | + | |
442 | +#include "msg.h" | |
443 | +#include "load_lib.h" | |
444 | + | |
445 | +extern int load_library_symbols(const char * libname, LIB_FN * libfuncs, LIB_FN * libdata) | |
446 | +{ | |
447 | + char *myname = "load_library_symbols"; | |
448 | + LIB_FN *fn; | |
449 | + | |
450 | +#if defined(HAS_DLOPEN) | |
451 | + void *handle; | |
452 | + char *emsg; | |
453 | + | |
454 | + handle=dlopen(libname,RTLD_NOW); | |
455 | + emsg=dlerror(); | |
456 | + if (emsg) { | |
457 | + msg_fatal("%s: dlopen failure loading %s: %s", myname, libname, emsg); | |
458 | + } | |
459 | + | |
460 | + if (libfuncs) { | |
461 | + for (fn=libfuncs; fn->name; fn++) { | |
462 | + *(fn->ptr) = dlsym(handle,fn->name); | |
463 | + emsg=dlerror(); | |
464 | + if (emsg) { | |
465 | + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname, | |
466 | + fn->name, libname, emsg); | |
467 | + } | |
468 | + if (msg_verbose>1) { | |
469 | + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr))); | |
470 | + } | |
471 | + } | |
472 | + } | |
473 | + | |
474 | + if (libdata) { | |
475 | + for (fn=libdata; fn->name; fn++) { | |
476 | + *(fn->ptr) = dlsym(handle,fn->name); | |
477 | + emsg=dlerror(); | |
478 | + if (emsg) { | |
479 | + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname, | |
480 | + fn->name, libname, emsg); | |
481 | + } | |
482 | + if (msg_verbose>1) { | |
483 | + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr))); | |
484 | + } | |
485 | + } | |
486 | + } | |
487 | +#elif defined(HAS_SHL_LOAD) | |
488 | + shl_t handle; | |
489 | + | |
490 | + handle = shl_load(libname,BIND_IMMEDIATE,0); | |
491 | + | |
492 | + if (libfuncs) { | |
493 | + for (fn=libfuncs; fn->name; fn++) { | |
494 | + if (shl_findsym(&handle,fn->name,TYPE_PROCEDURE,fn->ptr) != 0) { | |
495 | + msg_fatal("%s: shl_findsym failure looking up %s in %s: %m", | |
496 | + myname, fn->name, libname); | |
497 | + } | |
498 | + if (msg_verbose>1) { | |
499 | + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr))); | |
500 | + } | |
501 | + } | |
502 | + } | |
503 | + | |
504 | + if (libdata) { | |
505 | + for (fn=libdata; fn->name; fn++) { | |
506 | + if (shl_findsym(&handle,fn->name,TYPE_DATA,fn->ptr) != 0) { | |
507 | + msg_fatal("%s: shl_findsym failure looking up %s in %s: %m", | |
508 | + myname, fn->name, libname); | |
509 | + } | |
510 | + if (msg_verbose>1) { | |
511 | + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr))); | |
512 | + } | |
513 | + } | |
514 | + } | |
515 | + | |
516 | +#else | |
517 | + msg_fatal("%s: need dlopen or shl_load support for dynamic libraries", | |
518 | + myname); | |
519 | +#endif | |
520 | + return 0; | |
521 | +} | |
0b72d562 | 522 | --- postfix-2.0.16.orig/src/util/load_lib.h 1970-01-01 01:00:00.000000000 +0100 |
523 | +++ postfix-2.0.16/src/util/load_lib.h 2003-11-08 19:52:14.000000000 +0100 | |
9d756e3c JB |
524 | @@ -0,0 +1,41 @@ |
525 | +#ifndef _LOAD_LIB_H_INCLUDED_ | |
526 | +#define _LOAD_LIB_H_INCLUDED_ | |
527 | + | |
528 | +/*++ | |
529 | +/* NAME | |
530 | +/* load_lib 3h | |
531 | +/* SUMMARY | |
532 | +/* library loading wrappers | |
533 | +/* SYNOPSIS | |
534 | +/* #include "load_lib.h" | |
535 | +/* DESCRIPTION | |
536 | +/* .nf | |
537 | + | |
538 | + /* | |
539 | + * External interface. | |
540 | + */ | |
541 | +/* NULL name terminates list */ | |
542 | +typedef struct LIB_FN { | |
543 | + const char *name; | |
544 | + void **ptr; | |
545 | +} LIB_FN; | |
546 | + | |
547 | +extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *); | |
548 | + | |
549 | +/* LICENSE | |
550 | +/* .ad | |
551 | +/* .fi | |
552 | +/* The Secure Mailer license must be distributed with this software. | |
553 | +/* AUTHOR(S) | |
554 | +/* LaMont Jones | |
555 | +/* Hewlett-Packard Company | |
556 | +/* 3404 Harmony Road | |
557 | +/* Fort Collins, CO 80528, USA | |
558 | +/* | |
559 | +/* Wietse Venema | |
560 | +/* IBM T.J. Watson Research | |
561 | +/* P.O. Box 704 | |
562 | +/* Yorktown Heights, NY 10598, USA | |
563 | +/*--*/ | |
564 | + | |
565 | +#endif | |
0b72d562 | 566 | --- postfix-2.0.16.orig/src/util/Makefile.in 2003-11-08 19:49:41.000000000 +0100 |
567 | +++ postfix-2.0.16/src/util/Makefile.in 2003-11-08 19:55:55.000000000 +0100 | |
568 | @@ -3,7 +3,7 @@ | |
569 | attr_scan0.c attr_scan64.c base64_code.c basename.c binhash.c \ | |
570 | chroot_uid.c clean_env.c close_on_exec.c concatenate.c ctable.c \ | |
571 | dict.c dict_alloc.c dict_db.c dict_dbm.c dict_debug.c dict_env.c \ | |
572 | - dict_ht.c dict_ldap.c dict_mysql.c dict_ni.c dict_nis.c \ | |
573 | + dict_ht.c dict_mysql.c dict_ni.c dict_nis.c \ | |
574 | dict_nisplus.c dict_open.c dict_pcre.c dict_regexp.c dict_static.c \ | |
575 | dict_tcp.c dict_unix.c dir_forest.c doze.c duplex_pipe.c \ | |
576 | environ.c events.c exec_command.c fifo_listen.c fifo_trigger.c \ | |
577 | @@ -27,13 +27,13 @@ | |
578 | valid_hostname.c vbuf.c vbuf_print.c vstream.c vstream_popen.c \ | |
579 | vstring.c vstring_vstream.c watchdog.c writable.c write_buf.c \ | |
580 | write_wait.c strcasecmp.c nvtable.c host_port.c sane_connect.c \ | |
581 | - dict_sdbm.c sdbm.c | |
582 | + dict_sdbm.c sdbm.c load_lib.c | |
583 | OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \ | |
584 | attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \ | |
585 | chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \ | |
586 | dict.o dict_alloc.o dict_db.o dict_dbm.o dict_debug.o dict_env.o \ | |
587 | - dict_ht.o dict_ldap.o dict_mysql.o dict_ni.o dict_nis.o \ | |
588 | - dict_nisplus.o dict_open.o dict_pcre.o dict_regexp.o dict_static.o \ | |
589 | + dict_ht.o dict_ni.o dict_nis.o \ | |
590 | + dict_nisplus.o dict_open.o dict_regexp.o dict_static.o \ | |
591 | dict_tcp.o dict_unix.o dir_forest.o doze.o duplex_pipe.o \ | |
592 | environ.o events.o exec_command.o fifo_listen.o fifo_trigger.o \ | |
593 | file_limit.o find_inet.o fsspace.o fullname.o get_domainname.o \ | |
594 | @@ -56,7 +56,7 @@ | |
595 | valid_hostname.o vbuf.o vbuf_print.o vstream.o vstream_popen.o \ | |
596 | vstring.o vstring_vstream.o watchdog.o writable.o write_buf.o \ | |
c0adfb58 TO |
597 | write_wait.o nvtable.o host_port.o sane_connect.o $(STRCASE) \ |
598 | - dict_sdbm.o sdbm.o | |
599 | + dict_sdbm.o sdbm.o load_lib.o | |
0b72d562 | 600 | HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \ |
601 | connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \ | |
602 | dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \ | |
c0adfb58 | 603 | @@ -75,7 +75,7 @@ |
0b72d562 | 604 | timed_wait.h trigger.h username.h valid_hostname.h vbuf.h \ |
605 | vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h \ | |
c0adfb58 TO |
606 | nvtable.h host_port.h sane_connect.h \ |
607 | - dict_sdbm.h sdbm.h | |
608 | + dict_sdbm.h sdbm.h load_lib.h | |
0b72d562 | 609 | TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ |
610 | stream_test.c dup2_pass_on_exec.c | |
611 | WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ | |
612 | @@ -84,6 +84,8 @@ | |
613 | CFLAGS = $(DEBUG) $(OPT) $(DEFS) | |
614 | FILES = Makefile $(SRCS) $(HDRS) | |
615 | INCL = | |
616 | +PCRESO = dict_pcre.so | |
617 | +MYSQLSO = dict_mysql.so | |
618 | LIB = libutil.a | |
619 | TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \ | |
620 | fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \ | |
621 | @@ -96,8 +98,9 @@ | |
622 | ||
623 | LIB_DIR = ../../lib | |
624 | INC_DIR = ../../include | |
625 | +LIBS = $(LIB_DIR)/$(LIB) $(LIB_DIR)/$(PCRESO) $(LIB_DIR)/$(MYSQLSO) | |
626 | ||
627 | -.c.o:; $(CC) $(CFLAGS) -c $*.c | |
628 | +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c | |
629 | ||
630 | all: $(LIB) | |
631 | ||
632 | @@ -106,15 +109,25 @@ | |
633 | ||
634 | test: $(TESTPROG) | |
635 | ||
636 | +$(PCRESO): dict_pcre.o | |
637 | + gcc -shared -Wl,-soname,dict_pcre.so -o $@ $? -lpcre -L. -lutil | |
638 | + | |
639 | +$(MYSQLSO): dict_mysql.o | |
640 | + gcc -shared -Wl,-soname,dict_mysql.so -o $@ $? -lmysqlclient -L. -lutil | |
641 | + | |
642 | $(LIB): $(OBJS) | |
643 | - $(AR) $(ARFL) $(LIB) $? | |
644 | - $(RANLIB) $(LIB) | |
645 | + gcc -shared -Wl,-soname,libpostfix-util.so.1 -o $(LIB) $(OBJS) -ldl | |
646 | ||
647 | $(LIB_DIR)/$(LIB): $(LIB) | |
648 | cp $(LIB) $(LIB_DIR) | |
649 | - $(RANLIB) $(LIB_DIR)/$(LIB) | |
650 | ||
651 | -update: $(LIB_DIR)/$(LIB) $(HDRS) | |
652 | +$(LIB_DIR)/$(PCRESO): $(PCRESO) | |
653 | + cp $(PCRESO) $(LIB_DIR) | |
654 | + | |
655 | +$(LIB_DIR)/$(MYSQLSO): $(MYSQLSO) | |
656 | + cp $(MYSQLSO) $(LIB_DIR) | |
657 | + | |
658 | +update: $(LIBS) $(HDRS) | |
659 | -for i in $(HDRS); \ | |
660 | do \ | |
661 | cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \ | |
662 | @@ -136,7 +149,8 @@ | |
663 | lint $(SRCS) | |
664 | ||
665 | clean: | |
666 | - rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp | |
667 | + rm -f *.o $(LIB) $(PCRESO) $(MYSQLSO) *core $(TESTPROG) \ | |
668 | + junk $(MAKES) *.tmp | |
669 | rm -rf printfck | |
670 | ||
671 | tidy: clean | |
672 | --- postfix-2.0.16.orig/src/util/sys_defs.h 2003-11-08 19:49:41.000000000 +0100 | |
673 | +++ postfix-2.0.16/src/util/sys_defs.h 2003-11-08 19:52:14.000000000 +0100 | |
674 | @@ -501,6 +501,7 @@ | |
9d756e3c JB |
675 | #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT |
676 | #define PREPEND_PLUS_TO_OPTSTRING | |
677 | #define HAS_POSIX_REGEXP | |
678 | +#define HAS_DLOPEN | |
7e195e4d TO |
679 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
680 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
681 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 682 | @@ -529,6 +530,7 @@ |
7e195e4d TO |
683 | #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT /* unverified */ |
684 | #define PREPEND_PLUS_TO_OPTSTRING | |
9d756e3c JB |
685 | #define HAS_POSIX_REGEXP |
686 | +#define HAS_DLOPEN | |
7e195e4d TO |
687 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
688 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
689 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 690 | @@ -567,6 +569,7 @@ |
9d756e3c JB |
691 | #define USE_STATFS |
692 | #define STATFS_IN_SYS_VFS_H | |
693 | #define HAS_POSIX_REGEXP | |
694 | +#define HAS_SHL_LOAD | |
7e195e4d TO |
695 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
696 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
697 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" | |
0b72d562 | 698 | @@ -602,6 +605,7 @@ |
9d756e3c JB |
699 | #define USE_STATFS |
700 | #define STATFS_IN_SYS_VFS_H | |
701 | #define HAS_POSIX_REGEXP | |
702 | +#define HAS_SHL_LOAD | |
7e195e4d TO |
703 | #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail" |
704 | #define NATIVE_MAILQ_PATH "/usr/bin/mailq" | |
705 | #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases" |