| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913 |
- /** 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. */
- #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);
- PL_strncpyz(ebuf, slapi_entry_get_dn_const(e), sizeof(ebuf)); /* 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 > -1) && (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_entryrdn_switch_get(void *arg)
- {
- return (void *)((uintptr_t)entryrdn_get_switch());
- }
- static int ldbm_config_entryrdn_switch_set(void *arg, void *value,
- char *errorbuf, int phase, int apply)
- {
- if (apply) {
- entryrdn_set_switch((int)((uintptr_t)value));
- }
- return LDAP_SUCCESS;
- }
- static void *ldbm_config_entryrdn_noancestorid_get(void *arg)
- {
- return (void *)((uintptr_t)entryrdn_get_noancestorid());
- }
- static int ldbm_config_entryrdn_noancestorid_set(void *arg, void *value,
- char *errorbuf, int phase, int apply)
- {
- if (apply) {
- entryrdn_set_noancestorid((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 = slapi_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_FLAG_ALLOW_RUNNING_CHANGE},
- {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},
- {CONFIG_ENTRYRDN_SWITCH, CONFIG_TYPE_ONOFF, "on", &ldbm_config_entryrdn_switch_get, &ldbm_config_entryrdn_switch_set, CONFIG_FLAG_ALWAYS_SHOW},
- {CONFIG_ENTRYRDN_NOANCESTORID, CONFIG_TYPE_ONOFF, "off", &ldbm_config_entryrdn_noancestorid_get, &ldbm_config_entryrdn_noancestorid_set, 0 /* no show */},
- {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 */, LDAP_MOD_REPLACE);
- }
- }
- void
- ldbm_config_read_instance_entries(struct ldbminfo *li, const char *backend_type)
- {
- Slapi_PBlock *tmp_pb;
- Slapi_Entry **entries = NULL;
- char *basedn = NULL;
- /* Construct the base dn of the subtree that holds the instance entries. */
- basedn = slapi_create_dn_string("cn=%s,cn=plugins,cn=config", backend_type);
- if (NULL == basedn) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_config_read_instance_entries: "
- "failed create backend dn for %s\n", backend_type);
- return;
- }
- /* 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);
- slapi_ch_free_string(&basedn);
- }
- /* 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;
- char *dn = NULL;
- int rval = 0;
- /* 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.
- */
- dn = slapi_create_dn_string("cn=config,cn=%s,cn=plugins,cn=config",
- li->li_plugin->plg_name);
- if (NULL == dn) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_config_load_dse_info: "
- "failed create config dn for %s\n",
- li->li_plugin->plg_name);
- rval = 1;
- goto bail;
- }
- search_pb = slapi_pblock_new();
- if (!search_pb) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ldbm_config_load_dse_info: Out of memory\n",
- 0, 0, 0);
- rval = 1;
- goto bail;
- }
- 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, &rval);
- if (LDAP_NO_SUCH_OBJECT == rval) {
- /* 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 (rval != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error accessing the ldbm config DSE\n",
- 0, 0, 0);
- rval = 1;
- goto bail;
- } 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);
- rval = 1;
- goto bail;
- }
- 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);
- rval = 1;
- goto bail;
- }
- }
- 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 */
- 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);
- slapi_ch_free_string(&dn);
- /* setup the dse callback functions for the ldbm backend monitor entry */
- dn = slapi_create_dn_string("cn=monitor,cn=%s,cn=plugins,cn=config",
- li->li_plugin->plg_name);
- if (NULL == dn) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_config_load_dse_info: "
- "failed create monitor dn for %s\n",
- li->li_plugin->plg_name);
- rval = 1;
- goto bail;
- }
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_back_monitor_search,
- (void *)li);
- slapi_ch_free_string(&dn);
- /* And the ldbm backend database monitor entry */
- dn = slapi_create_dn_string("cn=database,cn=monitor,cn=%s,cn=plugins,cn=config",
- li->li_plugin->plg_name);
- if (NULL == dn) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_config_load_dse_info: "
- "failed create monitor database dn for %s\n",
- li->li_plugin->plg_name);
- rval = 1;
- goto bail;
- }
- slapi_config_register_callback(SLAPI_OPERATION_SEARCH, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", ldbm_back_dbmonitor_search,
- (void *)li);
- slapi_ch_free_string(&dn);
- /* setup the dse callback functions for the ldbm backend instance
- * entries */
- dn = slapi_create_dn_string("cn=%s,cn=plugins,cn=config",
- li->li_plugin->plg_name);
- if (NULL == dn) {
- LDAPDebug1Arg(LDAP_DEBUG_ANY,
- "ldbm_config_load_dse_info: "
- "failed create plugin dn for %s\n",
- li->li_plugin->plg_name);
- rval = 1;
- goto bail;
- }
- 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);
- bail:
- slapi_ch_free_string(&dn);
- return rval;
- }
- /* 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';
- return;
- }
-
- 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, "%lu", 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(LDBM_NUMSUBORDINATES_STR, 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, int mod_op)
- {
- 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 or if we are deleting
- the value, we will use the default value for the attribute. */
- if ((CONFIG_PHASE_INITIALIZATION == phase) || (NULL == bval) || SLAPI_IS_MOD_DELETE(mod_op)) {
- if (CONFIG_FLAG_SKIP_DEFAULT_SETTING & config->config_flags) {
- return LDAP_SUCCESS; /* Skipping the default config setting */
- }
- use_default = 1;
- } else {
- use_default = 0;
- /* cannot use mod add on a single valued attribute if the attribute was
- previously set to a non-default value */
- if (SLAPI_IS_MOD_ADD(mod_op) && apply_mod &&
- (config->config_flags & CONFIG_FLAG_PREVIOUSLY_SET)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE,
- "cannot add a value to single valued attribute %s.\n",
- attr_name);
- return LDAP_OBJECT_CLASS_VIOLATION;
- }
- }
- /* if delete, and a specific value was provided to delete, the existing value must
- match that value, or return LDAP_NO_SUCH_ATTRIBUTE */
- if (SLAPI_IS_MOD_DELETE(mod_op) && bval && bval->bv_len && bval->bv_val) {
- char buf[BUFSIZ];
- ldbm_config_get(arg, config, buf);
- if (PL_strncmp(buf, bval->bv_val, bval->bv_len)) {
- PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE,
- "value [%s] for attribute %s does not match existing value [%s].\n",
- bval->bv_val, attr_name, buf);
- return LDAP_NO_SUCH_ATTRIBUTE;
- }
- }
-
- 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;
- }
- /* operation was successful and we applied the value? */
- if (!retval && apply_mod) {
- /* 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. */
- if (use_default) {
- /* attr deleted or we are using the default value */
- config->config_flags &= ~CONFIG_FLAG_PREVIOUSLY_SET;
- } else {
- /* attr set explicitly */
- config->config_flags |= CONFIG_FLAG_PREVIOUSLY_SET;
- }
- }
-
- 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_MOD_REPLACE) != 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;
- }
- /* when deleting a value, and this is the last or only value, set
- the config param to its default value
- when adding a value, if the value is set to its default value, replace
- it with the new value - otherwise, if it is single valued, reject the
- operation with TYPE_OR_VALUE_EXISTS */
- /* 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, mods[i]->mod_op);
- }
- }
-
- 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_MOD_REPLACE) != 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);
- }
|