Status: Exploratory Light Weight Directory Access Protocol (LDAP) is used to manage distributed directories over a network.

According to Wikipedia: Historically the OpenLDAP server (slapd, the Standalone LDAP Daemon) architecture was split between a frontend which handles network access and protocol processing, and a backend which deals strictly with data storage. The architecture is modular and many different backends are available for interfacing to other technologies, not just traditional databases.

OpenLDAP has been identified by Dr. Sherrill as a "high-priority" for RTEMS. According to Beyond Linux from Scratch The OpenLDAP package provides an open source implementation of the Lightweight Directory Access Protocol,.

In addition to helping me learn valuable porting skills, this project is on of the first steps towards adding needed modern protocols to RTEMS, so that RTEMS can use LDAP. One of the more major first steps towards modernizing the networking protocols in RTEMS is the RTEMS BSD Porting project.


Concise statement of the overall goal of the project. Refine this initial statement to include: project deliverable (code, docs, testing), required/suggested methodology, standards of quality, possible goal extensions beyond the main objective.

C Rempel's main goal for porting OpenLDAP to RTEMS is to develop a method of porting semi-complex existing open source packages to RTEMS that is efficient, elegant and complete. Efficient meaning the person porting the software can do so in a matter of days or weeks. Elegant meaning the essence of the original source package, and the RTEMS source are preserved: as few lines of code are modified as possible in both the original source package and the RTEMS source as possible, as well as libraries, programs, and executable are installed in the same locations as they would be if they were built in the RTEMS source tree. Completeness meaning not only the libraries are ported, but the programs and tests as well.


Just some ideas from C Rempel:

= RTEMS Webkit =

# DONE: A Makefile.openldap that builds the SlapD libraries for RTEMS applications. DONE. # DONE: A Makefile that builds the programs. # DONE: Write an RTEMS Shell Addon that adds the SLAP Tools and SLAPD commands to the RTEMS Shell # TODO: A program that will run the LDAP testing suite provided by OpenLDAP. Should be automated, as additional tests will be used in the future. # TODO: Files and settings needed for OpenLDAP. ## HOME env ## ldaprc ## LDAPCONF env ## LDAPRC env ## hostname ## ldap:/// # TODO: port cyrus SASL. For security reasons, C Rempel is recommending AGAINST using the cyrusimap git. Currently looking for another source. Perhaps the Debian Package? Since ldap-bind is being deprecated in favor of ldap-sasl-bind, this extention is needed for a longterm port. # TODO: Integrate encryption supported by OpenLDAP (preferably with a BSD-compatible license). Currently OpenSSL has been ported to RTEMS. # TODO: port database supported by OpenLDAP (preferably with a BSD-compatible license). One possibility to explore is the Berkely Database BDB. Although BDB falls under the sleepy cat license, BDB is the default database for OpenLDAP.

Suggested Methodology

# Use RTEMS-Addon-Packages as a guide for porting SASL, encryption, and database. # Use the multiio git as a guide for the shell commands addon and application. # Use online LDAP/OpenLDAP documentation as a guide for files/settings. # Read RTEMS publications for how to set the environment. # Maintain contact with Dr. Sherril as to needs for the project.

Standards of Quality

The standards of quality will be a SLAPD server, with a RTEMS shell application.

Eventually, there should be tests that demonstrate how the SLAPD implementation meets [ RFC 4510].

Possible Goal Extensions

#Explore and (possibly port to RTEMS) the additional packages used by OpenLDAP: ## Integrate Database Support. ## Additional encryption (when configuring openLDAP just type ./configure --help) # Explore and (possibly port to RTEMS) the additional packages that use OpenLDAP: ## Apache (did this already, but could be ported more efficiently, elegantly, and completely) ## Others # Explore adding other opensource LDAP implementations to RTEMS, the 389 Directory Server looks like it's written in C (as opposed to Java), so may be a preferred LDAP implementation to port, but additional research is needed to determine such issues as how feasible is it to "embed", and is the 389 DS license in line with the RTEMS license? # Add an OpenLDAP test to the RTEMS Networking Demos


