From d877251b2cdc526045529a44b8a1b5863969096f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 6 Aug 2021 22:50:23 +0100 Subject: [PATCH] (From ITS#8958) allow 2.5 slapcat to read 2.4 DB --- servers/slapd/back-mdb/init.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/servers/slapd/back-mdb/init.c b/servers/slapd/back-mdb/init.c index 9d9e7ae775..1b6ac18847 100644 --- a/servers/slapd/back-mdb/init.c +++ b/servers/slapd/back-mdb/init.c @@ -215,15 +215,18 @@ mdb_db_open( BackendDB *be, ConfigReply *cr ) &mdb->mi_dbis[i] ); if ( rc != 0 ) { - snprintf( cr->msg, sizeof(cr->msg), "database \"%s\": " - "mdb_dbi_open(%s/%s) failed: %s (%d).", - be->be_suffix[0].bv_val, - mdb->mi_dbenv_home, mdmi_databases[i].bv_val, - mdb_strerror(rc), rc ); - Debug( LDAP_DEBUG_ANY, - LDAP_XSTRING(mdb_db_open) ": %s\n", - cr->msg ); - goto fail; + /* when read-only, it's ok for ID2VAL or IDXCKP to not exist */ + if (( flags & MDB_CREATE ) || ( i < MDB_ID2VAL )) { + snprintf( cr->msg, sizeof(cr->msg), "database \"%s\": " + "mdb_dbi_open(%s/%s) failed: %s (%d).", + be->be_suffix[0].bv_val, + mdb->mi_dbenv_home, mdmi_databases[i].bv_val, + mdb_strerror(rc), rc ); + Debug( LDAP_DEBUG_ANY, + LDAP_XSTRING(mdb_db_open) ": %s\n", + cr->msg ); + goto fail; + } } if ( i == MDB_ID2ENTRY )