Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 4e9b912

Browse files
committed
Import 2.5 version of dnsshim from nic.br
1 parent 72b8a8f commit 4e9b912

37 files changed

Lines changed: 585 additions & 189 deletions

ChangeLog

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
DNSSHIM: NIC.br's DNS Secure Hidden Master
22

3-
version 2.2.2
4-
* Fix to allow AXFR responses bigger than 32767 bytes
3+
version 2.5
4+
* big zones (+64k) transfers fixed
55

6-
version 2.2.1
7-
* Fix for list-zones and change-password
8-
* Added hook to capture a shutdown signal from the Operating System
6+
version 2.4
7+
* NSD support
8+
* New config parameter: minimun_soa_refresh
9+
* New config parameter: minimun_soa_expire
10+
* Include SOA RR as a hint in notify messages
11+
Bug Fixes:
12+
* Fixed command for changing user password
13+
14+
version 2.3
15+
* Memory leak fixed
916

1017
version 2.2
1118
* TLS certificate import fix

build.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@
2222
<copy todir="${build}" >
2323
<fileset dir="${src}">
2424
<include name="**/resources/**" />
25-
</fileset>
26-
</copy>
27-
<copy todir="${build}/META-INF">
28-
<fileset dir="${src}/META-INF">
29-
<include name="*" />
30-
</fileset>
25+
</fileset>
3126
</copy>
3227
</target>
3328

@@ -40,7 +35,8 @@
4035
<!-- signer -->
4136
<jar jarfile="${dist}/dnsshim-signer.jar">
4237
<fileset dir="${build}/" excludes="**/xfrd/" />
43-
<manifest>
38+
39+
<manifest>
4440
<attribute name="Main-Class"
4541
value="br/registro/dnsshim/signer/server/SignerServer" />
4642
<attribute name="Class-Path" value="${manifest-classpath-signer} ." /> <!-- class-path + current directory -->
@@ -64,9 +60,9 @@
6460
</fileset>
6561
</copy>
6662

67-
<copy file="scripts/SlaveSync.sh" todir="${dist}/"/>
63+
<copy file="scripts/BindSync.sh" todir="${dist}/"/>
64+
<copy file="scripts/NSDSync.sh" todir="${dist}/"/>
6865
<copy file="scripts/CreateZoneDirs.sh" todir="${dist}/"/>
69-
<copy file="ChangeLog" todir="${dist}/"/>
7066

7167
</target>
7268

@@ -83,7 +79,9 @@
8379
<map from="${lib.app.dir}" to="lib" /> <!-- to relative path -->
8480
<path id="class.path">
8581
<fileset dir="lib">
86-
<include name="**/*.jar" />
82+
<!-- <include name="**/*.jar" /> -->
83+
<include name="*log4j*" />
84+
<include name="*commons-codec*" />
8785
</fileset>
8886
</path>
8987
</pathconvert>
@@ -93,7 +91,8 @@
9391
<map from="${lib.app.dir}" to="lib" /> <!-- to relative path -->
9492
<path id="class.path">
9593
<fileset dir="lib">
96-
<include name="**/*.jar" />
94+
<include name="*log4j*" />
95+
<include name="*commons-codec*" />
9796
</fileset>
9897
</path>
9998
</pathconvert>

lib/commons-validator-1.4.0.jar

173 KB
Binary file not shown.