Required Programming Languages

C, Bash, Makefile

Specific Areas of RTEMS or tools

# RTEMS Addon Packages # RTEMS Networking Demos # RTEMS Multiio

Level of Familiarity of RTEMS

# Ability to configure RTEMS # Ability to start the Hello, World RTEMS Application from the Examples v2. # Ability to build the AVL library using the RTEMS Addon Packages


# Experience using Makefiles and using configurations for cross development.


Ability to use the command line, and modify Makefiles. Knowing "grep -r", "find -name", and a text search feature REALLY helpful.

Development / Documentation / Testing Tools

Development Tools: RTEMS Addon Packages, RTEMS Source Tree, RTEMS Toolset, Qemu

Documentation Tools: RTEMS Wiki, comments

Testing Tools: Tests provided by GCC and OpenLDAP, possibly other third party open source LDAP testing software...

Mathematical/algorithmic background

None: this is simply putting two pieces of existing software together.

Other Desirable Skills

# Code reuse skills: can research and use other programmer's code. # Exploration skills: a willingness to peruse the RTEMS git, and other projects, to find code maintained by other developers (to make this port successful after the developer moves on).


Current RTEMS developers, papers, etc that may help you in this project.

C Rempel is willing to help

Other sections

If you have more to say about the project that doesn't fit in the proposed sections of this template, feel free to add other sections at will.


  • who helped add did work

Miscellaneous Sections

A first stab at building Open LDAP

As the project progresses, you will need to add build instructions, etc and this page will evolve from a project description into a HOWTO.

I am building this package because it is simpler than the Apache Runtime, and so is a good way to gain needed experience. I started with using the RTEMS Addon Packages. How to use the RTEMS Addon Packages is outlined


I put the following in rtems-addon-packages/Makefile.openldap. On the first pass I didn't want to generate the example configuration files, but on the second pass, I added the sysconfdir and localstatedir switches to make the example files. Then I removed the sysconfdir and localstatedir, so my customizations would not be overwritten.

# # Declare supported terminal types. # This value can be augmented/overridden by the site-configuration file #

include ../RTEMS_Makefiles/Makefile.common

# # The following will work only if you have the latest ncurses version # of infocmp installed before trying to build for an RTEMS target. # The cf_cv_type_of_bool hack works around a bug when configuring # for a cross-target. # # Two options needed to generate example files in rootfs # --sysconfdir=/home/joel/rtems-addon-packages/network-demos/ldap/rootfs/etc # --localstatedir=/home/joel/rtems-addon-packages/network-demos/ldap/rootfs/var all:

ac_cv_member_struct_msghdr_msg_control=no \ ac_cv_func_memcmp_working=yes \ ac_cv_func_initgroups=yes \ ac_cv_func_setuid=no \ ./configure \

--host=$(RTEMS_CPU)-rtems4.11 \ --prefix=$(exec_prefix) \ --libdir=$(exec_prefix)/$(RTEMS_BSP)/lib \ --includedir=$(exec_prefix)/$(RTEMS_BSP)/lib/include \ --disable-cleartext \ --enable-debug \ --disable-hdb \ --disable-mdb \ --disable-overlays \ --enable-proctitle \ --enable-null \ --disable-syslog \ --without-tls \ --with-yielding_select=yes

make make install


$ cd ~/rtems-addon-packages $ git clone git:// openldap $ cd openldap

Binary Relocatability

When I tried linking slapd directly into RTEMS, Qemu bailed out with address outside of range... So, to avoid having the address outside of range, I decided to try making SLADP a relocatable binary (or library).

Unfortuneately, when I did that, the convienience libraries were no longer included. However, I will walk through the process of turning an executable into a library...

First, I modified the openldap/servers/slapd/ to build a library.


+ LIBRARY = libslapd.a


Second, I commented out the original openldap/servers/slapd/ libslapd.a: Makefile target, as that was designed for a Windows host.

! # libslapd.a: symdummy.o ! # dlltool ...

