Importing version 0.2.4

git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@4 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
Ben Klang
2005-12-02 04:21:08 +00:00
parent ce1c7b5782
commit 2991d167ee
8 changed files with 81 additions and 39 deletions

View File

@@ -1,6 +1,13 @@
Version 0.2.4 (todo) Version 0.2.5 (next)
+ Check for next availabe server in /etc/ldap.conf + Make ldap2dns behave like a secondary nameserver by storing
if first one is unavialable. the serial number, expire, refresh, retry and minimum values
in a record.
+ Password to connect to LDAP now is invisible to ps.
Version 0.2.4 (latest)
- Check for next availabe server in /etc/ldap.conf
if one is unavialable.
- Schema for DNSzone in dns.schema was corrected.
Version 0.2.3 Version 0.2.3
- Replaced integer variables for DNSserial, DNSttl etc. by strings - Replaced integer variables for DNSserial, DNSttl etc. by strings

View File

@@ -1,10 +1,10 @@
# $Id: Makefile,v 1.22 2001/02/16 09:51:23 jrief Exp $ # $Id: Makefile,v 1.24 2001/05/08 07:00:06 jrief Exp $
VERSION=0.2.3 VERSION=0.2.4
RELEASE=1 RELEASE=1
CC=gcc -O2 CC=gcc -O2
CFLAGS=$(INC) $(WITHTINYDNS) -DVERSION='"$(VERSION)"' CFLAGS=$(INC) -DVERSION='"$(VERSION)"'
OBJS=ldap2dns.o OBJS=ldap2dns.o
LIBS=-lldap -llber -lresolv LIBS=-lldap -llber
LD=gcc LD=gcc
LDFLAGS= LDFLAGS=
INSTALL_PREFIX= INSTALL_PREFIX=
@@ -32,7 +32,7 @@ install: all
install -o root -g root -m 644 dns.oc.conf $(LDAPCONFDIR)/ install -o root -g root -m 644 dns.oc.conf $(LDAPCONFDIR)/
clean: clean:
rm -f $(OBJS) ldap2dns ldap2dnsd data* *.db $(SPECFILE) rm -f $(OBJS) ldap2dns ldap2dnsd data* *.db core $(SPECFILE)
tar: clean tar: clean
cd ..; \ cd ..; \

View File

@@ -329,7 +329,8 @@ to populate Your LDAP directory.
<H3>6. Coming soon</H3> <H3>6. Coming soon</H3>
A browser-based administration toolkit, which connects directly A browser-based administration toolkit, which connects directly
to the LDAP-directory service. <A HREF="example.html">Here is a screenshot</A> to the LDAP-directory service. <A HREF="ldap2dns/example.html">
Here is a screenshot</A>
<P> <P>
<H3>7. To Do</H3> <H3>7. To Do</H3>

View File

