summaryrefslogtreecommitdiffstats
path: root/ldap/admin/src/scripts/10fixrundir.pl
blob: a1e752406b141f175890e5d3d885974b3b1a916e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use Mozilla::LDAP::Conn;
use Mozilla::LDAP::Utils qw(normalizeDN);
use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);

sub runinst {
    my ($inf, $inst, $dseldif, $conn) = @_;

    my @errs;

    # see if nsslapd-rundir is defined
    my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
    if (!$ent) {
        return ('error_finding_config_entry', 'cn=config', $conn->getErrorString());
    }

    if (!$ent->getValues('nsslapd-rundir')) {
        $ent->setValues('nsslapd-rundir', $inf->{slapd}->{run_dir});
        # mark as modified so update will use a replace instead of an add
        $ent->attrModified('nsslapd-rundir');
        $conn->update($ent);
        my $rc = $conn->getErrorCode();
        if ($rc) {
            return ('error_updating_entry', 'cn=config', $conn->getErrorString());
        }
    }

    return ();
}