aboutsummaryrefslogtreecommitdiffstats
path: root/main/postfix/postfix-2.7.1-dynamic-maps.patch
blob: bfc19a1524bd10b458e15f99e28f24a038580dd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
commit a6b79e8091c5e75d5d0a6b45b6652f0378583686
Author: Natanael Copa <ncopa@alpinelinux.org>
Date:   Tue Jul 6 08:16:25 2010 +0000

    patch for dynamic maps

diff --git a/conf/postfix-files b/conf/postfix-files
index 7ff93ea..7cae109 100644
--- a/conf/postfix-files
+++ b/conf/postfix-files
@@ -65,6 +65,10 @@ $queue_directory/saved:d:$mail_owner:-:700:ucr
 $queue_directory/trace:d:$mail_owner:-:700:ucr
 $daemon_directory/anvil:f:root:-:755
 $daemon_directory/bounce:f:root:-:755
+$daemon_directory/dict_ldap.so:f:root:-:755
+$daemon_directory/dict_pcre.so:f:root:-:755
+$daemon_directory/dict_mysql.so:f:root:-:755
+$daemon_directory/dict_pgsql.so:f:root:-:755
 $daemon_directory/cleanup:f:root:-:755
 $daemon_directory/discard:f:root:-:755
 $daemon_directory/error:f:root:-:755
@@ -94,6 +98,11 @@ $daemon_directory/tlsmgr:f:root:-:755
 $daemon_directory/trivial-rewrite:f:root:-:755
 $daemon_directory/verify:f:root:-:755
 $daemon_directory/virtual:f:root:-:755
+/usr/lib/libpostfix-dns.so.1:f:root:-:755
+/usr/lib/libpostfix-global.so.1:f:root:-:755
+/usr/lib/libpostfix-tls.so.1:f:root:-:755
+/usr/lib/libpostfix-master.so.1:f:root:-:755
+/usr/lib/libpostfix-util.so.1:f:root:-:755
 $daemon_directory/nqmgr:h:$daemon_directory/qmgr
 $daemon_directory/lmtp:h:$daemon_directory/smtp
 $command_directory/postalias:f:root:-:755
@@ -117,6 +126,7 @@ $config_directory/access:f:root:-:644:p1
 $config_directory/aliases:f:root:-:644:p1
 $config_directory/bounce.cf.default:f:root:-:644:1
 $config_directory/canonical:f:root:-:644:p1
+$config_directory/dynamicmaps.cf:f:root:-:644:p
 $config_directory/cidr_table:f:root:-:644:o
 $config_directory/generic:f:root:-:644:p1
 $config_directory/generics:f:root:-:644:o
diff --git a/src/dns/Makefile.in b/src/dns/Makefile.in
index bbc5e98..f70cb96 100644
--- a/src/dns/Makefile.in
+++ b/src/dns/Makefile.in
@@ -14,7 +14,7 @@ LIBS	= ../../lib/libutil.a
 LIB_DIR	= ../../lib
 INC_DIR	= ../../include
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) -fPIC $(CFLAGS) -c $*.c
 
 all: $(LIB)
 
@@ -31,12 +31,10 @@ tests:	test dns_rr_to_pa_test dns_rr_to_sa_test dns_sa_to_rr_test \
 root_tests:
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	gcc -shared -Wl,-soname,libpostfix-dns.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
 update: $(LIB_DIR)/$(LIB) $(HDRS)
 	-for i in $(HDRS); \
diff --git a/src/global/Makefile.in b/src/global/Makefile.in
index 56c9b6c..b0c83d6 100644
--- a/src/global/Makefile.in
+++ b/src/global/Makefile.in
@@ -34,7 +34,7 @@ OBJS	= abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \
 	canon_addr.o cfg_parser.o cleanup_strerror.o cleanup_strflags.o \
 	clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \
 	defer.o deliver_completed.o deliver_flock.o deliver_pass.o \
-	deliver_request.o dict_ldap.o dict_mysql.o dict_pgsql.o \
+	deliver_request.o \
 	dict_proxy.o domain_list.o dot_lockfile.o dot_lockfile_as.o \
 	dsb_scan.o dsn.o dsn_buf.o dsn_mask.o dsn_print.o dsn_util.o \
 	ehlo_mask.o ext_prop.o file_id.o flush_clnt.o header_opts.o \
@@ -104,10 +104,13 @@ LIBS	= ../../lib/libutil.a
 LIB_DIR	= ../../lib
 INC_DIR	= ../../include
 MAKES	=
+LDAPSO  = dict_ldap.so
+MYSQLSO = dict_mysql.so
+PGSQLSO = dict_pgsql.so
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) -fPIC $(CFLAGS) -c $*.c
 
-all: $(LIB)
+all: $(LIB) $(LDAPSO) $(MYSQLSO) $(PGSQLSO) 
 
 $(OBJS): ../../conf/makedefs.out
 
