Sunday, May 12, 2013

Openldap bug on centos6,4

Openldap bug on centos6,4

When you are setting up the new openldap server, specifically with the following combination.

[root@centos6-01 openldap]# cat /etc/centos-release
CentOS release 6.4 (Final)

[root@centos6-01 openldap]# uname -r
2.6.32-358.6.1.el6.x86_64

[root@centos6-01 openldap]# rpm -qa | grep openldap-servers
openldap-servers-2.4.23-32.el6_4.1.x86_64

Most of the problem that you will hit when you are trying to add a first ldap entry from a ldif file was "ldap_bind invalid credentials (49)". Luckily, when you are doing a search from google, you should be able to find this link to help you to solve the problem.  http://www.ezylinux.com/en/red-hat-6-how-to-fixes-ldapadd-ldap_bind-invalid-credentials-49/. However, right after you have applied the commands, I just found "ANOTHER" bug on the daemon script as depicted as below. Even though the daemon script yielded an error message, but the slapd process will still spawned out, which I think it is a bit ugly.

[root@centos6-01 openldap]# /etc/init.d/slapd start
ln: accessing `/var/run/openldap/slapd.pid': No such file or directory

[root@centos6-01 openldap]# pidof slapd
1857
[root@centos6-01 openldap]# ps -eaf | grep slapd
ldap      1857     1  0 15:07 ?        00:00:00 /usr/sbin/slapd -h  ldap:/// ldapi:/// -u ldap

I keep on finding for bug list reported from the redhat bugzilla, but I have no luck. So, I decided to hack the daemon script, /etc/init.d/slapd. In this script, you will find some lines sound as below.

 # Start daemons.
        echo -n $"Starting $prog: "
        daemon --pidfile=$pidfile --check=$prog $ulimit ${slapd} -h "\"$harg\"" -u ${user} $OPTIONS $SLAPD_OPTIONS
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
                touch $lockfile
                ln $slapd_pidfile $pidfile
        fi

So, this is my hacked version. Please pay more attention on the highlighted lines.

 # Start daemons.
        echo -n $"Starting $prog: "
        daemon --pidfile=$pidfile --check=$prog $ulimit ${slapd} -h "\"$harg\"" -u ${user} $OPTIONS $SLAPD_OPTIONS
        pidof ${slapd} > $pidfile
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
                touch $lockfile
                #ln $slapd_pidfile $pidfile
                ln $pidfile $slapd_pidfile
        fi

With this, I can start/stop my daemon with no problem.

[root@centos6-01 cn=config]# /etc/init.d/slapd start
Starting slapd:                                            [  OK  ]
[root@centos6-01 cn=config]# /etc/init.d/slapd stop
Stopping slapd:                                            [  OK  ]


I am not sure if Centos community aware of this bug. But, I am just sharing it out, in hoping that the bug will be fixed in future. 

5 comments:

Bricktop said...

Your patch works like a charm (Centos 6.4), thanks!

Anonymous said...

yes, it works

Thanks

Anonymous said...

yes, it works

thanks

Anonymous said...

Works in Fedora as well!

Jérôme said...

Thank you. Works for RHEL6.7 also.