libglobs.c 152 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486
  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. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /*
  42. *
  43. * libglobs.c -- SLAPD library global variables
  44. */
  45. /* for windows only
  46. we define slapd_ldap_debug here, so we don't want to declare
  47. it in any header file which might conflict with our definition
  48. */
  49. #define DONT_DECLARE_SLAPD_LDAP_DEBUG /* see ldaplog.h */
  50. #include "ldap.h"
  51. #include <sslproto.h>
  52. #include <ldap_ssl.h>
  53. #undef OFF
  54. #undef LITTLE_ENDIAN
  55. #include <stdio.h>
  56. #include <string.h>
  57. #include <sys/types.h>
  58. #include <time.h>
  59. #include <stdarg.h>
  60. #include <stdlib.h>
  61. #if defined( _WIN32 )
  62. #define R_OK 04
  63. #include "ntslapdmessages.h"
  64. #include "proto-ntutil.h"
  65. #else
  66. #include <sys/time.h>
  67. #include <sys/param.h> /* MAXPATHLEN */
  68. #include <sys/socket.h>
  69. #include <netinet/in.h>
  70. #include <arpa/inet.h>
  71. #include <netdb.h>
  72. #include <unistd.h>
  73. #include <pwd.h> /* pwdnam */
  74. #endif
  75. #ifdef USE_SYSCONF
  76. #include <unistd.h>
  77. #endif /* USE_SYSCONF */
  78. #include "slap.h"
  79. #include "plhash.h"
  80. #define REMOVE_CHANGELOG_CMD "remove"
  81. /* On UNIX, there's only one copy of slapd_ldap_debug */
  82. /* On NT, each module keeps its own module_ldap_debug, which */
  83. /* points to the process' slapd_ldap_debug */
  84. #ifdef _WIN32
  85. int *module_ldap_debug;
  86. int __declspec(dllexport) slapd_ldap_debug = LDAP_DEBUG_ANY;
  87. #else
  88. int slapd_ldap_debug = LDAP_DEBUG_ANY;
  89. #endif
  90. char *ldap_srvtab = "";
  91. /* Note that the 'attrname' arguments are used only for log messages */
  92. typedef int (*ConfigSetFunc)(const char *attrname, char *value,
  93. char *errorbuf, int apply);
  94. typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
  95. char *errorbuf, int apply);
  96. typedef enum {
  97. CONFIG_INT, /* maps to int */
  98. CONFIG_LONG, /* maps to long */
  99. CONFIG_STRING, /* maps to char* */
  100. CONFIG_CHARRAY, /* maps to char** */
  101. CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
  102. CONFIG_STRING_OR_OFF, /* use "off" instead of null or an empty string */
  103. CONFIG_STRING_OR_UNKNOWN, /* use "unknown" instead of an empty string */
  104. CONFIG_CONSTANT_INT, /* for #define values, e.g. */
  105. CONFIG_CONSTANT_STRING, /* for #define values, e.g. */
  106. CONFIG_SPECIAL_REFERRALLIST, /* this is a berval list */
  107. CONFIG_SPECIAL_SSLCLIENTAUTH, /* maps strings to an enumeration */
  108. CONFIG_SPECIAL_ERRORLOGLEVEL, /* requires & with LDAP_DEBUG_ANY */
  109. CONFIG_STRING_OR_EMPTY /* use an empty string */
  110. } ConfigVarType;
  111. static int config_set_onoff( const char *attrname, char *value,
  112. int *configvalue, char *errorbuf, int apply );
  113. static int config_set_schemareplace ( const char *attrname, char *value,
  114. char *errorbuf, int apply );
  115. static int
  116. isIntegralType(ConfigVarType type)
  117. {
  118. return type == CONFIG_INT || type == CONFIG_LONG || type == CONFIG_ON_OFF;
  119. }
  120. /* the caller will typically have to cast the result based on the ConfigVarType */
  121. typedef void *(*ConfigGetFunc)(void);
  122. /* static Ref_Array global_referrals; */
  123. static slapdFrontendConfig_t global_slapdFrontendConfig;
  124. static struct config_get_and_set {
  125. const char *attr_name; /* the name of the attribute */
  126. ConfigSetFunc setfunc; /* the function to call to set the value */
  127. LogSetFunc logsetfunc; /* log functions are special */
  128. int whichlog; /* ACCESS, ERROR, AUDIT, etc. */
  129. void** config_var_addr; /* address of member of slapdFrontendConfig struct */
  130. ConfigVarType config_var_type; /* cast to this type when getting */
  131. ConfigGetFunc getfunc; /* for special handling */
  132. } ConfigList[] = {
  133. {CONFIG_AUDITLOG_MODE_ATTRIBUTE, NULL,
  134. log_set_mode, SLAPD_AUDIT_LOG,
  135. (void**)&global_slapdFrontendConfig.auditlog_mode, CONFIG_STRING, NULL},
  136. {CONFIG_AUDITLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  137. log_set_rotationsync_enabled, SLAPD_AUDIT_LOG,
  138. (void**)&global_slapdFrontendConfig.auditlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  139. {CONFIG_AUDITLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  140. log_set_rotationsynchour, SLAPD_AUDIT_LOG,
  141. (void**)&global_slapdFrontendConfig.auditlog_rotationsynchour, CONFIG_INT, NULL},
  142. {CONFIG_AUDITLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  143. log_set_rotationsyncmin, SLAPD_AUDIT_LOG,
  144. (void**)&global_slapdFrontendConfig.auditlog_rotationsyncmin, CONFIG_INT, NULL},
  145. {CONFIG_AUDITLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  146. log_set_rotationtime, SLAPD_AUDIT_LOG,
  147. (void**)&global_slapdFrontendConfig.auditlog_rotationtime, CONFIG_INT, NULL},
  148. {CONFIG_ACCESSLOG_MODE_ATTRIBUTE, NULL,
  149. log_set_mode, SLAPD_ACCESS_LOG,
  150. (void**)&global_slapdFrontendConfig.accesslog_mode, CONFIG_STRING, NULL},
  151. {CONFIG_ACCESSLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  152. log_set_numlogsperdir, SLAPD_ACCESS_LOG,
  153. (void**)&global_slapdFrontendConfig.accesslog_maxnumlogs, CONFIG_INT, NULL},
  154. {CONFIG_LOGLEVEL_ATTRIBUTE, config_set_errorlog_level,
  155. NULL, 0,
  156. (void**)&global_slapdFrontendConfig.errorloglevel,
  157. CONFIG_SPECIAL_ERRORLOGLEVEL, NULL},
  158. {CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  159. log_set_logging, SLAPD_ERROR_LOG,
  160. (void**)&global_slapdFrontendConfig.errorlog_logging_enabled, CONFIG_ON_OFF, NULL},
  161. {CONFIG_ERRORLOG_MODE_ATTRIBUTE, NULL,
  162. log_set_mode, SLAPD_ERROR_LOG,
  163. (void**)&global_slapdFrontendConfig.errorlog_mode, CONFIG_STRING, NULL},
  164. {CONFIG_ERRORLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  165. log_set_expirationtime, SLAPD_ERROR_LOG,
  166. (void**)&global_slapdFrontendConfig.errorlog_exptime, CONFIG_INT, NULL},
  167. {CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  168. log_set_logging, SLAPD_ACCESS_LOG,
  169. (void**)&global_slapdFrontendConfig.accesslog_logging_enabled, CONFIG_ON_OFF, NULL},
  170. {CONFIG_PORT_ATTRIBUTE, config_set_port,
  171. NULL, 0,
  172. (void**)&global_slapdFrontendConfig.port, CONFIG_INT, NULL},
  173. {CONFIG_WORKINGDIR_ATTRIBUTE, config_set_workingdir,
  174. NULL, 0,
  175. (void**)&global_slapdFrontendConfig.workingdir, CONFIG_STRING_OR_EMPTY, NULL},
  176. {CONFIG_MAXTHREADSPERCONN_ATTRIBUTE, config_set_maxthreadsperconn,
  177. NULL, 0,
  178. (void**)&global_slapdFrontendConfig.maxthreadsperconn, CONFIG_INT, NULL},
  179. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  180. log_set_expirationtime, SLAPD_ACCESS_LOG,
  181. (void**)&global_slapdFrontendConfig.accesslog_exptime, CONFIG_INT, NULL},
  182. #ifndef _WIN32
  183. {CONFIG_LOCALUSER_ATTRIBUTE, config_set_localuser,
  184. NULL, 0,
  185. (void**)&global_slapdFrontendConfig.localuser, CONFIG_STRING, NULL},
  186. #endif
  187. {CONFIG_ERRORLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  188. log_set_rotationsync_enabled, SLAPD_ERROR_LOG,
  189. (void**)&global_slapdFrontendConfig.errorlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  190. {CONFIG_ERRORLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  191. log_set_rotationsynchour, SLAPD_ERROR_LOG,
  192. (void**)&global_slapdFrontendConfig.errorlog_rotationsynchour, CONFIG_INT, NULL},
  193. {CONFIG_ERRORLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  194. log_set_rotationsyncmin, SLAPD_ERROR_LOG,
  195. (void**)&global_slapdFrontendConfig.errorlog_rotationsyncmin, CONFIG_INT, NULL},
  196. {CONFIG_ERRORLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  197. log_set_rotationtime, SLAPD_ERROR_LOG,
  198. (void**)&global_slapdFrontendConfig.errorlog_rotationtime, CONFIG_INT, NULL},
  199. {CONFIG_PW_INHISTORY_ATTRIBUTE, config_set_pw_inhistory,
  200. NULL, 0,
  201. (void**)&global_slapdFrontendConfig.pw_policy.pw_inhistory, CONFIG_INT, NULL},
  202. {CONFIG_PW_STORAGESCHEME_ATTRIBUTE, config_set_pw_storagescheme,
  203. NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_pw_storagescheme},
  204. {CONFIG_PW_UNLOCK_ATTRIBUTE, config_set_pw_unlock,
  205. NULL, 0,
  206. (void**)&global_slapdFrontendConfig.pw_policy.pw_unlock, CONFIG_ON_OFF, NULL},
  207. {CONFIG_PW_GRACELIMIT_ATTRIBUTE, config_set_pw_gracelimit,
  208. NULL, 0,
  209. (void**)&global_slapdFrontendConfig.pw_policy.pw_gracelimit, CONFIG_INT, NULL},
  210. {CONFIG_ACCESSLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  211. log_set_rotationsync_enabled, SLAPD_ACCESS_LOG,
  212. (void**)&global_slapdFrontendConfig.accesslog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
  213. {CONFIG_ACCESSLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  214. log_set_rotationsynchour, SLAPD_ACCESS_LOG,
  215. (void**)&global_slapdFrontendConfig.accesslog_rotationsynchour, CONFIG_INT, NULL},
  216. {CONFIG_ACCESSLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  217. log_set_rotationsyncmin, SLAPD_ACCESS_LOG,
  218. (void**)&global_slapdFrontendConfig.accesslog_rotationsyncmin, CONFIG_INT, NULL},
  219. {CONFIG_ACCESSLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  220. log_set_rotationtime, SLAPD_ACCESS_LOG,
  221. (void**)&global_slapdFrontendConfig.accesslog_rotationtime, CONFIG_INT, NULL},
  222. {CONFIG_PW_MUSTCHANGE_ATTRIBUTE, config_set_pw_must_change,
  223. NULL, 0,
  224. (void**)&global_slapdFrontendConfig.pw_policy.pw_must_change, CONFIG_ON_OFF, NULL},
  225. {CONFIG_PWPOLICY_LOCAL_ATTRIBUTE, config_set_pwpolicy_local,
  226. NULL, 0,
  227. (void**)&global_slapdFrontendConfig.pwpolicy_local, CONFIG_ON_OFF, NULL},
  228. {CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  229. log_set_maxdiskspace, SLAPD_AUDIT_LOG,
  230. (void**)&global_slapdFrontendConfig.auditlog_maxdiskspace, CONFIG_INT, NULL},
  231. {CONFIG_SIZELIMIT_ATTRIBUTE, config_set_sizelimit,
  232. NULL, 0,
  233. (void**)&global_slapdFrontendConfig.sizelimit, CONFIG_INT, NULL},
  234. {CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  235. log_set_logsize, SLAPD_AUDIT_LOG,
  236. (void**)&global_slapdFrontendConfig.auditlog_maxlogsize, CONFIG_INT, NULL},
  237. {CONFIG_PW_WARNING_ATTRIBUTE, config_set_pw_warning,
  238. NULL, 0,
  239. (void**)&global_slapdFrontendConfig.pw_policy.pw_warning, CONFIG_LONG, NULL},
  240. {CONFIG_READONLY_ATTRIBUTE, config_set_readonly,
  241. NULL, 0,
  242. (void**)&global_slapdFrontendConfig.readonly, CONFIG_ON_OFF, NULL},
  243. {CONFIG_THREADNUMBER_ATTRIBUTE, config_set_threadnumber,
  244. NULL, 0,
  245. (void**)&global_slapdFrontendConfig.threadnumber, CONFIG_INT, NULL},
  246. {CONFIG_PW_LOCKOUT_ATTRIBUTE, config_set_pw_lockout,
  247. NULL, 0,
  248. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockout, CONFIG_ON_OFF, NULL},
  249. {CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, config_set_enquote_sup_oc,
  250. NULL, 0,
  251. (void**)&global_slapdFrontendConfig.enquote_sup_oc, CONFIG_ON_OFF, NULL},
  252. {CONFIG_LOCALHOST_ATTRIBUTE, config_set_localhost,
  253. NULL, 0,
  254. (void**)&global_slapdFrontendConfig.localhost, CONFIG_STRING, NULL},
  255. {CONFIG_IOBLOCKTIMEOUT_ATTRIBUTE, config_set_ioblocktimeout,
  256. NULL, 0,
  257. (void**)&global_slapdFrontendConfig.ioblocktimeout, CONFIG_INT, NULL},
  258. {CONFIG_MAX_FILTER_NEST_LEVEL_ATTRIBUTE, config_set_max_filter_nest_level,
  259. NULL, 0, (void**)&global_slapdFrontendConfig.max_filter_nest_level,
  260. CONFIG_INT, NULL},
  261. {CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  262. log_set_maxdiskspace, SLAPD_ERROR_LOG,
  263. (void**)&global_slapdFrontendConfig.errorlog_maxdiskspace, CONFIG_INT, NULL},
  264. {CONFIG_PW_MINLENGTH_ATTRIBUTE, config_set_pw_minlength,
  265. NULL, 0,
  266. (void**)&global_slapdFrontendConfig.pw_policy.pw_minlength, CONFIG_INT, NULL},
  267. {CONFIG_PW_MINDIGITS_ATTRIBUTE, config_set_pw_mindigits,
  268. NULL, 0,
  269. (void**)&global_slapdFrontendConfig.pw_policy.pw_mindigits, CONFIG_INT, NULL},
  270. {CONFIG_PW_MINALPHAS_ATTRIBUTE, config_set_pw_minalphas,
  271. NULL, 0,
  272. (void**)&global_slapdFrontendConfig.pw_policy.pw_minalphas, CONFIG_INT, NULL},
  273. {CONFIG_PW_MINUPPERS_ATTRIBUTE, config_set_pw_minuppers,
  274. NULL, 0,
  275. (void**)&global_slapdFrontendConfig.pw_policy.pw_minuppers, CONFIG_INT, NULL},
  276. {CONFIG_PW_MINLOWERS_ATTRIBUTE, config_set_pw_minlowers,
  277. NULL, 0,
  278. (void**)&global_slapdFrontendConfig.pw_policy.pw_minlowers, CONFIG_INT, NULL},
  279. {CONFIG_PW_MINSPECIALS_ATTRIBUTE, config_set_pw_minspecials,
  280. NULL, 0,
  281. (void**)&global_slapdFrontendConfig.pw_policy.pw_minspecials, CONFIG_INT, NULL},
  282. {CONFIG_PW_MIN8BIT_ATTRIBUTE, config_set_pw_min8bit,
  283. NULL, 0,
  284. (void**)&global_slapdFrontendConfig.pw_policy.pw_min8bit, CONFIG_INT, NULL},
  285. {CONFIG_PW_MAXREPEATS_ATTRIBUTE, config_set_pw_maxrepeats,
  286. NULL, 0,
  287. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxrepeats, CONFIG_INT, NULL},
  288. {CONFIG_PW_MINCATEGORIES_ATTRIBUTE, config_set_pw_mincategories,
  289. NULL, 0,
  290. (void**)&global_slapdFrontendConfig.pw_policy.pw_mincategories, CONFIG_INT, NULL},
  291. {CONFIG_PW_MINTOKENLENGTH_ATTRIBUTE, config_set_pw_mintokenlength,
  292. NULL, 0,
  293. (void**)&global_slapdFrontendConfig.pw_policy.pw_mintokenlength, CONFIG_INT, NULL},
  294. {CONFIG_ERRORLOG_ATTRIBUTE, config_set_errorlog,
  295. NULL, 0,
  296. (void**)&global_slapdFrontendConfig.errorlog, CONFIG_STRING_OR_EMPTY, NULL},
  297. {CONFIG_AUDITLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  298. log_set_expirationtime, SLAPD_AUDIT_LOG,
  299. (void**)&global_slapdFrontendConfig.auditlog_exptime, CONFIG_INT, NULL},
  300. {CONFIG_SCHEMACHECK_ATTRIBUTE, config_set_schemacheck,
  301. NULL, 0,
  302. (void**)&global_slapdFrontendConfig.schemacheck, CONFIG_ON_OFF, NULL},
  303. {CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema,
  304. NULL, 0,
  305. (void**)&global_slapdFrontendConfig.ds4_compatible_schema,
  306. CONFIG_ON_OFF, NULL},
  307. {CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  308. config_set_schema_ignore_trailing_spaces, NULL, 0,
  309. (void**)&global_slapdFrontendConfig.schema_ignore_trailing_spaces,
  310. CONFIG_ON_OFF, NULL},
  311. {CONFIG_SCHEMAREPLACE_ATTRIBUTE, config_set_schemareplace, NULL, 0,
  312. (void**)&global_slapdFrontendConfig.schemareplace,
  313. CONFIG_STRING_OR_OFF, NULL},
  314. {CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  315. log_set_maxdiskspace, SLAPD_ACCESS_LOG,
  316. (void**)&global_slapdFrontendConfig.accesslog_maxdiskspace, CONFIG_INT, NULL},
  317. {CONFIG_REFERRAL_ATTRIBUTE, (ConfigSetFunc)config_set_defaultreferral,
  318. NULL, 0,
  319. (void**)&global_slapdFrontendConfig.defaultreferral,
  320. CONFIG_SPECIAL_REFERRALLIST, NULL},
  321. {CONFIG_PW_MAXFAILURE_ATTRIBUTE, config_set_pw_maxfailure,
  322. NULL, 0,
  323. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxfailure, CONFIG_INT, NULL},
  324. {CONFIG_ACCESSLOG_ATTRIBUTE, config_set_accesslog,
  325. NULL, 0,
  326. (void**)&global_slapdFrontendConfig.accesslog, CONFIG_STRING_OR_EMPTY, NULL},
  327. {CONFIG_LASTMOD_ATTRIBUTE, config_set_lastmod,
  328. NULL, 0,
  329. (void**)&global_slapdFrontendConfig.lastmod, CONFIG_ON_OFF, NULL},
  330. {CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
  331. NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme},
  332. {CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
  333. NULL, 0,
  334. (void**)&global_slapdFrontendConfig.pw_policy.pw_history, CONFIG_ON_OFF, NULL},
  335. {CONFIG_SECURITY_ATTRIBUTE, config_set_security,
  336. NULL, 0,
  337. (void**)&global_slapdFrontendConfig.security, CONFIG_ON_OFF, NULL},
  338. {CONFIG_PW_MAXAGE_ATTRIBUTE, config_set_pw_maxage,
  339. NULL, 0,
  340. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxage, CONFIG_LONG, NULL},
  341. {CONFIG_AUDITLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  342. log_set_rotationtimeunit, SLAPD_AUDIT_LOG,
  343. (void**)&global_slapdFrontendConfig.auditlog_rotationunit,
  344. CONFIG_STRING_OR_UNKNOWN, NULL},
  345. {CONFIG_PW_RESETFAILURECOUNT_ATTRIBUTE, config_set_pw_resetfailurecount,
  346. NULL, 0,
  347. (void**)&global_slapdFrontendConfig.pw_policy.pw_resetfailurecount, CONFIG_LONG, NULL},
  348. {CONFIG_PW_ISGLOBAL_ATTRIBUTE, config_set_pw_is_global_policy,
  349. NULL, 0,
  350. (void**)&global_slapdFrontendConfig.pw_is_global_policy, CONFIG_ON_OFF, NULL},
  351. {CONFIG_AUDITLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  352. log_set_numlogsperdir, SLAPD_AUDIT_LOG,
  353. (void**)&global_slapdFrontendConfig.auditlog_maxnumlogs, CONFIG_INT, NULL},
  354. {CONFIG_ERRORLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  355. log_set_expirationtimeunit, SLAPD_ERROR_LOG,
  356. (void**)&global_slapdFrontendConfig.errorlog_exptimeunit,
  357. CONFIG_STRING_OR_UNKNOWN, NULL},
  358. /* errorlog list is read only, so no set func and no config var addr */
  359. {CONFIG_ERRORLOG_LIST_ATTRIBUTE, NULL, NULL, 0, NULL,
  360. CONFIG_CHARRAY, (ConfigGetFunc)config_get_errorlog_list},
  361. {CONFIG_GROUPEVALNESTLEVEL_ATTRIBUTE, config_set_groupevalnestlevel,
  362. NULL, 0,
  363. (void**)&global_slapdFrontendConfig.groupevalnestlevel, CONFIG_INT, NULL},
  364. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  365. log_set_expirationtimeunit, SLAPD_ACCESS_LOG,
  366. (void**)&global_slapdFrontendConfig.accesslog_exptimeunit,
  367. CONFIG_STRING_OR_UNKNOWN, NULL},
  368. {CONFIG_ROOTPW_ATTRIBUTE, config_set_rootpw,
  369. NULL, 0,
  370. (void**)&global_slapdFrontendConfig.rootpw, CONFIG_STRING, NULL},
  371. {CONFIG_PW_CHANGE_ATTRIBUTE, config_set_pw_change,
  372. NULL, 0,
  373. (void**)&global_slapdFrontendConfig.pw_policy.pw_change, CONFIG_ON_OFF, NULL},
  374. {CONFIG_ACCESSLOGLEVEL_ATTRIBUTE, config_set_accesslog_level,
  375. NULL, 0,
  376. (void**)&global_slapdFrontendConfig.accessloglevel, CONFIG_INT, NULL},
  377. {CONFIG_ERRORLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  378. log_set_rotationtimeunit, SLAPD_ERROR_LOG,
  379. (void**)&global_slapdFrontendConfig.errorlog_rotationunit,
  380. CONFIG_STRING_OR_UNKNOWN, NULL},
  381. {CONFIG_SECUREPORT_ATTRIBUTE, config_set_secureport,
  382. NULL, 0,
  383. (void**)&global_slapdFrontendConfig.secureport, CONFIG_INT, NULL},
  384. {CONFIG_BASEDN_ATTRIBUTE, config_set_basedn,
  385. NULL, 0,
  386. (void**)&global_slapdFrontendConfig.certmap_basedn, CONFIG_STRING, NULL},
  387. {CONFIG_TIMELIMIT_ATTRIBUTE, config_set_timelimit,
  388. NULL, 0,
  389. (void**)&global_slapdFrontendConfig.timelimit, CONFIG_INT, NULL},
  390. {CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  391. log_set_logsize, SLAPD_ERROR_LOG,
  392. (void**)&global_slapdFrontendConfig.errorlog_maxlogsize, CONFIG_INT, NULL},
  393. {CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE, config_set_reservedescriptors,
  394. NULL, 0,
  395. (void**)&global_slapdFrontendConfig.reservedescriptors, CONFIG_INT, NULL},
  396. /* access log list is read only, no set func, no config var addr */
  397. {CONFIG_ACCESSLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  398. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_accesslog_list},
  399. {CONFIG_SVRTAB_ATTRIBUTE, config_set_srvtab,
  400. NULL, 0,
  401. (void**)&global_slapdFrontendConfig.srvtab, CONFIG_STRING, NULL},
  402. {CONFIG_PW_EXP_ATTRIBUTE, config_set_pw_exp,
  403. NULL, 0,
  404. (void**)&global_slapdFrontendConfig.pw_policy.pw_exp, CONFIG_ON_OFF, NULL},
  405. {CONFIG_ACCESSCONTROL_ATTRIBUTE, config_set_accesscontrol,
  406. NULL, 0,
  407. (void**)&global_slapdFrontendConfig.accesscontrol, CONFIG_ON_OFF, NULL},
  408. {CONFIG_AUDITLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  409. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_auditlog_list},
  410. {CONFIG_ACCESSLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  411. log_set_rotationtimeunit, SLAPD_ACCESS_LOG,
  412. (void**)&global_slapdFrontendConfig.accesslog_rotationunit, CONFIG_STRING, NULL},
  413. {CONFIG_PW_LOCKDURATION_ATTRIBUTE, config_set_pw_lockduration,
  414. NULL, 0,
  415. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockduration, CONFIG_LONG, NULL},
  416. {CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  417. log_set_logsize, SLAPD_ACCESS_LOG,
  418. (void**)&global_slapdFrontendConfig.accesslog_maxlogsize, CONFIG_INT, NULL},
  419. {CONFIG_IDLETIMEOUT_ATTRIBUTE, config_set_idletimeout,
  420. NULL, 0,
  421. (void**)&global_slapdFrontendConfig.idletimeout, CONFIG_INT, NULL},
  422. {CONFIG_NAGLE_ATTRIBUTE, config_set_nagle,
  423. NULL, 0,
  424. (void**)&global_slapdFrontendConfig.nagle, CONFIG_ON_OFF, NULL},
  425. {CONFIG_ERRORLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  426. log_set_mindiskspace, SLAPD_ERROR_LOG,
  427. (void**)&global_slapdFrontendConfig.errorlog_minfreespace, CONFIG_INT, NULL},
  428. {CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  429. log_set_logging, SLAPD_AUDIT_LOG,
  430. (void**)&global_slapdFrontendConfig.auditlog_logging_enabled, CONFIG_ON_OFF, NULL},
  431. {CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
  432. NULL, 0,
  433. (void**)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL},
  434. {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
  435. NULL, 0,
  436. (void**)&global_slapdFrontendConfig.csnlogging, CONFIG_ON_OFF, NULL},
  437. {CONFIG_AUDITLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  438. log_set_expirationtimeunit, SLAPD_AUDIT_LOG,
  439. (void**)&global_slapdFrontendConfig.auditlog_exptimeunit,
  440. CONFIG_STRING_OR_UNKNOWN, NULL},
  441. {CONFIG_PW_SYNTAX_ATTRIBUTE, config_set_pw_syntax,
  442. NULL, 0,
  443. (void**)&global_slapdFrontendConfig.pw_policy.pw_syntax, CONFIG_ON_OFF, NULL},
  444. {CONFIG_LISTENHOST_ATTRIBUTE, config_set_listenhost,
  445. NULL, 0,
  446. (void**)&global_slapdFrontendConfig.listenhost, CONFIG_STRING, NULL},
  447. {CONFIG_LDAPI_FILENAME_ATTRIBUTE, config_set_ldapi_filename,
  448. NULL, 0,
  449. (void**)&global_slapdFrontendConfig.ldapi_filename, CONFIG_STRING, NULL},
  450. {CONFIG_LDAPI_SWITCH_ATTRIBUTE, config_set_ldapi_switch,
  451. NULL, 0,
  452. (void**)&global_slapdFrontendConfig.ldapi_switch, CONFIG_ON_OFF, NULL},
  453. {CONFIG_LDAPI_BIND_SWITCH_ATTRIBUTE, config_set_ldapi_bind_switch,
  454. NULL, 0,
  455. (void**)&global_slapdFrontendConfig.ldapi_bind_switch, CONFIG_ON_OFF, NULL},
  456. {CONFIG_LDAPI_ROOT_DN_ATTRIBUTE, config_set_ldapi_root_dn,
  457. NULL, 0,
  458. (void**)&global_slapdFrontendConfig.ldapi_root_dn, CONFIG_STRING, NULL},
  459. {CONFIG_LDAPI_MAP_ENTRIES_ATTRIBUTE, config_set_ldapi_map_entries,
  460. NULL, 0,
  461. (void**)&global_slapdFrontendConfig.ldapi_map_entries, CONFIG_ON_OFF, NULL},
  462. {CONFIG_LDAPI_UIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_uidnumber_type,
  463. NULL, 0,
  464. (void**)&global_slapdFrontendConfig.ldapi_uidnumber_type, CONFIG_STRING, NULL},
  465. {CONFIG_LDAPI_GIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_gidnumber_type,
  466. NULL, 0,
  467. (void**)&global_slapdFrontendConfig.ldapi_gidnumber_type, CONFIG_STRING, NULL},
  468. {CONFIG_LDAPI_SEARCH_BASE_DN_ATTRIBUTE, config_set_ldapi_search_base_dn,
  469. NULL, 0,
  470. (void**)&global_slapdFrontendConfig.ldapi_search_base_dn, CONFIG_STRING, NULL},
  471. #if defined(ENABLE_AUTO_DN_SUFFIX)
  472. {CONFIG_LDAPI_AUTO_DN_SUFFIX_ATTRIBUTE, config_set_ldapi_auto_dn_suffix,
  473. NULL, 0,
  474. (void**)&global_slapdFrontendConfig.ldapi_auto_dn_suffix, CONFIG_STRING, NULL},
  475. #endif
  476. {CONFIG_SLAPI_COUNTER_ATTRIBUTE, config_set_slapi_counters,
  477. NULL, 0,
  478. (void**)&global_slapdFrontendConfig.slapi_counters, CONFIG_ON_OFF,
  479. (ConfigGetFunc)config_get_slapi_counters},
  480. {CONFIG_ACCESSLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  481. log_set_mindiskspace, SLAPD_ACCESS_LOG,
  482. (void**)&global_slapdFrontendConfig.accesslog_minfreespace, CONFIG_INT, NULL},
  483. {CONFIG_ERRORLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  484. log_set_numlogsperdir, SLAPD_ERROR_LOG,
  485. (void**)&global_slapdFrontendConfig.errorlog_maxnumlogs, CONFIG_INT, NULL},
  486. {CONFIG_SECURELISTENHOST_ATTRIBUTE, config_set_securelistenhost,
  487. NULL, 0,
  488. (void**)&global_slapdFrontendConfig.securelistenhost, CONFIG_STRING, NULL},
  489. {CONFIG_AUDITLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  490. log_set_mindiskspace, SLAPD_AUDIT_LOG,
  491. (void**)&global_slapdFrontendConfig.auditlog_minfreespace, CONFIG_INT, NULL},
  492. {CONFIG_ROOTDN_ATTRIBUTE, config_set_rootdn,
  493. NULL, 0,
  494. (void**)&global_slapdFrontendConfig.rootdn, CONFIG_STRING, NULL},
  495. {CONFIG_PW_MINAGE_ATTRIBUTE, config_set_pw_minage,
  496. NULL, 0,
  497. (void**)&global_slapdFrontendConfig.pw_policy.pw_minage, CONFIG_LONG, NULL},
  498. {CONFIG_AUDITFILE_ATTRIBUTE, config_set_auditlog,
  499. NULL, 0,
  500. (void**)&global_slapdFrontendConfig.auditlog, CONFIG_STRING_OR_EMPTY, NULL},
  501. {CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, config_set_return_exact_case,
  502. NULL, 0,
  503. (void**)&global_slapdFrontendConfig.return_exact_case, CONFIG_ON_OFF, NULL},
  504. {CONFIG_RESULT_TWEAK_ATTRIBUTE, config_set_result_tweak,
  505. NULL, 0,
  506. (void**)&global_slapdFrontendConfig.result_tweak, CONFIG_ON_OFF, NULL},
  507. {CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, config_set_attrname_exceptions,
  508. NULL, 0,
  509. (void**)&global_slapdFrontendConfig.attrname_exceptions, CONFIG_ON_OFF, NULL},
  510. {CONFIG_MAXBERSIZE_ATTRIBUTE, config_set_maxbersize,
  511. NULL, 0,
  512. (void**)&global_slapdFrontendConfig.maxbersize, CONFIG_INT, NULL},
  513. {CONFIG_MAXSASLIOSIZE_ATTRIBUTE, config_set_maxsasliosize,
  514. NULL, 0,
  515. (void**)&global_slapdFrontendConfig.maxsasliosize, CONFIG_INT, NULL},
  516. {CONFIG_VERSIONSTRING_ATTRIBUTE, config_set_versionstring,
  517. NULL, 0,
  518. (void**)&global_slapdFrontendConfig.versionstring, CONFIG_STRING, NULL},
  519. {CONFIG_REFERRAL_MODE_ATTRIBUTE, config_set_referral_mode,
  520. NULL, 0,
  521. (void**)&global_slapdFrontendConfig.refer_url, CONFIG_STRING, NULL},
  522. #if !defined(_WIN32) && !defined(AIX)
  523. {CONFIG_MAXDESCRIPTORS_ATTRIBUTE, config_set_maxdescriptors,
  524. NULL, 0,
  525. (void**)&global_slapdFrontendConfig.maxdescriptors, CONFIG_INT, NULL},
  526. #endif
  527. {CONFIG_CONNTABLESIZE_ATTRIBUTE, config_set_conntablesize,
  528. NULL, 0,
  529. (void**)&global_slapdFrontendConfig.conntablesize, CONFIG_INT, NULL},
  530. {CONFIG_SSLCLIENTAUTH_ATTRIBUTE, config_set_SSLclientAuth,
  531. NULL, 0,
  532. (void **)&global_slapdFrontendConfig.SSLclientAuth, CONFIG_SPECIAL_SSLCLIENTAUTH, NULL},
  533. {CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE, config_set_ssl_check_hostname,
  534. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_ssl_check_hostname},
  535. {CONFIG_CONFIG_ATTRIBUTE, 0, NULL, 0, (void**)SLAPD_CONFIG_DN,
  536. CONFIG_CONSTANT_STRING, NULL},
  537. {CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
  538. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters},
  539. /* instance dir; used by admin tasks */
  540. {CONFIG_INSTDIR_ATTRIBUTE, config_set_instancedir,
  541. NULL, 0, NULL, CONFIG_STRING, NULL},
  542. /* parameterizing schema dir */
  543. {CONFIG_SCHEMADIR_ATTRIBUTE, config_set_schemadir,
  544. NULL, 0,
  545. (void**)&global_slapdFrontendConfig.schemadir, CONFIG_STRING, NULL},
  546. /* parameterizing lock dir */
  547. {CONFIG_LOCKDIR_ATTRIBUTE, config_set_lockdir,
  548. NULL, 0,
  549. (void**)&global_slapdFrontendConfig.lockdir, CONFIG_STRING, (ConfigGetFunc)config_get_lockdir},
  550. /* parameterizing tmp dir */
  551. {CONFIG_TMPDIR_ATTRIBUTE, config_set_tmpdir,
  552. NULL, 0,
  553. (void**)&global_slapdFrontendConfig.tmpdir, CONFIG_STRING, (ConfigGetFunc)config_get_tmpdir},
  554. /* parameterizing cert dir */
  555. {CONFIG_CERTDIR_ATTRIBUTE, config_set_certdir,
  556. NULL, 0,
  557. (void**)&global_slapdFrontendConfig.certdir, CONFIG_STRING, (ConfigGetFunc)config_get_certdir},
  558. /* parameterizing ldif dir */
  559. {CONFIG_LDIFDIR_ATTRIBUTE, config_set_ldifdir,
  560. NULL, 0,
  561. (void**)&global_slapdFrontendConfig.ldifdir, CONFIG_STRING, (ConfigGetFunc)config_get_ldifdir},
  562. /* parameterizing bak dir */
  563. {CONFIG_BAKDIR_ATTRIBUTE, config_set_bakdir,
  564. NULL, 0,
  565. (void**)&global_slapdFrontendConfig.bakdir, CONFIG_STRING, (ConfigGetFunc)config_get_bakdir},
  566. /* parameterizing sasl plugin path */
  567. {CONFIG_SASLPATH_ATTRIBUTE, config_set_saslpath,
  568. NULL, 0,
  569. (void**)&global_slapdFrontendConfig.saslpath, CONFIG_STRING, (ConfigGetFunc)config_get_saslpath},
  570. /* parameterizing run dir */
  571. {CONFIG_RUNDIR_ATTRIBUTE, config_set_rundir,
  572. NULL, 0,
  573. (void**)&global_slapdFrontendConfig.rundir, CONFIG_STRING, (ConfigGetFunc)config_get_rundir},
  574. {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
  575. NULL, 0,
  576. (void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
  577. {CONFIG_OUTBOUND_LDAP_IO_TIMEOUT_ATTRIBUTE,
  578. config_set_outbound_ldap_io_timeout,
  579. NULL, 0,
  580. (void **)&global_slapdFrontendConfig.outbound_ldap_io_timeout,
  581. CONFIG_INT, NULL},
  582. {CONFIG_UNAUTH_BINDS_ATTRIBUTE, config_set_unauth_binds_switch,
  583. NULL, 0,
  584. (void**)&global_slapdFrontendConfig.allow_unauth_binds, CONFIG_ON_OFF,
  585. (ConfigGetFunc)config_get_unauth_binds_switch}
  586. #ifdef MEMPOOL_EXPERIMENTAL
  587. ,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
  588. NULL, 0,
  589. (void**)&global_slapdFrontendConfig.mempool_switch, CONFIG_ON_OFF, (ConfigGetFunc)config_get_mempool_switch},
  590. {CONFIG_MEMPOOL_MAXFREELIST_ATTRIBUTE, config_set_mempool_maxfreelist,
  591. NULL, 0,
  592. (void**)&global_slapdFrontendConfig.mempool_maxfreelist, CONFIG_INT, (ConfigGetFunc)config_get_mempool_maxfreelist}
  593. #endif /* MEMPOOL_EXPERIMENTAL */
  594. };
  595. /*
  596. * hashNocaseString - used for case insensitive hash lookups
  597. */
  598. static PLHashNumber
  599. hashNocaseString(const void *key)
  600. {
  601. PLHashNumber h = 0;
  602. const unsigned char *s;
  603. for (s = key; *s; s++)
  604. h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
  605. return h;
  606. }
  607. /*
  608. * hashNocaseCompare - used for case insensitive hash key comparisons
  609. */
  610. static PRIntn
  611. hashNocaseCompare(const void *v1, const void *v2)
  612. {
  613. return (strcasecmp((char *)v1, (char *)v2) == 0);
  614. }
  615. static PLHashTable *confighash = 0;
  616. static void
  617. init_config_get_and_set()
  618. {
  619. if (!confighash) {
  620. int ii = 0;
  621. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  622. confighash = PL_NewHashTable(tablesize+1, hashNocaseString,
  623. hashNocaseCompare,
  624. PL_CompareValues, 0, 0);
  625. for (ii = 0; ii < tablesize; ++ii) {
  626. if (PL_HashTableLookup(confighash, ConfigList[ii].attr_name))
  627. printf("error: %s is already in the list\n",
  628. ConfigList[ii].attr_name);
  629. if (!PL_HashTableAdd(confighash, ConfigList[ii].attr_name, &ConfigList[ii]))
  630. printf("error: could not add %s to the list\n",
  631. ConfigList[ii].attr_name);
  632. }
  633. }
  634. }
  635. #if 0
  636. #define GOLDEN_RATIO 0x9E3779B9U
  637. PR_IMPLEMENT(PLHashEntry **)
  638. PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
  639. {
  640. PLHashEntry *he, **hep, **hep0;
  641. PLHashNumber h;
  642. #ifdef HASHMETER
  643. ht->nlookups++;
  644. #endif
  645. h = keyHash * GOLDEN_RATIO;
  646. h >>= ht->shift;
  647. hep = hep0 = &ht->buckets[h];
  648. while ((he = *hep) != 0) {
  649. if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
  650. /* Move to front of chain if not already there */
  651. if (hep != hep0) {
  652. *hep = he->next;
  653. he->next = *hep0;
  654. *hep0 = he;
  655. }
  656. return hep0;
  657. }
  658. hep = &he->next;
  659. #ifdef HASHMETER
  660. ht->nsteps++;
  661. #endif
  662. }
  663. return hep;
  664. }
  665. static void
  666. debugHashTable(const char *key)
  667. {
  668. int ii = 0;
  669. PLHashEntry **hep = PL_HashTableRawLookup(confighash, hashNocaseString(key),
  670. key);
  671. if (!hep || !*hep)
  672. printf("raw lookup failed for %s\n", key);
  673. else if (hep && *hep)
  674. printf("raw lookup found %s -> %ul %s\n", key, (*hep)->keyHash, (*hep)->key);
  675. printf("hash table has %d entries\n", confighash->nentries);
  676. for (ii = 0; ii < confighash->nentries; ++ii)
  677. {
  678. PLHashEntry *he = confighash->buckets[ii];
  679. if (!he)
  680. printf("hash table entry %d is null\n", ii);
  681. else {
  682. printf("hash bucket %d:\n", ii);
  683. while (he) {
  684. int keys = !hashNocaseCompare(key, he->key);
  685. int hash = (hashNocaseString(key) == he->keyHash);
  686. printf("\thashval = %ul key = %s\n", he->keyHash, he->key);
  687. if (keys && hash) {
  688. printf("\t\tFOUND\n");
  689. } else if (keys) {
  690. printf("\t\tkeys match but hash vals do not\n");
  691. } else if (hash) {
  692. printf("\t\thash match but keys do not\n");
  693. }
  694. he = he->next;
  695. }
  696. }
  697. }
  698. }
  699. #endif
  700. static void
  701. bervalarray_free(struct berval **bvec)
  702. {
  703. int ii = 0;
  704. for(ii = 0; bvec && bvec[ii]; ++ii) {
  705. slapi_ch_free((void **)&bvec[ii]->bv_val);
  706. slapi_ch_free((void **)&bvec[ii]);
  707. }
  708. slapi_ch_free((void**)&bvec);
  709. }
  710. static struct berval **
  711. strarray2bervalarray(const char **strarray)
  712. {
  713. int ii = 0;
  714. struct berval **newlist = 0;
  715. /* first, count the number of items in the list */
  716. for (ii = 0; strarray && strarray[ii]; ++ii);
  717. /* if no items, return null */
  718. if (!ii)
  719. return newlist;
  720. /* allocate the list */
  721. newlist = (struct berval **)slapi_ch_malloc((ii+1) * sizeof(struct berval *));
  722. newlist[ii] = 0;
  723. for (; ii; --ii) {
  724. newlist[ii-1] = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
  725. newlist[ii-1]->bv_val = slapi_ch_strdup(strarray[ii-1]);
  726. newlist[ii-1]->bv_len = strlen(strarray[ii-1]);
  727. }
  728. return newlist;
  729. }
  730. /*
  731. * counter for active threads
  732. */
  733. static PRInt32 active_threads = 0;
  734. void
  735. g_incr_active_threadcnt()
  736. {
  737. PR_AtomicIncrement(&active_threads);
  738. }
  739. void
  740. g_decr_active_threadcnt()
  741. {
  742. PR_AtomicDecrement(&active_threads);
  743. }
  744. int
  745. g_get_active_threadcnt()
  746. {
  747. return (int)active_threads;
  748. }
  749. /*
  750. ** Setting this flag forces the server to shutdown.
  751. */
  752. static int slapd_shutdown;
  753. void g_set_shutdown( int reason )
  754. {
  755. slapd_shutdown = reason;
  756. }
  757. int g_get_shutdown()
  758. {
  759. return slapd_shutdown;
  760. }
  761. static int cmd_shutdown;
  762. void c_set_shutdown()
  763. {
  764. cmd_shutdown = SLAPI_SHUTDOWN_SIGNAL;
  765. }
  766. int c_get_shutdown()
  767. {
  768. return cmd_shutdown;
  769. }
  770. slapdFrontendConfig_t *
  771. getFrontendConfig()
  772. {
  773. return &global_slapdFrontendConfig;
  774. }
  775. /*
  776. * FrontendConfig_init:
  777. * Put all default values for config stuff here.
  778. * If there's no default value, the value will be NULL if it's not set in dse.ldif
  779. */
  780. void
  781. FrontendConfig_init () {
  782. slapdFrontendConfig_t *cfg = getFrontendConfig();
  783. /* initialize the read/write configuration lock */
  784. if ( (cfg->cfg_rwlock = rwl_new()) == NULL ) {
  785. LDAPDebug ( LDAP_DEBUG_ANY,
  786. "FrontendConfig_init: failed to initialize cfg_rwlock. Exiting now.",
  787. 0,0,0 );
  788. exit(-1);
  789. }
  790. cfg->port = LDAP_PORT;
  791. cfg->secureport = LDAPS_PORT;
  792. cfg->ldapi_filename = slapi_ch_strdup(SLAPD_LDAPI_DEFAULT_FILENAME);
  793. cfg->ldapi_switch = LDAP_OFF;
  794. cfg->ldapi_bind_switch = LDAP_OFF;
  795. cfg->ldapi_root_dn = slapi_ch_strdup("cn=Directory Manager");
  796. cfg->ldapi_map_entries = LDAP_OFF;
  797. cfg->ldapi_uidnumber_type = slapi_ch_strdup("uidNumber");
  798. cfg->ldapi_gidnumber_type = slapi_ch_strdup("gidNumber");
  799. cfg->ldapi_search_base_dn = slapi_ch_strdup("dc=example, dc=com");
  800. #if defined(ENABLE_AUTO_DN_SUFFIX)
  801. cfg->ldapi_auto_dn_suffix = slapi_ch_strdup("cn=peercred,cn=external,cn=auth");
  802. #endif
  803. cfg->allow_unauth_binds = LDAP_OFF;
  804. cfg->slapi_counters = LDAP_ON;
  805. cfg->threadnumber = SLAPD_DEFAULT_MAX_THREADS;
  806. cfg->maxthreadsperconn = SLAPD_DEFAULT_MAX_THREADS_PER_CONN;
  807. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  808. cfg->idletimeout = SLAPD_DEFAULT_IDLE_TIMEOUT;
  809. cfg->ioblocktimeout = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  810. cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
  811. cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
  812. cfg->maxsasliosize = SLAPD_DEFAULT_MAX_SASLIO_SIZE;
  813. #ifdef _WIN32
  814. cfg->conntablesize = SLAPD_DEFAULT_CONNTABLESIZE;
  815. #else
  816. #ifdef USE_SYSCONF
  817. cfg->conntablesize = sysconf( _SC_OPEN_MAX );
  818. #else /* USE_SYSCONF */
  819. cfg->conntablesize = getdtablesize();
  820. #endif /* USE_SYSCONF */
  821. #endif /* _WIN32 */
  822. cfg->accesscontrol = LDAP_ON;
  823. cfg->security = LDAP_OFF;
  824. cfg->ssl_check_hostname = LDAP_ON;
  825. cfg->return_exact_case = LDAP_ON;
  826. cfg->result_tweak = LDAP_OFF;
  827. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  828. cfg->useroc = slapi_ch_strdup ( "" );
  829. cfg->userat = slapi_ch_strdup ( "" );
  830. /* kexcoff: should not be initialized by default here
  831. cfg->rootpwstoragescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  832. cfg->pw_storagescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  833. */
  834. cfg->slapd_type = 0;
  835. cfg->versionstring = SLAPD_VERSION_STR;
  836. cfg->sizelimit = SLAPD_DEFAULT_SIZELIMIT;
  837. cfg->timelimit = SLAPD_DEFAULT_TIMELIMIT;
  838. cfg->schemacheck = LDAP_ON;
  839. cfg->ds4_compatible_schema = LDAP_OFF;
  840. cfg->enquote_sup_oc = LDAP_OFF;
  841. cfg->lastmod = LDAP_ON;
  842. cfg->rewrite_rfc1274 = LDAP_OFF;
  843. cfg->schemareplace = slapi_ch_strdup( CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY );
  844. cfg->schema_ignore_trailing_spaces = SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES;
  845. cfg->pwpolicy_local = LDAP_OFF;
  846. cfg->pw_policy.pw_change = LDAP_ON;
  847. cfg->pw_policy.pw_must_change = LDAP_OFF;
  848. cfg->pw_policy.pw_syntax = LDAP_OFF;
  849. cfg->pw_policy.pw_exp = LDAP_OFF;
  850. cfg->pw_policy.pw_minlength = 8;
  851. cfg->pw_policy.pw_mindigits = 0;
  852. cfg->pw_policy.pw_minalphas = 0;
  853. cfg->pw_policy.pw_minuppers = 0;
  854. cfg->pw_policy.pw_minlowers = 0;
  855. cfg->pw_policy.pw_minspecials = 0;
  856. cfg->pw_policy.pw_min8bit = 0;
  857. cfg->pw_policy.pw_maxrepeats = 0;
  858. cfg->pw_policy.pw_mincategories = 3;
  859. cfg->pw_policy.pw_mintokenlength = 3;
  860. cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
  861. cfg->pw_policy.pw_minage = 0;
  862. cfg->pw_policy.pw_warning = 86400; /* 1 day */
  863. cfg->pw_policy.pw_history = LDAP_OFF;
  864. cfg->pw_policy.pw_inhistory = 6;
  865. cfg->pw_policy.pw_lockout = LDAP_OFF;
  866. cfg->pw_policy.pw_maxfailure = 3;
  867. cfg->pw_policy.pw_unlock = LDAP_ON;
  868. cfg->pw_policy.pw_lockduration = 3600; /* 60 minutes */
  869. cfg->pw_policy.pw_resetfailurecount = 600; /* 10 minutes */
  870. cfg->pw_policy.pw_gracelimit = 0;
  871. cfg->pw_is_global_policy = LDAP_OFF;
  872. cfg->accesslog_logging_enabled = LDAP_ON;
  873. cfg->accesslog_mode = slapi_ch_strdup("600");
  874. cfg->accesslog_maxnumlogs = 10;
  875. cfg->accesslog_maxlogsize = 100;
  876. cfg->accesslog_rotationtime = 1;
  877. cfg->accesslog_rotationunit = slapi_ch_strdup("day");
  878. cfg->accesslog_rotationsync_enabled = LDAP_OFF;
  879. cfg->accesslog_rotationsynchour = 0;
  880. cfg->accesslog_rotationsyncmin = 0;
  881. cfg->accesslog_maxdiskspace = 500;
  882. cfg->accesslog_minfreespace = 5;
  883. cfg->accesslog_exptime = 1;
  884. cfg->accesslog_exptimeunit = slapi_ch_strdup("month");
  885. cfg->accessloglevel = 256;
  886. cfg->accesslogbuffering = LDAP_ON;
  887. cfg->csnlogging = LDAP_ON;
  888. cfg->errorlog_logging_enabled = LDAP_ON;
  889. cfg->errorlog_mode = slapi_ch_strdup("600");
  890. cfg->errorlog_maxnumlogs = 1;
  891. cfg->errorlog_maxlogsize = 100;
  892. cfg->errorlog_rotationtime = 1;
  893. cfg->errorlog_rotationunit = slapi_ch_strdup ("week");
  894. cfg->errorlog_rotationsync_enabled = LDAP_OFF;
  895. cfg->errorlog_rotationsynchour = 0;
  896. cfg->errorlog_rotationsyncmin = 0;
  897. cfg->errorlog_maxdiskspace = 100;
  898. cfg->errorlog_minfreespace = 5;
  899. cfg->errorlog_exptime = 1;
  900. cfg->errorlog_exptimeunit = slapi_ch_strdup("month");
  901. cfg->errorloglevel = 0;
  902. cfg->auditlog_logging_enabled = LDAP_OFF;
  903. cfg->auditlog_mode = slapi_ch_strdup("600");
  904. cfg->auditlog_maxnumlogs = 1;
  905. cfg->auditlog_maxlogsize = 100;
  906. cfg->auditlog_rotationtime = 1;
  907. cfg->auditlog_rotationunit = slapi_ch_strdup ("week");
  908. cfg->auditlog_rotationsync_enabled = LDAP_OFF;
  909. cfg->auditlog_rotationsynchour = 0;
  910. cfg->auditlog_rotationsyncmin = 0;
  911. cfg->auditlog_maxdiskspace = 100;
  912. cfg->auditlog_minfreespace = 5;
  913. cfg->auditlog_exptime = 1;
  914. cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
  915. #ifdef MEMPOOL_EXPERIMENTAL
  916. cfg->mempool_switch = LDAP_ON;
  917. cfg->mempool_maxfreelist = 1024;
  918. cfg->system_page_size = sysconf(_SC_PAGE_SIZE); /* not to get every time; no set, get only */
  919. {
  920. long sc_size = cfg->system_page_size;
  921. cfg->system_page_bits = 0;
  922. while ((sc_size >>= 1) > 0) {
  923. cfg->system_page_bits++; /* to calculate once; no set, get only */
  924. }
  925. }
  926. #endif /* MEMPOOL_EXPERIMENTAL */
  927. init_config_get_and_set();
  928. }
  929. int
  930. g_get_global_lastmod()
  931. {
  932. return config_get_lastmod();
  933. }
  934. int g_get_slapd_security_on(){
  935. return config_get_security();
  936. }
  937. #ifdef _WIN32
  938. void libldap_init_debug_level(int *val_ptr)
  939. {
  940. module_ldap_debug = val_ptr;
  941. }
  942. #endif
  943. struct snmp_vars_t global_snmp_vars;
  944. struct snmp_vars_t * g_get_global_snmp_vars(){
  945. return &global_snmp_vars;
  946. }
  947. static slapdEntryPoints *sep = NULL;
  948. void
  949. set_dll_entry_points( slapdEntryPoints *p )
  950. {
  951. if ( NULL == sep )
  952. {
  953. sep = p;
  954. }
  955. }
  956. int
  957. get_entry_point( int ep_name, caddr_t *ep_addr )
  958. {
  959. int rc = 0;
  960. if(sep!=NULL)
  961. {
  962. switch ( ep_name ) {
  963. case ENTRY_POINT_PS_WAKEUP_ALL:
  964. *ep_addr = sep->sep_ps_wakeup_all;
  965. break;
  966. case ENTRY_POINT_PS_SERVICE:
  967. *ep_addr = sep->sep_ps_service;
  968. break;
  969. case ENTRY_POINT_DISCONNECT_SERVER:
  970. *ep_addr = sep->sep_disconnect_server;
  971. break;
  972. case ENTRY_POINT_SLAPD_SSL_INIT:
  973. *ep_addr = sep->sep_slapd_ssl_init;
  974. break;
  975. case ENTRY_POINT_SLAPD_SSL_INIT2:
  976. *ep_addr = sep->sep_slapd_ssl_init2;
  977. break;
  978. default:
  979. rc = -1;
  980. }
  981. }
  982. else
  983. {
  984. rc= -1;
  985. }
  986. return rc;
  987. }
  988. /*
  989. * Utility function called by many of the config_set_XXX() functions.
  990. * Returns a non-zero value if 'value' is NULL and zero if not.
  991. * Also constructs an error message in 'errorbuf' if value is NULL.
  992. * If or_zero_length is non-zero, zero length values are treated as
  993. * equivalent to NULL (i.e., they will cause a non-zero value to be
  994. * returned by this function).
  995. */
  996. static int
  997. config_value_is_null( const char *attrname, const char *value, char *errorbuf,
  998. int or_zero_length )
  999. {
  1000. if ( NULL == value || ( or_zero_length && *value == '\0' )) {
  1001. PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value",
  1002. attrname );
  1003. return 1;
  1004. }
  1005. return 0;
  1006. }
  1007. int
  1008. config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
  1009. long nPort;
  1010. char *endp = NULL;
  1011. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1012. int retVal = LDAP_SUCCESS;
  1013. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  1014. return LDAP_OPERATIONS_ERROR;
  1015. }
  1016. errno = 0;
  1017. nPort = strtol(port, &endp, 10);
  1018. if ( *endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort < 0 ) {
  1019. retVal = LDAP_OPERATIONS_ERROR;
  1020. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1021. "%s: \"%s\" is invalid, ports must range from 0 to %d",
  1022. attrname, port, LDAP_PORT_MAX );
  1023. return retVal;
  1024. }
  1025. if ( nPort == 0 ) {
  1026. LDAPDebug( LDAP_DEBUG_ANY,
  1027. "Information: Non-Secure Port Disabled\n", 0, 0, 0 );
  1028. }
  1029. if ( apply ) {
  1030. CFG_LOCK_WRITE(slapdFrontendConfig);
  1031. slapdFrontendConfig->port = nPort;
  1032. /* n_port = nPort; */
  1033. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1034. }
  1035. return retVal;
  1036. }
  1037. int
  1038. config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply ) {
  1039. long nPort;
  1040. char *endp = NULL;
  1041. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1042. int retVal = LDAP_SUCCESS;
  1043. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  1044. return LDAP_OPERATIONS_ERROR;
  1045. }
  1046. errno = 0;
  1047. nPort = strtol(port, &endp, 10);
  1048. if (*endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort <= 0 ) {
  1049. retVal = LDAP_OPERATIONS_ERROR;
  1050. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1051. "%s: \"%s\" is invalid, ports must range from 1 to %d",
  1052. attrname, port, LDAP_PORT_MAX );
  1053. }
  1054. if (apply) {
  1055. CFG_LOCK_WRITE(slapdFrontendConfig);
  1056. slapdFrontendConfig->secureport = nPort;
  1057. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1058. }
  1059. return retVal;
  1060. }
  1061. int
  1062. config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
  1063. int retVal = LDAP_SUCCESS;
  1064. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1065. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1066. retVal = LDAP_OPERATIONS_ERROR;
  1067. }
  1068. /* first check the value, return an error if it's invalid */
  1069. else if ( strcasecmp (value, "off") != 0 &&
  1070. strcasecmp (value, "allowed") != 0 &&
  1071. strcasecmp (value, "required")!= 0 ) {
  1072. retVal = LDAP_OPERATIONS_ERROR;
  1073. if( errorbuf )
  1074. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1075. "%s: unsupported value: %s", attrname, value );
  1076. return retVal;
  1077. }
  1078. else if ( !apply ) {
  1079. /* return success now, if we aren't supposed to apply the change */
  1080. return retVal;
  1081. }
  1082. CFG_LOCK_WRITE(slapdFrontendConfig);
  1083. if ( !strcasecmp( value, "off" )) {
  1084. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_OFF;
  1085. }
  1086. else if ( !strcasecmp( value, "allowed" )) {
  1087. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_ALLOWED;
  1088. }
  1089. else if ( !strcasecmp( value, "required" )) {
  1090. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_REQUIRED;
  1091. }
  1092. else {
  1093. retVal = LDAP_OPERATIONS_ERROR;
  1094. if( errorbuf )
  1095. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1096. "%s: unsupported value: %s", attrname, value );
  1097. }
  1098. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1099. return retVal;
  1100. }
  1101. int
  1102. config_set_ssl_check_hostname(const char *attrname, char *value,
  1103. char *errorbuf, int apply)
  1104. {
  1105. int retVal = LDAP_SUCCESS;
  1106. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1107. retVal = config_set_onoff(attrname,
  1108. value,
  1109. &(slapdFrontendConfig->ssl_check_hostname),
  1110. errorbuf,
  1111. apply);
  1112. return retVal;
  1113. }
  1114. int
  1115. config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1116. int retVal = LDAP_SUCCESS;
  1117. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1118. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1119. return LDAP_OPERATIONS_ERROR;
  1120. }
  1121. if (apply) {
  1122. CFG_LOCK_WRITE(slapdFrontendConfig);
  1123. slapi_ch_free ( (void **) &(slapdFrontendConfig->localhost) );
  1124. slapdFrontendConfig->localhost = slapi_ch_strdup ( value );
  1125. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1126. }
  1127. return retVal;
  1128. }
  1129. int
  1130. config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1131. int retVal = LDAP_SUCCESS;
  1132. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1133. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1134. return LDAP_OPERATIONS_ERROR;
  1135. }
  1136. if ( apply) {
  1137. CFG_LOCK_WRITE(slapdFrontendConfig);
  1138. slapi_ch_free ( (void **) &(slapdFrontendConfig->listenhost) );
  1139. slapdFrontendConfig->listenhost = slapi_ch_strdup ( value );
  1140. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1141. }
  1142. return retVal;
  1143. }
  1144. int
  1145. config_set_ldapi_filename( const char *attrname, char *value, char *errorbuf, int apply ) {
  1146. int retVal = LDAP_SUCCESS;
  1147. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1148. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1149. return LDAP_OPERATIONS_ERROR;
  1150. }
  1151. if ( apply) {
  1152. CFG_LOCK_WRITE(slapdFrontendConfig);
  1153. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_filename) );
  1154. slapdFrontendConfig->ldapi_filename = slapi_ch_strdup ( value );
  1155. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1156. }
  1157. return retVal;
  1158. }
  1159. int
  1160. config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
  1161. int retVal = LDAP_SUCCESS;
  1162. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1163. retVal = config_set_onoff(attrname,
  1164. value,
  1165. &(slapdFrontendConfig->ldapi_switch),
  1166. errorbuf,
  1167. apply);
  1168. return retVal;
  1169. }
  1170. int config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply )
  1171. {
  1172. int retVal = LDAP_SUCCESS;
  1173. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1174. retVal = config_set_onoff(attrname,
  1175. value,
  1176. &(slapdFrontendConfig->ldapi_bind_switch),
  1177. errorbuf,
  1178. apply);
  1179. return retVal;
  1180. }
  1181. int config_set_ldapi_root_dn( const char *attrname, char *value, char *errorbuf, int apply )
  1182. {
  1183. int retVal = LDAP_SUCCESS;
  1184. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1185. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1186. return LDAP_OPERATIONS_ERROR;
  1187. }
  1188. if ( apply) {
  1189. CFG_LOCK_WRITE(slapdFrontendConfig);
  1190. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_root_dn) );
  1191. slapdFrontendConfig->ldapi_root_dn = slapi_ch_strdup ( value );
  1192. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1193. }
  1194. return retVal;
  1195. }
  1196. int config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply )
  1197. {
  1198. int retVal = LDAP_SUCCESS;
  1199. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1200. retVal = config_set_onoff(attrname,
  1201. value,
  1202. &(slapdFrontendConfig->ldapi_map_entries),
  1203. errorbuf,
  1204. apply);
  1205. return retVal;
  1206. }
  1207. int config_set_ldapi_uidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
  1208. {
  1209. int retVal = LDAP_SUCCESS;
  1210. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1211. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1212. return LDAP_OPERATIONS_ERROR;
  1213. }
  1214. if ( apply) {
  1215. CFG_LOCK_WRITE(slapdFrontendConfig);
  1216. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_uidnumber_type) );
  1217. slapdFrontendConfig->ldapi_uidnumber_type = slapi_ch_strdup ( value );
  1218. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1219. }
  1220. return retVal;
  1221. }
  1222. int config_set_ldapi_gidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
  1223. {
  1224. int retVal = LDAP_SUCCESS;
  1225. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1226. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1227. return LDAP_OPERATIONS_ERROR;
  1228. }
  1229. if ( apply) {
  1230. CFG_LOCK_WRITE(slapdFrontendConfig);
  1231. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_gidnumber_type) );
  1232. slapdFrontendConfig->ldapi_gidnumber_type = slapi_ch_strdup ( value );
  1233. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1234. }
  1235. return retVal;
  1236. }
  1237. int config_set_ldapi_search_base_dn( const char *attrname, char *value, char *errorbuf, int apply )
  1238. {
  1239. int retVal = LDAP_SUCCESS;
  1240. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1241. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1242. return LDAP_OPERATIONS_ERROR;
  1243. }
  1244. if ( apply) {
  1245. CFG_LOCK_WRITE(slapdFrontendConfig);
  1246. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_search_base_dn) );
  1247. slapdFrontendConfig->ldapi_search_base_dn = slapi_ch_strdup ( value );
  1248. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1249. }
  1250. return retVal;
  1251. }
  1252. #if defined(ENABLE_AUTO_DN_SUFFIX)
  1253. int config_set_ldapi_auto_dn_suffix( const char *attrname, char *value, char *errorbuf, int apply )
  1254. {
  1255. int retVal = LDAP_SUCCESS;
  1256. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1257. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1258. return LDAP_OPERATIONS_ERROR;
  1259. }
  1260. if ( apply) {
  1261. CFG_LOCK_WRITE(slapdFrontendConfig);
  1262. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_auto_dn_suffix) );
  1263. slapdFrontendConfig->ldapi_auto_dn_suffix = slapi_ch_strdup ( value );
  1264. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1265. }
  1266. return retVal;
  1267. }
  1268. #endif
  1269. /*
  1270. * Set nsslapd-counters: on | off to the internal config variable slapi_counters.
  1271. * If set to off, slapi_counters is not initialized and the counters are not
  1272. * incremented. Note: counters which are necessary for the server's running
  1273. * are not disabled.
  1274. */
  1275. int config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply )
  1276. {
  1277. int retVal = LDAP_SUCCESS;
  1278. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1279. retVal = config_set_onoff(attrname, value,
  1280. &(slapdFrontendConfig->slapi_counters), errorbuf, apply);
  1281. return retVal;
  1282. }
  1283. int
  1284. config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1285. int retVal = LDAP_SUCCESS;
  1286. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1287. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1288. return LDAP_OPERATIONS_ERROR;
  1289. }
  1290. if ( apply ) {
  1291. CFG_LOCK_WRITE(slapdFrontendConfig);
  1292. slapi_ch_free ( (void **) &(slapdFrontendConfig->securelistenhost) );
  1293. slapdFrontendConfig->securelistenhost = slapi_ch_strdup ( value );
  1294. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1295. }
  1296. return retVal;
  1297. }
  1298. int
  1299. config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply ) {
  1300. int retVal = LDAP_SUCCESS;
  1301. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1302. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1303. return LDAP_OPERATIONS_ERROR;
  1304. }
  1305. if (apply) {
  1306. CFG_LOCK_WRITE(slapdFrontendConfig);
  1307. slapi_ch_free ( (void **) &(slapdFrontendConfig->srvtab) );
  1308. ldap_srvtab = slapi_ch_strdup ( value );
  1309. slapdFrontendConfig->srvtab = slapi_ch_strdup ( value );
  1310. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1311. }
  1312. return retVal;
  1313. }
  1314. int
  1315. config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1316. int retVal = LDAP_SUCCESS;
  1317. long sizelimit;
  1318. char *endp = NULL;
  1319. Slapi_Backend *be;
  1320. char *cookie;
  1321. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1322. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1323. return LDAP_OPERATIONS_ERROR;
  1324. }
  1325. errno = 0;
  1326. sizelimit = strtol(value, &endp, 10);
  1327. if ( *endp != '\0' || errno == ERANGE || sizelimit < -1 ) {
  1328. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, sizelimit must range from -1 to %ld",
  1329. attrname, value, LONG_MAX );
  1330. retVal = LDAP_OPERATIONS_ERROR;
  1331. return retVal;
  1332. }
  1333. if (apply) {
  1334. CFG_LOCK_WRITE(slapdFrontendConfig);
  1335. slapdFrontendConfig->sizelimit= sizelimit;
  1336. g_set_defsize (sizelimit);
  1337. cookie = NULL;
  1338. be = slapi_get_first_backend(&cookie);
  1339. while (be) {
  1340. be->be_sizelimit = slapdFrontendConfig->sizelimit;
  1341. be = slapi_get_next_backend(cookie);
  1342. }
  1343. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1344. slapi_ch_free ((void **)&cookie);
  1345. }
  1346. return retVal;
  1347. }
  1348. int
  1349. config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  1350. int retVal = LDAP_SUCCESS;
  1351. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1352. struct pw_scheme *new_scheme = NULL;
  1353. char * scheme_list = NULL;
  1354. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1355. return LDAP_OPERATIONS_ERROR;
  1356. }
  1357. scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  1358. new_scheme = pw_name2scheme(value);
  1359. if ( new_scheme == NULL) {
  1360. if ( scheme_list != NULL ) {
  1361. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1362. "%s: invalid scheme - %s. Valid schemes are: %s",
  1363. attrname, value, scheme_list );
  1364. } else {
  1365. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1366. "%s: invalid scheme - %s (no pwdstorage scheme"
  1367. " plugin loaded)",
  1368. attrname, value);
  1369. }
  1370. retVal = LDAP_OPERATIONS_ERROR;
  1371. slapi_ch_free_string(&scheme_list);
  1372. return retVal;
  1373. }
  1374. else if ( new_scheme->pws_enc == NULL )
  1375. {
  1376. /* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
  1377. compatibility with an Old Messaging Server that was setting passwords in the
  1378. directory already encrypted. The scheme cannot and don't encrypt password if
  1379. they are in clear. We don't take it */
  1380. if ( scheme_list != NULL ) {
  1381. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1382. "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
  1383. }
  1384. retVal = LDAP_UNWILLING_TO_PERFORM;
  1385. slapi_ch_free_string(&scheme_list);
  1386. return retVal;
  1387. }
  1388. if ( apply ) {
  1389. CFG_LOCK_WRITE(slapdFrontendConfig);
  1390. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  1391. slapdFrontendConfig->pw_storagescheme = new_scheme;
  1392. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1393. } else {
  1394. free_pw_scheme(new_scheme);
  1395. }
  1396. slapi_ch_free_string(&scheme_list);
  1397. return retVal;
  1398. }
  1399. int
  1400. config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1401. int retVal = LDAP_SUCCESS;
  1402. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1403. retVal = config_set_onoff ( attrname,
  1404. value,
  1405. &(slapdFrontendConfig->pw_policy.pw_change),
  1406. errorbuf,
  1407. apply);
  1408. if (retVal == LDAP_SUCCESS) {
  1409. /* LP: Update ACI to reflect the value ! */
  1410. if (apply)
  1411. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1412. !slapdFrontendConfig->pw_policy.pw_must_change);
  1413. }
  1414. return retVal;
  1415. }
  1416. int
  1417. config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) {
  1418. int retVal = LDAP_SUCCESS;
  1419. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1420. retVal = config_set_onoff ( attrname,
  1421. value,
  1422. &(slapdFrontendConfig->pw_policy.pw_history),
  1423. errorbuf,
  1424. apply);
  1425. return retVal;
  1426. }
  1427. int
  1428. config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1429. int retVal = LDAP_SUCCESS;
  1430. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1431. retVal = config_set_onoff ( attrname,
  1432. value,
  1433. &(slapdFrontendConfig->pw_policy.pw_must_change),
  1434. errorbuf,
  1435. apply);
  1436. if (retVal == LDAP_SUCCESS) {
  1437. /* LP: Update ACI to reflect the value ! */
  1438. if (apply)
  1439. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1440. !slapdFrontendConfig->pw_policy.pw_must_change);
  1441. }
  1442. return retVal;
  1443. }
  1444. int
  1445. config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) {
  1446. int retVal = LDAP_SUCCESS;
  1447. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1448. retVal = config_set_onoff ( attrname,
  1449. value,
  1450. &(slapdFrontendConfig->pwpolicy_local),
  1451. errorbuf,
  1452. apply);
  1453. return retVal;
  1454. }
  1455. int
  1456. config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) {
  1457. int retVal = LDAP_SUCCESS;
  1458. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1459. retVal = config_set_onoff ( attrname,
  1460. value,
  1461. &(slapdFrontendConfig->pw_policy.pw_syntax),
  1462. errorbuf,
  1463. apply);
  1464. return retVal;
  1465. }
  1466. int
  1467. config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  1468. int retVal = LDAP_SUCCESS;
  1469. long minLength = 0;
  1470. char *endp = NULL;
  1471. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1472. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1473. return LDAP_OPERATIONS_ERROR;
  1474. }
  1475. errno = 0;
  1476. minLength = strtol(value, &endp, 10);
  1477. if ( *endp != '\0' || errno == ERANGE || minLength < 2 || minLength > 512 ) {
  1478. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1479. "password minimum length \"%s\" is invalid. "
  1480. "The minimum length must range from 2 to 512.",
  1481. value );
  1482. retVal = LDAP_OPERATIONS_ERROR;
  1483. return retVal;
  1484. }
  1485. if ( apply ) {
  1486. CFG_LOCK_WRITE(slapdFrontendConfig);
  1487. slapdFrontendConfig->pw_policy.pw_minlength = minLength;
  1488. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1489. }
  1490. return retVal;
  1491. }
  1492. int
  1493. config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int apply ) {
  1494. int retVal = LDAP_SUCCESS;
  1495. long minDigits = 0;
  1496. char *endp = NULL;
  1497. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1498. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1499. return LDAP_OPERATIONS_ERROR;
  1500. }
  1501. errno = 0;
  1502. minDigits = strtol(value, &endp, 10);
  1503. if ( *endp != '\0' || errno == ERANGE || minDigits < 0 || minDigits > 64 ) {
  1504. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1505. "password minimum number of digits \"%s\" is invalid. "
  1506. "The minimum number of digits must range from 0 to 64.",
  1507. value );
  1508. retVal = LDAP_OPERATIONS_ERROR;
  1509. return retVal;
  1510. }
  1511. if ( apply ) {
  1512. CFG_LOCK_WRITE(slapdFrontendConfig);
  1513. slapdFrontendConfig->pw_policy.pw_mindigits = minDigits;
  1514. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1515. }
  1516. return retVal;
  1517. }
  1518. int
  1519. config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int apply ) {
  1520. int retVal = LDAP_SUCCESS;
  1521. long minAlphas = 0;
  1522. char *endp = NULL;
  1523. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1524. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1525. return LDAP_OPERATIONS_ERROR;
  1526. }
  1527. errno = 0;
  1528. minAlphas = strtol(value, &endp, 10);
  1529. if ( *endp != '\0' || errno == ERANGE || minAlphas < 0 || minAlphas > 64 ) {
  1530. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1531. "password minimum number of alphas \"%s\" is invalid. "
  1532. "The minimum number of alphas must range from 0 to 64.",
  1533. value );
  1534. retVal = LDAP_OPERATIONS_ERROR;
  1535. return retVal;
  1536. }
  1537. if ( apply ) {
  1538. CFG_LOCK_WRITE(slapdFrontendConfig);
  1539. slapdFrontendConfig->pw_policy.pw_minalphas = minAlphas;
  1540. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1541. }
  1542. return retVal;
  1543. }
  1544. int
  1545. config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int apply ) {
  1546. int retVal = LDAP_SUCCESS;
  1547. long minUppers = 0;
  1548. char *endp = NULL;
  1549. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1550. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1551. return LDAP_OPERATIONS_ERROR;
  1552. }
  1553. errno = 0;
  1554. minUppers = strtol(value, &endp, 10);
  1555. if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
  1556. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1557. "password minimum number of uppercase characters \"%s\" is invalid. "
  1558. "The minimum number of uppercase characters must range from 0 to 64.",
  1559. value );
  1560. retVal = LDAP_OPERATIONS_ERROR;
  1561. return retVal;
  1562. }
  1563. if ( apply ) {
  1564. CFG_LOCK_WRITE(slapdFrontendConfig);
  1565. slapdFrontendConfig->pw_policy.pw_minuppers = minUppers;
  1566. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1567. }
  1568. return retVal;
  1569. }
  1570. int
  1571. config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int apply ) {
  1572. int retVal = LDAP_SUCCESS;
  1573. long minLowers = 0;
  1574. char *endp = NULL;
  1575. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1576. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1577. return LDAP_OPERATIONS_ERROR;
  1578. }
  1579. errno = 0;
  1580. minLowers = strtol(value, &endp, 10);
  1581. if ( *endp != '\0' || errno == ERANGE || minLowers < 0 || minLowers > 64 ) {
  1582. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1583. "password minimum number of lowercase characters \"%s\" is invalid. "
  1584. "The minimum number of lowercase characters must range from 0 to 64.",
  1585. value );
  1586. retVal = LDAP_OPERATIONS_ERROR;
  1587. return retVal;
  1588. }
  1589. if ( apply ) {
  1590. CFG_LOCK_WRITE(slapdFrontendConfig);
  1591. slapdFrontendConfig->pw_policy.pw_minlowers = minLowers;
  1592. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1593. }
  1594. return retVal;
  1595. }
  1596. int
  1597. config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, int apply ) {
  1598. int retVal = LDAP_SUCCESS;
  1599. long minSpecials = 0;
  1600. char *endp = NULL;
  1601. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1602. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1603. return LDAP_OPERATIONS_ERROR;
  1604. }
  1605. errno = 0;
  1606. minSpecials = strtol(value, &endp, 10);
  1607. if ( *endp != '\0' || errno == ERANGE || minSpecials < 0 || minSpecials > 64 ) {
  1608. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1609. "password minimum number of special characters \"%s\" is invalid. "
  1610. "The minimum number of special characters must range from 0 to 64.",
  1611. value );
  1612. retVal = LDAP_OPERATIONS_ERROR;
  1613. return retVal;
  1614. }
  1615. if ( apply ) {
  1616. CFG_LOCK_WRITE(slapdFrontendConfig);
  1617. slapdFrontendConfig->pw_policy.pw_minspecials = minSpecials;
  1618. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1619. }
  1620. return retVal;
  1621. }
  1622. int
  1623. config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1624. int retVal = LDAP_SUCCESS;
  1625. long min8bit = 0;
  1626. char *endp = NULL;
  1627. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1628. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1629. return LDAP_OPERATIONS_ERROR;
  1630. }
  1631. errno = 0;
  1632. min8bit = strtol(value, &endp, 10);
  1633. if ( *endp != '\0' || errno == ERANGE || min8bit < 0 || min8bit > 64 ) {
  1634. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1635. "password minimum number of 8-bit characters \"%s\" is invalid. "
  1636. "The minimum number of 8-bit characters must range from 0 to 64.",
  1637. value );
  1638. retVal = LDAP_OPERATIONS_ERROR;
  1639. return retVal;
  1640. }
  1641. if ( apply ) {
  1642. CFG_LOCK_WRITE(slapdFrontendConfig);
  1643. slapdFrontendConfig->pw_policy.pw_min8bit = min8bit;
  1644. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1645. }
  1646. return retVal;
  1647. }
  1648. int
  1649. config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int apply ) {
  1650. int retVal = LDAP_SUCCESS;
  1651. long maxRepeats = 0;
  1652. char *endp = NULL;
  1653. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1654. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1655. return LDAP_OPERATIONS_ERROR;
  1656. }
  1657. errno = 0;
  1658. maxRepeats = strtol(value, &endp, 10);
  1659. if ( *endp != '\0' || errno == ERANGE || maxRepeats < 0 || maxRepeats > 64 ) {
  1660. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1661. "password maximum number of repeated characters \"%s\" is invalid. "
  1662. "The maximum number of repeated characters must range from 0 to 64.",
  1663. value );
  1664. retVal = LDAP_OPERATIONS_ERROR;
  1665. return retVal;
  1666. }
  1667. if ( apply ) {
  1668. CFG_LOCK_WRITE(slapdFrontendConfig);
  1669. slapdFrontendConfig->pw_policy.pw_maxrepeats = maxRepeats;
  1670. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1671. }
  1672. return retVal;
  1673. }
  1674. int
  1675. config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf, int apply ) {
  1676. int retVal = LDAP_SUCCESS;
  1677. long minCategories = 0;
  1678. char *endp = NULL;
  1679. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1680. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1681. return LDAP_OPERATIONS_ERROR;
  1682. }
  1683. errno = 0;
  1684. minCategories = strtol(value, &endp, 10);
  1685. if ( *endp != '\0' || errno == ERANGE || minCategories < 1 || minCategories > 5 ) {
  1686. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1687. "password minimum number of categories \"%s\" is invalid. "
  1688. "The minimum number of categories must range from 1 to 5.",
  1689. value );
  1690. retVal = LDAP_OPERATIONS_ERROR;
  1691. return retVal;
  1692. }
  1693. if ( apply ) {
  1694. CFG_LOCK_WRITE(slapdFrontendConfig);
  1695. slapdFrontendConfig->pw_policy.pw_mincategories = minCategories;
  1696. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1697. }
  1698. return retVal;
  1699. }
  1700. int
  1701. config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  1702. int retVal = LDAP_SUCCESS;
  1703. long minTokenLength = 0;
  1704. char *endp = NULL;
  1705. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1706. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1707. return LDAP_OPERATIONS_ERROR;
  1708. }
  1709. errno = 0;
  1710. minTokenLength = strtol(value, &endp, 10);
  1711. if ( *endp != '\0' || errno == ERANGE || minTokenLength < 1 || minTokenLength > 64 ) {
  1712. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1713. "password minimum token length \"%s\" is invalid. "
  1714. "The minimum token length must range from 1 to 64.",
  1715. value );
  1716. retVal = LDAP_OPERATIONS_ERROR;
  1717. return retVal;
  1718. }
  1719. if ( apply ) {
  1720. CFG_LOCK_WRITE(slapdFrontendConfig);
  1721. slapdFrontendConfig->pw_policy.pw_mintokenlength = minTokenLength;
  1722. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1723. }
  1724. return retVal;
  1725. }
  1726. int
  1727. config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int apply ) {
  1728. int retVal = LDAP_SUCCESS;
  1729. long maxFailure = 0;
  1730. char *endp = NULL;
  1731. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1732. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1733. return LDAP_OPERATIONS_ERROR;
  1734. }
  1735. errno = 0;
  1736. maxFailure = strtol(value, &endp, 10);
  1737. if ( *endp != '\0' || errno == ERANGE || maxFailure <= 0 || maxFailure > 32767 ) {
  1738. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1739. "password maximum retry \"%s\" is invalid. "
  1740. "Password maximum failure must range from 1 to 32767",
  1741. value );
  1742. retVal = LDAP_OPERATIONS_ERROR;
  1743. return retVal;
  1744. }
  1745. if ( apply ) {
  1746. CFG_LOCK_WRITE(slapdFrontendConfig);
  1747. slapdFrontendConfig->pw_policy.pw_maxfailure = maxFailure;
  1748. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1749. }
  1750. return retVal;
  1751. }
  1752. int
  1753. config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int apply ) {
  1754. int retVal = LDAP_SUCCESS;
  1755. long history = 0;
  1756. char *endp = NULL;
  1757. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1758. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1759. return LDAP_OPERATIONS_ERROR;
  1760. }
  1761. errno = 0;
  1762. history = strtol(value, &endp, 10);
  1763. if ( *endp != '\0' || errno == ERANGE || history < 2 || history > 24 ) {
  1764. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1765. "password history length \"%s\" is invalid. "
  1766. "The password history must range from 2 to 24",
  1767. value );
  1768. retVal = LDAP_OPERATIONS_ERROR;
  1769. return retVal;
  1770. }
  1771. if ( apply ) {
  1772. CFG_LOCK_WRITE(slapdFrontendConfig);
  1773. slapdFrontendConfig->pw_policy.pw_inhistory = history;
  1774. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1775. }
  1776. return retVal;
  1777. }
  1778. int
  1779. config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, int apply ) {
  1780. int retVal = LDAP_SUCCESS;
  1781. long duration = 0; /* in minutes */
  1782. char *endp = NULL;
  1783. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1784. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1785. return LDAP_OPERATIONS_ERROR;
  1786. }
  1787. errno = 0;
  1788. /* in seconds */
  1789. duration = strtol(value, &endp, 10);
  1790. if ( *endp != '\0' || errno == ERANGE || duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1791. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1792. "password lockout duration \"%s\" seconds is invalid. ",
  1793. value );
  1794. retVal = LDAP_OPERATIONS_ERROR;
  1795. return retVal;
  1796. }
  1797. if ( apply ) {
  1798. slapdFrontendConfig->pw_policy.pw_lockduration = duration;
  1799. }
  1800. return retVal;
  1801. }
  1802. int
  1803. config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorbuf, int apply ) {
  1804. int retVal = LDAP_SUCCESS;
  1805. long duration = 0; /* in minutes */
  1806. char *endp = NULL;
  1807. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1808. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1809. return LDAP_OPERATIONS_ERROR;
  1810. }
  1811. errno = 0;
  1812. /* in seconds */
  1813. duration = strtol(value, &endp, 10);
  1814. if ( *endp != '\0' || errno == ERANGE || duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1815. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1816. "password reset count duration \"%s\" seconds is invalid. ",
  1817. value );
  1818. retVal = LDAP_OPERATIONS_ERROR;
  1819. return retVal;
  1820. }
  1821. if ( apply ) {
  1822. slapdFrontendConfig->pw_policy.pw_resetfailurecount = duration;
  1823. }
  1824. return retVal;
  1825. }
  1826. int
  1827. config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
  1828. int retVal = LDAP_SUCCESS;
  1829. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1830. retVal = config_set_onoff ( attrname,
  1831. value,
  1832. &(slapdFrontendConfig->pw_is_global_policy),
  1833. errorbuf,
  1834. apply);
  1835. return retVal;
  1836. }
  1837. int
  1838. config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) {
  1839. int retVal = LDAP_SUCCESS;
  1840. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1841. retVal = config_set_onoff ( attrname,
  1842. value,
  1843. &(slapdFrontendConfig->pw_policy.pw_exp),
  1844. errorbuf,
  1845. apply);
  1846. return retVal;
  1847. }
  1848. int
  1849. config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) {
  1850. int retVal = LDAP_SUCCESS;
  1851. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1852. retVal = config_set_onoff ( attrname,
  1853. value,
  1854. &(slapdFrontendConfig->pw_policy.pw_unlock),
  1855. errorbuf,
  1856. apply);
  1857. return retVal;
  1858. }
  1859. int
  1860. config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) {
  1861. int retVal = LDAP_SUCCESS;
  1862. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1863. retVal = config_set_onoff ( attrname,
  1864. value,
  1865. &(slapdFrontendConfig->pw_policy.pw_lockout),
  1866. errorbuf,
  1867. apply);
  1868. return retVal;
  1869. }
  1870. int
  1871. config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1872. int retVal = LDAP_SUCCESS;
  1873. long gracelimit = 0;
  1874. char *endp = NULL;
  1875. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1876. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1877. return LDAP_OPERATIONS_ERROR;
  1878. }
  1879. errno = 0;
  1880. gracelimit = strtol(value, &endp, 10);
  1881. if ( *endp != '\0' || errno == ERANGE || gracelimit < 0 ) {
  1882. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1883. "password grace limit \"%s\" is invalid, password grace limit must range from 0 to %ld",
  1884. value , LONG_MAX );
  1885. retVal = LDAP_OPERATIONS_ERROR;
  1886. return retVal;
  1887. }
  1888. if ( apply ) {
  1889. CFG_LOCK_WRITE(slapdFrontendConfig);
  1890. slapdFrontendConfig->pw_policy.pw_gracelimit = gracelimit;
  1891. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1892. }
  1893. return retVal;
  1894. }
  1895. int
  1896. config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) {
  1897. int retVal = LDAP_SUCCESS;
  1898. Slapi_Backend *be = NULL;
  1899. char *cookie;
  1900. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1901. retVal = config_set_onoff ( attrname,
  1902. value,
  1903. &(slapdFrontendConfig->lastmod),
  1904. errorbuf,
  1905. apply);
  1906. if ( retVal == LDAP_SUCCESS && apply ) {
  1907. CFG_LOCK_WRITE(slapdFrontendConfig);
  1908. cookie = NULL;
  1909. be = slapi_get_first_backend (&cookie);
  1910. while (be) {
  1911. be->be_lastmod = slapdFrontendConfig->lastmod;
  1912. be = slapi_get_next_backend (cookie);
  1913. }
  1914. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1915. slapi_ch_free ((void **)&cookie);
  1916. }
  1917. return retVal;
  1918. }
  1919. int
  1920. config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) {
  1921. int retVal = LDAP_SUCCESS;
  1922. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1923. retVal = config_set_onoff ( attrname,
  1924. value,
  1925. &(slapdFrontendConfig->nagle),
  1926. errorbuf,
  1927. apply);
  1928. return retVal;
  1929. }
  1930. int
  1931. config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) {
  1932. int retVal = LDAP_SUCCESS;
  1933. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1934. retVal = config_set_onoff ( attrname,
  1935. value,
  1936. &(slapdFrontendConfig->accesscontrol),
  1937. errorbuf,
  1938. apply);
  1939. return retVal;
  1940. }
  1941. int
  1942. config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) {
  1943. int retVal = LDAP_SUCCESS;
  1944. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1945. retVal = config_set_onoff ( attrname,
  1946. value,
  1947. &(slapdFrontendConfig->return_exact_case),
  1948. errorbuf,
  1949. apply);
  1950. return retVal;
  1951. }
  1952. int
  1953. config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) {
  1954. int retVal = LDAP_SUCCESS;
  1955. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1956. retVal = config_set_onoff ( attrname,
  1957. value,
  1958. &(slapdFrontendConfig->result_tweak),
  1959. errorbuf,
  1960. apply);
  1961. return retVal;
  1962. }
  1963. int
  1964. config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) {
  1965. int retVal = LDAP_SUCCESS;
  1966. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1967. retVal = config_set_onoff ( attrname,
  1968. value,
  1969. &(slapdFrontendConfig->security),
  1970. errorbuf,
  1971. apply);
  1972. return retVal;
  1973. }
  1974. static int
  1975. config_set_onoff ( const char *attrname, char *value, int *configvalue,
  1976. char *errorbuf, int apply )
  1977. {
  1978. int retVal = LDAP_SUCCESS;
  1979. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1980. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1981. return LDAP_OPERATIONS_ERROR;
  1982. }
  1983. if ( strcasecmp ( value, "on" ) != 0 &&
  1984. strcasecmp ( value, "off") != 0 ) {
  1985. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1986. "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
  1987. attrname, value );
  1988. retVal = LDAP_OPERATIONS_ERROR;
  1989. }
  1990. if ( !apply ) {
  1991. /* we can return now if we aren't applying the changes */
  1992. return retVal;
  1993. }
  1994. CFG_LOCK_WRITE(slapdFrontendConfig);
  1995. if ( strcasecmp ( value, "on" ) == 0 ) {
  1996. *configvalue = LDAP_ON;
  1997. }
  1998. else if ( strcasecmp ( value, "off" ) == 0 ) {
  1999. *configvalue = LDAP_OFF;
  2000. }
  2001. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2002. return retVal;
  2003. }
  2004. int
  2005. config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) {
  2006. int retVal = LDAP_SUCCESS;
  2007. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2008. retVal = config_set_onoff ( attrname,
  2009. value,
  2010. &(slapdFrontendConfig->readonly),
  2011. errorbuf,
  2012. apply );
  2013. return retVal;
  2014. }
  2015. int
  2016. config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
  2017. int retVal = LDAP_SUCCESS;
  2018. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2019. retVal = config_set_onoff ( attrname,
  2020. value,
  2021. &(slapdFrontendConfig->schemacheck),
  2022. errorbuf,
  2023. apply);
  2024. return retVal;
  2025. }
  2026. int
  2027. config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) {
  2028. int retVal = LDAP_SUCCESS;
  2029. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2030. retVal = config_set_onoff ( attrname,
  2031. value,
  2032. &(slapdFrontendConfig->ds4_compatible_schema),
  2033. errorbuf,
  2034. apply);
  2035. return retVal;
  2036. }
  2037. int
  2038. config_set_schema_ignore_trailing_spaces( const char *attrname, char *value,
  2039. char *errorbuf, int apply ) {
  2040. int retVal = LDAP_SUCCESS;
  2041. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2042. retVal = config_set_onoff ( attrname,
  2043. value,
  2044. &(slapdFrontendConfig->schema_ignore_trailing_spaces),
  2045. errorbuf,
  2046. apply);
  2047. return retVal;
  2048. }
  2049. int
  2050. config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) {
  2051. int retVal = LDAP_SUCCESS;
  2052. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2053. retVal = config_set_onoff ( attrname,
  2054. value,
  2055. &(slapdFrontendConfig->enquote_sup_oc),
  2056. errorbuf,
  2057. apply);
  2058. return retVal;
  2059. }
  2060. int
  2061. config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ) {
  2062. int retVal = LDAP_SUCCESS;
  2063. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2064. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2065. return LDAP_OPERATIONS_ERROR;
  2066. }
  2067. if ( apply ) {
  2068. CFG_LOCK_WRITE(slapdFrontendConfig);
  2069. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootdn) );
  2070. slapdFrontendConfig->rootdn = slapi_dn_normalize (slapi_ch_strdup ( value ) );
  2071. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2072. }
  2073. return retVal;
  2074. }
  2075. int
  2076. config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply ) {
  2077. int retVal = LDAP_SUCCESS;
  2078. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2079. struct pw_scheme *is_hashed = NULL;
  2080. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2081. return LDAP_OPERATIONS_ERROR;
  2082. }
  2083. if (!apply) {
  2084. return retVal;
  2085. }
  2086. CFG_LOCK_WRITE(slapdFrontendConfig);
  2087. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootpw) );
  2088. is_hashed = pw_val2scheme ( value, NULL, 0 );
  2089. if ( is_hashed ) {
  2090. slapdFrontendConfig->rootpw = slapi_ch_strdup ( value );
  2091. free_pw_scheme(is_hashed);
  2092. }
  2093. else {
  2094. /* pwd enc func returns slapi_ch_malloc memory */
  2095. slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
  2096. }
  2097. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2098. return retVal;
  2099. }
  2100. int
  2101. config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  2102. int retVal = LDAP_SUCCESS;
  2103. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2104. struct pw_scheme *new_scheme = NULL;
  2105. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2106. return LDAP_OPERATIONS_ERROR;
  2107. }
  2108. new_scheme = pw_name2scheme ( value );
  2109. if (new_scheme == NULL ) {
  2110. char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  2111. if ( scheme_list != NULL ) {
  2112. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2113. "%s: invalid scheme - %s. Valid schemes are: %s",
  2114. attrname, value, scheme_list );
  2115. } else {
  2116. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2117. "%s: invalid scheme - %s (no pwdstorage scheme"
  2118. " plugin loaded)", attrname, value);
  2119. }
  2120. slapi_ch_free_string(&scheme_list);
  2121. retVal = LDAP_OPERATIONS_ERROR;
  2122. return retVal;
  2123. }
  2124. CFG_LOCK_WRITE(slapdFrontendConfig);
  2125. free_pw_scheme(slapdFrontendConfig->rootpwstoragescheme);
  2126. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  2127. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2128. return retVal;
  2129. }
  2130. /*
  2131. * kexcoff: to replace default initialization in FrontendConfig_init()
  2132. */
  2133. int config_set_storagescheme() {
  2134. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2135. struct pw_scheme *new_scheme = NULL;
  2136. CFG_LOCK_WRITE(slapdFrontendConfig);
  2137. new_scheme = pw_name2scheme("SSHA");
  2138. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  2139. slapdFrontendConfig->pw_storagescheme = new_scheme;
  2140. new_scheme = pw_name2scheme("SSHA");
  2141. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  2142. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2143. return ( new_scheme == NULL );
  2144. }
  2145. #ifndef _WIN32
  2146. int
  2147. config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply ) {
  2148. int retVal = LDAP_SUCCESS;
  2149. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2150. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2151. return LDAP_OPERATIONS_ERROR;
  2152. }
  2153. if (apply) {
  2154. struct passwd *pw = NULL;
  2155. CFG_LOCK_WRITE(slapdFrontendConfig);
  2156. slapi_ch_free ( (void **) &slapdFrontendConfig->localuser );
  2157. slapdFrontendConfig->localuser = slapi_ch_strdup ( value );
  2158. if (slapdFrontendConfig->localuserinfo != NULL) {
  2159. slapi_ch_free ( (void **) &(slapdFrontendConfig->localuserinfo) );
  2160. }
  2161. pw = getpwnam( value );
  2162. if ( pw ) {
  2163. slapdFrontendConfig->localuserinfo =
  2164. (struct passwd *)slapi_ch_malloc(sizeof(struct passwd));
  2165. memcpy(slapdFrontendConfig->localuserinfo, pw, sizeof(struct passwd));
  2166. }
  2167. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2168. }
  2169. return retVal;
  2170. }
  2171. #endif /* _WIN32 */
  2172. int
  2173. config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply ) {
  2174. int retVal = LDAP_SUCCESS;
  2175. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2176. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2177. return LDAP_OPERATIONS_ERROR;
  2178. }
  2179. if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
  2180. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
  2181. retVal = LDAP_OPERATIONS_ERROR;
  2182. return retVal;
  2183. }
  2184. if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
  2185. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
  2186. retVal = LDAP_OPERATIONS_ERROR;
  2187. return retVal;
  2188. }
  2189. if ( apply) {
  2190. CFG_LOCK_WRITE(slapdFrontendConfig);
  2191. slapdFrontendConfig->workingdir = slapi_ch_strdup ( value );
  2192. #ifdef _WIN32
  2193. dostounixpath(slapdFrontendConfig->workingdir);
  2194. #endif /* _WIN32 */
  2195. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2196. }
  2197. return retVal;
  2198. }
  2199. /* alias of encryption key and certificate files is now retrieved through */
  2200. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  2201. /* where this function is still used to set the global variable */
  2202. int
  2203. config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply ) {
  2204. int retVal = LDAP_SUCCESS;
  2205. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2206. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2207. return LDAP_OPERATIONS_ERROR;
  2208. }
  2209. if (apply) {
  2210. CFG_LOCK_WRITE(slapdFrontendConfig);
  2211. slapi_ch_free ( (void **) &(slapdFrontendConfig->encryptionalias) );
  2212. slapdFrontendConfig->encryptionalias = slapi_ch_strdup ( value );
  2213. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2214. }
  2215. return retVal;
  2216. }
  2217. int
  2218. config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply ) {
  2219. int retVal = LDAP_SUCCESS;
  2220. long threadnum = 0;
  2221. char *endp = NULL;
  2222. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2223. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2224. return LDAP_OPERATIONS_ERROR;
  2225. }
  2226. errno = 0;
  2227. threadnum = strtol(value, &endp, 10);
  2228. if ( *endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535 ) {
  2229. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value );
  2230. retVal = LDAP_OPERATIONS_ERROR;
  2231. }
  2232. if (apply) {
  2233. CFG_LOCK_WRITE(slapdFrontendConfig);
  2234. /* max_threads = threadnum; */
  2235. slapdFrontendConfig->threadnumber = threadnum;
  2236. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2237. }
  2238. return retVal;
  2239. }
  2240. int
  2241. config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply ) {
  2242. int retVal = LDAP_SUCCESS;
  2243. long maxthreadnum = 0;
  2244. char *endp = NULL;
  2245. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2246. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2247. return LDAP_OPERATIONS_ERROR;
  2248. }
  2249. errno = 0;
  2250. maxthreadnum = strtol(value, &endp, 10);
  2251. if ( *endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535 ) {
  2252. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535", attrname, value );
  2253. retVal = LDAP_OPERATIONS_ERROR;
  2254. }
  2255. if (apply) {
  2256. CFG_LOCK_WRITE(slapdFrontendConfig);
  2257. /* max_threads_per_conn = maxthreadnum; */
  2258. slapdFrontendConfig->maxthreadsperconn = maxthreadnum;
  2259. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2260. }
  2261. return retVal;
  2262. }
  2263. #if !defined(_WIN32) && !defined(AIX)
  2264. #include <sys/resource.h>
  2265. int
  2266. config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  2267. int retVal = LDAP_SUCCESS;
  2268. long nValue = 0;
  2269. int maxVal = 65535;
  2270. struct rlimit rlp;
  2271. char *endp = NULL;
  2272. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2273. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2274. return LDAP_OPERATIONS_ERROR;
  2275. }
  2276. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  2277. maxVal = (int)rlp.rlim_max;
  2278. }
  2279. errno = 0;
  2280. nValue = strtol(value, &endp, 10);
  2281. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  2282. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum "
  2283. "file descriptors must range from 1 to %d (the current process limit). "
  2284. "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
  2285. if ( nValue > maxVal ) {
  2286. nValue = maxVal;
  2287. retVal = LDAP_UNWILLING_TO_PERFORM;
  2288. } else {
  2289. retVal = LDAP_OPERATIONS_ERROR;
  2290. }
  2291. }
  2292. if (apply) {
  2293. CFG_LOCK_WRITE(slapdFrontendConfig);
  2294. slapdFrontendConfig->maxdescriptors = nValue;
  2295. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2296. }
  2297. return retVal;
  2298. }
  2299. #endif /* !_WIN32 && !AIX */
  2300. int
  2301. config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int apply ) {
  2302. int retVal = LDAP_SUCCESS;
  2303. long nValue = 0;
  2304. int maxVal = 65535;
  2305. char *endp = NULL;
  2306. #ifndef _WIN32
  2307. struct rlimit rlp;
  2308. #endif
  2309. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2310. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2311. return LDAP_OPERATIONS_ERROR;
  2312. }
  2313. #ifndef _WIN32
  2314. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  2315. maxVal = (int)rlp.rlim_max;
  2316. }
  2317. #endif
  2318. errno = 0;
  2319. nValue = strtol(value, &endp, 0);
  2320. #ifdef _WIN32
  2321. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > 0xfffffe ) {
  2322. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table size must range from 1 to 0xfffffe", attrname, value );
  2323. retVal = LDAP_OPERATIONS_ERROR;
  2324. }
  2325. #elif !defined(AIX)
  2326. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  2327. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table "
  2328. "size must range from 1 to %d (the current process maxdescriptors limit). "
  2329. "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
  2330. if ( nValue > maxVal) {
  2331. nValue = maxVal;
  2332. retVal = LDAP_UNWILLING_TO_PERFORM;
  2333. } else {
  2334. retVal = LDAP_OPERATIONS_ERROR;
  2335. }
  2336. }
  2337. #endif
  2338. if (apply) {
  2339. CFG_LOCK_WRITE(slapdFrontendConfig);
  2340. slapdFrontendConfig->conntablesize = nValue;
  2341. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2342. }
  2343. return retVal;
  2344. }
  2345. int
  2346. config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  2347. int retVal = LDAP_SUCCESS;
  2348. int maxVal = 65535;
  2349. long nValue = 0;
  2350. char *endp = NULL;
  2351. #ifndef _WIN32
  2352. struct rlimit rlp;
  2353. #endif
  2354. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2355. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2356. return LDAP_OPERATIONS_ERROR;
  2357. }
  2358. #ifndef _WIN32
  2359. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  2360. maxVal = (int)rlp.rlim_max;
  2361. }
  2362. #endif
  2363. errno = 0;
  2364. nValue = strtol(value, &endp, 10);
  2365. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  2366. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", reserved file "
  2367. "descriptors must range from 1 to %d (the current process maxdescriptors limit). "
  2368. "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
  2369. if ( nValue > maxVal) {
  2370. nValue = maxVal;
  2371. retVal = LDAP_UNWILLING_TO_PERFORM;
  2372. } else {
  2373. retVal = LDAP_OPERATIONS_ERROR;
  2374. }
  2375. }
  2376. if (apply) {
  2377. CFG_LOCK_WRITE(slapdFrontendConfig);
  2378. slapdFrontendConfig->reservedescriptors = nValue;
  2379. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2380. }
  2381. return retVal;
  2382. }
  2383. int
  2384. config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  2385. int retVal = LDAP_SUCCESS;
  2386. long nValue = 0;
  2387. char *endp = NULL;
  2388. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2389. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2390. return LDAP_OPERATIONS_ERROR;
  2391. }
  2392. errno = 0;
  2393. nValue = strtol(value, &endp, 10);
  2394. if ( *endp != '\0' || errno == ERANGE || nValue < 0 ) {
  2395. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %ld",
  2396. attrname, value, LONG_MAX );
  2397. retVal = LDAP_OPERATIONS_ERROR;
  2398. return retVal;
  2399. }
  2400. #if defined(IRIX)
  2401. /* on IRIX poll can only handle timeouts up to
  2402. 2147483 without failing, cap it at 30 minutes */
  2403. if ( nValue > SLAPD_DEFAULT_IOBLOCK_TIMEOUT ) {
  2404. nValue = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  2405. }
  2406. #endif /* IRIX */
  2407. if ( apply ) {
  2408. CFG_LOCK_WRITE(slapdFrontendConfig);
  2409. slapdFrontendConfig->ioblocktimeout = nValue;
  2410. /* g_ioblock_timeout= nValue; */
  2411. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2412. }
  2413. return retVal;
  2414. }
  2415. int
  2416. config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  2417. int retVal = LDAP_SUCCESS;
  2418. long nValue = 0;
  2419. char *endp = NULL;
  2420. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2421. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2422. return LDAP_OPERATIONS_ERROR;
  2423. }
  2424. errno = 0;
  2425. nValue = strtol(value, &endp, 10);
  2426. if (*endp != '\0' || errno == ERANGE || nValue < 0 ) {
  2427. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", idle timeout must range from 0 to %ld",
  2428. attrname, value, LONG_MAX );
  2429. retVal = LDAP_OPERATIONS_ERROR;
  2430. return retVal;
  2431. }
  2432. if (apply) {
  2433. CFG_LOCK_WRITE(slapdFrontendConfig);
  2434. slapdFrontendConfig->idletimeout = nValue;
  2435. /* g_idle_timeout= nValue; */
  2436. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2437. }
  2438. return retVal;
  2439. }
  2440. int
  2441. config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbuf, int apply ) {
  2442. int retVal = LDAP_SUCCESS;
  2443. long nValue = 0;
  2444. char *endp = NULL;
  2445. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2446. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2447. return LDAP_OPERATIONS_ERROR;
  2448. }
  2449. errno = 0;
  2450. nValue = strtol(value, &endp, 10);
  2451. if ( *endp != '\0' || errno == ERANGE || nValue < 0 || nValue > 5 ) {
  2452. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2453. "%s: invalid value \"%s\", group eval nest level must range from 0 to 5",
  2454. attrname, value );
  2455. retVal = LDAP_OPERATIONS_ERROR;
  2456. return retVal;
  2457. }
  2458. if (apply) {
  2459. CFG_LOCK_WRITE(slapdFrontendConfig);
  2460. slapdFrontendConfig->groupevalnestlevel = nValue;
  2461. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2462. }
  2463. return retVal;
  2464. }
  2465. int
  2466. config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply ) {
  2467. int retVal = LDAP_SUCCESS;
  2468. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2469. if ( config_value_is_null( attrname, (char *)value, errorbuf, 0 )) {
  2470. return LDAP_OPERATIONS_ERROR;
  2471. }
  2472. if (apply) {
  2473. CFG_LOCK_WRITE(slapdFrontendConfig);
  2474. g_set_default_referral( value );
  2475. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2476. }
  2477. return retVal;
  2478. }
  2479. int
  2480. config_set_userat( const char *attrname, char *value, char *errorbuf, int apply ) {
  2481. int retVal = LDAP_SUCCESS;
  2482. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2483. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2484. return LDAP_OPERATIONS_ERROR;
  2485. }
  2486. if ( apply ) {
  2487. CFG_LOCK_WRITE(slapdFrontendConfig);
  2488. slapi_ch_free( (void **) &(slapdFrontendConfig->userat) );
  2489. slapdFrontendConfig->userat = slapi_ch_strdup(value);
  2490. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2491. }
  2492. return retVal;
  2493. }
  2494. int
  2495. config_set_timelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2496. int retVal = LDAP_SUCCESS;
  2497. long nVal = 0;
  2498. char *endp = NULL;
  2499. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2500. Slapi_Backend *be = NULL;
  2501. char *cookie;
  2502. *errorbuf = 0;
  2503. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2504. return LDAP_OPERATIONS_ERROR;
  2505. }
  2506. errno = 0;
  2507. nVal = strtol(value, &endp, 10);
  2508. if ( *endp != '\0' || errno == ERANGE || nVal < -1 ) {
  2509. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2510. "%s: invalid value \"%s\", time limit must range from -1 to %ld",
  2511. attrname, value, LONG_MAX );
  2512. retVal = LDAP_OPERATIONS_ERROR;
  2513. return retVal;
  2514. }
  2515. if ( apply ) {
  2516. CFG_LOCK_WRITE(slapdFrontendConfig);
  2517. g_set_deftime ( nVal );
  2518. slapdFrontendConfig->timelimit = nVal;
  2519. be = slapi_get_first_backend (&cookie);
  2520. while (be) {
  2521. be->be_timelimit = slapdFrontendConfig->timelimit;
  2522. be = slapi_get_next_backend (cookie);
  2523. }
  2524. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2525. slapi_ch_free ((void **)&cookie);
  2526. }
  2527. return retVal;
  2528. }
  2529. int
  2530. config_set_useroc( const char *attrname, char *value, char *errorbuf, int apply ) {
  2531. int retVal = LDAP_SUCCESS;
  2532. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2533. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2534. return LDAP_OPERATIONS_ERROR;
  2535. }
  2536. if ( apply ) {
  2537. CFG_LOCK_WRITE(slapdFrontendConfig);
  2538. slapi_ch_free ( (void **) &(slapdFrontendConfig->useroc) );
  2539. slapdFrontendConfig->useroc = slapi_ch_strdup( value );
  2540. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2541. }
  2542. return retVal;
  2543. }
  2544. int
  2545. config_set_accesslog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2546. int retVal = LDAP_SUCCESS;
  2547. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2548. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2549. return LDAP_OPERATIONS_ERROR;
  2550. }
  2551. retVal = log_update_accesslogdir ( value, apply );
  2552. if ( retVal != LDAP_SUCCESS ) {
  2553. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2554. "Cannot open accesslog directory \"%s\", client accesses will "
  2555. "not be logged.", value );
  2556. }
  2557. if ( apply ) {
  2558. CFG_LOCK_WRITE(slapdFrontendConfig);
  2559. slapi_ch_free ( (void **) &(slapdFrontendConfig->accesslog) );
  2560. slapdFrontendConfig->accesslog = slapi_ch_strdup ( value );
  2561. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2562. }
  2563. return retVal;
  2564. }
  2565. int
  2566. config_set_errorlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2567. int retVal = LDAP_SUCCESS;
  2568. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2569. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2570. return LDAP_OPERATIONS_ERROR;
  2571. }
  2572. retVal = log_update_errorlogdir ( value, apply );
  2573. if ( retVal != LDAP_SUCCESS ) {
  2574. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2575. "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
  2576. value );
  2577. syslog(LOG_ERR,
  2578. "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
  2579. value );
  2580. g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
  2581. }
  2582. if ( apply ) {
  2583. CFG_LOCK_WRITE(slapdFrontendConfig);
  2584. slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
  2585. slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
  2586. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2587. }
  2588. return retVal;
  2589. }
  2590. int
  2591. config_set_auditlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2592. int retVal = LDAP_SUCCESS;
  2593. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2594. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2595. return LDAP_OPERATIONS_ERROR;
  2596. }
  2597. retVal = log_update_auditlogdir ( value, apply );
  2598. if ( retVal != LDAP_SUCCESS ) {
  2599. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2600. "Cannot open auditlog directory \"%s\"", value );
  2601. }
  2602. if ( apply ) {
  2603. CFG_LOCK_WRITE(slapdFrontendConfig);
  2604. slapi_ch_free ( (void **) &(slapdFrontendConfig->auditlog) );
  2605. slapdFrontendConfig->auditlog = slapi_ch_strdup ( value );
  2606. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2607. }
  2608. return retVal;
  2609. }
  2610. int
  2611. config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2612. int retVal = LDAP_SUCCESS;
  2613. long age;
  2614. char *endp = NULL;
  2615. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2616. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2617. return LDAP_OPERATIONS_ERROR;
  2618. }
  2619. errno = 0;
  2620. /* age in seconds */
  2621. age = strtol(value, &endp, 10);
  2622. if ( *endp != '\0' || errno == ERANGE || age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  2623. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2624. "%s: password maximum age \"%s\" seconds is invalid. ",
  2625. attrname, value );
  2626. retVal = LDAP_OPERATIONS_ERROR;
  2627. return retVal;
  2628. }
  2629. if ( apply ) {
  2630. slapdFrontendConfig->pw_policy.pw_maxage = age;
  2631. }
  2632. return retVal;
  2633. }
  2634. int
  2635. config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2636. int retVal = LDAP_SUCCESS;
  2637. long age;
  2638. char *endPtr = NULL;
  2639. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2640. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2641. return LDAP_OPERATIONS_ERROR;
  2642. }
  2643. errno = 0;
  2644. /* age in seconds */
  2645. age = strtol(value, &endPtr, 0 );
  2646. /* endPtr should never be NULL, but we check just in case; if the
  2647. value contains no digits, or a string that does not begin with
  2648. a valid digit (e.g. "z2"), the days will be 0, and endPtr will
  2649. point to the beginning of value; if days contains at least 1
  2650. valid digit string, endPtr will point to the character after
  2651. the end of the first valid digit string in value. Example:
  2652. value = " 2 3 " endPtr will point at the space character
  2653. between the 2 and the 3. So, we should be able to simply
  2654. check to see if the character at *(endPtr - 1) is a digit.
  2655. */
  2656. if ( (age < 0) ||
  2657. (age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
  2658. (endPtr == NULL) || (endPtr == value) || !isdigit(*(endPtr-1)) ||
  2659. errno == ERANGE ) {
  2660. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2661. "%s: password minimum age \"%s\" seconds is invalid. ",
  2662. attrname, value );
  2663. retVal = LDAP_OPERATIONS_ERROR;
  2664. return retVal;
  2665. }
  2666. if ( apply ) {
  2667. slapdFrontendConfig->pw_policy.pw_minage = age;
  2668. }
  2669. return retVal;
  2670. }
  2671. int
  2672. config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int apply ) {
  2673. int retVal = LDAP_SUCCESS;
  2674. long sec;
  2675. char *endp = NULL;
  2676. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2677. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2678. return LDAP_OPERATIONS_ERROR;
  2679. }
  2680. errno = 0;
  2681. /* in seconds */
  2682. sec = strtol(value, &endp, 10);
  2683. if (*endp != '\0' || errno == ERANGE || sec < 0) {
  2684. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2685. "%s: password warning age \"%s\" seconds is invalid, password warning "
  2686. "age must range from 0 to %ld seconds",
  2687. attrname, value, LONG_MAX );
  2688. retVal = LDAP_OPERATIONS_ERROR;
  2689. return retVal;
  2690. }
  2691. /* translate to seconds */
  2692. if ( apply ) {
  2693. slapdFrontendConfig->pw_policy.pw_warning = sec;
  2694. }
  2695. return retVal;
  2696. }
  2697. int
  2698. config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2699. int retVal = LDAP_SUCCESS;
  2700. long level = 0;
  2701. char *endp = NULL;
  2702. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2703. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2704. return LDAP_OPERATIONS_ERROR;
  2705. }
  2706. errno = 0;
  2707. level = strtol(value, &endp, 10);
  2708. if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
  2709. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: error log level \"%s\" is invalid,"
  2710. " error log level must range from 0 to %ld", attrname, value, LONG_MAX );
  2711. retVal = LDAP_OPERATIONS_ERROR;
  2712. return retVal;
  2713. }
  2714. if ( apply ) {
  2715. CFG_LOCK_WRITE(slapdFrontendConfig);
  2716. level |= LDAP_DEBUG_ANY;
  2717. #ifdef _WIN32
  2718. *module_ldap_debug = level;
  2719. #else
  2720. slapd_ldap_debug = level;
  2721. #endif
  2722. slapdFrontendConfig->errorloglevel = level;
  2723. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2724. }
  2725. return retVal;
  2726. }
  2727. int
  2728. config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2729. int retVal = LDAP_SUCCESS;
  2730. long level = 0;
  2731. char *endp = NULL;
  2732. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2733. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2734. return LDAP_OPERATIONS_ERROR;
  2735. }
  2736. errno = 0;
  2737. level = strtol(value, &endp, 10);
  2738. if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
  2739. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: access log level \"%s\" is invalid,"
  2740. " access log level must range from 0 to %ld", attrname, value, LONG_MAX );
  2741. retVal = LDAP_OPERATIONS_ERROR;
  2742. return retVal;
  2743. }
  2744. if ( apply ) {
  2745. CFG_LOCK_WRITE(slapdFrontendConfig);
  2746. g_set_accesslog_level ( level );
  2747. slapdFrontendConfig->accessloglevel = level;
  2748. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2749. }
  2750. return retVal;
  2751. }
  2752. /* set the referral-mode url (which puts us into referral mode) */
  2753. int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply)
  2754. {
  2755. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2756. slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
  2757. if ((!url) || (!url[0])) {
  2758. strcpy(errorbuf, "referral url must have a value");
  2759. return LDAP_OPERATIONS_ERROR;
  2760. }
  2761. if (apply) {
  2762. CFG_LOCK_WRITE(slapdFrontendConfig);
  2763. slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
  2764. slapdFrontendConfig->refer_mode = REFER_MODE_ON;
  2765. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2766. }
  2767. return LDAP_SUCCESS;
  2768. }
  2769. int
  2770. config_set_versionstring( const char *attrname, char *version, char *errorbuf, int apply ) {
  2771. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2772. if ((!version) || (!version[0])) {
  2773. PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
  2774. return LDAP_OPERATIONS_ERROR;
  2775. }
  2776. if (apply) {
  2777. CFG_LOCK_WRITE(slapdFrontendConfig);
  2778. slapdFrontendConfig->versionstring = slapi_ch_strdup(version);
  2779. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2780. }
  2781. return LDAP_SUCCESS;
  2782. }
  2783. #define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL;
  2784. int
  2785. config_get_port(){
  2786. int retVal;
  2787. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2788. CFG_LOCK_READ(slapdFrontendConfig);
  2789. retVal = slapdFrontendConfig->port;
  2790. CFG_UNLOCK_READ(slapdFrontendConfig);
  2791. return retVal;
  2792. }
  2793. char *
  2794. config_get_ldapi_filename(){
  2795. char *retVal;
  2796. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2797. CFG_LOCK_READ(slapdFrontendConfig);
  2798. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_filename);
  2799. CFG_UNLOCK_READ(slapdFrontendConfig);
  2800. return retVal;
  2801. }
  2802. int config_get_ldapi_switch(){
  2803. int retVal;
  2804. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2805. CFG_LOCK_READ(slapdFrontendConfig);
  2806. retVal = slapdFrontendConfig->ldapi_switch;
  2807. CFG_UNLOCK_READ(slapdFrontendConfig);
  2808. return retVal;
  2809. }
  2810. int config_get_ldapi_bind_switch(){
  2811. int retVal;
  2812. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2813. CFG_LOCK_READ(slapdFrontendConfig);
  2814. retVal = slapdFrontendConfig->ldapi_bind_switch;
  2815. CFG_UNLOCK_READ(slapdFrontendConfig);
  2816. return retVal;
  2817. }
  2818. char *config_get_ldapi_root_dn(){
  2819. char *retVal;
  2820. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2821. CFG_LOCK_READ(slapdFrontendConfig);
  2822. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_root_dn);
  2823. CFG_UNLOCK_READ(slapdFrontendConfig);
  2824. return retVal;
  2825. }
  2826. int config_get_ldapi_map_entries(){
  2827. int retVal;
  2828. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2829. CFG_LOCK_READ(slapdFrontendConfig);
  2830. retVal = slapdFrontendConfig->ldapi_map_entries;
  2831. CFG_UNLOCK_READ(slapdFrontendConfig);
  2832. return retVal;
  2833. }
  2834. char *config_get_ldapi_uidnumber_type(){
  2835. char *retVal;
  2836. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2837. CFG_LOCK_READ(slapdFrontendConfig);
  2838. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_uidnumber_type);
  2839. CFG_UNLOCK_READ(slapdFrontendConfig);
  2840. return retVal;
  2841. }
  2842. char *config_get_ldapi_gidnumber_type(){
  2843. char *retVal;
  2844. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2845. CFG_LOCK_READ(slapdFrontendConfig);
  2846. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_gidnumber_type);
  2847. CFG_UNLOCK_READ(slapdFrontendConfig);
  2848. return retVal;
  2849. }
  2850. char *config_get_ldapi_search_base_dn(){
  2851. char *retVal;
  2852. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2853. CFG_LOCK_READ(slapdFrontendConfig);
  2854. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_search_base_dn);
  2855. CFG_UNLOCK_READ(slapdFrontendConfig);
  2856. return retVal;
  2857. }
  2858. #if defined(ENABLE_AUTO_DN_SUFFIX)
  2859. char *config_get_ldapi_auto_dn_suffix(){
  2860. char *retVal;
  2861. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2862. CFG_LOCK_READ(slapdFrontendConfig);
  2863. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_auto_dn_suffix);
  2864. CFG_UNLOCK_READ(slapdFrontendConfig);
  2865. return retVal;
  2866. }
  2867. #endif
  2868. int config_get_slapi_counters()
  2869. {
  2870. int retVal;
  2871. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2872. CFG_LOCK_READ(slapdFrontendConfig);
  2873. retVal = slapdFrontendConfig->slapi_counters;
  2874. CFG_UNLOCK_READ(slapdFrontendConfig);
  2875. return retVal;
  2876. }
  2877. char *
  2878. config_get_workingdir() {
  2879. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2880. char *retVal;
  2881. CFG_LOCK_READ(slapdFrontendConfig);
  2882. retVal = slapi_ch_strdup(slapdFrontendConfig->workingdir);
  2883. CFG_UNLOCK_READ(slapdFrontendConfig);
  2884. return retVal;
  2885. }
  2886. char *
  2887. config_get_versionstring() {
  2888. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2889. char *retVal;
  2890. CFG_LOCK_READ(slapdFrontendConfig);
  2891. retVal = slapi_ch_strdup(slapdFrontendConfig->versionstring);
  2892. CFG_UNLOCK_READ(slapdFrontendConfig);
  2893. return retVal;
  2894. }
  2895. char *
  2896. config_get_buildnum(void)
  2897. {
  2898. return slapi_ch_strdup(BUILD_NUM);
  2899. }
  2900. int
  2901. config_get_secureport() {
  2902. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2903. int retVal;
  2904. CFG_LOCK_READ(slapdFrontendConfig);
  2905. retVal = slapdFrontendConfig->secureport;
  2906. CFG_UNLOCK_READ(slapdFrontendConfig);
  2907. return retVal;
  2908. }
  2909. int
  2910. config_get_SSLclientAuth() {
  2911. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2912. int retVal;
  2913. CFG_LOCK_READ(slapdFrontendConfig);
  2914. retVal = slapdFrontendConfig->SSLclientAuth;
  2915. CFG_UNLOCK_READ(slapdFrontendConfig);
  2916. return retVal;
  2917. }
  2918. int
  2919. config_get_ssl_check_hostname()
  2920. {
  2921. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2922. return slapdFrontendConfig->ssl_check_hostname;
  2923. }
  2924. char *
  2925. config_get_localhost() {
  2926. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2927. char *retVal;
  2928. CFG_LOCK_READ(slapdFrontendConfig);
  2929. retVal = config_copy_strval ( slapdFrontendConfig->localhost );
  2930. CFG_UNLOCK_READ(slapdFrontendConfig);
  2931. return retVal;
  2932. }
  2933. char *
  2934. config_get_listenhost() {
  2935. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2936. char *retVal;
  2937. CFG_LOCK_READ(slapdFrontendConfig);
  2938. retVal = config_copy_strval ( slapdFrontendConfig->listenhost );
  2939. CFG_UNLOCK_READ(slapdFrontendConfig);
  2940. return retVal;
  2941. }
  2942. char *
  2943. config_get_securelistenhost() {
  2944. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2945. char *retVal;
  2946. CFG_LOCK_READ(slapdFrontendConfig);
  2947. retVal = config_copy_strval( slapdFrontendConfig->securelistenhost );
  2948. CFG_UNLOCK_READ(slapdFrontendConfig);
  2949. return retVal;
  2950. }
  2951. char *
  2952. config_get_srvtab() {
  2953. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2954. char *retVal;
  2955. CFG_LOCK_READ(slapdFrontendConfig);
  2956. retVal = config_copy_strval(slapdFrontendConfig->srvtab);
  2957. CFG_UNLOCK_READ(slapdFrontendConfig);
  2958. return retVal;
  2959. }
  2960. int
  2961. config_get_sizelimit() {
  2962. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2963. int retVal;
  2964. CFG_LOCK_READ(slapdFrontendConfig);
  2965. retVal = slapdFrontendConfig->sizelimit;
  2966. CFG_UNLOCK_READ(slapdFrontendConfig);
  2967. return retVal;
  2968. }
  2969. char *
  2970. config_get_pw_storagescheme() {
  2971. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2972. char *retVal = 0;
  2973. CFG_LOCK_READ(slapdFrontendConfig);
  2974. retVal = config_copy_strval(slapdFrontendConfig->pw_storagescheme->pws_name);
  2975. CFG_UNLOCK_READ(slapdFrontendConfig);
  2976. return retVal;
  2977. }
  2978. int
  2979. config_get_pw_change() {
  2980. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2981. int retVal;
  2982. CFG_LOCK_READ(slapdFrontendConfig);
  2983. retVal = slapdFrontendConfig->pw_policy.pw_change;
  2984. CFG_UNLOCK_READ(slapdFrontendConfig);
  2985. return retVal;
  2986. }
  2987. int
  2988. config_get_pw_history() {
  2989. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2990. int retVal;
  2991. CFG_LOCK_READ(slapdFrontendConfig);
  2992. retVal = slapdFrontendConfig->pw_policy.pw_history;
  2993. CFG_UNLOCK_READ(slapdFrontendConfig);
  2994. return retVal;
  2995. }
  2996. int
  2997. config_get_pw_must_change() {
  2998. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2999. int retVal;
  3000. CFG_LOCK_READ(slapdFrontendConfig);
  3001. retVal = slapdFrontendConfig->pw_policy.pw_must_change;
  3002. CFG_UNLOCK_READ(slapdFrontendConfig);
  3003. return retVal;
  3004. }
  3005. int
  3006. config_get_pw_syntax() {
  3007. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3008. int retVal;
  3009. CFG_LOCK_READ(slapdFrontendConfig);
  3010. retVal = slapdFrontendConfig->pw_policy.pw_syntax;
  3011. CFG_UNLOCK_READ(slapdFrontendConfig);
  3012. return retVal;
  3013. }
  3014. int
  3015. config_get_pw_minlength() {
  3016. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3017. int retVal;
  3018. CFG_LOCK_READ(slapdFrontendConfig);
  3019. retVal = slapdFrontendConfig->pw_policy.pw_minlength;
  3020. CFG_UNLOCK_READ(slapdFrontendConfig);
  3021. return retVal;
  3022. }
  3023. int
  3024. config_get_pw_mindigits() {
  3025. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3026. int retVal;
  3027. CFG_LOCK_READ(slapdFrontendConfig);
  3028. retVal = slapdFrontendConfig->pw_policy.pw_mindigits;
  3029. CFG_UNLOCK_READ(slapdFrontendConfig);
  3030. return retVal;
  3031. }
  3032. int
  3033. config_get_pw_minalphas() {
  3034. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3035. int retVal;
  3036. CFG_LOCK_READ(slapdFrontendConfig);
  3037. retVal = slapdFrontendConfig->pw_policy.pw_minalphas;
  3038. CFG_UNLOCK_READ(slapdFrontendConfig);
  3039. return retVal;
  3040. }
  3041. int
  3042. config_get_pw_minuppers() {
  3043. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3044. int retVal;
  3045. CFG_LOCK_READ(slapdFrontendConfig);
  3046. retVal = slapdFrontendConfig->pw_policy.pw_minuppers;
  3047. CFG_UNLOCK_READ(slapdFrontendConfig);
  3048. return retVal;
  3049. }
  3050. int
  3051. config_get_pw_minlowers() {
  3052. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3053. int retVal;
  3054. CFG_LOCK_READ(slapdFrontendConfig);
  3055. retVal = slapdFrontendConfig->pw_policy.pw_minlowers;
  3056. CFG_UNLOCK_READ(slapdFrontendConfig);
  3057. return retVal;
  3058. }
  3059. int
  3060. config_get_pw_minspecials() {
  3061. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3062. int retVal;
  3063. CFG_LOCK_READ(slapdFrontendConfig);
  3064. retVal = slapdFrontendConfig->pw_policy.pw_minspecials;
  3065. CFG_UNLOCK_READ(slapdFrontendConfig);
  3066. return retVal;
  3067. }
  3068. int
  3069. config_get_pw_min8bit() {
  3070. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3071. int retVal;
  3072. CFG_LOCK_READ(slapdFrontendConfig);
  3073. retVal = slapdFrontendConfig->pw_policy.pw_min8bit;
  3074. CFG_UNLOCK_READ(slapdFrontendConfig);
  3075. return retVal;
  3076. }
  3077. int
  3078. config_get_pw_maxrepeats() {
  3079. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3080. int retVal;
  3081. CFG_LOCK_READ(slapdFrontendConfig);
  3082. retVal = slapdFrontendConfig->pw_policy.pw_maxrepeats;
  3083. CFG_UNLOCK_READ(slapdFrontendConfig);
  3084. return retVal;
  3085. }
  3086. int
  3087. config_get_pw_mincategories() {
  3088. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3089. int retVal;
  3090. CFG_LOCK_READ(slapdFrontendConfig);
  3091. retVal = slapdFrontendConfig->pw_policy.pw_mincategories;
  3092. CFG_UNLOCK_READ(slapdFrontendConfig);
  3093. return retVal;
  3094. }
  3095. int
  3096. config_get_pw_mintokenlength() {
  3097. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3098. int retVal;
  3099. CFG_LOCK_READ(slapdFrontendConfig);
  3100. retVal = slapdFrontendConfig->pw_policy.pw_mintokenlength;
  3101. CFG_UNLOCK_READ(slapdFrontendConfig);
  3102. return retVal;
  3103. }
  3104. int
  3105. config_get_pw_maxfailure() {
  3106. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3107. int retVal;
  3108. CFG_LOCK_READ(slapdFrontendConfig);
  3109. retVal = slapdFrontendConfig->pw_policy.pw_maxfailure;
  3110. CFG_UNLOCK_READ(slapdFrontendConfig);
  3111. return retVal;
  3112. }
  3113. int
  3114. config_get_pw_inhistory() {
  3115. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3116. int retVal;
  3117. CFG_LOCK_READ(slapdFrontendConfig);
  3118. retVal = slapdFrontendConfig->pw_policy.pw_inhistory;
  3119. CFG_UNLOCK_READ(slapdFrontendConfig);
  3120. return retVal;
  3121. }
  3122. long
  3123. config_get_pw_lockduration() {
  3124. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3125. long retVal;
  3126. CFG_LOCK_READ(slapdFrontendConfig);
  3127. retVal = slapdFrontendConfig->pw_policy.pw_lockduration;
  3128. CFG_UNLOCK_READ(slapdFrontendConfig);
  3129. return retVal;
  3130. }
  3131. long
  3132. config_get_pw_resetfailurecount() {
  3133. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3134. long retVal;
  3135. CFG_LOCK_READ(slapdFrontendConfig);
  3136. retVal = slapdFrontendConfig->pw_policy.pw_resetfailurecount;
  3137. CFG_UNLOCK_READ(slapdFrontendConfig);
  3138. return retVal;
  3139. }
  3140. int
  3141. config_get_pw_is_global_policy() {
  3142. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3143. int retVal;
  3144. CFG_LOCK_READ(slapdFrontendConfig);
  3145. retVal = slapdFrontendConfig->pw_is_global_policy;
  3146. CFG_UNLOCK_READ(slapdFrontendConfig);
  3147. return retVal;
  3148. }
  3149. int
  3150. config_get_pw_exp() {
  3151. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3152. int retVal;
  3153. CFG_LOCK_READ(slapdFrontendConfig);
  3154. retVal = slapdFrontendConfig->pw_policy.pw_exp;
  3155. CFG_UNLOCK_READ(slapdFrontendConfig);
  3156. return retVal;
  3157. }
  3158. int
  3159. config_get_pw_unlock() {
  3160. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3161. int retVal;
  3162. CFG_LOCK_READ(slapdFrontendConfig);
  3163. retVal = slapdFrontendConfig->pw_policy.pw_unlock;
  3164. CFG_UNLOCK_READ(slapdFrontendConfig);
  3165. return retVal;
  3166. }
  3167. int
  3168. config_get_pw_lockout(){
  3169. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3170. int retVal;
  3171. CFG_LOCK_READ(slapdFrontendConfig);
  3172. retVal = slapdFrontendConfig->pw_policy.pw_lockout;
  3173. CFG_UNLOCK_READ(slapdFrontendConfig);
  3174. return retVal;
  3175. }
  3176. int
  3177. config_get_pw_gracelimit() {
  3178. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3179. int retVal=0;
  3180. CFG_LOCK_READ(slapdFrontendConfig);
  3181. retVal = slapdFrontendConfig->pw_policy.pw_gracelimit;
  3182. CFG_UNLOCK_READ(slapdFrontendConfig);
  3183. return retVal;
  3184. }
  3185. int
  3186. config_get_lastmod(){
  3187. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3188. int retVal;
  3189. CFG_LOCK_READ(slapdFrontendConfig);
  3190. retVal = slapdFrontendConfig->lastmod;
  3191. CFG_UNLOCK_READ(slapdFrontendConfig);
  3192. return retVal;
  3193. }
  3194. int
  3195. config_get_enquote_sup_oc(){
  3196. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3197. int retVal;
  3198. CFG_LOCK_READ(slapdFrontendConfig);
  3199. retVal = slapdFrontendConfig->enquote_sup_oc;
  3200. CFG_UNLOCK_READ(slapdFrontendConfig);
  3201. return retVal;
  3202. }
  3203. int
  3204. config_get_nagle() {
  3205. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3206. int retVal;
  3207. CFG_LOCK_READ(slapdFrontendConfig);
  3208. retVal = slapdFrontendConfig->nagle;
  3209. CFG_UNLOCK_READ(slapdFrontendConfig);
  3210. return retVal; }
  3211. int
  3212. config_get_accesscontrol() {
  3213. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3214. int retVal;
  3215. CFG_LOCK_READ(slapdFrontendConfig);
  3216. retVal = slapdFrontendConfig->accesscontrol;
  3217. CFG_UNLOCK_READ(slapdFrontendConfig);
  3218. return retVal;
  3219. }
  3220. int
  3221. config_get_return_exact_case() {
  3222. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3223. int retVal;
  3224. retVal = slapdFrontendConfig->return_exact_case;
  3225. return retVal;
  3226. }
  3227. int
  3228. config_get_result_tweak() {
  3229. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3230. int retVal;
  3231. CFG_LOCK_READ(slapdFrontendConfig);
  3232. retVal = slapdFrontendConfig->result_tweak;
  3233. CFG_UNLOCK_READ(slapdFrontendConfig);
  3234. return retVal;
  3235. }
  3236. int
  3237. config_get_security() {
  3238. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3239. int retVal;
  3240. CFG_LOCK_READ(slapdFrontendConfig);
  3241. retVal = slapdFrontendConfig->security;
  3242. CFG_UNLOCK_READ(slapdFrontendConfig);
  3243. return retVal;
  3244. }
  3245. int
  3246. slapi_config_get_readonly() {
  3247. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3248. int retVal;
  3249. CFG_LOCK_READ(slapdFrontendConfig);
  3250. retVal = slapdFrontendConfig->readonly;
  3251. CFG_UNLOCK_READ(slapdFrontendConfig);
  3252. return retVal;
  3253. }
  3254. int
  3255. config_get_schemacheck() {
  3256. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3257. int retVal;
  3258. CFG_LOCK_READ(slapdFrontendConfig);
  3259. retVal = slapdFrontendConfig->schemacheck;
  3260. CFG_UNLOCK_READ(slapdFrontendConfig);
  3261. return retVal;
  3262. }
  3263. int
  3264. config_get_ds4_compatible_schema() {
  3265. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3266. int retVal;
  3267. CFG_LOCK_READ(slapdFrontendConfig);
  3268. retVal = slapdFrontendConfig->ds4_compatible_schema;
  3269. CFG_UNLOCK_READ(slapdFrontendConfig);
  3270. return retVal;
  3271. }
  3272. int
  3273. config_get_schema_ignore_trailing_spaces() {
  3274. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3275. int retVal;
  3276. CFG_LOCK_READ(slapdFrontendConfig);
  3277. retVal = slapdFrontendConfig->schema_ignore_trailing_spaces;
  3278. CFG_UNLOCK_READ(slapdFrontendConfig);
  3279. return retVal;
  3280. }
  3281. char *
  3282. config_get_rootdn() {
  3283. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3284. char *retVal;
  3285. CFG_LOCK_READ(slapdFrontendConfig);
  3286. retVal = config_copy_strval (slapdFrontendConfig->rootdn);
  3287. CFG_UNLOCK_READ(slapdFrontendConfig);
  3288. return retVal;
  3289. }
  3290. char * slapi_get_rootdn() {
  3291. return config_get_rootdn();
  3292. }
  3293. char *
  3294. config_get_rootpw() {
  3295. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3296. char *retVal;
  3297. CFG_LOCK_READ(slapdFrontendConfig);
  3298. retVal = config_copy_strval (slapdFrontendConfig->rootpw);
  3299. CFG_UNLOCK_READ(slapdFrontendConfig);
  3300. return retVal;
  3301. }
  3302. char *
  3303. config_get_rootpwstoragescheme() {
  3304. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3305. char *retVal;
  3306. CFG_LOCK_READ(slapdFrontendConfig);
  3307. retVal = config_copy_strval(slapdFrontendConfig->rootpwstoragescheme->pws_name);
  3308. CFG_UNLOCK_READ(slapdFrontendConfig);
  3309. return retVal;
  3310. }
  3311. #ifndef _WIN32
  3312. char *
  3313. config_get_localuser() {
  3314. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3315. char *retVal;
  3316. CFG_LOCK_READ(slapdFrontendConfig);
  3317. retVal = config_copy_strval(slapdFrontendConfig->localuser);
  3318. CFG_UNLOCK_READ(slapdFrontendConfig);
  3319. return retVal;
  3320. }
  3321. #endif /* _WIN32 */
  3322. /* alias of encryption key and certificate files is now retrieved through */
  3323. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  3324. /* where this function is still used to set the global variable */
  3325. char *
  3326. config_get_encryptionalias() {
  3327. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3328. char *retVal;
  3329. CFG_LOCK_READ(slapdFrontendConfig);
  3330. retVal = config_copy_strval(slapdFrontendConfig->encryptionalias);
  3331. CFG_UNLOCK_READ(slapdFrontendConfig);
  3332. return retVal;
  3333. }
  3334. int
  3335. config_get_threadnumber() {
  3336. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3337. int retVal;
  3338. CFG_LOCK_READ(slapdFrontendConfig);
  3339. retVal = slapdFrontendConfig->threadnumber;
  3340. CFG_UNLOCK_READ(slapdFrontendConfig);
  3341. return retVal;
  3342. }
  3343. int
  3344. config_get_maxthreadsperconn(){
  3345. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3346. int retVal;
  3347. CFG_LOCK_READ(slapdFrontendConfig);
  3348. retVal = slapdFrontendConfig->maxthreadsperconn;
  3349. CFG_UNLOCK_READ(slapdFrontendConfig);
  3350. return retVal;
  3351. }
  3352. #if !defined(_WIN32) && !defined(AIX)
  3353. int
  3354. config_get_maxdescriptors() {
  3355. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3356. int retVal;
  3357. CFG_LOCK_READ(slapdFrontendConfig);
  3358. retVal = slapdFrontendConfig->maxdescriptors;
  3359. CFG_UNLOCK_READ(slapdFrontendConfig);
  3360. return retVal;
  3361. }
  3362. #endif /* !_WIN32 && !AIX */
  3363. int
  3364. config_get_reservedescriptors(){
  3365. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3366. int retVal;
  3367. CFG_LOCK_READ(slapdFrontendConfig);
  3368. retVal = slapdFrontendConfig->reservedescriptors;
  3369. CFG_UNLOCK_READ(slapdFrontendConfig);
  3370. return retVal;
  3371. }
  3372. int
  3373. config_get_ioblocktimeout(){
  3374. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3375. int retVal;
  3376. CFG_LOCK_READ(slapdFrontendConfig);
  3377. retVal = slapdFrontendConfig->ioblocktimeout;
  3378. CFG_UNLOCK_READ(slapdFrontendConfig);
  3379. return retVal;
  3380. }
  3381. int
  3382. config_get_idletimeout(){
  3383. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3384. int retVal;
  3385. CFG_LOCK_READ(slapdFrontendConfig);
  3386. retVal = slapdFrontendConfig->idletimeout;
  3387. CFG_UNLOCK_READ(slapdFrontendConfig);
  3388. return retVal;
  3389. }
  3390. int
  3391. config_get_groupevalnestlevel(){
  3392. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3393. int retVal;
  3394. CFG_LOCK_READ(slapdFrontendConfig);
  3395. retVal = slapdFrontendConfig->groupevalnestlevel;
  3396. CFG_UNLOCK_READ(slapdFrontendConfig);
  3397. return retVal;
  3398. }
  3399. struct berval **
  3400. config_get_defaultreferral() {
  3401. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3402. struct berval **refs;
  3403. int nReferrals = 0;
  3404. CFG_LOCK_READ(slapdFrontendConfig);
  3405. /* count the number of referrals */
  3406. for ( nReferrals = 0;
  3407. slapdFrontendConfig->defaultreferral &&
  3408. slapdFrontendConfig->defaultreferral[nReferrals];
  3409. nReferrals++)
  3410. ;
  3411. refs = (struct berval **)
  3412. slapi_ch_malloc( (nReferrals + 1) * sizeof(struct berval *) );
  3413. /*terminate the end, and add the referrals backwards */
  3414. refs [nReferrals--] = NULL;
  3415. while ( nReferrals >= 0 ) {
  3416. refs[nReferrals] = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
  3417. refs[nReferrals]->bv_val =
  3418. config_copy_strval( slapdFrontendConfig->defaultreferral[nReferrals]->bv_val );
  3419. refs[nReferrals]->bv_len = slapdFrontendConfig->defaultreferral[nReferrals]->bv_len;
  3420. nReferrals--;
  3421. }
  3422. CFG_UNLOCK_READ(slapdFrontendConfig);
  3423. return refs;
  3424. }
  3425. char *
  3426. config_get_userat ( ){
  3427. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3428. char *retVal;
  3429. CFG_LOCK_READ(slapdFrontendConfig);
  3430. retVal = config_copy_strval( slapdFrontendConfig->userat );
  3431. CFG_UNLOCK_READ(slapdFrontendConfig);
  3432. return retVal;
  3433. }
  3434. int
  3435. config_get_timelimit(){
  3436. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3437. int retVal;
  3438. CFG_LOCK_READ(slapdFrontendConfig);
  3439. retVal= slapdFrontendConfig->timelimit;
  3440. CFG_UNLOCK_READ(slapdFrontendConfig);
  3441. return retVal;
  3442. }
  3443. char*
  3444. config_get_useroc(){
  3445. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3446. char *retVal;
  3447. CFG_LOCK_WRITE(slapdFrontendConfig);
  3448. retVal = config_copy_strval(slapdFrontendConfig->useroc );
  3449. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3450. return retVal;
  3451. }
  3452. char *
  3453. config_get_accesslog(){
  3454. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3455. char *retVal;
  3456. CFG_LOCK_READ(slapdFrontendConfig);
  3457. retVal = config_copy_strval(slapdFrontendConfig->accesslog);
  3458. CFG_UNLOCK_READ(slapdFrontendConfig);
  3459. return retVal;
  3460. }
  3461. char *
  3462. config_get_errorlog( ){
  3463. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3464. char *retVal;
  3465. CFG_LOCK_READ(slapdFrontendConfig);
  3466. retVal = config_copy_strval(slapdFrontendConfig->errorlog);
  3467. CFG_UNLOCK_READ(slapdFrontendConfig);
  3468. return retVal;
  3469. }
  3470. char *
  3471. config_get_auditlog( ){
  3472. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3473. char *retVal;
  3474. CFG_LOCK_READ(slapdFrontendConfig);
  3475. retVal = config_copy_strval(slapdFrontendConfig->auditlog);
  3476. CFG_UNLOCK_READ(slapdFrontendConfig);
  3477. return retVal;
  3478. }
  3479. long
  3480. config_get_pw_maxage() {
  3481. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3482. long retVal;
  3483. CFG_LOCK_READ(slapdFrontendConfig);
  3484. retVal = slapdFrontendConfig->pw_policy.pw_maxage;
  3485. CFG_UNLOCK_READ(slapdFrontendConfig);
  3486. return retVal;
  3487. }
  3488. long
  3489. config_get_pw_minage(){
  3490. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3491. long retVal;
  3492. CFG_LOCK_READ(slapdFrontendConfig);
  3493. retVal = slapdFrontendConfig->pw_policy.pw_minage;
  3494. CFG_UNLOCK_READ(slapdFrontendConfig);
  3495. return retVal;
  3496. }
  3497. long
  3498. config_get_pw_warning() {
  3499. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3500. long retVal;
  3501. CFG_LOCK_READ(slapdFrontendConfig);
  3502. retVal = slapdFrontendConfig->pw_policy.pw_warning;
  3503. CFG_UNLOCK_READ(slapdFrontendConfig);
  3504. return retVal;
  3505. }
  3506. int
  3507. config_get_errorlog_level(){
  3508. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3509. int retVal;
  3510. CFG_LOCK_READ(slapdFrontendConfig);
  3511. retVal = slapdFrontendConfig->errorloglevel;
  3512. CFG_UNLOCK_READ(slapdFrontendConfig);
  3513. return retVal;
  3514. }
  3515. /* return integer -- don't worry about locking similar to config_check_referral_mode
  3516. below */
  3517. int
  3518. config_get_accesslog_level(){
  3519. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3520. int retVal;
  3521. retVal = slapdFrontendConfig->accessloglevel;
  3522. return retVal;
  3523. }
  3524. /* return integer -- don't worry about locking similar to config_check_referral_mode
  3525. below */
  3526. int
  3527. config_get_auditlog_logging_enabled(){
  3528. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3529. int retVal;
  3530. retVal = slapdFrontendConfig->auditlog_logging_enabled;
  3531. return retVal;
  3532. }
  3533. char *config_get_referral_mode(void)
  3534. {
  3535. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3536. char *ret;
  3537. CFG_LOCK_READ(slapdFrontendConfig);
  3538. ret = config_copy_strval(slapdFrontendConfig->refer_url);
  3539. CFG_UNLOCK_READ(slapdFrontendConfig);
  3540. return ret;
  3541. }
  3542. int
  3543. config_get_conntablesize(void){
  3544. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3545. int retVal;
  3546. CFG_LOCK_READ(slapdFrontendConfig);
  3547. retVal = slapdFrontendConfig->conntablesize;
  3548. CFG_UNLOCK_READ(slapdFrontendConfig);
  3549. return retVal;
  3550. }
  3551. /* return yes/no without actually copying the referral url
  3552. we don't worry about another thread changing this value
  3553. since we now return an integer */
  3554. int config_check_referral_mode(void)
  3555. {
  3556. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3557. return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
  3558. }
  3559. int
  3560. config_get_outbound_ldap_io_timeout(void)
  3561. {
  3562. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3563. int retVal;
  3564. CFG_LOCK_READ(slapdFrontendConfig);
  3565. retVal = slapdFrontendConfig->outbound_ldap_io_timeout;
  3566. CFG_UNLOCK_READ(slapdFrontendConfig);
  3567. return retVal;
  3568. }
  3569. int
  3570. config_get_unauth_binds_switch(void)
  3571. {
  3572. int retVal;
  3573. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3574. CFG_LOCK_READ(slapdFrontendConfig);
  3575. retVal = slapdFrontendConfig->allow_unauth_binds;
  3576. CFG_UNLOCK_READ(slapdFrontendConfig);
  3577. return retVal;
  3578. }
  3579. int
  3580. config_is_slapd_lite ()
  3581. {
  3582. return ( SLAPD_FULL );
  3583. }
  3584. int
  3585. config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
  3586. {
  3587. int retVal = LDAP_SUCCESS;
  3588. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3589. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3590. return LDAP_OPERATIONS_ERROR;
  3591. }
  3592. if ( !apply ) {
  3593. return retVal;
  3594. }
  3595. CFG_LOCK_WRITE(slapdFrontendConfig);
  3596. slapdFrontendConfig->maxbersize = atoi(value);
  3597. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3598. return retVal;
  3599. }
  3600. ber_len_t
  3601. config_get_maxbersize()
  3602. {
  3603. ber_len_t maxbersize;
  3604. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3605. maxbersize = slapdFrontendConfig->maxbersize;
  3606. if(maxbersize==0)
  3607. maxbersize= 2 * 1024 * 1024; /* Default: 2Mb */
  3608. return maxbersize;
  3609. }
  3610. int
  3611. config_set_maxsasliosize( const char *attrname, char *value, char *errorbuf, int apply )
  3612. {
  3613. int retVal = LDAP_SUCCESS;
  3614. long maxsasliosize;
  3615. char *endptr;
  3616. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3617. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3618. return LDAP_OPERATIONS_ERROR;
  3619. }
  3620. maxsasliosize = strtol(value, &endptr, 10);
  3621. /* Check for non-numeric garbage in the value */
  3622. if (*endptr != '\0') {
  3623. retVal = LDAP_OPERATIONS_ERROR;
  3624. }
  3625. /* Check for a value overflow */
  3626. if (((maxsasliosize == LONG_MAX) || (maxsasliosize == LONG_MIN)) && (errno == ERANGE)){
  3627. retVal = LDAP_OPERATIONS_ERROR;
  3628. }
  3629. /* A setting of -1 means unlimited. Don't allow other negative values. */
  3630. if ((maxsasliosize < 0) && (maxsasliosize != -1)) {
  3631. retVal = LDAP_OPERATIONS_ERROR;
  3632. }
  3633. if (retVal != LDAP_SUCCESS) {
  3634. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3635. "%s: \"%s\" is invalid. Value must range from -1 to %ld",
  3636. attrname, value, LONG_MAX );
  3637. } else if (apply) {
  3638. CFG_LOCK_WRITE(slapdFrontendConfig);
  3639. slapdFrontendConfig->maxsasliosize = maxsasliosize;
  3640. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3641. }
  3642. return retVal;
  3643. }
  3644. size_t
  3645. config_get_maxsasliosize()
  3646. {
  3647. size_t maxsasliosize;
  3648. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3649. maxsasliosize = slapdFrontendConfig->maxsasliosize;
  3650. return maxsasliosize;
  3651. }
  3652. int
  3653. config_set_max_filter_nest_level( const char *attrname, char *value,
  3654. char *errorbuf, int apply )
  3655. {
  3656. int retVal = LDAP_SUCCESS;
  3657. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3658. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3659. return LDAP_OPERATIONS_ERROR;
  3660. }
  3661. if ( !apply ) {
  3662. return retVal;
  3663. }
  3664. CFG_LOCK_WRITE(slapdFrontendConfig);
  3665. slapdFrontendConfig->max_filter_nest_level = atoi(value);
  3666. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3667. return retVal;
  3668. }
  3669. int
  3670. config_get_max_filter_nest_level()
  3671. {
  3672. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3673. int retVal;
  3674. CFG_LOCK_READ(slapdFrontendConfig);
  3675. retVal = slapdFrontendConfig->max_filter_nest_level;
  3676. CFG_UNLOCK_READ(slapdFrontendConfig);
  3677. return retVal;
  3678. }
  3679. char *
  3680. config_get_basedn() {
  3681. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3682. char *retVal;
  3683. CFG_LOCK_READ(slapdFrontendConfig);
  3684. retVal = config_copy_strval ( slapdFrontendConfig->certmap_basedn );
  3685. CFG_UNLOCK_READ(slapdFrontendConfig);
  3686. return retVal;
  3687. }
  3688. int
  3689. config_set_basedn ( const char *attrname, char *value, char *errorbuf, int apply ) {
  3690. int retVal = LDAP_SUCCESS;
  3691. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3692. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3693. return LDAP_OPERATIONS_ERROR;
  3694. }
  3695. if ( !apply ) {
  3696. return retVal;
  3697. }
  3698. CFG_LOCK_WRITE(slapdFrontendConfig);
  3699. slapi_ch_free ( (void **) &slapdFrontendConfig->certmap_basedn );
  3700. slapdFrontendConfig->certmap_basedn = slapi_dn_normalize( slapi_ch_strdup(value) );
  3701. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3702. return retVal;
  3703. }
  3704. char *
  3705. config_get_configdir()
  3706. {
  3707. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3708. char *retVal;
  3709. CFG_LOCK_READ(slapdFrontendConfig);
  3710. retVal = config_copy_strval(slapdFrontendConfig->configdir);
  3711. CFG_UNLOCK_READ(slapdFrontendConfig);
  3712. return retVal;
  3713. }
  3714. int
  3715. config_set_configdir(const char *attrname, char *value, char *errorbuf, int apply)
  3716. {
  3717. int retVal = LDAP_SUCCESS;
  3718. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3719. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3720. return LDAP_OPERATIONS_ERROR;
  3721. }
  3722. if (!apply) {
  3723. return retVal;
  3724. }
  3725. CFG_LOCK_WRITE(slapdFrontendConfig);
  3726. slapi_ch_free((void **)&slapdFrontendConfig->configdir);
  3727. slapdFrontendConfig->configdir = slapi_ch_strdup(value);
  3728. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3729. return retVal;
  3730. }
  3731. /* W/o the setter, "config_set: the attribute nsslapd-instancedir is read only" is printed out. */
  3732. int
  3733. config_set_instancedir(const char *attrname, char *value, char *errorbuf, int apply)
  3734. {
  3735. return LDAP_SUCCESS;
  3736. }
  3737. char *
  3738. config_get_schemadir()
  3739. {
  3740. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3741. char *retVal;
  3742. CFG_LOCK_READ(slapdFrontendConfig);
  3743. retVal = config_copy_strval(slapdFrontendConfig->schemadir);
  3744. CFG_UNLOCK_READ(slapdFrontendConfig);
  3745. return retVal;
  3746. }
  3747. int
  3748. config_set_schemadir(const char *attrname, char *value, char *errorbuf, int apply)
  3749. {
  3750. int retVal = LDAP_SUCCESS;
  3751. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3752. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3753. return LDAP_OPERATIONS_ERROR;
  3754. }
  3755. if (!apply) {
  3756. return retVal;
  3757. }
  3758. CFG_LOCK_WRITE(slapdFrontendConfig);
  3759. slapi_ch_free((void **)&slapdFrontendConfig->schemadir);
  3760. slapdFrontendConfig->schemadir = slapi_ch_strdup(value);
  3761. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3762. return retVal;
  3763. }
  3764. char *
  3765. config_get_lockdir()
  3766. {
  3767. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3768. char *retVal;
  3769. CFG_LOCK_READ(slapdFrontendConfig);
  3770. retVal = config_copy_strval(slapdFrontendConfig->lockdir);
  3771. CFG_UNLOCK_READ(slapdFrontendConfig);
  3772. return retVal;
  3773. }
  3774. int
  3775. config_set_lockdir(const char *attrname, char *value, char *errorbuf, int apply)
  3776. {
  3777. int retVal = LDAP_SUCCESS;
  3778. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3779. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3780. return LDAP_OPERATIONS_ERROR;
  3781. }
  3782. if (!apply) {
  3783. return retVal;
  3784. }
  3785. CFG_LOCK_WRITE(slapdFrontendConfig);
  3786. slapi_ch_free((void **)&slapdFrontendConfig->lockdir);
  3787. slapdFrontendConfig->lockdir = slapi_ch_strdup(value);
  3788. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3789. return retVal;
  3790. }
  3791. char *
  3792. config_get_tmpdir()
  3793. {
  3794. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3795. char *retVal;
  3796. CFG_LOCK_READ(slapdFrontendConfig);
  3797. retVal = config_copy_strval(slapdFrontendConfig->tmpdir);
  3798. CFG_UNLOCK_READ(slapdFrontendConfig);
  3799. return retVal;
  3800. }
  3801. int
  3802. config_set_tmpdir(const char *attrname, char *value, char *errorbuf, int apply)
  3803. {
  3804. int retVal = LDAP_SUCCESS;
  3805. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3806. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3807. return LDAP_OPERATIONS_ERROR;
  3808. }
  3809. if (!apply) {
  3810. return retVal;
  3811. }
  3812. CFG_LOCK_WRITE(slapdFrontendConfig);
  3813. slapi_ch_free((void **)&slapdFrontendConfig->tmpdir);
  3814. slapdFrontendConfig->tmpdir = slapi_ch_strdup(value);
  3815. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3816. return retVal;
  3817. }
  3818. char *
  3819. config_get_certdir()
  3820. {
  3821. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3822. char *retVal;
  3823. CFG_LOCK_READ(slapdFrontendConfig);
  3824. retVal = config_copy_strval(slapdFrontendConfig->certdir);
  3825. CFG_UNLOCK_READ(slapdFrontendConfig);
  3826. return retVal;
  3827. }
  3828. int
  3829. config_set_certdir(const char *attrname, char *value, char *errorbuf, int apply)
  3830. {
  3831. int retVal = LDAP_SUCCESS;
  3832. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3833. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3834. return LDAP_OPERATIONS_ERROR;
  3835. }
  3836. if (!apply) {
  3837. return retVal;
  3838. }
  3839. CFG_LOCK_WRITE(slapdFrontendConfig);
  3840. slapi_ch_free((void **)&slapdFrontendConfig->certdir);
  3841. slapdFrontendConfig->certdir = slapi_ch_strdup(value);
  3842. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3843. return retVal;
  3844. }
  3845. char *
  3846. config_get_ldifdir()
  3847. {
  3848. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3849. char *retVal;
  3850. CFG_LOCK_READ(slapdFrontendConfig);
  3851. retVal = config_copy_strval(slapdFrontendConfig->ldifdir);
  3852. CFG_UNLOCK_READ(slapdFrontendConfig);
  3853. return retVal;
  3854. }
  3855. int
  3856. config_set_ldifdir(const char *attrname, char *value, char *errorbuf, int apply)
  3857. {
  3858. int retVal = LDAP_SUCCESS;
  3859. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3860. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3861. return LDAP_OPERATIONS_ERROR;
  3862. }
  3863. if (!apply) {
  3864. return retVal;
  3865. }
  3866. CFG_LOCK_WRITE(slapdFrontendConfig);
  3867. slapi_ch_free((void **)&slapdFrontendConfig->ldifdir);
  3868. slapdFrontendConfig->ldifdir = slapi_ch_strdup(value);
  3869. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3870. return retVal;
  3871. }
  3872. char *
  3873. config_get_bakdir()
  3874. {
  3875. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3876. char *retVal;
  3877. CFG_LOCK_READ(slapdFrontendConfig);
  3878. retVal = config_copy_strval(slapdFrontendConfig->bakdir);
  3879. CFG_UNLOCK_READ(slapdFrontendConfig);
  3880. return retVal;
  3881. }
  3882. int
  3883. config_set_bakdir(const char *attrname, char *value, char *errorbuf, int apply)
  3884. {
  3885. int retVal = LDAP_SUCCESS;
  3886. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3887. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3888. return LDAP_OPERATIONS_ERROR;
  3889. }
  3890. if (!apply) {
  3891. return retVal;
  3892. }
  3893. CFG_LOCK_WRITE(slapdFrontendConfig);
  3894. slapi_ch_free((void **)&slapdFrontendConfig->bakdir);
  3895. slapdFrontendConfig->bakdir = slapi_ch_strdup(value);
  3896. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3897. return retVal;
  3898. }
  3899. char *
  3900. config_get_rundir()
  3901. {
  3902. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3903. char *retVal;
  3904. CFG_LOCK_READ(slapdFrontendConfig);
  3905. retVal = config_copy_strval(slapdFrontendConfig->rundir);
  3906. CFG_UNLOCK_READ(slapdFrontendConfig);
  3907. return retVal;
  3908. }
  3909. int
  3910. config_set_rundir(const char *attrname, char *value, char *errorbuf, int apply)
  3911. {
  3912. int retVal = LDAP_SUCCESS;
  3913. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3914. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3915. return LDAP_OPERATIONS_ERROR;
  3916. }
  3917. if (!apply) {
  3918. return retVal;
  3919. }
  3920. CFG_LOCK_WRITE(slapdFrontendConfig);
  3921. slapi_ch_free((void **)&slapdFrontendConfig->rundir);
  3922. slapdFrontendConfig->rundir = slapi_ch_strdup(value);
  3923. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3924. return retVal;
  3925. }
  3926. char *
  3927. config_get_saslpath()
  3928. {
  3929. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3930. char *retVal;
  3931. CFG_LOCK_READ(slapdFrontendConfig);
  3932. retVal = config_copy_strval(slapdFrontendConfig->saslpath);
  3933. CFG_UNLOCK_READ(slapdFrontendConfig);
  3934. return retVal;
  3935. }
  3936. int
  3937. config_set_saslpath(const char *attrname, char *value, char *errorbuf, int apply)
  3938. {
  3939. int retVal = LDAP_SUCCESS;
  3940. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3941. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3942. return LDAP_OPERATIONS_ERROR;
  3943. }
  3944. if (!apply) {
  3945. return retVal;
  3946. }
  3947. CFG_LOCK_WRITE(slapdFrontendConfig);
  3948. slapi_ch_free((void **)&slapdFrontendConfig->saslpath);
  3949. slapdFrontendConfig->saslpath = slapi_ch_strdup(value);
  3950. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3951. return retVal;
  3952. }
  3953. char **
  3954. config_get_errorlog_list()
  3955. {
  3956. return log_get_loglist(SLAPD_ERROR_LOG);
  3957. }
  3958. char **
  3959. config_get_accesslog_list()
  3960. {
  3961. return log_get_loglist(SLAPD_ACCESS_LOG);
  3962. }
  3963. char **
  3964. config_get_auditlog_list()
  3965. {
  3966. return log_get_loglist(SLAPD_AUDIT_LOG);
  3967. }
  3968. int
  3969. config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
  3970. {
  3971. int retVal = LDAP_SUCCESS;
  3972. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3973. retVal = config_set_onoff(attrname,
  3974. value,
  3975. &(slapdFrontendConfig->accesslogbuffering),
  3976. errorbuf,
  3977. apply);
  3978. return retVal;
  3979. }
  3980. #ifdef MEMPOOL_EXPERIMENTAL
  3981. int
  3982. config_set_mempool_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
  3983. int retVal = LDAP_SUCCESS;
  3984. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3985. retVal = config_set_onoff(attrname,
  3986. value,
  3987. &(slapdFrontendConfig->mempool_switch),
  3988. errorbuf,
  3989. apply);
  3990. return retVal;
  3991. }
  3992. int
  3993. config_get_mempool_switch()
  3994. {
  3995. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3996. return slapdFrontendConfig->mempool_switch;
  3997. }
  3998. int
  3999. config_set_mempool_maxfreelist( const char *attrname, char *value, char *errorbuf, int apply )
  4000. {
  4001. int retVal = LDAP_SUCCESS;
  4002. char *endp = NULL;
  4003. int maxfreelist;
  4004. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4005. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4006. return LDAP_OPERATIONS_ERROR;
  4007. }
  4008. errno = 0;
  4009. maxfreelist = strtol(value, &endp, 10);
  4010. if (0 != errno ) {
  4011. return LDAP_OPERATIONS_ERROR;
  4012. }
  4013. if ( apply ) {
  4014. CFG_LOCK_WRITE(slapdFrontendConfig);
  4015. slapdFrontendConfig->mempool_maxfreelist = maxfreelist;
  4016. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4017. }
  4018. return retVal;
  4019. }
  4020. int
  4021. config_get_mempool_maxfreelist()
  4022. {
  4023. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4024. return slapdFrontendConfig->mempool_maxfreelist;
  4025. }
  4026. long
  4027. config_get_system_page_size()
  4028. {
  4029. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4030. return slapdFrontendConfig->system_page_size;
  4031. }
  4032. int
  4033. config_get_system_page_bits()
  4034. {
  4035. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4036. return slapdFrontendConfig->system_page_bits;
  4037. }
  4038. #endif /* MEMPOOL_EXPERIMENTAL */
  4039. int
  4040. config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply)
  4041. {
  4042. int retVal = LDAP_SUCCESS;
  4043. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4044. retVal = config_set_onoff(attrname,
  4045. value,
  4046. &(slapdFrontendConfig->csnlogging),
  4047. errorbuf,
  4048. apply);
  4049. return retVal;
  4050. }
  4051. int
  4052. config_get_csnlogging()
  4053. {
  4054. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4055. return slapdFrontendConfig->csnlogging;
  4056. }
  4057. int
  4058. config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply)
  4059. {
  4060. int retVal = LDAP_SUCCESS;
  4061. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4062. retVal = config_set_onoff(attrname,
  4063. value,
  4064. &(slapdFrontendConfig->attrname_exceptions),
  4065. errorbuf,
  4066. apply);
  4067. return retVal;
  4068. }
  4069. int
  4070. config_get_attrname_exceptions()
  4071. {
  4072. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4073. return slapdFrontendConfig->attrname_exceptions;
  4074. }
  4075. int
  4076. config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply)
  4077. {
  4078. int val = 0;
  4079. int retVal = LDAP_SUCCESS;
  4080. retVal = config_set_onoff(attrname,
  4081. value,
  4082. &val,
  4083. errorbuf,
  4084. apply);
  4085. if (retVal == LDAP_SUCCESS) {
  4086. set_hash_filters(val);
  4087. }
  4088. return retVal;
  4089. }
  4090. int
  4091. config_get_hash_filters()
  4092. {
  4093. return 0; /* for now */
  4094. }
  4095. int
  4096. config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply)
  4097. {
  4098. int retVal = LDAP_SUCCESS;
  4099. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4100. retVal = config_set_onoff(attrname,
  4101. value,
  4102. &(slapdFrontendConfig->rewrite_rfc1274),
  4103. errorbuf,
  4104. apply);
  4105. return retVal;
  4106. }
  4107. /* we don't worry about another thread changing this flag since it is an
  4108. integer */
  4109. int
  4110. config_get_rewrite_rfc1274()
  4111. {
  4112. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4113. int retVal;
  4114. retVal = slapdFrontendConfig->rewrite_rfc1274;
  4115. return retVal;
  4116. }
  4117. static int
  4118. config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int apply )
  4119. {
  4120. int retVal = LDAP_SUCCESS;
  4121. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4122. retVal = LDAP_OPERATIONS_ERROR;
  4123. } else {
  4124. /*
  4125. * check that the value is one we allow.
  4126. */
  4127. if ( 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_OFF ) &&
  4128. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
  4129. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
  4130. retVal = LDAP_OPERATIONS_ERROR;
  4131. if( errorbuf ) {
  4132. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
  4133. }
  4134. }
  4135. }
  4136. if ( LDAP_SUCCESS == retVal && apply ) {
  4137. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4138. CFG_LOCK_WRITE(slapdFrontendConfig);
  4139. slapi_ch_free( (void **)&slapdFrontendConfig->schemareplace );
  4140. slapdFrontendConfig->schemareplace = slapi_ch_strdup( value );
  4141. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4142. }
  4143. return retVal;
  4144. }
  4145. int
  4146. config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
  4147. char *errorbuf, int apply )
  4148. {
  4149. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4150. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4151. return LDAP_OPERATIONS_ERROR;
  4152. }
  4153. if ( apply ) {
  4154. CFG_LOCK_WRITE(slapdFrontendConfig);
  4155. slapdFrontendConfig->outbound_ldap_io_timeout = atoi( value );
  4156. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4157. }
  4158. return LDAP_SUCCESS;
  4159. }
  4160. int
  4161. config_set_unauth_binds_switch( const char *attrname, char *value,
  4162. char *errorbuf, int apply )
  4163. {
  4164. int retVal = LDAP_SUCCESS;
  4165. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4166. retVal = config_set_onoff(attrname,
  4167. value,
  4168. &(slapdFrontendConfig->allow_unauth_binds),
  4169. errorbuf,
  4170. apply);
  4171. return retVal;
  4172. }
  4173. /*
  4174. * This function is intended to be used from the dse code modify callback. It
  4175. * is "optimized" for that case because it takes a berval** of values, which is
  4176. * currently what is used by ldapmod to hold the values. We could easily switch
  4177. * this to take a Slapi_Value array or even a Slapi_Attr. Most config params
  4178. * have simple config_set_XXX functions which take a char* argument holding the
  4179. * value. The log_set_XXX functions have an additional parameter which
  4180. * discriminates the log to use. The config parameters with types CONFIG_SPECIAL_XXX
  4181. * require special handling to set their values.
  4182. */
  4183. int
  4184. config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
  4185. {
  4186. int ii = 0;
  4187. int retval = LDAP_SUCCESS;
  4188. struct config_get_and_set *cgas = 0;
  4189. cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash, attr);
  4190. if (!cgas)
  4191. {
  4192. #if 0
  4193. debugHashTable(attr);
  4194. #endif
  4195. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
  4196. slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
  4197. return retval;
  4198. }
  4199. switch (cgas->config_var_type)
  4200. {
  4201. case CONFIG_SPECIAL_REFERRALLIST:
  4202. if (NULL == values) /* special token which means to remove referrals */
  4203. {
  4204. struct berval val;
  4205. struct berval *vals[2] = {0, 0};
  4206. vals[0] = &val;
  4207. val.bv_val = REFERRAL_REMOVE_CMD;
  4208. val.bv_len = strlen(REFERRAL_REMOVE_CMD);
  4209. retval = config_set_defaultreferral(attr, vals, errorbuf, apply);
  4210. }
  4211. else
  4212. {
  4213. retval = config_set_defaultreferral(attr, values, errorbuf, apply);
  4214. }
  4215. break;
  4216. default:
  4217. for (ii = 0; !retval && values && values[ii]; ++ii)
  4218. {
  4219. if (cgas->setfunc)
  4220. retval = (cgas->setfunc)(cgas->attr_name,
  4221. (char *)values[ii]->bv_val, errorbuf, apply);
  4222. else if (cgas->logsetfunc)
  4223. retval = (cgas->logsetfunc)(cgas->attr_name,
  4224. (char *)values[ii]->bv_val, cgas->whichlog,
  4225. errorbuf, apply);
  4226. else
  4227. LDAPDebug(LDAP_DEBUG_ANY,
  4228. "config_set: the attribute %s is read only; ignoring new value %s\n",
  4229. attr, values[ii]->bv_val, 0);
  4230. }
  4231. break;
  4232. }
  4233. return retval;
  4234. }
  4235. static void
  4236. config_set_value(
  4237. Slapi_Entry *e,
  4238. struct config_get_and_set *cgas,
  4239. void **value
  4240. )
  4241. {
  4242. struct berval **values = 0;
  4243. char *sval = 0;
  4244. int ival = 0;
  4245. uintptr_t pval;
  4246. /* for null values, just set the attr value to the empty
  4247. string */
  4248. if (!value) {
  4249. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4250. return;
  4251. }
  4252. switch (cgas->config_var_type) {
  4253. case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */
  4254. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  4255. (value && *((int *)value)) ? "on" : "off");
  4256. break;
  4257. case CONFIG_INT:
  4258. if (value)
  4259. slapi_entry_attr_set_int(e, cgas->attr_name, *((int *)value));
  4260. else
  4261. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4262. break;
  4263. case CONFIG_LONG:
  4264. if (value)
  4265. slapi_entry_attr_set_long(e, cgas->attr_name, *((long *)value));
  4266. else
  4267. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4268. break;
  4269. case CONFIG_STRING:
  4270. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  4271. (value && *((char **)value)) ?
  4272. *((char **)value) : "");
  4273. break;
  4274. case CONFIG_CHARRAY:
  4275. values = strarray2bervalarray((const char **)*((char ***)value));
  4276. if (!values) {
  4277. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4278. } else {
  4279. slapi_entry_attr_replace(e, cgas->attr_name, values);
  4280. bervalarray_free(values);
  4281. }
  4282. break;
  4283. case CONFIG_SPECIAL_REFERRALLIST:
  4284. /* referral list is already an array of berval* */
  4285. if (value)
  4286. slapi_entry_attr_replace(e, cgas->attr_name, (struct berval**)*value);
  4287. else
  4288. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4289. break;
  4290. case CONFIG_CONSTANT_STRING:
  4291. PR_ASSERT(value); /* should be a constant value */
  4292. slapi_entry_attr_set_charptr(e, cgas->attr_name, (char*)value);
  4293. break;
  4294. case CONFIG_CONSTANT_INT:
  4295. PR_ASSERT(value); /* should be a constant value */
  4296. pval = (uintptr_t)value;
  4297. ival = (int)pval;
  4298. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  4299. break;
  4300. case CONFIG_SPECIAL_SSLCLIENTAUTH:
  4301. if (!value) {
  4302. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  4303. break;
  4304. }
  4305. if (*((int *)value) == SLAPD_SSLCLIENTAUTH_ALLOWED) {
  4306. sval = "allowed";
  4307. } else if (*((int *)value) == SLAPD_SSLCLIENTAUTH_REQUIRED) {
  4308. sval = "required";
  4309. } else {
  4310. sval = "off";
  4311. }
  4312. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  4313. break;
  4314. case CONFIG_STRING_OR_OFF:
  4315. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  4316. (value && *((char **)value)) ?
  4317. *((char **)value) : "off");
  4318. break;
  4319. case CONFIG_STRING_OR_EMPTY:
  4320. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  4321. (value && *((char **)value)) ?
  4322. *((char **)value) : "");
  4323. break;
  4324. case CONFIG_STRING_OR_UNKNOWN:
  4325. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  4326. (value && *((char **)value)) ?
  4327. *((char **)value) : "unknown");
  4328. break;
  4329. case CONFIG_SPECIAL_ERRORLOGLEVEL:
  4330. if (value) {
  4331. int ival = *(int *)value;
  4332. ival &= ~LDAP_DEBUG_ANY;
  4333. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  4334. }
  4335. else
  4336. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  4337. break;
  4338. default:
  4339. PR_ASSERT(0); /* something went horribly wrong . . . */
  4340. break;
  4341. }
  4342. return;
  4343. }
  4344. /*
  4345. * Fill in the given slapi_entry with the config attributes and values
  4346. */
  4347. int
  4348. config_set_entry(Slapi_Entry *e)
  4349. {
  4350. int ii = 0;
  4351. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  4352. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4353. /*
  4354. * Avoid recursive calls to the readers/writer
  4355. * lock as it causes deadlock under stress. Each
  4356. * individual config get function acquires a read
  4357. * lock where necessary.
  4358. */
  4359. /*
  4360. * Pass 1: Values which do not have a get function.
  4361. */
  4362. CFG_LOCK_READ(slapdFrontendConfig);
  4363. for (ii = 0; ii < tablesize; ++ii) {
  4364. struct config_get_and_set *cgas = &ConfigList[ii];
  4365. void **value = 0;
  4366. PR_ASSERT(cgas);
  4367. value = cgas->config_var_addr;
  4368. PR_ASSERT(cgas->attr_name);
  4369. /* Skip values handled in pass 2 */
  4370. if (NULL == value && cgas->getfunc) {
  4371. continue;
  4372. }
  4373. config_set_value(e, cgas, value);
  4374. }
  4375. CFG_UNLOCK_READ(slapdFrontendConfig);
  4376. /*
  4377. * Pass 2: Values which do have a get function.
  4378. */
  4379. for (ii = 0; ii < tablesize; ++ii) {
  4380. struct config_get_and_set *cgas = &ConfigList[ii];
  4381. void **value = 0;
  4382. void *alloc_val;
  4383. int needs_free = 0;
  4384. PR_ASSERT(cgas);
  4385. value = cgas->config_var_addr;
  4386. PR_ASSERT(cgas->attr_name);
  4387. /* Skip values handled in pass 1 */
  4388. if (NULL != value || cgas->getfunc == NULL) {
  4389. continue;
  4390. }
  4391. alloc_val = (cgas->getfunc)();
  4392. value = &alloc_val; /* value must be address of pointer */
  4393. if (!isIntegralType(cgas->config_var_type))
  4394. needs_free = 1; /* get funcs must return alloc'd memory except for get
  4395. funcs which return a simple integral type e.g. int */
  4396. config_set_value(e, cgas, value);
  4397. if (needs_free && value) { /* assumes memory allocated by slapi_ch_Xalloc */
  4398. if (CONFIG_CHARRAY == cgas->config_var_type) {
  4399. charray_free(*((char ***)value));
  4400. } else {
  4401. slapi_ch_free(value);
  4402. }
  4403. }
  4404. }
  4405. return 1;
  4406. }