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