scripts/BindSync.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/sh
2+
# Copyright (C) 2009 Registro.br. All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
# 1. Redistribution of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
#
13+
# THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS'' AND ANY EXPRESS OR
14+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
# WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16+
# EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT,
17+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
19+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
22+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23+
# DAMAGE.
24+
25+
26+
added=0
27+
removed=0
28+
ERRCOUNTER=0
29+
rndcExists=0
30+
31+
rndcPath="/usr/bin/rndc"
32+
rndcPort="953"
33+
34+
if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]
35+
then
36+
addedZones=$1
37+
removedZones=$2
38+
serverIp=$3
39+
timestamp=$4
40+
41+
if [ -x "$rndcPath" ]
42+
then
43+
rndcExists=1
44+
fi
45+
46+
filename="${addedZones}${timestamp}"
47+
# Make sure file exists and is not empty
48+
if [ -s $filename ]
49+
then
50+
while read LINE
51+
do
52+
if [ $rndcExists -eq 1 ]
53+
then
54+
err=`eval $rndcPath -s $serverIp -p $rndcPort addzone $LINE 2>&1`
55+
if [ $? -eq 0 ]
56+
then
57+
added=`expr $added + 1`
58+
else
59+
echo $err | grep "already exists"
60+
if [ $? -eq 1 ]
61+
then
62+
zone=`echo $LINE | awk '{ print $1 }'`
63+
echo $zone >> ${addedZones}.err
64+
fi
65+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
66+
fi
67+
else
68+
zone=`echo $LINE | awk '{ print $1 }'`
69+
echo $zone >> ${addedZones}.err
70+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
71+
fi
72+
done < $filename
73+
fi
74+
75+
filename="${removedZones}${timestamp}"
76+
if [ -s $filename ]
77+
then
78+
while read LINE
79+
do
80+
if [ $rndcExists -eq 1 ]
81+
then
82+
err=`eval $rndcPath -s $serverIp -p $rndcPort delzone $LINE 2>&1`
83+
if [ $? -eq 0 ]
84+
then
85+
removed=`expr $removed + 1`
86+
else
87+
echo $err | grep "not found"
88+
if [ $? -eq 1 ]
89+
then
90+
echo $LINE >> ${removedZones}.err
91+
fi
92+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
93+
94+
fi
95+
else
96+
echo $LINE >> ${removedZones}.err
97+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
98+
fi
99+
done < $filename
100+
fi
101+
102+
echo "SlaveSync $serverIp finished"
103+
echo "Added: $added"
104+
echo "Removed: $removed"
105+
echo "Errors: $ERRCOUNTER"
106+
fi

scripts/NSDSync.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/sh
2+
# Copyright (C) 2009 Registro.br. All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
# 1. Redistribution of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
#
13+
# THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS'' AND ANY EXPRESS OR
14+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
# WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16+
# EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT,
17+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
19+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
21+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
22+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23+
# DAMAGE.
24+
25+
26+
added=0
27+
removed=0
28+
ERRCOUNTER=0
29+
nsdControlExists=0
30+
31+
nsdControlPath="/home/mauro/nsd/sbin/nsd-control"
32+
nsdControlPort="8952"
33+
34+
if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]
35+
then
36+
addedZones=$1
37+
removedZones=$2
38+
serverIp=$3
39+
timestamp=$4
40+
41+
if [ -x "$nsdControlPath" ]
42+
then
43+
nsdControlExists=1
44+
fi
45+
46+
filename="${addedZones}${timestamp}"
47+
# Make sure file exists and is not empty
48+
if [ -s $filename ]
49+
then
50+
while read LINE
51+
do
52+
if [ $nsdControlExists -eq 1 ]
53+
then
54+
err=`eval $nsdControlPath -s $serverIp addzone $LINE 2>&1`
55+
if [ $? -eq 0 ]
56+
then
57+
added=`expr $added + 1`
58+
else
59+
zone=`echo $LINE | awk '{ print $1 }'`
60+
# checking if we could not add because the zone already exists
61+
err=`eval $nsdControlPath -s $serverIp zonestatus $zone 2>&1`
62+
if [ $? -eq 1 ]
63+
then
64+
echo $zone >> ${addedZones}.err
65+
fi
66+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
67+
fi
68+
else
69+
echo $LINE >> ${addedZones}.err
70+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
71+
fi
72+
done < $filename
73+
fi
74+
75+
filename="${removedZones}${timestamp}"
76+
if [ -s $filename ]
77+
then
78+
while read LINE
79+
do
80+
if [ $nsdControlExists -eq 1 ]
81+
then
82+
err=`eval $nsdControlPath -s $serverIp delzone $LINE 2>&1`
83+
if [ $? -eq 0 ]
84+
then
85+
removed=`expr $removed + 1`
86+
else
87+
echo $err | grep "not present"
88+
if [ $? -eq 1 ]
89+
then
90+
echo $LINE >> ${removedZones}.err
91+
fi
92+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
93+
94+
fi
95+
else
96+
echo $LINE >> ${removedZones}.err
97+
ERRCOUNTER=`expr $ERRCOUNTER + 1`
98+
fi
99+
done < $filename
100+
fi
101+
102+
echo "SlaveSync $serverIp finished"
103+
echo "Added: $added"
104+
echo "Removed: $removed"
105+
echo "Errors: $ERRCOUNTER"
106+
fi

