~ubuntu-branches/ubuntu/saucy/postfix/saucy

« back to all changes in this revision

Viewing changes to src/smtpstone/smtp-sink.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2011-02-22 11:20:43 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222112043-c34ht219w3ybrilr
Tags: 2.8.0-2
* a little more lintian cleanup
* Fix missing format strings in smtp-sink.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
/*      further input from the client; this is an attempt to block
46
46
/*      the client before it sends ".".  Specify a zero delay value
47
47
/*      to abort immediately.
 
48
/* .IP "\fB-b \fIsoft-bounce-reply\fR"
 
49
/*      Use \fIsoft-bounce-reply\fR for soft reject responses.  The
 
50
/*      default reply is "450 4.3.0 Error: command failed".
 
51
/* .IP "\fB-B \fIhard-bounce-reply\fR"
 
52
/*      Use \fIhard-bounce-reply\fR for hard reject responses.  The
 
53
/*      default reply is "500 5.3.0 Error: command failed".
48
54
/* .IP \fB-c\fR
49
55
/*      Display running counters that are updated whenever an SMTP
50
56
/*      session ends, a QUIT command is executed, or when "." is
326
332
#define DEF_MAX_CLIENT_COUNT    256
327
333
#endif
328
334
 
 
335
#define SOFT_ERROR_RESP         "450 4.3.0 Error: command failed"
 
336
#define HARD_ERROR_RESP         "500 5.3.0 Error: command failed"
 
337
 
329
338
static int var_tmout = 100;
330
339
static int var_max_line_length = 2048;
331
340
static char *var_myhostname;
 
341
static char *soft_error_resp = SOFT_ERROR_RESP;
 
342
static char *hard_error_resp = HARD_ERROR_RESP;
332
343
static int command_read(SINK_STATE *);
333
344
static int data_read(SINK_STATE *);
334
345
static void disconnect(SINK_STATE *);
360
371
 
361
372
static INET_PROTO_INFO *proto_info;
362
373
 
363
 
#define SOFT_ERROR_RESP         "450 4.3.0 Error: command failed"
364
 
#define HARD_ERROR_RESP         "500 5.3.0 Error: command failed"
365
 
 
366
374
#define STR(x)  vstring_str(x)
367
375
 
368
376
/* do_stats - show counters */
378
386
 
379
387
static void hard_err_resp(SINK_STATE *state)
380
388
{
381
 
    smtp_printf(state->stream, HARD_ERROR_RESP);
 
389
    smtp_printf(state->stream, "%s", hard_error_resp);
382
390
    smtp_flush(state->stream);
383
391
}
384
392
 
386
394
 
387
395
static void soft_err_resp(SINK_STATE *state)
388
396
{
389
 
    smtp_printf(state->stream, SOFT_ERROR_RESP);
 
397
    smtp_printf(state->stream, "%s", soft_error_resp);
390
398
    smtp_flush(state->stream);
391
399
}
392
400
 
737
745
{
738
746
    if (enable_lmtp) {
739
747
        while (state->rcpts-- > 0)      /* XXX this could block */
740
 
            smtp_printf(state->stream, HARD_ERROR_RESP);
 
748
            smtp_printf(state->stream, "%s", hard_error_resp);
741
749
    } else {
742
 
        smtp_printf(state->stream, HARD_ERROR_RESP);
 
750
        smtp_printf(state->stream, "%s", hard_error_resp);
743
751
    }
744
752
    smtp_flush(state->stream);
745
753
}
750
758
{
751
759
    if (enable_lmtp) {
752
760
        while (state->rcpts-- > 0)      /* XXX this could block */
753
 
            smtp_printf(state->stream, SOFT_ERROR_RESP);
 
761
            smtp_printf(state->stream, "%s", soft_error_resp);
754
762
    } else {
755
 
        smtp_printf(state->stream, SOFT_ERROR_RESP);
 
763
        smtp_printf(state->stream, "%s", soft_error_resp);
756
764
    }
757
765
    smtp_flush(state->stream);
758
766
}
1367
1375
 
1368
1376
static void usage(char *myname)
1369
1377
{
1370
 
    msg_fatal("usage: %s [-468acCeEFLpPv] [-A abort_delay] [-d dump-template] [-D dump-template] [-f commands] [-h hostname] [-m max_concurrency] [M message_quit_count] [-n quit_count] [-q commands] [-r commands] [-R root-dir] [-s commands] [-S start-string] [-u user_privs] [-w delay] [host]:port backlog", myname);
 
1378
    msg_fatal("usage: %s [-468acCeEFLpPv] [-A abort_delay] [-b soft_bounce_reply] [-B hard_bounce_reply] [-d dump-template] [-D dump-template] [-f commands] [-h hostname] [-m max_concurrency] [-M message_quit_count] [-n quit_count] [-q commands] [-r commands] [-R root-dir] [-s commands] [-S start-string] [-u user_privs] [-w delay] [host]:port backlog", myname);
1371
1379
}
1372
1380
 
1373
1381
MAIL_VERSION_STAMP_DECLARE;
1399
1407
    /*
1400
1408
     * Parse JCL.
1401
1409
     */
1402
 
    while ((ch = GETOPT(argc, argv, "468aA:cCd:D:eEf:Fh:Ln:m:M:pPq:Q:r:R:s:S:t:T:u:vw:W:")) > 0) {
 
1410
    while ((ch = GETOPT(argc, argv, "468aA:b:B:cCd:D:eEf:Fh:Ln:m:M:pPq:Q:r:R:s:S:t:T:u:vw:W:")) > 0) {
1403
1411
        switch (ch) {
1404
1412
        case '4':
1405
1413
            protocols = INET_PROTO_NAME_IPV4;
1417
1425
            if (!alldig(optarg) || (abort_delay = atoi(optarg)) < 0)
1418
1426
                usage(argv[0]);
1419
1427
            break;
 
1428
        case 'b':
 
1429
            if (optarg[0] != '4' || strspn(optarg, "0123456789") != 3) {
 
1430
                msg_error("bad soft error reply: %s", optarg);
 
1431
                usage(argv[0]);
 
1432
            } else
 
1433
                soft_error_resp = optarg;
 
1434
            break;
 
1435
        case 'B':
 
1436
            if (optarg[0] != '5' || strspn(optarg, "0123456789") != 3) {
 
1437
                msg_error("bad hard error reply: %s", optarg);
 
1438
                usage(argv[0]);
 
1439
            } else
 
1440
                hard_error_resp = optarg;
 
1441
            break;
1420
1442
        case 'c':
1421
1443
            count++;
1422
1444
            break;