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