Problem with OpenLDAP server

I get the following errors
ldap.service - Start OpenLDAP server
Loaded: loaded (/usr/lib/systemd/system/ldap.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2023-07-17 15:28:36 IST; 2s ago
Process: 10330 ExecStop=/usr/bin/kill cat /var/run/slapd/ (code=exited, status=1/FAILURE)
Process: 10326 ExecStart=/bin/sh -c slapd 2>&1 </dev/null (code=exited, status=0/SUCCESS)
Main PID: 10326 (code=exited, status=0/SUCCESS)

Jul 17 15:28:36 systemd[1]: Started Start OpenLDAP server.
Jul 17 15:28:36 slapd[10327]: @(#) $OpenLDAP: slapd 2.4.46 (Oct 11 2021 21:12:19) $>
Jul 17 15:28:36 slapd[10328]: slapd starting
Jul 17 15:28:36 kill[10330]: kill: cannot find process “cat" Jul 17 15:28:36 kill[10330]: kill: cannot find process "/var/run/slapd/
Jul 17 15:28:36 systemd[1]: ldap.service: Control process exited, code=exited status=1
Jul 17 15:28:36 slapd[10328]: daemon: shutdown requested and initiated.
Jul 17 15:28:36 slapd[10328]: slapd shutdown: waiting for 0 operations/tasks to finish
Jul 17 15:28:36 slapd[10328]: slapd stopped.
Jul 17 15:28:36 systemd[1]: ldap.service: Failed with result ‘exit-code’.

ls: cannot access ‘/var/run/slapd/’: No such file or directory

I have Rocky Linux release 8.8 (Green Obsidian)
openldap-servers.x86_64 2.4.46-18.el8

When I run the command slapd & it works.
Looks like some issue with systemctl start/stop ldap.service

This is my ldap.service file :
Description=Start OpenLDAP server

ExecStart=/bin/sh -c ‘slapd 2>&1 </dev/null’
ExecStop=kill cat /var/run/slapd/


OK problem solved:
I got a few thing wrong:

  1. I was using systemctl start/stop ldap.service, it should be systemctl start/stop slapd.service
  2. I did not have slapd.service enabled to start at boot, so when I did a reboot [which I do not do very often] slapd was not starting.
1 Like

Note that the systemctl status slapd.service shows only latest log messages.
The journalctl -u slapd.service shows more.

For more “what (services) do I have?” see outputs of:

systemctl status
systemctl list-unit-files

Red Hat has deprecated OpenLDAP server in RHEL. They do offer 389ds (aka dirsrv).
(Considering the recent turmoil that is mere trivia.)

My problem now is that the dir /var/run/slapd is not been created after a reboot.
/run/openldap/ is but has no after spald starts.

OK, I fixed that now:
In /usr/lib/tmpfiles.d/slapd.conf
d /run/openladp 0755 ldap ldap --------> -d /run/slapd 0755 ldap ldap -

I am not sure how my system got screwed up.

Both EL8 and EL9 versions of the package (from PowerTools and EPEL, respectively) do claim
providing the /var/run/openldap:

[el8 ~]# dnf -q --enablerepo=powertools list openldap-servers
Available Packages
openldap-servers.x86_64             2.4.46-18.el8             powertools
[el8 ~]# dnf -q --enablerepo=powertools rq -l openldap-servers | grep -E "var|service"

[el9 ~]# dnf -q --enablerepo=epel list openldap-servers
Available Packages
openldap-servers.x86_64                 2.6.2-2.el9                 epel
[el9 ~l]# dnf -q --enablerepo=epel rq -l openldap-servers | grep -E "var|service"

The /run (which the /var/run points to) is a tmpfs in RAM, so created on boot.
That means that something must create the /run/openldap on boot or at start of service.

As you find out, the tmpfiles does some of it and openldap-servers has something for it:

[el8 ~]# dnf -q --enablerepo=powertools rq -l openldap-servers | grep -E "tmpfil"

Logically, slapd.service must start after the tmpfiles has done its bit.

PS. At least on el9 systemd does warn about /var/run and implores to update scripts to use /run.

I have two systemd scripts on my system:

only /usr/lib/systemd/system/slapd.service works and produces /run/slapd/ and /run/slapd/slapd.args

Any idea as to why this is?

Where do they come from?

rpm -qf /usr/lib/systemd/system/ldap.service
rpm -qf /usr/lib/systemd/system/slapd.service

and what is in the working unti file (/usr/lib/systemd/system/slapd.service)?

file /usr/lib/systemd/system/ldap.service is not owned by any package

rpm -qf /usr/lib/systemd/system/slapd.service


Description=OpenLDAP Server Daemon

ExecStart=/usr/sbin/slapd -u ldap -h “ldap:/// ldaps:/// ldapi:///”


Was probably created by you and can be removed.
It should not have been in /usr/lib/systemd/system in the first place;
local customizations should go to /etc/systemd/system. See man systemd.unit

See description of PIDFile in man systemd.service
See description of unit file command edit in man systemctl

You could edit the service with:

systemctl edit slapd.service

(It starts vi by default.)

You start with empty buffer, and should probably add:


After save&quit (of editor) you should find a subdir and file under /etc/systemd/system.

You should also read man slapd and man slapd-config to see whether the PID-file is mentioned there; you want everybody to agree that it is the /run/openldap/

If that does not work out, then revert and adjust the tpmfiles config to create /run/slapd on boot instead.