~ubuntu-branches/ubuntu/dapper/postfix/dapper-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-12-07 15:39:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051207153911-hutf07z6i8ty25z5
Tags: 2.2.6-1
* New upstream.
  - the *SQL clients did not uniformly choose the database host from
    the available pool
  - raise the "policy violation" flag when a client request exceeds
    a concurrency or rate limit.
  - don't do smtpd_end_of_data_restrictions after the transaction
    failed due to, e.g., a write error.
  - two messages could get the same message ID due to a race
    condition. This time window was increased when queue file creation
    was postponed from MAIL FROM until the first accepted RCPT TO.  The
    window is closed again.
  - the queue manager did not write a per-recipient defer logfile record
    when the delivery agent crashed after the initial handshake with the
    queue manager, and before reporting the delivery status to the queue
    manager.
  - moved code around from one place to another to make REDIRECT, FILTER,
    HOLD and DISCARD access(5) table actions work in
    smtpd_end_of_data_restrictions.  PREPEND will not be fixed; it must
    be specified before the message content is received.
* Updated Italian translations.  Closes: #336925
* Swedish translations.  Closes: #339746
* Switch to libdb4.3.  Closes: #336488
* Add Replaces: mail-transport-agent.  Closes: #325624
* Merge changes from ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
/*      (default: port 25)
14
14
/*      and sends one or more messages to it, either sequentially
15
15
/*      or in parallel. The program speaks either SMTP (default) or
16
 
/*      LMTP. Connections can be made to UNIX-domain and IPV4 servers.
17
 
/*      IPV4 is the default.
 
16
/*      LMTP.
 
17
/*      Connections can be made to UNIX-domain and IPv4 or IPv6 servers.
 
18
/*      IPv4 and IPv6 are the default.
18
19
/*
19
20
/*      Arguments:
 
21
/* .IP \fB-4\fR
 
22
/*      Connect to the server with IPv4. This option has no effect when
 
23
/*      Postfix is built without IPv6 support.
 
24
/* .IP \fB-6\fR
 
25
/*      Connect to the server with IPv6. This option is not available when
 
26
/*      Postfix is built without IPv6 support.
20
27
/* .IP \fB-c\fR
21
28
/*      Display a running counter that is incremented each time
22
29
/*      an SMTP DATA command completes.
39
46
/*      Speak LMTP rather than SMTP.
40
47
/* .IP "\fB-m \fImessage_count\fR"
41
48
/*      Send the specified number of messages (default: 1).
 
49
/* .IP "\fB-N\fR"
 
50
/*      Prepend a non-repeating sequence number to each recipient
 
51
/*      address. This avoids the artificial 100% hit rate in the
 
52
/*      resolve and rewrite client caches and exercises the
 
53
/*      trivial-rewrite daemon, better approximating Postfix
 
54
/*      performance under real-life work-loads.
42
55
/* .IP "\fB-r \fIrecipient_count\fR"
43
56
/*      Send the specified number of recipients per transaction (default: 1).
44
57
/*      Recipient names are generated by prepending a number to the
103
116
#include <connect.h>
104
117
#include <mymalloc.h>
105
118
#include <events.h>
106
 
#include <find_inet.h>
107
119
#include <iostuff.h>
108
120
#include <sane_connect.h>
 
121
#include <host_port.h>
 
122
#include <myaddrinfo.h>
 
123
#include <inet_proto.h>
109
124
 
110
125
/* Global library. */
111
126
 
149
164
static const char *var_myhostname;
150
165
static int session_count;
151
166
static int message_count = 1;
152
 
static struct sockaddr_in sin;
 
167
static struct sockaddr_storage ss;
153
168
 
154
169
#undef sun
155
170
static struct sockaddr_un sun;
171
186
static int fixed_delay = 0;
172
187
static int talk_lmtp = 0;
173
188
static char *subject = 0;
 
189
static int number_rcpts = 0;
174
190
 
175
191
static void enqueue_connect(SESSION *);
176
192
static void start_connect(SESSION *);
573
589
    if ((except = vstream_setjmp(session->stream)) != 0)
574
590
        msg_fatal("%s while sending recipient", exception_text(except));
575
591
 
576
 
    if (session->rcpt_count > 1)
 
592
    if (session->rcpt_count > 1 || number_rcpts > 0)