Third, I added a openldap/servers/slapd/ libslapd.a: target by "cutting and pasting" the sources from the slapd: Makefile target, and using ar to build the library, and getting the ar flags from my target.cfg. The linked objects were taken from the slapd: Makefile target. Note: $@ means libslapd.a

+ libslapd.a: $(SLAPD_DEPENDS) @LIBSLAPI@ + $(AR) ruv $@ $(SLAPD_OBJECTS) $(LIB) $(WRAP_LIBS)

Fourth, I added an install-local Makefile target to the install-local-srv. The install-local Makefile target was inspired by the openldap/libraries/lib*/ install-local Makefile targets (which are used to install libraries). The install-local Makefile target in the install-local-srv tells the Makefile to actually build the library.

! install-local-srv: install-slapd ... \

install-conf ... install-local

Fifth, I added the install-local Makefile target. I was inspired by openldap/libraries/liblutil/ and openldap/include/ I not onlu have libslapi.a installed, but main.h, which is needed to call main from my test.

+ install-local: FORCE $(LIBRARY) + -$(MKDIR) $(DESTDIR)$(libdir) + $(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir) + $(LTFINISH) $(DESTDIR)$(libdir) + -$(MKDIR) $(DESTDIR)$(includedir) + for header in $(srcdir)/main.h ; \ + do \ + $(INSTALL) $(INSTALLFLAGS) -m 644 $$header \ + $(DESTDIR)$(includedir); \ + done +

Finally, write a main.h

int main(int argc, char *argc);

Now, you can make a relocatible libslapd.a!

$ make -f RTEMS_Makefiles/Makefile.openldap

Note: Very insecure! But builds OK.

To make this port a long-term solution, I will need to port SASL to RTEMS as well (ldap-bind is deprecated in favor of ldap-sasl-bind)... that will be a hobby project for months from now...


Multiio is an example application I used for my model shell application. I finally chose multiio over the network demos because the slapd documenation and tests used the shell, while the network-demos were more C-based.

Next Steps: //openldap guide


This is where binary relocatability gets REALLY interesting! Because libslapd.a is a library and not a program, the dependencies have to be listed from most dependent to least dependent.

So, I added the following to the LD_LIBS for rtems-openldap/openldap_shell/Makefile looked like

override LD_LIBS += -lmghttpd -lslapd -lback_ldif \

-lback_monitor -lback_null.a -lback_relay -loverlays \ -llunicode -lrewrite -llutil -lldap_r -lldap -llber

With all this, I am now able to call the slapd server, but now to figure out how to use the options, the config file, etc...


After struggling to call main, I was determined the following: # some configurations that were hard-coded at compile-time would need to be over-ridden at runtime. ## the configuration directory ## others (as dicovered) # additional openLDAP specific knowledge is required. An example site for openLDAP.


(Optional) Next, to make it easier for the end-user, automate building rtems-grub.cfg

# Generate rtems-grub.cfg

Add a comment of what grub is configured to load $(basename $PWD) prints the name of the directory.

echo \# RTEMS Grub configuration for $(basename $PWD) >> rtems-grub.cfg

This part was rather interesting... I've never used a pipe inside of a shell-script call before... list everything in o-optimize, that ends with .exe and count them.

# The number of executables

echo set default = $(ls o-optimize | \ grep '\.'exe | wc -l) >> rtems-grub.cfg

Used the & to use the name of the executable more than once. Note that sed"s/[a-zA-Z\-]/... has to be all on one line

# The menuentries ls o-optimize | \ grep '\.'exe | \ sed "s/[a-zA-Z\-]/menuentry \"RTEMS \-\" \{\n

set root=(hd1,1)\n multiboot (hd1,1)\/o-optimize\/&/" | \

sed "s/\.exe/\.exe\n\}\n/" >> rtems-grub.cfg

# List everything in o-optimize... # that is an executable... # select text composed of letters and format it ... # add a line a right brace, and # another line after any .exe ...

More tips

