libglobs.c 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. /*
  39. *
  40. * libglobs.c -- SLAPD library global variables
  41. */
  42. /* for windows only
  43. we define slapd_ldap_debug here, so we don't want to declare
  44. it in any header file which might conflict with our definition
  45. */
  46. #define DONT_DECLARE_SLAPD_LDAP_DEBUG /* see ldaplog.h */
  47. #if defined(NET_SSL)
  48. #include "ldap.h"
  49. #include <sslproto.h>
  50. #include <ldap_ssl.h>
  51. #undef OFF
  52. #undef LITTLE_ENDIAN
  53. #endif
  54. #include <stdio.h>
  55. #include <string.h>
  56. #include <sys/types.h>
  57. #include <time.h>
  58. #include <stdarg.h>
  59. #include <stdlib.h>
  60. #if defined( _WIN32 )
  61. #define R_OK 04
  62. #include "ntslapdmessages.h"
  63. #include "proto-ntutil.h"
  64. #else
  65. #include <sys/time.h>
  66. #include <sys/param.h> /* MAXPATHLEN */
  67. #include <sys/socket.h>
  68. #include <netinet/in.h>
  69. #include <arpa/inet.h>
  70. #include <netdb.h>
  71. #include <unistd.h>
  72. #include <pwd.h> /* pwdnam */
  73. #endif
  74. #ifdef USE_SYSCONF
  75. #include <unistd.h>
  76. #endif /* USE_SYSCONF */
  77. #include "slap.h"
  78. #include "plhash.h"
  79. #define REMOVE_CHANGELOG_CMD "remove"
  80. /* On UNIX, there's only one copy of slapd_ldap_debug */
  81. /* On NT, each module keeps its own module_ldap_debug, which */
  82. /* points to the process' slapd_ldap_debug */
  83. #ifdef _WIN32
  84. int *module_ldap_debug;
  85. int __declspec(dllexport) slapd_ldap_debug = LDAP_DEBUG_ANY;
  86. #else
  87. int slapd_ldap_debug = LDAP_DEBUG_ANY;
  88. #endif
  89. char *ldap_srvtab = "";
  90. /* Note that the 'attrname' arguments are used only for log messages */
  91. typedef int (*ConfigSetFunc)(const char *attrname, char *value,
  92. char *errorbuf, int apply);
  93. typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
  94. char *errorbuf, int apply);
  95. typedef enum {
  96. CONFIG_INT, /* maps to int */
  97. CONFIG_LONG, /* maps to long */
  98. CONFIG_STRING, /* maps to char* */
  99. CONFIG_CHARRAY, /* maps to char** */
  100. CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
  101. CONFIG_STRING_OR_OFF, /* use "off" instead of null or an empty string */
  102. CONFIG_STRING_OR_UNKNOWN, /* use "unknown" instead of an empty string */
  103. CONFIG_CONSTANT_INT, /* for #define values, e.g. */
  104. CONFIG_CONSTANT_STRING, /* for #define values, e.g. */
  105. CONFIG_SPECIAL_REFERRALLIST, /* this is a berval list */
  106. CONFIG_SPECIAL_SSLCLIENTAUTH, /* maps strings to an enumeration */
  107. CONFIG_SPECIAL_ERRORLOGLEVEL, /* requires & with LDAP_DEBUG_ANY */
  108. CONFIG_STRING_OR_EMPTY /* use an empty string */
  109. } ConfigVarType;
  110. static int config_set_onoff( const char *attrname, char *value,
  111. int *configvalue, char *errorbuf, int apply );
  112. static int config_set_schemareplace ( const char *attrname, char *value,
  113. char *errorbuf, int apply );
  114. static int
  115. isIntegralType(ConfigVarType type)
  116. {
  117. return type == CONFIG_INT || type == CONFIG_LONG || type == CONFIG_ON_OFF;
  118. }
  119. /* the caller will typically have to cast the result based on the ConfigVarType */
  120. typedef void *(*ConfigGetFunc)(void);
  121. /* static Ref_Array global_referrals; */
  122. static slapdFrontendConfig_t global_slapdFrontendConfig;
  123. static struct config_get_and_set {
  124. const char *attr_name; /* the name of the attribute */
  125. ConfigSetFunc setfunc; /* the function to call to set the value */
  126. LogSetFunc logsetfunc; /* log functions are special */
  127. int whichlog; /* ACCESS, ERROR, AUDIT, etc. */
  128. void** config_var_addr; /* address of member of slapdFrontendConfig struct */
  129. ConfigVarType config_var_type; /* cast to this type when getting */
  130. ConfigGetFunc getfunc; /* for special handling */
  131. } ConfigList[] = {
  132. {CONFIG_AUDITLOG_MODE_ATTRIBUTE, NULL,
  133. log_set_mode, SLAPD_AUDIT_LOG,
  134. (void**)&global_slapdFrontendConfig.auditlog_mode, CONFIG_STRING, NULL},
  135. {CONFIG_AUDITLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  136. log_set_rotationsync_enabled, SLAPD_AUDIT_LOG,
  137. (void**)&global_slapdFrontendConfig.auditlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  138. {CONFIG_AUDITLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  139. log_set_rotationsynchour, SLAPD_AUDIT_LOG,
  140. (void**)&global_slapdFrontendConfig.auditlog_rotationsynchour, CONFIG_INT, NULL},
  141. {CONFIG_AUDITLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  142. log_set_rotationsyncmin, SLAPD_AUDIT_LOG,
  143. (void**)&global_slapdFrontendConfig.auditlog_rotationsyncmin, CONFIG_INT, NULL},
  144. {CONFIG_AUDITLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  145. log_set_rotationtime, SLAPD_AUDIT_LOG,
  146. (void**)&global_slapdFrontendConfig.auditlog_rotationtime, CONFIG_INT, NULL},
  147. {CONFIG_ACCESSLOG_MODE_ATTRIBUTE, NULL,
  148. log_set_mode, SLAPD_ACCESS_LOG,
  149. (void**)&global_slapdFrontendConfig.accesslog_mode, CONFIG_STRING, NULL},
  150. {CONFIG_ACCESSLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  151. log_set_numlogsperdir, SLAPD_ACCESS_LOG,
  152. (void**)&global_slapdFrontendConfig.accesslog_maxnumlogs, CONFIG_INT, NULL},
  153. {CONFIG_LOGLEVEL_ATTRIBUTE, config_set_errorlog_level,
  154. NULL, 0,
  155. (void**)&global_slapdFrontendConfig.errorloglevel,
  156. CONFIG_SPECIAL_ERRORLOGLEVEL, NULL},
  157. {CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  158. log_set_logging, SLAPD_ERROR_LOG,
  159. (void**)&global_slapdFrontendConfig.errorlog_logging_enabled, CONFIG_ON_OFF, NULL},
  160. {CONFIG_ERRORLOG_MODE_ATTRIBUTE, NULL,
  161. log_set_mode, SLAPD_ERROR_LOG,
  162. (void**)&global_slapdFrontendConfig.errorlog_mode, CONFIG_STRING, NULL},
  163. {CONFIG_ERRORLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  164. log_set_expirationtime, SLAPD_ERROR_LOG,
  165. (void**)&global_slapdFrontendConfig.errorlog_exptime, CONFIG_INT, NULL},
  166. {CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  167. log_set_logging, SLAPD_ACCESS_LOG,
  168. (void**)&global_slapdFrontendConfig.accesslog_logging_enabled, CONFIG_ON_OFF, NULL},
  169. {CONFIG_PORT_ATTRIBUTE, config_set_port,
  170. NULL, 0,
  171. (void**)&global_slapdFrontendConfig.port, CONFIG_INT, NULL},
  172. {CONFIG_WORKINGDIR_ATTRIBUTE, config_set_workingdir,
  173. NULL, 0,
  174. (void**)&global_slapdFrontendConfig.workingdir, CONFIG_STRING_OR_EMPTY, NULL},
  175. {CONFIG_MAXTHREADSPERCONN_ATTRIBUTE, config_set_maxthreadsperconn,
  176. NULL, 0,
  177. (void**)&global_slapdFrontendConfig.maxthreadsperconn, CONFIG_INT, NULL},
  178. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  179. log_set_expirationtime, SLAPD_ACCESS_LOG,
  180. (void**)&global_slapdFrontendConfig.accesslog_exptime, CONFIG_INT, NULL},
  181. #ifndef _WIN32
  182. {CONFIG_LOCALUSER_ATTRIBUTE, config_set_localuser,
  183. NULL, 0,
  184. (void**)&global_slapdFrontendConfig.localuser, CONFIG_STRING, NULL},
  185. #endif
  186. {CONFIG_ERRORLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  187. log_set_rotationsync_enabled, SLAPD_ERROR_LOG,
  188. (void**)&global_slapdFrontendConfig.errorlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  189. {CONFIG_ERRORLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  190. log_set_rotationsynchour, SLAPD_ERROR_LOG,
  191. (void**)&global_slapdFrontendConfig.errorlog_rotationsynchour, CONFIG_INT, NULL},
  192. {CONFIG_ERRORLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  193. log_set_rotationsyncmin, SLAPD_ERROR_LOG,
  194. (void**)&global_slapdFrontendConfig.errorlog_rotationsyncmin, CONFIG_INT, NULL},
  195. {CONFIG_ERRORLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  196. log_set_rotationtime, SLAPD_ERROR_LOG,
  197. (void**)&global_slapdFrontendConfig.errorlog_rotationtime, CONFIG_INT, NULL},
  198. {CONFIG_PW_INHISTORY_ATTRIBUTE, config_set_pw_inhistory,
  199. NULL, 0,
  200. (void**)&global_slapdFrontendConfig.pw_policy.pw_inhistory, CONFIG_INT, NULL},
  201. {CONFIG_PW_STORAGESCHEME_ATTRIBUTE, config_set_pw_storagescheme,
  202. NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_pw_storagescheme},
  203. {CONFIG_PW_UNLOCK_ATTRIBUTE, config_set_pw_unlock,
  204. NULL, 0,
  205. (void**)&global_slapdFrontendConfig.pw_policy.pw_unlock, CONFIG_ON_OFF, NULL},
  206. {CONFIG_PW_GRACELIMIT_ATTRIBUTE, config_set_pw_gracelimit,
  207. NULL, 0,
  208. (void**)&global_slapdFrontendConfig.pw_policy.pw_gracelimit, CONFIG_INT, NULL},
  209. {CONFIG_ACCESSLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  210. log_set_rotationsync_enabled, SLAPD_ACCESS_LOG,
  211. (void**)&global_slapdFrontendConfig.accesslog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  212. {CONFIG_ACCESSLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  213. log_set_rotationsynchour, SLAPD_ACCESS_LOG,
  214. (void**)&global_slapdFrontendConfig.accesslog_rotationsynchour, CONFIG_INT, NULL},
  215. {CONFIG_ACCESSLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  216. log_set_rotationsyncmin, SLAPD_ACCESS_LOG,
  217. (void**)&global_slapdFrontendConfig.accesslog_rotationsyncmin, CONFIG_INT, NULL},
  218. {CONFIG_ACCESSLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  219. log_set_rotationtime, SLAPD_ACCESS_LOG,
  220. (void**)&global_slapdFrontendConfig.accesslog_rotationtime, CONFIG_INT, NULL},
  221. {CONFIG_PW_MUSTCHANGE_ATTRIBUTE, config_set_pw_must_change,
  222. NULL, 0,
  223. (void**)&global_slapdFrontendConfig.pw_policy.pw_must_change, CONFIG_ON_OFF, NULL},
  224. {CONFIG_PWPOLICY_LOCAL_ATTRIBUTE, config_set_pwpolicy_local,
  225. NULL, 0,
  226. (void**)&global_slapdFrontendConfig.pwpolicy_local, CONFIG_ON_OFF, NULL},
  227. {CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  228. log_set_maxdiskspace, SLAPD_AUDIT_LOG,
  229. (void**)&global_slapdFrontendConfig.auditlog_maxdiskspace, CONFIG_INT, NULL},
  230. {CONFIG_SIZELIMIT_ATTRIBUTE, config_set_sizelimit,
  231. NULL, 0,
  232. (void**)&global_slapdFrontendConfig.sizelimit, CONFIG_INT, NULL},
  233. {CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  234. log_set_logsize, SLAPD_AUDIT_LOG,
  235. (void**)&global_slapdFrontendConfig.auditlog_maxlogsize, CONFIG_INT, NULL},
  236. {CONFIG_PW_WARNING_ATTRIBUTE, config_set_pw_warning,
  237. NULL, 0,
  238. (void**)&global_slapdFrontendConfig.pw_policy.pw_warning, CONFIG_LONG, NULL},
  239. {CONFIG_READONLY_ATTRIBUTE, config_set_readonly,
  240. NULL, 0,
  241. (void**)&global_slapdFrontendConfig.readonly, CONFIG_ON_OFF, NULL},
  242. {CONFIG_THREADNUMBER_ATTRIBUTE, config_set_threadnumber,
  243. NULL, 0,
  244. (void**)&global_slapdFrontendConfig.threadnumber, CONFIG_INT, NULL},
  245. {CONFIG_PW_LOCKOUT_ATTRIBUTE, config_set_pw_lockout,
  246. NULL, 0,
  247. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockout, CONFIG_ON_OFF, NULL},
  248. {CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, config_set_enquote_sup_oc,
  249. NULL, 0,
  250. (void**)&global_slapdFrontendConfig.enquote_sup_oc, CONFIG_ON_OFF, NULL},
  251. {CONFIG_LOCALHOST_ATTRIBUTE, config_set_localhost,
  252. NULL, 0,
  253. (void**)&global_slapdFrontendConfig.localhost, CONFIG_STRING, NULL},
  254. {CONFIG_IOBLOCKTIMEOUT_ATTRIBUTE, config_set_ioblocktimeout,
  255. NULL, 0,
  256. (void**)&global_slapdFrontendConfig.ioblocktimeout, CONFIG_INT, NULL},
  257. {CONFIG_MAX_FILTER_NEST_LEVEL_ATTRIBUTE, config_set_max_filter_nest_level,
  258. NULL, 0, (void**)&global_slapdFrontendConfig.max_filter_nest_level,
  259. CONFIG_INT, NULL},
  260. {CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  261. log_set_maxdiskspace, SLAPD_ERROR_LOG,
  262. (void**)&global_slapdFrontendConfig.errorlog_maxdiskspace, CONFIG_INT, NULL},
  263. {CONFIG_PW_MINLENGTH_ATTRIBUTE, config_set_pw_minlength,
  264. NULL, 0,
  265. (void**)&global_slapdFrontendConfig.pw_policy.pw_minlength, CONFIG_INT, NULL},
  266. {CONFIG_ERRORLOG_ATTRIBUTE, config_set_errorlog,
  267. NULL, 0,
  268. (void**)&global_slapdFrontendConfig.errorlog, CONFIG_STRING_OR_EMPTY, NULL},
  269. {CONFIG_AUDITLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  270. log_set_expirationtime, SLAPD_AUDIT_LOG,
  271. (void**)&global_slapdFrontendConfig.auditlog_exptime, CONFIG_INT, NULL},
  272. {CONFIG_SCHEMACHECK_ATTRIBUTE, config_set_schemacheck,
  273. NULL, 0,
  274. (void**)&global_slapdFrontendConfig.schemacheck, CONFIG_ON_OFF, NULL},
  275. {CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema,
  276. NULL, 0,
  277. (void**)&global_slapdFrontendConfig.ds4_compatible_schema,
  278. CONFIG_ON_OFF, NULL},
  279. {CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  280. config_set_schema_ignore_trailing_spaces, NULL, 0,
  281. (void**)&global_slapdFrontendConfig.schema_ignore_trailing_spaces,
  282. CONFIG_ON_OFF, NULL},
  283. {CONFIG_SCHEMAREPLACE_ATTRIBUTE, config_set_schemareplace, NULL, 0,
  284. (void**)&global_slapdFrontendConfig.schemareplace,
  285. CONFIG_STRING_OR_OFF, NULL},
  286. {CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  287. log_set_maxdiskspace, SLAPD_ACCESS_LOG,
  288. (void**)&global_slapdFrontendConfig.accesslog_maxdiskspace, CONFIG_INT, NULL},
  289. {CONFIG_REFERRAL_ATTRIBUTE, (ConfigSetFunc)config_set_defaultreferral,
  290. NULL, 0,
  291. (void**)&global_slapdFrontendConfig.defaultreferral,
  292. CONFIG_SPECIAL_REFERRALLIST, NULL},
  293. {CONFIG_PW_MAXFAILURE_ATTRIBUTE, config_set_pw_maxfailure,
  294. NULL, 0,
  295. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxfailure, CONFIG_INT, NULL},
  296. {CONFIG_ACCESSLOG_ATTRIBUTE, config_set_accesslog,
  297. NULL, 0,
  298. (void**)&global_slapdFrontendConfig.accesslog, CONFIG_STRING_OR_EMPTY, NULL},
  299. {CONFIG_LASTMOD_ATTRIBUTE, config_set_lastmod,
  300. NULL, 0,
  301. (void**)&global_slapdFrontendConfig.lastmod, CONFIG_ON_OFF, NULL},
  302. {CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
  303. NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme},
  304. {CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
  305. NULL, 0,
  306. (void**)&global_slapdFrontendConfig.pw_policy.pw_history, CONFIG_ON_OFF, NULL},
  307. {CONFIG_SECURITY_ATTRIBUTE, config_set_security,
  308. NULL, 0,
  309. (void**)&global_slapdFrontendConfig.security, CONFIG_ON_OFF, NULL},
  310. {CONFIG_PW_MAXAGE_ATTRIBUTE, config_set_pw_maxage,
  311. NULL, 0,
  312. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxage, CONFIG_LONG, NULL},
  313. {CONFIG_AUDITLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  314. log_set_rotationtimeunit, SLAPD_AUDIT_LOG,
  315. (void**)&global_slapdFrontendConfig.auditlog_rotationunit,
  316. CONFIG_STRING_OR_UNKNOWN, NULL},
  317. {CONFIG_PW_RESETFAILURECOUNT_ATTRIBUTE, config_set_pw_resetfailurecount,
  318. NULL, 0,
  319. (void**)&global_slapdFrontendConfig.pw_policy.pw_resetfailurecount, CONFIG_LONG, NULL},
  320. {CONFIG_PW_ISGLOBAL_ATTRIBUTE, config_set_pw_is_global_policy,
  321. NULL, 0,
  322. (void**)&global_slapdFrontendConfig.pw_is_global_policy, CONFIG_ON_OFF, NULL},
  323. {CONFIG_AUDITLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  324. log_set_numlogsperdir, SLAPD_AUDIT_LOG,
  325. (void**)&global_slapdFrontendConfig.auditlog_maxnumlogs, CONFIG_INT, NULL},
  326. {CONFIG_ERRORLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  327. log_set_expirationtimeunit, SLAPD_ERROR_LOG,
  328. (void**)&global_slapdFrontendConfig.errorlog_exptimeunit,
  329. CONFIG_STRING_OR_UNKNOWN, NULL},
  330. /* errorlog list is read only, so no set func and no config var addr */
  331. {CONFIG_ERRORLOG_LIST_ATTRIBUTE, NULL, NULL, 0, NULL,
  332. CONFIG_CHARRAY, (ConfigGetFunc)config_get_errorlog_list},
  333. {CONFIG_GROUPEVALNESTLEVEL_ATTRIBUTE, config_set_groupevalnestlevel,
  334. NULL, 0,
  335. (void**)&global_slapdFrontendConfig.groupevalnestlevel, CONFIG_INT, NULL},
  336. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  337. log_set_expirationtimeunit, SLAPD_ACCESS_LOG,
  338. (void**)&global_slapdFrontendConfig.accesslog_exptimeunit,
  339. CONFIG_STRING_OR_UNKNOWN, NULL},
  340. {CONFIG_ROOTPW_ATTRIBUTE, config_set_rootpw,
  341. NULL, 0,
  342. (void**)&global_slapdFrontendConfig.rootpw, CONFIG_STRING, NULL},
  343. {CONFIG_PW_CHANGE_ATTRIBUTE, config_set_pw_change,
  344. NULL, 0,
  345. (void**)&global_slapdFrontendConfig.pw_policy.pw_change, CONFIG_ON_OFF, NULL},
  346. {CONFIG_ACCESSLOGLEVEL_ATTRIBUTE, config_set_accesslog_level,
  347. NULL, 0,
  348. (void**)&global_slapdFrontendConfig.accessloglevel, CONFIG_INT, NULL},
  349. {CONFIG_ERRORLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  350. log_set_rotationtimeunit, SLAPD_ERROR_LOG,
  351. (void**)&global_slapdFrontendConfig.errorlog_rotationunit,
  352. CONFIG_STRING_OR_UNKNOWN, NULL},
  353. {CONFIG_SECUREPORT_ATTRIBUTE, config_set_secureport,
  354. NULL, 0,
  355. (void**)&global_slapdFrontendConfig.secureport, CONFIG_INT, NULL},
  356. {CONFIG_BASEDN_ATTRIBUTE, config_set_basedn,
  357. NULL, 0,
  358. (void**)&global_slapdFrontendConfig.certmap_basedn, CONFIG_STRING, NULL},
  359. {CONFIG_TIMELIMIT_ATTRIBUTE, config_set_timelimit,
  360. NULL, 0,
  361. (void**)&global_slapdFrontendConfig.timelimit, CONFIG_INT, NULL},
  362. {CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  363. log_set_logsize, SLAPD_ERROR_LOG,
  364. (void**)&global_slapdFrontendConfig.errorlog_maxlogsize, CONFIG_INT, NULL},
  365. {CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE, config_set_reservedescriptors,
  366. NULL, 0,
  367. (void**)&global_slapdFrontendConfig.reservedescriptors, CONFIG_INT, NULL},
  368. /* access log list is read only, no set func, no config var addr */
  369. {CONFIG_ACCESSLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  370. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_accesslog_list},
  371. {CONFIG_SVRTAB_ATTRIBUTE, config_set_srvtab,
  372. NULL, 0,
  373. (void**)&global_slapdFrontendConfig.srvtab, CONFIG_STRING, NULL},
  374. {CONFIG_PW_EXP_ATTRIBUTE, config_set_pw_exp,
  375. NULL, 0,
  376. (void**)&global_slapdFrontendConfig.pw_policy.pw_exp, CONFIG_ON_OFF, NULL},
  377. {CONFIG_ACCESSCONTROL_ATTRIBUTE, config_set_accesscontrol,
  378. NULL, 0,
  379. (void**)&global_slapdFrontendConfig.accesscontrol, CONFIG_ON_OFF, NULL},
  380. {CONFIG_AUDITLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  381. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_auditlog_list},
  382. {CONFIG_ACCESSLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  383. log_set_rotationtimeunit, SLAPD_ACCESS_LOG,
  384. (void**)&global_slapdFrontendConfig.accesslog_rotationunit, CONFIG_STRING, NULL},
  385. {CONFIG_PW_LOCKDURATION_ATTRIBUTE, config_set_pw_lockduration,
  386. NULL, 0,
  387. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockduration, CONFIG_LONG, NULL},
  388. {CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  389. log_set_logsize, SLAPD_ACCESS_LOG,
  390. (void**)&global_slapdFrontendConfig.accesslog_maxlogsize, CONFIG_INT, NULL},
  391. {CONFIG_IDLETIMEOUT_ATTRIBUTE, config_set_idletimeout,
  392. NULL, 0,
  393. (void**)&global_slapdFrontendConfig.idletimeout, CONFIG_INT, NULL},
  394. {CONFIG_NAGLE_ATTRIBUTE, config_set_nagle,
  395. NULL, 0,
  396. (void**)&global_slapdFrontendConfig.nagle, CONFIG_ON_OFF, NULL},
  397. {CONFIG_ERRORLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  398. log_set_mindiskspace, SLAPD_ERROR_LOG,
  399. (void**)&global_slapdFrontendConfig.errorlog_minfreespace, CONFIG_INT, NULL},
  400. {CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  401. log_set_logging, SLAPD_AUDIT_LOG,
  402. (void**)&global_slapdFrontendConfig.auditlog_logging_enabled, CONFIG_ON_OFF, NULL},
  403. {CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
  404. NULL, 0,
  405. (void**)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL},
  406. {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
  407. NULL, 0,
  408. (void**)&global_slapdFrontendConfig.csnlogging, CONFIG_ON_OFF, NULL},
  409. {CONFIG_AUDITLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  410. log_set_expirationtimeunit, SLAPD_AUDIT_LOG,
  411. (void**)&global_slapdFrontendConfig.auditlog_exptimeunit,
  412. CONFIG_STRING_OR_UNKNOWN, NULL},
  413. {CONFIG_PW_SYNTAX_ATTRIBUTE, config_set_pw_syntax,
  414. NULL, 0,
  415. (void**)&global_slapdFrontendConfig.pw_policy.pw_syntax, CONFIG_ON_OFF, NULL},
  416. {CONFIG_LISTENHOST_ATTRIBUTE, config_set_listenhost,
  417. NULL, 0,
  418. (void**)&global_slapdFrontendConfig.listenhost, CONFIG_STRING, NULL},
  419. {CONFIG_ACCESSLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  420. log_set_mindiskspace, SLAPD_ACCESS_LOG,
  421. (void**)&global_slapdFrontendConfig.accesslog_minfreespace, CONFIG_INT, NULL},
  422. {CONFIG_ERRORLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  423. log_set_numlogsperdir, SLAPD_ERROR_LOG,
  424. (void**)&global_slapdFrontendConfig.errorlog_maxnumlogs, CONFIG_INT, NULL},
  425. {CONFIG_SECURELISTENHOST_ATTRIBUTE, config_set_securelistenhost,
  426. NULL, 0,
  427. (void**)&global_slapdFrontendConfig.securelistenhost, CONFIG_STRING, NULL},
  428. {CONFIG_AUDITLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  429. log_set_mindiskspace, SLAPD_AUDIT_LOG,
  430. (void**)&global_slapdFrontendConfig.auditlog_minfreespace, CONFIG_INT, NULL},
  431. {CONFIG_ROOTDN_ATTRIBUTE, config_set_rootdn,
  432. NULL, 0,
  433. (void**)&global_slapdFrontendConfig.rootdn, CONFIG_STRING, NULL},
  434. {CONFIG_PW_MINAGE_ATTRIBUTE, config_set_pw_minage,
  435. NULL, 0,
  436. (void**)&global_slapdFrontendConfig.pw_policy.pw_minage, CONFIG_LONG, NULL},
  437. {CONFIG_AUDITFILE_ATTRIBUTE, config_set_auditlog,
  438. NULL, 0,
  439. (void**)&global_slapdFrontendConfig.auditlog, CONFIG_STRING_OR_EMPTY, NULL},
  440. {CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, config_set_return_exact_case,
  441. NULL, 0,
  442. (void**)&global_slapdFrontendConfig.return_exact_case, CONFIG_ON_OFF, NULL},
  443. {CONFIG_RESULT_TWEAK_ATTRIBUTE, config_set_result_tweak,
  444. NULL, 0,
  445. (void**)&global_slapdFrontendConfig.result_tweak, CONFIG_ON_OFF, NULL},
  446. {CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, config_set_attrname_exceptions,
  447. NULL, 0,
  448. (void**)&global_slapdFrontendConfig.attrname_exceptions, CONFIG_ON_OFF, NULL},
  449. {CONFIG_MAXBERSIZE_ATTRIBUTE, config_set_maxbersize,
  450. NULL, 0,
  451. (void**)&global_slapdFrontendConfig.maxbersize, CONFIG_INT, NULL},
  452. {CONFIG_VERSIONSTRING_ATTRIBUTE, config_set_versionstring,
  453. NULL, 0,
  454. (void**)&global_slapdFrontendConfig.versionstring, CONFIG_STRING, NULL},
  455. {CONFIG_REFERRAL_MODE_ATTRIBUTE, config_set_referral_mode,
  456. NULL, 0,
  457. (void**)&global_slapdFrontendConfig.refer_url, CONFIG_STRING, NULL},
  458. #if !defined(_WIN32) && !defined(AIX)
  459. {CONFIG_MAXDESCRIPTORS_ATTRIBUTE, config_set_maxdescriptors,
  460. NULL, 0,
  461. (void**)&global_slapdFrontendConfig.maxdescriptors, CONFIG_INT, NULL},
  462. #endif
  463. {CONFIG_CONNTABLESIZE_ATTRIBUTE, config_set_conntablesize,
  464. NULL, 0,
  465. (void**)&global_slapdFrontendConfig.conntablesize, CONFIG_INT, NULL},
  466. {CONFIG_SSLCLIENTAUTH_ATTRIBUTE, config_set_SSLclientAuth,
  467. NULL, 0,
  468. (void **)&global_slapdFrontendConfig.SSLclientAuth, CONFIG_SPECIAL_SSLCLIENTAUTH, NULL},
  469. {CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE, config_set_ssl_check_hostname,
  470. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_ssl_check_hostname},
  471. {CONFIG_CONFIG_ATTRIBUTE, 0, NULL, 0, (void**)SLAPD_CONFIG_DN,
  472. CONFIG_CONSTANT_STRING, NULL},
  473. {CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
  474. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters},
  475. {CONFIG_INSTANCEDIR_ATTRIBUTE, NULL /* read only */,
  476. NULL, 0,
  477. (void**)&global_slapdFrontendConfig.instancedir, CONFIG_STRING, NULL},
  478. {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
  479. NULL, 0,
  480. (void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
  481. {CONFIG_OUTBOUND_LDAP_IO_TIMEOUT_ATTRIBUTE,
  482. config_set_outbound_ldap_io_timeout,
  483. NULL, 0,
  484. (void **)&global_slapdFrontendConfig.outbound_ldap_io_timeout,
  485. CONFIG_INT, NULL}
  486. };
  487. /*
  488. * hashNocaseString - used for case insensitive hash lookups
  489. */
  490. static PLHashNumber
  491. hashNocaseString(const void *key)
  492. {
  493. PLHashNumber h = 0;
  494. const unsigned char *s;
  495. for (s = key; *s; s++)
  496. h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
  497. return h;
  498. }
  499. /*
  500. * hashNocaseCompare - used for case insensitive hash key comparisons
  501. */
  502. static PRIntn
  503. hashNocaseCompare(const void *v1, const void *v2)
  504. {
  505. return (strcasecmp((char *)v1, (char *)v2) == 0);
  506. }
  507. static PLHashTable *confighash = 0;
  508. static void
  509. init_config_get_and_set()
  510. {
  511. if (!confighash) {
  512. int ii = 0;
  513. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  514. confighash = PL_NewHashTable(tablesize+1, hashNocaseString,
  515. hashNocaseCompare,
  516. PL_CompareValues, 0, 0);
  517. for (ii = 0; ii < tablesize; ++ii) {
  518. if (PL_HashTableLookup(confighash, ConfigList[ii].attr_name))
  519. printf("error: %s is already in the list\n",
  520. ConfigList[ii].attr_name);
  521. if (!PL_HashTableAdd(confighash, ConfigList[ii].attr_name, &ConfigList[ii]))
  522. printf("error: could not add %s to the list\n",
  523. ConfigList[ii].attr_name);
  524. }
  525. }
  526. }
  527. #if 0
  528. #define GOLDEN_RATIO 0x9E3779B9U
  529. PR_IMPLEMENT(PLHashEntry **)
  530. PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
  531. {
  532. PLHashEntry *he, **hep, **hep0;
  533. PLHashNumber h;
  534. #ifdef HASHMETER
  535. ht->nlookups++;
  536. #endif
  537. h = keyHash * GOLDEN_RATIO;
  538. h >>= ht->shift;
  539. hep = hep0 = &ht->buckets[h];
  540. while ((he = *hep) != 0) {
  541. if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
  542. /* Move to front of chain if not already there */
  543. if (hep != hep0) {
  544. *hep = he->next;
  545. he->next = *hep0;
  546. *hep0 = he;
  547. }
  548. return hep0;
  549. }
  550. hep = &he->next;
  551. #ifdef HASHMETER
  552. ht->nsteps++;
  553. #endif
  554. }
  555. return hep;
  556. }
  557. static void
  558. debugHashTable(const char *key)
  559. {
  560. int ii = 0;
  561. PLHashEntry **hep = PL_HashTableRawLookup(confighash, hashNocaseString(key),
  562. key);
  563. if (!hep || !*hep)
  564. printf("raw lookup failed for %s\n", key);
  565. else if (hep && *hep)
  566. printf("raw lookup found %s -> %ul %s\n", key, (*hep)->keyHash, (*hep)->key);
  567. printf("hash table has %d entries\n", confighash->nentries);
  568. for (ii = 0; ii < confighash->nentries; ++ii)
  569. {
  570. PLHashEntry *he = confighash->buckets[ii];
  571. if (!he)
  572. printf("hash table entry %d is null\n", ii);
  573. else {
  574. printf("hash bucket %d:\n", ii);
  575. while (he) {
  576. int keys = !hashNocaseCompare(key, he->key);
  577. int hash = (hashNocaseString(key) == he->keyHash);
  578. printf("\thashval = %ul key = %s\n", he->keyHash, he->key);
  579. if (keys && hash) {
  580. printf("\t\tFOUND\n");
  581. } else if (keys) {
  582. printf("\t\tkeys match but hash vals do not\n");
  583. } else if (hash) {
  584. printf("\t\thash match but keys do not\n");
  585. }
  586. he = he->next;
  587. }
  588. }
  589. }
  590. }
  591. #endif
  592. static void
  593. bervalarray_free(struct berval **bvec)
  594. {
  595. int ii = 0;
  596. for(ii = 0; bvec && bvec[ii]; ++ii) {
  597. slapi_ch_free((void **)&bvec[ii]->bv_val);
  598. slapi_ch_free((void **)&bvec[ii]);
  599. }
  600. slapi_ch_free((void**)&bvec);
  601. }
  602. static struct berval **
  603. strarray2bervalarray(const char **strarray)
  604. {
  605. int ii = 0;
  606. struct berval **newlist = 0;
  607. /* first, count the number of items in the list */
  608. for (ii = 0; strarray && strarray[ii]; ++ii);
  609. /* if no items, return null */
  610. if (!ii)
  611. return newlist;
  612. /* allocate the list */
  613. newlist = (struct berval **)slapi_ch_malloc((ii+1) * sizeof(struct berval *));
  614. newlist[ii] = 0;
  615. for (; ii; --ii) {
  616. newlist[ii-1] = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
  617. newlist[ii-1]->bv_val = slapi_ch_strdup(strarray[ii-1]);
  618. newlist[ii-1]->bv_len = strlen(strarray[ii-1]);
  619. }
  620. return newlist;
  621. }
  622. /*
  623. ** Setting this flag forces the server to shutdown.
  624. */
  625. static int slapd_shutdown;
  626. void g_set_shutdown( int reason )
  627. {
  628. slapd_shutdown = reason;
  629. }
  630. int g_get_shutdown()
  631. {
  632. return slapd_shutdown;
  633. }
  634. static int cmd_shutdown;
  635. void c_set_shutdown()
  636. {
  637. cmd_shutdown = SLAPI_SHUTDOWN_SIGNAL;
  638. }
  639. int c_get_shutdown()
  640. {
  641. return cmd_shutdown;
  642. }
  643. slapdFrontendConfig_t *
  644. getFrontendConfig()
  645. {
  646. return &global_slapdFrontendConfig;
  647. }
  648. /*
  649. * FrontendConfig_init:
  650. * Put all default values for config stuff here.
  651. * If there's no default value, the value will be NULL if it's not set in dse.ldif
  652. */
  653. void
  654. FrontendConfig_init () {
  655. slapdFrontendConfig_t *cfg = getFrontendConfig();
  656. /* initialize the read/write configuration lock */
  657. if ( (cfg->cfg_rwlock = rwl_new()) == NULL ) {
  658. LDAPDebug ( LDAP_DEBUG_ANY,
  659. "FrontendConfig_init: failed to initialize cfg_rwlock. Exiting now.",
  660. 0,0,0 );
  661. exit(-1);
  662. }
  663. cfg->port = LDAP_PORT;
  664. cfg->secureport = LDAPS_PORT;
  665. cfg->threadnumber = SLAPD_DEFAULT_MAX_THREADS;
  666. cfg->maxthreadsperconn = SLAPD_DEFAULT_MAX_THREADS_PER_CONN;
  667. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  668. cfg->idletimeout = SLAPD_DEFAULT_IDLE_TIMEOUT;
  669. cfg->ioblocktimeout = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  670. cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
  671. cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
  672. #ifdef _WIN32
  673. cfg->conntablesize = SLAPD_DEFAULT_CONNTABLESIZE;
  674. #else
  675. #ifdef USE_SYSCONF
  676. cfg->conntablesize = sysconf( _SC_OPEN_MAX );
  677. #else /* USE_SYSCONF */
  678. cfg->conntablesize = getdtablesize();
  679. #endif /* USE_SYSCONF */
  680. #endif /* _WIN32 */
  681. cfg->accesscontrol = LDAP_ON;
  682. cfg->security = LDAP_OFF;
  683. cfg->ssl_check_hostname = LDAP_ON;
  684. cfg->return_exact_case = LDAP_ON;
  685. cfg->result_tweak = LDAP_OFF;
  686. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  687. cfg->useroc = slapi_ch_strdup ( "" );
  688. cfg->userat = slapi_ch_strdup ( "" );
  689. /* kexcoff: should not be initialized by default here
  690. cfg->rootpwstoragescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  691. cfg->pw_storagescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  692. */
  693. cfg->slapd_type = 0;
  694. cfg->versionstring = SLAPD_VERSION_STR;
  695. cfg->sizelimit = SLAPD_DEFAULT_SIZELIMIT;
  696. cfg->timelimit = SLAPD_DEFAULT_TIMELIMIT;
  697. cfg->schemacheck = LDAP_ON;
  698. cfg->ds4_compatible_schema = LDAP_OFF;
  699. cfg->enquote_sup_oc = LDAP_OFF;
  700. cfg->lastmod = LDAP_ON;
  701. cfg->rewrite_rfc1274 = LDAP_OFF;
  702. cfg->schemareplace = slapi_ch_strdup( CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY );
  703. cfg->schema_ignore_trailing_spaces = SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES;
  704. cfg->pwpolicy_local = LDAP_OFF;
  705. cfg->pw_policy.pw_change = LDAP_ON;
  706. cfg->pw_policy.pw_must_change = LDAP_OFF;
  707. cfg->pw_policy.pw_syntax = LDAP_OFF;
  708. cfg->pw_policy.pw_exp = LDAP_OFF;
  709. cfg->pw_policy.pw_minlength = 6;
  710. cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
  711. cfg->pw_policy.pw_minage = 0;
  712. cfg->pw_policy.pw_warning = 86400; /* 1 day */
  713. cfg->pw_policy.pw_history = LDAP_OFF;
  714. cfg->pw_policy.pw_inhistory = 6;
  715. cfg->pw_policy.pw_lockout = LDAP_OFF;
  716. cfg->pw_policy.pw_maxfailure = 3;
  717. cfg->pw_policy.pw_unlock = LDAP_ON;
  718. cfg->pw_policy.pw_lockduration = 3600; /* 60 minutes */
  719. cfg->pw_policy.pw_resetfailurecount = 600; /* 10 minutes */
  720. cfg->pw_policy.pw_gracelimit = 0;
  721. cfg->pw_is_global_policy = LDAP_OFF;
  722. cfg->accesslog_logging_enabled = LDAP_ON;
  723. cfg->accesslog_mode = slapi_ch_strdup("600");
  724. cfg->accesslog_maxnumlogs = 10;
  725. cfg->accesslog_maxlogsize = 100;
  726. cfg->accesslog_rotationtime = 1;
  727. cfg->accesslog_rotationunit = slapi_ch_strdup("day");
  728. cfg->accesslog_rotationsync_enabled = LDAP_OFF;
  729. cfg->accesslog_rotationsynchour = 0;
  730. cfg->accesslog_rotationsyncmin = 0;
  731. cfg->accesslog_maxdiskspace = 500;
  732. cfg->accesslog_minfreespace = 5;
  733. cfg->accesslog_exptime = 1;
  734. cfg->accesslog_exptimeunit = slapi_ch_strdup("month");
  735. cfg->accessloglevel = 256;
  736. cfg->accesslogbuffering = LDAP_ON;
  737. cfg->csnlogging = LDAP_ON;
  738. cfg->errorlog_logging_enabled = LDAP_ON;
  739. cfg->errorlog_mode = slapi_ch_strdup("600");
  740. cfg->errorlog_maxnumlogs = 1;
  741. cfg->errorlog_maxlogsize = 100;
  742. cfg->errorlog_rotationtime = 1;
  743. cfg->errorlog_rotationunit = slapi_ch_strdup ("week");
  744. cfg->errorlog_rotationsync_enabled = LDAP_OFF;
  745. cfg->errorlog_rotationsynchour = 0;
  746. cfg->errorlog_rotationsyncmin = 0;
  747. cfg->errorlog_maxdiskspace = 100;
  748. cfg->errorlog_minfreespace = 5;
  749. cfg->errorlog_exptime = 1;
  750. cfg->errorlog_exptimeunit = slapi_ch_strdup("month");
  751. cfg->errorloglevel = 0;
  752. cfg->auditlog_logging_enabled = LDAP_OFF;
  753. cfg->auditlog_mode = slapi_ch_strdup("600");
  754. cfg->auditlog_maxnumlogs = 1;
  755. cfg->auditlog_maxlogsize = 100;
  756. cfg->auditlog_rotationtime = 1;
  757. cfg->auditlog_rotationunit = slapi_ch_strdup ("week");
  758. cfg->auditlog_rotationsync_enabled = LDAP_OFF;
  759. cfg->auditlog_rotationsynchour = 0;
  760. cfg->auditlog_rotationsyncmin = 0;
  761. cfg->auditlog_maxdiskspace = 100;
  762. cfg->auditlog_minfreespace = 5;
  763. cfg->auditlog_exptime = 1;
  764. cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
  765. init_config_get_and_set();
  766. }
  767. int
  768. g_get_global_lastmod()
  769. {
  770. return config_get_lastmod();
  771. }
  772. int g_get_slapd_security_on(){
  773. return config_get_security();
  774. }
  775. #ifdef _WIN32
  776. void libldap_init_debug_level(int *val_ptr)
  777. {
  778. module_ldap_debug = val_ptr;
  779. }
  780. #endif
  781. struct snmp_vars_t global_snmp_vars;
  782. struct snmp_vars_t * g_get_global_snmp_vars(){
  783. return &global_snmp_vars;
  784. }
  785. static slapdEntryPoints *sep = NULL;
  786. void
  787. set_dll_entry_points( slapdEntryPoints *p )
  788. {
  789. if ( NULL == sep )
  790. {
  791. sep = p;
  792. }
  793. }
  794. int
  795. get_entry_point( int ep_name, caddr_t *ep_addr )
  796. {
  797. int rc = 0;
  798. if(sep!=NULL)
  799. {
  800. switch ( ep_name ) {
  801. case ENTRY_POINT_PS_WAKEUP_ALL:
  802. *ep_addr = sep->sep_ps_wakeup_all;
  803. break;
  804. case ENTRY_POINT_PS_SERVICE:
  805. *ep_addr = sep->sep_ps_service;
  806. break;
  807. case ENTRY_POINT_DISCONNECT_SERVER:
  808. *ep_addr = sep->sep_disconnect_server;
  809. break;
  810. case ENTRY_POINT_SLAPD_SSL_CLIENT_INIT:
  811. *ep_addr = sep->sep_slapd_SSL_client_init;
  812. break;
  813. case ENTRY_POINT_SLAPD_SSL_INIT:
  814. *ep_addr = sep->sep_slapd_ssl_init;
  815. break;
  816. case ENTRY_POINT_SLAPD_SSL_INIT2:
  817. *ep_addr = sep->sep_slapd_ssl_init2;
  818. break;
  819. default:
  820. rc = -1;
  821. }
  822. }
  823. else
  824. {
  825. rc= -1;
  826. }
  827. return rc;
  828. }
  829. /*
  830. * Utility function called by many of the config_set_XXX() functions.
  831. * Returns a non-zero value if 'value' is NULL and zero if not.
  832. * Also constructs an error message in 'errorbuf' if value is NULL.
  833. * If or_zero_length is non-zero, zero length values are treated as
  834. * equivalent to NULL (i.e., they will cause a non-zero value to be
  835. * returned by this function).
  836. */
  837. static int
  838. config_value_is_null( const char *attrname, const char *value, char *errorbuf,
  839. int or_zero_length )
  840. {
  841. if ( NULL == value || ( or_zero_length && *value == '\0' )) {
  842. PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value",
  843. attrname );
  844. return 1;
  845. }
  846. return 0;
  847. }
  848. int
  849. config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
  850. int nPort;
  851. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  852. int retVal = LDAP_SUCCESS;
  853. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  854. return LDAP_OPERATIONS_ERROR;
  855. }
  856. nPort = atoi( port );
  857. if ( nPort == 0 ) {
  858. LDAPDebug( LDAP_DEBUG_ANY,
  859. "Information: Non-Secure Port Disabled, server only contactable via secure port\n", 0, 0, 0 );
  860. }
  861. else if (nPort > LDAP_PORT_MAX || nPort < 0 ) {
  862. retVal = LDAP_OPERATIONS_ERROR;
  863. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  864. "%s: %d is invalid, ports must range from 1 to %d",
  865. attrname, nPort, LDAP_PORT_MAX );
  866. }
  867. if ( apply ) {
  868. CFG_LOCK_WRITE(slapdFrontendConfig);
  869. slapdFrontendConfig->port = nPort;
  870. /* n_port = nPort; */
  871. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  872. }
  873. return retVal;
  874. }
  875. int
  876. config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply ) {
  877. int nPort = atoi ( port );
  878. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  879. int retVal = LDAP_SUCCESS;
  880. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  881. return LDAP_OPERATIONS_ERROR;
  882. }
  883. if (nPort > LDAP_PORT_MAX || nPort <= 0 ) {
  884. retVal = LDAP_OPERATIONS_ERROR;
  885. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  886. "%s: %d is invalid, ports must range from 1 to %d",
  887. attrname, nPort, LDAP_PORT_MAX );
  888. }
  889. if (apply) {
  890. CFG_LOCK_WRITE(slapdFrontendConfig);
  891. slapdFrontendConfig->secureport = nPort;
  892. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  893. }
  894. return retVal;
  895. }
  896. int
  897. config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
  898. int retVal = LDAP_SUCCESS;
  899. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  900. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  901. retVal = LDAP_OPERATIONS_ERROR;
  902. }
  903. /* first check the value, return an error if it's invalid */
  904. else if ( strcasecmp (value, "off") != 0 &&
  905. strcasecmp (value, "allowed") != 0 &&
  906. strcasecmp (value, "required")!= 0 ) {
  907. retVal = LDAP_OPERATIONS_ERROR;
  908. if( errorbuf )
  909. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  910. "%s: unsupported value: %s", attrname, value );
  911. return retVal;
  912. }
  913. else if ( !apply ) {
  914. /* return success now, if we aren't supposed to apply the change */
  915. return retVal;
  916. }
  917. CFG_LOCK_WRITE(slapdFrontendConfig);
  918. if ( !strcasecmp( value, "off" )) {
  919. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_OFF;
  920. }
  921. else if ( !strcasecmp( value, "allowed" )) {
  922. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_ALLOWED;
  923. }
  924. else if ( !strcasecmp( value, "required" )) {
  925. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_REQUIRED;
  926. }
  927. else {
  928. retVal = LDAP_OPERATIONS_ERROR;
  929. if( errorbuf )
  930. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  931. "%s: unsupported value: %s", attrname, value );
  932. }
  933. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  934. return retVal;
  935. }
  936. int
  937. config_set_ssl_check_hostname(const char *attrname, char *value,
  938. char *errorbuf, int apply)
  939. {
  940. int retVal = LDAP_SUCCESS;
  941. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  942. retVal = config_set_onoff(attrname,
  943. value,
  944. &(slapdFrontendConfig->ssl_check_hostname),
  945. errorbuf,
  946. apply);
  947. return retVal;
  948. }
  949. int
  950. config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  951. int retVal = LDAP_SUCCESS;
  952. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  953. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  954. return LDAP_OPERATIONS_ERROR;
  955. }
  956. if (apply) {
  957. CFG_LOCK_WRITE(slapdFrontendConfig);
  958. slapi_ch_free ( (void **) &(slapdFrontendConfig->localhost) );
  959. slapdFrontendConfig->localhost = slapi_ch_strdup ( value );
  960. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  961. }
  962. return retVal;
  963. }
  964. int
  965. config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  966. int retVal = LDAP_SUCCESS;
  967. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  968. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  969. return LDAP_OPERATIONS_ERROR;
  970. }
  971. if ( apply) {
  972. CFG_LOCK_WRITE(slapdFrontendConfig);
  973. slapi_ch_free ( (void **) &(slapdFrontendConfig->listenhost) );
  974. slapdFrontendConfig->listenhost = slapi_ch_strdup ( value );
  975. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  976. }
  977. return retVal;
  978. }
  979. int
  980. config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  981. int retVal = LDAP_SUCCESS;
  982. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  983. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  984. return LDAP_OPERATIONS_ERROR;
  985. }
  986. if ( apply ) {
  987. CFG_LOCK_WRITE(slapdFrontendConfig);
  988. slapi_ch_free ( (void **) &(slapdFrontendConfig->securelistenhost) );
  989. slapdFrontendConfig->securelistenhost = slapi_ch_strdup ( value );
  990. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  991. }
  992. return retVal;
  993. }
  994. int
  995. config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply ) {
  996. int retVal = LDAP_SUCCESS;
  997. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  998. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  999. return LDAP_OPERATIONS_ERROR;
  1000. }
  1001. if (apply) {
  1002. CFG_LOCK_WRITE(slapdFrontendConfig);
  1003. slapi_ch_free ( (void **) &(slapdFrontendConfig->srvtab) );
  1004. ldap_srvtab = slapi_ch_strdup ( value );
  1005. slapdFrontendConfig->srvtab = slapi_ch_strdup ( value );
  1006. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1007. }
  1008. return retVal;
  1009. }
  1010. int
  1011. config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1012. int retVal = LDAP_SUCCESS;
  1013. Slapi_Backend *be;
  1014. char *cookie;
  1015. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1016. int sizelimit = atoi ( value );
  1017. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1018. return LDAP_OPERATIONS_ERROR;
  1019. }
  1020. if ( sizelimit < -1 ) {
  1021. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: %d is too small",
  1022. attrname, sizelimit );
  1023. retVal = LDAP_OPERATIONS_ERROR;
  1024. return retVal;
  1025. }
  1026. if (apply) {
  1027. CFG_LOCK_WRITE(slapdFrontendConfig);
  1028. slapdFrontendConfig->sizelimit= sizelimit;
  1029. g_set_defsize (sizelimit);
  1030. cookie = NULL;
  1031. be = slapi_get_first_backend(&cookie);
  1032. while (be) {
  1033. be->be_sizelimit = slapdFrontendConfig->sizelimit;
  1034. be = slapi_get_next_backend(cookie);
  1035. }
  1036. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1037. slapi_ch_free ((void **)&cookie);
  1038. }
  1039. return retVal;
  1040. }
  1041. int
  1042. config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  1043. int retVal = LDAP_SUCCESS;
  1044. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1045. struct pw_scheme *new_scheme = NULL;
  1046. char * scheme_list = NULL;
  1047. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1048. return LDAP_OPERATIONS_ERROR;
  1049. }
  1050. scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  1051. new_scheme = pw_name2scheme(value);
  1052. if ( new_scheme == NULL) {
  1053. if ( scheme_list != NULL ) {
  1054. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1055. "%s: invalid scheme - %s. Valid schemes are: %s",
  1056. attrname, value, scheme_list );
  1057. } else {
  1058. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1059. "%s: invalid scheme - %s (no pwdstorage scheme"
  1060. " plugin loaded)",
  1061. attrname, value);
  1062. }
  1063. retVal = LDAP_OPERATIONS_ERROR;
  1064. slapi_ch_free_string(&scheme_list);
  1065. return retVal;
  1066. }
  1067. else if ( new_scheme->pws_enc == NULL )
  1068. {
  1069. /* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
  1070. compatibility with an Old Messaging Server that was setting passwords in the
  1071. directory already encrypted. The scheme cannot and don't encrypt password if
  1072. they are in clear. We don't take it */
  1073. if ( scheme_list != NULL ) {
  1074. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1075. "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
  1076. }
  1077. retVal = LDAP_UNWILLING_TO_PERFORM;
  1078. slapi_ch_free_string(&scheme_list);
  1079. return retVal;
  1080. }
  1081. if ( apply ) {
  1082. CFG_LOCK_WRITE(slapdFrontendConfig);
  1083. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  1084. slapdFrontendConfig->pw_storagescheme = new_scheme;
  1085. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1086. }
  1087. slapi_ch_free_string(&scheme_list);
  1088. return retVal;
  1089. }
  1090. int
  1091. config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1092. int retVal = LDAP_SUCCESS;
  1093. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1094. retVal = config_set_onoff ( attrname,
  1095. value,
  1096. &(slapdFrontendConfig->pw_policy.pw_change),
  1097. errorbuf,
  1098. apply);
  1099. if (retVal == LDAP_SUCCESS) {
  1100. /* LP: Update ACI to reflect the value ! */
  1101. if (apply)
  1102. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1103. !slapdFrontendConfig->pw_policy.pw_must_change);
  1104. }
  1105. return retVal;
  1106. }
  1107. int
  1108. config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) {
  1109. int retVal = LDAP_SUCCESS;
  1110. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1111. retVal = config_set_onoff ( attrname,
  1112. value,
  1113. &(slapdFrontendConfig->pw_policy.pw_history),
  1114. errorbuf,
  1115. apply);
  1116. return retVal;
  1117. }
  1118. int
  1119. config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1120. int retVal = LDAP_SUCCESS;
  1121. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1122. retVal = config_set_onoff ( attrname,
  1123. value,
  1124. &(slapdFrontendConfig->pw_policy.pw_must_change),
  1125. errorbuf,
  1126. apply);
  1127. if (retVal == LDAP_SUCCESS) {
  1128. /* LP: Update ACI to reflect the value ! */
  1129. if (apply)
  1130. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1131. !slapdFrontendConfig->pw_policy.pw_must_change);
  1132. }
  1133. return retVal;
  1134. }
  1135. int
  1136. config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) {
  1137. int retVal = LDAP_SUCCESS;
  1138. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1139. retVal = config_set_onoff ( attrname,
  1140. value,
  1141. &(slapdFrontendConfig->pwpolicy_local),
  1142. errorbuf,
  1143. apply);
  1144. return retVal;
  1145. }
  1146. int
  1147. config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) {
  1148. int retVal = LDAP_SUCCESS;
  1149. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1150. retVal = config_set_onoff ( attrname,
  1151. value,
  1152. &(slapdFrontendConfig->pw_policy.pw_syntax),
  1153. errorbuf,
  1154. apply);
  1155. return retVal;
  1156. }
  1157. int
  1158. config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  1159. int retVal = LDAP_SUCCESS, minLength = 0;
  1160. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1161. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1162. return LDAP_OPERATIONS_ERROR;
  1163. }
  1164. minLength = atoi(value);
  1165. if ( minLength < 2 || minLength > 512 ) {
  1166. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1167. "password minimum length \"%s\" is invalid. "
  1168. "The minimum length must range from 2 to 512.",
  1169. value );
  1170. retVal = LDAP_OPERATIONS_ERROR;
  1171. return retVal;
  1172. }
  1173. if ( apply ) {
  1174. CFG_LOCK_WRITE(slapdFrontendConfig);
  1175. slapdFrontendConfig->pw_policy.pw_minlength = minLength;
  1176. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1177. }
  1178. return retVal;
  1179. }
  1180. int
  1181. config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int apply ) {
  1182. int retVal = LDAP_SUCCESS, maxFailure = 0;
  1183. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1184. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1185. return LDAP_OPERATIONS_ERROR;
  1186. }
  1187. maxFailure = atoi(value);
  1188. if ( maxFailure <= 0 || maxFailure > 32767 ) {
  1189. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1190. "password maximum retry \"%s\" is invalid. "
  1191. "Password maximum failure must range from 1 to 32767",
  1192. value );
  1193. retVal = LDAP_OPERATIONS_ERROR;
  1194. return retVal;
  1195. }
  1196. if ( apply ) {
  1197. CFG_LOCK_WRITE(slapdFrontendConfig);
  1198. slapdFrontendConfig->pw_policy.pw_maxfailure = maxFailure;
  1199. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1200. }
  1201. return retVal;
  1202. }
  1203. int
  1204. config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int apply ) {
  1205. int retVal = LDAP_SUCCESS, history = 0;
  1206. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1207. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1208. return LDAP_OPERATIONS_ERROR;
  1209. }
  1210. history = atoi(value);
  1211. if ( history < 2 || history > 24 ) {
  1212. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1213. "password history length \"%s\" is invalid. "
  1214. "The password history must range from 2 to 24",
  1215. value );
  1216. retVal = LDAP_OPERATIONS_ERROR;
  1217. return retVal;
  1218. }
  1219. if ( apply ) {
  1220. CFG_LOCK_WRITE(slapdFrontendConfig);
  1221. slapdFrontendConfig->pw_policy.pw_inhistory = history;
  1222. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1223. }
  1224. return retVal;
  1225. }
  1226. int
  1227. config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, int apply ) {
  1228. int retVal = LDAP_SUCCESS;
  1229. long duration = 0; /* in minutes */
  1230. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1231. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1232. return LDAP_OPERATIONS_ERROR;
  1233. }
  1234. /* in seconds */
  1235. duration = strtol (value, NULL, 0);
  1236. if ( duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1237. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1238. "password lockout duration \"%s\" seconds is invalid. ",
  1239. value );
  1240. retVal = LDAP_OPERATIONS_ERROR;
  1241. return retVal;
  1242. }
  1243. if ( apply ) {
  1244. slapdFrontendConfig->pw_policy.pw_lockduration = duration;
  1245. }
  1246. return retVal;
  1247. }
  1248. int
  1249. config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorbuf, int apply ) {
  1250. int retVal = LDAP_SUCCESS;
  1251. long duration = 0; /* in minutes */
  1252. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1253. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1254. return LDAP_OPERATIONS_ERROR;
  1255. }
  1256. /* in seconds */
  1257. duration = strtol (value, NULL, 0);
  1258. if ( duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1259. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1260. "password reset count duration \"%s\" seconds is invalid. ",
  1261. value );
  1262. retVal = LDAP_OPERATIONS_ERROR;
  1263. return retVal;
  1264. }
  1265. if ( apply ) {
  1266. slapdFrontendConfig->pw_policy.pw_resetfailurecount = duration;
  1267. }
  1268. return retVal;
  1269. }
  1270. int
  1271. config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
  1272. int retVal = LDAP_SUCCESS;
  1273. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1274. retVal = config_set_onoff ( attrname,
  1275. value,
  1276. &(slapdFrontendConfig->pw_is_global_policy),
  1277. errorbuf,
  1278. apply);
  1279. return retVal;
  1280. }
  1281. int
  1282. config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) {
  1283. int retVal = LDAP_SUCCESS;
  1284. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1285. retVal = config_set_onoff ( attrname,
  1286. value,
  1287. &(slapdFrontendConfig->pw_policy.pw_exp),
  1288. errorbuf,
  1289. apply);
  1290. return retVal;
  1291. }
  1292. int
  1293. config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) {
  1294. int retVal = LDAP_SUCCESS;
  1295. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1296. retVal = config_set_onoff ( attrname,
  1297. value,
  1298. &(slapdFrontendConfig->pw_policy.pw_unlock),
  1299. errorbuf,
  1300. apply);
  1301. return retVal;
  1302. }
  1303. int
  1304. config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) {
  1305. int retVal = LDAP_SUCCESS;
  1306. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1307. retVal = config_set_onoff ( attrname,
  1308. value,
  1309. &(slapdFrontendConfig->pw_policy.pw_lockout),
  1310. errorbuf,
  1311. apply);
  1312. return retVal;
  1313. }
  1314. int
  1315. config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1316. int retVal = LDAP_SUCCESS, gracelimit = 0;
  1317. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1318. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1319. return LDAP_OPERATIONS_ERROR;
  1320. }
  1321. gracelimit = atoi(value);
  1322. if ( gracelimit < 0 ) {
  1323. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1324. "password grace limit \"%s\" is invalid.",
  1325. value );
  1326. retVal = LDAP_OPERATIONS_ERROR;
  1327. return retVal;
  1328. }
  1329. if ( apply ) {
  1330. CFG_LOCK_WRITE(slapdFrontendConfig);
  1331. slapdFrontendConfig->pw_policy.pw_gracelimit = gracelimit;
  1332. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1333. }
  1334. return retVal;
  1335. }
  1336. int
  1337. config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) {
  1338. int retVal = LDAP_SUCCESS;
  1339. Slapi_Backend *be = NULL;
  1340. char *cookie;
  1341. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1342. retVal = config_set_onoff ( attrname,
  1343. value,
  1344. &(slapdFrontendConfig->lastmod),
  1345. errorbuf,
  1346. apply);
  1347. if ( retVal == LDAP_SUCCESS && apply ) {
  1348. CFG_LOCK_WRITE(slapdFrontendConfig);
  1349. cookie = NULL;
  1350. be = slapi_get_first_backend (&cookie);
  1351. while (be) {
  1352. be->be_lastmod = slapdFrontendConfig->lastmod;
  1353. be = slapi_get_next_backend (cookie);
  1354. }
  1355. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1356. slapi_ch_free ((void **)&cookie);
  1357. }
  1358. return retVal;
  1359. }
  1360. int
  1361. config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) {
  1362. int retVal = LDAP_SUCCESS;
  1363. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1364. retVal = config_set_onoff ( attrname,
  1365. value,
  1366. &(slapdFrontendConfig->nagle),
  1367. errorbuf,
  1368. apply);
  1369. return retVal;
  1370. }
  1371. int
  1372. config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) {
  1373. int retVal = LDAP_SUCCESS;
  1374. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1375. retVal = config_set_onoff ( attrname,
  1376. value,
  1377. &(slapdFrontendConfig->accesscontrol),
  1378. errorbuf,
  1379. apply);
  1380. return retVal;
  1381. }
  1382. int
  1383. config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) {
  1384. int retVal = LDAP_SUCCESS;
  1385. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1386. retVal = config_set_onoff ( attrname,
  1387. value,
  1388. &(slapdFrontendConfig->return_exact_case),
  1389. errorbuf,
  1390. apply);
  1391. return retVal;
  1392. }
  1393. int
  1394. config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) {
  1395. int retVal = LDAP_SUCCESS;
  1396. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1397. retVal = config_set_onoff ( attrname,
  1398. value,
  1399. &(slapdFrontendConfig->result_tweak),
  1400. errorbuf,
  1401. apply);
  1402. return retVal;
  1403. }
  1404. int
  1405. config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) {
  1406. int retVal = LDAP_SUCCESS;
  1407. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1408. retVal = config_set_onoff ( attrname,
  1409. value,
  1410. &(slapdFrontendConfig->security),
  1411. errorbuf,
  1412. apply);
  1413. return retVal;
  1414. }
  1415. static int
  1416. config_set_onoff ( const char *attrname, char *value, int *configvalue,
  1417. char *errorbuf, int apply )
  1418. {
  1419. int retVal = LDAP_SUCCESS;
  1420. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1421. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1422. return LDAP_OPERATIONS_ERROR;
  1423. }
  1424. if ( strcasecmp ( value, "on" ) != 0 &&
  1425. strcasecmp ( value, "off") != 0 ) {
  1426. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1427. "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
  1428. attrname, value );
  1429. retVal = LDAP_OPERATIONS_ERROR;
  1430. }
  1431. if ( !apply ) {
  1432. /* we can return now if we aren't applying the changes */
  1433. return retVal;
  1434. }
  1435. CFG_LOCK_WRITE(slapdFrontendConfig);
  1436. if ( strcasecmp ( value, "on" ) == 0 ) {
  1437. *configvalue = LDAP_ON;
  1438. }
  1439. else if ( strcasecmp ( value, "off" ) == 0 ) {
  1440. *configvalue = LDAP_OFF;
  1441. }
  1442. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1443. return retVal;
  1444. }
  1445. int
  1446. config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) {
  1447. int retVal = LDAP_SUCCESS;
  1448. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1449. retVal = config_set_onoff ( attrname,
  1450. value,
  1451. &(slapdFrontendConfig->readonly),
  1452. errorbuf,
  1453. apply );
  1454. return retVal;
  1455. }
  1456. int
  1457. config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
  1458. int retVal = LDAP_SUCCESS;
  1459. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1460. retVal = config_set_onoff ( attrname,
  1461. value,
  1462. &(slapdFrontendConfig->schemacheck),
  1463. errorbuf,
  1464. apply);
  1465. return retVal;
  1466. }
  1467. int
  1468. config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) {
  1469. int retVal = LDAP_SUCCESS;
  1470. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1471. retVal = config_set_onoff ( attrname,
  1472. value,
  1473. &(slapdFrontendConfig->ds4_compatible_schema),
  1474. errorbuf,
  1475. apply);
  1476. return retVal;
  1477. }
  1478. int
  1479. config_set_schema_ignore_trailing_spaces( const char *attrname, char *value,
  1480. char *errorbuf, int apply ) {
  1481. int retVal = LDAP_SUCCESS;
  1482. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1483. retVal = config_set_onoff ( attrname,
  1484. value,
  1485. &(slapdFrontendConfig->schema_ignore_trailing_spaces),
  1486. errorbuf,
  1487. apply);
  1488. return retVal;
  1489. }
  1490. int
  1491. config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) {
  1492. int retVal = LDAP_SUCCESS;
  1493. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1494. retVal = config_set_onoff ( attrname,
  1495. value,
  1496. &(slapdFrontendConfig->enquote_sup_oc),
  1497. errorbuf,
  1498. apply);
  1499. return retVal;
  1500. }
  1501. int
  1502. config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ) {
  1503. int retVal = LDAP_SUCCESS;
  1504. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1505. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1506. return LDAP_OPERATIONS_ERROR;
  1507. }
  1508. if ( apply ) {
  1509. CFG_LOCK_WRITE(slapdFrontendConfig);
  1510. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootdn) );
  1511. slapdFrontendConfig->rootdn = slapi_dn_normalize (slapi_ch_strdup ( value ) );
  1512. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1513. }
  1514. return retVal;
  1515. }
  1516. int
  1517. config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply ) {
  1518. int retVal = LDAP_SUCCESS;
  1519. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1520. struct pw_scheme *is_hashed = NULL;
  1521. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1522. return LDAP_OPERATIONS_ERROR;
  1523. }
  1524. if (!apply) {
  1525. return retVal;
  1526. }
  1527. CFG_LOCK_WRITE(slapdFrontendConfig);
  1528. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootpw) );
  1529. is_hashed = pw_val2scheme ( value, NULL, 0 );
  1530. if ( is_hashed ) {
  1531. slapdFrontendConfig->rootpw = slapi_ch_strdup ( value );
  1532. free_pw_scheme(is_hashed);
  1533. }
  1534. else {
  1535. /* pwd enc func returns slapi_ch_malloc memory */
  1536. slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
  1537. }
  1538. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1539. return retVal;
  1540. }
  1541. int
  1542. config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  1543. int retVal = LDAP_SUCCESS;
  1544. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1545. struct pw_scheme *new_scheme = NULL;
  1546. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1547. return LDAP_OPERATIONS_ERROR;
  1548. }
  1549. new_scheme = pw_name2scheme ( value );
  1550. if (new_scheme == NULL ) {
  1551. char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  1552. if ( scheme_list != NULL ) {
  1553. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1554. "%s: invalid scheme - %s. Valid schemes are: %s",
  1555. attrname, value, scheme_list );
  1556. } else {
  1557. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1558. "%s: invalid scheme - %s (no pwdstorage scheme"
  1559. " plugin loaded)", attrname, value);
  1560. }
  1561. slapi_ch_free_string(&scheme_list);
  1562. retVal = LDAP_OPERATIONS_ERROR;
  1563. return retVal;
  1564. }
  1565. CFG_LOCK_WRITE(slapdFrontendConfig);
  1566. free_pw_scheme(slapdFrontendConfig->rootpwstoragescheme);
  1567. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  1568. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1569. return retVal;
  1570. }
  1571. /*
  1572. * kexcoff: to replace default initialization in FrontendConfig_init()
  1573. */
  1574. int config_set_storagescheme() {
  1575. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1576. struct pw_scheme *new_scheme = NULL;
  1577. CFG_LOCK_WRITE(slapdFrontendConfig);
  1578. new_scheme = pw_name2scheme("SSHA");
  1579. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  1580. slapdFrontendConfig->pw_storagescheme = new_scheme;
  1581. new_scheme = pw_name2scheme("SSHA");
  1582. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  1583. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1584. return ( new_scheme == NULL );
  1585. }
  1586. #ifndef _WIN32
  1587. int
  1588. config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply ) {
  1589. int retVal = LDAP_SUCCESS;
  1590. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1591. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1592. return LDAP_OPERATIONS_ERROR;
  1593. }
  1594. if (apply) {
  1595. CFG_LOCK_WRITE(slapdFrontendConfig);
  1596. slapi_ch_free ( (void **) &slapdFrontendConfig->localuser );
  1597. slapdFrontendConfig->localuser = slapi_ch_strdup ( value );
  1598. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1599. }
  1600. return retVal;
  1601. }
  1602. #endif /* _WIN32 */
  1603. int
  1604. config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply ) {
  1605. int retVal = LDAP_SUCCESS;
  1606. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1607. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1608. return LDAP_OPERATIONS_ERROR;
  1609. }
  1610. if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
  1611. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
  1612. retVal = LDAP_OPERATIONS_ERROR;
  1613. return retVal;
  1614. }
  1615. if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
  1616. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
  1617. retVal = LDAP_OPERATIONS_ERROR;
  1618. return retVal;
  1619. }
  1620. if ( apply) {
  1621. CFG_LOCK_WRITE(slapdFrontendConfig);
  1622. slapdFrontendConfig->workingdir = slapi_ch_strdup ( value );
  1623. #ifdef _WIN32
  1624. dostounixpath(slapdFrontendConfig->workingdir);
  1625. #endif /* _WIN32 */
  1626. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1627. }
  1628. return retVal;
  1629. }
  1630. int
  1631. config_set_instancedir( const char *attrname, char *value, char *errorbuf, int apply ) {
  1632. int retVal = LDAP_SUCCESS;
  1633. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1634. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1635. return LDAP_OPERATIONS_ERROR;
  1636. }
  1637. if ( PR_Access ( value, PR_ACCESS_READ_OK ) != 0 ) {
  1638. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Directory \"%s\" is not accessible.", value );
  1639. retVal = LDAP_OPERATIONS_ERROR;
  1640. return retVal;
  1641. }
  1642. if ( apply) {
  1643. CFG_LOCK_WRITE(slapdFrontendConfig);
  1644. slapdFrontendConfig->instancedir = slapi_ch_strdup ( value );
  1645. #ifdef _WIN32
  1646. dostounixpath(slapdFrontendConfig->instancedir);
  1647. #endif /* _WIN32 */
  1648. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1649. /* Set the slapd type also */
  1650. config_set_slapd_type ();
  1651. /* Set the configdir if not set */
  1652. if (!slapdFrontendConfig->configdir)
  1653. {
  1654. char newdir[MAXPATHLEN+1];
  1655. PR_snprintf ( newdir, sizeof(newdir), "%s/%s",
  1656. slapdFrontendConfig->instancedir, CONFIG_SUBDIR_NAME);
  1657. retVal = config_set_configdir(attrname, newdir, errorbuf, apply);
  1658. }
  1659. }
  1660. return retVal;
  1661. }
  1662. /* alias of encryption key and certificate files is now retrieved through */
  1663. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  1664. /* where this function is still used to set the global variable */
  1665. int
  1666. config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply ) {
  1667. int retVal = LDAP_SUCCESS;
  1668. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1669. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1670. return LDAP_OPERATIONS_ERROR;
  1671. }
  1672. if (apply) {
  1673. CFG_LOCK_WRITE(slapdFrontendConfig);
  1674. slapi_ch_free ( (void **) &(slapdFrontendConfig->encryptionalias) );
  1675. slapdFrontendConfig->encryptionalias = slapi_ch_strdup ( value );
  1676. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1677. }
  1678. return retVal;
  1679. }
  1680. int
  1681. config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply ) {
  1682. int retVal = LDAP_SUCCESS, threadnum = 0;
  1683. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1684. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1685. return LDAP_OPERATIONS_ERROR;
  1686. }
  1687. threadnum = atoi ( value );
  1688. if ( threadnum < 1 || threadnum > 65535 ) {
  1689. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum thread number must range from 1 to 65535", attrname, threadnum );
  1690. retVal = LDAP_OPERATIONS_ERROR;
  1691. }
  1692. if (apply) {
  1693. CFG_LOCK_WRITE(slapdFrontendConfig);
  1694. /* max_threads = threadnum; */
  1695. slapdFrontendConfig->threadnumber = threadnum;
  1696. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1697. }
  1698. return retVal;
  1699. }
  1700. int
  1701. config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply ) {
  1702. int retVal = LDAP_SUCCESS, maxthreadnum = 0;
  1703. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1704. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1705. return LDAP_OPERATIONS_ERROR;
  1706. }
  1707. maxthreadnum = atoi ( value );
  1708. if ( maxthreadnum < 1 || maxthreadnum > 65535 ) {
  1709. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum thread number per connection must range from 1 to 65535", attrname, maxthreadnum );
  1710. retVal = LDAP_OPERATIONS_ERROR;
  1711. }
  1712. if (apply) {
  1713. CFG_LOCK_WRITE(slapdFrontendConfig);
  1714. /* max_threads_per_conn = maxthreadnum; */
  1715. slapdFrontendConfig->maxthreadsperconn = maxthreadnum;
  1716. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1717. }
  1718. return retVal;
  1719. }
  1720. #if !defined(_WIN32) && !defined(AIX)
  1721. #include <sys/resource.h>
  1722. int
  1723. config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  1724. int retVal = LDAP_SUCCESS, nValue = 0;
  1725. int maxVal = 65535;
  1726. struct rlimit rlp;
  1727. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1728. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1729. return LDAP_OPERATIONS_ERROR;
  1730. }
  1731. nValue = atoi ( value );
  1732. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  1733. maxVal = (int)rlp.rlim_max;
  1734. }
  1735. if ( nValue < 1 || nValue > maxVal ) {
  1736. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum file descriptors must range from 1 to %d (the current process limit)",
  1737. attrname, nValue, maxVal );
  1738. if ( nValue < 1 ) {
  1739. retVal = LDAP_OPERATIONS_ERROR;
  1740. } else {
  1741. nValue = maxVal;
  1742. retVal = LDAP_UNWILLING_TO_PERFORM;
  1743. }
  1744. }
  1745. if (apply) {
  1746. CFG_LOCK_WRITE(slapdFrontendConfig);
  1747. slapdFrontendConfig->maxdescriptors = nValue;
  1748. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1749. }
  1750. return retVal;
  1751. }
  1752. #endif /* !_WIN32 && !AIX */
  1753. int
  1754. config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int apply ) {
  1755. int retVal = LDAP_SUCCESS, nValue = 0;
  1756. int maxVal = 65535;
  1757. #ifndef _WIN32
  1758. struct rlimit rlp;
  1759. #endif
  1760. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1761. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1762. return LDAP_OPERATIONS_ERROR;
  1763. }
  1764. nValue = atoi ( value );
  1765. #ifdef _WIN32
  1766. if ( nValue < 1 || nValue > 0xfffffe ) {
  1767. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, connection table size must range from 1 to 0xfffffe", attrname, nValue );
  1768. retVal = LDAP_OPERATIONS_ERROR;
  1769. }
  1770. #elif !defined(AIX)
  1771. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  1772. maxVal = (int)rlp.rlim_max;
  1773. }
  1774. if ( nValue < 1 || nValue > maxVal ) {
  1775. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, connection table size must range from 1 to %d (the current process maxdescriptors limit)",
  1776. attrname, nValue, maxVal );
  1777. if ( nValue < 1 ) {
  1778. retVal = LDAP_OPERATIONS_ERROR;
  1779. } else {
  1780. nValue = maxVal;
  1781. retVal = LDAP_UNWILLING_TO_PERFORM;
  1782. }
  1783. }
  1784. #endif
  1785. if (apply) {
  1786. CFG_LOCK_WRITE(slapdFrontendConfig);
  1787. slapdFrontendConfig->conntablesize = nValue;
  1788. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1789. }
  1790. return retVal;
  1791. }
  1792. int
  1793. config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  1794. int retVal = LDAP_SUCCESS, nValue = 0;
  1795. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1796. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1797. return LDAP_OPERATIONS_ERROR;
  1798. }
  1799. nValue = atoi ( value );
  1800. if ( nValue < 1 || nValue > 65535 ) {
  1801. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, reserved file descriptors must range from 1 to 65535", attrname, nValue );
  1802. retVal = LDAP_OPERATIONS_ERROR;
  1803. }
  1804. if (apply) {
  1805. CFG_LOCK_WRITE(slapdFrontendConfig);
  1806. slapdFrontendConfig->reservedescriptors = nValue;
  1807. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1808. }
  1809. return retVal;
  1810. }
  1811. int
  1812. config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  1813. int retVal = LDAP_SUCCESS, nValue = 0;
  1814. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1815. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1816. return LDAP_OPERATIONS_ERROR;
  1817. }
  1818. nValue = atoi ( value );
  1819. #if defined(IRIX)
  1820. /* on IRIX poll can only handle timeouts up to
  1821. 2147483 without failing, cap it at 30 minutes */
  1822. if ( nValue > SLAPD_DEFAULT_IOBLOCK_TIMEOUT ) {
  1823. nValue = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  1824. }
  1825. #endif /* IRIX */
  1826. if ( apply ) {
  1827. CFG_LOCK_WRITE(slapdFrontendConfig);
  1828. slapdFrontendConfig->ioblocktimeout = nValue;
  1829. /* g_ioblock_timeout= nValue; */
  1830. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1831. }
  1832. return retVal;
  1833. }
  1834. int
  1835. config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  1836. int retVal = LDAP_SUCCESS, nValue = 0;
  1837. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1838. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1839. return LDAP_OPERATIONS_ERROR;
  1840. }
  1841. nValue = atoi ( value );
  1842. if (apply) {
  1843. CFG_LOCK_WRITE(slapdFrontendConfig);
  1844. slapdFrontendConfig->idletimeout = nValue;
  1845. /* g_idle_timeout= nValue; */
  1846. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1847. }
  1848. return retVal;
  1849. }
  1850. int
  1851. config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbuf, int apply ) {
  1852. int retVal = LDAP_SUCCESS, nValue = 0;
  1853. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1854. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1855. return LDAP_OPERATIONS_ERROR;
  1856. }
  1857. nValue = atoi ( value );
  1858. if ( nValue < 1 ) {
  1859. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1860. "%s: invalid value %d, must be a positive number",
  1861. attrname, nValue );
  1862. }
  1863. if (apply) {
  1864. CFG_LOCK_WRITE(slapdFrontendConfig);
  1865. slapdFrontendConfig->groupevalnestlevel = nValue;
  1866. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1867. }
  1868. return retVal;
  1869. }
  1870. int
  1871. config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply ) {
  1872. int retVal = LDAP_SUCCESS;
  1873. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1874. if ( config_value_is_null( attrname, (char *)value, errorbuf, 0 )) {
  1875. return LDAP_OPERATIONS_ERROR;
  1876. }
  1877. if (apply) {
  1878. CFG_LOCK_WRITE(slapdFrontendConfig);
  1879. g_set_default_referral( value );
  1880. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1881. }
  1882. return retVal;
  1883. }
  1884. int
  1885. config_set_userat( const char *attrname, char *value, char *errorbuf, int apply ) {
  1886. int retVal = LDAP_SUCCESS;
  1887. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1888. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1889. return LDAP_OPERATIONS_ERROR;
  1890. }
  1891. if ( apply ) {
  1892. CFG_LOCK_WRITE(slapdFrontendConfig);
  1893. slapi_ch_free( (void **) &(slapdFrontendConfig->userat) );
  1894. slapdFrontendConfig->userat = slapi_ch_strdup(value);
  1895. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1896. }
  1897. return retVal;
  1898. }
  1899. int
  1900. config_set_timelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1901. int retVal = LDAP_SUCCESS, nVal = 0;
  1902. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1903. Slapi_Backend *be = NULL;
  1904. char *cookie;
  1905. *errorbuf = 0;
  1906. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1907. return LDAP_OPERATIONS_ERROR;
  1908. }
  1909. nVal = atoi(value);
  1910. if ( nVal < 0 ) {
  1911. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1912. "%s: invalid value %d", attrname, nVal );
  1913. }
  1914. if ( apply ) {
  1915. CFG_LOCK_WRITE(slapdFrontendConfig);
  1916. g_set_deftime ( nVal );
  1917. slapdFrontendConfig->timelimit = nVal;
  1918. be = slapi_get_first_backend (&cookie);
  1919. while (be) {
  1920. be->be_timelimit = slapdFrontendConfig->timelimit;
  1921. be = slapi_get_next_backend (cookie);
  1922. }
  1923. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1924. slapi_ch_free ((void **)&cookie);
  1925. }
  1926. return retVal;
  1927. }
  1928. int
  1929. config_set_useroc( const char *attrname, char *value, char *errorbuf, int apply ) {
  1930. int retVal = LDAP_SUCCESS;
  1931. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1932. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1933. return LDAP_OPERATIONS_ERROR;
  1934. }
  1935. if ( apply ) {
  1936. CFG_LOCK_WRITE(slapdFrontendConfig);
  1937. slapi_ch_free ( (void **) &(slapdFrontendConfig->useroc) );
  1938. slapdFrontendConfig->useroc = slapi_ch_strdup( value );
  1939. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1940. }
  1941. return retVal;
  1942. }
  1943. int
  1944. config_set_accesslog( const char *attrname, char *value, char *errorbuf, int apply ) {
  1945. int retVal = LDAP_SUCCESS;
  1946. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1947. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1948. return LDAP_OPERATIONS_ERROR;
  1949. }
  1950. retVal = log_update_accesslogdir ( value, apply );
  1951. if ( retVal != LDAP_SUCCESS ) {
  1952. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1953. "Cannot open accesslog directory \"%s\", client accesses will "
  1954. "not be logged.", value );
  1955. }
  1956. if ( apply ) {
  1957. CFG_LOCK_WRITE(slapdFrontendConfig);
  1958. slapi_ch_free ( (void **) &(slapdFrontendConfig->accesslog) );
  1959. slapdFrontendConfig->accesslog = slapi_ch_strdup ( value );
  1960. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1961. }
  1962. return retVal;
  1963. }
  1964. int
  1965. config_set_errorlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  1966. int retVal = LDAP_SUCCESS;
  1967. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1968. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1969. return LDAP_OPERATIONS_ERROR;
  1970. }
  1971. retVal = log_update_errorlogdir ( value, apply );
  1972. if ( retVal != LDAP_SUCCESS ) {
  1973. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1974. "Cannot open errorlog directory \"%s\", errors will "
  1975. "not be logged.", value );
  1976. }
  1977. if ( apply ) {
  1978. CFG_LOCK_WRITE(slapdFrontendConfig);
  1979. slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
  1980. slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
  1981. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1982. }
  1983. return retVal;
  1984. }
  1985. int
  1986. config_set_auditlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  1987. int retVal = LDAP_SUCCESS;
  1988. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1989. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1990. return LDAP_OPERATIONS_ERROR;
  1991. }
  1992. retVal = log_update_auditlogdir ( value, apply );
  1993. if ( retVal != LDAP_SUCCESS ) {
  1994. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1995. "Cannot open auditlog directory \"%s\"", value );
  1996. }
  1997. if ( apply ) {
  1998. CFG_LOCK_WRITE(slapdFrontendConfig);
  1999. slapi_ch_free ( (void **) &(slapdFrontendConfig->auditlog) );
  2000. slapdFrontendConfig->auditlog = slapi_ch_strdup ( value );
  2001. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2002. }
  2003. return retVal;
  2004. }
  2005. int
  2006. config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2007. int retVal = LDAP_SUCCESS;
  2008. long age;
  2009. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2010. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2011. return LDAP_OPERATIONS_ERROR;
  2012. }
  2013. /* age in seconds */
  2014. age = strtol(value, NULL, 0 );
  2015. if ( age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  2016. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2017. "password maximum age \"%s\" seconds is invalid. ",
  2018. value );
  2019. retVal = LDAP_OPERATIONS_ERROR;
  2020. return retVal;
  2021. }
  2022. if ( apply ) {
  2023. slapdFrontendConfig->pw_policy.pw_maxage = age;
  2024. }
  2025. return retVal;
  2026. }
  2027. int
  2028. config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2029. int retVal = LDAP_SUCCESS;
  2030. long age;
  2031. char *endPtr = NULL;
  2032. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2033. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2034. return LDAP_OPERATIONS_ERROR;
  2035. }
  2036. /* age in seconds */
  2037. age = strtol(value, &endPtr, 0 );
  2038. /* endPtr should never be NULL, but we check just in case; if the
  2039. value contains no digits, or a string that does not begin with
  2040. a valid digit (e.g. "z2"), the days will be 0, and endPtr will
  2041. point to the beginning of value; if days contains at least 1
  2042. valid digit string, endPtr will point to the character after
  2043. the end of the first valid digit string in value. Example:
  2044. value = " 2 3 " endPtr will point at the space character
  2045. between the 2 and the 3. So, we should be able to simply
  2046. check to see if the character at *(endPtr - 1) is a digit.
  2047. */
  2048. if ( (age < 0) ||
  2049. (age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
  2050. (endPtr == NULL) || (endPtr == value) || !isdigit(*(endPtr-1)) ) {
  2051. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2052. "password minimum age \"%s\" seconds is invalid. ",
  2053. value );
  2054. retVal = LDAP_OPERATIONS_ERROR;
  2055. return retVal;
  2056. }
  2057. if ( apply ) {
  2058. slapdFrontendConfig->pw_policy.pw_minage = age;
  2059. }
  2060. return retVal;
  2061. }
  2062. int
  2063. config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int apply ) {
  2064. int retVal = LDAP_SUCCESS;
  2065. long sec;
  2066. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2067. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2068. return LDAP_OPERATIONS_ERROR;
  2069. }
  2070. /* in seconds */
  2071. sec = strtol(value, NULL, 0);
  2072. if (sec < 0) {
  2073. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2074. "password warning age \"%s\" seconds is invalid, password warning "
  2075. "age must be >= 0 seconds",
  2076. value );
  2077. retVal = LDAP_OPERATIONS_ERROR;
  2078. return retVal;
  2079. }
  2080. /* translate to seconds */
  2081. if ( apply ) {
  2082. slapdFrontendConfig->pw_policy.pw_warning = sec;
  2083. }
  2084. return retVal;
  2085. }
  2086. int
  2087. config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2088. int retVal = LDAP_SUCCESS, level = 0;
  2089. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2090. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2091. return LDAP_OPERATIONS_ERROR;
  2092. }
  2093. if ( apply ) {
  2094. CFG_LOCK_WRITE(slapdFrontendConfig);
  2095. level = atoi ( value );
  2096. level |= LDAP_DEBUG_ANY;
  2097. #ifdef _WIN32
  2098. *module_ldap_debug = level;
  2099. #else
  2100. slapd_ldap_debug = level;
  2101. #endif
  2102. slapdFrontendConfig->errorloglevel = level;
  2103. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2104. }
  2105. return retVal;
  2106. }
  2107. int
  2108. config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2109. int retVal = LDAP_SUCCESS, level = 0;
  2110. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2111. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2112. return LDAP_OPERATIONS_ERROR;
  2113. }
  2114. if ( apply ) {
  2115. CFG_LOCK_WRITE(slapdFrontendConfig);
  2116. level = atoi ( value );
  2117. g_set_accesslog_level ( level );
  2118. slapdFrontendConfig->accessloglevel = level;
  2119. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2120. }
  2121. return retVal;
  2122. }
  2123. /* set the referral-mode url (which puts us into referral mode) */
  2124. int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply)
  2125. {
  2126. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2127. slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
  2128. if ((!url) || (!url[0])) {
  2129. strcpy(errorbuf, "referral url must have a value");
  2130. return LDAP_OPERATIONS_ERROR;
  2131. }
  2132. if (apply) {
  2133. CFG_LOCK_WRITE(slapdFrontendConfig);
  2134. slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
  2135. slapdFrontendConfig->refer_mode = REFER_MODE_ON;
  2136. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2137. }
  2138. return LDAP_SUCCESS;
  2139. }
  2140. int
  2141. config_set_versionstring( const char *attrname, char *version, char *errorbuf, int apply ) {
  2142. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2143. if ((!version) || (!version[0])) {
  2144. PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
  2145. return LDAP_OPERATIONS_ERROR;
  2146. }
  2147. if (apply) {
  2148. CFG_LOCK_WRITE(slapdFrontendConfig);
  2149. slapdFrontendConfig->versionstring = slapi_ch_strdup(version);
  2150. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2151. }
  2152. return LDAP_SUCCESS;
  2153. }
  2154. #define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL;
  2155. int
  2156. config_get_port(){
  2157. int retVal;
  2158. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2159. CFG_LOCK_READ(slapdFrontendConfig);
  2160. retVal = slapdFrontendConfig->port;
  2161. CFG_UNLOCK_READ(slapdFrontendConfig);
  2162. return retVal;
  2163. }
  2164. char *
  2165. config_get_workingdir() {
  2166. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2167. char *retVal;
  2168. CFG_LOCK_READ(slapdFrontendConfig);
  2169. retVal = slapi_ch_strdup(slapdFrontendConfig->workingdir);
  2170. CFG_UNLOCK_READ(slapdFrontendConfig);
  2171. return retVal;
  2172. }
  2173. char *
  2174. config_get_versionstring() {
  2175. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2176. char *retVal;
  2177. CFG_LOCK_READ(slapdFrontendConfig);
  2178. retVal = slapi_ch_strdup(slapdFrontendConfig->versionstring);
  2179. CFG_UNLOCK_READ(slapdFrontendConfig);
  2180. return retVal;
  2181. }
  2182. char *
  2183. config_get_buildnum(void)
  2184. {
  2185. return slapi_ch_strdup(BUILD_NUM);
  2186. }
  2187. int
  2188. config_get_secureport() {
  2189. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2190. int retVal;
  2191. CFG_LOCK_READ(slapdFrontendConfig);
  2192. retVal = slapdFrontendConfig->secureport;
  2193. CFG_UNLOCK_READ(slapdFrontendConfig);
  2194. return retVal;
  2195. }
  2196. int
  2197. config_get_SSLclientAuth() {
  2198. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2199. int retVal;
  2200. CFG_LOCK_READ(slapdFrontendConfig);
  2201. retVal = slapdFrontendConfig->SSLclientAuth;
  2202. CFG_UNLOCK_READ(slapdFrontendConfig);
  2203. return retVal;
  2204. }
  2205. int
  2206. config_get_ssl_check_hostname()
  2207. {
  2208. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2209. return slapdFrontendConfig->ssl_check_hostname;
  2210. }
  2211. char *
  2212. config_get_localhost() {
  2213. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2214. char *retVal;
  2215. CFG_LOCK_READ(slapdFrontendConfig);
  2216. retVal = config_copy_strval ( slapdFrontendConfig->localhost );
  2217. CFG_UNLOCK_READ(slapdFrontendConfig);
  2218. return retVal;
  2219. }
  2220. char *
  2221. config_get_listenhost() {
  2222. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2223. char *retVal;
  2224. CFG_LOCK_READ(slapdFrontendConfig);
  2225. retVal = config_copy_strval ( slapdFrontendConfig->listenhost );
  2226. CFG_UNLOCK_READ(slapdFrontendConfig);
  2227. return retVal;
  2228. }
  2229. char *
  2230. config_get_securelistenhost() {
  2231. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2232. char *retVal;
  2233. CFG_LOCK_READ(slapdFrontendConfig);
  2234. retVal = config_copy_strval( slapdFrontendConfig->securelistenhost );
  2235. CFG_UNLOCK_READ(slapdFrontendConfig);
  2236. return retVal;
  2237. }
  2238. char *
  2239. config_get_srvtab() {
  2240. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2241. char *retVal;
  2242. CFG_LOCK_READ(slapdFrontendConfig);
  2243. retVal = config_copy_strval(slapdFrontendConfig->srvtab);
  2244. CFG_UNLOCK_READ(slapdFrontendConfig);
  2245. return retVal;
  2246. }
  2247. int
  2248. config_get_sizelimit() {
  2249. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2250. int retVal;
  2251. CFG_LOCK_READ(slapdFrontendConfig);
  2252. retVal = slapdFrontendConfig->sizelimit;
  2253. CFG_UNLOCK_READ(slapdFrontendConfig);
  2254. return retVal;
  2255. }
  2256. char *
  2257. config_get_pw_storagescheme() {
  2258. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2259. char *retVal = 0;
  2260. CFG_LOCK_READ(slapdFrontendConfig);
  2261. retVal = config_copy_strval(slapdFrontendConfig->pw_storagescheme->pws_name);
  2262. CFG_UNLOCK_READ(slapdFrontendConfig);
  2263. return retVal;
  2264. }
  2265. int
  2266. config_get_pw_change() {
  2267. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2268. int retVal;
  2269. CFG_LOCK_READ(slapdFrontendConfig);
  2270. retVal = slapdFrontendConfig->pw_policy.pw_change;
  2271. CFG_UNLOCK_READ(slapdFrontendConfig);
  2272. return retVal;
  2273. }
  2274. int
  2275. config_get_pw_history() {
  2276. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2277. int retVal;
  2278. CFG_LOCK_READ(slapdFrontendConfig);
  2279. retVal = slapdFrontendConfig->pw_policy.pw_history;
  2280. CFG_UNLOCK_READ(slapdFrontendConfig);
  2281. return retVal;
  2282. }
  2283. int
  2284. config_get_pw_must_change() {
  2285. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2286. int retVal;
  2287. CFG_LOCK_READ(slapdFrontendConfig);
  2288. retVal = slapdFrontendConfig->pw_policy.pw_must_change;
  2289. CFG_UNLOCK_READ(slapdFrontendConfig);
  2290. return retVal;
  2291. }
  2292. int
  2293. config_get_pw_syntax() {
  2294. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2295. int retVal;
  2296. CFG_LOCK_READ(slapdFrontendConfig);
  2297. retVal = slapdFrontendConfig->pw_policy.pw_syntax;
  2298. CFG_UNLOCK_READ(slapdFrontendConfig);
  2299. return retVal;
  2300. }
  2301. int
  2302. config_get_pw_minlength() {
  2303. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2304. int retVal;
  2305. CFG_LOCK_READ(slapdFrontendConfig);
  2306. retVal = slapdFrontendConfig->pw_policy.pw_minlength;
  2307. CFG_UNLOCK_READ(slapdFrontendConfig);
  2308. return retVal;
  2309. }
  2310. int
  2311. config_get_pw_maxfailure() {
  2312. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2313. int retVal;
  2314. CFG_LOCK_READ(slapdFrontendConfig);
  2315. retVal = slapdFrontendConfig->pw_policy.pw_maxfailure;
  2316. CFG_UNLOCK_READ(slapdFrontendConfig);
  2317. return retVal;
  2318. }
  2319. int
  2320. config_get_pw_inhistory() {
  2321. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2322. int retVal;
  2323. CFG_LOCK_READ(slapdFrontendConfig);
  2324. retVal = slapdFrontendConfig->pw_policy.pw_inhistory;
  2325. CFG_UNLOCK_READ(slapdFrontendConfig);
  2326. return retVal;
  2327. }
  2328. long
  2329. config_get_pw_lockduration() {
  2330. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2331. long retVal;
  2332. CFG_LOCK_READ(slapdFrontendConfig);
  2333. retVal = slapdFrontendConfig->pw_policy.pw_lockduration;
  2334. CFG_UNLOCK_READ(slapdFrontendConfig);
  2335. return retVal;
  2336. }
  2337. long
  2338. config_get_pw_resetfailurecount() {
  2339. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2340. long retVal;
  2341. CFG_LOCK_READ(slapdFrontendConfig);
  2342. retVal = slapdFrontendConfig->pw_policy.pw_resetfailurecount;
  2343. CFG_UNLOCK_READ(slapdFrontendConfig);
  2344. return retVal;
  2345. }
  2346. int
  2347. config_get_pw_is_global_policy() {
  2348. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2349. int retVal;
  2350. CFG_LOCK_READ(slapdFrontendConfig);
  2351. retVal = slapdFrontendConfig->pw_is_global_policy;
  2352. CFG_UNLOCK_READ(slapdFrontendConfig);
  2353. return retVal;
  2354. }
  2355. int
  2356. config_get_pw_exp() {
  2357. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2358. int retVal;
  2359. CFG_LOCK_READ(slapdFrontendConfig);
  2360. retVal = slapdFrontendConfig->pw_policy.pw_exp;
  2361. CFG_UNLOCK_READ(slapdFrontendConfig);
  2362. return retVal;
  2363. }
  2364. int
  2365. config_get_pw_unlock() {
  2366. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2367. int retVal;
  2368. CFG_LOCK_READ(slapdFrontendConfig);
  2369. retVal = slapdFrontendConfig->pw_policy.pw_unlock;
  2370. CFG_UNLOCK_READ(slapdFrontendConfig);
  2371. return retVal;
  2372. }
  2373. int
  2374. config_get_pw_lockout(){
  2375. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2376. int retVal;
  2377. CFG_LOCK_READ(slapdFrontendConfig);
  2378. retVal = slapdFrontendConfig->pw_policy.pw_lockout;
  2379. CFG_UNLOCK_READ(slapdFrontendConfig);
  2380. return retVal;
  2381. }
  2382. int
  2383. config_get_pw_gracelimit() {
  2384. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2385. int retVal=0;
  2386. CFG_LOCK_READ(slapdFrontendConfig);
  2387. retVal = slapdFrontendConfig->pw_policy.pw_gracelimit;
  2388. CFG_UNLOCK_READ(slapdFrontendConfig);
  2389. return retVal;
  2390. }
  2391. int
  2392. config_get_lastmod(){
  2393. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2394. int retVal;
  2395. CFG_LOCK_READ(slapdFrontendConfig);
  2396. retVal = slapdFrontendConfig->lastmod;
  2397. CFG_UNLOCK_READ(slapdFrontendConfig);
  2398. return retVal;
  2399. }
  2400. int
  2401. config_get_enquote_sup_oc(){
  2402. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2403. int retVal;
  2404. CFG_LOCK_READ(slapdFrontendConfig);
  2405. retVal = slapdFrontendConfig->enquote_sup_oc;
  2406. CFG_UNLOCK_READ(slapdFrontendConfig);
  2407. return retVal;
  2408. }
  2409. int
  2410. config_get_nagle() {
  2411. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2412. int retVal;
  2413. CFG_LOCK_READ(slapdFrontendConfig);
  2414. retVal = slapdFrontendConfig->nagle;
  2415. CFG_UNLOCK_READ(slapdFrontendConfig);
  2416. return retVal; }
  2417. int
  2418. config_get_accesscontrol() {
  2419. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2420. int retVal;
  2421. CFG_LOCK_READ(slapdFrontendConfig);
  2422. retVal = slapdFrontendConfig->accesscontrol;
  2423. CFG_UNLOCK_READ(slapdFrontendConfig);
  2424. return retVal;
  2425. }
  2426. int
  2427. config_get_return_exact_case() {
  2428. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2429. int retVal;
  2430. retVal = slapdFrontendConfig->return_exact_case;
  2431. return retVal;
  2432. }
  2433. int
  2434. config_get_result_tweak() {
  2435. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2436. int retVal;
  2437. CFG_LOCK_READ(slapdFrontendConfig);
  2438. retVal = slapdFrontendConfig->result_tweak;
  2439. CFG_UNLOCK_READ(slapdFrontendConfig);
  2440. return retVal;
  2441. }
  2442. int
  2443. config_get_security() {
  2444. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2445. int retVal;
  2446. CFG_LOCK_READ(slapdFrontendConfig);
  2447. retVal = slapdFrontendConfig->security;
  2448. CFG_UNLOCK_READ(slapdFrontendConfig);
  2449. return retVal;
  2450. }
  2451. int
  2452. slapi_config_get_readonly() {
  2453. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2454. int retVal;
  2455. CFG_LOCK_READ(slapdFrontendConfig);
  2456. retVal = slapdFrontendConfig->readonly;
  2457. CFG_UNLOCK_READ(slapdFrontendConfig);
  2458. return retVal;
  2459. }
  2460. int
  2461. config_get_schemacheck() {
  2462. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2463. int retVal;
  2464. CFG_LOCK_READ(slapdFrontendConfig);
  2465. retVal = slapdFrontendConfig->schemacheck;
  2466. CFG_UNLOCK_READ(slapdFrontendConfig);
  2467. return retVal;
  2468. }
  2469. int
  2470. config_get_ds4_compatible_schema() {
  2471. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2472. int retVal;
  2473. CFG_LOCK_READ(slapdFrontendConfig);
  2474. retVal = slapdFrontendConfig->ds4_compatible_schema;
  2475. CFG_UNLOCK_READ(slapdFrontendConfig);
  2476. return retVal;
  2477. }
  2478. int
  2479. config_get_schema_ignore_trailing_spaces() {
  2480. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2481. int retVal;
  2482. CFG_LOCK_READ(slapdFrontendConfig);
  2483. retVal = slapdFrontendConfig->schema_ignore_trailing_spaces;
  2484. CFG_UNLOCK_READ(slapdFrontendConfig);
  2485. return retVal;
  2486. }
  2487. char *
  2488. config_get_rootdn() {
  2489. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2490. char *retVal;
  2491. CFG_LOCK_READ(slapdFrontendConfig);
  2492. retVal = config_copy_strval (slapdFrontendConfig->rootdn);
  2493. CFG_UNLOCK_READ(slapdFrontendConfig);
  2494. return retVal;
  2495. }
  2496. char * slapi_get_rootdn() {
  2497. return config_get_rootdn();
  2498. }
  2499. char *
  2500. config_get_rootpw() {
  2501. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2502. char *retVal;
  2503. CFG_LOCK_READ(slapdFrontendConfig);
  2504. retVal = config_copy_strval (slapdFrontendConfig->rootpw);
  2505. CFG_UNLOCK_READ(slapdFrontendConfig);
  2506. return retVal;
  2507. }
  2508. char *
  2509. config_get_rootpwstoragescheme() {
  2510. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2511. char *retVal;
  2512. CFG_LOCK_READ(slapdFrontendConfig);
  2513. retVal = config_copy_strval(slapdFrontendConfig->rootpwstoragescheme->pws_name);
  2514. CFG_UNLOCK_READ(slapdFrontendConfig);
  2515. return retVal;
  2516. }
  2517. #ifndef _WIN32
  2518. char *
  2519. config_get_localuser() {
  2520. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2521. char *retVal;
  2522. CFG_LOCK_READ(slapdFrontendConfig);
  2523. retVal = config_copy_strval(slapdFrontendConfig->localuser);
  2524. CFG_UNLOCK_READ(slapdFrontendConfig);
  2525. return retVal;
  2526. }
  2527. #endif /* _WIN32 */
  2528. char *
  2529. config_get_instancedir() {
  2530. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2531. char *retVal;
  2532. CFG_LOCK_READ(slapdFrontendConfig);
  2533. retVal = config_copy_strval( slapdFrontendConfig->instancedir );
  2534. CFG_UNLOCK_READ(slapdFrontendConfig);
  2535. return retVal;
  2536. }
  2537. /* alias of encryption key and certificate files is now retrieved through */
  2538. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  2539. /* where this function is still used to set the global variable */
  2540. char *
  2541. config_get_encryptionalias() {
  2542. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2543. char *retVal;
  2544. CFG_LOCK_READ(slapdFrontendConfig);
  2545. retVal = config_copy_strval(slapdFrontendConfig->encryptionalias);
  2546. CFG_UNLOCK_READ(slapdFrontendConfig);
  2547. return retVal;
  2548. }
  2549. int
  2550. config_get_threadnumber() {
  2551. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2552. int retVal;
  2553. CFG_LOCK_READ(slapdFrontendConfig);
  2554. retVal = slapdFrontendConfig->threadnumber;
  2555. CFG_UNLOCK_READ(slapdFrontendConfig);
  2556. return retVal;
  2557. }
  2558. int
  2559. config_get_maxthreadsperconn(){
  2560. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2561. int retVal;
  2562. CFG_LOCK_READ(slapdFrontendConfig);
  2563. retVal = slapdFrontendConfig->maxthreadsperconn;
  2564. CFG_UNLOCK_READ(slapdFrontendConfig);
  2565. return retVal;
  2566. }
  2567. #if !defined(_WIN32) && !defined(AIX)
  2568. int
  2569. config_get_maxdescriptors() {
  2570. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2571. int retVal;
  2572. CFG_LOCK_READ(slapdFrontendConfig);
  2573. retVal = slapdFrontendConfig->maxdescriptors;
  2574. CFG_UNLOCK_READ(slapdFrontendConfig);
  2575. return retVal;
  2576. }
  2577. #endif /* !_WIN32 && !AIX */
  2578. int
  2579. config_get_reservedescriptors(){
  2580. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2581. int retVal;
  2582. CFG_LOCK_READ(slapdFrontendConfig);
  2583. retVal = slapdFrontendConfig->reservedescriptors;
  2584. CFG_UNLOCK_READ(slapdFrontendConfig);
  2585. return retVal;
  2586. }
  2587. int
  2588. config_get_ioblocktimeout(){
  2589. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2590. int retVal;
  2591. CFG_LOCK_READ(slapdFrontendConfig);
  2592. retVal = slapdFrontendConfig->ioblocktimeout;
  2593. CFG_UNLOCK_READ(slapdFrontendConfig);
  2594. return retVal;
  2595. }
  2596. int
  2597. config_get_idletimeout(){
  2598. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2599. int retVal;
  2600. CFG_LOCK_READ(slapdFrontendConfig);
  2601. retVal = slapdFrontendConfig->idletimeout;
  2602. CFG_UNLOCK_READ(slapdFrontendConfig);
  2603. return retVal;
  2604. }
  2605. int
  2606. config_get_groupevalnestlevel(){
  2607. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2608. int retVal;
  2609. CFG_LOCK_READ(slapdFrontendConfig);
  2610. retVal = slapdFrontendConfig->groupevalnestlevel;
  2611. CFG_UNLOCK_READ(slapdFrontendConfig);
  2612. return retVal;
  2613. }
  2614. struct berval **
  2615. config_get_defaultreferral() {
  2616. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2617. struct berval **refs;
  2618. int nReferrals = 0;
  2619. CFG_LOCK_READ(slapdFrontendConfig);
  2620. /* count the number of referrals */
  2621. for ( nReferrals = 0;
  2622. slapdFrontendConfig->defaultreferral &&
  2623. slapdFrontendConfig->defaultreferral[nReferrals];
  2624. nReferrals++)
  2625. ;
  2626. refs = (struct berval **)
  2627. slapi_ch_malloc( (nReferrals + 1) * sizeof(struct berval *) );
  2628. /*terminate the end, and add the referrals backwards */
  2629. refs [nReferrals--] = NULL;
  2630. while ( nReferrals >= 0 ) {
  2631. refs[nReferrals] = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
  2632. refs[nReferrals]->bv_val =
  2633. config_copy_strval( slapdFrontendConfig->defaultreferral[nReferrals]->bv_val );
  2634. refs[nReferrals]->bv_len = slapdFrontendConfig->defaultreferral[nReferrals]->bv_len;
  2635. nReferrals--;
  2636. }
  2637. CFG_UNLOCK_READ(slapdFrontendConfig);
  2638. return refs;
  2639. }
  2640. char *
  2641. config_get_userat ( ){
  2642. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2643. char *retVal;
  2644. CFG_LOCK_READ(slapdFrontendConfig);
  2645. retVal = config_copy_strval( slapdFrontendConfig->userat );
  2646. CFG_UNLOCK_READ(slapdFrontendConfig);
  2647. return retVal;
  2648. }
  2649. int
  2650. config_get_timelimit(){
  2651. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2652. int retVal;
  2653. CFG_LOCK_READ(slapdFrontendConfig);
  2654. retVal= slapdFrontendConfig->timelimit;
  2655. CFG_UNLOCK_READ(slapdFrontendConfig);
  2656. return retVal;
  2657. }
  2658. char*
  2659. config_get_useroc(){
  2660. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2661. char *retVal;
  2662. CFG_LOCK_WRITE(slapdFrontendConfig);
  2663. retVal = config_copy_strval(slapdFrontendConfig->useroc );
  2664. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2665. return retVal;
  2666. }
  2667. char *
  2668. config_get_accesslog(){
  2669. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2670. char *retVal;
  2671. CFG_LOCK_READ(slapdFrontendConfig);
  2672. retVal = config_copy_strval(slapdFrontendConfig->accesslog);
  2673. CFG_UNLOCK_READ(slapdFrontendConfig);
  2674. return retVal;
  2675. }
  2676. char *
  2677. config_get_errorlog( ){
  2678. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2679. char *retVal;
  2680. CFG_LOCK_READ(slapdFrontendConfig);
  2681. retVal = config_copy_strval(slapdFrontendConfig->errorlog);
  2682. CFG_UNLOCK_READ(slapdFrontendConfig);
  2683. return retVal;
  2684. }
  2685. char *
  2686. config_get_auditlog( ){
  2687. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2688. char *retVal;
  2689. CFG_LOCK_READ(slapdFrontendConfig);
  2690. retVal = config_copy_strval(slapdFrontendConfig->auditlog);
  2691. CFG_UNLOCK_READ(slapdFrontendConfig);
  2692. return retVal;
  2693. }
  2694. long
  2695. config_get_pw_maxage() {
  2696. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2697. long retVal;
  2698. CFG_LOCK_READ(slapdFrontendConfig);
  2699. retVal = slapdFrontendConfig->pw_policy.pw_maxage;
  2700. CFG_UNLOCK_READ(slapdFrontendConfig);
  2701. return retVal;
  2702. }
  2703. long
  2704. config_get_pw_minage(){
  2705. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2706. long retVal;
  2707. CFG_LOCK_READ(slapdFrontendConfig);
  2708. retVal = slapdFrontendConfig->pw_policy.pw_minage;
  2709. CFG_UNLOCK_READ(slapdFrontendConfig);
  2710. return retVal;
  2711. }
  2712. long
  2713. config_get_pw_warning() {
  2714. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2715. long retVal;
  2716. CFG_LOCK_READ(slapdFrontendConfig);
  2717. retVal = slapdFrontendConfig->pw_policy.pw_warning;
  2718. CFG_UNLOCK_READ(slapdFrontendConfig);
  2719. return retVal;
  2720. }
  2721. int
  2722. config_get_errorlog_level(){
  2723. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2724. int retVal;
  2725. CFG_LOCK_READ(slapdFrontendConfig);
  2726. retVal = slapdFrontendConfig->errorloglevel;
  2727. CFG_UNLOCK_READ(slapdFrontendConfig);
  2728. return retVal;
  2729. }
  2730. /* return integer -- don't worry about locking similar to config_check_referral_mode
  2731. below */
  2732. int
  2733. config_get_accesslog_level(){
  2734. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2735. int retVal;
  2736. retVal = slapdFrontendConfig->accessloglevel;
  2737. return retVal;
  2738. }
  2739. /* return integer -- don't worry about locking similar to config_check_referral_mode
  2740. below */
  2741. int
  2742. config_get_auditlog_logging_enabled(){
  2743. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2744. int retVal;
  2745. retVal = slapdFrontendConfig->auditlog_logging_enabled;
  2746. return retVal;
  2747. }
  2748. char *config_get_referral_mode(void)
  2749. {
  2750. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2751. char *ret;
  2752. CFG_LOCK_READ(slapdFrontendConfig);
  2753. ret = config_copy_strval(slapdFrontendConfig->refer_url);
  2754. CFG_UNLOCK_READ(slapdFrontendConfig);
  2755. return ret;
  2756. }
  2757. int
  2758. config_get_conntablesize(void){
  2759. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2760. int retVal;
  2761. CFG_LOCK_READ(slapdFrontendConfig);
  2762. retVal = slapdFrontendConfig->conntablesize;
  2763. CFG_UNLOCK_READ(slapdFrontendConfig);
  2764. return retVal;
  2765. }
  2766. /* return yes/no without actually copying the referral url
  2767. we don't worry about another thread changing this value
  2768. since we now return an integer */
  2769. int config_check_referral_mode(void)
  2770. {
  2771. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2772. return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
  2773. }
  2774. int
  2775. config_get_outbound_ldap_io_timeout(void)
  2776. {
  2777. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2778. int retVal;
  2779. CFG_LOCK_READ(slapdFrontendConfig);
  2780. retVal = slapdFrontendConfig->outbound_ldap_io_timeout;
  2781. CFG_UNLOCK_READ(slapdFrontendConfig);
  2782. return retVal;
  2783. }
  2784. int
  2785. config_is_slapd_lite ()
  2786. {
  2787. return ( SLAPD_FULL );
  2788. }
  2789. /* This function is called once at the startup time and no more */
  2790. void
  2791. config_set_slapd_type( )
  2792. {
  2793. char *root = NULL;
  2794. char *s_root = NULL;
  2795. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2796. CFG_LOCK_WRITE(slapdFrontendConfig);
  2797. if ( slapdFrontendConfig->instancedir )
  2798. s_root = root = slapi_ch_strdup ( slapdFrontendConfig->instancedir );
  2799. if ( (root = strrchr( root, '/' )) != NULL ) {
  2800. *root = '\0';
  2801. }
  2802. slapdFrontendConfig->slapd_type = 0;
  2803. slapdFrontendConfig->versionstring = SLAPD_VERSION_STR;
  2804. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2805. slapi_ch_free ( (void **) &s_root );
  2806. }
  2807. int
  2808. config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
  2809. {
  2810. int retVal = LDAP_SUCCESS;
  2811. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2812. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2813. return LDAP_OPERATIONS_ERROR;
  2814. }
  2815. if ( !apply ) {
  2816. return retVal;
  2817. }
  2818. CFG_LOCK_WRITE(slapdFrontendConfig);
  2819. slapdFrontendConfig->maxbersize = atoi(value);
  2820. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2821. return retVal;
  2822. }
  2823. unsigned long
  2824. config_get_maxbersize()
  2825. {
  2826. unsigned long maxbersize;
  2827. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2828. maxbersize = slapdFrontendConfig->maxbersize;
  2829. if(maxbersize==0)
  2830. maxbersize= 2 * 1024 * 1024; /* Default: 2Mb */
  2831. return maxbersize;
  2832. }
  2833. int
  2834. config_set_max_filter_nest_level( const char *attrname, char *value,
  2835. char *errorbuf, int apply )
  2836. {
  2837. int retVal = LDAP_SUCCESS;
  2838. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2839. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2840. return LDAP_OPERATIONS_ERROR;
  2841. }
  2842. if ( !apply ) {
  2843. return retVal;
  2844. }
  2845. CFG_LOCK_WRITE(slapdFrontendConfig);
  2846. slapdFrontendConfig->max_filter_nest_level = atoi(value);
  2847. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2848. return retVal;
  2849. }
  2850. int
  2851. config_get_max_filter_nest_level()
  2852. {
  2853. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2854. int retVal;
  2855. CFG_LOCK_READ(slapdFrontendConfig);
  2856. retVal = slapdFrontendConfig->max_filter_nest_level;
  2857. CFG_UNLOCK_READ(slapdFrontendConfig);
  2858. return retVal;
  2859. }
  2860. char *
  2861. config_get_basedn() {
  2862. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2863. char *retVal;
  2864. CFG_LOCK_READ(slapdFrontendConfig);
  2865. retVal = config_copy_strval ( slapdFrontendConfig->certmap_basedn );
  2866. CFG_UNLOCK_READ(slapdFrontendConfig);
  2867. return retVal;
  2868. }
  2869. int
  2870. config_set_basedn ( const char *attrname, char *value, char *errorbuf, int apply ) {
  2871. int retVal = LDAP_SUCCESS;
  2872. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2873. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2874. return LDAP_OPERATIONS_ERROR;
  2875. }
  2876. if ( !apply ) {
  2877. return retVal;
  2878. }
  2879. CFG_LOCK_WRITE(slapdFrontendConfig);
  2880. slapi_ch_free ( (void **) &slapdFrontendConfig->certmap_basedn );
  2881. slapdFrontendConfig->certmap_basedn = slapi_dn_normalize( slapi_ch_strdup(value) );
  2882. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2883. return retVal;
  2884. }
  2885. char *
  2886. config_get_configdir()
  2887. {
  2888. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2889. char *retVal;
  2890. CFG_LOCK_READ(slapdFrontendConfig);
  2891. retVal = config_copy_strval(slapdFrontendConfig->configdir);
  2892. CFG_UNLOCK_READ(slapdFrontendConfig);
  2893. return retVal;
  2894. }
  2895. int
  2896. config_set_configdir(const char *attrname, char *value, char *errorbuf, int apply)
  2897. {
  2898. int retVal = LDAP_SUCCESS;
  2899. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2900. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2901. return LDAP_OPERATIONS_ERROR;
  2902. }
  2903. if (!apply) {
  2904. return retVal;
  2905. }
  2906. CFG_LOCK_WRITE(slapdFrontendConfig);
  2907. slapi_ch_free((void **)&slapdFrontendConfig->configdir);
  2908. slapdFrontendConfig->configdir = slapi_ch_strdup(value);
  2909. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2910. return retVal;
  2911. }
  2912. char **
  2913. config_get_errorlog_list()
  2914. {
  2915. return log_get_loglist(SLAPD_ERROR_LOG);
  2916. }
  2917. char **
  2918. config_get_accesslog_list()
  2919. {
  2920. return log_get_loglist(SLAPD_ACCESS_LOG);
  2921. }
  2922. char **
  2923. config_get_auditlog_list()
  2924. {
  2925. return log_get_loglist(SLAPD_AUDIT_LOG);
  2926. }
  2927. int
  2928. config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
  2929. {
  2930. int retVal = LDAP_SUCCESS;
  2931. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2932. retVal = config_set_onoff(attrname,
  2933. value,
  2934. &(slapdFrontendConfig->accesslogbuffering),
  2935. errorbuf,
  2936. apply);
  2937. return retVal;
  2938. }
  2939. int
  2940. config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply)
  2941. {
  2942. int retVal = LDAP_SUCCESS;
  2943. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2944. retVal = config_set_onoff(attrname,
  2945. value,
  2946. &(slapdFrontendConfig->csnlogging),
  2947. errorbuf,
  2948. apply);
  2949. return retVal;
  2950. }
  2951. int
  2952. config_get_csnlogging()
  2953. {
  2954. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2955. return slapdFrontendConfig->csnlogging;
  2956. }
  2957. int
  2958. config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply)
  2959. {
  2960. int retVal = LDAP_SUCCESS;
  2961. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2962. retVal = config_set_onoff(attrname,
  2963. value,
  2964. &(slapdFrontendConfig->attrname_exceptions),
  2965. errorbuf,
  2966. apply);
  2967. return retVal;
  2968. }
  2969. int
  2970. config_get_attrname_exceptions()
  2971. {
  2972. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2973. return slapdFrontendConfig->attrname_exceptions;
  2974. }
  2975. int
  2976. config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply)
  2977. {
  2978. int val = 0;
  2979. int retVal = LDAP_SUCCESS;
  2980. retVal = config_set_onoff(attrname,
  2981. value,
  2982. &val,
  2983. errorbuf,
  2984. apply);
  2985. if (retVal == LDAP_SUCCESS) {
  2986. set_hash_filters(val);
  2987. }
  2988. return retVal;
  2989. }
  2990. int
  2991. config_get_hash_filters()
  2992. {
  2993. return 0; /* for now */
  2994. }
  2995. int
  2996. config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply)
  2997. {
  2998. int retVal = LDAP_SUCCESS;
  2999. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3000. retVal = config_set_onoff(attrname,
  3001. value,
  3002. &(slapdFrontendConfig->rewrite_rfc1274),
  3003. errorbuf,
  3004. apply);
  3005. return retVal;
  3006. }
  3007. /* we don't worry about another thread changing this flag since it is an
  3008. integer */
  3009. int
  3010. config_get_rewrite_rfc1274()
  3011. {
  3012. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3013. int retVal;
  3014. retVal = slapdFrontendConfig->rewrite_rfc1274;
  3015. return retVal;
  3016. }
  3017. static int
  3018. config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int apply )
  3019. {
  3020. int retVal = LDAP_SUCCESS;
  3021. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3022. retVal = LDAP_OPERATIONS_ERROR;
  3023. } else {
  3024. /*
  3025. * check that the value is one we allow.
  3026. */
  3027. if ( 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_OFF ) &&
  3028. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
  3029. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
  3030. retVal = LDAP_OPERATIONS_ERROR;
  3031. if( errorbuf ) {
  3032. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
  3033. }
  3034. }
  3035. }
  3036. if ( LDAP_SUCCESS == retVal && apply ) {
  3037. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3038. CFG_LOCK_WRITE(slapdFrontendConfig);
  3039. slapi_ch_free( (void **)&slapdFrontendConfig->schemareplace );
  3040. slapdFrontendConfig->schemareplace = slapi_ch_strdup( value );
  3041. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3042. }
  3043. return retVal;
  3044. }
  3045. int
  3046. config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
  3047. char *errorbuf, int apply )
  3048. {
  3049. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3050. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3051. return LDAP_OPERATIONS_ERROR;
  3052. }
  3053. if ( apply ) {
  3054. CFG_LOCK_WRITE(slapdFrontendConfig);
  3055. slapdFrontendConfig->outbound_ldap_io_timeout = atoi( value );
  3056. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3057. }
  3058. return LDAP_SUCCESS;
  3059. }
  3060. /*
  3061. * This function is intended to be used from the dse code modify callback. It
  3062. * is "optimized" for that case because it takes a berval** of values, which is
  3063. * currently what is used by ldapmod to hold the values. We could easily switch
  3064. * this to take a Slapi_Value array or even a Slapi_Attr. Most config params
  3065. * have simple config_set_XXX functions which take a char* argument holding the
  3066. * value. The log_set_XXX functions have an additional parameter which
  3067. * discriminates the log to use. The config parameters with types CONFIG_SPECIAL_XXX
  3068. * require special handling to set their values.
  3069. */
  3070. int
  3071. config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
  3072. {
  3073. int ii = 0;
  3074. int retval = LDAP_SUCCESS;
  3075. struct config_get_and_set *cgas = 0;
  3076. cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash, attr);
  3077. if (!cgas)
  3078. {
  3079. #if 0
  3080. debugHashTable(attr);
  3081. #endif
  3082. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
  3083. slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
  3084. return retval;
  3085. }
  3086. switch (cgas->config_var_type)
  3087. {
  3088. case CONFIG_SPECIAL_REFERRALLIST:
  3089. if (NULL == values) /* special token which means to remove referrals */
  3090. {
  3091. struct berval val;
  3092. struct berval *vals[2] = {0, 0};
  3093. vals[0] = &val;
  3094. val.bv_val = REFERRAL_REMOVE_CMD;
  3095. val.bv_len = strlen(REFERRAL_REMOVE_CMD);
  3096. retval = config_set_defaultreferral(attr, vals, errorbuf, apply);
  3097. }
  3098. else
  3099. {
  3100. retval = config_set_defaultreferral(attr, values, errorbuf, apply);
  3101. }
  3102. break;
  3103. default:
  3104. for (ii = 0; !retval && values && values[ii]; ++ii)
  3105. {
  3106. if (cgas->setfunc)
  3107. retval = (cgas->setfunc)(cgas->attr_name,
  3108. (char *)values[ii]->bv_val, errorbuf, apply);
  3109. else if (cgas->logsetfunc)
  3110. retval = (cgas->logsetfunc)(cgas->attr_name,
  3111. (char *)values[ii]->bv_val, cgas->whichlog,
  3112. errorbuf, apply);
  3113. else
  3114. LDAPDebug(LDAP_DEBUG_ANY,
  3115. "config_set: the attribute %s is read only; ignoring new value %s\n",
  3116. attr, values[ii]->bv_val, 0);
  3117. }
  3118. break;
  3119. }
  3120. return retval;
  3121. }
  3122. static void
  3123. config_set_value(
  3124. Slapi_Entry *e,
  3125. struct config_get_and_set *cgas,
  3126. void **value
  3127. )
  3128. {
  3129. struct berval **values = 0;
  3130. char *sval = 0;
  3131. /* for null values, just set the attr value to the empty
  3132. string */
  3133. if (!value) {
  3134. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3135. return;
  3136. }
  3137. switch (cgas->config_var_type) {
  3138. case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */
  3139. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3140. (value && *((int *)value)) ? "on" : "off");
  3141. break;
  3142. case CONFIG_INT:
  3143. if (value)
  3144. slapi_entry_attr_set_int(e, cgas->attr_name, *((int *)value));
  3145. else
  3146. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3147. break;
  3148. case CONFIG_LONG:
  3149. if (value)
  3150. slapi_entry_attr_set_long(e, cgas->attr_name, *((long *)value));
  3151. else
  3152. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3153. break;
  3154. case CONFIG_STRING:
  3155. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3156. (value && *((char **)value)) ?
  3157. *((char **)value) : "");
  3158. break;
  3159. case CONFIG_CHARRAY:
  3160. values = strarray2bervalarray((const char **)*((char ***)value));
  3161. if (!values) {
  3162. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3163. } else {
  3164. slapi_entry_attr_replace(e, cgas->attr_name, values);
  3165. bervalarray_free(values);
  3166. }
  3167. break;
  3168. case CONFIG_SPECIAL_REFERRALLIST:
  3169. /* referral list is already an array of berval* */
  3170. if (value)
  3171. slapi_entry_attr_replace(e, cgas->attr_name, (struct berval**)*value);
  3172. else
  3173. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3174. break;
  3175. case CONFIG_CONSTANT_STRING:
  3176. PR_ASSERT(value); /* should be a constant value */
  3177. slapi_entry_attr_set_charptr(e, cgas->attr_name, (char*)value);
  3178. break;
  3179. case CONFIG_CONSTANT_INT:
  3180. PR_ASSERT(value); /* should be a constant value */
  3181. slapi_entry_attr_set_int(e, cgas->attr_name, (int)value);
  3182. break;
  3183. case CONFIG_SPECIAL_SSLCLIENTAUTH:
  3184. if (!value) {
  3185. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  3186. break;
  3187. }
  3188. if (*((int *)value) == SLAPD_SSLCLIENTAUTH_ALLOWED) {
  3189. sval = "allowed";
  3190. } else if (*((int *)value) == SLAPD_SSLCLIENTAUTH_REQUIRED) {
  3191. sval = "required";
  3192. } else {
  3193. sval = "off";
  3194. }
  3195. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  3196. break;
  3197. case CONFIG_STRING_OR_OFF:
  3198. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3199. (value && *((char **)value)) ?
  3200. *((char **)value) : "off");
  3201. break;
  3202. case CONFIG_STRING_OR_EMPTY:
  3203. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3204. (value && *((char **)value)) ?
  3205. *((char **)value) : "");
  3206. break;
  3207. case CONFIG_STRING_OR_UNKNOWN:
  3208. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3209. (value && *((char **)value)) ?
  3210. *((char **)value) : "unknown");
  3211. break;
  3212. case CONFIG_SPECIAL_ERRORLOGLEVEL:
  3213. if (value) {
  3214. int ival = *(int *)value;
  3215. ival &= ~LDAP_DEBUG_ANY;
  3216. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  3217. }
  3218. else
  3219. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3220. break;
  3221. default:
  3222. PR_ASSERT(0); /* something went horribly wrong . . . */
  3223. break;
  3224. }
  3225. return;
  3226. }
  3227. /*
  3228. * Fill in the given slapi_entry with the config attributes and values
  3229. */
  3230. int
  3231. config_set_entry(Slapi_Entry *e)
  3232. {
  3233. int ii = 0;
  3234. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  3235. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3236. /*
  3237. * Avoid recursive calls to the readers/writer
  3238. * lock as it causes deadlock under stress. Each
  3239. * individual config get function acquires a read
  3240. * lock where necessary.
  3241. */
  3242. /*
  3243. * Pass 1: Values which do not have a get function.
  3244. */
  3245. CFG_LOCK_READ(slapdFrontendConfig);
  3246. for (ii = 0; ii < tablesize; ++ii) {
  3247. struct config_get_and_set *cgas = &ConfigList[ii];
  3248. void **value = 0;
  3249. PR_ASSERT(cgas);
  3250. value = cgas->config_var_addr;
  3251. PR_ASSERT(cgas->attr_name);
  3252. /* Skip values handled in pass 2 */
  3253. if (NULL == value && cgas->getfunc) {
  3254. continue;
  3255. }
  3256. config_set_value(e, cgas, value);
  3257. }
  3258. CFG_UNLOCK_READ(slapdFrontendConfig);
  3259. /*
  3260. * Pass 2: Values which do have a get function.
  3261. */
  3262. for (ii = 0; ii < tablesize; ++ii) {
  3263. struct config_get_and_set *cgas = &ConfigList[ii];
  3264. void **value = 0;
  3265. void *alloc_val;
  3266. int needs_free = 0;
  3267. PR_ASSERT(cgas);
  3268. value = cgas->config_var_addr;
  3269. PR_ASSERT(cgas->attr_name);
  3270. /* Skip values handled in pass 1 */
  3271. if (NULL != value || cgas->getfunc == NULL) {
  3272. continue;
  3273. }
  3274. alloc_val = (cgas->getfunc)();
  3275. value = &alloc_val; /* value must be address of pointer */
  3276. if (!isIntegralType(cgas->config_var_type))
  3277. needs_free = 1; /* get funcs must return alloc'd memory except for get
  3278. funcs which return a simple integral type e.g. int */
  3279. config_set_value(e, cgas, value);
  3280. if (needs_free && value) { /* assumes memory allocated by slapi_ch_Xalloc */
  3281. if (CONFIG_CHARRAY == cgas->config_var_type) {
  3282. charray_free(*((char ***)value));
  3283. } else {
  3284. slapi_ch_free(value);
  3285. }
  3286. }
  3287. }
  3288. return 1;
  3289. }