|
From: <abe...@us...> - 2013-10-02 19:21:38
|
Revision: 6212
http://sourceforge.net/p/astlinux/code/6212
Author: abelbeck
Date: 2013-10-02 19:21:33 +0000 (Wed, 02 Oct 2013)
Log Message:
-----------
slapd LDAP server, initial check-in, not enabled in default configs, runtime enable with LDAP_SERVER=yes
The goal is to setup an ODBC SQL(ite3) LDAP backend to the file /mnt/kd/ldap-odbc.sqlite3 which could store an address book that can be distributed via LDAP to IP Phones, mail app contacts, etc. and additionally be used within Asterisk using func_odbc. Far more configuration and testing is required to prove this is useful. Also openldap debug is enabled for now on a temp basis.
Modified Paths:
--------------
branches/1.0/astlinux-ast11.config
branches/1.0/astlinux.config
branches/1.0/astlinux18.config
branches/1.0/package/openldap/Config.in
branches/1.0/package/openldap/openldap.mk
branches/1.0/package/unixodbc/unixodbc.init
branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf
Added Paths:
-----------
branches/1.0/package/openldap/slapd.init
Modified: branches/1.0/astlinux-ast11.config
===================================================================
--- branches/1.0/astlinux-ast11.config 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/astlinux-ast11.config 2013-10-02 19:21:33 UTC (rev 6212)
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Buildroot 2011.08-svn6129-dirty Configuration
-# Fri Jul 12 11:14:34 2013
+# Buildroot 2011.08-svn6211-dirty Configuration
+# Mon Sep 30 15:22:34 2013
#
BR2_HAVE_DOT_CONFIG=y
# BR2_arm is not set
@@ -737,6 +737,7 @@
# BR2_PACKAGE_NUTTCP is not set
# BR2_PACKAGE_OLSR is not set
BR2_PACKAGE_OPENLDAP=y
+# BR2_PACKAGE_OPENLDAP_SERVER is not set
# BR2_PACKAGE_OPENNTPD is not set
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_OPENVPN=y
Modified: branches/1.0/astlinux.config
===================================================================
--- branches/1.0/astlinux.config 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/astlinux.config 2013-10-02 19:21:33 UTC (rev 6212)
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Buildroot 2011.08-svn6129-dirty Configuration
-# Fri Jul 12 11:14:23 2013
+# Buildroot 2011.08-svn6211-dirty Configuration
+# Mon Sep 30 15:22:26 2013
#
BR2_HAVE_DOT_CONFIG=y
# BR2_arm is not set
@@ -739,6 +739,7 @@
# BR2_PACKAGE_NUTTCP is not set
# BR2_PACKAGE_OLSR is not set
BR2_PACKAGE_OPENLDAP=y
+# BR2_PACKAGE_OPENLDAP_SERVER is not set
# BR2_PACKAGE_OPENNTPD is not set
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_OPENVPN=y
Modified: branches/1.0/astlinux18.config
===================================================================
--- branches/1.0/astlinux18.config 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/astlinux18.config 2013-10-02 19:21:33 UTC (rev 6212)
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Buildroot 2011.08-svn6129-dirty Configuration
-# Fri Jul 12 11:14:30 2013
+# Buildroot 2011.08-svn6211-dirty Configuration
+# Mon Sep 30 15:22:28 2013
#
BR2_HAVE_DOT_CONFIG=y
# BR2_arm is not set
@@ -737,6 +737,7 @@
# BR2_PACKAGE_NUTTCP is not set
# BR2_PACKAGE_OLSR is not set
BR2_PACKAGE_OPENLDAP=y
+# BR2_PACKAGE_OPENLDAP_SERVER is not set
# BR2_PACKAGE_OPENNTPD is not set
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_OPENVPN=y
Modified: branches/1.0/package/openldap/Config.in
===================================================================
--- branches/1.0/package/openldap/Config.in 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/package/openldap/Config.in 2013-10-02 19:21:33 UTC (rev 6212)
@@ -6,8 +6,16 @@
Lightweight Directory Access Protocol.
The suite includes:
- - slapd: stand-alone LDAP daemon (server) DISABLED
+ - slapd: stand-alone LDAP daemon (optional server)
- libraries: implementing the LDAP protocol
- utilities, tools, and sample clients (ex. ldapsearch)
http://www.openldap.org/
+
+config BR2_PACKAGE_OPENLDAP_SERVER
+ bool "openldap-server"
+ default n
+ depends on BR2_PACKAGE_OPENLDAP
+ help
+ Include slapd and server related files.
+
Modified: branches/1.0/package/openldap/openldap.mk
===================================================================
--- branches/1.0/package/openldap/openldap.mk 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/package/openldap/openldap.mk 2013-10-02 19:21:33 UTC (rev 6212)
@@ -15,20 +15,35 @@
OPENLDAP_CONF_OPT = \
--enable-shared \
--disable-static \
- --disable-debug \
+ --enable-debug \
--enable-syslog \
--enable-ipv6 \
--with-tls \
- --with-yielding_select="yes" \
+ --with-odbc=unixodbc \
+ --with-yielding_select=yes \
--without-fetch \
--without-cyrus-sasl \
- --disable-slapd \
+ --enable-slapd \
+ --enable-sql \
+ --enable-null \
--disable-local \
--disable-bdb \
--disable-hdb \
--disable-monitor \
--disable-relay
+ifeq ($(BR2_PACKAGE_OPENLDAP_SERVER),y)
+define OPENLDAP_INSTALL_TARGET_SERVER
+ cp -a $(STAGING_DIR)/etc/openldap/schema $(TARGET_DIR)/etc/openldap/
+ $(INSTALL) -D -m 0755 $(STAGING_DIR)/usr/libexec/slapd $(TARGET_DIR)/usr/sbin/
+ $(INSTALL) -D -m 0755 $(STAGING_DIR)/usr/bin/ldap* $(TARGET_DIR)/usr/bin/
+ $(INSTALL) -m 0755 -D package/openldap/slapd.init $(TARGET_DIR)/etc/init.d/slapd
+ ln -sf /tmp/etc/openldap/slapd.conf $(TARGET_DIR)/etc/openldap/slapd.conf
+ ln -sf ../../init.d/slapd $(TARGET_DIR)/etc/runlevels/default/S45slapd
+ ln -sf ../../init.d/slapd $(TARGET_DIR)/etc/runlevels/default/K16slapd
+endef
+endif
+
define OPENLDAP_INSTALL_TARGET_CMDS
cp -a $(STAGING_DIR)/usr/lib/libldap*.so* $(TARGET_DIR)/usr/lib/
cp -a $(STAGING_DIR)/usr/lib/liblber*.so* $(TARGET_DIR)/usr/lib/
@@ -38,16 +53,20 @@
mkdir -p $(TARGET_DIR)/etc/openldap
ln -sf /tmp/etc/openldap/ldap.conf $(TARGET_DIR)/etc/openldap/ldap.conf
ln -sf ../../init.d/ldap $(TARGET_DIR)/etc/runlevels/default/S00ldap
+ $(OPENLDAP_INSTALL_TARGET_SERVER)
endef
define OPENLDAP_UNINSTALL_TARGET_CMDS
rm -f $(TARGET_DIR)/usr/lib/libldap*
rm -f $(TARGET_DIR)/usr/lib/liblber*
- rm -f $(TARGET_DIR)/usr/bin/ldapsearch
- rm -f $(TARGET_DIR)/usr/bin/ldapwhoami
+ rm -f $(TARGET_DIR)/usr/bin/ldap*
rm -f $(TARGET_DIR)/etc/init.d/ldap
+ rm -f $(TARGET_DIR)/etc/init.d/slapd
rm -rf $(TARGET_DIR)/etc/openldap
rm -f $(TARGET_DIR)/etc/runlevels/default/S00ldap
+ rm -f $(TARGET_DIR)/etc/runlevels/default/S45slapd
+ rm -f $(TARGET_DIR)/etc/runlevels/default/K16slapd
+ rm -f $(TARGET_DIR)/usr/sbin/slapd
endef
$(eval $(call AUTOTARGETS,package,openldap))
Added: branches/1.0/package/openldap/slapd.init
===================================================================
--- branches/1.0/package/openldap/slapd.init (rev 0)
+++ branches/1.0/package/openldap/slapd.init 2013-10-02 19:21:33 UTC (rev 6212)
@@ -0,0 +1,154 @@
+#!/bin/sh
+
+. /etc/rc.conf
+
+gen_sqlite3_schema()
+{
+
+ sqlite3 -batch /mnt/kd/ldap-odbc.sqlite3 <<EOF
+CREATE TABLE 'ldap_oc_mappings' (
+ 'id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ 'name' TEXT NOT NULL,
+ 'keytbl' TEXT NOT NULL,
+ 'keycol' TEXT NOT NULL,
+ 'create_proc' TEXT,
+ 'delete_proc' TEXT,
+ 'expect_return' INTEGER NOT NULL
+);
+
+CREATE TABLE 'ldap_attr_mappings' (
+ 'id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ 'oc_map_id' INTEGER NOT NULL REFERENCES ldap_oc_mappings('id'),
+ 'name' TEXT NOT NULL,
+ 'sel_expr' TEXT NOT NULL,
+ 'sel_expr_u' TEXT,
+ 'from_tbls' TEXT NOT NULL,
+ 'join_where' TEXT,
+ 'add_proc' TEXT,
+ 'delete_proc' TEXT,
+ 'param_order' INTEGER NOT NULL,
+ 'expect_return' INTEGER NOT NULL
+);
+
+CREATE TABLE 'ldap_entries' (
+ 'id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ 'dn' TEXT UNIQUE NOT NULL,
+ 'oc_map_id' INTEGER UNIQUE NOT NULL REFERENCES ldap_oc_mappings('id'),
+ 'parent' INTEGER NOT NULL,
+ 'keyval' INTEGER UNIQUE NOT NULL
+);
+
+CREATE TABLE 'ldap_entry_objclasses' (
+ 'entry_id' INTEGER NOT NULL REFERENCES ldap_entries('id'),
+ 'oc_name' TEXT
+);
+
+EOF
+}
+
+gen_slapd_conf()
+{
+
+ echo "include /etc/openldap/schema/core.schema
+include /etc/openldap/schema/cosine.schema
+include /etc/openldap/schema/inetorgperson.schema
+
+pidfile /var/run/slapd.pid
+argsfile /var/run/slapd.args
+
+database sql
+#suffix \"o=sql,c=RU\"
+#rootdn \"cn=root,o=sql,c=RU\"
+suffix \"dc=example,dc=com\"
+rootdn \"cn=root,dc=example,dc=com\"
+rootpw astlinux
+dbname ldap
+dbuser unused
+dbpasswd unused
+insentry_stmt \"INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)\"
+upper_func \"upper\"
+concat_pattern \"?||?\"
+has_ldapinfo_dn_ru no
+
+#database ldif
+#suffix \"dc=example,dc=com\"
+#rootdn \"cn=root,dc=example,dc=com\"
+#rootpw astlinux
+#directory /var/lib/ldap
+"
+}
+
+init () {
+
+ if [ "$LDAP_SERVER" != "yes" ]; then
+ if [ -f /tmp/etc/openldap/slapd.conf ]; then
+ rm /tmp/etc/openldap/slapd.conf
+ fi
+ return
+ fi
+
+ # Generate /etc/openldap/slapd.conf configuration file
+ if [ -f /mnt/kd/slapd.conf ]; then
+ echo "# Autogenerated. Edit /mnt/kd/slapd.conf file.
+" >/tmp/etc/openldap/slapd.conf
+ cat /mnt/kd/slapd.conf >>/tmp/etc/openldap/slapd.conf
+ else
+ echo "# Autogenerated. Do not edit.
+# A manually generated slapd config will use /mnt/kd/slapd.conf if it exists.
+" >/tmp/etc/openldap/slapd.conf
+ gen_slapd_conf >>/tmp/etc/openldap/slapd.conf
+ fi
+
+ chmod 600 /tmp/etc/openldap/slapd.conf
+
+ if [ ! -d /var/lib/ldap ]; then
+ mkdir -m 0700 -p /var/lib/ldap
+ fi
+
+ if [ ! -f /mnt/kd/ldap-odbc.sqlite3 ]; then
+ gen_sqlite3_schema
+ fi
+}
+
+start () {
+
+ if [ -f /etc/openldap/slapd.conf ]; then
+ echo "Starting LDAP Server (slapd)..."
+ slapd
+ fi
+}
+
+stop () {
+
+ if [ -f /var/run/slapd.pid ]; then
+ echo "Stopping LDAP Server (slapd)..."
+ kill $(cat /var/run/slapd.pid) >/dev/null 2>&1
+ fi
+}
+
+case $1 in
+
+start)
+ start
+ ;;
+
+stop)
+ stop
+ ;;
+
+init)
+ init
+ start
+ ;;
+
+restart)
+ stop
+ sleep 2
+ start
+ ;;
+
+*)
+ echo "Usage: start|stop|restart"
+ ;;
+
+esac
Property changes on: branches/1.0/package/openldap/slapd.init
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: branches/1.0/package/unixodbc/unixodbc.init
===================================================================
--- branches/1.0/package/unixodbc/unixodbc.init 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/package/unixodbc/unixodbc.init 2013-10-02 19:21:33 UTC (rev 6212)
@@ -102,6 +102,14 @@
Timeout=2000
"
install_odbc_dsn "asterisk-cdr" "$DATA"
+
+ DATA="
+Description=LDAP database
+Driver=SQLite3
+Database=/mnt/kd/ldap-odbc.sqlite3
+Timeout=2000
+"
+ install_odbc_dsn "ldap" "$DATA"
}
stop () {
@@ -112,6 +120,7 @@
# Remove DSN's
remove_odbc_dsn "asterisk"
remove_odbc_dsn "asterisk-cdr"
+ remove_odbc_dsn "ldap"
}
case $1 in
Modified: branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf
===================================================================
--- branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2013-09-30 19:43:00 UTC (rev 6211)
+++ branches/1.0/project/astlinux/target_skeleton/stat/etc/rc.conf 2013-10-02 19:21:33 UTC (rev 6212)
@@ -482,6 +482,8 @@
#LDAP_DEREF="never" # Dereferencing: "never", "searching", "finding" or "always", defaults to "never"
#LDAP_TLS_CACERT="/mnt/kd/ssl/ca-ldap.pem" # TLS server CA certificates recognized by the client, file path
#LDAP_TLS_REQCERT="never" # TLS certificate check: "never", "allow", "try" or "demand", defaults to "demand"
+## LDAP Server - OpenLDAP (slapd)
+#LDAP_SERVER="yes" # Enable LDAP server slapd with "yes", defaults to "no"
## Proxy ENV variables (http_proxy, ftp_proxy, etc.) for curl, wget, etc.
## Format: http://user:pass@proxyhost:proxyport"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|