[Pkg-freeipa-devel] Bug#905184: upgrade of 389-ds-base fails if /var/lib/dirsrv is on different partition as /etc

Jan Kowalsky jankow at datenkollektiv.net
Wed Aug 1 11:30:23 BST 2018


Package: 389-ds-base
Version: 1.3.5.17-2
Severity: serious

Upgrade to newer version of 389-ds-base fails with dpkg configuration
error on postinstall script /var/lib/dpkg/info/389-ds-base.postinst

After getting full log of postinstall I saw:

[18/08/01:10:33:37] - [Setup] Info Could not rename config file
'/etc/dirsrv/slapd-INSTANCE/slapd-collations.conf' to
'/var/lib/dirsrv/slapd-INSTANCE/bak.bak/slapd-collations.conf'.  Error:
Invalid cross-device link

This is caused by line 24:

setup-ds -l $OUT -u -s General.UpdateMode=offline > $OUT 2>&1

calling this directly we got the same failure.

The reason is that the script tries to make a backup of configuration
files in /var/lib/dirsrv/INSTANCE/bak.bak:


    # these files are obsolete, or we want to replace
    # them with newer versions
    my @toremove = qw(slapd-collations.conf);

    # make a backup directory to store the deleted config file, then
    # don't really delete it, just move it to that directory
    my $mode = (stat($inf->{slapd}->{config_dir}))[2];
    my $bakdir = $inf->{slapd}->{bak_dir} . ".bak";
    if (! -d $bakdir) {
        $! = 0; # clear
        mkdir $bakdir, $mode;
        if ($!) {
            return ('error_creating_directory', $bakdir, $!);
        }
    }

    my @errs;
    for my $file (@toremove) {
        my $oldname = $inf->{slapd}->{config_dir} . "/" . $file;
        next if (! -f $oldname); # does not exist - skip - already (re)moved
        my $newname = "$bakdir/$file";
        $! = 0; # clear
        rename $oldname, $newname;
        if ($!) {
            push @errs, ["error_renaming_config", $oldname, $newname, $!];
        }
    }


According to
https://www.unix.com/shell-programming-and-scripting/27747-perl-rename-failed.html
the perl rename call can cause this error.

My workaround was to create the directories in /etc and make symlinks in
/var/lib/dirsrv/...

  mkdir /etc/dirsrv/slapd-INSTANCE/bak
  ln -s /etc/dirsrv/slapd-INSTANCE/bak /var/lib/dirsrv/slapd-INSTANCE/bak
  mkdir /etc/dirsrv/slapd-INSTANCE/bak.bak
  ln -s /etc/dirsrv/slapd-INSTANCE/bak.bak
/var/lib/dirsrv/slapd-INSTANCE/bak.bak


Upgrade succeeded now.

I originally encountered this problem while upgrading 389-ds-base on
jessie from 1.3.3.5-4 to 1.3.3.5-4+deb8u1. Since upgrade scripts didn't
change this should be still valid for the actual version.



More information about the Pkg-freeipa-devel mailing list