Commit 2c2a54d6 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Add DNS SRV backend framework (a work in progress).

parent f0c4f83e
This diff is collapsed.
......@@ -149,6 +149,9 @@ dnl SLAPD Backend options
OL_ARG_ENABLE(bdb2,[ --enable-bdb2 enable bdb2 backend], no)dnl
OL_ARG_WITH(bdb2_module,[ --with-bdb2-module module type], static,
[static dynamic])
OL_ARG_ENABLE(dnssrv,[ --enable-dnssrv enable bdb2 backend], no)dnl
OL_ARG_WITH(dnssrv_module,[ --with-dnssrv-module module type], static,
[static dynamic])
OL_ARG_ENABLE(ldap,[ --enable-ldap enable ldap backend], no)dnl
OL_ARG_WITH(ldap_module,[ --with-ldap-module module type], static,
[static dynamic])
......@@ -159,7 +162,6 @@ OL_ARG_WITH(ldbm_module,[ --with-ldbm-module module type], static,
[static dynamic])
OL_ARG_WITH(ldbm_type,[ --with-ldbm-type use LDBM type], auto,
[auto btree hash])
OL_ARG_ENABLE(passwd,[ --enable-passwd enable passwd backend], no)dnl
OL_ARG_WITH(passwd_module,[ --with-passwd-module module type], static,
[static dynamic])
......@@ -169,12 +171,12 @@ OL_ARG_WITH(perl_module,[ --with-perl-module module type], static,
OL_ARG_ENABLE(shell,[ --enable-shell enable shell backend], no)dnl
OL_ARG_WITH(shell_module,[ --with-shell-module module type], static,
[static dynamic])
OL_ARG_ENABLE(tcl,[ --enable-tcl enable tcl backend], no)dnl
OL_ARG_WITH(tcl_module,[ --with-tcl-module module type], static,
[static dynamic])
OL_ARG_ENABLE(sql,[ --enable-sql enable sql backend], no)dnl
OL_ARG_WITH(sql_module,[ --with-sql-module module type], static,
[static dynamic])
OL_ARG_ENABLE(tcl,[ --enable-tcl enable tcl backend], no)dnl
OL_ARG_WITH(tcl_module,[ --with-tcl-module module type], static,
[static dynamic])
dnl ----------------------------------------------------------------
dnl SLURPD OPTIONS
......@@ -206,6 +208,9 @@ if test $ol_enable_slapd = no ; then
if test $ol_enable_bdb2 = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-bdb2 argument])
fi
if test $ol_enable_dnssrv = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-dnssrv argument])
fi
if test $ol_enable_ldap = yes ; then
AC_MSG_WARN([slapd disabled, ignoring --enable-ldap argument])
fi
......@@ -257,6 +262,9 @@ if test $ol_enable_slapd = no ; then
if test $ol_with_bdb2_module != static ; then
AC_MSG_WARN([slapd disabled, ignoring --with-bdb2-module argument])
fi
if test $ol_with_dnssrv_module != static ; then
AC_MSG_WARN([slapd disabled, ignoring --with-dnssrv-module argument])
fi
if test $ol_with_ldap_module != static ; then
AC_MSG_WARN([slapd disabled, ignoring --with-ldap-module argument])
fi
......@@ -284,6 +292,7 @@ if test $ol_enable_slapd = no ; then
# force settings to no
ol_enable_bdb2=no
ol_enable_dnssrv=no
ol_enable_ldap=no
ol_enable_ldbm=no
ol_enable_passwd=no
......@@ -305,6 +314,7 @@ if test $ol_enable_slapd = no ; then
ol_with_ldbm_type=no
ol_with_bdb2_module=static
ol_with_dnssrv_module=static
ol_with_ldap_module=static
ol_with_ldbm_module=static
ol_with_passwd_module=static
......@@ -335,12 +345,13 @@ elif test $ol_enable_ldbm = no ; then
fi
if test $ol_enable_modules != yes -a \
$ol_enable_dnssrv = no -a \
$ol_enable_ldap = no -a \
$ol_enable_passwd = no -a \
$ol_enable_perl = no -a \
$ol_enable_shell = no -a \
$ol_enable_tcl = no -a \
$ol_enable_sql = no ; then
$ol_enable_sql = no -a \
$ol_enable_tcl = no ; then
AC_MSG_ERROR([slapd requires a backend])
fi
......@@ -427,18 +438,21 @@ BUILD_LDAPD=no
BUILD_SLAPD=no
BUILD_SLURPD=no
BUILD_QUIPU=no
BUILD_THREAD=no
BUILD_BDB2=no
BUILD_DNSSRV=no
BUILD_LDAP=no
BUILD_LDBM=no
BUILD_PASSWD=no
BUILD_PERL=no
BUILD_QUIPU=no
BUILD_SHELL=no
BUILD_TCL=no
BUILD_SQL=no
BUILD_THREAD=no
BUILD_TCL=no
BUILD_BDB2_DYNAMIC=static
BUILD_DNSSRV_DYNAMIC=static
BUILD_LDAP_DYNAMIC=static
BUILD_LDBM_DYNAMIC=static
BUILD_PASSWD_DYNAMIC=static
......@@ -640,6 +654,7 @@ if test $ol_enable_modules != no ; then
ol_link_modules=yes
else
ol_with_bdb2_module=static
ol_with_dnssrv_module=static
ol_with_ldap_module=static
ol_with_ldbm_module=static
ol_with_passwd_module=static
......@@ -2251,6 +2266,19 @@ if test "$ol_link_bdb2" != no ; then
fi
fi
if test "$ol_enable_dnssrv" != no ; then
AC_DEFINE(SLAPD_DNSSRV,1,[define to support DNS SRV backend])
BUILD_SLAPD=yes
BUILD_DNSSRV=yes
if test "$ol_with_dnssrv_module" != static ; then
AC_DEFINE(SLAPD_DNSSRV_DYNAMIC,1,
[define to support dynamic DNS SRV backend])
BUILD_DNSSRV=mod
BUILD_DNSSRV_DYNAMIC=shared
SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-dnssrv/back_dnssrv.la"
fi
fi
if test "$ol_enable_ldap" != no ; then
AC_DEFINE(SLAPD_LDAP,1,[define to support LDAP backend])
BUILD_SLAPD=yes
......@@ -2380,22 +2408,24 @@ AC_SUBST(DYN_EXT)
AC_SUBST(BUILD_LDAPD)
AC_SUBST(BUILD_SLAPD)
AC_SUBST(BUILD_BDB2)
AC_SUBST(BUILD_DNSSRV)
AC_SUBST(BUILD_LDAP)
AC_SUBST(BUILD_LDBM)
AC_SUBST(BUILD_PASSWD)
AC_SUBST(BUILD_PERL)
AC_SUBST(BUILD_QUIPU)
AC_SUBST(BUILD_SHELL)
AC_SUBST(BUILD_TCL)
AC_SUBST(BUILD_SQL)
AC_SUBST(BUILD_TCL)
AC_SUBST(BUILD_BDB2_DYNAMIC)
AC_SUBST(BUILD_DNSSRV_DYNAMIC)
AC_SUBST(BUILD_LDAP_DYNAMIC)
AC_SUBST(BUILD_LDBM_DYNAMIC)
AC_SUBST(BUILD_PASSWD_DYNAMIC)
AC_SUBST(BUILD_PERL_DYNAMIC)
AC_SUBST(BUILD_SHELL_DYNAMIC)
AC_SUBST(BUILD_TCL_DYNAMIC)
AC_SUBST(BUILD_SQL_DYNAMIC)
AC_SUBST(BUILD_TCL_DYNAMIC)
AC_SUBST(BUILD_SLURPD)
AC_SUBST(LDAP_LIBS)
......@@ -2464,13 +2494,14 @@ servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
servers/slapd/back-bdb2/Makefile:build/top.mk:servers/slapd/back-bdb2/Makefile.in:build/mod.mk \
servers/slapd/back-dnssrv/Makefile:build/top.mk:servers/slapd/back-dnssrv/Makefile.in:build/mod.mk \
servers/slapd/back-ldap/Makefile:build/top.mk:servers/slapd/back-ldap/Makefile.in:build/mod.mk \
servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/mod.mk \
servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/mod.mk \
servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/mod.mk \
servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/mod.mk \
servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:build/mod.mk \
servers/slapd/back-sql/Makefile:build/top.mk:servers/slapd/back-sql/Makefile.in:build/mod.mk \
servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:build/mod.mk \
servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
......
......@@ -898,6 +898,12 @@
/* define to support dynamic BDB2 backend */
#undef SLAPD_BDB2_DYNAMIC
/* define to support DNS SRV backend */
#undef SLAPD_DNSSRV
/* define to support dynamic DNS SRV backend */
#undef SLAPD_DNSSRV_DYNAMIC
/* define to support LDAP backend */
#undef SLAPD_LDAP
......
# $OpenLDAP$
###########################################################################
# Copyright 2000, OpenLDAP Foundation, All rights reserved.
#
# Redistribution and use in source and binary forms are permitted only
# as authorized by the OpenLDAP Public License. A copy of this
# license is available at http://www.OpenLDAP.org/license.html or
# in file LICENSE in the top-level directory of the distribution.
###########################################################################
# DNSSRV backend written by Kurt Zeilenga
##########################################################################
SRCS = init.c search.c config.c bind.c compare.c \
modify.c add.c modrdn.c delete.c
OBJS = init.lo search.lo config.lo bind.lo compare.lo \
modify.lo add.lo modrdn.lo delete.lo
LDAP_INCDIR= ../../../include
LDAP_LIBDIR= ../../../libraries
BUILD_OPT = "--enable-dnssrv"
BUILD_MOD = @BUILD_DNSSRV@
LINKAGE = @BUILD_DNSSRV_DYNAMIC@
LIBBASE = back_dnssrv
XINCPATH = -I.. -I$(srcdir)/..
XDEFS = $(MODULES_CPPFLAGS)
XLDFLAGS = $(MODULES_LDFLAGS)
all-local-lib: ../.backend
../.backend: lib$(LIBBASE).a
@touch $@
/* add.c - DNS SRV backend add function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_add(
Backend *be,
Connection *conn,
Operation *op,
Entry *e
)
{
return -1;
}
/* $OpenLDAP$ */
/*
* Copyright 2000, OpenLDAP Foundation, All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
#ifndef DNSSRV_BACK_H
#define DNSSRV_BACK_H 1
#include "external.h"
LDAP_BEGIN_DECL
LDAP_END_DECL
#endif /* DNSSRV_BACK_H */
/* bind.c - DNS SRV backend bind function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_bind(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
char *ndn,
int method,
char *mech,
struct berval *cred,
char **edn
)
{
return( -1 );
}
/* compare.c - DNS SRV backend compare function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_compare(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
char *ndn,
Ava *ava
)
{
return -1;
}
/* config.c - DNS SRV backend configuration file routine */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_db_config(
BackendDB *be,
const char *fname,
int lineno,
int argc,
char **argv
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
char *port;
if ( li == NULL ) {
fprintf( stderr, "%s: line %d: DNSSRV backend info is null!\n",
fname, lineno );
return( 1 );
}
/* no configuration options (yet) */
{
fprintf( stderr,
"%s: line %d: unknown directive \"%s\" in DNSSRV database definition (ignored)\n",
fname, lineno, argv[0] );
}
return 0;
}
/* delete.c - DNS SRV backend delete function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_delete(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
char *ndn
)
{
return -1;
}
/* $OpenLDAP$ */
/*
* Copyright 2000, OpenLDAP Foundation, All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
#ifndef _DNSSRV_EXTERNAL_H
#define _DNSSRV_EXTERNAL_H
LDAP_BEGIN_DECL
extern int dnssrv_back_initialize LDAP_P(( BackendInfo *bi ));
extern int dnssrv_back_open LDAP_P(( BackendInfo *bi ));
extern int dnssrv_back_close LDAP_P(( BackendInfo *bi ));
extern int dnssrv_back_destroy LDAP_P(( BackendInfo *bi ));
extern int dnssrv_back_db_init LDAP_P(( BackendDB *bd ));
extern int dnssrv_back_db_destroy LDAP_P(( BackendDB *bd ));
extern int dnssrv_back_db_config LDAP_P(( BackendDB *bd,
const char *fname, int lineno, int argc, char **argv ));
extern int dnssrv_back_bind LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
char *dn, char *ndn, int method, char* mech,
struct berval *cred, char** edn ));
extern int dnssrv_back_search LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, char *base,
char *nbase, int scope, int deref, int sizelimit, int timelimit,
Filter *filter, char *filterstr, char **attrs, int attrsonly ));
extern int dnssrv_back_compare LDAP_P((BackendDB *bd,
Connection *conn, Operation *op,
char *dn, char *ndn, Ava *ava ));
extern int dnssrv_back_modify LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
char *dn, char *ndn, Modifications *ml ));
extern int dnssrv_back_modrdn LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op,
char *dn, char *ndn, char*newrdn, int deleteoldrdn,
char *newSuperior ));
extern int dnssrv_back_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, Entry *e ));
extern int dnssrv_back_delete LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, char *dn, char *ndn ));
LDAP_END_DECL
#endif /* _DNSSRV_EXTERNAL_H */
/* init.c - initialize ldap backend */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
#ifdef SLAPD_DNSSRV_DYNAMIC
int back_dnssrv_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
bi.bi_type = "dnssrv";
bi.bi_init = dnssrv_back_initialize;
backend_add(&bi);
return 0;
}
#endif /* SLAPD_DNSSRV_DYNAMIC */
int
dnssrv_back_initialize(
BackendInfo *bi
)
{
bi->bi_open = 0;
bi->bi_config = 0;
bi->bi_close = 0;
bi->bi_destroy = 0;
bi->bi_db_init = dnssrv_back_db_init;
bi->bi_db_config = dnssrv_back_db_config;
bi->bi_db_open = 0;
bi->bi_db_close = 0;
bi->bi_db_destroy = dnssrv_back_db_destroy;
bi->bi_op_bind = dnssrv_back_bind;
bi->bi_op_unbind = 0;
bi->bi_op_search = dnssrv_back_search;
bi->bi_op_compare = dnssrv_back_compare;
bi->bi_op_modify = dnssrv_back_modify;
bi->bi_op_modrdn = dnssrv_back_modrdn;
bi->bi_op_add = dnssrv_back_add;
bi->bi_op_delete = dnssrv_back_delete;
bi->bi_op_abandon = 0;
bi->bi_extended = 0;
bi->bi_acl_group = 0;
#ifdef HAVE_CYRUS_SASL
bi->bi_sasl_authorize = 0;
bi->bi_sasl_getsecret = 0;
bi->bi_sasl_putsecret = 0;
#endif /* HAVE_CYRUS_SASL */
bi->bi_connection_init = 0;
bi->bi_connection_destroy = 0;
return 0;
}
int
dnssrv_back_db_init(
Backend *be
)
{
#if 0
struct ldapinfo *li;
li = (struct ldapinfo *) ch_calloc( 1, sizeof(struct ldapinfo) );
ldap_pvt_thread_mutex_init( &li->conn_mutex );
be->be_private = li;
return li == NULL;
#else
return 0;
#endif
}
int
dnssrv_back_db_destroy(
Backend *be
)
{
#if 0
struct ldapinfo *li;
if (be->be_private) {
li = (struct ldapinfo *)be->be_private;
if (li->host) {
free(li->host);
li->host = NULL;
}
ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
}
free( be->be_private );
return 0;
#else
return 0;
#endif
}
/* modify.c - DNS SRV backend modify function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-dnssrv.h"
int
dnssrv_back_modify(
Backend *be,
Connection *conn,
Operation *op,
char *dn,
char *ndn,
LDAPModList *ml
)
{
return -1;
}
/* modrdn.c - DNS SRV backend modrdn function */
/* $OpenLDAP$ */
/*
* Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>