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

« back to all changes in this revision

Viewing changes to src/smtp/smtp_addr.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones, LaMont Jones, localization folks
  • Date: 2014-02-11 07:44:30 UTC
  • mfrom: (58.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140211074430-kwkoxdz0fbajn0fj
Tags: 2.11.0-1
[LaMont Jones]

* New upstream release: 2.11.0

[localization folks]

* l10n: Updated German translations.  Closes: #734893 (Helge Kreutzmann)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
/* SYNOPSIS
7
7
/*      #include "smtp_addr.h"
8
8
/*
9
 
/*      DNS_RR *smtp_domain_addr(name, misc_flags, why, found_myself)
 
9
/*      DNS_RR *smtp_domain_addr(name, mxrr, misc_flags, why, found_myself)
10
10
/*      char    *name;
 
11
/*      DNS_RR  **mxrr;
11
12
/*      int     misc_flags;
12
13
/*      DSN_BUF *why;
13
14
/*      int     *found_myself;
29
30
/*      so that it contains only hosts that are more preferred than the
30
31
/*      local mail server itself. The found_myself result parameter
31
32
/*      is updated when the local MTA is MX host for the specified
32
 
/*      destination.
 
33
/*      destination.  If MX records were found, the rname, qname,
 
34
/*      and dnssec validation status of the MX RRset are returned
 
35
/*      via mxrr, which the caller must free with dns_rr_free().
33
36
/*
34
37
/*      When no mail exchanger is listed in the DNS for \fIname\fR, the
35
38
/*      request is passed to smtp_host_addr().
120
123
 
121
124
/* smtp_addr_one - address lookup for one host name */
122
125
 
123
 
static DNS_RR *smtp_addr_one(DNS_RR *addr_list, const char *host,
 
126
static DNS_RR *smtp_addr_one(DNS_RR *addr_list, const char *host, int res_opt,
124
127
                                     unsigned pref, DSN_BUF *why)
125
128
{
126
129
    const char *myname = "smtp_addr_one";
155
158
     * should not clobber a soft error text and status code.
156
159
     */
157
160
    if (smtp_host_lookup_mask & SMTP_HOST_FLAG_DNS) {
158
 
        switch (dns_lookup_v(host, smtp_dns_res_opt, &addr, (VSTRING *) 0,
 
161
        res_opt |= smtp_dns_res_opt;
 
162
        switch (dns_lookup_v(host, res_opt, &addr, (VSTRING *) 0,
159
163
                             why->reason, DNS_REQ_FLAG_NONE,
160
164
                             proto_info->dns_atype_list)) {
161
165
        case DNS_OK:
236
240
{
237
241
    DNS_RR *addr_list = 0;
238
242
    DNS_RR *rr;
 
243
    int     res_opt = mx_names->dnssec_valid ? RES_USE_DNSSEC : 0;
239
244
 
240
245
    /*
241
246
     * As long as we are able to look up any host address, we ignore problems
261
266
    for (rr = mx_names; rr; rr = rr->next) {
262
267
        if (rr->type != T_MX)
263
268
            msg_panic("smtp_addr_list: bad resource type: %d", rr->type);
264
 
        addr_list = smtp_addr_one(addr_list, (char *) rr->data, rr->pref, why);
 
269
        addr_list = smtp_addr_one(addr_list, (char *) rr->data, res_opt,
 
270
                                  rr->pref, why);
265
271
    }
266
272
    return (addr_list);
267
273
}
336
342
 
337
343
/* smtp_domain_addr - mail exchanger address lookup */
338
344
 
339
 
DNS_RR *smtp_domain_addr(char *name, int misc_flags, DSN_BUF *why,
340
 
                                 int *found_myself)
 
345
DNS_RR *smtp_domain_addr(char *name, DNS_RR **mxrr, int misc_flags,
 
346
                                 DSN_BUF *why, int *found_myself)
341
347
{
342
348
    DNS_RR *mx_names;
343
349
    DNS_RR *addr_list = 0;
344
350
    DNS_RR *self = 0;
345
351
    unsigned best_pref;
346
352
    unsigned best_found;
 
353
    int     r = 0;                      /* Resolver flags */
347
354
 
348
355
    dsb_reset(why);                             /* Paranoia */
349
356
 
355
362
    /*
356
363
     * Sanity check.
357
364
     */
358
 
    if (var_disable_dns)
 
365
    if (smtp_dns_support == SMTP_DNS_DISABLED)
359
366
        msg_panic("smtp_domain_addr: DNS lookup is disabled");
 
367
    if (smtp_dns_support == SMTP_DNS_DNSSEC)
 
368
        r |= RES_USE_DNSSEC;
360
369
 
361
370
    /*
362
371
     * Look up the mail exchanger hosts listed for this name. Sort the
400
409
     * at hostnames provides a partial solution for MX hosts behind a NAT
401
410
     * gateway.
402
411
     */
403
 
    switch (dns_lookup(name, T_MX, 0, &mx_names, (VSTRING *) 0, why->reason)) {
 
412
    switch (dns_lookup(name, T_MX, r, &mx_names, (VSTRING *) 0, why->reason)) {
404
413
    default:
405
414
        dsb_status(why, "4.4.3");
406
415
        if (var_ign_mx_lookup_err)
420
429
        mx_names = dns_rr_sort(mx_names, dns_rr_compare_pref_any);
421
430
        best_pref = (mx_names ? mx_names->pref : IMPOSSIBLE_PREFERENCE);
422
431
        addr_list = smtp_addr_list(mx_names, why);
 
432
        if (mxrr)
 
433
            *mxrr = dns_rr_copy(mx_names);      /* copies one record! */
423
434
        dns_rr_free(mx_names);
424
435
        if (addr_list == 0) {
425
436
            /* Text does not change. */
477
488
DNS_RR *smtp_host_addr(const char *host, int misc_flags, DSN_BUF *why)
478
489
{
479
490
    DNS_RR *addr_list;
 
491
    int     res_opt = 0;
480
492
 
481
493
    dsb_reset(why);                             /* Paranoia */
482
494
 
 
495
    if (smtp_dns_support == SMTP_DNS_DNSSEC)
 
496
        res_opt |= RES_USE_DNSSEC;
 
497
 
483
498
    /*
484
499
     * If the host is specified by numerical address, just convert the
485
500
     * address to internal form. Otherwise, the host is specified by name.
486
501
     */
487
502
#define PREF0   0
488
 
    addr_list = smtp_addr_one((DNS_RR *) 0, host, PREF0, why);
 
503
    addr_list = smtp_addr_one((DNS_RR *) 0, host, res_opt, PREF0, why);
489
504
    if (addr_list
490
505
        && (misc_flags & SMTP_MISC_FLAG_LOOP_DETECT)
491
506
        && smtp_find_self(addr_list) != 0) {