src/br/registro/dnsshim/domain/A.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.net.UnknownHostException;
2929
import java.nio.ByteBuffer;
3030

31+
import org.apache.commons.validator.routines.InetAddressValidator;
32+
3133
import br.registro.dnsshim.common.server.DnsshimProtocolException;
3234
import br.registro.dnsshim.common.server.ProtocolStatusCode;
3335
import br.registro.dnsshim.util.ByteUtil;
@@ -39,6 +41,9 @@ public A(String ownername, DnsClass dnsClass, int ttl, String ip)
3941
throws DnsshimProtocolException {
4042
super(ownername, RrType.A, dnsClass, ttl);
4143
try {
44+
if (InetAddressValidator.getInstance().isValid(ip) == false) {
45+
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv4 address: " + ip);
46+
}
4247
this.addr = (Inet4Address) InetAddress.getByName(ip);
4348
} catch (UnknownHostException uhe) {
4449
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv4 address: " + ip);

src/br/registro/dnsshim/domain/Aaaa.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.net.UnknownHostException;
2929
import java.nio.ByteBuffer;
3030

31+
import org.apache.commons.validator.routines.InetAddressValidator;
32+
3133
import br.registro.dnsshim.common.server.DnsshimProtocolException;
3234
import br.registro.dnsshim.common.server.ProtocolStatusCode;
3335
import br.registro.dnsshim.util.ByteUtil;
@@ -39,6 +41,16 @@ public Aaaa(String ownername, DnsClass dnsClass, int ttl, String ipv6)
3941
throws DnsshimProtocolException {
4042
super(ownername, RrType.AAAA, dnsClass, ttl);
4143
try {
44+
// is a IPv4 ?
45+
if (InetAddressValidator.getInstance().isValid(ipv6)){
46+
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);
47+
}
48+
InetAddress inet = InetAddress.getByName(ipv6);
49+
50+
if ((inet instanceof Inet6Address) == false) {
51+
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);
52+
}
53+
4254
this.addr = (Inet6Address) InetAddress.getByName(ipv6);
4355
} catch (UnknownHostException uhe) {
4456
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);

src/br/registro/dnsshim/domain/Rrset.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ public Rrset(String ownername, RrType type, DnsClass dnsClass) {
4747
this.dnsClass = dnsClass;
4848
}
4949

50-
public Rrset(Rrset rrset) {
51-
if (rrset == null) {
52-
throw new IllegalArgumentException();
53-
}
54-
55-
this.ownername = rrset.ownername;
56-
this.type = rrset.type;
57-
this.dnsClass = rrset.dnsClass;
58-
59-
records = new TreeSet<ResourceRecord>(rrset.records);
60-
}
61-
6250
public String getOwnername() {
6351
return ownername;
6452
}

src/br/registro/dnsshim/domain/Soa.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import br.registro.dnsshim.common.server.DnsshimProtocolException;
3232
import br.registro.dnsshim.common.server.ProtocolStatusCode;
3333
import br.registro.dnsshim.util.DomainNameUtil;
34+
import br.registro.dnsshim.xfrd.domain.XfrdConfig;
35+
import br.registro.dnsshim.xfrd.domain.logic.XfrdConfigManager;
3436

3537
public class Soa extends ResourceRecord {
3638

@@ -49,12 +51,27 @@ public Soa(String ownername, DnsClass dnsClass, int ttl,
4951
this.mname = mname.toLowerCase();
5052
this.rname = rname.toLowerCase();
5153
this.serial = serial;
52-
this.refresh = refresh;
54+
55+
// Refresh minimum
56+
XfrdConfig config = XfrdConfigManager.getInstance();
57+
if (refresh < config.getMinimumSOARefresh()) {
58+
this.refresh = config.getMinimumSOARefresh();
59+
} else {
60+
this.refresh = refresh;
61+
}
62+
5363
this.retry = retry;
54-
this.expire = expire;
64+
65+
// Expire minimum
66+
if (expire < config.getMinimumSOAExpire()) {
67+
this.expire = config.getMinimumSOAExpire();
68+
} else {
69+
this.expire = expire;
70+
}
71+
5572
this.minimum = minimum;
5673
this.rdata = RdataSoaBuilder.get(this.mname, this.rname,
57-
serial, refresh, retry, expire, minimum);
74+
this.serial, this.refresh, this.retry, this.expire, this.minimum);
5875
}
5976

6077

0 commit comments

Comments
 (0)