Bug 261792 - net/openldap26-server /usr/local/etc/rc.d/slapd assumes cn=config/olcDatabase=* are files
Summary: net/openldap26-server /usr/local/etc/rc.d/slapd assumes cn=config/olcDatabase...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Xin LI
URL:
Keywords:
: 261793 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-02-08 15:30 UTC by Norman Gray
Modified: 2024-02-05 15:56 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (delphij)


Attachments
Fix grep error message (1.95 KB, patch)
2024-02-05 15:56 UTC, Michael Glaus
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Norman Gray 2022-02-08 15:30:38 UTC
The slapd startup script searches for the location of the database directory with the line

    DATABASEDIR=`grep olcDbDirectory /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase=* | awk '{ print $2 }'`

This assumes that the objects olcDatabase=* are files, but they needn't be.  For example

    % ls -d1 /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase=*
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={-1}frontend.ldif
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={1}mdb/
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={1}mdb.ldif
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={2}mdb/
    /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={2}mdb.ldif

(the extra databases are for accesslog and syncprov)

This produces warnings when the script is used:

    % service slapd stop
    grep: /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={1}mdb: Is a directory
    grep: /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={2}mdb: Is a directory
    Stopping slapd.
    Waiting for PIDS: 72659.

A suitable alternative might be:

    % find /usr/local/etc/openldap/slapd.d/cn=config -name olcDatabase=\*.ldif|xargs grep olcDbDirectory

This is in the port of openldap26-server-2.6.0, in 13.0-RELEASE.
Comment 1 Li-Wen Hsu freebsd_committer freebsd_triage 2022-02-08 15:36:04 UTC
*** Bug 261793 has been marked as a duplicate of this bug. ***
Comment 2 Norman Gray 2022-02-08 15:39:57 UTC
Sorry for the duplicate.  I submitted the first one, but got a big red warning about an invalid token (?), so I assumed the submission had failed and did it again (I'd fortunately/automatically copied the body text!).
Comment 3 Corey Hinshaw 2022-08-05 15:46:01 UTC
Note that this also affects net/openldap25-server
Comment 4 Zeus Panchenko 2023-07-26 18:29:15 UTC
I have the same issue and used grep -r option as workaround

here a diff

--- slapd.orig  2023-07-26 20:40:23.461548000 +0300
+++ slapd       2023-07-26 21:16:31.057004000 +0300
@@ -71,7 +71,7 @@
 if checkyesno slapd_cn_config; then
   required_dirs="/usr/local/etc/openldap/slapd.d"
   required_files="/usr/local/etc/openldap/slapd.d/cn=config.ldif"
-  DATABASEDIR=`grep olcDbDirectory /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase=* | awk '{ print $2 }'`
+  DATABASEDIR=`grep -r olcDbDirectory /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase=* | awk '{ print $2 }'`
 else
   required_files="/usr/local/etc/openldap/slapd.conf"
   DATABASEDIR=`awk '$1 == "directory" { print $2 }' "/usr/local/etc/openldap/slapd.conf" 2>&1 /dev/null`
Comment 5 Michael Glaus 2024-02-05 15:56:23 UTC
Created attachment 248207 [details]
Fix grep error message

I just run into the same problem.

Based on the workaround of Zeus i created a patch for openldap25 and openldap26.