| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804 |
- /** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
- /* ldbm_config.c - Handles configuration information that is global to all ldbm instances. */
- /* Required to get portable printf/scanf format macros */
- #ifdef HAVE_INTTYPES_H
- #include <inttypes.h>
- #else
- #error Need to define portable format macros such as PRIu64
- #endif /* HAVE_INTTYPES_H */
- #include "back-ldbm.h"
- #include "dblayer.h"
- /* Forward declarations */
- static int parse_ldbm_config_entry(struct ldbminfo *li, Slapi_Entry *e, config_info *config_array);
- /* Forward callback declarations */
- int ldbm_config_search_entry_callback(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
- int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
- static char *ldbm_skeleton_entries[] =
- {
- "dn:cn=config, cn=%s, cn=plugins, cn=config\n"
- "objectclass:top\n"
- "objectclass:extensibleObject\n"
- "cn:config\n",
- "dn:cn=monitor, cn=%s, cn=plugins, cn=config\n"
- "objectclass:top\n"
- "objectclass:extensibleObject\n"
- "cn:monitor\n",
- "dn:cn=database, cn=monitor, cn=%s, cn=plugins, cn=config\n"
- "objectclass:top\n"
- "objectclass:extensibleObject\n"
- "cn:database\n",
- ""
- };
- /* Used to add an array of entries, like the one above and
- * ldbm_instance_skeleton_entries in ldbm_instance_config.c, to the dse.
- * Returns 0 on success.
- */
- int ldbm_config_add_dse_entries(struct ldbminfo *li, char **entries, char *string1, char *string2, char *string3, int flags)
- {
- int x;
- Slapi_Entry *e;
- Slapi_PBlock *util_pb = NULL;
- int rc;
- int result;
- char entry_string[512];
- int dont_write_file = 0;
- char ebuf[BUFSIZ];
- if (flags & LDBM_INSTANCE_CONFIG_DONT_WRITE) {
- dont_write_file = 1;
- }
- for(x = 0; strlen(entries[x]) > 0; x++) {
- util_pb = slapi_pblock_new();
- PR_snprintf(entry_string, 512, entries[x], string1, string2, string3);
- e = slapi_str2entry(entry_string, 0);
- PR_snprintf(ebuf, sizeof(ebuf), slapi_entry_get_dn_const(e)); /* for logging */
- slapi_add_entry_internal_set_pb(util_pb, e, NULL, li->li_identity, 0);
- slapi_pblock_set(util_pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING,
- &dont_write_file);
- rc = slapi_add_internal_pb(util_pb);
- slapi_pblock_get(util_pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
- if (!rc && (result == LDAP_SUCCESS)) {
- LDAPDebug(LDAP_DEBUG_CONFIG, "Added database config entry [%s]\n",
- ebuf, 0, 0);
- } else if (result == LDAP_ALREADY_EXISTS) {
- LDAPDebug(LDAP_DEBUG_TRACE, "Database config entry [%s] already exists - skipping\n",
- ebuf, 0, 0);
- } else {
- LDAPDebug(LDAP_DEBUG_ANY, "Unable to add config entry [%s] to the DSE: %d %d\n",
- ebuf, result, rc);
- }
- slapi_pblock_destroy(util_pb);
- }
- return 0;
- }
- /* used to add a single entry, special case of above */
- int ldbm_config_add_dse_entry(struct ldbminfo *li, char *entry, int flags)
- {
- char *entries[] = { "%s", "" };
- return ldbm_config_add_dse_entries(li, entries, entry, NULL, NULL, flags);
- }
- /* Finds an entry in a config_info array with the given name. Returns
- * the entry on success and NULL when not found.
- */
- config_info *get_config_info(config_info *config_array, char *attr_name)
- {
- int x;
- for(x = 0; config_array[x].config_name != NULL; x++) {
- if (!strcasecmp(config_array[x].config_name, attr_name)) {
- return &(config_array[x]);
- }
- }
- return NULL;
- }
- /*------------------------------------------------------------------------
- * Get and set functions for ldbm and dblayer variables
- *----------------------------------------------------------------------*/
- static void *ldbm_config_lookthroughlimit_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)(li->li_lookthroughlimit));
- }
- static int ldbm_config_lookthroughlimit_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- /* Do whatever we can to make sure the data is ok. */
- if (apply) {
- li->li_lookthroughlimit = val;
- }
- return retval;
- }
- static void *ldbm_config_mode_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)(li->li_mode));
- }
- static int ldbm_config_mode_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- /* Do whatever we can to make sure the data is ok. */
- if (apply) {
- li->li_mode = val;
- }
- return retval;
- }
- static void *ldbm_config_allidsthreshold_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)(li->li_allidsthreshold));
- }
- static int ldbm_config_allidsthreshold_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- /* Do whatever we can to make sure the data is ok. */
- /* Catch attempts to configure a stupidly low allidsthreshold */
- if (val < 100) {
- val = 100;
- }
- if (apply) {
- li->li_allidsthreshold = val;
- }
- return retval;
- }
- static void *ldbm_config_directory_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- /* Remember get functions of type string need to return
- * alloced memory. */
- return (void *) slapi_ch_strdup(li->li_new_directory);
- }
- static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- char *val = (char *) value;
- char tmpbuf[BUFSIZ];
- errorbuf[0] = '\0';
- if (!apply) {
- /* we should really do some error checking here. */
- return retval;
- }
- if (CONFIG_PHASE_RUNNING == phase) {
- slapi_ch_free((void **) &(li->li_new_directory));
- li->li_new_directory = rel2abspath(val); /* normalize the path;
- strdup'ed in rel2abspath */
- LDAPDebug(LDAP_DEBUG_ANY, "New db directory location will not take affect until the server is restarted\n", 0, 0, 0);
- } else {
- slapi_ch_free((void **) &(li->li_new_directory));
- slapi_ch_free((void **) &(li->li_directory));
- if (NULL == val || '\0' == *val) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: db directory is not set; check %s in the db config: %s\n",
- CONFIG_DIRECTORY, CONFIG_LDBM_DN, 0);
- retval = LDAP_PARAM_ERROR;
- } else {
- if (0 == strcmp(val, "get default")) {
- /* We use this funky "get default" string for the caller to
- * tell us that it has no idea what the db directory should
- * be. This code figures it out be reading "cn=config,cn=ldbm
- * database,cn=plugins,cn=config" entry. */
- Slapi_PBlock *search_pb;
- Slapi_Entry **entries = NULL;
- Slapi_Attr *attr = NULL;
- Slapi_Value *v = NULL;
- const char *s = NULL;
- int res;
-
- search_pb = slapi_pblock_new();
- slapi_search_internal_set_pb(search_pb, CONFIG_LDBM_DN,
- LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, NULL, NULL,
- li->li_identity, 0);
- slapi_search_internal_pb(search_pb);
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
-
- if (res != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read %s\n",
- CONFIG_LDBM_DN, 0, 0);
- retval = res;
- goto done;
- }
-
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
- if (NULL == entries) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read %s\n",
- CONFIG_LDBM_DN, 0, 0);
- retval = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
- res = slapi_entry_attr_find(entries[0], "nsslapd-directory", &attr);
- if (res != 0 || attr == NULL) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
- CONFIG_LDBM_DN, 0, 0);
- retval = LDAP_OPERATIONS_ERROR;
- goto done;
- }
-
- if ( slapi_attr_first_value(attr,&v) != 0
- || ( NULL == v )
- || ( NULL == ( s = slapi_value_get_string( v )))) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n",
- CONFIG_LDBM_DN, 0, 0);
- retval = LDAP_OPERATIONS_ERROR;
- goto done;
- }
- slapi_pblock_destroy(search_pb);
- if (NULL == s || '\0' == s || 0 == PL_strcmp(s, "(null)")) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: db directory is not set; check %s in the db config: %s\n",
- CONFIG_DIRECTORY, CONFIG_LDBM_DN, 0);
- retval = LDAP_PARAM_ERROR;
- goto done;
- }
- PR_snprintf(tmpbuf, BUFSIZ, "%s", s);
- val = tmpbuf;
- }
- li->li_new_directory = rel2abspath(val); /* normalize the path;
- strdup'ed in
- rel2abspath */
- li->li_directory = rel2abspath(val); /* ditto */
- }
- }
- done:
- return retval;
- }
- static void *ldbm_config_dbcachesize_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) (li->li_new_dbcachesize);
- }
- static int ldbm_config_dbcachesize_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
- if (apply) {
- /* Stop the user configuring a stupidly small cache */
- /* min: 8KB (page size) * def thrd cnts (threadnumber==20). */
- #define DBDEFMINSIZ 500000
- if (val < DBDEFMINSIZ) {
- LDAPDebug( LDAP_DEBUG_ANY,"WARNING: cache too small, increasing to %dK bytes\n", DBDEFMINSIZ/1000, 0, 0);
- val = DBDEFMINSIZ;
- }
-
- if (CONFIG_PHASE_RUNNING == phase) {
- li->li_new_dbcachesize = val;
- LDAPDebug(LDAP_DEBUG_ANY, "New db cache size will not take affect until the server is restarted\n", 0, 0, 0);
- } else {
- li->li_new_dbcachesize = val;
- li->li_dbcachesize = val;
- }
-
- }
-
- return retval;
- }
- static void *ldbm_config_maxpassbeforemerge_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)(li->li_maxpassbeforemerge));
- }
- static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- if (val < 0) {
- LDAPDebug( LDAP_DEBUG_ANY,"WARNING: maxpassbeforemerge will not take negative value\n", 0, 0, 0);
- val = 100;
- }
-
- li->li_maxpassbeforemerge = val;
- }
- return retval;
- }
- static void *ldbm_config_dbncache_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)(li->li_new_dbncache));
- }
- static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- if (val < 0) {
- LDAPDebug( LDAP_DEBUG_ANY,"WARNING: ncache will not take negative value\n", 0, 0, 0);
- val = 0;
- }
-
- if (CONFIG_PHASE_RUNNING == phase) {
- li->li_new_dbncache = val;
- LDAPDebug(LDAP_DEBUG_ANY, "New db ncache will not take affect until the server is restarted\n", 0, 0, 0);
- } else {
- li->li_new_dbncache = val;
- li->li_dbncache = val;
- }
-
- }
-
- return retval;
- }
- static void *ldbm_config_db_logdirectory_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- /* Remember get functions of type string need to return
- * alloced memory. */
- /* if dblayer_log_directory is set to a string different from ""
- * then it has been set, return this variable
- * otherwise it is set to default, use the instance home directory
- */
- if (strlen(li->li_dblayer_private->dblayer_log_directory) > 0)
- return (void *) slapi_ch_strdup(li->li_dblayer_private->dblayer_log_directory);
- else
- return (void *) slapi_ch_strdup(li->li_new_directory);
- }
- static int ldbm_config_db_logdirectory_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- char *val = (char *) value;
-
- if (apply) {
- slapi_ch_free((void **) &(li->li_dblayer_private->dblayer_log_directory));
- li->li_dblayer_private->dblayer_log_directory = slapi_ch_strdup(val);
- }
-
- return retval;
- }
- static void *ldbm_config_db_durable_transactions_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_durable_transactions);
- }
- static int ldbm_config_db_durable_transactions_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_durable_transactions = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_lockdown_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lockdown);
- }
- static int ldbm_config_db_lockdown_set(
- void *arg,
- void *value,
- char *errorbuf,
- int phase,
- int apply
- )
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- if (apply) {
- li->li_dblayer_private->dblayer_lockdown = val;
- }
- return retval;
- }
- static void *ldbm_config_db_circular_logging_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_circular_logging);
- }
- static int ldbm_config_db_circular_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_circular_logging = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_transaction_logging_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_enable_transactions);
- }
- static int ldbm_config_db_transaction_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_enable_transactions = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_logbuf_size_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) li->li_dblayer_private->dblayer_logbuf_size;
- }
- static int ldbm_config_db_logbuf_size_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
-
- if (apply) {
- li->li_dblayer_private->dblayer_logbuf_size = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_checkpoint_interval_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_checkpoint_interval);
- }
- static int ldbm_config_db_checkpoint_interval_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_checkpoint_interval = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_page_size_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) li->li_dblayer_private->dblayer_page_size;
- }
- static int ldbm_config_db_page_size_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
-
- if (apply) {
- li->li_dblayer_private->dblayer_page_size = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_index_page_size_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) li->li_dblayer_private->dblayer_index_page_size;
- }
- static int ldbm_config_db_index_page_size_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
-
- if (apply) {
- li->li_dblayer_private->dblayer_index_page_size = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_idl_divisor_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_idl_divisor);
- }
- static int ldbm_config_db_idl_divisor_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_idl_divisor = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_logfile_size_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) li->li_dblayer_private->dblayer_logfile_size;
- }
- static int ldbm_config_db_logfile_size_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
-
- if (apply) {
- li->li_dblayer_private->dblayer_logfile_size = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_spin_count_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_spin_count);
- }
- static int ldbm_config_db_spin_count_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_spin_count = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_trickle_percentage_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_trickle_percentage);
- }
- static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (val < 0 || val > 100) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", errorbuf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
-
- if (apply) {
- li->li_dblayer_private->dblayer_trickle_percentage = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_verbose_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_verbose);
- }
- static int ldbm_config_db_verbose_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_verbose = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_debug_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_debug);
- }
- static int ldbm_config_db_debug_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_debug = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_named_regions_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_named_regions);
- }
- static int ldbm_config_db_named_regions_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_named_regions = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_private_mem_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_mem);
- }
- static int ldbm_config_db_private_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_private_mem = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_private_import_mem_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_import_mem);
- }
- static int ldbm_config_db_private_import_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_private_import_mem = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_shm_key_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) li->li_dblayer_private->dblayer_shm_key;
- }
- static int ldbm_config_db_shm_key_set(
- void *arg,
- void *value,
- char *errorbuf,
- int phase,
- int apply
- )
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- if (apply) {
- li->li_dblayer_private->dblayer_shm_key = val;
- }
- return retval;
- }
- static void *ldbm_config_db_lock_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lock_config);
- }
- static int ldbm_config_db_lock_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- size_t val = (size_t) value;
- if (apply) {
- if (CONFIG_PHASE_RUNNING == phase) {
- li->li_dblayer_private->dblayer_lock_config = val;
- LDAPDebug(LDAP_DEBUG_ANY, "New db cache size will not take affect until the server is restarted\n", 0, 0, 0);
- } else {
- li->li_dblayer_private->dblayer_lock_config = val;
- }
-
- }
- return retval;
- }
- static void *ldbm_config_db_cache_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_cache_config);
- }
- static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->dblayer_cache_config = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_debug_checkpointing_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- return (void *) ((uintptr_t)li->li_dblayer_private->db_debug_checkpointing);
- }
- static int ldbm_config_db_debug_checkpointing_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- li->li_dblayer_private->db_debug_checkpointing = val;
- }
-
- return retval;
- }
- static void *ldbm_config_db_home_directory_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- /* Remember get functions of type string need to return
- * alloced memory. */
- return (void *) slapi_ch_strdup(li->li_dblayer_private->dblayer_dbhome_directory);
- }
- static int ldbm_config_db_home_directory_set(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- char *val = (char *) value;
-
- if (apply) {
- slapi_ch_free((void **) &(li->li_dblayer_private->dblayer_dbhome_directory));
- li->li_dblayer_private->dblayer_dbhome_directory = slapi_ch_strdup(val);
- }
-
- return retval;
- }
- static void *ldbm_config_import_cache_autosize_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)((uintptr_t)(li->li_import_cache_autosize));
- }
- static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if (apply)
- li->li_import_cache_autosize = (int)((uintptr_t)value);
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_cache_autosize_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)((uintptr_t)(li->li_cache_autosize));
- }
- static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if (apply)
- li->li_cache_autosize = (int)((uintptr_t)value);
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_cache_autosize_split_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)((uintptr_t)(li->li_cache_autosize_split));
- }
- static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if (apply)
- li->li_cache_autosize_split = (int)((uintptr_t)value);
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_import_cachesize_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- return (void *)(li->li_import_cachesize);
- }
- static int ldbm_config_import_cachesize_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if (apply)
- li->li_import_cachesize = (size_t)value;
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_index_buffer_size_get(void *arg)
- {
- return (void *)import_get_index_buffer_size();
- }
- static int ldbm_config_index_buffer_size_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- if (apply)
- import_configure_index_buffer_size((size_t)value);
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_idl_get_idl_new(void *arg)
- {
- if (idl_get_idl_new())
- return slapi_ch_strdup("new");
- else
- return slapi_ch_strdup("old");
- }
- static int ldbm_config_idl_set_tune(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- if (!strcasecmp("new", value))
- idl_set_tune(4096);
- else
- idl_set_tune(0);
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_serial_lock_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)li->li_fat_lock);
- }
- static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- if (apply) {
- li->li_fat_lock = (int) ((uintptr_t)value);
- }
-
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_legacy_errcode_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)li->li_legacy_errcode);
- }
- static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
-
- if (apply) {
- li->li_legacy_errcode = (int) ((uintptr_t)value);
- }
-
- return LDAP_SUCCESS;
- }
- static int
- ldbm_config_set_bypass_filter_test(void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if (apply) {
- char *myvalue = (char *)value;
- if (0 == strcasecmp(myvalue, "on")) {
- li->li_filter_bypass = 1;
- li->li_filter_bypass_check = 0;
- } else if (0 == strcasecmp(myvalue, "verify")) {
- li->li_filter_bypass = 1;
- li->li_filter_bypass_check = 1;
- } else {
- li->li_filter_bypass = 0;
- li->li_filter_bypass_check = 0;
- }
- }
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_get_bypass_filter_test(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- char *retstr = NULL;
- if (li->li_filter_bypass) {
- if (li->li_filter_bypass_check) {
- /* meaningful only if is bypass filter test called */
- retstr = slapi_ch_strdup("verify");
- } else {
- retstr = slapi_ch_strdup("on");
- }
- } else {
- retstr = slapi_ch_strdup("off");
- }
- return (void *)retstr;
- }
- static int ldbm_config_set_use_vlv_index(void *arg, void *value, char *errorbuf, int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int val = (int) ((uintptr_t)value);
-
- if (apply) {
- if (val) {
- li->li_use_vlv = 1;
- } else {
- li->li_use_vlv = 0;
- }
- }
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_get_use_vlv_index(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)li->li_use_vlv);
- }
- static int
- ldbm_config_exclude_from_export_set( void *arg, void *value, char *errorbuf,
- int phase, int apply)
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- if ( apply ) {
- if ( NULL != li->li_attrs_to_exclude_from_export ) {
- charray_free( li->li_attrs_to_exclude_from_export );
- li->li_attrs_to_exclude_from_export = NULL;
- }
-
- if ( NULL != value ) {
- char *dupvalue = slapi_ch_strdup( value );
- li->li_attrs_to_exclude_from_export = str2charray( dupvalue, " " );
- slapi_ch_free((void**)&dupvalue);
- }
- }
-
- return LDAP_SUCCESS;
- }
- static void *
- ldbm_config_exclude_from_export_get( void *arg )
- {
- struct ldbminfo *li = (struct ldbminfo *)arg;
- char *p, *retstr = NULL;
- size_t len = 0;
-
- if ( NULL != li->li_attrs_to_exclude_from_export &&
- NULL != li->li_attrs_to_exclude_from_export[0] ) {
- int i;
-
- for ( i = 0; li->li_attrs_to_exclude_from_export[i] != NULL; ++i ) {
- len += strlen( li->li_attrs_to_exclude_from_export[i] ) + 1;
- }
- p = retstr = slapi_ch_malloc( len );
- for ( i = 0; li->li_attrs_to_exclude_from_export[i] != NULL; ++i ) {
- if ( i > 0 ) {
- *p++ = ' ';
- }
- strcpy( p, li->li_attrs_to_exclude_from_export[i] );
- p += strlen( p );
- }
- *p = '\0';
- } else {
- retstr = slapi_ch_strdup( "" );
- }
-
- return (void *)retstr;
- }
- static void *ldbm_config_db_tx_max_get(void *arg)
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_tx_max);
- }
- static int ldbm_config_db_tx_max_set(
- void *arg,
- void *value,
- char *errorbuf,
- int phase,
- int apply
- )
- {
- struct ldbminfo *li = (struct ldbminfo *) arg;
- int retval = LDAP_SUCCESS;
- int val = (int) ((uintptr_t)value);
- if (apply) {
- li->li_dblayer_private->dblayer_tx_max = val;
- }
- return retval;
- }
- /*------------------------------------------------------------------------
- * Configuration array for ldbm and dblayer variables
- *----------------------------------------------------------------------*/
- static config_info ldbm_config[] = {
- {CONFIG_LOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_lookthroughlimit_get, &ldbm_config_lookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE|CONFIG_FLAG_SKIP_DEFAULT_SETTING},
- {CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, "10000000", &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0},
-
- /* dblayer config attributes */
- {CONFIG_DB_LOGDIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_logdirectory_get, &ldbm_config_db_logdirectory_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_DURABLE_TRANSACTIONS, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_durable_transactions_get, &ldbm_config_db_durable_transactions_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_CIRCULAR_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_circular_logging_get, &ldbm_config_db_circular_logging_set, 0},
- {CONFIG_DB_TRANSACTION_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_transaction_logging_get, &ldbm_config_db_transaction_logging_set, 0},
- {CONFIG_DB_CHECKPOINT_INTERVAL, CONFIG_TYPE_INT, "60", &ldbm_config_db_checkpoint_interval_get, &ldbm_config_db_checkpoint_interval_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_TRANSACTION_BATCH, CONFIG_TYPE_INT, "0", &dblayer_get_batch_transactions, &dblayer_set_batch_transactions, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_LOGBUF_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logbuf_size_get, &ldbm_config_db_logbuf_size_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0},
- {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0},
- {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0},
- {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0},
- {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0},
- {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0},
- {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0},
- {CONFIG_DB_DEBUG, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_debug_get, &ldbm_config_db_debug_set, 0},
- {CONFIG_DB_NAMED_REGIONS, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_named_regions_get, &ldbm_config_db_named_regions_set, 0},
- {CONFIG_DB_LOCK, CONFIG_TYPE_INT, "10000", &ldbm_config_db_lock_get, &ldbm_config_db_lock_set, 0},
- {CONFIG_DB_PRIVATE_MEM, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_private_mem_get, &ldbm_config_db_private_mem_set, 0},
- {CONFIG_DB_PRIVATE_IMPORT_MEM, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_private_import_mem_get, &ldbm_config_db_private_import_mem_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_SHM_KEY, CONFIG_TYPE_LONG, "389389", &ldbm_config_db_shm_key_get, &ldbm_config_db_shm_key_set, 0},
- {CONFIG_DB_CACHE, CONFIG_TYPE_INT, "0", &ldbm_config_db_cache_get, &ldbm_config_db_cache_set, 0},
- {CONFIG_DB_DEBUG_CHECKPOINTING, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_debug_checkpointing_get, &ldbm_config_db_debug_checkpointing_set, 0},
- {CONFIG_DB_HOME_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_home_directory_get, &ldbm_config_db_home_directory_set, 0},
- {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "0", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, 0},
- {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0},
- {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0},
- {CONFIG_INDEX_BUFFER_SIZE, CONFIG_TYPE_INT, "0", &ldbm_config_index_buffer_size_get, &ldbm_config_index_buffer_size_set, 0},
- {CONFIG_EXCLUDE_FROM_EXPORT, CONFIG_TYPE_STRING,
- CONFIG_EXCLUDE_FROM_EXPORT_DEFAULT_VALUE,
- &ldbm_config_exclude_from_export_get,
- &ldbm_config_exclude_from_export_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_DB_TX_MAX, CONFIG_TYPE_INT, "200", &ldbm_config_db_tx_max_get, &ldbm_config_db_tx_max_set, 0},
- {CONFIG_SERIAL_LOCK, CONFIG_TYPE_ONOFF, "on", &ldbm_config_serial_lock_get, &ldbm_config_serial_lock_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE},
- {CONFIG_USE_LEGACY_ERRORCODE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_legacy_errcode_get, &ldbm_config_legacy_errcode_set, 0},
- {NULL, 0, NULL, NULL, NULL, 0}
- };
- void ldbm_config_setup_default(struct ldbminfo *li)
- {
- config_info *config;
- char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
-
- for (config = ldbm_config; config->config_name != NULL; config++) {
- ldbm_config_set((void *)li, config->config_name, ldbm_config, NULL /* use default */, err_buf, CONFIG_PHASE_INITIALIZATION, 1 /* apply */);
- }
- }
- void
- ldbm_config_read_instance_entries(struct ldbminfo *li, const char *backend_type)
- {
- Slapi_PBlock *tmp_pb;
- char basedn[BUFSIZ];
- Slapi_Entry **entries = NULL;
- /* Construct the base dn of the subtree that holds the instance entries. */
- PR_snprintf(basedn, BUFSIZ, "cn=%s, cn=plugins, cn=config", backend_type);
- /* Do a search of the subtree containing the instance entries */
- tmp_pb = slapi_pblock_new();
- slapi_search_internal_set_pb(tmp_pb, basedn, LDAP_SCOPE_SUBTREE, "(objectclass=nsBackendInstance)", NULL, 0, NULL, NULL, li->li_identity, 0);
- slapi_search_internal_pb (tmp_pb);
- slapi_pblock_get(tmp_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
- if (entries!=NULL) {
- int i;
- for (i=0; entries[i]!=NULL; i++) {
- ldbm_instance_add_instance_entry_callback(NULL, entries[i], NULL, NULL, NULL, li);
- }
- }
- slapi_free_search_results_internal(tmp_pb);
- slapi_pblock_destroy(tmp_pb);
- }
- /* Reads in any config information held in the dse for the ldbm plugin.
- * Creates dse entries used to configure the ldbm plugin and dblayer
- * if they don't already exist. Registers dse callback functions to
- * maintain those dse entries. Returns 0 on success.
- */
- int ldbm_config_load_dse_info(struct ldbminfo *li)
- {
- Slapi_PBlock *search_pb;
- Slapi_Entry **entries = NULL;
- int res;
- char dn[BUFSIZ];
- /* We try to read the entry
- * cn=config, cn=ldbm database, cn=plugins, cn=config. If the entry is
- * there, then we process the config information it stores.
- */
- PR_snprintf(dn, BUFSIZ, "cn=config, cn=%s, cn=plugins, cn=config",
- li->li_plugin->plg_name);
- search_pb = slapi_pblock_new();
- slapi_search_internal_set_pb(search_pb, dn, LDAP_SCOPE_BASE,
- "objectclass=*", NULL, 0, NULL, NULL, li->li_identity, 0);
- slapi_search_internal_pb (search_pb);
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
- if (LDAP_NO_SUCH_OBJECT == res) {
- /* Add skeleten dse entries for the ldbm plugin */
- ldbm_config_add_dse_entries(li, ldbm_skeleton_entries,
- li->li_plugin->plg_name, NULL, NULL, 0);
- } else if (res != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error accessing the ldbm config DSE\n",
- 0, 0, 0);
- return 1;
- } else {
- /* Need to parse the configuration information for the ldbm
- * plugin that is held in the DSE. */
- slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
- &entries);
- if (NULL == entries || entries[0] == NULL) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error accessing the ldbm config DSE\n",
- 0, 0, 0);
- return 1;
- }
- if (0 != parse_ldbm_config_entry(li, entries[0], ldbm_config)) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error parsing the ldbm config DSE\n",
- 0, 0, 0);
- return 1;
- }
- }
- if (search_pb) {
- slapi_free_search_results_internal(search_pb);
- slapi_pblock_destroy(search_pb);
- }
-
- /* Find all the instance entries and create a Slapi_Backend and an
- * ldbm_instance for each */
- ldbm_config_read_instance_entries(li, li->li_plugin->plg_name);
- /* setup the dse callback functions for the ldbm backend config entry */
- PR_snprintf(dn, BUFSIZ, "cn=config, cn=%s, cn=plugins, cn=config",
- li->li_plugin->plg_name);
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_config_search_entry_callback,
- (void *) li);
- slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_config_modify_entry_callback,
- (void *) li);
- slapi_config_register_callback(DSE_OPERATION_WRITE, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_config_search_entry_callback,
- (void *) li);
- /* setup the dse callback functions for the ldbm backend monitor entry */
- PR_snprintf(dn, BUFSIZ, "cn=monitor, cn=%s, cn=plugins, cn=config",
- li->li_plugin->plg_name);
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_back_monitor_search,
- (void *)li);
- /* And the ldbm backend database monitor entry */
- PR_snprintf(dn, BUFSIZ, "cn=database, cn=monitor, cn=%s, cn=plugins, cn=config",
- li->li_plugin->plg_name);
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_back_dbmonitor_search,
- (void *)li);
- /* setup the dse callback functions for the ldbm backend instance
- * entries */
- PR_snprintf(dn, BUFSIZ, "cn=%s, cn=plugins, cn=config", li->li_plugin->plg_name);
- slapi_config_register_callback(SLAPI_OPERATION_ADD, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_SUBTREE, "(objectclass=nsBackendInstance)",
- ldbm_instance_add_instance_entry_callback, (void *) li);
- slapi_config_register_callback(SLAPI_OPERATION_ADD, DSE_FLAG_POSTOP, dn,
- LDAP_SCOPE_SUBTREE, "(objectclass=nsBackendInstance)",
- ldbm_instance_postadd_instance_entry_callback, (void *) li);
- slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_SUBTREE, "(objectclass=nsBackendInstance)",
- ldbm_instance_delete_instance_entry_callback, (void *) li);
- slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_POSTOP, dn,
- LDAP_SCOPE_SUBTREE, "(objectclass=nsBackendInstance)",
- ldbm_instance_post_delete_instance_entry_callback, (void *) li);
- return 0;
- }
- /* Utility function used in creating config entries. Using the
- * config_info, this function gets info and formats in the correct
- * way.
- * buf is char[BUFSIZ]
- */
- void ldbm_config_get(void *arg, config_info *config, char *buf)
- {
- char *tmp_string;
- size_t val = 0;
-
- if (config == NULL) {
- buf[0] = '\0';
- }
-
- switch(config->config_type) {
- case CONFIG_TYPE_INT:
- sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg)));
- break;
- case CONFIG_TYPE_INT_OCTAL:
- sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg)));
- break;
- case CONFIG_TYPE_LONG:
- sprintf(buf, "%ld", (long) config->config_get_fn(arg));
- break;
- case CONFIG_TYPE_SIZE_T:
- val = (size_t) config->config_get_fn(arg);
- sprintf(buf, "%" PRIuPTR, val);
- break;
- case CONFIG_TYPE_STRING:
- /* Remember the get function for strings returns memory
- * that must be freed. */
- tmp_string = (char *) config->config_get_fn(arg);
- PR_snprintf(buf, BUFSIZ, "%s", (char *) tmp_string);
- slapi_ch_free((void **)&tmp_string);
- break;
- case CONFIG_TYPE_ONOFF:
- if ((int) ((uintptr_t)config->config_get_fn(arg))) {
- sprintf(buf, "on");
- } else {
- sprintf(buf, "off");
- }
- break;
- }
- }
- /*
- * Returns:
- * SLAPI_DSE_CALLBACK_ERROR on failure
- * SLAPI_DSE_CALLBACK_OK on success
- */
- int ldbm_config_search_entry_callback(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg)
- {
- char buf[BUFSIZ];
- struct berval *vals[2];
- struct berval val;
- struct ldbminfo *li= (struct ldbminfo *) arg;
- config_info *config;
-
- vals[0] = &val;
- vals[1] = NULL;
-
- returntext[0] = '\0';
-
- PR_Lock(li->li_config_mutex);
-
- for(config = ldbm_config; config->config_name != NULL; config++) {
- /* Go through the ldbm_config table and fill in the entry. */
- if (!(config->config_flags & (CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_PREVIOUSLY_SET))) {
- /* This config option shouldn't be shown */
- continue;
- }
-
- ldbm_config_get((void *) li, config, buf);
-
- val.bv_val = buf;
- val.bv_len = strlen(buf);
- slapi_entry_attr_replace(e, config->config_name, vals);
- }
-
- PR_Unlock(li->li_config_mutex);
- *returncode = LDAP_SUCCESS;
- return SLAPI_DSE_CALLBACK_OK;
- }
- int ldbm_config_ignored_attr(char *attr_name)
- {
- /* These are the names of attributes that are in the
- * config entries but are not config attributes. */
- if (!strcasecmp("objectclass", attr_name) ||
- !strcasecmp("cn", attr_name) ||
- !strcasecmp("creatorsname", attr_name) ||
- !strcasecmp("modifiersname", attr_name) ||
- !strcasecmp("createtimestamp", attr_name) ||
- !strcasecmp("numsubordinates", attr_name) ||
- !strcasecmp("modifytimestamp", attr_name)) {
- return 1;
- } else {
- return 0;
- }
- }
- /* Returns LDAP_SUCCESS on success */
- int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struct berval *bval, char *err_buf, int phase, int apply_mod)
- {
- config_info *config;
- int use_default;
- int int_val;
- long long_val;
- size_t sz_val;
- PRInt64 llval;
- int maxint = (int)(((unsigned int)~0)>>1);
- int minint = ~maxint;
- PRInt64 llmaxint;
- PRInt64 llminint;
- int err = 0;
- char *str_val;
- int retval = 0;
- LL_I2L(llmaxint, maxint);
- LL_I2L(llminint, minint);
- config = get_config_info(config_array, attr_name);
- if (NULL == config) {
- LDAPDebug(LDAP_DEBUG_CONFIG, "Unknown config attribute %s\n", attr_name, 0, 0);
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown config attribute %s\n", attr_name);
- return LDAP_SUCCESS; /* Ignore unknown attributes */
- }
- /* Some config attrs can't be changed while the server is running. */
- if (phase == CONFIG_PHASE_RUNNING &&
- !(config->config_flags & CONFIG_FLAG_ALLOW_RUNNING_CHANGE)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "%s can't be modified while the server is running.\n", attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
-
- /* If the config phase is initialization or if bval is NULL, we will use
- * the default value for the attribute. */
- if (CONFIG_PHASE_INITIALIZATION == phase || NULL == bval) {
- if (CONFIG_FLAG_SKIP_DEFAULT_SETTING & config->config_flags) {
- return LDAP_SUCCESS; /* Skipping the default config setting */
- }
- use_default = 1;
- } else {
- use_default = 0;
-
- /* Since we are setting the value for the config attribute, we
- * need to turn on the CONFIG_FLAG_PREVIOUSLY_SET flag to make
- * sure this attribute is shown. */
- config->config_flags |= CONFIG_FLAG_PREVIOUSLY_SET;
- }
-
- switch(config->config_type) {
- case CONFIG_TYPE_INT:
- if (use_default) {
- str_val = config->config_default_value;
- } else {
- str_val = bval->bv_val;
- }
- /* get the value as a 64 bit value */
- llval = db_atoi(str_val, &err);
- /* check for parsing error (e.g. not a number) */
- if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for overflow */
- } else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
- str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for underflow */
- } else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
- str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
- /* convert 64 bit value to 32 bit value */
- LL_L2I(int_val, llval);
- retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
- break;
- case CONFIG_TYPE_INT_OCTAL:
- if (use_default) {
- int_val = (int) strtol(config->config_default_value, NULL, 8);
- } else {
- int_val = (int) strtol((char *)bval->bv_val, NULL, 8);
- }
- retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
- break;
- case CONFIG_TYPE_LONG:
- if (use_default) {
- str_val = config->config_default_value;
- } else {
- str_val = bval->bv_val;
- }
- /* get the value as a 64 bit value */
- llval = db_atoi(str_val, &err);
- /* check for parsing error (e.g. not a number) */
- if (err) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for overflow */
- } else if (LL_CMP(llval, >, llmaxint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n",
- str_val, attr_name, maxint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for underflow */
- } else if (LL_CMP(llval, <, llminint)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n",
- str_val, attr_name, minint);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
- /* convert 64 bit value to 32 bit value */
- LL_L2I(long_val, llval);
- retval = config->config_set_fn(arg, (void *) long_val, err_buf, phase, apply_mod);
- break;
- case CONFIG_TYPE_SIZE_T:
- if (use_default) {
- str_val = config->config_default_value;
- } else {
- str_val = bval->bv_val;
- }
- /* get the value as a size_t value */
- sz_val = db_strtoul(str_val, &err);
- /* check for parsing error (e.g. not a number) */
- if (err == EINVAL) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- /* check for overflow */
- } else if (err == ERANGE) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is outside the range of representable values\n",
- str_val, attr_name);
- LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0);
- return LDAP_UNWILLING_TO_PERFORM;
- }
- retval = config->config_set_fn(arg, (void *) sz_val, err_buf, phase, apply_mod);
- break;
- case CONFIG_TYPE_STRING:
- if (use_default) {
- retval = config->config_set_fn(arg, config->config_default_value, err_buf, phase, apply_mod);
- } else {
- retval = config->config_set_fn(arg, bval->bv_val, err_buf, phase, apply_mod);
- }
- break;
- case CONFIG_TYPE_ONOFF:
- if (use_default) {
- int_val = !strcasecmp(config->config_default_value, "on");
- } else {
- int_val = !strcasecmp((char *) bval->bv_val, "on");
- }
- retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
- break;
- }
-
- return retval;
- }
- static int parse_ldbm_config_entry(struct ldbminfo *li, Slapi_Entry *e, config_info *config_array)
- {
- Slapi_Attr *attr = NULL;
-
- for (slapi_entry_first_attr(e, &attr); attr; slapi_entry_next_attr(e, attr, &attr)) {
- char *attr_name = NULL;
- Slapi_Value *sval = NULL;
- struct berval *bval;
- char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
-
- slapi_attr_get_type(attr, &attr_name);
-
- /* There are some attributes that we don't care about, like objectclass. */
- if (ldbm_config_ignored_attr(attr_name)) {
- continue;
- }
- slapi_attr_first_value(attr, &sval);
- bval = (struct berval *) slapi_value_get_berval(sval);
-
- if (ldbm_config_set(li, attr_name, config_array, bval, err_buf, CONFIG_PHASE_STARTUP, 1 /* apply */) != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error with config attribute %s : %s\n", attr_name, err_buf, 0);
- return 1;
- }
- }
- return 0;
- }
- /*
- * Returns:
- * SLAPI_DSE_CALLBACK_ERROR on failure
- * SLAPI_DSE_CALLBACK_OK on success
- */
- int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg)
- {
- int i;
- char *attr_name;
- LDAPMod **mods;
- int rc = LDAP_SUCCESS;
- int apply_mod = 0;
- struct ldbminfo *li= (struct ldbminfo *) arg;
-
- /* This lock is probably way too conservative, but we don't expect much
- * contention for it. */
- PR_Lock(li->li_config_mutex);
-
- slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
-
- returntext[0] = '\0';
- /*
- * First pass: set apply mods to 0 so only input validation will be done;
- * 2nd pass: set apply mods to 1 to apply changes to internal storage
- */
- for ( apply_mod = 0; apply_mod <= 1 && LDAP_SUCCESS == rc; apply_mod++ ) {
- for (i = 0; mods[i] && LDAP_SUCCESS == rc; i++) {
- attr_name = mods[i]->mod_type;
-
- /* There are some attributes that we don't care about, like modifiersname. */
- if (ldbm_config_ignored_attr(attr_name)) {
- continue;
- }
-
- if ((mods[i]->mod_op & LDAP_MOD_DELETE) ||
- ((mods[i]->mod_op & ~LDAP_MOD_BVALUES) == LDAP_MOD_ADD)) {
- rc= LDAP_UNWILLING_TO_PERFORM;
- PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "%s attributes is not allowed",
- (mods[i]->mod_op & LDAP_MOD_DELETE) ? "Deleting" : "Adding");
- } else if (mods[i]->mod_op & LDAP_MOD_REPLACE) {
- /* This assumes there is only one bval for this mod. */
- rc = ldbm_config_set((void *) li, attr_name, ldbm_config,
- ( mods[i]->mod_bvalues == NULL ) ? NULL
- : mods[i]->mod_bvalues[0], returntext,
- ((li->li_flags&LI_FORCE_MOD_CONFIG)?
- CONFIG_PHASE_INTERNAL:CONFIG_PHASE_RUNNING),
- apply_mod);
- }
- }
- }
-
- PR_Unlock(li->li_config_mutex);
-
- *returncode= rc;
- if(LDAP_SUCCESS == rc) {
- return SLAPI_DSE_CALLBACK_OK;
- }
- else {
- return SLAPI_DSE_CALLBACK_ERROR;
- }
- }
- /* This function is used to set config attributes. It can be used as a
- * shortcut to doing an internal modify operation on the config DSE.
- */
- void ldbm_config_internal_set(struct ldbminfo *li, char *attrname, char *value)
- {
- char err_buf[SLAPI_DSE_RETURNTEXT_SIZE];
- struct berval bval;
-
- bval.bv_val = value;
- bval.bv_len = strlen(value);
-
- if (ldbm_config_set((void *) li, attrname, ldbm_config, &bval,
- err_buf, CONFIG_PHASE_INTERNAL, 1 /* apply */) != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "Internal Error: Error setting instance config attr %s to %s: %s\n",
- attrname, value, err_buf);
- exit(1);
- }
- }
- /*
- * replace_ldbm_config_value:
- * - update an ldbm database config value
- */
- void replace_ldbm_config_value(char *conftype, char *val, struct ldbminfo *li)
- {
- Slapi_PBlock pb;
- Slapi_Mods smods;
- pblock_init(&pb);
- slapi_mods_init(&smods, 1);
- slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val);
- slapi_modify_internal_set_pb(&pb, CONFIG_LDBM_DN,
- slapi_mods_get_ldapmods_byref(&smods),
- NULL, NULL, li->li_identity, 0);
- slapi_modify_internal_pb(&pb);
- slapi_mods_done(&smods);
- pblock_done(&pb);
- }
|