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