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

Import 2.5 version of dnsshim from nic.br #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
DNSSHIM: NIC.br's DNS Secure Hidden Master

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

version 2.2.1
* Fix for list-zones and change-password
* Added hook to capture a shutdown signal from the Operating System
version 2.4
* NSD support
* New config parameter: minimun_soa_refresh
* New config parameter: minimun_soa_expire
* Include SOA RR as a hint in notify messages
Bug Fixes:
* Fixed command for changing user password

version 2.3
* Memory leak fixed

version 2.2
* TLS certificate import fix
Expand Down
21 changes: 10 additions & 11 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
<copy todir="${build}" >
<fileset dir="${src}">
<include name="**/resources/**" />
</fileset>
</copy>
<copy todir="${build}/META-INF">
<fileset dir="${src}/META-INF">
<include name="*" />
</fileset>
</fileset>
</copy>
</target>

Expand All @@ -40,7 +35,8 @@
<!-- signer -->
<jar jarfile="${dist}/dnsshim-signer.jar">
<fileset dir="${build}/" excludes="**/xfrd/" />
<manifest>

<manifest>
<attribute name="Main-Class"
value="br/registro/dnsshim/signer/server/SignerServer" />
<attribute name="Class-Path" value="${manifest-classpath-signer} ." /> <!-- class-path + current directory -->
Expand All @@ -64,9 +60,9 @@
</fileset>
</copy>

<copy file="scripts/SlaveSync.sh" todir="${dist}/"/>
<copy file="scripts/BindSync.sh" todir="${dist}/"/>
<copy file="scripts/NSDSync.sh" todir="${dist}/"/>
<copy file="scripts/CreateZoneDirs.sh" todir="${dist}/"/>
<copy file="ChangeLog" todir="${dist}/"/>

</target>

Expand All @@ -83,7 +79,9 @@
<map from="${lib.app.dir}" to="lib" /> <!-- to relative path -->
<path id="class.path">
<fileset dir="lib">
<include name="**/*.jar" />
<!-- <include name="**/*.jar" /> -->
<include name="*log4j*" />
<include name="*commons-codec*" />
</fileset>
</path>
</pathconvert>
Expand All @@ -93,7 +91,8 @@
<map from="${lib.app.dir}" to="lib" /> <!-- to relative path -->
<path id="class.path">
<fileset dir="lib">
<include name="**/*.jar" />
<include name="*log4j*" />
<include name="*commons-codec*" />
</fileset>
</path>
</pathconvert>
Expand Down
Binary file added lib/commons-validator-1.4.0.jar
Binary file not shown.
106 changes: 106 additions & 0 deletions scripts/BindSync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/sh
# Copyright (C) 2009 Registro.br. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 1. Redistribution of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.


added=0
removed=0
ERRCOUNTER=0
rndcExists=0

rndcPath="/usr/bin/rndc"
rndcPort="953"

if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]
then
addedZones=$1
removedZones=$2
serverIp=$3
timestamp=$4

if [ -x "$rndcPath" ]
then
rndcExists=1
fi

filename="${addedZones}${timestamp}"
# Make sure file exists and is not empty
if [ -s $filename ]
then
while read LINE
do
if [ $rndcExists -eq 1 ]
then
err=`eval $rndcPath -s $serverIp -p $rndcPort addzone $LINE 2>&1`
if [ $? -eq 0 ]
then
added=`expr $added + 1`
else
echo $err | grep "already exists"
if [ $? -eq 1 ]
then
zone=`echo $LINE | awk '{ print $1 }'`
echo $zone >> ${addedZones}.err
fi
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
else
zone=`echo $LINE | awk '{ print $1 }'`
echo $zone >> ${addedZones}.err
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
done < $filename
fi

filename="${removedZones}${timestamp}"
if [ -s $filename ]
then
while read LINE
do
if [ $rndcExists -eq 1 ]
then
err=`eval $rndcPath -s $serverIp -p $rndcPort delzone $LINE 2>&1`
if [ $? -eq 0 ]
then
removed=`expr $removed + 1`
else
echo $err | grep "not found"
if [ $? -eq 1 ]
then
echo $LINE >> ${removedZones}.err
fi
ERRCOUNTER=`expr $ERRCOUNTER + 1`

fi
else
echo $LINE >> ${removedZones}.err
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
done < $filename
fi

echo "SlaveSync $serverIp finished"
echo "Added: $added"
echo "Removed: $removed"
echo "Errors: $ERRCOUNTER"
fi
106 changes: 106 additions & 0 deletions scripts/NSDSync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/sh
# Copyright (C) 2009 Registro.br. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 1. Redistribution of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.


added=0
removed=0
ERRCOUNTER=0
nsdControlExists=0

nsdControlPath="/home/mauro/nsd/sbin/nsd-control"
nsdControlPort="8952"

if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]
then
addedZones=$1
removedZones=$2
serverIp=$3
timestamp=$4

if [ -x "$nsdControlPath" ]
then
nsdControlExists=1
fi