577
593
        command(session->stream, "RCPT TO:<%d%s>",
578
 
                session->rcpt_count, recipient);
 
594
                number_rcpts ? number_rcpts++ : session->rcpt_count,
 
595
                recipient);
579
596
    else
580
597
        command(session->stream, "RCPT TO:<%s>", recipient);
581
598
    session->rcpt_count--;
767
784
 
768
785
static void usage(char *myname)
769
786
{
770
 
    msg_fatal("usage: %s -s sess -l msglen -m msgs -c -C count -d -f from -o -t to -r rcptcount -R delay -v -w delay host[:port]", myname);
 
787
    msg_fatal("usage: %s -cdLNov -s sess -l msglen -m msgs -C count -f from -t to -r rcptcount -R delay -w delay host[:port]", myname);
771
788
}
772
789
 
773
790
/* main - parse JCL and start the machine */
782
799
    int     sessions = 1;
783
800
    int     ch;
784
801
    int     i;
 
802
    char   *buf;
 
803
    const char *parse_err;
 
804
    struct addrinfo *res;
 
805
    int     aierr;
 
806
    const char *protocols = INET_PROTO_NAME_ALL;
 
807
    INET_PROTO_INFO *proto_info;
785
808
 
786
809
    signal(SIGPIPE, SIG_IGN);
787
810
    msg_vstream_init(argv[0], VSTREAM_ERR);
789
812
    /*
790
813
     * Parse JCL.
791
814
     */
792
 
    while ((ch = GETOPT(argc, argv, "cC:df:l:Lm:or:R:s:S:t:vw:")) > 0) {
 
815
    while ((ch = GETOPT(argc, argv, "46cC:df:l:Lm:Nor:R:s:S:t:vw:")) > 0) {
793
816
        switch (ch) {
 
817
        case '4':
 
818
            protocols = INET_PROTO_NAME_IPV4;
 
819
            break;
 
820
        case '6':
 
821
            protocols = INET_PROTO_NAME_IPV6;
 
822
            break;
794
823
        case 'c':
795
824
            count++;
796
825
            break;
822
851
            if ((message_count = atoi(optarg)) <= 0)
823
852
                msg_fatal("bad message count: %s", optarg);
824
853
            break;
 
854
        case 'N':
 
855
            number_rcpts = 1;
 
856
            break;
825
857
        case 'o':
826
858
            send_helo_first = 0;
827
859
            send_headers = 0;
868
900
    /*
869
901
     * Translate endpoint address to internal form.
870
902
     */
 
903
    proto_info = inet_proto_init("protocols", protocols);
871
904
    if (strncmp(argv[optind], "unix:", 5) == 0) {
872
905
        path = argv[optind] + 5;
873
906
        path_len = strlen(path);
884
917
    } else {
885
918
        if (strncmp(argv[optind], "inet:", 5) == 0)
886
919
            argv[optind] += 5;
887
 
        if ((port = split_at(host = argv[optind], ':')) == 0 || *port == 0)
888
 
            port = "smtp";
889
 
        memset((char *) &sin, 0, sizeof(sin));
890
 
        sin.sin_family = AF_INET;
891
 
        sin.sin_addr.s_addr = find_inet_addr(host);
892
 
        sin.sin_port = find_inet_port(port, "tcp");
893
 
        sa = (struct sockaddr *) & sin;
894
 
        sa_length = sizeof(sin);
 
920
        buf = mystrdup(argv[optind]);
 
921
        if ((parse_err = host_port(buf, &host, (char *) 0, &port, "smtp")) != 0)
 
922
            msg_fatal("%s: %s", argv[optind], parse_err);
 
923
        if ((aierr = hostname_to_sockaddr(host, port, SOCK_STREAM, &res)) != 0)
 
924
            msg_fatal("%s: %s", argv[optind], MAI_STRERROR(aierr));
 
925
        myfree(buf);
 
926
        sa = (struct sockaddr *) & ss;
 
927
        memcpy((char *) sa, res->ai_addr, res->ai_addrlen);
 
928
        sa_length = res->ai_addrlen;
 
929
#ifdef HAS_SA_LEN
 
930
        sa->sa_len = sa_length;
 
931
#endif
 
932
        freeaddrinfo(res);
895
933
    }
896
934
 
897
935
    /*