Linux – Slapd service won’t start, unable to open pid file

ldaplinux

I'm trying to set up a test LDAP-server for some developers but I'm running into some trouble.

service slapd start

errors so I run

/usr/sbin/slapd -d 1

and this gives me the following error at the end:

unable to open pid file "/var/run/ldap/slapd.pid": 13 (Permission denied)

slapd destroy: freeing system resources.

slapd stopped.

The rights for /var/run/ldap are as follows:

root@pec:/var/run/ldap# ls -ld
drwxr-xr-x 2 openldap openldap 60 2012-07-04 20:45 

So I don't get why there is still a permission denied.
Syslog gives the following when running slapd:

Jul  4 21:00:27 pec slapd[13758]: @(#) $OpenLDAP: slapd 2.4.21 (Dec 19 2011 15:40:04) $#012#011buildd@allspice:/build/buildd/openldap-2.4.21/debian/build/servers/slapd
Jul  4 21:00:27 pec kernel: [8147247.203100] type=1503 audit(1341428427.953:64):  operation="truncate" pid=13758 parent=20433 profile="/usr/sbin/slapd" requested_mask="::w" denied_mask="::w" fsuid=0 ouid=119 name="/var/run/ldap/slapd.pid"

Can anyone point me in the right direction?

Best Answer

What distribution are you running and how did you install OpenLDAP?

The error you got is from AppArmor and tells you that it prevented slapd from creating it's pid file.

For Ubuntu: You should have something like the following in your /etc/apparmor.d/usr.bin.slapd file:

  /{,var/}run/ldap/* w,

to allow this.

Normally, this should be set up to work without further configuration.

Related Topic