filename="${addedZones}${timestamp}"
# Make sure file exists and is not empty
if [ -s $filename ]
then
while read LINE
do
if [ $nsdControlExists -eq 1 ]
then
err=`eval $nsdControlPath -s $serverIp addzone $LINE 2>&1`
if [ $? -eq 0 ]
then
added=`expr $added + 1`
else
zone=`echo $LINE | awk '{ print $1 }'`
# checking if we could not add because the zone already exists
err=`eval $nsdControlPath -s $serverIp zonestatus $zone 2>&1`
if [ $? -eq 1 ]
then
echo $zone >> ${addedZones}.err
fi
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
else
echo $LINE >> ${addedZones}.err
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
done < $filename
fi

filename="${removedZones}${timestamp}"
if [ -s $filename ]
then
while read LINE
do
if [ $nsdControlExists -eq 1 ]
then
err=`eval $nsdControlPath -s $serverIp delzone $LINE 2>&1`
if [ $? -eq 0 ]
then
removed=`expr $removed + 1`
else
echo $err | grep "not present"
if [ $? -eq 1 ]
then
echo $LINE >> ${removedZones}.err
fi
ERRCOUNTER=`expr $ERRCOUNTER + 1`

fi
else
echo $LINE >> ${removedZones}.err
ERRCOUNTER=`expr $ERRCOUNTER + 1`
fi
done < $filename
fi

echo "SlaveSync $serverIp finished"
echo "Added: $added"
echo "Removed: $removed"
echo "Errors: $ERRCOUNTER"
fi
5 changes: 5 additions & 0 deletions src/br/registro/dnsshim/domain/A.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.net.UnknownHostException;
import java.nio.ByteBuffer;

import org.apache.commons.validator.routines.InetAddressValidator;

import br.registro.dnsshim.common.server.DnsshimProtocolException;
import br.registro.dnsshim.common.server.ProtocolStatusCode;
import br.registro.dnsshim.util.ByteUtil;
Expand All @@ -39,6 +41,9 @@ public A(String ownername, DnsClass dnsClass, int ttl, String ip)
throws DnsshimProtocolException {
super(ownername, RrType.A, dnsClass, ttl);
try {
if (InetAddressValidator.getInstance().isValid(ip) == false) {
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv4 address: " + ip);
}
this.addr = (Inet4Address) InetAddress.getByName(ip);
} catch (UnknownHostException uhe) {
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv4 address: " + ip);
Expand Down
12 changes: 12 additions & 0 deletions src/br/registro/dnsshim/domain/Aaaa.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.net.UnknownHostException;
import java.nio.ByteBuffer;

import org.apache.commons.validator.routines.InetAddressValidator;

import br.registro.dnsshim.common.server.DnsshimProtocolException;
import br.registro.dnsshim.common.server.ProtocolStatusCode;
import br.registro.dnsshim.util.ByteUtil;
Expand All @@ -39,6 +41,16 @@ public Aaaa(String ownername, DnsClass dnsClass, int ttl, String ipv6)
throws DnsshimProtocolException {
super(ownername, RrType.AAAA, dnsClass, ttl);
try {
// is a IPv4 ?
if (InetAddressValidator.getInstance().isValid(ipv6)){
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);
}
InetAddress inet = InetAddress.getByName(ipv6);

if ((inet instanceof Inet6Address) == false) {
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);
}

this.addr = (Inet6Address) InetAddress.getByName(ipv6);
} catch (UnknownHostException uhe) {
throw new DnsshimProtocolException(ProtocolStatusCode.INVALID_RESOURCE_RECORD, "Invalid IPv6 address: " + ipv6);
Expand Down
12 changes: 0 additions & 12 deletions src/br/registro/dnsshim/domain/Rrset.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ public Rrset(String ownername, RrType type, DnsClass dnsClass) {
this.dnsClass = dnsClass;
}

public Rrset(Rrset rrset) {
if (rrset == null) {
throw new IllegalArgumentException();
}

this.ownername = rrset.ownername;
this.type = rrset.type;
this.dnsClass = rrset.dnsClass;

records = new TreeSet<ResourceRecord>(rrset.records);
}

public String getOwnername() {
return ownername;
}
Expand Down
23 changes: 20 additions & 3 deletions src/br/registro/dnsshim/domain/Soa.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import br.registro.dnsshim.common.server.DnsshimProtocolException;
import br.registro.dnsshim.common.server.ProtocolStatusCode;
import br.registro.dnsshim.util.DomainNameUtil;
import br.registro.dnsshim.xfrd.domain.XfrdConfig;
import br.registro.dnsshim.xfrd.domain.logic.XfrdConfigManager;

public class Soa extends ResourceRecord {

Expand All @@ -49,12 +51,27 @@ public Soa(String ownername, DnsClass dnsClass, int ttl,
this.mname = mname.toLowerCase();
this.rname = rname.toLowerCase();
this.serial = serial;
this.refresh = refresh;

// Refresh minimum
XfrdConfig config = XfrdConfigManager.getInstance();
if (refresh < config.getMinimumSOARefresh()) {
this.refresh = config.getMinimumSOARefresh();
} else {
this.refresh = refresh;
}

this.retry = retry;
this.expire = expire;

// Expire minimum
if (expire < config.getMinimumSOAExpire()) {
this.expire = config.getMinimumSOAExpire();
} else {
this.expire = expire;
}

this.minimum = minimum;
this.rdata = RdataSoaBuilder.get(this.mname, this.rname,
serial, refresh, retry, expire, minimum);
this.serial, this.refresh, this.retry, this.expire, this.minimum);
}


Expand Down
Loading