]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#8307 fix slapo-accesslog: noop if logDB isn't open yet
authorHoward Chu <hyc@openldap.org>
Wed, 13 Jan 2021 16:35:43 +0000 (16:35 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 13 Jan 2021 16:35:43 +0000 (16:35 +0000)
Add be_flag for DB OPEN status

servers/slapd/backend.c
servers/slapd/overlays/accesslog.c
servers/slapd/slap.h

index 622f5657c2444e12d4b6e7542ce8b96976e2911e..2e2e5ea8a9fb12fd0631436020e6e3e0dfc06e47 100644 (file)
@@ -226,6 +226,7 @@ int backend_startup_one(Backend *be, ConfigReply *cr)
                rc = be->bd_info->bi_db_open( be, cr );
                if ( rc == 0 ) {
                        (void)backend_set_controls( be );
+                       be->be_flags |= SLAP_DBFLAG_OPEN;
 
                } else {
                        char *type = be->bd_info->bi_type;
@@ -291,6 +292,7 @@ int backend_startup(Backend *be)
                                rc );
                        return rc;
                }
+               frontendDB->be_flags |= SLAP_DBFLAG_OPEN;
        }
 
        /* open each backend type */
@@ -365,6 +367,7 @@ int backend_shutdown( Backend *be )
 
                if ( be->bd_info->bi_db_close ) {
                        rc = be->bd_info->bi_db_close( be, NULL );
+                       be->be_flags &= ~SLAP_DBFLAG_OPEN;
                        if ( rc ) return rc;
                }
 
@@ -382,6 +385,7 @@ int backend_shutdown( Backend *be )
                        continue;
                if ( be->bd_info->bi_db_close ) {
                        be->bd_info->bi_db_close( be, NULL );
+                       be->be_flags &= ~SLAP_DBFLAG_OPEN;
                }
 
                if(rc != 0) {
@@ -406,6 +410,7 @@ int backend_shutdown( Backend *be )
        /* close frontend, if required */
        if ( frontendDB->bd_info->bi_db_close ) {
                rc = frontendDB->bd_info->bi_db_close ( frontendDB, NULL );
+               frontendDB->be_flags &= ~SLAP_DBFLAG_OPEN;
                if ( rc != 0 ) {
                        Debug( LDAP_DEBUG_ANY,
                                "backend_startup: bi_db_close(frontend) failed! (%d)\n",
@@ -655,6 +660,7 @@ be_db_close( void )
        LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
                if ( be->bd_info->bi_db_close ) {
                        be->bd_info->bi_db_close( be, NULL );
+                       be->be_flags &= ~SLAP_DBFLAG_OPEN;
                }
        }
 
index 5bb75a25534cd80b6648a287c48b5e30b03b8933..2f3fedfc6ab8818948281173c424a9c0f9b08fc7 100644 (file)
@@ -1501,6 +1501,10 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
        if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
                return SLAP_CB_CONTINUE;
 
+       /* can't do anything if logDB isn't open */
+       if ( !SLAP_DBOPEN( li->li_db ))
+               return SLAP_CB_CONTINUE;
+
        logop = accesslog_op2logop( op );
        lo = logops+logop+EN_OFFSET;
        if ( !( li->li_ops & lo->mask )) {
index 2d8e02d8c892eb27d8e1d873bc55a252f0352515..90109f81917415f1a580f8317245bd800e6f49ad 100644 (file)
@@ -1872,6 +1872,7 @@ struct BackendDB {
 #define SLAP_DBFLAG_MULTI_SHADOW       0x80000U /* uses multi-provider */
 #define SLAP_DBFLAG_DISABLED   0x100000U
 #define SLAP_DBFLAG_LASTBIND   0x200000U
+#define SLAP_DBFLAG_OPEN       0x400000U       /* db is currently open */
        slap_mask_t     be_flags;
 #define SLAP_DBFLAGS(be)                       ((be)->be_flags)
 #define SLAP_NOLASTMOD(be)                     (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NOLASTMOD)
@@ -1899,6 +1900,7 @@ struct BackendDB {
 #define SLAP_SINGLE_SHADOW(be)                 (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SINGLE_SHADOW)
 #define SLAP_MULTIPROVIDER(be)                 (SLAP_DBFLAGS(be) & SLAP_DBFLAG_MULTI_SHADOW)
 #define SLAP_DBCLEAN(be)                       (SLAP_DBFLAGS(be) & SLAP_DBFLAG_CLEAN)
+#define SLAP_DBOPEN(be)                        (SLAP_DBFLAGS(be) & SLAP_DBFLAG_OPEN)
 #define SLAP_DBACL_ADD(be)                     (SLAP_DBFLAGS(be) & SLAP_DBFLAG_ACL_ADD)
 #define SLAP_SYNC_SUBENTRY(be)                 (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SUBENTRY)