Fossil

Check-in [d0fb5ac7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Replaced the call to the undocumented ns_name_uncompress() function with dn_expand(), which is documented, at least on OpenBSD, and it's shorter. Then made ns_name_uncompress() and __ns_name_uncompress() fallbacks for this, with suitable autosetup tests for all of it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | libbind-ns-alternative
Files: files | file ages | folders
SHA3-256:d0fb5ac7cae085d60804115d7abfbfbbd9596a98da620e2e530b151c21b3aa46
User & Date: wyoung 2018-09-22 16:38:50
Context
2018-09-22
16:55
Removed the "Linux" platform test from the DNS MX stuff in src/smtp.c. You should always test for features, not platforms, and we've now got the feature tests we need to replace this too-broad platform test. check-in: 5358fe95 user: wyoung tags: libbind-ns-alternative
16:38
Replaced the call to the undocumented ns_name_uncompress() function with dn_expand(), which is documented, at least on OpenBSD, and it's shorter. Then made ns_name_uncompress() and __ns_name_uncompress() fallbacks for this, with suitable autosetup tests for all of it. check-in: d0fb5ac7 user: wyoung tags: libbind-ns-alternative
06:57
Fix to previous for CentOS 7. check-in: c7640b38 user: tangent tags: libbind-ns-alternative
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to auto.def.

518
519
520
521
522
523
524

525
526


527
528
529
530
531
532
533
534
535
536

# The SMTP module requires special libraries and headers for MX DNS
# record lookups and such.
cc-check-includes arpa/nameser.h
cc-include-needs bind/resolv.h netinet/in.h
cc-check-includes bind/resolv.h
cc-check-includes resolv.h

if {    ![cc-check-function-in-lib   ns_name_uncompress {resolv bind}] &&
        ![cc-check-function-in-lib __ns_name_uncompress {resolv bind}]} {


    msg-result "WARNING: SMTP feature will not be able to look up local MX."
}
cc-check-function-in-lib res_query resolv
cc-check-function-in-lib res_9_ns_initparse resolv

# Other nonstandard function checks
cc-check-functions utime
cc-check-functions usleep
cc-check-functions strchrnul
cc-check-functions pledge







>
|
|
>
>


<







518
519
520
521
522
523
524
525
526
527
528
529
530
531

532
533
534
535
536
537
538

# The SMTP module requires special libraries and headers for MX DNS
# record lookups and such.
cc-check-includes arpa/nameser.h
cc-include-needs bind/resolv.h netinet/in.h
cc-check-includes bind/resolv.h
cc-check-includes resolv.h
if {    (![cc-check-function-in-lib dn_expand resolv] ||
         ![cc-check-function-in-lib   ns_name_uncompress {bind resolv}] ||
         ![cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) &&
        (![cc-check-function-in-lib   res_query {bind resolv}] ||
         ![cc-check-function-in-lib __res_query {bind resolv}])} {
    msg-result "WARNING: SMTP feature will not be able to look up local MX."
}

cc-check-function-in-lib res_9_ns_initparse resolv

# Other nonstandard function checks
cc-check-functions utime
cc-check-functions usleep
cc-check-functions strchrnul
cc-check-functions pledge

Changes to src/smtp.c.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34



35
36
37
38
39
40
41
42
43
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
**
** Implementation of SMTP (Simple Mail Transport Protocol) according
** to RFC 5321.
*/
#include "config.h"
#include "smtp.h"
#include <assert.h>
#if HAVE___NS_NAME_UNCOMPRESS || HAVE_NS_NAME_UNCOMPRES || \
    (defined(__linux__) && !defined(FOSSIL_OMIT_DNS))
#  include <sys/types.h>
#  include <netinet/in.h>
#  if defined(HAVE_BIND_RESOLV_H)
#    include <bind/resolv.h>
#    include <bind/arpa/nameser_compat.h>
#  else
#    include <arpa/nameser.h>
#    include <resolv.h>
#  endif



#  if defined(HAVE__NS_NAME_UNCOMPRESS) && !defined(ns_name_uncompress)
#    define ns_name_uncompress __ns_name_uncompress
#  endif
#  define FOSSIL_UNIX_STYLE_DNS 1
#endif
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
#  include <windows.h>
#  include <windns.h>
#  define FOSSIL_WINDOWS_STYLE_DNS 1
................................................................................
      if( priority<iBestPriority ){
        pBest = p;
        iBestPriority = priority;
      }
    }
  }
  if( pBest ){
    ns_name_uncompress(aDns, aDns+nDns, pBest+2,
                       zHostname, sizeof(zHostname));
    return fossil_strdup(zHostname);
  }
  return 0;
#elif defined(FOSSIL_WINDOWS_STYLE_DNS)
  DNS_STATUS status;           /* Return status */
  PDNS_RECORDA pDnsRecord, p;  /* Pointer to DNS_RECORD structure */
  int iBestPriority = 9999999; /* Best priority */







|










>
>
>
|
|







 







<
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
**
** Implementation of SMTP (Simple Mail Transport Protocol) according
** to RFC 5321.
*/
#include "config.h"
#include "smtp.h"
#include <assert.h>
#if HAVE_DN_EXPAND || HAVE___NS_NAME_UNCOMPRESS || HAVE_NS_NAME_UNCOMPRES || \
    (defined(__linux__) && !defined(FOSSIL_OMIT_DNS))
#  include <sys/types.h>
#  include <netinet/in.h>
#  if defined(HAVE_BIND_RESOLV_H)
#    include <bind/resolv.h>
#    include <bind/arpa/nameser_compat.h>
#  else
#    include <arpa/nameser.h>
#    include <resolv.h>
#  endif
#  if defined(HAVENS_NAME_UNCOMPRESS) && !defined(dn_expand)
#    define dn_expand ns_name_uncompress
#  endif
#  if defined(HAVE__NS_NAME_UNCOMPRESS) && !defined(dn_expand)
#    define dn_expand __ns_name_uncompress
#  endif
#  define FOSSIL_UNIX_STYLE_DNS 1
#endif
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
#  include <windows.h>
#  include <windns.h>
#  define FOSSIL_WINDOWS_STYLE_DNS 1
................................................................................
      if( priority<iBestPriority ){
        pBest = p;
        iBestPriority = priority;
      }
    }
  }
  if( pBest ){

    dn_expand(aDns, aDns+nDns, pBest+2, zHostname, sizeof(zHostname));
    return fossil_strdup(zHostname);
  }
  return 0;
#elif defined(FOSSIL_WINDOWS_STYLE_DNS)
  DNS_STATUS status;           /* Return status */
  PDNS_RECORDA pDnsRecord, p;  /* Pointer to DNS_RECORD structure */
  int iBestPriority = 9999999; /* Best priority */