slapd cannot get resinstalled or removed if the configuration files were lost

Bug #411045 reported by Christian Glahn on 2009-08-09
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
openldap (Ubuntu)
Low
Unassigned

Bug Description

Binary package hint: slapd

The installation scripts for slapd force good system even in recovery modes.

In a moment of complete blackout, I dropped the configuration in /etc/ldap/slap.d/ with 'rm -r *' .

Usually it is possible to reinstall a package in order to get to a clean system state, but not with the slapd package.

I would expect the following:
If slapd is set for reinstallation, missing configuration files should not hinder the package manager to create the configuration files just as in a vanilla installation.

However, when I want to reinstall or remove slapd I get is:
somehow the package management identifies the package as "configuration pending".
it tries to reconfigure the package and fails because the files are missing.
The messages are as follows:

# apt-get install slapd --reinstall -f -m
1 Reading package lists...
2 Building dependency tree...
3 Reading state information...
4 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
5 1 not fully installed or removed.
6 Need to get 0B/1519kB of archives.
7 After this operation, 0B of additional disk space will be used.
8 Do you want to continue [Y/n]? Preconfiguring packages ...
9 (Reading database ... 272567 files and directories currently installed.)
10 Preparing to replace slapd 2.4.15-1ubuntu3 (using .../slapd_2.4.15-1ubuntu3_i386.deb) ...
11 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or directory
12 invoke-rc.d: initscript slapd, action "stop" failed.
13 dpkg: warning - old pre-removal script returned error exit status 2
14 dpkg - trying script from the new package instead ...
15 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or directory
16 invoke-rc.d: initscript slapd, action "stop" failed.
17 dpkg: error processing /var/cache/apt/archives/slapd_2.4.15-1ubuntu3_i386.deb (--unpack):
18 subprocess new pre-removal script returned error exit status 2
19 Backing up /etc/ldap/slapd.d/ in /var/backups/slapd-2.4.15-1ubuntu3... done.
20 grep: /etc/ldap/slapd.d//cn=config/olcDatabase*: No such file or directory
21 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or directory
22 invoke-rc.d: initscript slapd, action "start" failed.
23 dpkg: error while cleaning up:
24 subprocess post-installation script returned error exit status 2
25 Errors were encountered while processing:
26 /var/cache/apt/archives/slapd_2.4.15-1ubuntu3_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

no surprisingly the old pre-removal script fails in line 11.
even less surprisingly the new pre-removal script fails in line 15.
This is the case because both scripts are the same.

BTW, the server stop fails because the server did not run in the first place.

The problem is that the script is not able to recognize that the configuration files are missing.

The correct solution would be to test for the configuration files in the pre-removal scripts and perform the operations only if the files are actually present. Otherwise it should just ignore the missing configuration and do only the pre-removal stuff that does not require the configuration.

Christian Glahn (cpglahn) wrote :

I found that the problem was related to the init script (/etc/init.d/slapd)

With the attached patch the problem disappears, because the script stops before the daemon tries to access the configuration.

Mathias Gug (mathiaz) wrote :

Did you try to purge the slapd package before reinstalling it?

Changed in openldap (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Download full text (4.0 KiB)

Yes, Purging failed because the related files hindered slapd from being
stopped.

I posted a patch for the slapd init script that removes this problem.

Christian

On Thu, Sep 10, 2009 at 2:36 AM, Mathias Gug <email address hidden> wrote:

> Did you try to purge the slapd package before reinstalling it?
>
> ** Changed in: openldap (Ubuntu)
> Importance: Undecided => Low
>
> ** Changed in: openldap (Ubuntu)
> Status: New => Incomplete
>
> --
> slapd cannot get resinstalled or removed if the configuration files were
> lost
> https://bugs.launchpad.net/bugs/411045
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in “openldap” package in Ubuntu: Incomplete
>
> Bug description:
> Binary package hint: slapd
>
> The installation scripts for slapd force good system even in recovery
> modes.
>
> In a moment of complete blackout, I dropped the configuration in
> /etc/ldap/slap.d/ with 'rm -r *' .
>
> Usually it is possible to reinstall a package in order to get to a clean
> system state, but not with the slapd package.
>
> I would expect the following:
> If slapd is set for reinstallation, missing configuration files should not
> hinder the package manager to create the configuration files just as in a
> vanilla installation.
>
> However, when I want to reinstall or remove slapd I get is:
> somehow the package management identifies the package as "configuration
> pending".
> it tries to reconfigure the package and fails because the files are
> missing.
> The messages are as follows:
>
> # apt-get install slapd --reinstall -f -m
> 1 Reading package lists...
> 2 Building dependency tree...
> 3 Reading state information...
> 4 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not
> upgraded.
> 5 1 not fully installed or removed.
> 6 Need to get 0B/1519kB of archives.
> 7 After this operation, 0B of additional disk space will be used.
> 8 Do you want to continue [Y/n]? Preconfiguring packages ...
> 9 (Reading database ... 272567 files and directories currently
> installed.)
> 10 Preparing to replace slapd 2.4.15-1ubuntu3 (using
> .../slapd_2.4.15-1ubuntu3_i386.deb) ...
> 11 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or
> directory
> 12 invoke-rc.d: initscript slapd, action "stop" failed.
> 13 dpkg: warning - old pre-removal script returned error exit status 2
> 14 dpkg - trying script from the new package instead ...
> 15 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or
> directory
> 16 invoke-rc.d: initscript slapd, action "stop" failed.
> 17 dpkg: error processing
> /var/cache/apt/archives/slapd_2.4.15-1ubuntu3_i386.deb (--unpack):
> 18 subprocess new pre-removal script returned error exit status 2
> 19 Backing up /etc/ldap/slapd.d/ in
> /var/backups/slapd-2.4.15-1ubuntu3... done.
> 20 grep: /etc/ldap/slapd.d//cn=config/olcDatabase*: No such file or
> directory
> 21 sed: can't read /etc/ldap/slapd.d//cn=config.ldif: No such file or
> directory
> 22 invoke-rc.d: initscript slapd, action "start" failed.
> 23 dpkg: error while ...

Read more...

Mathias Gug (mathiaz) on 2009-10-22
Changed in openldap (Ubuntu):
status: Incomplete → Triaged
bnewtonius (brian-newtonius) wrote :

There is a much easier way to fix this.

Just remove (or move) your slap.d directory and run the reinstall again. The /etc/init.d/slapd script exits with a 0 if that folder is missing.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers