From c6aae1e5b75e9436e5378cec705af5f79fc98b0d Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Jul 27 2020 18:08:57 +0000 Subject: Issue 49487 - Cleanup unused code Description: Remove unused functions and "#if 0" code blocks. relates: https://pagure.io/389-ds-base/issue/49487 Reviewed by: firstyear(Thanks!) --- diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c index 41a909a..e9246b2 100644 --- a/ldap/servers/plugins/acl/acl.c +++ b/ldap/servers/plugins/acl/acl.c @@ -3614,12 +3614,6 @@ acl__attr_cached_result(struct acl_pblock *aclpb, char *attr, int access) * "don't know". */ return (ACL_ERR); -#if 0 - if ( eval_read ) - return LDAP_INSUFFICIENT_ACCESS; - else - return ACL_ERR; -#endif } for (i = 0; i < c_evalContext->acle_numof_attrs; i++) { diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c index 11cbd7a..f02efaa 100644 --- a/ldap/servers/plugins/acl/aclplugin.c +++ b/ldap/servers/plugins/acl/aclplugin.c @@ -84,16 +84,6 @@ acl_preopInit(Slapi_PBlock *pb) rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN, (void *)aclplugin_preop_modify); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN, (void *)aclplugin_preop_modify); -#if 0 - /* - * XXXmcs: In order to support access control checking from - * extended operations, we need a SLAPI_PLUGIN_PRE_EXTENDED_FN hook. - * But today no such entry point exists. - */ - rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_EXTENDED_FN, (void*)aclplugin_preop_modify); -#endif - - slapi_log_err(SLAPI_LOG_PLUGIN, plugin_name, "<= acl_preop_Init %d\n", rc); return (rc); } diff --git a/ldap/servers/plugins/posix-winsync/posix-group-task.c b/ldap/servers/plugins/posix-winsync/posix-group-task.c index 922c4f7..c139e1a 100644 --- a/ldap/servers/plugins/posix-winsync/posix-group-task.c +++ b/ldap/servers/plugins/posix-winsync/posix-group-task.c @@ -166,43 +166,6 @@ posix_group_task_destructor(Slapi_Task *task) "posix_group_task_destructor <--\n"); } -#if 0 /* NOT USED */ -static int -posix_group_del_memberuid_callback(Slapi_Entry *e, void *callback_data) -{ - int rc = 0; - LDAPMod mod; - LDAPMod *mods[2]; - char *val[2]; - Slapi_PBlock *mod_pb = 0; - cb_data *the_cb_data = (cb_data *) callback_data; - - mod_pb = slapi_pblock_new(); - - mods[0] = &mod; - mods[1] = 0; - - val[0] = 0; /* all */ - val[1] = 0; - - mod.mod_op = LDAP_MOD_DELETE; - mod.mod_type = "memberuid"; - mod.mod_values = val; - - slapi_modify_internal_set_pb_ext(mod_pb, slapi_entry_get_sdn(e), mods, 0, 0, - posix_winsync_get_plugin_identity(), 0); - - slapi_pblock_set(mod_pb, SLAPI_TXN, the_cb_data->txn); - slapi_modify_internal_pb(mod_pb); - - slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc); - - slapi_pblock_destroy(mod_pb); - - return rc; -} -#endif - static int posix_group_fix_memberuid(char *dn, char *filter_str, void *txn) { diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c index 6b591fb..e4ae739 100644 --- a/ldap/servers/plugins/replication/cl5_clcache.c +++ b/ldap/servers/plugins/replication/cl5_clcache.c @@ -399,12 +399,6 @@ clcache_load_buffer_bulk(CLC_Buffer *buf, int flag) int tries = 0; int use_flag = flag; -#if 0 /* txn control seems not improving anything so turn it off */ - if ( *(_pool->pl_dbenv) ) { - txn_begin( *(_pool->pl_dbenv), NULL, &txn, 0 ); - } -#endif - if (NULL == buf) { slapi_log_err(SLAPI_LOG_ERR, get_thread_private_agmtname(), "clcache_load_buffer_bulk - NULL buf\n"); @@ -466,12 +460,6 @@ retry: tries); } -#if 0 /* txn control seems not improving anything so turn it off */ - if ( txn ) { - txn->commit ( txn, DB_TXN_NOSYNC ); - } -#endif - PR_Unlock(buf->buf_busy_list->bl_lock); buf->buf_record_ptr = NULL; diff --git a/ldap/servers/plugins/replication/cl5_test.c b/ldap/servers/plugins/replication/cl5_test.c index d665665..0e2894a 100644 --- a/ldap/servers/plugins/replication/cl5_test.c +++ b/ldap/servers/plugins/replication/cl5_test.c @@ -434,21 +434,6 @@ testAll() testBackupRestore(); testLDIF(); - -/* testTrimming ();*/ - -#if 0 - /* xxxPINAKI */ - /* these tests are not working correctly...the call to db->put() */ - /* just hangs forever */ - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "Starting single threaded performance measurement ...\n"); - testPerformance (); - - slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name_cl, - "Starting multi threaded performance measurement ...\n"); - testPerformanceMT (); -#endif } static int diff --git a/ldap/servers/plugins/views/views.c b/ldap/servers/plugins/views/views.c index 64e305a..3df125b 100644 --- a/ldap/servers/plugins/views/views.c +++ b/ldap/servers/plugins/views/views.c @@ -981,11 +981,6 @@ views_cache_create_descendent_filter(viewEntry *ancestor, PRBool useEntryID) static void views_cache_create_inclusion_filter(viewEntry *pView) { -#if 0 - viewEntry *head = theCache.pCacheViews; -#endif - /* viewEntry *current; */ - /* Slapi_Filter *view_filter; */ char *view_filter_str; if (pView->includeChildViewsFilter) { @@ -993,59 +988,15 @@ views_cache_create_inclusion_filter(viewEntry *pView) slapi_filter_free(pView->includeChildViewsFilter, 1); pView->includeChildViewsFilter = 0; } -#if 0 - for(current = head; current != NULL; current = current->list.pNext) - { - Slapi_DN *viewDN; - Slapi_RDN *viewRDN; - char *viewRDNstr; - char *buf = 0; - Slapi_Filter *viewSubFilter; - - /* if this is this a descendent, ignore it */ - if(slapi_dn_issuffix(current->pDn,pView->pDn) && !(current == pView)) - continue; - - viewDN = slapi_sdn_new_dn_byref(current->pDn); - viewRDN = slapi_rdn_new(); - - slapi_sdn_get_rdn(viewDN,viewRDN); - viewRDNstr = (char *)slapi_rdn_get_rdn(viewRDN); - - buf = slapi_ch_calloc(1, strlen(viewRDNstr) + 11 ); /* 3 for filter */ - sprintf(buf, "(%s)", viewRDNstr ); - viewSubFilter = slapi_str2filter( buf ); - if (!viewSubFilter) { - slapi_log_err(SLAPI_LOG_ERR, VIEWS_PLUGIN_SUBSYSTEM, - "views_cache_create_inclusion_filter - View filter [%s] in entry [%s] is invalid\n", - buf, current->pDn); - } - - if(pView->includeChildViewsFilter && viewSubFilter) - pView->includeChildViewsFilter = slapi_filter_join_ex( LDAP_FILTER_OR, pView->includeChildViewsFilter, viewSubFilter, 0 ); - else - pView->includeChildViewsFilter = viewSubFilter; - - slapi_ch_free((void **)&buf); - slapi_sdn_free(&viewDN); - slapi_rdn_free(&viewRDN); - child_count++; - } -#endif - - /* exclude all other view entries but decendents */ - /* pView->includeChildViewsFilter = slapi_filter_join_ex( LDAP_FILTER_NOT, pView->includeChildViewsFilter, NULL, 0 ); -*/ /* it seems reasonable to include entries which - * may not fit the view decription but which + * may not fit the view description but which * are actually *contained* in the view * therefore we use parentids for the view * filter */ - - /* add decendents */ + /* add descendants */ pView->includeChildViewsFilter = views_cache_create_descendent_filter(pView, PR_TRUE); /* add this view */ @@ -1059,39 +1010,6 @@ views_cache_create_inclusion_filter(viewEntry *pView) PR_smprintf_free(view_filter_str); view_filter_str = NULL; - /* and make sure the this applies only to views */ - - /* if(pView->includeChildViewsFilter) - {*/ - /* Not necessary since we now use entryid in the filter, - so all will be views anyway, and the less sub-filters - the better - view_filter_str = strdup("(objectclass=" VIEW_OBJECTCLASS ")"); - view_filter = slapi_str2filter( view_filter_str ); -*/ - /* child views first because entryid indexed - * and makes evaluation faster when a bunch - * of indexed filter evaluations with only one - * target are evaluated first rather than an - * indexed filter which will provide many entries - * that may trigger an index evaluation short - * circuit. i.e. if one of the child filters is - * true then we have one entry, if not, then we - * have used indexes completely to determine that - * no entry matches and (objectclass=nsview) is never - * evaluated. - * I should imagine this will hold for all but the - * very deepest, widest view trees when subtree - * searches are performed from the top - */ - /* pView->includeChildViewsFilter = slapi_filter_join_ex( LDAP_FILTER_AND, pView->includeChildViewsFilter, view_filter, 0 ); - } - else - { - view_filter_str = strdup("(objectclass=nsviewincludenone)"); */ /* hackery to get the right result */ -/* pView->includeChildViewsFilter = slapi_str2filter( view_filter_str ); - } -*/ #ifdef _VIEW_DEBUG_FILTERS slapi_filter_to_string(pView->includeChildViewsFilter, pView->includeChildViewsFilter_str, sizeof(pView->includeChildViewsFilter_str)); #endif diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c index 7de006c..6bbcb05 100644 --- a/ldap/servers/slapd/attrsyntax.c +++ b/ldap/servers/slapd/attrsyntax.c @@ -128,82 +128,6 @@ attr_syntax_unlock_write(void) AS_UNLOCK_WRITE(oid2asi_lock); } - -#if 0 -static int -check_oid( const char *oid ) { - - int i = 0, length_oid = 0, rc = 0; - - if ( oid == NULL) { - /* this is bad */ - slapi_log_err(SLAPI_LOG_ERR, "check_oid", "NULL passed to check_oid\n"); - return 0; - } - - length_oid = strlen(oid); - if (length_oid < 4) { - /* this is probably bad */ - slapi_log_err(SLAPI_LOG_ERR, "check_oid", "Bad oid %s passed to check_oid\n",oid); - return 0; - } - - rc = strcasecmp(oid+(length_oid-4), "-oid"); - - if ( 0 == rc ) { - return 1; - } - - /* If not, the OID must begin and end with a digit, and contain only - digits and dots */ - - if ( !isdigit(oid[0]) || - !isdigit(oid[length_oid-1]) ) { - slapi_log_err(SLAPI_LOG_ERR, "check_oid", "Non numeric oid %s passed to check_oid\n",oid); - return 0; - } - - /* check to see that it contains only digits and dots */ - for ( i = 0; i < length_oid; i++ ) { - if ( !isdigit(oid[i]) && oid[i] != '.' ){ - slapi_log_err(SLAPI_LOG_ERR, "check_oid", "Non numeric oid %s passed to check_oid\n",oid); - return 0; - } - } - - /* The oid is OK if we're here */ - return 1; - - -} -#endif - -#define NBUCKETS(ht) (1 << (PL_HASH_BITS - (ht)->shift)) - -#if 0 -static int -attr_syntax_check_oids() -{ - int ii = 0; - int nbad = 0; - AS_LOCK_READ(oid2asi_lock); - ii = NBUCKETS(oid2asi); - for (;ii;--ii) { - PLHashEntry *he = oid2asi->buckets[ii-1]; - for (; he; he = he->next) { - if (!check_oid(he->key)) { - slapi_log_err(SLAPI_LOG_ERR, "attr_syntax_check_oids", "bad oid %s in bucket %d\n", - he->key, ii-1); - nbad++; - } - } - } - - AS_UNLOCK_READ(oid2asi_lock); - return nbad; -} -#endif - void attr_syntax_free(struct asyntaxinfo *a) { diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_upgrade.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_upgrade.c index 26b99d6..9525a35 100644 --- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_upgrade.c +++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_upgrade.c @@ -341,71 +341,3 @@ ldbm_upgrade(ldbm_instance *inst, int action) return rval; } - -/* Here's the upgrade process : - Delete all the keys from the parentid index - Scan the id2entry file: - Remove any hassubordinates attribute present - Update the parentid index, maintaining a hash of high-count parents - Scan the newly created parentid index updating the subordinatecount attributes. - - Most of the functionality is implemented in the import code. - */ -#if 0 -static int upgrade_db_3x_40(backend *be) -{ - struct ldbminfo *li = (struct ldbminfo *) be->be_database->plg_private; - int ret = 0; - back_txn txn; - - static char* indexes_modified[] = {"parentid", "numsubordinates", NULL}; - - slapi_log_err(SLAPI_LOG_WARNING, "upgrade_db_3x_40", - "WARNING: Detected a database older than this server, upgrading data...\n"); - - dblayer_txn_init(li,&txn); - ret = dblayer_txn_begin(li,NULL,&txn); - if (0 != ret) { - ldbm_nasty("upgrade_db_3x_40",filename,69,ret); - goto error; - } - ret = indexfile_delete_all_keys(be,"parentid",&txn); - if (0 != ret) { - ldbm_nasty("upgrade_db_3x_40",filename,70,ret); - goto error; - } - - { - Slapi_Mods smods; - slapi_mods_init(&smods,1); - /* Mods are to remove the hassubordinates attribute */ - slapi_mods_add(&smods, LDAP_MOD_DELETE, "hassubordinates", 0, NULL); - /* This function takes care of generating the subordinatecount attribute and indexing it */ - ret = indexfile_primary_modifyall(be,slapi_mods_get_ldapmods_byref(&smods),indexes_modified,&txn); - slapi_mods_done(&smods); - } - - if (0 != ret) { - ldbm_nasty("upgrade_db_3x_40",filename,61,ret); - } - -error: - if (0 != ret ) { - dblayer_txn_abort(li,&txn); - } else { - ret = dblayer_txn_commit(li,&txn); - if (0 != ret) { - ldbm_nasty("upgrade_db_3x_40",filename,60,ret); - } else { - /* Now update DBVERSION file */ - } - } - if (0 == ret) { - slapi_log_err(SLAPI_LOG_INFO, "upgrade_db_3x_40", "...upgrade complete.\n"); - } else { - slapi_log_err(SLAPI_LOG_ERR, "upgrade_db_3x_40", "Attempt to upgrade the older database FAILED.\n"); - } - return ret; -} - -#endif diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c index 410db23..4cb8eb3 100644 --- a/ldap/servers/slapd/back-ldbm/index.c +++ b/ldap/servers/slapd/back-ldbm/index.c @@ -1800,150 +1800,6 @@ index_range_read( return index_range_read_ext(pb, be, type, indextype, operator, val, nextval, range, txn, err, 0); } -/* DBDB: this function is never actually called */ -#if 0 -static int -addordel_values( - backend *be, - DB *db, - char *type, - const char *indextype, - struct berval **vals, - ID id, - int flags, /* BE_INDEX_ADD, etc */ - back_txn *txn, - struct attrinfo *a, - int *idl_disposition, - void *buffer_handle -) -{ - int rc = 0; - int i = 0; - DBT key = {0}; - DB_TXN *db_txn = NULL; - size_t plen, vlen, len; - char *tmpbuf = NULL; - size_t tmpbuflen = 0; - char *realbuf; - char *prefix; - - slapi_log_err(SLAPI_LOG_TRACE, "addordel_values", "%s_values\n", - (flags & BE_INDEX_ADD) ? "add" : "del"); - - prefix = index_index2prefix( indextype ); - - if (prefix == NULL) { - slapi_log_err(SLAPI_LOG_ERR, "addordel_values", "%s_values: NULL prefix\n", - (flags & BE_INDEX_ADD) ? "add" : "del"); - return( -1 ); - } - - if ( vals == NULL ) { - key.dptr = prefix; - key.dsize = strlen( prefix ) + 1; /* include null terminator */ - key.flags = DB_DBT_MALLOC; - if (NULL != txn) { - db_txn = txn->back_txn_txn; - } - - if (flags & BE_INDEX_ADD) { - rc = idl_insert_key( be, db, &key, id, db_txn, a, idl_disposition ); - } else { - rc = idl_delete_key( be, db, &key, id, db_txn, a ); - /* check for no such key/id - ok in some cases */ - if ( rc == DB_NOTFOUND || rc == -666 ) { - rc = 0; - } - } - - if ( rc != 0) - { - ldbm_nasty("addordel_values", errmsg, 1096, rc); - } - index_free_prefix (prefix); - if (NULL != key.dptr && prefix != key.dptr) - slapi_ch_free( (void**)&key.dptr ); - slapi_log_err(SLAPI_LOG_TRACE, "addordel_values", "%s_values %d\n", - (flags & BE_INDEX_ADD) ? "add" : "del", rc); - return( rc ); - } - - plen = strlen( prefix ); - for ( i = 0; vals[i] != NULL; i++ ) { - vlen = vals[i]->bv_len; - len = plen + vlen; - - if ( len < tmpbuflen ) { - realbuf = tmpbuf; - } else { - tmpbuf = slapi_ch_realloc( tmpbuf, len + 1 ); - tmpbuflen = len + 1; - realbuf = tmpbuf; - } - - memcpy( realbuf, prefix, plen ); - memcpy( realbuf+plen, vals[i]->bv_val, vlen ); - realbuf[len] = '\0'; - key.dptr = realbuf; - key.size = plen + vlen + 1; - /* should be okay to use USERMEM here because we know what - * the key is and it should never return a different value - * than the one we pass in. - */ - key.flags = DB_DBT_USERMEM; - key.ulen = tmpbuflen; - if (slapi_is_loglevel_set(LDAP_DEBUG_TRACE)) { - char encbuf[BUFSIZ]; - - slapi_log_err(SLAPI_LOG_TRACE, "addordel_values", "%s_value(\"%s\")\n", - (flags & BE_INDEX_ADD) ? "add" : "del", - encoded (&key, encbuf)); - } - - if (NULL != txn) { - db_txn = txn->back_txn_txn; - } - - if ( flags & BE_INDEX_ADD ) { - if (buffer_handle) { - rc = index_buffer_insert(buffer_handle,&key,id,be,db_txn,a); - if (rc == -2) { - rc = idl_insert_key( be, db, &key, id, db_txn, a, idl_disposition ); - } - } else { - rc = idl_insert_key( be, db, &key, id, db_txn, a, idl_disposition ); - } - } else { - rc = idl_delete_key( be, db, &key, id, db_txn, a ); - /* check for no such key/id - ok in some cases */ - if ( rc == DB_NOTFOUND || rc == -666 ) { - rc = 0; - } - } - if ( rc != 0 ) { - ldbm_nasty("addordel_values", errmsg, 1100, rc); - break; - } - if ( NULL != key.dptr && realbuf != key.dptr) { /* realloc'ed */ - tmpbuf = key.dptr; - tmpbuflen = key.size; - } - } - index_free_prefix (prefix); - if ( tmpbuf != NULL ) { - slapi_ch_free( (void**)&tmpbuf ); - } - - if ( rc != 0 ) - { - ldbm_nasty("addordel_values", errmsg, 1110, rc); - } - slapi_log_err(SLAPI_LOG_TRACE, "addordel_values", "%s_values %d\n", - (flags & BE_INDEX_ADD) ? "add" : "del", rc); - return( rc ); -} -#endif - static int addordel_values_sv( backend *be, diff --git a/ldap/servers/slapd/back-ldbm/init.c b/ldap/servers/slapd/back-ldbm/init.c index 8937766..4e38eb3 100644 --- a/ldap/servers/slapd/back-ldbm/init.c +++ b/ldap/servers/slapd/back-ldbm/init.c @@ -110,12 +110,8 @@ ldbm_back_init(Slapi_PBlock *pb) (void *)ldbm_back_search); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN, (void *)ldbm_back_next_search_entry); - rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN, - (void *)ldbm_back_next_search_entry_ext); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_PREV_SEARCH_RESULTS_FN, (void *)ldbm_back_prev_search_results); - rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN, - (void *)ldbm_back_entry_release); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN, (void *)ldbm_back_search_results_release); rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_COMPARE_FN, diff --git a/ldap/servers/slapd/back-ldbm/instance.c b/ldap/servers/slapd/back-ldbm/instance.c index 07655a8..1e490b0 100644 --- a/ldap/servers/slapd/back-ldbm/instance.c +++ b/ldap/servers/slapd/back-ldbm/instance.c @@ -205,12 +205,6 @@ ldbm_instance_create_default_indexes(backend *be) ldbm_instance_config_add_index_entry(inst, e, flags); slapi_entry_free(e); -#if 0 /* don't need copiedfrom */ - e = ldbm_instance_init_config_entry("copiedfrom","pres",0 ,0); - ldbm_instance_config_add_index_entry(inst, e, flags); - slapi_entry_free(e); -#endif - e = ldbm_instance_init_config_entry(LDBM_NUMSUBORDINATES_STR, "pres", 0, 0, 0); ldbm_instance_config_add_index_entry(inst, e, flags); slapi_entry_free(e); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index fbcb573..3b7a321 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -967,25 +967,7 @@ replace_entry: goto error_return; } } -#if 0 /* The entryrdn element is already deleted in the index_addordel_entry */ - retval = entryrdn_index_entry(be, e, BE_INDEX_DEL, &txn); - if (DB_LOCK_DEADLOCK == retval) { - slapi_log_err(SLAPI_LOG_BACKLDBM, - "ldbm_back_delete", "(deleting entryrdn) DB_LOCK_DEADLOCK\n"); - /* Retry txn */ - continue; - } - if (0 != retval) { - slapi_log_err(SLAPI_LOG_ERR, - "ldbm_back_delete", "(deleting entryrdn) failed, err=%d %s\n", - retval, - (msg = dblayer_strerror( retval )) ? msg : "" ); - if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; - DEL_SET_ERROR(ldap_result_code, - LDAP_OPERATIONS_ERROR, retry_count); - goto error_return; - } -#endif + retval = entryrdn_index_entry(be, tombstone, BE_INDEX_ADD, &txn); if (DB_LOCK_DEADLOCK == retval) { slapi_log_err(SLAPI_LOG_BACKLDBM, diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c index 5797dd7..85d5526 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c @@ -79,10 +79,6 @@ static size_t _entryrdn_rdn_elem_size(rdn_elem *elem); static void _entryrdn_dump_rdn_elem(rdn_elem *elem); #endif static int _entryrdn_open_index(backend *be, struct attrinfo **ai, DB **dbp); -#if 0 /* not used */ -static char *_entryrdn_encrypt_key(backend *be, const char *key, struct attrinfo *ai); -static char *_entryrdn_decrypt_key(backend *be, const char *key, struct attrinfo *ai); -#endif static int _entryrdn_get_elem(DBC *cursor, DBT *key, DBT *data, const char *comp_key, rdn_elem **elem, DB_TXN *db_txn); static int _entryrdn_get_tombstone_elem(DBC *cursor, Slapi_RDN *srdn, DBT *key, const char *comp_key, rdn_elem **elem, DB_TXN *db_txn); static int _entryrdn_put_data(DBC *cursor, DBT *key, DBT *data, char type, DB_TXN *db_txn); @@ -1619,88 +1615,6 @@ bail: return rc; } -#if 0 /* not used */ -/* - * We don't support attribute encryption for entryrdn. - * Since there is no way to encrypt RDN in the main db id2entry, - * encrypting/decrypting entryrdn does not add any benefit to the server. - */ -static berval * -_entryrdn_encrypt_key(backend *be, const char *key, struct attrinfo *ai) -{ - int rc = 0; - struct berval val = {0}; - struct berval *encrypted_val = NULL; - char *encrypted = NULL; - - slapi_log_err(SLAPI_LOG_TRACE, "_entryrdn_encrypt_key", - "--> _entryrdn_encrypt_key\n"); - - if (NULL == key) { - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_encrypt_key", "Empty key\n"); - goto bail; - } - if (NULL == be || NULL == key || NULL == ai) { - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_encrypt_key", - "Param error: Empty %s\n", - NULL==be?"be":NULL==key?"key": - NULL==ai?"attrinfo":"unknown"); - goto bail; - } - val.bv_val = (void *)key; - val.bv_len = strlen(key); - rc = attrcrypt_encrypt_index_key(be, ai, &val, &encrypted_val); - if (NULL == encrypted_val) { - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_encrypt_key", - "Failed to encrypt index key for %s\n", key); - } -bail: - slapi_log_err(SLAPI_LOG_TRACE, "_entryrdn_encrypt_key", - "<-- _entryrdn_encrypt_key\n"); - return encrypted_val; -} - -static char * -_entryrdn_decrypt_key(backend *be, const char *key, struct attrinfo *ai) -{ - int rc = 0; - struct berval val = {0}; - struct berval *decrypted_val = NULL; - char *decrypted = NULL; - - slapi_log_err(SLAPI_LOG_TRACE, "_entryrdn_decrypt_key", - "--> _entryrdn_decrypt_key\n"); - - if (NULL == key) { - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_decrypt_key", "Empty key\n"); - goto bail; - } - if (NULL == be || NULL == key || NULL == ai) { - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_decrypt_key", - "Param error: Empty %s\n", - NULL==be?"be":NULL==key?"key": - NULL==ai?"attrinfo":"unknown"); - goto bail; - } - val.bv_val = (void *)key; - val.bv_len = strlen(key); - rc = attrcrypt_decrypt_index_key(be, ai, &val, &decrypted_val); - if (decrypted_val) { - /* null terminated string */ - decrypted = slapi_ch_strdup(decrypted_val->bv_val); - ber_bvfree(decrypted_val); - goto bail; - } - slapi_log_err(SLAPI_LOG_ERR, "_entryrdn_decrypt_key", - "Failed to decrypt index key for %s\n", key); - -bail: - slapi_log_err(SLAPI_LOG_TRACE, "_entryrdn_decrypt_key", - "<-- _detryrdn_encrypt_key\n"); - return decrypted; -} -#endif - /* Notes: * 1) data->data must be located in the data area (not in the stack). * If c_get reallocate the memory, the given data is freed. diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c index 1a7b510..9119ed5 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_search.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c @@ -1248,22 +1248,6 @@ subtree_candidates( } static int grok_filter(struct slapi_filter *f); -#if 0 -/* Helper for grok_filter() */ -static int -grok_filter_list(struct slapi_filter *flist) -{ - struct slapi_filter *f; - - /* Scan the clauses of the AND filter, if any of them fails the grok, then we fail */ - for ( f = flist; f != NULL; f = f->f_next ) { - if ( !grok_filter(f) ) { - return( 0 ); - } - } - return( 1 ); -} -#endif /* Helper function for can_skip_filter_test() */ static int @@ -1382,22 +1366,6 @@ can_skip_filter_test( return rc; } - -/* - * Return the next entry in the result set. The entry is returned - * in the pblock. - * Returns 0 normally. If -1 is returned, it means that some - * exceptional condition, e.g. timelimit exceeded has occurred, - * and this routine has sent a result to the client. If zero - * is returned and no entry is available in the PBlock, then - * we've iterated through all the entries. - */ -int -ldbm_back_next_search_entry(Slapi_PBlock *pb) -{ - return ldbm_back_next_search_entry_ext(pb, 0); -} - /* The reference on the target_entry (base search) is stored in the operation * This is to prevent additional cache find/return that require cache lock. * @@ -1419,8 +1387,17 @@ non_target_cache_return(Slapi_Operation *op, struct cache *cache, struct backent } } +/* + * Return the next entry in the result set. The entry is returned + * in the pblock. + * Returns 0 normally. If -1 is returned, it means that some + * exceptional condition, e.g. timelimit exceeded has occurred, + * and this routine has sent a result to the client. If zero + * is returned and no entry is available in the PBlock, then + * we've iterated through all the entries. + */ int -ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) +ldbm_back_next_search_entry(Slapi_PBlock *pb) { backend *be; ldbm_instance *inst; @@ -1520,15 +1497,15 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) /* Return to the cache the entry we handed out last time */ /* If we are using the extension, the front end will tell * us when to do this so we don't do it now */ - if (sr->sr_entry && !use_extension) { + if (sr->sr_entry) { non_target_cache_return(op, &inst->inst_cache, &(sr->sr_entry)); sr->sr_entry = NULL; } - if (sr->sr_vlventry != NULL && !use_extension) { - /* This empty entry was handed out last time because the ACL check failed on a VLV Search. */ - /* The empty entry has a pointer to the cache entry dn... make sure we don't free the dn */ - /* which belongs to the cache entry. */ + if (sr->sr_vlventry != NULL) { + /* This empty entry was handed out last time because the ACL check failed on a VLV Search. + * The empty entry has a pointer to the cache entry dn... make sure we don't free the dn + * which belongs to the cache entry. */ slapi_entry_free(sr->sr_vlventry); sr->sr_vlventry = NULL; } @@ -1542,9 +1519,6 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) /* check for abandon */ if (slapi_op_abandoned(pb) || (NULL == sr)) { slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, NULL); delete_search_result_set(pb, &sr); rc = SLAPI_FAIL_GENERAL; @@ -1552,15 +1526,11 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) } /* - * Check this only every few iters to prevent smashing the clock api? + * Check time limit, Check this only every few iters to prevent smashing the clock api? */ - /* check time limit */ if (slapi_timespec_expire_check(&expire_time) == TIMER_EXPIRED) { - slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_next_search_entry_ext", "LDAP_TIMELIMIT_EXCEEDED\n"); + slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_next_search_entry", "LDAP_TIMELIMIT_EXCEEDED\n"); slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, NULL); delete_search_result_set(pb, &sr); rc = SLAPI_FAIL_GENERAL; @@ -1570,9 +1540,6 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) /* check lookthrough limit */ if (llimit != -1 && sr->sr_lookthroughcount >= llimit) { slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, NULL); delete_search_result_set(pb, &sr); rc = SLAPI_FAIL_GENERAL; @@ -1610,9 +1577,6 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) /* No more entries */ /* destroy back_search_result_set */ slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, NULL); delete_search_result_set(pb, &sr); op->o_reverse_search_state = 0; @@ -1642,18 +1606,17 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) } if (e == NULL) { if (err != 0 && err != DB_NOTFOUND) { - slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry_ext", "next_search_entry db err %d\n", - err); + slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry", + "next_search_entry db err %d\n", err); if (LDBM_OS_ERR_IS_DISKFULL(err)) { /* disk full in the middle of returning search results - * is gonna be traumatic. unavoidable. - */ + * is gonna be traumatic. unavoidable. */ slapi_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, NULL, 0, NULL); rc = return_on_disk_full(li); goto bail; } } - slapi_log_err(SLAPI_LOG_ARGS, "ldbm_back_next_search_entry_ext", "candidate %lu not found\n", + slapi_log_err(SLAPI_LOG_ARGS, "ldbm_back_next_search_entry", "candidate %lu not found\n", (u_long)id); if (err == DB_NOTFOUND) { /* Since we didn't really look at this entry, we should @@ -1661,8 +1624,7 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) * If we didn't do this, it would be possible to go over the * lookthrough limit when there are fewer entries in the database * than the lookthrough limit. This could happen on an ALLIDS - * search after adding a bunch of entries and then deleting - * them. */ + * search after adding a bunch of entries and then deleting them. */ --sr->sr_lookthroughcount; } continue; @@ -1678,23 +1640,20 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) if (!managedsait && slapi_entry_attr_find(e->ep_entry, "ref", &attr) == 0) { Slapi_Value **refs = attr_get_present_values(attr); if (refs == NULL || refs[0] == NULL) { - slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry_ext", "null ref in (%s)\n", + slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry", "null ref in (%s)\n", backentry_get_ndn(e)); } else if (slapi_sdn_scope_test(backentry_get_sdn(e), basesdn, scope)) { - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, e); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, e->ep_entry); rc = 0; goto bail; } } else { /* - * As per slapi_filter_test: - * 0 filter matched - * -1 filter did not match - * >0 an ldap error code - */ + * As per slapi_filter_test: + * 0 filter matched + * -1 filter did not match + * >0 an ldap error code + */ int filter_test = -1; int is_bulk_import = operation_is_flag_set(op, OP_FLAG_BULK_IMPORT); @@ -1706,25 +1665,26 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) !filter_flag_is_set(filter, SLAPI_FILTER_LDAPSUBENTRY)) || (slapi_entry_flag_is_set(e->ep_entry, SLAPI_ENTRY_FLAG_TOMBSTONE) && ((!isroot && !filter_flag_is_set(filter, SLAPI_FILTER_RUV)) || - !filter_flag_is_set(filter, SLAPI_FILTER_TOMBSTONE)))) { + !filter_flag_is_set(filter, SLAPI_FILTER_TOMBSTONE)))) + { /* If the entry is an LDAP subentry and filter don't filter subentries OR - * the entry is a TombStone and filter don't filter Tombstone - * don't return the entry. We make a special case to allow a non-root user - * to search for the RUV entry using a filter of: - * - * "(&(objectclass=nstombstone)(nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff))" - * - * For this RUV case, we let the ACL check apply. - */ + * the entry is a TombStone and filter don't filter Tombstone + * don't return the entry. We make a special case to allow a non-root user + * to search for the RUV entry using a filter of: + * + * "(&(objectclass=nstombstone)(nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff))" + * + * For this RUV case, we let the ACL check apply. + */ /* ugaston - we don't want to mistake this filter failure with the one below due to ACL, - * because whereas the former should be read as 'no entry must be returned', the latter - * might still lead to return an empty entry. */ + * because whereas the former should be read as 'no entry must be returned', the latter + * might still lead to return an empty entry. */ filter_test = -1; } else { /* it's a regular entry, check if it matches the filter, and passes the ACL check */ if (0 != (sr->sr_flags & SR_FLAG_CAN_SKIP_FILTER_TEST)) { /* Since we do access control checking in the filter test (?Why?) we need to check access now */ - slapi_log_err(SLAPI_LOG_FILTER, "ldbm_back_next_search_entry_ext", + slapi_log_err(SLAPI_LOG_FILTER, "ldbm_back_next_search_entry", "Bypassing filter test\n"); if (ACL_CHECK_FLAG) { filter_test = slapi_vattr_filter_test_ext(pb, e->ep_entry, filter, ACL_CHECK_FLAG, 1 /* Only perform access checking, thank you */); @@ -1734,12 +1694,12 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) if (li->li_filter_bypass_check) { int ft_rc; - slapi_log_err(SLAPI_LOG_FILTER, "ldbm_back_next_search_entry_ext", "Checking bypass\n"); + slapi_log_err(SLAPI_LOG_FILTER, "ldbm_back_next_search_entry", "Checking bypass\n"); ft_rc = slapi_vattr_filter_test(pb, e->ep_entry, filter, ACL_CHECK_FLAG); if (filter_test != ft_rc) { /* Oops ! This means that we thought we could bypass the filter test, but noooo... */ - slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry_ext", + slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_next_search_entry", "Filter bypass ERROR on entry %s\n", backentry_get_ndn(e)); filter_test = ft_rc; /* Fix the error */ } @@ -1769,29 +1729,23 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) slapi_pblock_set(pb, SLAPI_SEARCH_SIZELIMIT, &slimit); if (op_is_pagedresults(op)) { /* - * On Simple Paged Results search, - * sizelimit is appied to each page. - */ + * On Simple Paged Results search, + * sizelimit is appied to each page. + */ pagedresults_set_sizelimit(conn, op, slimit, pr_idx); } sr->sr_current_sizelimit = slimit; } if ((filter_test != 0) && sr->sr_virtuallistview) { /* Slapi Filter Test failed. - * Must be that the ACL check failed. - * Send back an empty entry. - */ + * Must be that the ACL check failed. + * Send back an empty entry. + */ sr->sr_vlventry = slapi_entry_alloc(); slapi_entry_init(sr->sr_vlventry, slapi_ch_strdup(slapi_entry_get_dn_const(e->ep_entry)), NULL); e->ep_vlventry = sr->sr_vlventry; - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, e); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, sr->sr_vlventry); } else { - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, e); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, e->ep_entry); } rc = 0; @@ -1821,9 +1775,6 @@ ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension) /* check for the final abandon */ if (slapi_op_abandoned(pb)) { slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE, &estimate); - if (use_extension) { - slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, NULL); - } slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_ENTRY, NULL); delete_search_result_set(pb, &sr); rc = SLAPI_FAIL_GENERAL; @@ -1930,26 +1881,3 @@ ldbm_back_search_results_release(void **sr) /* passing NULL pb forces to delete the search result set */ delete_search_result_set(NULL, (back_search_result_set **)sr); } - -int -ldbm_back_entry_release(Slapi_PBlock *pb, void *backend_info_ptr) -{ - backend *be; - ldbm_instance *inst; - - if (backend_info_ptr == NULL) - return 1; - - slapi_pblock_get(pb, SLAPI_BACKEND, &be); - inst = (ldbm_instance *)be->be_instance_info; - - if (((struct backentry *)backend_info_ptr)->ep_vlventry != NULL) { - /* This entry was created during a vlv search whose acl check failed. It needs to be - * freed here */ - slapi_entry_free(((struct backentry *)backend_info_ptr)->ep_vlventry); - ((struct backentry *)backend_info_ptr)->ep_vlventry = NULL; - } - CACHE_RETURN(&inst->inst_cache, (struct backentry **)&backend_info_ptr); - - return 0; -} diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h index 5d618a8..f461b5d 100644 --- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -472,8 +472,6 @@ int ldbm_back_ldbm2archive(Slapi_PBlock *pb); int ldbm_back_upgradedb(Slapi_PBlock *pb); int ldbm_back_dbverify(Slapi_PBlock *pb); int ldbm_back_next_search_entry(Slapi_PBlock *pb); -int ldbm_back_next_search_entry_ext(Slapi_PBlock *pb, int use_extension); -int ldbm_back_entry_release(Slapi_PBlock *pb, void *backend_info_ptr); void ldbm_back_search_results_release(void **search_results); int ldbm_back_init(Slapi_PBlock *pb); void ldbm_back_prev_search_results(Slapi_PBlock *pb); @@ -531,17 +529,6 @@ int indexfile_delete_all_keys(backend *be, char *type, back_txn *txn); int indexfile_primary_modifyall(backend *be, LDAPMod **mods_to_perform, char **indexes_to_update, back_txn *txn); /* - * bedse.c - */ -#if 0 -int bedse_init(void); -int bedse_search(Slapi_PBlock *pb); -struct dse_callback *bedse_register_callback(int operation, const Slapi_DN *base, int scope, const char *filter, int (*fn)(Slapi_PBlock *,Slapi_Entry *,Slapi_Entry *,int*,char*,void *), void *fn_arg); -void bedse_remove_callback(int operation, const Slapi_DN *base, int scope, const char *filter, int (*fn)(Slapi_PBlock *,Slapi_Entry *,Slapi_Entry *,int*,char*,void *)); -int bedse_add_index_entry(int argc, char **argv); -#endif - -/* * ldbm_search.c */ Slapi_Filter *create_onelevel_filter(Slapi_Filter *filter, const struct backentry *e, int managedsait, Slapi_Filter **fid2kids, Slapi_Filter **focref, Slapi_Filter **fand, Slapi_Filter **forr); diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c index 70ac608..65af5dc 100644 --- a/ldap/servers/slapd/back-ldbm/sort.c +++ b/ldap/servers/slapd/back-ldbm/sort.c @@ -406,14 +406,6 @@ err: return rc; } -#if 0 -static int attr_value_compare(struct berval *value_a, struct berval *value_b) -{ - /* return value_cmp(value_a,value_b,syntax,3); */ - return strcasecmp(value_a->bv_val, value_b->bv_val); -} -#endif - struct berval * attr_value_lowest(struct berval **values, value_compare_fn_type compare_fn) { diff --git a/ldap/servers/slapd/back-ldbm/vlv_key.c b/ldap/servers/slapd/back-ldbm/vlv_key.c index a6a06fb..cac81e7 100644 --- a/ldap/servers/slapd/back-ldbm/vlv_key.c +++ b/ldap/servers/slapd/back-ldbm/vlv_key.c @@ -41,17 +41,6 @@ vlv_key_delete(struct vlv_key **p) slapi_ch_free((void **)p); } -#if 0 -static void -vlv_key_copy(const struct vlv_key *p1,struct vlv_key *p2) -{ - p2->keymem= p1->keymem; - p2->key.data= slapi_ch_realloc(p2->key.data,p2->keymem); - strcpy(p2->key.data, p1->key.data); - p2->key.size= p1->key.size; -} -#endif - /* * Add an attribute value to the end of a composite key. */ diff --git a/ldap/servers/slapd/control.c b/ldap/servers/slapd/control.c index 4fd8473..9eabef2 100644 --- a/ldap/servers/slapd/control.c +++ b/ldap/servers/slapd/control.c @@ -617,47 +617,6 @@ loser: return return_value; } - -#if 0 -/* - * rbyrne: This is version of the above using the slapi_build_control_from_berval() - * I'll enable this afterwards. - * Build an allocated LDAPv3 control from a BerElement. - * Returns an LDAP error code. - */ -int -slapi_build_control( char *oid, BerElement *ber, - char iscritical, LDAPControl **ctrlp ) -{ - int rc = 0; - int return_value = LDAP_SUCCESS; - struct berval *bvp = NULL; - - PR_ASSERT( NULL != oid && NULL != ctrlp ); - - if ( NULL == ber ) { - bvp = NULL; - } else { - /* allocate struct berval with contents of the BER encoding */ - rc = ber_flatten( ber, &bvp ); - if ( -1 == rc ) { - return_value = LDAP_NO_MEMORY; - goto loser; - } - } - - return_value = slapi_build_control_from_berval( oid, bvp, iscritical, - ctrlp); - if ( bvp != NULL ) { - ldap_memfree(bvp); /* free container, but not contents */ - bvp = NULL; - } - -loser: - return return_value; -} -#endif - /* * Build an allocated LDAPv3 control from a berval. Returns an LDAP error code. */ diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 0c5585e..0f4f655 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -2300,14 +2300,11 @@ write_pid_file(void) static void set_shutdown(int sig __attribute__((unused))) { -/* don't log anything from a signal handler: + /* don't log anything from a signal handler: * you could be holding a lock when the signal was trapped. more * specifically, you could be holding the logfile lock (and deadlock * yourself). */ -#if 0 - slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon", "slapd got shutdown signal\n"); -#endif if (g_get_shutdown() == 0) { g_set_shutdown(SLAPI_SHUTDOWN_SIGNAL); } @@ -2323,14 +2320,11 @@ set_shutdown(int sig __attribute__((unused))) void slapd_do_nothing(int sig) { -/* don't log anything from a signal handler: + /* don't log anything from a signal handler: * you could be holding a lock when the signal was trapped. more * specifically, you could be holding the logfile lock (and deadlock * yourself). */ -#if 0 - slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon", "slapd got SIGUSR1\n"); -#endif (void)SIGNAL(SIGUSR1, slapd_do_nothing); #if 0 @@ -2348,14 +2342,11 @@ slapd_wait4child(int sig __attribute__((unused))) { WAITSTATUSTYPE status; -/* don't log anything from a signal handler: + /* don't log anything from a signal handler: * you could be holding a lock when the signal was trapped. more * specifically, you could be holding the logfile lock (and deadlock * yourself). */ -#if 0 - slapi_log_err(SLAPI_LOG_ARGS, "slapd_daemon", "listener: catching SIGCHLD\n"); -#endif #ifdef USE_WAITPID while (waitpid((pid_t)-1, 0, WAIT_FLAGS) > 0) #else /* USE_WAITPID */ diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 1cc30fc..774ee93 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -3177,13 +3177,6 @@ slapi_entry_add_rdn_values(Slapi_Entry *e) slapi_log_err(SLAPI_LOG_TRACE, "slapi_entry_add_rdn_values", "RDN value is not identical to entry value for type %s in entry %s\n", type, dn ? dn : ""); -#if 0 - /* - * This would be the right thing to do except that - * it breaks our own clients. - */ - rc = LDAP_TYPE_OR_VALUE_EXISTS; -#endif } /* exact same ava already present in entry, that's OK */ } diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c index c818bae..898417d 100644 --- a/ldap/servers/slapd/filter.c +++ b/ldap/servers/slapd/filter.c @@ -781,21 +781,6 @@ slapi_filter_free(struct slapi_filter *f, int recurse) slapi_ch_free((void **)&f); } -#if 0 -static void -filter_list_insert( struct slapi_filter **into, struct slapi_filter *from ) -{ - struct slapi_filter *f; - if (into == NULL || from == NULL) return; - if (*into != NULL) { - for (f = from; f->f_next != NULL; f = f->f_next); - f->f_next = *into; - } - *into = from; -} -#endif - - struct slapi_filter * slapi_filter_join(int ftype, struct slapi_filter *f1, struct slapi_filter *f2) { diff --git a/ldap/servers/slapd/getopt_ext.c b/ldap/servers/slapd/getopt_ext.c index 709963d..44f4cb7 100644 --- a/ldap/servers/slapd/getopt_ext.c +++ b/ldap/servers/slapd/getopt_ext.c @@ -36,15 +36,6 @@ _getopt_ext_init(int argc) return (0); } -#if 0 -static -int _getopt_ext_done() -{ - _getopt_ext_done_long = 1; - return(0); -} -#endif - static int _getopt_ext_find(int argc __attribute__((unused)), char **argv, diff --git a/ldap/servers/slapd/ldbmlinktest.c b/ldap/servers/slapd/ldbmlinktest.c index edbdf67..995dafc 100644 --- a/ldap/servers/slapd/ldbmlinktest.c +++ b/ldap/servers/slapd/ldbmlinktest.c @@ -11,11 +11,6 @@ #include #endif -#if 0 -int detached; -int error_logfp; -#endif - main() { ldbm_back_bind(); @@ -31,15 +26,3 @@ main() ldbm_back_init(); ldbm_back_close(); } - -#if 0 -slapi_access_allowed(){} -send_ldap_result(){} -slapi_op_abandoned(){} -be_issuffix(){} -slapi_pw_find(){} -send_ldap_search_entry(){} -slapi_pblock_get(){} -slapi_pblock_set(){} -slapi_acl_check_mods(){} -#endif diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index 3500108..f4f52b7 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -2432,9 +2432,6 @@ vslapd_log_error( buffer[sizeof(buffer) - 1] = '\0'; if (fp) -#if 0 - LOG_WRITE_NOW(fp, buffer, strlen(buffer), header_len, err); -#else do { int size = strlen(buffer); (err) = 0; @@ -2446,7 +2443,6 @@ vslapd_log_error( /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ PR_Sync(fp); } while (0); -#endif else /* stderr is always unbuffered */ fprintf(stderr, "%s", buffer); @@ -5058,15 +5054,6 @@ log_create_buffer(size_t sz) return lbi; } -#if 0 -/* for some reason, we never call this. */ -static void log_destroy_buffer(LogBufferInfo *lbi) -{ - slapi_ch_free((void *)&(lbi->top)); - slapi_ch_free((void *)&lbi); -} -#endif - /* Some notes about this function. It is written the way it is for performance reasons. diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index b50ebd4..19499f7 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -955,42 +955,6 @@ done: return result; } -#if 0 -/* defined but not used */ -/* - * Description: - * A first attempt at walking over the mapping tree and making sure things - * make sense. Right now it just makes sure that each parent node has a - * subtree that is the suffix of its children's subtrees. This function - * is called recursively. - * - * Arguments: - * The root node of the mapping tree. - * - * Returns: - * Nothing - it just prints warnings. This should probably change. - */ -static void -mapping_tree_node_validate(mapping_tree_node *node) -{ - mapping_tree_node *child_entry; - - /* Call this function for all of nodes children */ - for (child_entry = node->mtn_children; child_entry; child_entry = child_entry->mtn_brother) { - mapping_tree_node_validate(child_entry); - } - - if (node->mtn_parent) { - if (!slapi_sdn_issuffix(node->mtn_subtree, node->mtn_parent->mtn_subtree)) { - slapi_log_err(SLAPI_LOG_WARNING, "mapping_tree_node_validate", - "Invalid mapping tree. %s can not be a child of %s\n", - slapi_sdn_get_ndn(node->mtn_subtree), - slapi_sdn_get_ndn(node->mtn_parent->mtn_subtree)); - } - } -} -#endif - static void mtn_free_referral_in_node(mapping_tree_node *node) { diff --git a/ldap/servers/slapd/match.c b/ldap/servers/slapd/match.c index 3dbbf2b..2162136 100644 --- a/ldap/servers/slapd/match.c +++ b/ldap/servers/slapd/match.c @@ -163,15 +163,6 @@ _mr_alloc_new(struct matchingRuleList **mrl) return (0); } -#if 0 -static int -_mr_free(struct matchingRuleList **mrl /*, int freeEntry */) -{ - slapi_ch_free((void **)mrl); - return(0); -} -#endif - int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrule) { diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index a186dbd..bd66c94 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -43,9 +43,6 @@ /* Forward declarations */ static int modify_internal_pb(Slapi_PBlock *pb); static void op_shared_modify(Slapi_PBlock *pb, int pw_change, char *old_pw); -#if 0 /* not used */ -static void remove_mod (Slapi_Mods *smods, const char *type, Slapi_Mods *smod_unhashed); -#endif static int op_shared_allow_pw_change(Slapi_PBlock *pb, LDAPMod *mod, char **old_pw, Slapi_Mods *smods); static int hash_rootpw(LDAPMod **mods); static int valuearray_init_bervalarray_unhashed_only(struct berval **bvals, Slapi_Value ***cvals); @@ -1124,24 +1121,6 @@ valuearray_init_bervalarray_unhashed_only(struct berval **bvals, Slapi_Value *** return n; } -#if 0 /* not used */ -static void remove_mod (Slapi_Mods *smods, const char *type, Slapi_Mods *smod_unhashed) -{ - LDAPMod *mod; - Slapi_Mod smod; - - for (mod = slapi_mods_get_first_mod(smods); mod; mod = slapi_mods_get_next_mod(smods)) - { - if (strcasecmp (mod->mod_type, type) == 0) - { - slapi_mod_init_byval (&smod, mod); - slapi_mods_add_smod(smod_unhashed, &smod); - slapi_mods_remove (smods); - } - } -} -#endif - static int op_shared_allow_pw_change(Slapi_PBlock *pb, LDAPMod *mod, char **old_pw, Slapi_Mods *smods) { diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c index c0bc5dc..778b994 100644 --- a/ldap/servers/slapd/opshared.c +++ b/ldap/servers/slapd/opshared.c @@ -1124,6 +1124,7 @@ process_entry(Slapi_PBlock *pb, Slapi_Entry *e, int send_result) return 0; } + static void send_entry(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Operation *operation, char **attrs, int attrsonly, int *pnentries) { @@ -1150,151 +1151,6 @@ send_entry(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Operation *operation, char ** } } -#if 0 -/* Loops through search entries and sends them to the client. - * returns -1 on error, 0 if result packet was sent or 1 if - * result packet wasn't sent - */ -static int -iterate_with_lookahead(Slapi_PBlock *pb, Slapi_Backend *be, int send_result, int *pnentries) -{ - int rc; - int attrsonly; - int done = 0; - Slapi_Entry *e; - void *backend_info_ptr; - Slapi_Entry *next_e; - void *next_backend_info_ptr; - char **attrs = NULL; - int send_result_status = 0; - - slapi_pblock_get(pb, SLAPI_SEARCH_ATTRS, &attrs); - slapi_pblock_get(pb, SLAPI_SEARCH_ATTRSONLY, &attrsonly); - - /* setup for the loop */ - rc = be->be_next_search_entry_ext(pb, 1); - if (rc < 0) - { - /* - * Some exceptional condition occurred. Results - * have been sent, so we're finished. - */ - if (rc == SLAPI_FAIL_DISKFULL) - { - operation_out_of_disk_space(); - } - return -1; - } - - slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &next_e); - slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, &next_backend_info_ptr); - if (NULL == next_e) - { - /* no entries */ - done = 1; - } - - backend_info_ptr = NULL; - - /* Done setting up the loop, now here it comes */ - - while (!done) - { - /* Allow the backend to free the entry we just finished using */ - /* It is ok to call this when backend_info_ptr is NULL */ - be->be_entry_release(pb, backend_info_ptr); - e = next_e; - backend_info_ptr = next_backend_info_ptr; - - rc = be->be_next_search_entry_ext(pb, 1); - if (rc < 0) - { - /* - * Some exceptional condition occurred. Results - * have been sent, so we're finished. - */ - if (rc == SLAPI_FAIL_DISKFULL) - { - operation_out_of_disk_space(); - } - return -1; - } - else - { - slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY, &next_e); - slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_ENTRY_EXT, &next_backend_info_ptr); - if (next_e == NULL) - { - /* no more entries */ - done = 1; - } - } - - if (process_entry(pb, e, send_result)) - { - /* shouldn't send this entry */ - continue; - } - - /* - * It's a regular entry, or it's a referral and - * managedsait control is on. In either case, send the entry. - */ - if (done) - { - struct berval **urls = NULL; - /* Send the entry and the result at the same time */ - slapi_pblock_get(pb, SLAPI_SEARCH_REFERRALS, &urls); - rc = send_ldap_search_entry_ext(pb, e, NULL, attrs, attrsonly, 1, - (*pnentries)+1, urls); - if (rc == 1) - { - /* this means we didn't have access to the entry. Since the - * entry was not sent, we need to send the done packet. - */ - send_result_status = 1; - } - } - else - { - /* Send the entry */ - rc = send_ldap_search_entry(pb, e, NULL, attrs, - attrsonly); - } - switch (rc) - { - case 0: /* entry sent ok */ - (*pnentries)++; - slapi_pblock_set(pb, SLAPI_NENTRIES, pnentries); - break; - case 1: /* entry not sent */ - break; - case -1: /* connection closed */ - /* - * mark the operation as abandoned so the backend - * next entry function gets called again and has - * a chance to clean things up. - */ - operation->o_status = SLAPI_OP_STATUS_ABANDONED; - break; - } - } - - be->be_entry_release(pb, backend_info_ptr); - if (*pnentries == 0 || send_result_status) - { - /* We didn't send the result done message so the caller - * must send it */ - return 1; - } - else - { - /* The result message has been sent */ - return 0; - } -} -#endif - /* Loops through search entries and sends them to the client. * returns -1 on error or 1 if result packet wasn't sent. * This function never returns 0 because it doesn't send diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index faf8a69..3e369c6 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -794,12 +794,6 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value) } (*(IFP *)value) = pblock->pb_plugin->plg_next_search_entry_ext; break; - case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) { - return (-1); - } - (*(IFP *)value) = pblock->pb_plugin->plg_entry_release; - break; case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN: if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) { return (-1); @@ -2720,12 +2714,6 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value) } pblock->pb_plugin->plg_next_search_entry_ext = (IFP)value; break; - case SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN: - if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) { - return (-1); - } - pblock->pb_plugin->plg_entry_release = (IFP)value; - break; case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN: if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) { return (-1); diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index e6b48de..c4ad6f1 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -166,34 +166,6 @@ typedef struct entry_and_plugin static entry_and_plugin_t *dep_plugin_entries = NULL; /* for dependencies */ -#if 0 -static entry_and_plugin_t *plugin_entries = NULL; - -static void -add_plugin_entries() -{ - entry_and_plugin_t *ep = plugin_entries; - entry_and_plugin_t *deleteep = 0; - while (ep) - { - int plugin_actions = 0; - Slapi_PBlock newpb; - pblock_init(&newpb); - slapi_add_entry_internal_set_pb(&newpb, ep->e, NULL, - ep->plugin, plugin_actions); - slapi_pblock_set(&newpb, SLAPI_TARGET_DN, (void*)slapi_entry_get_dn_const(ep->e)); - slapi_pblock_set(&newpb, SLAPI_TARGET_SDN, (void*)slapi_entry_get_sdn_const(ep->e)); - slapi_add_internal_pb(&newpb); - deleteep = ep; - ep = ep->next; - slapi_ch_free((void**)&deleteep); - pblock_done(&newpb); - } - - plugin_entries = NULL; -} -#endif - static int plugin_is_critical(Slapi_Entry *plugin_entry) { @@ -3562,20 +3534,6 @@ plugin_config_cleanup(struct pluginconfig *config) ptd_cleanup(&config->plgc_excluded_bind_subtrees); } -#if 0 -static char* -plugin_config_action_to_string (int action) -{ - switch (action) - { - case PLGC_ON: return "on"; - case PLGC_OFF: return "off"; - case PLGC_UPTOPLUGIN: return "uptoplugin"; - default: return NULL; - } -} -#endif - static struct pluginconfig * plugin_get_config(struct slapdplugin *plugin) { @@ -3944,31 +3902,6 @@ default_plugin_init(void) plugin_set_default_access(&global_default_plg.plg_conf); } -#if 0 -static void trace_plugin_invocation (Slapi_DN *target_spec, PluginTargetData *ptd, - PRBool bindop, PRBool isroot, PRBool islocal, int invoked) -{ - int cookie, i = 0; - Slapi_DN *sdn; - - - slapi_log_err(SLAPI_LOG_ERR, "trace_plugin_invocation", - "Invocation parameters: target_spec = %s, bindop = %d, isroot=%d, islocal=%d\n" - "Plugin configuration: local_data=%d, remote_data=%d, anonymous_bind=%d, root_bind=%d\n", - slapi_sdn_get_ndn (target_spec), bindop, isroot, islocal, ptd->special_data[0], - ptd->special_data[1], ptd->special_data[2], ptd->special_data[3]); - - sdn = ptd_get_first_subtree (ptd, &cookie); - while (sdn) - { - slapi_log_err(SLAPI_LOG_ERR, "trace_plugin_invocation", "target_subtree%d: %s\n", i, slapi_sdn_get_ndn (sdn)); - sdn = ptd_get_next_subtree (ptd, &cookie); - } - - slapi_log_err(SLAPI_LOG_ERR, "trace_plugin_invocation", invoked ? "Plugin is invoked\n" : "Plugin is not invoked\n"); -} -#endif - /* functions to manipulate PluginTargetData type */ static void ptd_init(PluginTargetData *ptd) @@ -4006,16 +3939,6 @@ ptd_set_special_data(PluginTargetData *ptd, int type) ptd->special_data[type] = PR_TRUE; } -#if 0 -static void ptd_clear_special_data (PluginTargetData *ptd, int type) -{ - PR_ASSERT (ptd); - PR_ASSERT (type >= 0 && type < PLGC_DATA_MAX); - - ptd->special_data [type] = PR_FALSE; -} -#endif - static Slapi_DN * ptd_get_first_subtree(const PluginTargetData *ptd, int *cookie) { @@ -4041,16 +3964,6 @@ ptd_is_special_data_set(const PluginTargetData *ptd, int type) return ptd->special_data[type]; } -#if 0 -static Slapi_DN* ptd_delete_subtree (PluginTargetData *ptd, Slapi_DN *subtree) -{ - PR_ASSERT (ptd); - PR_ASSERT (subtree); - - return (Slapi_DN*)dl_delete (&ptd->subtrees, subtree, (CMPFN)slapi_sdn_compare, NULL); -} -#endif - int ptd_get_subtree_count(const PluginTargetData *ptd) { diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 3acc24f..2356738 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -1549,10 +1549,6 @@ int pagedresults_set_timelimit(Connection *conn, Operation *op, time_t timelimit int pagedresults_get_sizelimit(Connection *conn, Operation *op, int index); int pagedresults_set_sizelimit(Connection *conn, Operation *op, int sizelimit, int index); int pagedresults_cleanup(Connection *conn, int needlock); -#if 0 /* Stopped using it (#47347) */ -int pagedresults_check_or_set_processing(Connection *conn, int index); -int pagedresults_reset_processing(Connection *conn, int index); -#endif int pagedresults_is_timedout_nolock(Connection *conn); int pagedresults_reset_timedout_nolock(Connection *conn); int pagedresults_in_use_nolock(Connection *conn); diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index 2472cb4..b6c2c89 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -3256,8 +3256,8 @@ add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e) } slapi_mods_free(&smods); -#if 0 /* These 3 attributes are no need (or not able) to auto-fill. */ - /* + /* These 3 attributes are no need (or not able) to auto-fill. + * * shadowInactive - the number of days of inactivity allowed for the user. * Password Policy does not have the corresponding parameter. * @@ -3267,7 +3267,6 @@ add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e) * * shadowFlag - not currently in use. */ -#endif slapi_log_err(SLAPI_LOG_TRACE, "add_shadow_ext_password_attrs", "<=\n"); return rc; diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c index bf7e59f..0846444 100644 --- a/ldap/servers/slapd/schema.c +++ b/ldap/servers/slapd/schema.c @@ -3021,15 +3021,6 @@ clean_up_and_return: */ nextocp = tmpocp->oc_next; prevocp = tmpocp; - -#if 0 - - schema_create_errormsg( errorbuf, errorbufsize, - schema_errprefix_oc, tmpocp->oc_name, - "Cannot delete a standard object class" ); - rc = LDAP_UNWILLING_TO_PERFORM; - break; -#endif } } } diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 78f14c7..0c17f90 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -638,13 +638,6 @@ new_task(const char *rawdn, void *plugin) slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP, dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL); /* don't add entries under this one */ -#if 0 - /* don't know why, but this doesn't work. it makes the current add - * operation fail. :( - */ - slapi_config_register_callback(SLAPI_OPERATION_ADD, DSE_FLAG_PREOP, dn, - LDAP_SCOPE_SUBTREE, "(objectclass=*)", task_deny, NULL); -#endif PR_Unlock(task->task_log_lock);