@@ -117,14 +120,30 @@ Makefile: Makefile.in
 test:	$(TESTPROG)
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	gcc -shared -Wl,-soname,libpostfix-global.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
+
+$(LDAPSO): dict_ldap.o $(LIB) ../../lib/libglobal.a
+	gcc -shared -Wl,-soname,dict_ldap.so -o $@ $? -lldap -llber -L../../lib -lutil -L. -lglobal
+
+$(MYSQLSO): dict_mysql.o $(LIB) ../../lib/libglobal.a
+	gcc -shared -Wl,-soname,dict_mysql.so -o $@ $? -lmysqlclient -L. -lutil -lglobal
+
+$(PGSQLSO): dict_pgsql.o $(LIB) ../../lib/libglobal.a
+	gcc -shared -Wl,-soname,dict_pgsql.so -o $@ $? -lpq -L. -lutil -lglobal
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
-update: $(LIB_DIR)/$(LIB) $(HDRS)
+../../libexec/$(LDAPSO): $(LDAPSO)
+	cp $(LDAPSO) ../../libexec
+
+../../libexec/$(MYSQLSO): $(MYSQLSO)
+	cp $(MYSQLSO) ../../libexec
+
+../../libexec/$(PGSQLSO): $(PGSQLSO)
+	cp $(PGSQLSO) ../../libexec
+
+update: $(LIB_DIR)/$(LIB) ../../libexec/$(LDAPSO) ../../libexec/$(MYSQLSO) ../../libexec/$(PGSQLSO) $(HDRS)
 	-for i in $(HDRS); \
 	do \
 	  cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
@@ -492,7 +511,7 @@ lint:
 	lint $(DEFS) $(SRCS) $(LINTFIX)
 
 clean:
-	rm -f *.o $(LIB) *core $(TESTPROG) junk
+	rm -f *.o $(LIB) $(LDAPSO) $(MYSQLSO) $(PGSQLSO) *core $(TESTPROG) junk
 	rm -rf printfck
 
 tidy:	clean
diff --git a/src/global/mail_conf.c b/src/global/mail_conf.c
index c5d3d43..feb7d66 100644
--- a/src/global/mail_conf.c
+++ b/src/global/mail_conf.c
@@ -182,6 +182,13 @@ void    mail_conf_suck(void)
     path = concatenate(var_config_dir, "/", "main.cf", (char *) 0);
     dict_load_file(CONFIG_DICT, path);
     myfree(path);
+
+#ifndef NO_DYNAMIC_MAPS
+    path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0);
+    dict_open_dlinfo(path);
+    myfree(path);
+#endif
+
 }
 
 /* mail_conf_flush - discard configuration dictionary */
diff --git a/src/global/mail_dict.c b/src/global/mail_dict.c
index 35ecffb..c1ff165 100644
--- a/src/global/mail_dict.c
+++ b/src/global/mail_dict.c
@@ -45,6 +45,7 @@ typedef struct {
 
 static const DICT_OPEN_INFO dict_open_info[] = {
     DICT_TYPE_PROXY, dict_proxy_open,
+#ifdef NO_DYNAMIC_MAPS
 #ifdef HAS_LDAP
     DICT_TYPE_LDAP, dict_ldap_open,
 #endif
@@ -54,6 +55,7 @@ static const DICT_OPEN_INFO dict_open_info[] = {
 #ifdef HAS_PGSQL
     DICT_TYPE_PGSQL, dict_pgsql_open,
 #endif
+#endif /* NO_DYNAMIC_MAPS */
     0,
 };
 
diff --git a/src/global/mail_params.c b/src/global/mail_params.c
index f5350a1..1bbad7a 100644
--- a/src/global/mail_params.c
+++ b/src/global/mail_params.c
@@ -79,6 +79,7 @@
 /*	char	*var_export_environ;
 /*	char	*var_debug_peer_list;
 /*	int	var_debug_peer_level;
+/*	int	var_command_maxtime;
 /*	int	var_in_flow_delay;
 /*	int	var_fault_inj_code;
 /*	char   *var_bounce_service;
@@ -265,6 +266,7 @@ char   *var_import_environ;
 char   *var_export_environ;
 char   *var_debug_peer_list;
 int     var_debug_peer_level;
+int	var_command_maxtime;
 int     var_fault_inj_code;
 char   *var_bounce_service;
 char   *var_cleanup_service;
@@ -276,6 +278,7 @@ char   *var_showq_service;
 char   *var_error_service;
 char   *var_flush_service;
 char   *var_verify_service;
+char   *var_scache_service;
 char   *var_trace_service;
 char   *var_proxymap_service;
 char   *var_proxywrite_service;
diff --git a/src/global/mkmap_open.c b/src/global/mkmap_open.c
index 69a0d57..eb8de71 100644
--- a/src/global/mkmap_open.c
+++ b/src/global/mkmap_open.c
@@ -81,7 +81,7 @@
   * We use a different table (in dict_open.c) when querying maps.
   */
 typedef struct {
-    char   *type;
+    const char   *type;
     MKMAP  *(*before_open) (const char *);
 } MKMAP_OPEN_INFO;
 
@@ -156,7 +156,16 @@ MKMAP  *mkmap_open(const char *type, const char *path,
      */
     for (mp = mkmap_types; /* void */ ; mp++) {
 	if (mp->type == 0)
+#ifndef NO_DYNAMIC_MAPS
+	{
+	    static MKMAP_OPEN_INFO oi;
+	    oi.before_open=(MKMAP*(*)(const char*))dict_mkmap_func(type);
+	    oi.type=type;
+	    mp=&oi;
+	}
+#else
 	    msg_fatal("unsupported map type: %s", type);
+#endif
 	if (strcmp(type, mp->type) == 0)
 	    break;
     }
diff --git a/src/master/Makefile.in b/src/master/Makefile.in
index 53f65bd..48ca35e 100644
--- a/src/master/Makefile.in
+++ b/src/master/Makefile.in
@@ -20,7 +20,7 @@ LIB_DIR	= ../../lib
 INC_DIR	= ../../include
 BIN_DIR	= ../../libexec
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) `for i in $(LIB_OBJ); do [ $$i = $@ ] && echo -fPIC; done` $(CFLAGS) -c $*.c
 
 all:	$(PROG) $(LIB)
 
@@ -39,12 +39,10 @@ tests:
 root_tests:
 
 $(LIB):	$(LIB_OBJ)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	gcc -shared -Wl,-soname,libpostfix-master.so.1 -o $(LIB) $(LIB_OBJ) $(LIBS) $(SYSLIBS)
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)/$(LIB)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
 $(BIN_DIR)/$(PROG): $(PROG)
 	 cp $(PROG) $(BIN_DIR)
diff --git a/src/milter/Makefile.in b/src/milter/Makefile.in
index c28263a..549b868 100644
--- a/src/milter/Makefile.in
+++ b/src/milter/Makefile.in
@@ -14,7 +14,7 @@ LIB_DIR	= ../../lib
 INC_DIR	= ../../include
 MAKES	=
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) -fPIC $(CFLAGS) -c $*.c
 
 all: $(LIB)
 