For integrating legacy libraries/applications to RTEMS... I was playing around with adding the sqlite3 command to the multiio shell, and found the following general ideas very helpful.

# tear and rebuild ALL applications within the kit every time you make a small change. # link the library into EVERY directory with an RTEMS shell application using your new commands.

To tear down and rebuild

rtems-addon-packages$ nano

#!/bin/sh make clean make qemu...

To link add an entry to the Makefile:

you can put the library in with the COBJS,


or link with LD_LIBS

LD_LIBS += -lslapd


LD_LIBS += ../openldap/.libs/libslapd.a


I modified the rtems-addon-packages/examples/ncurses/Makefile to turn openldap programs used to test openldap into stand-alone executables.

I had to add slapd-common.c to the C_PIECES, and slapd-common.h to the headers.

Also, to link the liblutil.a convienience library, I had to add liblutil.a to C_O_FILES (it's an object file after-all :), I linked the ldap libraries using LD_LIBS, and increased the HeapSize? by a factor of ten (because it said networking required more -- online research is needed to get an exact size required).

Finally, it's worth noting the $(TEST) parameter is used to identify which test to build, and PGMS stands for programs.

# # $Id$ # # Templates/Makefile?.leaf # Template leaf node Makefile # SRCDIR=../../openldap/tests/progs

# C source names, if any, go here -- minus the .c C_PIECES=slapd-common $(TEST)

C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) liblutil.a

# C++ source names, if any, go here -- minus the .cc CC_PIECES=


H_FILES= slapd-common.h

# Assembly source names, if any, go here -- minus the .s S_PIECES=

S_FILES=$(S_PIECES:%=%.s) S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)



# # RTEMS managers go here # MANAGERS=io event message semaphore

include $(RTEMS_MAKEFILE_PATH)/ include $(RTEMS_CUSTOM) include $(PROJECT_ROOT)/make/leaf.cfg

# # (OPTIONAL) Add local stuff here using +=



CPPFLAGS += -I$(SRCDIR)/../../include CFLAGS +=


LD_LIBS += -lldap -llber -lldap_r CFLAGS_LD += -Wl,--defsym -Wl,HeapSize?=0x200000 # network needs more space CFLAGS_DEBUG_V +=

# # Add your list of files to delete here. The config files # already know how to delete some stuff, so you may want # to just run 'make clean' first to see what gets missed. # 'make clobber' already includes 'make clean' #


all: ${ARCH} $(SRCS) $(PGMS)



# Install the program(s), appending _g or _p as appropriate. # for include files, just use $(INSTALL) install: all

$(INSTALL_VARIANT) -m 555 ${PGMS} /usr/local/tftpboot/bootfiles/m68360/

Then, I ran BuildTests?.sh

~/rtems-addon-packages/examples/openldap$ ./BuildTests?.sh

Again this only built the programs used to run the tests as stand-alone executables...

SLAPD Test Idea

The OpenLDAP quickstart guide has some interesting ideas.

If the test is written based on step 8 forwards, things that would be required would be: # an appropriate configuration file in the rootfs # a call to slapd with the -d option # adding initial entries to a directory # verify the entry exists

One general outline of a demo is:

/ slapd -d / ldapadd -x -D "cn=Manager,dc=ldapdemo,dc=org" -W -f ldapdemo.ldif / ldapsearch -x -b 'dc=ldapdemo,dc=org' '(objectclass=*)'

Another possibility was to look into the ldap C API, but that looks mostly like it's for use with clients, which is not what the requirements called for, and so is not currently being explored.

Current / Future Directions

# Polish the demo, by completing the items in the deliverables section. # Try to get an LDAP connection between RTEMS on Qemu and the build machine. # Straighten out this site. Got a very simplistic slapd application to load, now want to port cyrus sasl and verify the functionality of Berkely DB and Open SSL on RTEMS.

Some problems I'm anticipating is learning how to configure, use, and test OpenLDAP.

Hope this helps!


Last modified on Jul 19, 2012 at 7:15:27 AM Last modified on Jul 19, 2012, 7:15:27 AM