1 --- postfix-1.1.3.orig/conf/dynamicmaps.cf
2 +++ postfix-1.1.3/conf/dynamicmaps.cf
4 +# Postfix dynamic maps configuration file.
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
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
17 INC_DIR = ../../include
19 -.c.o:; $(CC) $(CFLAGS) -c $*.c
20 +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
28 - $(AR) $(ARFL) $(LIB) $?
30 + gcc -shared -Wl,-soname,libpostfix-dns.so.1 -o $(LIB) $(OBJS)
32 $(LIB_DIR)/$(LIB): $(LIB)
34 - $(RANLIB) $(LIB_DIR)/$(LIB)
36 update: $(LIB_DIR)/$(LIB) $(HDRS)
38 --- postfix-1.1.3.orig/src/global/Makefile.in
39 +++ postfix-1.1.3/src/global/Makefile.in
42 INC_DIR = ../../include
44 +LDAPSO = dict_ldap.so
46 -.c.o:; $(CC) $(CFLAGS) -c $*.c
47 +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
55 - $(AR) $(ARFL) $(LIB) $?
57 + gcc -shared -Wl,-soname,libpostfix-global.so.1 -o $(LIB) $(OBJS)
59 +$(LDAPSO): dict_ldap.o
60 + gcc -shared -Wl,-soname,dict_ldap.so -o $@ $? -lldap -llber -L../../lib -lutil -L. -lglobal
62 +dict_ldap.c: ../util/dict_ldap.c
65 $(LIB_DIR)/$(LIB): $(LIB)
67 - $(RANLIB) $(LIB_DIR)/$(LIB)
69 -update: $(LIB_DIR)/$(LIB) $(HDRS)
70 +$(LIB_DIR)/$(LDAPSO): $(LDAPSO)
71 + cp $(LDAPSO) $(LIB_DIR)
73 +update: $(LIB_DIR)/$(LIB) $(LIB_DIR)/${LDAPSO} $(HDRS)
76 cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
78 lint $(DEFS) $(SRCS) $(LINTFIX)
81 - rm -f *.o $(LIB) *core $(TESTPROG) junk
82 + rm -f *.o $(LIB) $(LDAPSO) dict_ldap.c *core $(TESTPROG) junk
87 dict_proxy.o: mail_params.h
88 dict_proxy.o: clnt_stream.h
89 dict_proxy.o: dict_proxy.h
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
98 path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
99 dict_load_file(CONFIG_DICT, path);
102 +#ifndef NO_DYNAMIC_MAPS
103 + path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0);
104 + dict_open_dlinfo(path);
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
117 +#include <safe_open.h>
118 +#include <mymalloc.h>
120 /* Global library. */
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;
129 #define MAIN_CONF_FILE "main.cf"
131 (long) var_sgid_gid);
134 +static char *read_file(const char *name)
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);
142 + * Ugly macros to make complex expressions less unreadable.
144 +#define SKIP(start, var, cond) \
145 + for (var = start; *var && (cond); var++);
149 + for (p = (s) + strlen(s); p > (s) && ISSPACE(p[-1]); p--); \
154 + msg_fatal("%s: unable to open: %s",name,vstring_str(why));
156 + vstring_get_nonl(new_name,vp);
157 + vstream_fclose(vp);
158 + SKIP(vstring_str(new_name),ret,ISSPACE(*ret));
162 + vstring_free(new_name);
166 /* mail_params_init - configure built-in parameters */
168 void mail_params_init()
170 * Variables that are needed by almost every program.
172 get_mail_conf_str_table(other_str_defaults);
173 + if (*var_myorigin=='/') {
174 + var_myorigin=read_file(var_myorigin);
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
182 INC_DIR = ../../include
183 BIN_DIR = ../../libexec
185 -.c.o:; $(CC) $(CFLAGS) -c $*.c
186 +.c.o:; $(CC) `for i in $(LIB_OBJ); do [ $$i = $@ ] && echo -fPIC; done` $(CFLAGS) -c $*.c
194 - $(AR) $(ARFL) $(LIB) $?
196 + gcc -shared -Wl,-soname,libpostfix-master.so.1 -o $(LIB) $(LIB_OBJ)
198 $(LIB_DIR)/$(LIB): $(LIB)
199 cp $(LIB) $(LIB_DIR)/$(LIB)
200 - $(RANLIB) $(LIB_DIR)/$(LIB)
202 $(BIN_DIR)/$(PROG): $(PROG)
203 cp $(PROG) $(BIN_DIR)
204 --- postfix-1.1.5.orig/src/util/Makefile.in
205 +++ postfix-1.1.5/src/util/Makefile.in
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 \
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 \
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
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 \
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 \
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
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 \
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 \
247 nvtable.h host_port.h dict_sdbm.h sdbm.h
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
251 CFLAGS = $(DEBUG) $(OPT) $(DEFS)
252 FILES = Makefile $(SRCS) $(HDRS)
254 +PCRESO = dict_pcre.so
255 +MYSQLSO = dict_mysql.so
257 TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
258 fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \
262 INC_DIR = ../../include
263 +LIBS = $(LIB_DIR)/$(LIB) $(LIB_DIR)/$(PCRESO) $(LIB_DIR)/$(MYSQLSO)
265 -.c.o:; $(CC) $(CFLAGS) -c $*.c
266 +.c.o:; $(CC) -fPIC $(CFLAGS) -c $*.c
270 @@ -104,15 +107,25 @@
274 +$(PCRESO): dict_pcre.o
275 + gcc -shared -Wl,-soname,dict_pcre.so -o $@ $? -lpcre -L. -lutil
277 +$(MYSQLSO): dict_mysql.o
278 + gcc -shared -Wl,-soname,dict_mysql.so -o $@ $? -lmysqlclient -L. -lutil
281 - $(AR) $(ARFL) $(LIB) $?
283 + gcc -shared -Wl,-soname,libpostfix-util.so.1 -o $(LIB) $(OBJS) -ldl
285 $(LIB_DIR)/$(LIB): $(LIB)
287 - $(RANLIB) $(LIB_DIR)/$(LIB)
289 -update: $(LIB_DIR)/$(LIB) $(HDRS)
290 +$(LIB_DIR)/$(PCRESO): $(PCRESO)
291 + cp $(PCRESO) $(LIB_DIR)
293 +$(LIB_DIR)/$(MYSQLSO): $(MYSQLSO)
294 + cp $(MYSQLSO) $(LIB_DIR)
296 +update: $(LIBS) $(HDRS)
299 cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
304 - rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp
305 + rm -f *.o $(LIB) $(PCRESO) $(MYSQLSO) *core $(TESTPROG) \
306 + junk $(MAKES) *.tmp
310 --- postfix-1.1.3.orig/src/util/dict.h
311 +++ postfix-1.1.3/src/util/dict.h
314 extern ARGV *dict_mapnames(void);
316 +#ifndef NO_DYNAMIC_MAPS
318 + * Interface for dynamic map loading.
321 + const char *pattern;
322 + const char *soname;
323 + const char *openfunc;
326 +extern void dict_open_dlinfo(const char *path);
327 +extern DLINFO *dict_open_dlfind(const char *type);
331 * High-level interface, with logical dictionary names.
333 --- postfix-1.1.3.orig/src/util/dict_open.c
334 +++ postfix-1.1.3/src/util/dict_open.c
339 +#include <sys/stat.h>
342 /* Utility library. */
346 #include <split_at.h>
349 +#ifndef NO_DYNAMIC_MAPS
350 +#include <load_lib.h>
351 +#include <vstring.h>
352 +#include <vstream.h>
353 +#include <vstring_vstream.h>
358 * lookup table for available map types.
362 DICT_TYPE_NETINFO, dict_ni_open,
364 +#ifndef MAX_DYNAMIC_MAPS
366 DICT_TYPE_LDAP, dict_ldap_open,
370 DICT_TYPE_PCRE, dict_pcre_open,
372 +#endif /* MAX_DYNAMIC_MAPS */
373 #ifdef HAS_POSIX_REGEXP
374 DICT_TYPE_REGEXP, dict_regexp_open,
378 if (dict_open_hash == 0)
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
385 + VSTRING *lib, *func;
387 + DICT *(*open) (const char *, int, int);
388 + DLINFO *dl=dict_open_dlfind(dict_type);
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);
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;
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);
408 + vstring_free(func);
411 + if (msg_verbose>1) {
412 + msg_info("%s: calling %s open routine",myname,dict_type);
414 if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0)
415 msg_fatal("opening %s:%s %m", dict_type, dict_name);
418 argv_terminate(mapnames);
422 +#ifndef NO_DYNAMIC_MAPS
423 +static DLINFO *dict_dlinfo;
425 +void dict_open_dlinfo(const char *path)
427 + char *myname="dict_open_dlinfo";
428 + VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0);
429 + VSTRING *buf = vstring_alloc(100);
436 + dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL);
439 + msg_warn("%s: cannot open %s. No dynamic maps will be allowed.",
442 + while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) {
443 + cp = vstring_str(buf);
445 + if (*cp == '#' || *cp == '\0')
447 + argv = argv_split(cp, " \t");
448 + if (argv->argc != 3) {
449 + msg_fatal("%s: Expected \"pattern .so-name function\" at line %d",
452 + if (argv->argv[1][0] != '/') {
453 + msg_fatal("%s: .so name must begin with a \"/\" at line %d",
456 + if (nelm >= vector.nelm) {
457 + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3);
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]);
466 + if (nelm >= vector.nelm) {
467 + dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1);
469 + dict_dlinfo[nelm].pattern = NULL;
470 + dict_dlinfo[nelm].soname = NULL;
471 + dict_dlinfo[nelm].openfunc = NULL;
473 + vstream_fclose(conf_fp);
477 +DLINFO *dict_open_dlfind(const char *type)
484 + for (dp=dict_dlinfo; dp->pattern; dp++) {
485 + if (strcmp(dp->pattern,type)==0 || strcmp(dp->pattern,"*")==0)
490 +#endif /* !NO_DYNAMIC_MAPS */
494 --- postfix-1.1.3.orig/src/util/load_lib.c
495 +++ postfix-1.1.3/src/util/load_lib.c
501 +/* library loading wrappers
503 +/* #include <load_lib.h>
505 +/* extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *);
506 +/* const char *libname;
507 +/* LIB_FN *libfuncs;
511 +/* This module loads functions from libraries, returnine pointers
512 +/* to the named functions.
514 +/* load_library_symbols() loads all of the desired functions, and
515 +/* returns zero for success, or exits via msg_fatal().
518 +/* msg(3) diagnostics interface
520 +/* Problems are reported via the msg(3) diagnostics routines:
521 +/* library not found, symbols not found, other fatal errors.
525 +/* The Secure Mailer license must be distributed with this software.
528 +/* Hewlett-Packard Company
529 +/* 3404 Harmony Road
530 +/* Fort Collins, CO 80528, USA
533 +/* IBM T.J. Watson Research
535 +/* Yorktown Heights, NY 10598, USA
538 +/* System libraries. */
540 +#include "sys_defs.h"
544 +#if defined(HAS_DLOPEN)
546 +#elif defined(HAS_SHL_LOAD)
550 +/* Application-specific. */
553 +#include "load_lib.h"
555 +extern int load_library_symbols(const char * libname, LIB_FN * libfuncs, LIB_FN * libdata)
557 + char *myname = "load_library_symbols";
560 +#if defined(HAS_DLOPEN)
564 + handle=dlopen(libname,RTLD_NOW);
567 + msg_fatal("%s: dlopen failure loading %s: %s", myname, libname, emsg);
571 + for (fn=libfuncs; fn->name; fn++) {
572 + *(fn->ptr) = dlsym(handle,fn->name);
575 + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
576 + fn->name, libname, emsg);
578 + if (msg_verbose>1) {
579 + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
585 + for (fn=libdata; fn->name; fn++) {
586 + *(fn->ptr) = dlsym(handle,fn->name);
589 + msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
590 + fn->name, libname, emsg);
592 + if (msg_verbose>1) {
593 + msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
597 +#elif defined(HAS_SHL_LOAD)
600 + handle = shl_load(libname,BIND_IMMEDIATE,0);
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);
608 + if (msg_verbose>1) {
609 + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
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);
620 + if (msg_verbose>1) {
621 + msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
627 + msg_fatal("%s: need dlopen or shl_load support for dynamic libraries",
632 --- postfix-1.1.3.orig/src/util/load_lib.h
633 +++ postfix-1.1.3/src/util/load_lib.h
635 +#ifndef _LOAD_LIB_H_INCLUDED_
636 +#define _LOAD_LIB_H_INCLUDED_
642 +/* library loading wrappers
644 +/* #include "load_lib.h"
649 + * External interface.
651 +/* NULL name terminates list */
652 +typedef struct LIB_FN {
657 +extern int load_library_symbols(const char *, LIB_FN *, LIB_FN *);
662 +/* The Secure Mailer license must be distributed with this software.
665 +/* Hewlett-Packard Company
666 +/* 3404 Harmony Road
667 +/* Fort Collins, CO 80528, USA
670 +/* IBM T.J. Watson Research
672 +/* Yorktown Heights, NY 10598, USA
676 --- postfix-1.1.3.orig/src/util/sys_defs.h
677 +++ postfix-1.1.3/src/util/sys_defs.h
679 #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
680 #define PREPEND_PLUS_TO_OPTSTRING
681 #define HAS_POSIX_REGEXP
683 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
684 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
685 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
687 #define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT /* unverified */
688 #define PREPEND_PLUS_TO_OPTSTRING
689 #define HAS_POSIX_REGEXP
691 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
692 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
693 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
696 #define STATFS_IN_SYS_VFS_H
697 #define HAS_POSIX_REGEXP
698 +#define HAS_SHL_LOAD
699 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
700 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
701 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
704 #define STATFS_IN_SYS_VFS_H
705 #define HAS_POSIX_REGEXP
706 +#define HAS_SHL_LOAD
707 #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
708 #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
709 #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"