Skip to content

Commit d8c6f4c

Browse files
authored
Merge pull request #147 from matsduf/merge-develop-into-master
Merge develop into master (Zonemaster-LDNS)
2 parents 66b2ba8 + 5bfa879 commit d8c6f4c

File tree

10 files changed

+142
-50
lines changed

10 files changed

+142
-50
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
dist: bionic
1+
dist: focal
22

33
env:
44
- TEST_WITH_NETWORK=1
55

66
language: perl
77
perl:
8-
- "5.30"
9-
- "5.28"
8+
- "5.32"
9+
- "5.30.2"
1010
- "5.26"
11-
- "5.24"
12-
- "5.22"
13-
- "5.16"
11+
- "5.14.4"
1412

1513
before_install:
16-
- eval $(curl https://travis-perl.github.io/init)
17-
- sudo apt-get install -y libidn11-dev
14+
# quoting preserves newlines in the script and then avoid error if the
15+
# script contains comments
16+
- eval "$(curl https://travis-perl.github.io/init)"
17+
- sudo apt-get install -y libidn2-dev
1818
- cpan-install --deps Devel::CheckLib Module::Install Module::Install::XSUtil
1919

2020
install:

Changes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Release history for Zonemaster component Zonemaster-LDNS
22

3+
2.2.2 2022-06-09
4+
5+
[Features]
6+
- Gives more freedom when configuring (#134, #129, #96)
7+
- Replaces libidn with libidn2 (#133, #131)
8+
9+
[Fixes]
10+
- Clarifies README on --ed25519 (#142)
11+
312

413
2.2.1 2021-12-03
514
[Features]

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN apk add --no-cache \
44
# Compile-time dependencies
55
build-base \
66
ldns-dev \
7-
libidn-dev \
7+
libidn2-dev \
88
make \
99
openssl-dev \
1010
perl-app-cpanminus \
@@ -32,5 +32,5 @@ COPY --from=build /usr/local/lib/perl5/site_perl/Zonemaster /usr/local/lib/perl5
3232
RUN apk add --no-cache \
3333
# Run-time dependencies
3434
ldns \
35-
libidn \
35+
libidn2 \
3636
perl

Makefile.PL

Lines changed: 93 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,69 @@ all_from 'lib/Zonemaster/LDNS.pm';
1414
repository 'https://github.com/zonemaster/zonemaster-ldns';
1515
bugtracker 'https://github.com/zonemaster/zonemaster-ldns/issues';
1616

17+
=head1 Optional features
18+
19+
=over
20+
21+
=item --[no-]ed25519
22+
23+
Enable (or disable) support for Ed25519 in both openssl and ldns.
24+
Enabled by default.
25+
26+
=item --[no-]idn
27+
28+
Enable (or disable) support for converting IDN labels in U-label format (with
29+
non-ASCII Unicode characters) to the same IDN labels in A-label format (encoded
30+
in ASCII).
31+
Enabled by default.
32+
33+
=item --[no-]internal-ldns
34+
35+
When enabled, an included version of ldns is statically linked into
36+
Zonemaster::LDNS.
37+
When disabled, libldns is dynamically linked just like other dependencies.
38+
Enabled by default.
39+
40+
=item --[no-]randomize
41+
42+
Experimental.
43+
Randomizes the capitalization of returned domain names.
44+
Disabled by default.
45+
46+
=item --prefix-openssl=PATH
47+
48+
Search for OpenSSL headers and libraries in PATH.
49+
The LDNS script will look for an "include" and a "lib" folder.
50+
51+
=item --openssl-inc=PATH
52+
53+
Search for OpenSSL include in PATH.
54+
The PATH is passed to the LDNS compiler via the CFLAGS variable.
55+
56+
=item --openssl-lib=PATH
57+
58+
Search for OpenSSL library in PATH.
59+
The PATH is passed to the LDNS compiler via the LDFLAGS variable.
60+
61+
=back
62+
63+
=cut
64+
1765
my $opt_ed25519 = 1;
1866
my $opt_idn = 1;
1967
my $opt_internal_ldns = 1;
2068
my $opt_randomize = 0;
2169
my $opt_prefix_openssl = "";
70+
my $opt_openssl_inc = "";
71+
my $opt_openssl_lib = "";
2272
GetOptions(
2373
'ed25519!' => \$opt_ed25519,
2474
'idn!' => \$opt_idn,
2575
'internal-ldns!' => \$opt_internal_ldns,
2676
'randomize!' => \$opt_randomize,
2777
'prefix-openssl=s' => \$opt_prefix_openssl,
78+
'openssl-inc=s' => \$opt_openssl_inc,
79+
'openssl-lib=s' => \$opt_openssl_lib,
2880
);
2981

3082
configure_requires 'Devel::CheckLib';
@@ -42,12 +94,31 @@ cc_src_paths 'src';
4294
# OpenSSL
4395

4496
my %assert_lib_args_openssl;
45-
if ( $opt_prefix_openssl ) {
46-
print "Custom prefix for OpenSSL: $opt_prefix_openssl\n";
47-
cc_include_paths "$opt_prefix_openssl/include";
48-
cc_libs "-L$opt_prefix_openssl/lib", "crypto";
49-
$assert_lib_args_openssl{incpath} = "$opt_prefix_openssl/include";
50-
$assert_lib_args_openssl{libpath} = "$opt_prefix_openssl/lib";
97+
my $custom_openssl = ( $opt_prefix_openssl or $opt_openssl_inc or $opt_openssl_lib );
98+
if ( $custom_openssl ) {
99+
my $openssl_incpath = "";
100+
my $openssl_libpath = "";
101+
102+
if ( $opt_prefix_openssl ) {
103+
print "Custom prefix for OpenSSL: $opt_prefix_openssl\n";
104+
$openssl_incpath = "$opt_prefix_openssl/include";
105+
$openssl_libpath = "$opt_prefix_openssl/lib";
106+
}
107+
108+
if ( $opt_openssl_inc ) {
109+
print "Custom include directory for OpenSSL: $opt_openssl_inc\n";
110+
$openssl_incpath = "$opt_openssl_inc";
111+
}
112+
113+
if ( $opt_openssl_lib ) {
114+
print "Custom library directory for OpenSSL: $opt_openssl_lib\n";
115+
$openssl_libpath = "$opt_openssl_lib";
116+
}
117+
118+
cc_include_paths "$openssl_incpath";
119+
cc_libs "-L$openssl_libpath", "crypto";
120+
$assert_lib_args_openssl{incpath} = "$openssl_incpath";
121+
$assert_lib_args_openssl{libpath} = "$openssl_libpath";
51122
}
52123
else {
53124
cc_libs 'crypto';
@@ -99,12 +170,11 @@ else {
99170
if ( $opt_idn ) {
100171
print "Feature idn enabled\n";
101172
check_lib_or_exit(
102-
lib => 'idn',
103-
header => 'idna.h',
173+
lib => 'idn2',
174+
header => 'idn2.h',
104175
function =>
105-
'if(strcmp(IDNA_ACE_PREFIX,"xn--")==0) return 0; else return 1;'
106-
);
107-
cc_libs 'idn';
176+
'return IDN2_OK;');
177+
cc_libs 'idn2';
108178
cc_define '-DWE_CAN_HAZ_IDN';
109179
}
110180
else {
@@ -156,11 +226,18 @@ CONFIGURE_FLAGS += --disable-ldns-config --disable-dane
156226
157227
END_CONFIGURE_FLAGS
158228

159-
my $openssl_make = <<END_ED25519;
229+
my $openssl_make = <<END_OPENSSL_MAKE;
160230
161231
CONFIGURE_FLAGS += --with-ssl=$opt_prefix_openssl
162232
163-
END_ED25519
233+
END_OPENSSL_MAKE
234+
235+
my $openssl_flags = <<END_OPENSSL_FLAGS;
236+
237+
CFLAGS += -I$opt_openssl_inc
238+
LDFLAGS += -L$opt_openssl_lib
239+
240+
END_OPENSSL_FLAGS
164241

165242
my $ed25519_make = <<'END_ED25519';
166243
@@ -176,13 +253,14 @@ END_NO_ED25519
176253

177254
my $internal_ldns_make = <<'END_INTERNAL_LDNS';
178255
256+
CFLAGS += -fPIC
179257
LDFROM += ldns/.libs/libldns.a
180258
181259
config :: ldns/.libs/libldns.a
182260
183261
ldns/.libs/libldns.a: ldns/configure
184262
cd ldns ;\
185-
./configure CFLAGS=-fPIC $(CONFIGURE_FLAGS) ;\
263+
./configure CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" $(CONFIGURE_FLAGS) ;\
186264
make lib
187265
188266
ldns/configure:
@@ -203,6 +281,7 @@ END_INTERNAL_LDNS
203281
$postamble .= $openssl_make if $opt_prefix_openssl;
204282
$postamble .= $ed25519_make if $opt_ed25519;
205283
$postamble .= $no_ed25519_make if !$opt_ed25519;
284+
$postamble .= $openssl_flags if ( $opt_openssl_inc or $opt_openssl_lib );
206285
$postamble .= $internal_ldns_make;
207286
}
208287

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Initially this module was named Net::LDNS.
3939

4040
Run-time dependencies:
4141
* `openssl` (openssl >= 1.1.1 unless [Ed25519] is disabled)
42-
* `libidn` (if [IDN] is enabled)
42+
* `libidn2` (if [IDN] is enabled)
4343
* `libldns` (if [Internal ldns] is disabled; libldns >= 1.7.0, or
4444
libldns >= 1.7.1 if [Ed25519] is enabled)
4545

@@ -127,19 +127,20 @@ commands.
127127
Enabled by default.
128128
Disabled with `--no-ed25519`
129129

130-
Requires support for Ed25519 in both openssl and ldns.
130+
Requires support for algorithms Ed25519 and Ed448 in both openssl and ldns.
131131

132132
>
133133
> *Note:* Zonemaster Engine relies on this feature for its analysis when Ed25519
134-
> (algorithm 15) is being used in DNS records.
134+
> (DNSKEY algorithm 15) or Ed448 (DNSKEY algorithm 16) is being used in DNSSEC
135+
> signatures.
135136
>
136137
137138
### IDN
138139

139140
Enabled by default.
140141
Disable with `--no-idn`.
141142

142-
If the IDN feature is enabled, the GNU `libidn` library will be used to
143+
If the IDN feature is enabled, the GNU `libidn2` library will be used to
143144
add a simple function that converts strings from Perl's internal encoding
144145
to IDNA domain name format.
145146
In order to convert strings from whatever encoding you have to Perl's
@@ -173,7 +174,8 @@ Randomizes the capitalization of returned domain names.
173174
### Custom OpenSSL
174175

175176
Disabled by default.
176-
Enabled with `--prefix-openssl=/path/to/openssl`.
177+
Enabled with `--prefix-openssl=/path/to/openssl` or
178+
`--openssl-inc=/path/to/openssl_inc` or `--openssl-lib=/path/to/openssl_lib`
177179

178180
Enabling this makes the build tools look for OpenSSL in a non-standard place.
179181

@@ -185,6 +187,10 @@ Technically this does two things:
185187
> **Note:** The `lib` directory under the given path must be known to the
186188
> dynamic linker or feature checks will fail.
187189
190+
If both headers and libraries directories (`include` and `lib`) are not in the
191+
same parent directory, use `--openssl-inc` and `--openssl-lib` options to
192+
specify both paths.
193+
188194

189195
[DNS::LDNS]: http://search.cpan.org/~erikoest/DNS-LDNS/
190196
[Docker Hub]: https://hub.docker.com/u/zonemaster

include/LDNS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <ldns/ldns.h>
1414

1515
#ifdef WE_CAN_HAZ_IDN
16-
#include <idna.h>
16+
#include <idn2.h>
1717
#endif
1818

1919
/* ldns 1.6.17 does not have this in its header files, but it is in the published documentation and we need it */

lib/Zonemaster/LDNS.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package Zonemaster::LDNS;
22

33
use 5.014;
44

5-
our $VERSION = '2.2.1';
5+
our $VERSION = '2.2.2';
66

77
use parent 'Exporter';
88
our @EXPORT_OK = qw[to_idn has_idn ldns_version load_zonefile];
@@ -46,12 +46,12 @@ labels converted to A-labels unless they are already in ASCII.
4646
Assumes that the strings have been converted to Perl's internal encoding before
4747
it's called. Can be exported, but is not by default.
4848
49-
This function requires that GNU libidn was present when L<Zonemaster::LDNS> was
49+
This function requires that GNU libidn2 was present when L<Zonemaster::LDNS> was
5050
compiled. If not, calling C<to_idn> will result in an exception getting thrown.
5151
5252
=item has_idn()
5353
54-
Takes no arguments. Returns true if libidn was present at compilation, false if not.
54+
Takes no arguments. Returns true if libidn2 was present at compilation, false if not.
5555
5656
=item has_gost()
5757

src/LDNS.xs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ to_idn(...)
1818

1919
if (SvPOK(ST(i)))
2020
{
21-
status = idna_to_ascii_8z(SvPVutf8_nolen(obj), &out, IDNA_ALLOW_UNASSIGNED);
22-
if (status == IDNA_SUCCESS)
21+
status = idn2_to_ascii_8z(SvPVutf8_nolen(obj), &out, IDN2_ALLOW_UNASSIGNED);
22+
if (status == IDN2_OK)
2323
{
2424
SV *new = newSVpv(out,0);
2525
SvUTF8_on(new); /* We know the string is plain ASCII, so let Perl know too */
@@ -28,12 +28,12 @@ to_idn(...)
2828
}
2929
else
3030
{
31-
croak("Error: %s\n", idna_strerror(status));
31+
croak("Error: %s\n", idn2_strerror(status));
3232
}
3333
}
3434
}
3535
#else
36-
croak("libidn not installed");
36+
croak("libidn2 not installed");
3737
#endif
3838
}
3939

t/idn.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use utf8;
77
BEGIN { use_ok( "Zonemaster::LDNS" => qw[:all] ) }
88

99
no warnings 'uninitialized';
10-
if (exception {to_idn("whatever")} =~ /libidn not installed/) {
10+
if (exception {to_idn("whatever")} =~ /libidn2 not installed/) {
1111
ok(!has_idn(), 'No IDN');
1212
done_testing;
1313
exit;

0 commit comments

Comments
 (0)