[debian-edu-commits] debian-edu/pkg-team/ 09/13: Imported Upstream version 0.2
Mike Gabriel
sunweaver at debian.org
Wed Oct 1 02:59:14 UTC 2014
This is an automated email from the git hooks/post-receive script.
sunweaver pushed a commit to branch master
in repository ldap2bind.
commit e47467027e83fcda7ed4671ecb034454b5da72a8
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Wed Oct 1 04:56:53 2014 +0200
Imported Upstream version 0.2
---
Makefile | 14 +--
changelog | 3 +
debian/README.debian | 6 --
debian/changelog | 6 --
debian/compat | 1 -
debian/control | 18 ----
debian/copyright | 12 ---
debian/cron.d | 4 -
debian/default | 26 -----
debian/dirs | 3 -
debian/install | 5 -
debian/ldap2zone.lintian-overrides | 2 -
debian/ldap2zone.manpages | 2 -
debian/rules | 49 ---------
dnszonehowto.html | 202 +++++++++++++++++++++++++++++++++++++
ldap2bind | 56 ++++++++--
ldap2bind.1 | 42 ++++++++
ldap2zone.c | 42 +++++---
18 files changed, 319 insertions(+), 174 deletions(-)
diff --git a/Makefile b/Makefile
index ab06ab2..4533f55 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,4 @@
all: ldap2zone
ldap2zone: ldap2zone.c
- gcc -Wall ldap2zone.c -o ldap2zone -lldap
-
-install: ldap2zone
- install -d ${DESTDIR}/usr/sbin
- install -d ${DESTDIR}/usr/share/doc/ldap2zone
- install ldap2zone ${DESTDIR}/usr/sbin/ldap2zone
- install ldap2bind ${DESTDIR}/usr/sbin/ldap2bind
- install -D -m 0644 debian/ldap2zone.lintian-overrides $(DESTDIR)/usr/share/lintian/overrides/ldap2zone
- install -d $(CURDIR)/debian/tmp/etc/default
- install -m 644 $(CURDIR)/debian/default $(CURDIR)/debian/tmp/etc/default/ldap2zone
-
-clean:
- -rm ldap2zone
+ gcc -Wall ldap2zone.c -o ldap2zone -lldap -llber
diff --git a/changelog b/changelog
new file mode 100644
index 0000000..80bbfac
--- /dev/null
+++ b/changelog
@@ -0,0 +1,3 @@
+ldap2zone-0.1 2005-04-24
+ This is the very first release and consists of just the file ldap2zone.c
+
diff --git a/debian/README.debian b/debian/README.debian
deleted file mode 100644
index 1d2aebd..0000000
--- a/debian/README.debian
+++ /dev/null
@@ -1,6 +0,0 @@
-ldap2zone for Debian
---------------------
-
-This program extract dns record from ldap and create zone files
-
-Cajus Pollmeier <cajus at debian.org>, Thu, 17 Mar 2005 09:05:17 +0100
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index e0909ab..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,6 +0,0 @@
-ldap2zone (0.1-1) unstable; urgency=low
-
- * Initial upload (Closes: #532665)
- * Include cron script
-
- -- Cajus Pollmeier <cajus at debian.org> Wed, 24 Jun 2009 10:02:00 +0200
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index d7d4ddb..0000000
--- a/debian/control
+++ /dev/null
@@ -1,18 +0,0 @@
-Source: ldap2zone
-Section: utils
-Priority: optional
-Maintainer: GOsa packages mainteners group <gosa-pkg at oss.gonicus.de>
-Uploaders: Cajus Pollmeier <cajus at debian.org>, Benoit Mortier <benoit.mortier at opensides.be>
-Standards-Version: 3.8.2
-Build-Depends: debhelper (>= 5.0.0), libldap2-dev
-Homepage: https://oss.gonicus.de/labs/gosa
-Vcs-Browser: https://oss.gonicus.de/repositories/goto/trunk/ldap2zone
-Vcs-Svn: https://oss.gonicus.de/repositories/goto/trunk/ldap2zone
-
-Package: ldap2zone
-Architecture: any
-Depends: ${shlibs:Depends}, bind9
-Conflicts: ldapdns, ldap2dns
-Description: Extract DNS zones from LDAP trees
- This tool allows the extraction of GOsa edited DNS
- zones and the creation of the Bind flat files.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index e6a5dd4..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,12 +0,0 @@
-This package was debianized by Cajus Pollmeier <cajus at debian.org>
-Thu, 17 Mar 2005 09:05:17 +0100.
-
-It was downloaded from http://www.uninett.no
-
-Copyright:
-
-This software is copyright (C) 2004, 2005 Stig Venaas <venaas at uninett.no>
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
diff --git a/debian/cron.d b/debian/cron.d
deleted file mode 100644
index 2984f81..0000000
--- a/debian/cron.d
+++ /dev/null
@@ -1,4 +0,0 @@
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-
- at reboot bind /usr/sbin/ldap2bind
- at hourly bind /usr/sbin/ldap2bind
diff --git a/debian/default b/debian/default
deleted file mode 100644
index 6bdf670..0000000
--- a/debian/default
+++ /dev/null
@@ -1,26 +0,0 @@
-# Configuration file for automatic deployment of ldap2zone generated zones to bind
-
-# Should we run the cronjob
-# DEFAULT: "false"
-RUN_DEPLOY="false"
-
-# How the LDAP server can be accessed
-# DEFAULT: "ldap://localhost"
-#LDAP_URI="ldap://localhost"
-
-# Where the zonefiles are located
-# DEFAULT: "/etc/bind"
-BIND_DIR="/etc/bind"
-
-# Time to live value for a and ptr records
-# DEFAULT: 500 Seconds
-TTL="500"
-
-# Prefix for zone definition files
-# DEFAULT: "db."
-# The zone definition file for 0.168.192.in-addr.arpa is stored as 'db.0.168.192.in-addr.arpa'
-PREFIX="db."
-
-# Allow Updates from these networks (semicolon separated and ended)
-# DEFAULT: Don't allow updates
-#ALLOW_UPDATE="192.168.0.0/24;"
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index dc52318..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-etc/default
-usr/sbin
-usr/share/doc/ldap2zone
diff --git a/debian/install b/debian/install
deleted file mode 100644
index 4973182..0000000
--- a/debian/install
+++ /dev/null
@@ -1,5 +0,0 @@
-usr/sbin/ldap2zone
-usr/sbin/ldap2bind
-etc/default/ldap2zone
-usr/share/lintian/overrides/ldap2zone
-
diff --git a/debian/ldap2zone.lintian-overrides b/debian/ldap2zone.lintian-overrides
deleted file mode 100644
index 7501fe3..0000000
--- a/debian/ldap2zone.lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-ldap2zone: binary-without-manpage usr/sbin/ldap2bind
-
diff --git a/debian/ldap2zone.manpages b/debian/ldap2zone.manpages
deleted file mode 100644
index b48c171..0000000
--- a/debian/ldap2zone.manpages
+++ /dev/null
@@ -1,2 +0,0 @@
-ldap2zone.1
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index dcd6652..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/make -f
-
-PACKAGE=ldap2zone
-VERSION=$(shell dpkg-parsechangelog |grep "^Version:" | cut -f2 -d' ')
-
-build: build-stamp
-build-stamp:
- dh_testdir
- $(MAKE)
- touch build-stamp
-
-clean:
- dh_testdir
- $(MAKE) clean
- rm -f build-stamp
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
-# install -d $(CURDIR)/debian/tmp/etc/default
-# install -m 644 $(CURDIR)/debian/default $(CURDIR)/debian/tmp/etc/default/ldap2zone
-
-binary-indep: build install
- dh_testdir
- dh_testroot
- dh_install --fail-missing --sourcedir=debian/tmp
- dh_installman
- dh_installchangelogs
- dh_installdocs debian/copyright
- dh_compress
- dh_fixperms
- dh_installcron
- dh_shlibdeps
- dh_strip
- dh_installdeb
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep
-
-binary-arch:
-
-.PHONY: binary binary-indep clean checkroot
diff --git a/dnszonehowto.html b/dnszonehowto.html
new file mode 100644
index 0000000..d15fe08
--- /dev/null
+++ b/dnszonehowto.html
@@ -0,0 +1,202 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<HEAD>
+<TITLE>How to use dnsZone with the BIND 9 sdb back-end</TITLE>
+</HEAD>
+<BODY>
+<H1>How to use dnsZone with the BIND 9 sdb back-end</H1>
+<H2>Record types</H2>
+The dnsZone class does not contain attributes for all known record types. The
+following types are missing: MF, MB, MG, MR, NULL, WKS, RP, AFSDB, X25, ISDN,
+RT, NSAP, NSAP-PTR, PX and GPOS. Anything defined after this document was
+written is obviously missing. If you want to add some record types that are
+defined by <A href="http://www.iana.org/assignments/dns-parameters">IANA</A>,
+please define it similar to what I've done for the existing ones. The name
+should be <em>{TYPE}Record</em>, and OID should be
+<em>1.3.6.1.4.1.2428.20.1.value</em>. For instance the RR type <em>LOC</em> has
+value <em>29</em>, so attribute name should be <em>LocRecord</em> (casing
+shouldn't matter), and the OID is <em>1.3.6.1.4.1.2428.20.1.29</em>. If you
+follow this, you know that it will be compatible with what I and others
+use, and I guarantee that the OIDs are unique.
+<p>
+The dnsZone class has attributes for some
+basic record types like A, SOA, etc. which are defined in the cosine schema
+and not in this schema. This means that your LDAP server must use both the
+cosine schema and this one. If you're not you should get an error from your
+LDAP server.
+<H2>Example 1</H2>
+Let's look at the following simple zone file.
+<pre>
+@ 3600 IN SOA ns.my-domain.com. hostmaster.my-domain.com. (
+ 2001030201 3600 1800 604800 86400 )
+ NS ns.my-domain.com.
+ NS ns.other-domain.com.
+ MX 10 mail.my-domain.com.
+ MX 20 mail.other-domain.com.
+
+my-hosta A 10.10.10.10
+ MX 10 mail.my-domain.com.
+ MX 20 mail.other-domain.com.
+www 1800 CNAME my-hosta.my-domain.com.
+my-hostb 3600 A 10.10.10.11
+ MX 10 mail.my-domain.com.
+ MX 20 mail.other-domain.com.
+</pre>
+This can be represented by the following LDIF file:
+<pre>
+dn: relativeDomainName=@, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: @
+zoneName: my-domain.com
+dNSTTL: 3600
+dNSClass: IN
+sOARecord: ns.my-domain.com. hostmaster.my-domain.com. 2001030201 3600 1800 604800 86400
+nSRecord: ns.my-domain.com.
+nSRecord: ns.other-domain.com.
+mXRecord: 10 mail.my-domain.com.
+mXRecord: 20 mail.other-domain.com.
+
+dn: relativeDomainName=my-hosta, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: my-hosta
+zoneName: my-domain.com
+dNSTTL: 86400
+dNSClass: IN
+aRecord: 10.10.10.10
+mXRecord: 10 mail.my-domain.com.
+mXRecord: 20 mail.other-domain.com.
+
+dn: relativeDomainName=www, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: www
+zoneName: my-domain.com
+dNSTTL: 1800
+dNSClass: IN
+cNAMERecord: my-hosta.my-domain.com.
+
+dn: relativeDomainName=my-hostb, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: my-hostb
+zoneName: my-domain.com
+dNSTTL: 3600
+dNSClass: IN
+aRecord: 10.10.10.11
+
+dn: relativeDomainName=my-hostb + dNSTTL=86400, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: my-hostb
+zoneName: my-domain.com
+dNSTTL: 86400
+dNSClass: IN
+mXRecord: 10 mail.my-domain.com.
+mXRecord: 20 mail.other-domain.com.
+</pre>
+<p>
+zoneName is the name of the zone, i.e. the name of the node in the zone
+that is highest up in the DNS tree. relativeDomainName is the name of
+the nodes relative to this, just like relative names in zone files
+dNSClass is not used by the sdb back-end, so you can leave it out if you
+like. The dNSTTL can also be left out, it will then default to the TTL
+specified in named.conf.
+<p>
+If you want RRs with the same name to have different TTLs (like
+my-hostb in the example), you will have to store it as multiple entries
+all including <em>relativeDomainName=my-hostb</em>. You will need at least as
+many entries as there are different TTLs. The main difficulty is to make
+sure that they all have unique DNs. The way I've chosen is to have a
+multi-valued RDN including dNSTTL, and put all RRs with the same TTL together.
+This is a bit ugly, but I think this is better than having one entry per RR.
+Let me know if you have other ideas.
+<p>
+When storing multiple zones you must make sure of course that the dn's are
+unique. This can easily be done by including the zoneName attribute in the
+DN. This can be done in several ways, one example would be
+<em>relativeDomainName=www, zoneName=my-zone, dc=my-domain, dc=com</em>.
+
+<H2>Example 2</H2>
+The schema is quite flexible as I'll try to show in the next two examples.
+If you have say the same MX records for the three hosts hosta, hostb and
+hostc, you might have one entry for each host and have the same mXRecord
+values in all the entries, or you can have one common entry with the
+mXRecords like this:
+<pre>
+dn: relativeDomainName=hosta, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: hosta
+relativeDomainName: hostb
+relativeDomainName: hostc
+zoneName: my-domain.com
+mXRecord: 10 mail.my-domain.com.
+mXRecord: 20 mail.other-domain.com.
+</pre>
+
+<H2>Example 3</H2>
+Assume that we have one web server with one IP address that is a virtual
+web server for hundreds of domains. Rather than having hundreds of similar
+entries, one for each zone, you might do as follows:
+<pre>
+dn: relativeDomainName=www, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: www
+zoneName: customerdomain1.com
+zoneName: customerdomain2.com
+...
+zoneName: customerdomain999.com
+aRecord: 10.10.10.10
+mXRecord: 10 mail.my-domain.com.
+mXRecord: 20 mail.other-domain.com.
+</pre>
+If you have a bunch of zones that are identical, except for the zone name,
+you might combine all their entries like above. Sort of like using the same
+zone file for multiple zones.
+
+<H2>Example 4</H2>
+Let's have a look at PTR records for reverse lookups for IPv4 addresses.
+Say you want to have a reverse for the address <em>1.2.3.4</em>. You then
+need a PTR record for <em>4.3.2.1.in-addr.arpa</em>. Using normal zone
+files you would typically have a file for the zone <em>3.2.1.in-addr.arpa</em>
+and inside that put say
+<pre>4 PTR my-hostc.my-domain.com.
+</pre>
+Using this back-end, you change <em>named.conf</em> like above, and use an
+LDAP entry like this:
+<pre>
+dn: relativeDomainName=4, zoneName=3.2.1.in-addr.arpa, dc=my-domain, dc=com
+objectClass: dNSZone
+relativeDomainName: 4
+zoneName: 3.2.1.in-addr.arpa
+pTRRecord: my-hostc.my-domain.com.
+</pre>
+Note that the DN can be whatever you like. If you use a DN like the above,
+you can use <em>zoneName=3.2.1.in-addr.arpa, dc=my-domain, dc=com</em> as
+the search base in the URL in <em>named.conf</em>.
+
+<H2>Example 5</H2>
+As a final example, you might try to search below
+<A href="ldap://ldap.venaas.no/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no">
+ldap://ldap.venaas.no/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no</A>. There
+you will find the zone data for venaas.com.
+You can also browse my directory data using
+<a href="http://sites.inka.de/ms/cgi-bin/web2ldap.fcgi/ldapurl?ldap://garibaldi.venaas.no/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no??sub?(objectclass=*)">web2ldap</a>.
+The master server for
+venaas.com uses this server. The slave uses normal zone transfers.
+
+<H2>Summary</H2>
+As should be evident from the examples, you have great flexibility when
+using this schema with the BIND9 back-end. The tree structure, the dn's,
+doesn't matter at all, the back-end simply does a sub-tree search using
+the base specified in named.conf for all entries in the wanted zone with
+the wanted name. For example when someone tries to look up the node
+<em>my-hosta.my-domain.com</em> it simply does a sub-tree search at the base
+given in <em>named.conf</em> with the filter
+<em>(&(zoneName=my-domain.com)(relativeDomainName=my-hosta))</em>. If someone
+looks up <em>my-domain.com</em> it uses the filter
+<em>(&(zoneName=my-domain.com)(relativeDomainName=@))</em>, and finally if
+someone wants to get the entire zone, for example a secondary using AXFR,
+it uses the filter <em>(zoneName=my-domain.com)</em>. Wildcards are not
+supported.
+<hr>
+<address>
+<a href="mailto:venaas at uninett.no">venaas at uninett.no</a>
+</address>
+Last modified: 2002-02-03
+</BODY>
diff --git a/ldap2bind b/ldap2bind
index 4f84ce7..89f44bf 100755
--- a/ldap2bind
+++ b/ldap2bind
@@ -2,43 +2,75 @@
[ -r /etc/default/ldap2zone ] && . /etc/default/ldap2zone
-[[ ${LDAP_URI} =~ 'ldap''s'?'://''.'* ]] || LDAP_URI="ldap://${LDAP_URI}"
+case "$LDAP_URI" in
+ldap://*|ldaps://*) ;;
+ *) LDAP_URI="ldap://${LDAP_URI}" ;;
+ esac
+
LDAPSEARCH=`which ldapsearch`
+
+if [ -z "${LDAPSEARCH}" ]; then
+ echo "ldapsearch program not in $PATH. Exiting..."
+ exit 1
+fi
+
LDAP_URI_PARAM=${LDAP_URI:+"-H $LDAP_URI"}
-ALLOW_UPDATE_PARAM=${ALLOW_UPDATE:+"allow-update {$ALLOW_UPDATE};"}
+
+if [ "$ALLOW_NOTIFY" ]; then
+ ALLOW_NOTIFY="$ALLOW_NOTIFY";
+else ALLOW_NOTIFY=;
+fi
+
+if [ "$ALLOW_UPDATE" ]; then
+ ALLOW_UPDATE_PARAM="allow-update {$ALLOW_UPDATE};";
+else ALLOW_UPDATE_PARAM=;
+fi
+
+if [ "$ALLOW_TRANSFER" ]; then
+ ALLOW_TRANSFER_PARAM="allow-transfer {$ALLOW_TRANSFER};";
+else ALLOW_TRANSFER_PARAM=;
+fi
ZONES=`ldapsearch -LLL $LDAP_HOST_PARAM -x "(objectClass=dNSZone)" zoneName | grep zoneName: | sort | uniq | awk '{print $2}'`
ldap2zone=`which ldap2zone`
rndc=`which rndc`
-if [ -z ${#ZONES} ]; then
+if [ -z "${ZONES}" ]; then
echo "No domains configured. Exiting..."
exit 0
fi
-if [ -z ${#rndc} ]; then
- echo "rndc utilty not in $PATH. Exiting..."
+if [ -z "${rndc}" ]; then
+ echo "rndc program not in $PATH. Exiting..."
exit 1
fi
-if [ -z ${#ldap2zone} ]; then
- echo "ldap2zone utilty not in $PATH. Exiting..."
+if [ -z "${ldap2zone}" ]; then
+ echo "ldap2zone program not in $PATH. Exiting..."
exit 1
fi
if [ ! -d $BIND_DIR ]; then
- echo "The directory specified as BIND_DIR does not exist. Exiting..."
+ echo "The directory specified as $BIND_DIR does not exist. Exiting..."
exit 1
fi
+if [ ! -d $BIND_DATA ]; then
+ echo "The directory specified as $BIND_DATA does not exist. Exiting..."
+ exit 1
+fi
+
+
if [ -w $BIND_DIR/named.conf.ldap2zone ]; then
>${BIND_DIR}/named.conf.ldap2zone
for domain in $ZONES; do
cat << EOF >> ${BIND_DIR}/named.conf.ldap2zone
zone "${domain}" {
type master;
- file "${BIND_DIR}/${PREFIX}${domain}";
+ $ALLOW_NOTIFY
+ file "${BIND_DATA}/${PREFIX}${domain}";
$ALLOW_UPDATE_PARAM
+ $ALLOW_TRANSFER_PARAM
};
EOF
done
@@ -48,11 +80,13 @@ fi
for domain in $ZONES; do
if $ldap2zone $domain $LDAP_URI $TTL > /tmp/$domain; then
lines=$(cat /tmp/$domain | wc -l)
- [ $lines -gt 1 ] && mv /tmp/$domain $BIND_DIR/${PREFIX}${domain}
+ [ $lines -gt 1 ] && mv /tmp/$domain $BIND_DATA/${PREFIX}${domain}
fi
result=$($rndc reload $domain 2>&1)
if [ $? -ne 0 ]; then
- echo -e "Reloading the zone '$domain' failed:\n$result" 1>&2
+ printf "Reloading the zone '$domain' failed: $result\n" 1>&2
+ else
+ printf "Reloading the zone '$domain' was successful\n" 1>&2
fi
done
diff --git a/ldap2bind.1 b/ldap2bind.1
new file mode 100644
index 0000000..005a4e9
--- /dev/null
+++ b/ldap2bind.1
@@ -0,0 +1,42 @@
+.TH LDAP2BIND 1
+.SH NAME
+ldap2bind \- update bind's DNS zones from LDAP
+.SH SYNOPSIS
+.B ldap2bind
+.SH DESCRIPTION
+The
+.BR ldap2bind
+program converts DNS zones from LDAP to bind zone
+configuration files and reloads these zones.
+It uses
+.BR ldap2zone (1)
+to do the conversion.
+.PP
+The script takes no options, but some variables are defined and can be
+modified in
+.I /etc/defaults/ldap2zone.
+.PP
+Usually
+.BR ldap2bind
+is called from a cron job that updates the zones
+regularly from LDAP.
+.SH Notes
+The file
+.I named.conf.ldap2zone
+must exist in bind's configuration directory and has to be included in
+bind's configuration. This is usually done by including it in
+.I named.conf.local.
+.SH "EXIT STATUS"
+.BR ldap2bind
+returns 0 on success, 1 on failures.
+.SH FILES
+.nf
+.ta \w'/etc/bind/named.conf.ldap2zone\ 'u
+\fI/etc/default/ldap2zone\fR configuration variables
+\fI/etc/bind/named.conf.ldap2zone\fR zones extracted from LDAP
+.SH AUTHOR
+This manual page has been written by Andreas B. Mundt
+<andi.mundt at web.de> for the Debian Project (but may be used by
+others).
+.SH "SEE ALSO"
+.BR ldap2zone (1).
diff --git a/ldap2zone.c b/ldap2zone.c
index 8b9fa6d..80e5231 100644
--- a/ldap2zone.c
+++ b/ldap2zone.c
@@ -250,13 +250,15 @@ int main(int argc, char **argv) {
LDAP *ld;
char *fltr = NULL;
LDAPMessage *res, *e;
- char *a, **ttlvals, **soavals, *serial;
- struct berval **vals, **names;
+ char *a, *serial;
+ struct berval **vals, **names, **ttlvals, **soavals;
char type[64];
BerElement *ptr;
- int i, j, rc, msgid;
+ int i, j, rc, msgid,msgidp,sizelimit = 0;
struct assstack_entry *zone = NULL;
-
+ LDAPControl **server = NULL, **client = NULL;
+ struct timeval timeout;
+
if (argc < 4 || argc > 5)
usage(argv[0]);
@@ -280,7 +282,7 @@ int main(int argc, char **argv) {
}
defaultttl = argv[3];
-
+
rc = ldap_initialize(&ld, hostporturl);
if (rc != LDAP_SUCCESS)
err(argv[0], "ldap_initialize() failed");
@@ -289,7 +291,8 @@ int main(int argc, char **argv) {
/* serial number specified, check if different from one in SOA */
fltr = (char *)malloc(strlen(argv[1]) + strlen("(&(relativeDomainName=@)(zoneName=))") + 1);
sprintf(fltr, "(&(relativeDomainName=@)(zoneName=%s))", argv[1]);
- msgid = ldap_search(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
+ msgid = ldap_search_ext(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0, server, client, NULL, 0, &msgidp);
+
if (msgid == -1)
err(argv[0], "ldap_search() failed");
@@ -305,7 +308,8 @@ int main(int argc, char **argv) {
err(argv[0], "ldap_first_entry() failed");
}
- soavals = ldap_get_values(ld, e, "SOARecord");
+ soavals = ldap_get_values_len(ld, e, "SOARecord");
+
if (soavals)
break;
}
@@ -316,32 +320,37 @@ int main(int argc, char **argv) {
}
/* We have a SOA, compare serial numbers */
- /* Only checkinf first value, should be only one */
- s = strchr(soavals[0], ' ');
+ /* Only checking first value, should be only one */
+ /* chat changed to struct see where is problem */
+ s = strchr(soavals[0]->bv_val, ' ');
s++;
s = strchr(s, ' ');
s++;
serial = s;
s = strchr(s, ' ');
*s = '\0';
+
if (!strcmp(serial, argv[4])) {
- ldap_value_free(soavals);
+ ldap_value_free_len(soavals);
+
err(argv[0], "serial numbers match");
}
- ldap_value_free(soavals);
+ ldap_value_free_len(soavals);
}
if (!fltr)
fltr = (char *)malloc(strlen(argv[1]) + strlen("(zoneName=)") + 1);
+
if (!fltr)
err(argv[0], "Malloc failed");
+
sprintf(fltr, "(zoneName=%s)", argv[1]);
- msgid = ldap_search(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
+ msgid = ldap_search_ext(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0, server, client, 0, 0, &msgidp);
if (msgid == -1)
err(argv[0], "ldap_search() failed");
- while ((rc = ldap_result(ld, msgid, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) {
+ while ((rc = ldap_result(ld, msgidp, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) {
/* not supporting continuation references at present */
if (rc != LDAP_RES_SEARCH_ENTRY)
err(argv[0], "ldap_result() returned cont.ref? Exiting");
@@ -357,8 +366,8 @@ int main(int argc, char **argv) {
if (!names)
continue;
- ttlvals = ldap_get_values(ld, e, "dNSTTL");
- ttl = ttlvals ? ttlvals[0] : defaultttl;
+ ttlvals = ldap_get_values_len(ld, e, "dNSTTL");
+ ttl = ttlvals ? ttlvals[0]->bv_val : defaultttl;
for (a = ldap_first_attribute(ld, e, &ptr); a != NULL; a = ldap_next_attribute(ld, e, ptr)) {
char *s;
@@ -387,7 +396,8 @@ int main(int argc, char **argv) {
if (ptr)
ber_free(ptr, 0);
if (ttlvals)
- ldap_value_free(ttlvals);
+ ldap_value_free_len(ttlvals);
+
ldap_value_free_len(names);
/* free this result */
ldap_msgfree(res);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/ldap2bind.git
More information about the debian-edu-commits
mailing list