ldap_routing.m4 revision 203004
1divert(-1)
2#
3# Copyright (c) 1999-2002, 2004, 2007, 2009 Sendmail, Inc. and its suppliers.
4#	All rights reserved.
5#
6# By using this file, you agree to the terms and conditions set
7# forth in the LICENSE file which can be found at the top level of
8# the sendmail distribution.
9#
10#
11
12divert(0)
13VERSIONID(`$Id: ldap_routing.m4,v 8.17 2009/06/26 21:11:08 ca Exp $')
14divert(-1)
15
16# Check first two arguments.  If they aren't set, may need to warn in proto.m4
17ifelse(len(X`'_ARG1_), `1', `define(`_LDAP_ROUTING_WARN_', `yes')')
18ifelse(len(X`'_ARG2_), `1', `define(`_LDAP_ROUTING_WARN_', `yes')')
19ifelse(len(X`'_ARG5_), `1', `', `define(`_LDAP_ROUTE_NODOMAIN_', `yes')')
20
21# Check for third argument to indicate how to deal with non-existant
22# LDAP records
23ifelse(len(X`'_ARG3_), `1', `define(`_LDAP_ROUTING_', `_PASS_THROUGH_')',
24       _ARG3_, `passthru', `define(`_LDAP_ROUTING_', `_PASS_THROUGH_')',
25       _ARG3_, `sendertoo', `define(`_LDAP_ROUTING_', `_MUST_EXIST_')define(`_LDAP_SENDER_MUST_EXIST_')',
26       `define(`_LDAP_ROUTING_', `_MUST_EXIST_')')
27
28# Check for fourth argument to indicate how to deal with +detail info
29ifelse(len(X`'_ARG4_), `1', `',
30       _ARG4_, `strip', `define(`_LDAP_ROUTE_DETAIL_', `_STRIP_')',
31       _ARG4_, `preserve', `define(`_LDAP_ROUTE_DETAIL_', `_PRESERVE_')')
32
33# Check for sixth argument to indicate how to deal with tempfails
34ifelse(len(X`'_ARG6_), `1', `define(`_LDAP_ROUTE_MAPTEMP_', `_QUEUE_')',
35       _ARG6_, `tempfail', `define(`_LDAP_ROUTE_MAPTEMP_', `_TEMPFAIL_')',
36       _ARG6_, `queue', `define(`_LDAP_ROUTE_MAPTEMP_', `_QUEUE_')')
37
38define(`_ATMPF_', `<TMPF>')dnl
39dnl check whether arg contains -T`'_ATMPF_
40dnl unless it is a sequence map or just LDAP
41dnl note: this does not work if ARG1 begins with space(s), however, as
42dnl we issue a warning, hopefully the user will fix it...
43ifelse(defn(`_ARG1_'), `', `',
44  defn(`_ARG1_'), `LDAP', `',
45  `ifelse(index(_ARG1_, `sequence '), `0', `',
46    `ifelse(index(_ARG1_, _ATMPF_), `-1',
47      `errprint(`*** WARNING: missing -T'_ATMPF_` in first argument of FEATURE(`ldap_routing')
48')
49      define(`_ABP_', index(_ARG1_, ` '))
50      define(`_NARG1_', `substr(_ARG1_, 0, _ABP_) -T'_ATMPF_` substr(_ARG1_, _ABP_)')
51      ')
52    ')
53  ')
54ifelse(defn(`_ARG2_'), `', `',
55  defn(`_ARG2_'), `LDAP', `',
56  `ifelse(index(_ARG2_, `sequence '), `0', `',
57    `ifelse(index(_ARG2_, _ATMPF_), `-1',
58      `errprint(`*** WARNING: missing -T'_ATMPF_` in second argument of FEATURE(`ldap_routing')
59')
60      define(`_ABP_', index(_ARG2_, ` '))
61      define(`_NARG2_', `substr(_ARG2_, 0, _ABP_) -T'_ATMPF_` substr(_ARG2_, _ABP_)')
62      ')
63    ')
64  ')
65
66LOCAL_CONFIG
67# LDAP routing maps
68Kldapmh ifelse(len(X`'_ARG1_), `1',
69	       `ldap -1 -T<TMPF> -v mailHost -k (&(objectClass=inetLocalMailRecipient)(mailLocalAddress=%0))',
70	       defn(`_NARG1_'), `', `_ARG1_', `_NARG1_')
71
72Kldapmra ifelse(len(X`'_ARG2_), `1',
73		`ldap -1 -T<TMPF> -v mailRoutingAddress -k (&(objectClass=inetLocalMailRecipient)(mailLocalAddress=%0))',
74		defn(`_NARG2_'), `', `_ARG2_', `_NARG2_')
75