@@ -30,12 +30,10 @@ tests:
 root_tests:
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	 gcc -shared -Wl,-soname,libpostfix-milter.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
 update: $(LIB_DIR)/$(LIB) $(HDRS)
 	-for i in $(HDRS); \
diff --git a/src/postconf/postconf.c b/src/postconf/postconf.c
index d1ae434..dd604bb 100644
--- a/src/postconf/postconf.c
+++ b/src/postconf/postconf.c
@@ -965,6 +965,16 @@ static void show_maps(void)
 {
     ARGV   *maps_argv;
     int     i;
+#ifndef NO_DYNAMIC_MAPS
+    char   *path;
+    char   *config_dir;
+
+    var_config_dir = mystrdup((config_dir = safe_getenv(CONF_ENV_PATH)) != 0 ?
+			      config_dir : DEF_CONFIG_DIR);	/* XXX */
+    path = concatenate(var_config_dir, "/", "dynamicmaps.cf", (char *) 0);
+    dict_open_dlinfo(path);
+    myfree(path);
+#endif
 
     maps_argv = dict_mapnames();
     for (i = 0; i < maps_argv->argc; i++)
diff --git a/src/postmap/postmap.c b/src/postmap/postmap.c
index e956aed..712d041 100644
--- a/src/postmap/postmap.c
+++ b/src/postmap/postmap.c
@@ -5,7 +5,7 @@
 /*	Postfix lookup table management
 /* SYNOPSIS
 /* .fi
-/*	\fBpostmap\fR [\fB-Nbfhimnoprsvw\fR] [\fB-c \fIconfig_dir\fR]
+/*	\fBpostmap\fR [\fB-Nbfhimnoprsuvw\fR] [\fB-c \fIconfig_dir\fR]
 /*	[\fB-d \fIkey\fR] [\fB-q \fIkey\fR]
 /*		[\fIfile_type\fR:]\fIfile_name\fR ...
 /* DESCRIPTION
@@ -151,6 +151,8 @@
 /* .sp
 /*	This feature is available in Postfix version 2.2 and later,
 /*	and is not available for all database types.
+/* .IP \fB-u\fR
+/*     Upgrade the database to the current version.
 /* .IP \fB-v\fR
 /*	Enable verbose logging for debugging purposes. Multiple \fB-v\fR
 /*	options make the software increasingly verbose.
@@ -723,6 +725,18 @@ static void postmap_seq(const char *map_type, const char *map_name,
     dict_close(dict);
 }
 
+/* postmap_upgrade - upgrade a map */
+
+static int postmap_upgrade(const char *map_type, const char *map_name)
+{
+    DICT   *dict;
+
+    dict = dict_open3(map_type, map_name, O_RDWR,
+                       DICT_FLAG_LOCK|DICT_FLAG_UPGRADE);
+    dict_close(dict);
+    return (dict != 0);
+}
+
 /* usage - explain */
 
 static NORETURN usage(char *myname)
@@ -743,6 +757,7 @@ int     main(int argc, char **argv)
     int     postmap_flags = POSTMAP_FLAG_AS_OWNER | POSTMAP_FLAG_SAVE_PERM;
     int     open_flags = O_RDWR | O_CREAT | O_TRUNC;
     int     dict_flags = DICT_FLAG_DUP_WARN | DICT_FLAG_FOLD_FIX;
+    int     upgrade = 0;
     char   *query = 0;
     char   *delkey = 0;
     int     sequence = 0;
@@ -787,7 +802,7 @@ int     main(int argc, char **argv)
     /*
      * Parse JCL.
      */
-    while ((ch = GETOPT(argc, argv, "Nbc:d:fhimnopq:rsvw")) > 0) {
+    while ((ch = GETOPT(argc, argv, "Nbc:d:fhimnopq:rsuvw")) > 0) {
 	switch (ch) {
 	default:
 	    usage(argv[0]);
@@ -804,8 +819,8 @@ int     main(int argc, char **argv)
 		msg_fatal("out of memory");
 	    break;
 	case 'd':
-	    if (sequence || query || delkey)
-		msg_fatal("specify only one of -s -q or -d");
+	    if (sequence || query || delkey || upgrade)
+		msg_fatal("specify only one of -s -q -u or -d");
 	    delkey = optarg;
 	    break;
 	case 'f':
@@ -831,8 +846,8 @@ int     main(int argc, char **argv)
 	    postmap_flags &= ~POSTMAP_FLAG_SAVE_PERM;
 	    break;
 	case 'q':
-	    if (sequence || query || delkey)
-		msg_fatal("specify only one of -s -q or -d");
+	    if (sequence || query || delkey || upgrade)
+		msg_fatal("specify only one of -s -q -u or -d");
 	    query = optarg;
 	    break;
 	case 'r':
@@ -840,10 +855,15 @@ int     main(int argc, char **argv)
 	    dict_flags |= DICT_FLAG_DUP_REPLACE;
 	    break;
 	case 's':
-	    if (query || delkey)
-		msg_fatal("specify only one of -s or -q or -d");
+	    if (query || delkey || upgrade)
+		msg_fatal("specify only one of -s or -q or -u or -d");
 	    sequence = 1;
 	    break;
+       case 'u':
+           if (sequence || query || delkey || upgrade)
+               msg_fatal("specify only one of -s -q -u or -d");
+           upgrade=1;
+           break;
 	case 'v':
 	    msg_verbose++;
 	    break;
@@ -914,6 +934,21 @@ int     main(int argc, char **argv)
 	    exit(0);
 	}
 	exit(1);
+    } else if (upgrade) {                      /* Upgrade the map(s) */
+       int success = 1;
+       if (optind + 1 > argc)
+           usage(argv[0]);
+       while (optind < argc) {
+           if ((path_name = split_at(argv[optind], ':')) != 0) {
+               success &= postmap_upgrade(argv[optind], path_name);
+           } else {
+               success &= postmap_upgrade(var_db_type, path_name);
+           }
+           if (!success)
+               exit(1);
+           optind++;
+       }
+       exit(0);
     } else {					/* create/update map(s) */
 	if (optind + 1 > argc)
 	    usage(argv[0]);
diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in
index 1a8e26d..1f26fd8 100644
--- a/src/tls/Makefile.in
+++ b/src/tls/Makefile.in
@@ -22,7 +22,7 @@ LIB_DIR	= ../../lib
 INC_DIR	= ../../include
 MAKES	=
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) -fPIC $(CFLAGS) -c $*.c
 
 all: $(LIB)
 
@@ -38,12 +38,10 @@ tests:
 root_tests:
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	gcc -shared -Wl,-soname,libpostfix-tls.so.1 -o $(LIB) $(OBJS) $(LIBS) $(SYSLIBS)
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
 update: $(LIB_DIR)/$(LIB) $(HDRS)
 	-for i in $(HDRS); \
diff --git a/src/util/Makefile.in b/src/util/Makefile.in
index 653919c..21e918a 100644
--- a/src/util/Makefile.in
+++ b/src/util/Makefile.in
@@ -32,21 +32,22 @@ SRCS	= alldig.c allprint.c argv.c argv_split.c attr_clnt.c attr_print0.c \
 	write_buf.c write_wait.c sane_basename.c format_tv.c allspace.c \
 	allascii.c load_file.c killme_after.c vstream_tweak.c upass_connect.c \
 	upass_listen.c upass_trigger.c edit_file.c inet_windowsize.c \
-	unix_pass_fd_fix.c dict_cache.c
+	unix_pass_fd_fix.c dict_cache.c load_lib.c
 OBJS	= alldig.o allprint.o argv.o argv_split.o attr_clnt.o attr_print0.o \
 	attr_print64.o attr_print_plain.o attr_scan0.o attr_scan64.o \
 	attr_scan_plain.o auto_clnt.o base64_code.o basename.o binhash.o \
 	chroot_uid.o cidr_match.o clean_env.o close_on_exec.o concatenate.o \
 	ctable.o dict.o dict_alloc.o dict_cdb.o dict_cidr.o dict_db.o \
 	dict_dbm.o dict_debug.o dict_env.o dict_ht.o dict_ni.o dict_nis.o \
-	dict_nisplus.o dict_open.o dict_pcre.o dict_regexp.o dict_sdbm.o \
-	dict_static.o dict_tcp.o dict_unix.o dir_forest.o doze.o dummy_read.o \
+	dict_nisplus.o dict_open.o dict_regexp.o \
+	dict_static.o dict_unix.o dir_forest.o doze.o dummy_read.o \
 	dummy_write.o duplex_pipe.o environ.o events.o exec_command.o \
 	fifo_listen.o fifo_trigger.o file_limit.o find_inet.o fsspace.o \
 	fullname.o get_domainname.o get_hostname.o hex_code.o hex_quote.o \
 	host_port.o htable.o inet_addr_host.o inet_addr_list.o \
 	inet_addr_local.o inet_connect.o inet_listen.o inet_proto.o \
 	inet_trigger.o line_wrap.o lowercase.o lstat_as.o mac_expand.o \
+	load_lib.o \
 	mac_parse.o make_dirs.o mask_addr.o match_list.o match_ops.o msg.o \
 	msg_output.o msg_syslog.o msg_vstream.o mvect.o myaddrinfo.o myflock.o \
 	mymalloc.o myrand.o mystrtok.o name_code.o name_mask.o netstring.o \
@@ -80,7 +81,7 @@ HDRS	= argv.h attr.h attr_clnt.h auto_clnt.h base64_code.h binhash.h \
 	msg_output.h msg_syslog.h msg_vstream.h mvect.h myaddrinfo.h myflock.h \
 	mymalloc.h myrand.h name_code.h name_mask.h netstring.h nvtable.h \
 	open_as.h open_lock.h percentm.h posix_signals.h readlline.h ring.h \
-	safe.h safe_open.h sane_accept.h sane_connect.h sane_fsops.h \
+	safe.h safe_open.h sane_accept.h sane_connect.h sane_fsops.h load_lib.h \
 	sane_socketpair.h sane_time.h scan_dir.h set_eugid.h set_ugid.h \
 	sigdelay.h sock_addr.h spawn_command.h split_at.h stat_as.h \
 	stringops.h sys_defs.h timed_connect.h timed_wait.h trigger.h \
@@ -93,6 +94,7 @@ DEFS	= -I. -D$(SYSTYPE)
 CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
 FILES	= Makefile $(SRCS) $(HDRS)
 INCL	=
+PCRESO  = dict_pcre.so
 LIB	= libutil.a
 TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
 	fifo_rdonly_bug fifo_rdwr_bug fifo_trigger fsspace fullname \
@@ -108,10 +110,11 @@ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
 
 LIB_DIR	= ../../lib
 INC_DIR	= ../../include
+LIBS    = $(LIB_DIR)/$(LIB) $(PCRESO)
 
-.c.o:;	$(CC) $(CFLAGS) -c $*.c
+.c.o:;	$(CC) -fPIC $(CFLAGS) -c $*.c
 
-all: $(LIB)
+all: $(LIB) $(PCRESO)
 
 $(OBJS): ../../conf/makedefs.out
 
@@ -120,15 +123,19 @@ Makefile: Makefile.in
 
 test:	$(TESTPROG)
 
+$(PCRESO): dict_pcre.o libutil.a
+	gcc -shared -Wl,-soname,dict_pcre.so -o $@ $? -lpcre -L. -lutil
+
 $(LIB):	$(OBJS)
-	$(AR) $(ARFL) $(LIB) $?
-	$(RANLIB) $(LIB)
+	gcc -shared -Wl,-soname,libpostfix-util.so.1 -o $(LIB) $(OBJS) -ldl $(SYSLIBS)
 
 $(LIB_DIR)/$(LIB): $(LIB)
 	cp $(LIB) $(LIB_DIR)
-	$(RANLIB) $(LIB_DIR)/$(LIB)
 
-update: $(LIB_DIR)/$(LIB) $(HDRS)
+../../libexec/$(PCRESO): $(PCRESO)
+	cp $(PCRESO) ../../libexec
+
+update: $(LIBS) ../../libexec/$(PCRESO) $(HDRS)
 	-for i in $(HDRS); \
 	do \
 	  cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
@@ -150,7 +157,8 @@ lint:
 	lint $(SRCS)
 
 clean:
-	rm -f *.o $(LIB) *core $(TESTPROG) junk $(MAKES) *.tmp
+	rm -f *.o $(LIB) $(PCRESO) *core $(TESTPROG) \
+		junk $(MAKES) *.tmp
 	rm -rf printfck
 
 tidy:	clean
diff --git a/src/util/dict.h b/src/util/dict.h
index 9829d28..d7dc53c 100644
--- a/src/util/dict.h
+++ b/src/util/dict.h
@@ -66,6 +66,7 @@ extern DICT *dict_debug(DICT *);
 #define DICT_FLAG_NO_UNAUTH	(1<<13)	/* disallow unauthenticated data */
 #define DICT_FLAG_FOLD_FIX	(1<<14)	/* case-fold key with fixed-case map */
 #define DICT_FLAG_FOLD_MUL	(1<<15)	/* case-fold key with multi-case map */
+#define DICT_FLAG_UPGRADE	(1<<30) /* Upgrade the db */
 #define DICT_FLAG_FOLD_ANY	(DICT_FLAG_FOLD_FIX | DICT_FLAG_FOLD_MUL)
 
  /* IMPORTANT: Update the dict_mask[] table when the above changes */
@@ -138,6 +139,11 @@ extern const char *dict_eval(const char *, const char *, int);
 extern DICT *dict_open(const char *, int, int);
 extern DICT *dict_open3(const char *, const char *, int, int);
 extern void dict_open_register(const char *, DICT *(*) (const char *, int, int));
+#ifndef NO_DYNAMIC_MAPS
+extern void dict_open_dlinfo(const char *path);
+typedef void* (*dict_mkmap_func_t)(const char *);
+dict_mkmap_func_t dict_mkmap_func(const char *dict_type);
+#endif
 
 #define dict_get(dp, key)	((const char *) (dp)->lookup((dp), (key)))
 #define dict_put(dp, key, val)	(dp)->update((dp), (key), (val))
diff --git a/src/util/dict_db.c b/src/util/dict_db.c
index 9e82f9b..93264e6 100644
--- a/src/util/dict_db.c
+++ b/src/util/dict_db.c
@@ -675,6 +675,12 @@ static DICT *dict_db_open(const char *class, const char *path, int open_flags,
 	msg_fatal("set DB cache size %d: %m", dict_db_cache_size);
     if (type == DB_HASH && db->set_h_nelem(db, DICT_DB_NELM) != 0)
 	msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM);
+    if (dict_flags & DICT_FLAG_UPGRADE) {
+	if (msg_verbose)
+	    msg_info("upgrading database %s",db_path);
+	if ((errno = db->upgrade(db,db_path,0)) != 0)
+	    msg_fatal("upgrade of database %s: %m",db_path);
+    }
 #if DB_VERSION_MAJOR == 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR > 0)
     if ((errno = db->open(db, 0, db_path, 0, type, db_flags, 0644)) != 0)
 	msg_fatal("open database %s: %m", db_path);
diff --git a/src/util/dict_dbm.c b/src/util/dict_dbm.c
index 3603e44..adc5258 100644
--- a/src/util/dict_dbm.c
+++ b/src/util/dict_dbm.c
@@ -409,6 +409,10 @@ DICT   *dict_dbm_open(const char *path, int open_flags, int dict_flags)
     char   *dbm_path;
     int     lock_fd;
 
+#ifdef HAVE_GDBM
+    msg_fatal("%s: gdbm maps use locking that is incompatible with postfix.  Use a hash map instead.",
+		 path);
+#endif
     /*
      * Note: DICT_FLAG_LOCK is used only by programs that do fine-grained (in
      * the time domain) locking while accessing individual database records.
diff --git a/src/util/dict_open.c b/src/util/dict_open.c
index b807bc2..0f4e382 100644
--- a/src/util/dict_open.c
+++ b/src/util/dict_open.c
@@ -44,6 +44,8 @@
 /*	DICT	*(*open) (const char *, int, int);
 /*
 /*	ARGV	*dict_mapnames()
+/*
+/*	void (*)() dict_mkmap_func(const char *dict_type)
 /* DESCRIPTION
 /*	This module implements a low-level interface to multiple
 /*	physical dictionary types.
@@ -159,6 +161,9 @@
 /*
 /*	dict_mapnames() returns a sorted list with the names of all available
 /*	dictionary types.
+/*
+/*	dict_mkmap_func() returns a pointer to the mkmap setup function
+/*	for the given map type, as given in /etc/dynamicmaps.cf
 /* DIAGNOSTICS
 /*	Fatal error: open error, unsupported dictionary type, attempt to
 /*	update non-writable dictionary.
@@ -183,6 +188,9 @@
 #include <strings.h>
 #endif
 
+#include <sys/stat.h>
+#include <unistd.h>
+
 /* Utility library. */
 
 #include <argv.h>
@@ -208,6 +216,27 @@
 #include <split_at.h>
 #include <htable.h>
 
+#ifndef NO_DYNAMIC_MAPS
+#include <load_lib.h>
+#include <vstring.h>
+#include <vstream.h>
+#include <vstring_vstream.h>
+#include <mvect.h>
+
+ /*
+  * Interface for dynamic map loading.
+  */
+typedef struct {
+    const char  *pattern;
+    const char  *soname;
+    const char  *openfunc;
+    const char  *mkmapfunc;
+} DLINFO;
+
+static DLINFO *dict_dlinfo;
+static DLINFO *dict_open_dlfind(const char *type);
+#endif
+
  /*
   * lookup table for available map types.
   */
@@ -223,7 +252,9 @@ static const DICT_OPEN_INFO dict_open_info[] = {
     DICT_TYPE_ENVIRON, dict_env_open,
     DICT_TYPE_HT, dict_ht_open,
     DICT_TYPE_UNIX, dict_unix_open,
+#ifdef NO_DYNAMIC_MAPS
     DICT_TYPE_TCP, dict_tcp_open,
+#endif
 #ifdef HAS_SDBM
     DICT_TYPE_SDBM, dict_sdbm_open,
 #endif
@@ -243,9 +274,11 @@ static const DICT_OPEN_INFO dict_open_info[] = {
 #ifdef HAS_NETINFO
     DICT_TYPE_NETINFO, dict_ni_open,
 #endif
+#ifdef NO_DYNAMIC_MAPS
 #ifdef HAS_PCRE
     DICT_TYPE_PCRE, dict_pcre_open,
 #endif
+#endif /* NO_DYNAMIC_MAPS */
 #ifdef HAS_POSIX_REGEXP
     DICT_TYPE_REGEXP, dict_regexp_open,
 #endif
@@ -303,8 +336,31 @@ DICT   *dict_open3(const char *dict_type, const char *dict_name,
 		  dict_type, dict_name);
     if (dict_open_hash == 0)
 	dict_open_init();
-    if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0)
-	msg_fatal("unsupported dictionary type: %s", dict_type);
+    if ((dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type)) == 0) {
+#ifdef NO_DYNAMIC_MAPS
+	msg_fatal("%s: unsupported dictionary type: %s", myname, dict_type);
+#else
+	struct stat st;
+	LIB_FN fn[2];
+	DICT *(*open) (const char *, int, int);
+	DLINFO *dl=dict_open_dlfind(dict_type);
+	if (!dl)
+	    msg_fatal("%s: unsupported dictionary type: %s:  Is the postfix-%s package installed?", myname, dict_type, dict_type);
+	if (stat(dl->soname,&st) < 0) {
+	    msg_fatal("%s: unsupported dictionary type: %s (%s not found.  Is the postfix-%s package installed?)",
+		myname, dict_type, dl->soname, dict_type);
+	}
+	fn[0].name = dl->openfunc;
+	fn[0].ptr  = (void**)&open;
+	fn[1].name = NULL;
+	load_library_symbols(dl->soname, fn, NULL);
+	dict_open_register(dict_type, open);
+	dp = (DICT_OPEN_INFO *) htable_find(dict_open_hash, dict_type);
+#endif
+    }
+    if (msg_verbose>1) {
+	msg_info("%s: calling %s open routine",myname,dict_type);
+    }
     if ((dict = dp->open(dict_name, open_flags, dict_flags)) == 0)
 	msg_fatal("opening %s:%s %m", dict_type, dict_name);
     if (msg_verbose)
@@ -312,6 +368,36 @@ DICT   *dict_open3(const char *dict_type, const char *dict_name,
     return (dict);
 }
 
+dict_mkmap_func_t dict_mkmap_func(const char *dict_type)
+{
+    char   *myname="dict_mkmap_func";
+    struct stat st;
+    LIB_FN fn[2];
+    dict_mkmap_func_t mkmap;
+    DLINFO *dl;
+#ifndef NO_DYNAMIC_MAPS
+    if (!dict_dlinfo)
+	msg_fatal("dlinfo==NULL");
+    dl=dict_open_dlfind(dict_type);
+    if (!dl)
+	msg_fatal("%s: unsupported dictionary type: %s:  Is the postfix-%s package installed?", myname, dict_type, dict_type);
+    if (stat(dl->soname,&st) < 0) {
+	msg_fatal("%s: unsupported dictionary type: %s (%s not found.  Is the postfix-%s package installed?)",
+	    myname, dict_type, dl->soname, dict_type);
+    }
+    if (!dl->mkmapfunc)
+	msg_fatal("%s: unsupported dictionary type: %s does not allow map creation.", myname, dict_type);
+
+    fn[0].name = dl->mkmapfunc;
+    fn[0].ptr  = (void**)&mkmap;
+    fn[1].name = NULL;
+    load_library_symbols(dl->soname, fn, NULL);
+    return mkmap;
+#else
+    return (void(*)())NULL;
+#endif
+}
+
 /* dict_open_register - register dictionary type */
 
 void    dict_open_register(const char *type,
@@ -345,6 +431,9 @@ ARGV   *dict_mapnames()
     HTABLE_INFO **ht;
     DICT_OPEN_INFO *dp;
     ARGV   *mapnames;
+#ifndef NO_DYNAMIC_MAPS
+    DLINFO *dlp;
+#endif
 
     if (dict_open_hash == 0)
 	dict_open_init();
@@ -353,6 +442,13 @@ ARGV   *dict_mapnames()
 	dp = (DICT_OPEN_INFO *) ht[0]->value;
 	argv_add(mapnames, dp->type, ARGV_END);
     }
+#ifndef NO_DYNAMIC_MAPS
+    if (!dict_dlinfo)
+	msg_fatal("dlinfo==NULL");
+    for (dlp=dict_dlinfo; dlp->pattern; dlp++) {
+	argv_add(mapnames, dlp->pattern, ARGV_END);
+    }
+#endif
     qsort((void *) mapnames->argv, mapnames->argc, sizeof(mapnames->argv[0]),
 	  dict_sort_alpha_cpp);
     myfree((char *) ht_info);
@@ -360,6 +456,87 @@ ARGV   *dict_mapnames()
     return mapnames;
 }
 
+#ifndef NO_DYNAMIC_MAPS
+#define	STREQ(x,y) (x == y || (x[0] == y[0] && strcmp(x,y) == 0))
+
+void dict_open_dlinfo(const char *path)
+{
+    char    *myname="dict_open_dlinfo";
+    VSTREAM *conf_fp=vstream_fopen(path,O_RDONLY,0);
+    VSTRING *buf = vstring_alloc(100);
+    char    *cp;
+    ARGV    *argv;
+    MVECT    vector;
+    int      nelm=0;
+    int      linenum=0;
+
+    dict_dlinfo=(DLINFO*)mvect_alloc(&vector,sizeof(DLINFO),3,NULL,NULL);
+
+    if (!conf_fp) {
+	msg_warn("%s: cannot open %s.  No dynamic maps will be allowed.",
+		myname, path);
+    } else {
+	while (vstring_get_nonl(buf,conf_fp) != VSTREAM_EOF) {
+	    cp = vstring_str(buf);
+	    linenum++;
+	    if (*cp == '#' || *cp == '\0')
+		continue;
+	    argv = argv_split(cp, " \t");
+	    if (argv->argc != 3 && argv->argc != 4) {
+		msg_fatal("%s: Expected \"pattern .so-name open-function [mkmap-function]\" at line %d",
+			  myname, linenum);
+	    }
+	    if (STREQ(argv->argv[0],"*")) {
+		msg_warn("%s: wildcard dynamic map entry no longer supported.",
+			  myname);
+		continue;
+	    }
+	    if (argv->argv[1][0] != '/') {
+		msg_fatal("%s: .so name must begin with a \"/\" at line %d",
+			  myname, linenum);
+	    }
+	    if (nelm >= vector.nelm) {
+		dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+3);
+	    }
+	    dict_dlinfo[nelm].pattern  = mystrdup(argv->argv[0]);
+	    dict_dlinfo[nelm].soname   = mystrdup(argv->argv[1]);
+	    dict_dlinfo[nelm].openfunc = mystrdup(argv->argv[2]);
+	    if (argv->argc==4)
+		dict_dlinfo[nelm].mkmapfunc = mystrdup(argv->argv[3]);
+	    else
+		dict_dlinfo[nelm].mkmapfunc = NULL;
+	    nelm++;
+	    argv_free(argv);
+	}
+    }
+    if (nelm >= vector.nelm) {
+	dict_dlinfo=(DLINFO*)mvect_realloc(&vector,vector.nelm+1);
+    }
+    dict_dlinfo[nelm].pattern  = NULL;
+    dict_dlinfo[nelm].soname   = NULL;
+    dict_dlinfo[nelm].openfunc = NULL;
+    dict_dlinfo[nelm].mkmapfunc = NULL;
+    if (conf_fp)
+	vstream_fclose(conf_fp);
+    vstring_free(buf);
+}
+
+static DLINFO *dict_open_dlfind(const char *type)
+{
+    DLINFO *dp;
+
+    if (!dict_dlinfo)
+	return NULL;
+
+    for (dp=dict_dlinfo; dp->pattern; dp++) {
+	if (STREQ(dp->pattern,type))
+	    return dp;
+    }
+    return NULL;
+}
+
+#endif /* !NO_DYNAMIC_MAPS */
+
 #ifdef TEST
 
  /*
diff --git a/src/util/load_lib.c b/src/util/load_lib.c
new file mode 100644
index 0000000..b6526ef
--- /dev/null
+++ b/src/util/load_lib.c
@@ -0,0 +1,135 @@
+/*++
+/* NAME
+/*	load_lib 3
+/* SUMMARY
+/*	library loading wrappers
+/* SYNOPSIS
+/*	#include <load_lib.h>
+/*
+/*	extern int  load_library_symbols(const char *, LIB_FN *, LIB_FN *);
+/*	const char *libname;
+/*      LIB_FN     *libfuncs;
+/*      LIB_FN     *libdata;
+/*
+/* DESCRIPTION
+/*	This module loads functions from libraries, returnine pointers
+/*	to the named functions.
+/*
+/*	load_library_symbols() loads all of the desired functions, and
+/*	returns zero for success, or exits via msg_fatal().
+/*
+/* SEE ALSO
+/*	msg(3) diagnostics interface
+/* DIAGNOSTICS
+/*	Problems are reported via the msg(3) diagnostics routines:
+/*	library not found, symbols not found, other fatal errors.
+/* LICENSE
+/* .ad
+/* .fi
+/*	The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*	LaMont Jones
+/*	Hewlett-Packard Company
+/*	3404 Harmony Road
+/*	Fort Collins, CO 80528, USA
+/*
+/*	Wietse Venema
+/*	IBM T.J. Watson Research
+/*	P.O. Box 704
+/*	Yorktown Heights, NY 10598, USA
+/*--*/
+
+/* System libraries. */
+
+#include "sys_defs.h"
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#if defined(HAS_DLOPEN)
+#include <dlfcn.h>
+#elif defined(HAS_SHL_LOAD)
+#include <dl.h>
+#endif
+
+/* Application-specific. */
+
+#include "msg.h"
+#include "load_lib.h"
+
+extern int  load_library_symbols(const char * libname, LIB_FN * libfuncs, LIB_FN * libdata)
+{
+    char   *myname = "load_library_symbols";
+    LIB_FN *fn;
+
+#if defined(HAS_DLOPEN)
+    void   *handle;
+    char   *emsg;
+
+    handle=dlopen(libname,RTLD_NOW);
+    emsg=dlerror();
+    if (emsg) {
+	msg_fatal("%s: dlopen failure loading %s: %s", myname, libname, emsg);
+    }
+
+    if (libfuncs) {
+	for (fn=libfuncs; fn->name; fn++) {
+	    *(fn->ptr) = dlsym(handle,fn->name);
+	    emsg=dlerror();
+	    if (emsg) {
+		msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
+			  fn->name, libname, emsg);
+	    }
+	    if (msg_verbose>1) {
+		msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
+	    }
+	}
+    }
+
+    if (libdata) {
+	for (fn=libdata; fn->name; fn++) {
+	    *(fn->ptr) = dlsym(handle,fn->name);
+	    emsg=dlerror();
+	    if (emsg) {
+		msg_fatal("%s: dlsym failure looking up %s in %s: %s", myname,
+			  fn->name, libname, emsg);
+	    }
+	    if (msg_verbose>1) {
+		msg_info("loaded %s = %lx",fn->name, *((long*)(fn->ptr)));
+	    }
+	}
+    }
+#elif defined(HAS_SHL_LOAD)
+    shl_t   handle;
+
+    handle = shl_load(libname,BIND_IMMEDIATE,0);
+
+    if (libfuncs) {
+	for (fn=libfuncs; fn->name; fn++) {
+	    if (shl_findsym(&handle,fn->name,TYPE_PROCEDURE,fn->ptr) != 0) {
+		msg_fatal("%s: shl_findsym failure looking up %s in %s: %m",
+			  myname, fn->name, libname);
+	    }
+	    if (msg_verbose>1) {
+		msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
+	    }
+	}
+    }
+
+    if (libdata) {
+	for (fn=libdata; fn->name; fn++) {
+	    if (shl_findsym(&handle,fn->name,TYPE_DATA,fn->ptr) != 0) {
+		msg_fatal("%s: shl_findsym failure looking up %s in %s: %m",
+			  myname, fn->name, libname);
+	    }
+	    if (msg_verbose>1) {
+		msg_info("loaded %s = %x",fn->name, *((long*)(fn->ptr)));
+	    }
+	}
+    }
+
+#else
+    msg_fatal("%s: need dlopen or shl_load support for dynamic libraries",
+		myname);
+#endif
+    return 0;
+}
diff --git a/src/util/load_lib.h b/src/util/load_lib.h
new file mode 100644
index 0000000..adebd25
--- /dev/null
+++ b/src/util/load_lib.h
@@ -0,0 +1,41 @@
+#ifndef _LOAD_LIB_H_INCLUDED_
+#define _LOAD_LIB_H_INCLUDED_
+
+/*++
+/* NAME
+/*	load_lib 3h
+/* SUMMARY
+/*	library loading wrappers
+/* SYNOPSIS
+/*	#include "load_lib.h"
+/* DESCRIPTION
+/* .nf
+
+ /*
+  * External interface.
+  */
+/* NULL name terminates list */
+typedef struct LIB_FN {
+    const char *name;
+    void       **ptr;
+} LIB_FN;
+
+extern int  load_library_symbols(const char *, LIB_FN *, LIB_FN *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/*	The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*	LaMont Jones
+/*	Hewlett-Packard Company
+/*	3404 Harmony Road
+/*	Fort Collins, CO 80528, USA
+/*
+/*	Wietse Venema
+/*	IBM T.J. Watson Research
+/*	P.O. Box 704
+/*	Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif