~ubuntu-branches/ubuntu/trusty/postfix/trusty-updates

« back to all changes in this revision

Viewing changes to src/milter/milter8.c

Tags: upstream-2.3.5
ImportĀ upstreamĀ versionĀ 2.3.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
858
858
                                         int skip_reply,
859
859
                                         ARGV *macros,...)
860
860
{
 
861
    const char *myname = "milter8_event";
861
862
    va_list ap;
862
863
    ssize_t data_len;
863
864
    int     err;
872
873
#define DONT_SKIP_REPLY 0
873
874
 
874
875
    /*
 
876
     * Sanity check.
 
877
     */
 
878
    if (milter->fp == 0 || milter->def_reply != 0) {
 
879
        msg_warn("%s: attempt to send event %s to milter %s after error",
 
880
                 myname,
 
881
                 (smfic_name = str_name_code(smfic_table, event)) != 0 ?
 
882
                 smfic_name : "(unknown MTA event)", milter->m.name);
 
883
        return (milter->def_reply);
 
884
    }
 
885
 
 
886
    /*
875
887
     * Skip this event if it doesn't exist in the protocol that I announced.
876
888
     */
877
889
#ifndef USE_LIBMILTER_INCLUDES
1185
1197
                                                       (ssize_t) index,
1186
1198
                                                       STR(milter->buf));
1187
1199
                    if (edit_resp)
1188
 
                        return (milter8_def_reply(milter, edit_resp));
 
1200
                        return (edit_resp);
1189
1201
                    continue;
1190
1202
#endif
1191
1203
 
1203
1215
                                                   STR(milter->buf),
1204
1216
                                                   STR(milter->body));
1205
1217
                    if (edit_resp)
1206
 
                        return (milter8_def_reply(milter, edit_resp));
 
1218
                        return (edit_resp);
1207
1219
                    continue;
1208
1220
 
1209
1221
                    /*
1232
1244
                                                   STR(milter->buf),
1233
1245
                                                   STR(milter->body));
1234
1246
                    if (edit_resp)
1235
 
                        return (milter8_def_reply(milter, edit_resp));
 
1247
                        return (edit_resp);
1236
1248
                    continue;
1237
1249
#endif
1238
1250
 
1248
1260
                    edit_resp = parent->add_rcpt(parent->chg_context,
1249
1261
                                                 STR(milter->buf));
1250
1262
                    if (edit_resp)
1251
 
                        return (milter8_def_reply(milter, edit_resp));
 
1263
                        return (edit_resp);
1252
1264
                    continue;
1253
1265
 
1254
1266
                    /*
1263
1275
                    edit_resp = parent->del_rcpt(parent->chg_context,
1264
1276
                                                 STR(milter->buf));
1265
1277
                    if (edit_resp)
1266
 
                        return (milter8_def_reply(milter, edit_resp));
 
1278
                        return (edit_resp);
1267
1279
                    continue;
1268
1280
 
1269
1281
                    /*
1280
1292
                    edit_resp = parent->repl_body(parent->chg_context,
1281
1293
                                                  milter->body);
1282
1294
                    if (edit_resp)
1283
 
                        return (milter8_def_reply(milter, edit_resp));
 
1295
                        return (edit_resp);
1284
1296
                    continue;
1285
1297
#endif
1286
1298
                }
1928
1940
    int     skip_reply;
1929
1941
 
1930
1942
    /*
 
1943
     * XXX Workaround: mime_state_update() may invoke multiple call-backs
 
1944
     * before returning to the caller.
 
1945
     */
 
1946
#define MILTER8_MESSAGE_DONE(milter, msg_ctx) \
 
1947
        ((milter)->state != MILTER8_STAT_MESSAGE || (msg_ctx)->resp != 0)
 
1948
 
 
1949
    if (MILTER8_MESSAGE_DONE(milter, msg_ctx))
 
1950
        return;
 
1951
 
 
1952
    /*
1931
1953
     * XXX Sendmail compatibility. Don't expose our first (received) header
1932
1954
     * to mail filter applications. See also cleanup_milter.c for code to
1933
1955
     * ensure that header replace requests are relative to the message
1990
2012
    MILTER_MSG_CONTEXT *msg_ctx = (MILTER_MSG_CONTEXT *) ptr;
1991
2013
    MILTER8 *milter = msg_ctx->milter;
1992
2014
 
 
2015
    if (MILTER8_MESSAGE_DONE(milter, msg_ctx))
 
2016
        return;
1993
2017
    if (msg_verbose)
1994
2018
        msg_info("%s: eoh milter %s", myname, milter->m.name);
1995
2019
    msg_ctx->resp =
2012
2036
    ssize_t space;
2013
2037
    ssize_t count;
2014
2038
 
 
2039
    if (MILTER8_MESSAGE_DONE(milter, msg_ctx))
 
2040
        return;
 
2041
 
2015
2042
    /*
2016
2043
     * XXX Sendmail compatibility: don't expose our first body line.
2017
2044
     */
2079
2106
    MILTER_MSG_CONTEXT *msg_ctx = (MILTER_MSG_CONTEXT *) ptr;
2080
2107
    MILTER8 *milter = msg_ctx->milter;
2081
2108
 
 
2109
    if (MILTER8_MESSAGE_DONE(milter, msg_ctx))
 
2110
        return;
2082
2111
    if (msg_verbose)
2083
2112
        msg_info("%s: eob milter %s", myname, milter->m.name);
2084
2113
    msg_ctx->resp =
2144
2173
 
2145
2174
        /*
2146
2175
         * XXX When the message (not MIME body part) does not end in CRLF
2147
 
         * (i.e. the last record was REC_TYPE_CONT), do we send CRLF
 
2176
         * (i.e. the last record was REC_TYPE_CONT), do we send a CRLF
2148
2177
         * terminator before triggering the end-of-body condition?
2149
2178
         */
2150
2179
        for (;;) {
2164
2193
                msg_ctx.resp = "450 4.3.0 Queue file write error";
2165
2194
                break;
2166
2195
            }
2167
 
            if (msg_ctx.resp != 0)
2168
 
                break;
2169
 
            if (milter->state != MILTER8_STAT_MESSAGE)
 
2196
            if (MILTER8_MESSAGE_DONE(milter, &msg_ctx))
2170
2197
                break;
2171
2198
            if (rec_type != REC_TYPE_NORM && rec_type != REC_TYPE_CONT)
2172
2199
                break;