@@ -7,7 +7,6 @@ Release: %RELEASE%
Copyright: GPL Copyright: GPL
Group: Daemons/DNS Group: Daemons/DNS
Source: ldap2dns-%{version}.tar.gz Source: ldap2dns-%{version}.tar.gz
Source1: http://cr.yp.to/djbdns/%{djbdns}.tar.gz
BuildRoot: /var/tmp/%{name}-root BuildRoot: /var/tmp/%{name}-root
Requires: openldap Requires: openldap
@@ -24,17 +23,13 @@ ldap2dns is designed to write binary data.cdb files used by tinydns, but also ma
used to write .db-files used by named. used to write .db-files used by named.
%prep %prep
#%setup -a1 -q
%setup %setup
%build %build
#make -C %{djbdns}
#make DJBDNSDIR="%{djbdns}" VERSION=%{version} RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
make VERSION=%{version} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" make VERSION=%{version} RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%install %install
[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot} [ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
#make DJBDNSDIR="%{djbdns}" INSTALL_PREFIX=$RPM_BUILD_ROOT install
make INSTALL_PREFIX=$RPM_BUILD_ROOT install make INSTALL_PREFIX=$RPM_BUILD_ROOT install
%clean %clean

3
TODO
View File

@@ -1,3 +0,0 @@
- Use env-variable LDAP2DNS_UPDATE for update intervalls
- If connection to ldapserver fialed retry later

View File

@@ -1,6 +1,6 @@
# schema for DNS data # schema for DNS data
# include this file into Your slapd.conf for openldap-2.0.x # include this file into Your slapd.conf for openldap-2.0.x
# $Id: dns.schema,v 1.4 2001/02/16 09:51:23 jrief Exp $ # $Id: dns.schema,v 1.5 2001/05/08 07:00:06 jrief Exp $
attributetype ( 1.2.840.113556.1.17.1 attributetype ( 1.2.840.113556.1.17.1
NAME 'DNSzonename' NAME 'DNSzonename'
@@ -99,7 +99,7 @@ objectclass ( 1.2.840.113556.1.17.21
NAME 'DNSzone' NAME 'DNSzone'
MUST ( objectclass $ cn ) MUST ( objectclass $ cn )
MAY ( DNSdomainname $ DNSserial $ DNSrefresh $ DNSretry $ DNSexpire $ DNSminimum MAY ( DNSdomainname $ DNSserial $ DNSrefresh $ DNSretry $ DNSexpire $ DNSminimum
$ DNSadminmailbox $ DNSzonemaster $ DNSzonetype $ DNSzoneclass $ DNSrrcount $ DNSadminmailbox $ DNSzonemaster $ DNStype $ DNSclass $ DNSrrcount
$ DNSttl $ DNStimestamp ) ) $ DNSttl $ DNStimestamp ) )
objectclass ( 1.2.840.113556.1.17.22 objectclass ( 1.2.840.113556.1.17.22

View File

@@ -27,6 +27,7 @@
<P> <P>
<H3 align=center>Download</H3> <H3 align=center>Download</H3>
<TABLE border=2 cellpadding=4 align=center> <TABLE border=2 cellpadding=4 align=center>
<TR align=center><TD>latest</TD><TD><A HREF="ldap2dns.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns.src.rpm">ldap2dns</A></TD><TD><A HREF="CHANGELOG">CHANGELOG</A></TD></TR>
<TR align=center><TH>Version</TH><TH>tar.gz</TH><TH>rpm</TH><TH>srpm</TH><TH>Released</TH></TR> <TR align=center><TH>Version</TH><TH>tar.gz</TH><TH>rpm</TH><TH>srpm</TH><TH>Released</TH></TR>
<TR align=center><TD>0.1.1</TD><TD><A HREF="ldap2dns-0.1.1.tar.gz">ldap2dns</A></TD><TD></TD><TD></TD><TD>2000-Sep-19</TD></TR> <TR align=center><TD>0.1.1</TD><TD><A HREF="ldap2dns-0.1.1.tar.gz">ldap2dns</A></TD><TD></TD><TD></TD><TD>2000-Sep-19</TD></TR>
<TR align=center><TD>0.1.2</TD><TD><A HREF="ldap2dns-0.1.2.tar.gz">ldap2dns</A></TD><TD></TD><TD></TD><TD>2000-Sep-22</TD></TR> <TR align=center><TD>0.1.2</TD><TD><A HREF="ldap2dns-0.1.2.tar.gz">ldap2dns</A></TD><TD></TD><TD></TD><TD>2000-Sep-22</TD></TR>
@@ -35,6 +36,7 @@
<TR align=center><TD>0.2.0</TD><TD><A HREF="ldap2dns-0.2.0.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.0-1.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.0-1.src.rpm">ldap2dns</A></TD><TD>2000-Dec-14</TD></TR> <TR align=center><TD>0.2.0</TD><TD><A HREF="ldap2dns-0.2.0.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.0-1.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.0-1.src.rpm">ldap2dns</A></TD><TD>2000-Dec-14</TD></TR>
<TR align=center><TD>0.2.2</TD><TD><A HREF="ldap2dns-0.2.2.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.2-2.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.2-2.src.rpm">ldap2dns</A></TD><TD>2001-Feb-16</TD></TR> <TR align=center><TD>0.2.2</TD><TD><A HREF="ldap2dns-0.2.2.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.2-2.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.2-2.src.rpm">ldap2dns</A></TD><TD>2001-Feb-16</TD></TR>
<TR align=center><TD>0.2.3</TD><TD><A HREF="ldap2dns-0.2.3.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.3-1.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.3-1.src.rpm">ldap2dns</A></TD><TD>2001-Mar-23</TD></TR> <TR align=center><TD>0.2.3</TD><TD><A HREF="ldap2dns-0.2.3.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.3-1.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.3-1.src.rpm">ldap2dns</A></TD><TD>2001-Mar-23</TD></TR>
<TR align=center><TD>0.2.4</TD><TD><A HREF="ldap2dns-0.2.4.tar.gz">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.4-1.i386.rpm">ldap2dns</A></TD><TD><A HREF="ldap2dns-0.2.4-1.src.rpm">ldap2dns</A></TD><TD>2001-May-08</TD></TR>
</TABLE> </TABLE>
</BLOCKQUOTE> </BLOCKQUOTE>

View File

@@ -1,6 +1,6 @@
/* /*
* Create data from an LDAP directory service to be used for tinydns * Create data from an LDAP directory service to be used for tinydns
* $Id: ldap2dns.c,v 1.27 2001/03/12 12:26:55 jrief Exp $ * $Id: ldap2dns.c,v 1.28 2001/05/08 07:00:06 jrief Exp $
* Copyright 2000 by Jacob Rief <jacob.rief@tiscover.com> * Copyright 2000 by Jacob Rief <jacob.rief@tiscover.com>
* License: GPL version 2 or later. See http://www.fsf.org for details * License: GPL version 2 or later. See http://www.fsf.org for details
*/ */
@@ -17,6 +17,7 @@
#define LDAP_CONF "/etc/openldap/ldap.conf" #define LDAP_CONF "/etc/openldap/ldap.conf"
#define OUTPUT_DATA 1 #define OUTPUT_DATA 1
#define OUTPUT_DB 2 #define OUTPUT_DB 2
#define MAXHOSTS 10
static char tinydns_textfile[256]; static char tinydns_textfile[256];
static char tinydns_texttemp[256]; static char tinydns_texttemp[256];
@@ -83,11 +84,12 @@ static struct
{ {
char searchbase[128]; char searchbase[128];
char binddn[128]; char binddn[128];
char hostname[128]; char hostname[MAXHOSTS][128];
int port[MAXHOSTS];
char password[128]; char password[128];
int usedhosts;
int is_daemon; int is_daemon;
int update_iv; int update_iv;
int port;
unsigned int output; unsigned int output;
int verbose; int verbose;
char ldifname[128]; char ldifname[128];
@@ -150,6 +152,31 @@ static void print_usage(void)
printf(" -V\t\tprint version and exit\n\n"); printf(" -V\t\tprint version and exit\n\n");
} }
static void parse_hosts(char* buf)
{
int i, port, k;
char value[128], rest[512];
options.usedhosts = 0;
for (i = 0; i<MAXHOSTS; i++) {
if ((k = sscanf(buf, "%128s:%d %512[A-Za-z0-9 .:_+-]", value, &port, rest))>=2) {
strcpy(options.hostname[i], value);
options.port[i] = port;
options.usedhosts++;
if (k==2)
break;
buf = rest;
} else if ((k = sscanf(buf, "%128s %512[A-Za-z0-9 .:_+-]", value, rest))>=1) {
strcpy(options.hostname[i], value);
options.port[i] = LDAP_PORT;
options.usedhosts++;
if (k==1)
break;
buf = rest;
} else break;
}
}
static int parse_options() static int parse_options()
{ {
extern char* optarg; extern char* optarg;
@@ -160,19 +187,18 @@ static int parse_options()
char* ev; char* ev;
strcpy(options.searchbase, ""); strcpy(options.searchbase, "");
strcpy(options.hostname, "localhost"); strcpy(options.hostname[0], "localhost");
options.port = LDAP_PORT; options.port[0] = LDAP_PORT;
if (ldap_conf = fopen(LDAP_CONF, "r")) { if (ldap_conf = fopen(LDAP_CONF, "r")) {
while(fgets(buf, 256, ldap_conf)!=0) { while(fgets(buf, 256, ldap_conf)!=0) {
int i;
if (sscanf(buf, "BASE %128s", value)==1) if (sscanf(buf, "BASE %128s", value)==1)
strcpy(options.searchbase, value); strcpy(options.searchbase, value);
if (sscanf(buf, "HOST %128s:%d", value, &len)==2) { if (sscanf(buf, "HOST %512[A-Za-z0-9 .:_+-]", value)==1)
strcpy(options.hostname, value); parse_hosts(value);
options.port = len;
} else if (sscanf(buf, "HOST %128s", value)==1)
strcpy(options.hostname, value);
if (sscanf(buf, "PORT %d", &len)==1) if (sscanf(buf, "PORT %d", &len)==1)
options.port = len; for (i = 0; i<MAXHOSTS; i++)
options.port[i] = len;
} }
fclose(ldap_conf); fclose(ldap_conf);
} }
@@ -218,7 +244,8 @@ static int parse_options()
strcpy(options.binddn, optarg); strcpy(options.binddn, optarg);
break; break;
case 'h': case 'h':
strcpy(options.hostname, optarg); strcpy(options.hostname[0], optarg);
options.usedhosts = 1;
break; break;
case 'L': case 'L':
if (optarg==NULL) if (optarg==NULL)
@@ -233,8 +260,8 @@ static int parse_options()
options.output |= OUTPUT_DB; options.output |= OUTPUT_DB;
break; break;
case 'p': case 'p':
if (sscanf(optarg, "%d", &options.port)!=1) if (sscanf(optarg, "%d", &options.port[0])!=1)
options.port = LDAP_PORT; options.port[0] = LDAP_PORT;
break; break;
case 'v': case 'v':
if (optarg && optarg[0]=='v') if (optarg && optarg[0]=='v')
@@ -753,6 +780,21 @@ static void read_dnszones(void)
ldap_msgfree(res); ldap_msgfree(res);
} }
static int connect()
{
int i;
for (i = 0; i<options.usedhosts; i++) {
ldap_con = ldap_init(options.hostname[i], options.port[i]);
if (ldap_simple_bind_s(ldap_con, options.binddn, options.password)==LDAP_SUCCESS) {
if (options.verbose&1)
printf("Connected to %s:%d as \"%s\"\n", options.hostname[i], options.port[i], options.binddn);
return 1;
}
}
ldap_con = NULL;
return 0;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@@ -771,11 +813,9 @@ int main(int argc, char** argv)
} }
set_datadir(); set_datadir();
for (;;) { for (;;) {
int ldaperr; int ldaperr = -1;
ldap_con = ldap_init(options.hostname, options.port); if (!connect()) {
ldaperr = ldap_con && ldap_simple_bind_s(ldap_con, options.binddn, options.password); fprintf(stderr, "Warning - Could not connect to any LDAP server\n");
if (ldaperr!=LDAP_SUCCESS) {
fprintf(stderr, "Warning - Could not connect to LDAP server %s:%d as '%s'\n", options.hostname, options.port, options.binddn);
if (options.is_daemon==0) if (options.is_daemon==0)
break; break;
sleep(options.update_iv); sleep(options.update_iv);