7 /* delivery of unknown recipients
11 /* int deliver_unknown(state, usr_attr)
13 /* USER_ATTR usr_attr;
15 /* deliver_unknown() delivers a message for unknown recipients.
17 /* If an alternative message transport is specified via the
18 /* fallback_transport parameter, delivery is delegated to the
21 /* If an alternative address is specified via the luser_relay
22 /* configuration parameter, mail is forwarded to that address.
24 /* Otherwise the recipient is bounced.
26 /* The luser_relay parameter is subjected to $name expansion of
27 /* the standard message attributes: $user, $home, $shell, $domain,
28 /* $recipient, $mailbox, $extension, $recipient_delimiter, not
29 /* all of which actually make sense.
33 /* Message delivery attributes (sender, recipient etc.).
34 /* Attributes describing alias, include or forward expansion.
35 /* A table with the results from expanding aliases or lists.
36 /* A table with delivered-to: addresses taken from the message.
38 /* Attributes describing user rights and environment.
40 /* The result status is non-zero when delivery should be tried again.
44 /* The Secure Mailer license must be distributed with this software.
47 /* IBM T.J. Watson Research
49 /* Yorktown Heights, NY 10598, USA
57 #ifdef STRCASECMP_IN_STRINGS_H
61 /* Utility library. */
64 #include <stringops.h>
70 #include <been_here.h>
71 #include <mail_params.h>
72 #include <mail_proto.h>
74 #include <mail_addr.h>
76 #include <deliver_pass.h>
78 /* Application-specific. */
82 /* deliver_unknown - delivery for unknown recipients */
84 int deliver_unknown(LOCAL_STATE state
, USER_ATTR usr_attr
)
86 const char *myname
= "deliver_unknown";
88 VSTRING
*expand_luser
;
89 static MAPS
*transp_maps
;
90 const char *map_transport
;
93 * Make verbose logging easier to understand.
97 MSG_LOG_STATE(myname
, state
);
100 * DUPLICATE/LOOP ELIMINATION
102 * Don't deliver the same user twice.
104 if (been_here(state
.dup_filter
, "%s %s", myname
, state
.msg_attr
.local
))
108 * The fall-back transport specifies a delivery machanism that handles
109 * users not found in the aliases or UNIX passwd databases.
111 if (*var_fbck_transp_maps
&& transp_maps
== 0)
112 transp_maps
= maps_create(VAR_FBCK_TRANSP_MAPS
, var_fbck_transp_maps
,
113 DICT_FLAG_LOCK
| DICT_FLAG_NO_REGSUB
);
114 /* The -1 is a hint for the down-stream deliver_completed() function. */
115 if (*var_fbck_transp_maps
116 && (map_transport
= maps_find(transp_maps
, state
.msg_attr
.user
,
117 DICT_FLAG_NONE
)) != 0) {
118 state
.msg_attr
.rcpt
.offset
= -1L;
119 return (deliver_pass(MAIL_CLASS_PRIVATE
, map_transport
,
120 state
.request
, &state
.msg_attr
.rcpt
));
122 if (*var_fallback_transport
) {
123 state
.msg_attr
.rcpt
.offset
= -1L;
124 return (deliver_pass(MAIL_CLASS_PRIVATE
, var_fallback_transport
,
125 state
.request
, &state
.msg_attr
.rcpt
));
129 * Subject the luser_relay address to $name expansion, disable
130 * propagation of unmatched address extension, and re-inject the address
131 * into the delivery machinery. Do not give special treatment to "|stuff"
134 if (*var_luser_relay
) {
135 state
.msg_attr
.unmatched
= 0;
136 expand_luser
= vstring_alloc(100);
137 local_expand(expand_luser
, var_luser_relay
, &state
, &usr_attr
, (char *) 0);
138 status
= deliver_resolve_addr(state
, usr_attr
, STR(expand_luser
));
139 vstring_free(expand_luser
);
144 * If no alias was found for a required reserved name, toss the message
145 * into the bit bucket, and issue a warning instead.
147 #define STREQ(x,y) (strcasecmp(x,y) == 0)
149 if (STREQ(state
.msg_attr
.local
, MAIL_ADDR_MAIL_DAEMON
)
150 || STREQ(state
.msg_attr
.local
, MAIL_ADDR_POSTMASTER
)) {
151 msg_warn("required alias not found: %s", state
.msg_attr
.local
);
152 dsb_simple(state
.msg_attr
.why
, "2.0.0", "discarded");
153 return (sent(BOUNCE_FLAGS(state
.request
), SENT_ATTR(state
.msg_attr
)));
157 * Bounce the message when no luser relay is specified.
159 dsb_simple(state
.msg_attr
.why
, "5.1.1",
160 "unknown user: \"%s\"", state
.msg_attr
.local
);
161 return (bounce_append(BOUNCE_FLAGS(state
.request
),
162 BOUNCE_ATTR(state
.msg_attr
)));