slapd upgrade fails: chown: cannot access `olcDbDirectory\nolcDbDirectory': No such file or directory

Bug #322944 reported by Iain
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
openldap (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: slapd

slapd upgrade fails with:

iain@stronginthearm:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up slapd (2.4.11-0ubuntu6.1) ...
  Backing up /etc/ldap/slapd.d/ in /var/backups/slapd-2.4.11-0ubuntu6... done.
chown: cannot access `olcDbDirectory\nolcDbDirectory': No such file or directory
dpkg: error processing slapd (--configure):
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
 slapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

The attempt to parse out the olcDbDirectory in /var/lib/dpkg/info/slapd.postinst:get_directory() fails if there is more than one matching file, which there is on my system - there's an emacs backup file (i.e. olcDatabase={1}hdb.ldif~). Made the following patch:

--- slapd.postinst 2009-01-29 22:32:24.000000000 +0000
+++ /var/lib/dpkg/info/slapd.postinst 2009-01-29 22:37:55.000000000 +0000
@@ -229,7 +229,7 @@
 get_directory() { # {{{
 # Returns the db directory for a given suffix
        if [ -d "${SLAPD_CONF}" ] && echo `get_suffix` | grep -q "$1" ; then
- grep "olcDbDirectory:" `grep -l "olcSuffix: $1" ${SLAPD_CONF}/cn\=config/olcDatabase*` | cut -d: -f 2 | sed 's/^ *//g'
+ grep -H "olcDbDirectory:" `grep -l "olcSuffix: $1" ${SLAPD_CONF}/cn\=config/olcDatabase*` | head -1 | cut -d: -f 3 | sed 's/^ *//g'
        elif [ -f "${SLAPD_CONF}" ]; then
                # Extract the directory for the given suffix ($1)
                for f in `get_all_slapd_conf_files`; do

which is more robust in the face of multiple matches. Extra credit is given for explicitly grepping out junk.

# lsb_release -rd
Description: Ubuntu 8.10
Release: 8.10

# apt-cache policy slapd
slapd:
  Installed: 2.4.11-0ubuntu6.1
  Candidate: 2.4.11-0ubuntu6.1
  Version table:
 *** 2.4.11-0ubuntu6.1 0
        500 http://gb.archive.ubuntu.com intrepid-updates/main Packages
        100 /var/lib/dpkg/status
     2.4.11-0ubuntu6 0
        500 http://gb.archive.ubuntu.com intrepid/main Packages

Mathias Gug (mathiaz)
Changed in openldap:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Mark Powell (mark-blackbirdhouse) wrote :

Did some investigation on 8.10:
My object value has a space in it, which was not handled due to insufficient quoting in the post-install script.
I hacked around it by making the script just return success.

When I upgraded to 9.04 I got the same error report.

Revision history for this message
Peder Stray (pstray) wrote :

Still encountered in upgrade to 14.04, due to a few cases of a missing -h parameter to grep when finding the value of olcDbDirectory. In my case the suffix is stored in two backends, one of them on disk, causing a grep with more than one file on the command line, and thus the result of grep beeing prefixed with "<filename>:", which again causes "| cut -d: -f 2" to return "olcDbDirectory" instead of "/var/lib/ldap".

Revision history for this message
Ryan Tandy (rtandy) wrote :

Hi Peder,

Can you please try the patch from Debian bug #723957:

https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=10;filename=fix-723957.debdiff;att=1;bug=723957

(apply it to slapd.postinst)

and see whether it resolves the problem for you? If it still fails, I'd appreciate a dump of your config db (slapcat -n0) so I can reproduce it myself.

Thanks!

Revision history for this message
Ryan Tandy (rtandy) wrote :

The reporter's case is fixed in quantal and later by this change:

http://anonscm.debian.org/cgit/pkg-openldap/openldap.git/commit/debian/slapd.scripts-common?id=c8d1f619c8e151704508b671a7c801d9863e183e

and Mark Powell's case, if I've understood it correctly, is fixed in natty and later by this change:

http://anonscm.debian.org/cgit/pkg-openldap/openldap.git/commit/debian/slapd.scripts-common?id=ce2e21b144dfc7703aec25a4cf6bce2a4c8f2d78

Therefore, setting this bug to Fix Released; Peder and I are discussing his case in bug 1362481.

Changed in openldap (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.