libglobs.c 216 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511
  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. #undef OFF
  53. #undef LITTLE_ENDIAN
  54. #include <stdio.h>
  55. #include <string.h>
  56. #include <sys/types.h>
  57. #include <time.h>
  58. #include <stdarg.h>
  59. #include <stdlib.h>
  60. #if defined( _WIN32 )
  61. #define R_OK 04
  62. #include "ntslapdmessages.h"
  63. #include "proto-ntutil.h"
  64. #else
  65. #include <sys/time.h>
  66. #include <sys/param.h> /* MAXPATHLEN */
  67. #include <sys/socket.h>
  68. #include <netinet/in.h>
  69. #include <arpa/inet.h>
  70. #include <netdb.h>
  71. #include <unistd.h>
  72. #include <pwd.h> /* pwdnam */
  73. #endif
  74. #ifdef USE_SYSCONF
  75. #include <unistd.h>
  76. #endif /* USE_SYSCONF */
  77. #include "slap.h"
  78. #include "plhash.h"
  79. #define REMOVE_CHANGELOG_CMD "remove"
  80. /* On UNIX, there's only one copy of slapd_ldap_debug */
  81. /* On NT, each module keeps its own module_ldap_debug, which */
  82. /* points to the process' slapd_ldap_debug */
  83. #ifdef _WIN32
  84. int *module_ldap_debug;
  85. int __declspec(dllexport) slapd_ldap_debug = LDAP_DEBUG_ANY;
  86. #else
  87. int slapd_ldap_debug = LDAP_DEBUG_ANY;
  88. #endif
  89. char *ldap_srvtab = "";
  90. /* Note that the 'attrname' arguments are used only for log messages */
  91. typedef int (*ConfigSetFunc)(const char *attrname, char *value,
  92. char *errorbuf, int apply);
  93. typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
  94. char *errorbuf, int apply);
  95. typedef enum {
  96. CONFIG_INT, /* maps to int */
  97. CONFIG_LONG, /* maps to long */
  98. CONFIG_STRING, /* maps to char* */
  99. CONFIG_CHARRAY, /* maps to char** */
  100. CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
  101. CONFIG_STRING_OR_OFF, /* use "off" instead of null or an empty string */
  102. CONFIG_STRING_OR_UNKNOWN, /* use "unknown" instead of an empty string */
  103. CONFIG_CONSTANT_INT, /* for #define values, e.g. */
  104. CONFIG_CONSTANT_STRING, /* for #define values, e.g. */
  105. CONFIG_SPECIAL_REFERRALLIST, /* this is a berval list */
  106. CONFIG_SPECIAL_SSLCLIENTAUTH, /* maps strings to an enumeration */
  107. CONFIG_SPECIAL_ERRORLOGLEVEL, /* requires & with LDAP_DEBUG_ANY */
  108. CONFIG_STRING_OR_EMPTY, /* use an empty string */
  109. CONFIG_SPECIAL_ANON_ACCESS_SWITCH, /* maps strings to an enumeration */
  110. CONFIG_SPECIAL_VALIDATE_CERT_SWITCH, /* maps strings to an enumeration */
  111. CONFIG_SPECIAL_UNHASHED_PW_SWITCH /* unhashed pw: on/off/nolog */
  112. } ConfigVarType;
  113. static int config_set_onoff( const char *attrname, char *value,
  114. int *configvalue, char *errorbuf, int apply );
  115. static int config_set_schemareplace ( const char *attrname, char *value,
  116. char *errorbuf, int apply );
  117. /* Keeping the initial values */
  118. /* CONFIG_INT/CONFIG_LONG */
  119. #define DEFAULT_LOG_ROTATIONSYNCHOUR "0"
  120. #define DEFAULT_LOG_ROTATIONSYNCMIN "0"
  121. #define DEFAULT_LOG_ROTATIONTIME "1"
  122. #define DEFAULT_LOG_ACCESS_MAXNUMLOGS "10"
  123. #define DEFAULT_LOG_MAXNUMLOGS "1"
  124. #define DEFAULT_LOG_EXPTIME "1"
  125. #define DEFAULT_LOG_ACCESS_MAXDISKSPACE "500"
  126. #define DEFAULT_LOG_MAXDISKSPACE "100"
  127. #define DEFAULT_LOG_MAXLOGSIZE "100"
  128. #define DEFAULT_LOG_MINFREESPACE "5"
  129. #define DEFAULT_ACCESSLOGLEVEL "256"
  130. #define DEFAULT_SIZELIMIT "2000"
  131. #define DEFAULT_TIMELIMIT "3600"
  132. #define DEFAULT_PAGEDSIZELIMIT "0"
  133. #define DEFAULT_IDLE_TIMEOUT "0"
  134. #define DEFAULT_MAXDESCRIPTORS "1024"
  135. #define DEFAULT_RESERVE_FDS "64"
  136. #define DEFAULT_MAX_BERSIZE "0"
  137. #define DEFAULT_MAX_THREADS "30"
  138. #define DEFAULT_MAX_THREADS_PER_CONN "5"
  139. #define DEFAULT_IOBLOCK_TIMEOUT "1800000"
  140. #define DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT "300000"
  141. #define DEFAULT_MAX_FILTER_NEST_LEVEL "40"
  142. #define DEFAULT_GROUPEVALNESTLEVEL "0"
  143. #define DEFAULT_SNMP_INDEX "0"
  144. #define DEFAULT_MAX_SASLIO_SIZE "2097152"
  145. #define DEFAULT_DISK_THRESHOLD "2097152"
  146. #define DEFAULT_DISK_GRACE_PERIOD "60"
  147. #define DEFAULT_LOCAL_SSF "71"
  148. #define DEFAULT_MIN_SSF "0"
  149. #define DEFAULT_PW_INHISTORY "6"
  150. #define DEFAULT_PW_GRACELIMIT "0"
  151. #define DEFAULT_PW_MINLENGTH "0"
  152. #define DEFAULT_PW_MINDIGITS "0"
  153. #define DEFAULT_PW_MINALPHAS "0"
  154. #define DEFAULT_PW_MINUPPERS "0"
  155. #define DEFAULT_PW_MINLOWERS "0"
  156. #define DEFAULT_PW_MINSPECIALS "0"
  157. #define DEFAULT_PW_MIN8BIT "0"
  158. #define DEFAULT_PW_MAXREPEATS "0"
  159. #define DEFAULT_PW_MINCATEGORIES "3"
  160. #define DEFAULT_PW_MINTOKENLENGTH "3"
  161. #define DEFAULT_PW_MAXAGE "8640000"
  162. #define DEFAULT_PW_MINAGE "0"
  163. #define DEFAULT_PW_WARNING "86400"
  164. #define DEFAULT_PW_MAXFAILURE "3"
  165. #define DEFAULT_PW_RESETFAILURECOUNT "600"
  166. #define DEFAULT_PW_LOCKDURATION "3600"
  167. #define DEFAULT_NDN_SIZE "20971520"
  168. #define DEFAULT_SASL_MAXBUFSIZE "65536"
  169. #define SLAPD_DEFAULT_SASL_MAXBUFSIZE 65536
  170. #ifdef MEMPOOL_EXPERIMENTAL
  171. #define DEFAULT_MEMPOOL_MAXFREELIST "1024"
  172. #endif
  173. /* CONFIG_STRING... */
  174. #define INIT_ACCESSLOG_MODE "600"
  175. #define INIT_ERRORLOG_MODE "600"
  176. #define INIT_AUDITLOG_MODE "600"
  177. #define INIT_ACCESSLOG_ROTATIONUNIT "day"
  178. #define INIT_ERRORLOG_ROTATIONUNIT "week"
  179. #define INIT_AUDITLOG_ROTATIONUNIT "week"
  180. #define INIT_ACCESSLOG_EXPTIMEUNIT "month"
  181. #define INIT_ERRORLOG_EXPTIMEUNIT "month"
  182. #define INIT_AUDITLOG_EXPTIMEUNIT "month"
  183. #define DEFAULT_DIRECTORY_MANAGER "cn=Directory Manager"
  184. #define DEFAULT_UIDNUM_TYPE "uidNumber"
  185. #define DEFAULT_GIDNUM_TYPE "gidNumber"
  186. #define DEFAULT_LDAPI_SEARCH_BASE "dc=example,dc=com"
  187. #define DEFAULT_LDAPI_AUTO_DN "cn=peercred,cn=external,cn=auth"
  188. #define ENTRYUSN_IMPORT_INIT "0"
  189. #define DEFAULT_ALLOWED_TO_DELETE_ATTRS "nsslapd-listenhost nsslapd-securelistenhost nsslapd-defaultnamingcontext nsslapd-snmp-index"
  190. #define SALTED_SHA1_SCHEME_NAME "SSHA"
  191. /* CONFIG_ON_OFF */
  192. slapi_onoff_t init_accesslog_rotationsync_enabled;
  193. slapi_onoff_t init_errorlog_rotationsync_enabled;
  194. slapi_onoff_t init_auditlog_rotationsync_enabled;
  195. slapi_onoff_t init_accesslog_logging_enabled;
  196. slapi_onoff_t init_accesslogbuffering;
  197. slapi_onoff_t init_errorlog_logging_enabled;
  198. slapi_onoff_t init_auditlog_logging_enabled;
  199. slapi_onoff_t init_auditlog_logging_hide_unhashed_pw;
  200. slapi_onoff_t init_csnlogging;
  201. slapi_onoff_t init_pw_unlock;
  202. slapi_onoff_t init_pw_must_change;
  203. slapi_onoff_t init_pwpolicy_local;
  204. slapi_onoff_t init_pw_lockout;
  205. slapi_onoff_t init_pw_history;
  206. slapi_onoff_t init_pw_is_global_policy;
  207. slapi_onoff_t init_pw_is_legacy;
  208. slapi_onoff_t init_pw_track_update_time;
  209. slapi_onoff_t init_pw_change;
  210. slapi_onoff_t init_pw_exp;
  211. slapi_onoff_t init_pw_syntax;
  212. slapi_onoff_t init_schemacheck;
  213. slapi_onoff_t init_schemamod;
  214. slapi_onoff_t init_ds4_compatible_schema;
  215. slapi_onoff_t init_schema_ignore_trailing_spaces;
  216. slapi_onoff_t init_enquote_sup_oc;
  217. slapi_onoff_t init_rewrite_rfc1274;
  218. slapi_onoff_t init_syntaxcheck;
  219. slapi_onoff_t init_syntaxlogging;
  220. slapi_onoff_t init_dn_validate_strict;
  221. slapi_onoff_t init_attrname_exceptions;
  222. slapi_onoff_t init_return_exact_case;
  223. slapi_onoff_t init_result_tweak;
  224. slapi_onoff_t init_plugin_track;
  225. slapi_onoff_t init_lastmod;
  226. slapi_onoff_t init_readonly;
  227. slapi_onoff_t init_accesscontrol;
  228. slapi_onoff_t init_nagle;
  229. slapi_onoff_t init_security;
  230. slapi_onoff_t init_ssl_check_hostname;
  231. slapi_onoff_t init_ldapi_switch;
  232. slapi_onoff_t init_ldapi_bind_switch;
  233. slapi_onoff_t init_ldapi_map_entries;
  234. slapi_onoff_t init_allow_unauth_binds;
  235. slapi_onoff_t init_require_secure_binds;
  236. slapi_onoff_t init_minssf_exclude_rootdse;
  237. slapi_onoff_t init_force_sasl_external;
  238. slapi_onoff_t init_slapi_counters;
  239. slapi_onoff_t init_entryusn_global;
  240. slapi_onoff_t init_disk_monitoring;
  241. slapi_onoff_t init_disk_logging_critical;
  242. slapi_onoff_t init_disk_preserve_logging;
  243. slapi_onoff_t init_ndn_cache_enabled;
  244. slapi_onoff_t init_sasl_mapping_fallback;
  245. slapi_onoff_t init_return_orig_type;
  246. slapi_onoff_t init_enable_turbo_mode;
  247. slapi_onoff_t init_connection_nocanon;
  248. slapi_int_t init_connection_buffer;
  249. #ifdef MEMPOOL_EXPERIMENTAL
  250. slapi_onoff_t init_mempool_switch;
  251. #endif
  252. #define DEFAULT_SSLCLIENTAPTH "off"
  253. #define DEFAULT_ALLOW_ANON_ACCESS "on"
  254. #define DEFAULT_VALIDATE_CERT "warn"
  255. #define DEFAULT_UNHASHED_PW_SWITCH "on"
  256. static int
  257. isInt(ConfigVarType type)
  258. {
  259. return type == CONFIG_INT || type == CONFIG_ON_OFF || type == CONFIG_SPECIAL_SSLCLIENTAUTH || type == CONFIG_SPECIAL_ERRORLOGLEVEL;
  260. }
  261. /* the caller will typically have to cast the result based on the ConfigVarType */
  262. typedef void *(*ConfigGetFunc)(void);
  263. /* static Ref_Array global_referrals; */
  264. static slapdFrontendConfig_t global_slapdFrontendConfig;
  265. static struct config_get_and_set {
  266. const char *attr_name; /* the name of the attribute */
  267. ConfigSetFunc setfunc; /* the function to call to set the value */
  268. LogSetFunc logsetfunc; /* log functions are special */
  269. int whichlog; /* ACCESS, ERROR, AUDIT, etc. */
  270. void** config_var_addr; /* address of member of slapdFrontendConfig struct */
  271. ConfigVarType config_var_type; /* cast to this type when getting */
  272. ConfigGetFunc getfunc; /* for special handling */
  273. void *initvalue;
  274. } ConfigList[] = {
  275. {CONFIG_AUDITLOG_MODE_ATTRIBUTE, NULL,
  276. log_set_mode, SLAPD_AUDIT_LOG,
  277. (void**)&global_slapdFrontendConfig.auditlog_mode,
  278. CONFIG_STRING, NULL, INIT_AUDITLOG_MODE},
  279. {CONFIG_AUDITLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  280. log_set_rotationsync_enabled, SLAPD_AUDIT_LOG,
  281. (void**)&global_slapdFrontendConfig.auditlog_rotationsync_enabled,
  282. CONFIG_ON_OFF, NULL, &init_auditlog_rotationsync_enabled},
  283. {CONFIG_AUDITLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  284. log_set_rotationsynchour, SLAPD_AUDIT_LOG,
  285. (void**)&global_slapdFrontendConfig.auditlog_rotationsynchour,
  286. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCHOUR},
  287. {CONFIG_AUDITLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  288. log_set_rotationsyncmin, SLAPD_AUDIT_LOG,
  289. (void**)&global_slapdFrontendConfig.auditlog_rotationsyncmin,
  290. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCMIN},
  291. {CONFIG_AUDITLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  292. log_set_rotationtime, SLAPD_AUDIT_LOG,
  293. (void**)&global_slapdFrontendConfig.auditlog_rotationtime,
  294. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONTIME},
  295. {CONFIG_ACCESSLOG_MODE_ATTRIBUTE, NULL,
  296. log_set_mode, SLAPD_ACCESS_LOG,
  297. (void**)&global_slapdFrontendConfig.accesslog_mode,
  298. CONFIG_STRING, NULL, INIT_ACCESSLOG_MODE},
  299. {CONFIG_ACCESSLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  300. log_set_numlogsperdir, SLAPD_ACCESS_LOG,
  301. (void**)&global_slapdFrontendConfig.accesslog_maxnumlogs,
  302. CONFIG_INT, NULL, DEFAULT_LOG_ACCESS_MAXNUMLOGS},
  303. {CONFIG_LOGLEVEL_ATTRIBUTE, config_set_errorlog_level,
  304. NULL, 0,
  305. (void**)&global_slapdFrontendConfig.errorloglevel,
  306. CONFIG_SPECIAL_ERRORLOGLEVEL, NULL, NULL},
  307. {CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  308. log_set_logging, SLAPD_ERROR_LOG,
  309. (void**)&global_slapdFrontendConfig.errorlog_logging_enabled,
  310. CONFIG_ON_OFF, NULL, &init_errorlog_logging_enabled},
  311. {CONFIG_ERRORLOG_MODE_ATTRIBUTE, NULL,
  312. log_set_mode, SLAPD_ERROR_LOG,
  313. (void**)&global_slapdFrontendConfig.errorlog_mode,
  314. CONFIG_STRING, NULL, INIT_ERRORLOG_MODE},
  315. {CONFIG_ERRORLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  316. log_set_expirationtime, SLAPD_ERROR_LOG,
  317. (void**)&global_slapdFrontendConfig.errorlog_exptime,
  318. CONFIG_INT, NULL, DEFAULT_LOG_EXPTIME},
  319. {CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  320. log_set_logging, SLAPD_ACCESS_LOG,
  321. (void**)&global_slapdFrontendConfig.accesslog_logging_enabled,
  322. CONFIG_ON_OFF, NULL, &init_accesslog_logging_enabled},
  323. {CONFIG_PORT_ATTRIBUTE, config_set_port,
  324. NULL, 0,
  325. (void**)&global_slapdFrontendConfig.port,
  326. CONFIG_INT, NULL, NULL/* deletion is not allowed */},
  327. {CONFIG_WORKINGDIR_ATTRIBUTE, config_set_workingdir,
  328. NULL, 0,
  329. (void**)&global_slapdFrontendConfig.workingdir,
  330. CONFIG_STRING_OR_EMPTY, NULL, NULL/* deletion is not allowed */},
  331. {CONFIG_MAXTHREADSPERCONN_ATTRIBUTE, config_set_maxthreadsperconn,
  332. NULL, 0,
  333. (void**)&global_slapdFrontendConfig.maxthreadsperconn,
  334. CONFIG_INT, NULL, DEFAULT_MAX_THREADS_PER_CONN},
  335. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  336. log_set_expirationtime, SLAPD_ACCESS_LOG,
  337. (void**)&global_slapdFrontendConfig.accesslog_exptime,
  338. CONFIG_INT, NULL, DEFAULT_LOG_EXPTIME},
  339. #ifndef _WIN32
  340. {CONFIG_LOCALUSER_ATTRIBUTE, config_set_localuser,
  341. NULL, 0,
  342. (void**)&global_slapdFrontendConfig.localuser,
  343. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  344. #endif
  345. {CONFIG_ERRORLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  346. log_set_rotationsync_enabled, SLAPD_ERROR_LOG,
  347. (void**)&global_slapdFrontendConfig.errorlog_rotationsync_enabled,
  348. CONFIG_ON_OFF, NULL, &init_errorlog_rotationsync_enabled},
  349. {CONFIG_ERRORLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  350. log_set_rotationsynchour, SLAPD_ERROR_LOG,
  351. (void**)&global_slapdFrontendConfig.errorlog_rotationsynchour,
  352. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCHOUR},
  353. {CONFIG_ERRORLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  354. log_set_rotationsyncmin, SLAPD_ERROR_LOG,
  355. (void**)&global_slapdFrontendConfig.errorlog_rotationsyncmin,
  356. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCMIN},
  357. {CONFIG_ERRORLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  358. log_set_rotationtime, SLAPD_ERROR_LOG,
  359. (void**)&global_slapdFrontendConfig.errorlog_rotationtime,
  360. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONTIME},
  361. {CONFIG_PW_INHISTORY_ATTRIBUTE, config_set_pw_inhistory,
  362. NULL, 0,
  363. (void**)&global_slapdFrontendConfig.pw_policy.pw_inhistory,
  364. CONFIG_INT, NULL, DEFAULT_PW_INHISTORY},
  365. {CONFIG_PW_STORAGESCHEME_ATTRIBUTE, config_set_pw_storagescheme,
  366. NULL, 0, NULL,
  367. CONFIG_STRING, (ConfigGetFunc)config_get_pw_storagescheme,
  368. SALTED_SHA1_SCHEME_NAME},
  369. {CONFIG_PW_UNLOCK_ATTRIBUTE, config_set_pw_unlock,
  370. NULL, 0,
  371. (void**)&global_slapdFrontendConfig.pw_policy.pw_unlock,
  372. CONFIG_ON_OFF, NULL, &init_pw_unlock},
  373. {CONFIG_PW_GRACELIMIT_ATTRIBUTE, config_set_pw_gracelimit,
  374. NULL, 0,
  375. (void**)&global_slapdFrontendConfig.pw_policy.pw_gracelimit,
  376. CONFIG_INT, NULL, DEFAULT_PW_GRACELIMIT},
  377. {CONFIG_PW_ADMIN_DN_ATTRIBUTE, config_set_pw_admin_dn,
  378. NULL, 0,
  379. (void**)&global_slapdFrontendConfig.pw_policy.pw_admin,
  380. CONFIG_STRING, NULL, ""},
  381. {CONFIG_ACCESSLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
  382. log_set_rotationsync_enabled, SLAPD_ACCESS_LOG,
  383. (void**)&global_slapdFrontendConfig.accesslog_rotationsync_enabled,
  384. CONFIG_ON_OFF, NULL, &init_accesslog_rotationsync_enabled},
  385. {CONFIG_ACCESSLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
  386. log_set_rotationsynchour, SLAPD_ACCESS_LOG,
  387. (void**)&global_slapdFrontendConfig.accesslog_rotationsynchour,
  388. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCHOUR},
  389. {CONFIG_ACCESSLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
  390. log_set_rotationsyncmin, SLAPD_ACCESS_LOG,
  391. (void**)&global_slapdFrontendConfig.accesslog_rotationsyncmin,
  392. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONSYNCMIN},
  393. {CONFIG_ACCESSLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
  394. log_set_rotationtime, SLAPD_ACCESS_LOG,
  395. (void**)&global_slapdFrontendConfig.accesslog_rotationtime,
  396. CONFIG_INT, NULL, DEFAULT_LOG_ROTATIONTIME},
  397. {CONFIG_PW_MUSTCHANGE_ATTRIBUTE, config_set_pw_must_change,
  398. NULL, 0,
  399. (void**)&global_slapdFrontendConfig.pw_policy.pw_must_change,
  400. CONFIG_ON_OFF, NULL, &init_pw_must_change},
  401. {CONFIG_PWPOLICY_LOCAL_ATTRIBUTE, config_set_pwpolicy_local,
  402. NULL, 0,
  403. (void**)&global_slapdFrontendConfig.pwpolicy_local,
  404. CONFIG_ON_OFF, NULL, &init_pwpolicy_local},
  405. {CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  406. log_set_maxdiskspace, SLAPD_AUDIT_LOG,
  407. (void**)&global_slapdFrontendConfig.auditlog_maxdiskspace,
  408. CONFIG_INT, NULL, DEFAULT_LOG_MAXDISKSPACE},
  409. {CONFIG_SIZELIMIT_ATTRIBUTE, config_set_sizelimit,
  410. NULL, 0,
  411. (void**)&global_slapdFrontendConfig.sizelimit,
  412. CONFIG_INT, NULL, DEFAULT_SIZELIMIT},
  413. {CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  414. log_set_logsize, SLAPD_AUDIT_LOG,
  415. (void**)&global_slapdFrontendConfig.auditlog_maxlogsize,
  416. CONFIG_INT, NULL, DEFAULT_LOG_MAXLOGSIZE},
  417. {CONFIG_PW_WARNING_ATTRIBUTE, config_set_pw_warning,
  418. NULL, 0,
  419. (void**)&global_slapdFrontendConfig.pw_policy.pw_warning,
  420. CONFIG_LONG, NULL, DEFAULT_PW_WARNING},
  421. {CONFIG_READONLY_ATTRIBUTE, config_set_readonly,
  422. NULL, 0,
  423. (void**)&global_slapdFrontendConfig.readonly,
  424. CONFIG_ON_OFF, NULL, &init_readonly},
  425. {CONFIG_SASL_MAPPING_FALLBACK, config_set_sasl_mapping_fallback,
  426. NULL, 0,
  427. (void**)&global_slapdFrontendConfig.sasl_mapping_fallback,
  428. CONFIG_ON_OFF, (ConfigGetFunc)config_get_sasl_mapping_fallback,
  429. &init_sasl_mapping_fallback},
  430. {CONFIG_THREADNUMBER_ATTRIBUTE, config_set_threadnumber,
  431. NULL, 0,
  432. (void**)&global_slapdFrontendConfig.threadnumber,
  433. CONFIG_INT, NULL, DEFAULT_MAX_THREADS},
  434. {CONFIG_PW_LOCKOUT_ATTRIBUTE, config_set_pw_lockout,
  435. NULL, 0,
  436. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockout,
  437. CONFIG_ON_OFF, NULL, &init_pw_lockout},
  438. {CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, config_set_enquote_sup_oc,
  439. NULL, 0,
  440. (void**)&global_slapdFrontendConfig.enquote_sup_oc,
  441. CONFIG_ON_OFF, NULL, &init_enquote_sup_oc},
  442. {CONFIG_LOCALHOST_ATTRIBUTE, config_set_localhost,
  443. NULL, 0,
  444. (void**)&global_slapdFrontendConfig.localhost,
  445. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  446. {CONFIG_IOBLOCKTIMEOUT_ATTRIBUTE, config_set_ioblocktimeout,
  447. NULL, 0,
  448. (void**)&global_slapdFrontendConfig.ioblocktimeout,
  449. CONFIG_INT, NULL, DEFAULT_IOBLOCK_TIMEOUT},
  450. {CONFIG_MAX_FILTER_NEST_LEVEL_ATTRIBUTE, config_set_max_filter_nest_level,
  451. NULL, 0,
  452. (void**)&global_slapdFrontendConfig.max_filter_nest_level,
  453. CONFIG_INT, NULL, DEFAULT_MAX_FILTER_NEST_LEVEL},
  454. {CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  455. log_set_maxdiskspace, SLAPD_ERROR_LOG,
  456. (void**)&global_slapdFrontendConfig.errorlog_maxdiskspace,
  457. CONFIG_INT, NULL, DEFAULT_LOG_MAXDISKSPACE},
  458. {CONFIG_PW_MINLENGTH_ATTRIBUTE, config_set_pw_minlength,
  459. NULL, 0,
  460. (void**)&global_slapdFrontendConfig.pw_policy.pw_minlength,
  461. CONFIG_INT, NULL, DEFAULT_PW_MINLENGTH},
  462. {CONFIG_PW_MINDIGITS_ATTRIBUTE, config_set_pw_mindigits,
  463. NULL, 0,
  464. (void**)&global_slapdFrontendConfig.pw_policy.pw_mindigits,
  465. CONFIG_INT, NULL, DEFAULT_PW_MINDIGITS},
  466. {CONFIG_PW_MINALPHAS_ATTRIBUTE, config_set_pw_minalphas,
  467. NULL, 0,
  468. (void**)&global_slapdFrontendConfig.pw_policy.pw_minalphas,
  469. CONFIG_INT, NULL, DEFAULT_PW_MINALPHAS},
  470. {CONFIG_PW_MINUPPERS_ATTRIBUTE, config_set_pw_minuppers,
  471. NULL, 0,
  472. (void**)&global_slapdFrontendConfig.pw_policy.pw_minuppers,
  473. CONFIG_INT, NULL, DEFAULT_PW_MINUPPERS},
  474. {CONFIG_PW_MINLOWERS_ATTRIBUTE, config_set_pw_minlowers,
  475. NULL, 0,
  476. (void**)&global_slapdFrontendConfig.pw_policy.pw_minlowers,
  477. CONFIG_INT, NULL, DEFAULT_PW_MINLOWERS},
  478. {CONFIG_PW_MINSPECIALS_ATTRIBUTE, config_set_pw_minspecials,
  479. NULL, 0,
  480. (void**)&global_slapdFrontendConfig.pw_policy.pw_minspecials,
  481. CONFIG_INT, NULL, DEFAULT_PW_MINSPECIALS},
  482. {CONFIG_PW_MIN8BIT_ATTRIBUTE, config_set_pw_min8bit,
  483. NULL, 0,
  484. (void**)&global_slapdFrontendConfig.pw_policy.pw_min8bit,
  485. CONFIG_INT, NULL, DEFAULT_PW_MIN8BIT},
  486. {CONFIG_PW_MAXREPEATS_ATTRIBUTE, config_set_pw_maxrepeats,
  487. NULL, 0,
  488. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxrepeats,
  489. CONFIG_INT, NULL, DEFAULT_PW_MAXREPEATS},
  490. {CONFIG_PW_MINCATEGORIES_ATTRIBUTE, config_set_pw_mincategories,
  491. NULL, 0,
  492. (void**)&global_slapdFrontendConfig.pw_policy.pw_mincategories,
  493. CONFIG_INT, NULL, DEFAULT_PW_MINCATEGORIES},
  494. {CONFIG_PW_MINTOKENLENGTH_ATTRIBUTE, config_set_pw_mintokenlength,
  495. NULL, 0,
  496. (void**)&global_slapdFrontendConfig.pw_policy.pw_mintokenlength,
  497. CONFIG_INT, NULL, DEFAULT_PW_MINTOKENLENGTH},
  498. {CONFIG_ERRORLOG_ATTRIBUTE, config_set_errorlog,
  499. NULL, 0,
  500. (void**)&global_slapdFrontendConfig.errorlog,
  501. CONFIG_STRING_OR_EMPTY, NULL, NULL/* deletion is not allowed */},
  502. {CONFIG_AUDITLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
  503. log_set_expirationtime, SLAPD_AUDIT_LOG,
  504. (void**)&global_slapdFrontendConfig.auditlog_exptime,
  505. CONFIG_INT, NULL, DEFAULT_LOG_EXPTIME},
  506. {CONFIG_SCHEMACHECK_ATTRIBUTE, config_set_schemacheck,
  507. NULL, 0,
  508. (void**)&global_slapdFrontendConfig.schemacheck,
  509. CONFIG_ON_OFF, NULL, &init_schemacheck},
  510. {CONFIG_SCHEMAMOD_ATTRIBUTE, config_set_schemamod,
  511. NULL, 0,
  512. (void**)&global_slapdFrontendConfig.schemamod,
  513. CONFIG_ON_OFF, NULL, &init_schemamod},
  514. {CONFIG_SYNTAXCHECK_ATTRIBUTE, config_set_syntaxcheck,
  515. NULL, 0,
  516. (void**)&global_slapdFrontendConfig.syntaxcheck,
  517. CONFIG_ON_OFF, NULL, &init_syntaxcheck},
  518. {CONFIG_SYNTAXLOGGING_ATTRIBUTE, config_set_syntaxlogging,
  519. NULL, 0,
  520. (void**)&global_slapdFrontendConfig.syntaxlogging,
  521. CONFIG_ON_OFF, NULL, &init_syntaxlogging},
  522. {CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, config_set_dn_validate_strict,
  523. NULL, 0,
  524. (void**)&global_slapdFrontendConfig.dn_validate_strict,
  525. CONFIG_ON_OFF, NULL, &init_dn_validate_strict},
  526. {CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema,
  527. NULL, 0,
  528. (void**)&global_slapdFrontendConfig.ds4_compatible_schema,
  529. CONFIG_ON_OFF, NULL, &init_ds4_compatible_schema},
  530. {CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  531. config_set_schema_ignore_trailing_spaces, NULL, 0,
  532. (void**)&global_slapdFrontendConfig.schema_ignore_trailing_spaces,
  533. CONFIG_ON_OFF, NULL, &init_schema_ignore_trailing_spaces},
  534. {CONFIG_SCHEMAREPLACE_ATTRIBUTE, config_set_schemareplace, NULL, 0,
  535. (void**)&global_slapdFrontendConfig.schemareplace,
  536. CONFIG_STRING_OR_OFF, NULL, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY},
  537. {CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  538. log_set_maxdiskspace, SLAPD_ACCESS_LOG,
  539. (void**)&global_slapdFrontendConfig.accesslog_maxdiskspace,
  540. CONFIG_INT, NULL, DEFAULT_LOG_ACCESS_MAXDISKSPACE},
  541. {CONFIG_REFERRAL_ATTRIBUTE, (ConfigSetFunc)config_set_defaultreferral,
  542. NULL, 0,
  543. (void**)&global_slapdFrontendConfig.defaultreferral,
  544. CONFIG_SPECIAL_REFERRALLIST, NULL, NULL/* deletion is not allowed */},
  545. {CONFIG_PW_MAXFAILURE_ATTRIBUTE, config_set_pw_maxfailure,
  546. NULL, 0,
  547. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxfailure,
  548. CONFIG_INT, NULL, DEFAULT_PW_MAXFAILURE},
  549. {CONFIG_ACCESSLOG_ATTRIBUTE, config_set_accesslog,
  550. NULL, 0,
  551. (void**)&global_slapdFrontendConfig.accesslog,
  552. CONFIG_STRING_OR_EMPTY, NULL, NULL/* deletion is not allowed */},
  553. {CONFIG_LASTMOD_ATTRIBUTE, config_set_lastmod,
  554. NULL, 0,
  555. (void**)&global_slapdFrontendConfig.lastmod,
  556. CONFIG_ON_OFF, NULL, &init_lastmod},
  557. {CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
  558. NULL, 0, NULL,
  559. CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme,
  560. SALTED_SHA1_SCHEME_NAME},
  561. {CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
  562. NULL, 0,
  563. (void**)&global_slapdFrontendConfig.pw_policy.pw_history,
  564. CONFIG_ON_OFF, NULL, &init_pw_history},
  565. {CONFIG_SECURITY_ATTRIBUTE, config_set_security,
  566. NULL, 0,
  567. (void**)&global_slapdFrontendConfig.security,
  568. CONFIG_ON_OFF, NULL, &init_security},
  569. {CONFIG_PW_MAXAGE_ATTRIBUTE, config_set_pw_maxage,
  570. NULL, 0,
  571. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxage,
  572. CONFIG_LONG, NULL, DEFAULT_PW_MAXAGE},
  573. {CONFIG_AUDITLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  574. log_set_rotationtimeunit, SLAPD_AUDIT_LOG,
  575. (void**)&global_slapdFrontendConfig.auditlog_rotationunit,
  576. CONFIG_STRING_OR_UNKNOWN, NULL, INIT_AUDITLOG_ROTATIONUNIT},
  577. {CONFIG_PW_RESETFAILURECOUNT_ATTRIBUTE, config_set_pw_resetfailurecount,
  578. NULL, 0,
  579. (void**)&global_slapdFrontendConfig.pw_policy.pw_resetfailurecount,
  580. CONFIG_LONG, NULL, DEFAULT_PW_RESETFAILURECOUNT},
  581. {CONFIG_PW_ISGLOBAL_ATTRIBUTE, config_set_pw_is_global_policy,
  582. NULL, 0,
  583. (void**)&global_slapdFrontendConfig.pw_is_global_policy,
  584. CONFIG_ON_OFF, NULL, &init_pw_is_global_policy},
  585. {CONFIG_PW_IS_LEGACY, config_set_pw_is_legacy_policy,
  586. NULL, 0,
  587. (void**)&global_slapdFrontendConfig.pw_policy.pw_is_legacy,
  588. CONFIG_ON_OFF, NULL, &init_pw_is_legacy},
  589. {CONFIG_PW_TRACK_LAST_UPDATE_TIME, config_set_pw_track_last_update_time,
  590. NULL, 0,
  591. (void**)&global_slapdFrontendConfig.pw_policy.pw_track_update_time,
  592. CONFIG_ON_OFF, NULL, &init_pw_track_update_time},
  593. {CONFIG_AUDITLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  594. log_set_numlogsperdir, SLAPD_AUDIT_LOG,
  595. (void**)&global_slapdFrontendConfig.auditlog_maxnumlogs,
  596. CONFIG_INT, NULL, DEFAULT_LOG_MAXNUMLOGS},
  597. {CONFIG_ERRORLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  598. log_set_expirationtimeunit, SLAPD_ERROR_LOG,
  599. (void**)&global_slapdFrontendConfig.errorlog_exptimeunit,
  600. CONFIG_STRING_OR_UNKNOWN, NULL, INIT_ERRORLOG_EXPTIMEUNIT},
  601. /* errorlog list is read only, so no set func and no config var addr */
  602. {CONFIG_ERRORLOG_LIST_ATTRIBUTE, NULL,
  603. NULL, 0, NULL,
  604. CONFIG_CHARRAY, (ConfigGetFunc)config_get_errorlog_list, NULL},
  605. {CONFIG_GROUPEVALNESTLEVEL_ATTRIBUTE, config_set_groupevalnestlevel,
  606. NULL, 0,
  607. (void**)&global_slapdFrontendConfig.groupevalnestlevel,
  608. CONFIG_INT, NULL, DEFAULT_GROUPEVALNESTLEVEL},
  609. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  610. log_set_expirationtimeunit, SLAPD_ACCESS_LOG,
  611. (void**)&global_slapdFrontendConfig.accesslog_exptimeunit,
  612. CONFIG_STRING_OR_UNKNOWN, NULL, INIT_ACCESSLOG_EXPTIMEUNIT},
  613. {CONFIG_ROOTPW_ATTRIBUTE, config_set_rootpw,
  614. NULL, 0,
  615. (void**)&global_slapdFrontendConfig.rootpw,
  616. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  617. {CONFIG_PW_CHANGE_ATTRIBUTE, config_set_pw_change,
  618. NULL, 0,
  619. (void**)&global_slapdFrontendConfig.pw_policy.pw_change,
  620. CONFIG_ON_OFF, NULL, &init_pw_change},
  621. {CONFIG_ACCESSLOGLEVEL_ATTRIBUTE, config_set_accesslog_level,
  622. NULL, 0,
  623. (void**)&global_slapdFrontendConfig.accessloglevel,
  624. CONFIG_INT, NULL, DEFAULT_ACCESSLOGLEVEL},
  625. {CONFIG_ERRORLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  626. log_set_rotationtimeunit, SLAPD_ERROR_LOG,
  627. (void**)&global_slapdFrontendConfig.errorlog_rotationunit,
  628. CONFIG_STRING_OR_UNKNOWN, NULL, INIT_ERRORLOG_ROTATIONUNIT},
  629. {CONFIG_SECUREPORT_ATTRIBUTE, config_set_secureport,
  630. NULL, 0,
  631. (void**)&global_slapdFrontendConfig.secureport,
  632. CONFIG_INT, NULL, NULL/* deletion is not allowed */},
  633. {CONFIG_BASEDN_ATTRIBUTE, config_set_basedn,
  634. NULL, 0,
  635. (void**)&global_slapdFrontendConfig.certmap_basedn,
  636. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  637. {CONFIG_TIMELIMIT_ATTRIBUTE, config_set_timelimit,
  638. NULL, 0,
  639. (void**)&global_slapdFrontendConfig.timelimit,
  640. CONFIG_INT, NULL, DEFAULT_TIMELIMIT},
  641. {CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  642. log_set_logsize, SLAPD_ERROR_LOG,
  643. (void**)&global_slapdFrontendConfig.errorlog_maxlogsize,
  644. CONFIG_INT, NULL, DEFAULT_LOG_MAXLOGSIZE},
  645. {CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE, config_set_reservedescriptors,
  646. NULL, 0,
  647. (void**)&global_slapdFrontendConfig.reservedescriptors,
  648. CONFIG_INT, NULL, DEFAULT_RESERVE_FDS},
  649. /* access log list is read only, no set func, no config var addr */
  650. {CONFIG_ACCESSLOG_LIST_ATTRIBUTE, NULL,
  651. NULL, 0, NULL,
  652. CONFIG_CHARRAY, (ConfigGetFunc)config_get_accesslog_list, NULL},
  653. {CONFIG_SVRTAB_ATTRIBUTE, config_set_srvtab,
  654. NULL, 0,
  655. (void**)&global_slapdFrontendConfig.srvtab,
  656. CONFIG_STRING, NULL, ""},
  657. {CONFIG_PW_EXP_ATTRIBUTE, config_set_pw_exp,
  658. NULL, 0,
  659. (void**)&global_slapdFrontendConfig.pw_policy.pw_exp,
  660. CONFIG_ON_OFF, NULL, &init_pw_exp},
  661. {CONFIG_ACCESSCONTROL_ATTRIBUTE, config_set_accesscontrol,
  662. NULL, 0,
  663. (void**)&global_slapdFrontendConfig.accesscontrol,
  664. CONFIG_ON_OFF, NULL, &init_accesscontrol},
  665. {CONFIG_AUDITLOG_LIST_ATTRIBUTE, NULL,
  666. NULL, 0, NULL,
  667. CONFIG_CHARRAY, (ConfigGetFunc)config_get_auditlog_list, NULL},
  668. {CONFIG_ACCESSLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  669. log_set_rotationtimeunit, SLAPD_ACCESS_LOG,
  670. (void**)&global_slapdFrontendConfig.accesslog_rotationunit,
  671. CONFIG_STRING, NULL, INIT_ACCESSLOG_ROTATIONUNIT},
  672. {CONFIG_PW_LOCKDURATION_ATTRIBUTE, config_set_pw_lockduration,
  673. NULL, 0,
  674. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockduration,
  675. CONFIG_LONG, NULL, DEFAULT_PW_LOCKDURATION},
  676. {CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  677. log_set_logsize, SLAPD_ACCESS_LOG,
  678. (void**)&global_slapdFrontendConfig.accesslog_maxlogsize,
  679. CONFIG_INT, NULL, DEFAULT_LOG_MAXLOGSIZE},
  680. {CONFIG_IDLETIMEOUT_ATTRIBUTE, config_set_idletimeout,
  681. NULL, 0,
  682. (void**)&global_slapdFrontendConfig.idletimeout,
  683. CONFIG_INT, NULL, DEFAULT_IDLE_TIMEOUT},
  684. {CONFIG_NAGLE_ATTRIBUTE, config_set_nagle,
  685. NULL, 0,
  686. (void**)&global_slapdFrontendConfig.nagle,
  687. CONFIG_ON_OFF, NULL, &init_nagle},
  688. {CONFIG_ERRORLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  689. log_set_mindiskspace, SLAPD_ERROR_LOG,
  690. (void**)&global_slapdFrontendConfig.errorlog_minfreespace,
  691. CONFIG_INT, NULL, DEFAULT_LOG_MINFREESPACE},
  692. {CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  693. log_set_logging, SLAPD_AUDIT_LOG,
  694. (void**)&global_slapdFrontendConfig.auditlog_logging_enabled,
  695. CONFIG_ON_OFF, NULL, &init_auditlog_logging_enabled},
  696. {CONFIG_AUDITLOG_LOGGING_HIDE_UNHASHED_PW, config_set_auditlog_unhashed_pw,
  697. NULL, 0,
  698. (void**)&global_slapdFrontendConfig.auditlog_logging_hide_unhashed_pw,
  699. CONFIG_ON_OFF, NULL, &init_auditlog_logging_hide_unhashed_pw},
  700. {CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
  701. NULL, 0,
  702. (void**)&global_slapdFrontendConfig.accesslogbuffering,
  703. CONFIG_ON_OFF, NULL, &init_accesslogbuffering},
  704. {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
  705. NULL, 0,
  706. (void**)&global_slapdFrontendConfig.csnlogging,
  707. CONFIG_ON_OFF, NULL, &init_csnlogging},
  708. {CONFIG_AUDITLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  709. log_set_expirationtimeunit, SLAPD_AUDIT_LOG,
  710. (void**)&global_slapdFrontendConfig.auditlog_exptimeunit,
  711. CONFIG_STRING_OR_UNKNOWN, NULL, INIT_AUDITLOG_EXPTIMEUNIT},
  712. {CONFIG_PW_SYNTAX_ATTRIBUTE, config_set_pw_syntax,
  713. NULL, 0,
  714. (void**)&global_slapdFrontendConfig.pw_policy.pw_syntax,
  715. CONFIG_ON_OFF, NULL, &init_pw_syntax},
  716. {CONFIG_LISTENHOST_ATTRIBUTE, config_set_listenhost,
  717. NULL, 0,
  718. (void**)&global_slapdFrontendConfig.listenhost,
  719. CONFIG_STRING, NULL, NULL/* NULL value is allowed */},
  720. {CONFIG_SNMP_INDEX_ATTRIBUTE, config_set_snmp_index,
  721. NULL, 0,
  722. (void**) &global_slapdFrontendConfig.snmp_index,
  723. CONFIG_INT, NULL, DEFAULT_SNMP_INDEX},
  724. {CONFIG_LDAPI_FILENAME_ATTRIBUTE, config_set_ldapi_filename,
  725. NULL, 0,
  726. (void**)&global_slapdFrontendConfig.ldapi_filename,
  727. CONFIG_STRING, NULL, SLAPD_LDAPI_DEFAULT_FILENAME},
  728. {CONFIG_LDAPI_SWITCH_ATTRIBUTE, config_set_ldapi_switch,
  729. NULL, 0,
  730. (void**)&global_slapdFrontendConfig.ldapi_switch,
  731. CONFIG_ON_OFF, NULL, &init_ldapi_switch},
  732. {CONFIG_LDAPI_BIND_SWITCH_ATTRIBUTE, config_set_ldapi_bind_switch,
  733. NULL, 0,
  734. (void**)&global_slapdFrontendConfig.ldapi_bind_switch,
  735. CONFIG_ON_OFF, NULL, &init_ldapi_bind_switch},
  736. {CONFIG_LDAPI_ROOT_DN_ATTRIBUTE, config_set_ldapi_root_dn,
  737. NULL, 0,
  738. (void**)&global_slapdFrontendConfig.ldapi_root_dn,
  739. CONFIG_STRING, NULL, DEFAULT_DIRECTORY_MANAGER},
  740. {CONFIG_LDAPI_MAP_ENTRIES_ATTRIBUTE, config_set_ldapi_map_entries,
  741. NULL, 0,
  742. (void**)&global_slapdFrontendConfig.ldapi_map_entries,
  743. CONFIG_ON_OFF, NULL, &init_ldapi_map_entries},
  744. {CONFIG_LDAPI_UIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_uidnumber_type,
  745. NULL, 0,
  746. (void**)&global_slapdFrontendConfig.ldapi_uidnumber_type,
  747. CONFIG_STRING, NULL, DEFAULT_UIDNUM_TYPE},
  748. {CONFIG_LDAPI_GIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_gidnumber_type,
  749. NULL, 0,
  750. (void**)&global_slapdFrontendConfig.ldapi_gidnumber_type,
  751. CONFIG_STRING, NULL, DEFAULT_GIDNUM_TYPE},
  752. {CONFIG_LDAPI_SEARCH_BASE_DN_ATTRIBUTE, config_set_ldapi_search_base_dn,
  753. NULL, 0,
  754. (void**)&global_slapdFrontendConfig.ldapi_search_base_dn,
  755. CONFIG_STRING, NULL, DEFAULT_LDAPI_SEARCH_BASE},
  756. #if defined(ENABLE_AUTO_DN_SUFFIX)
  757. {CONFIG_LDAPI_AUTO_DN_SUFFIX_ATTRIBUTE, config_set_ldapi_auto_dn_suffix,
  758. NULL, 0,
  759. (void**)&global_slapdFrontendConfig.ldapi_auto_dn_suffix,
  760. CONFIG_STRING, NULL, DEFAULT_LDAPI_AUTO_DN},
  761. #endif
  762. {CONFIG_ANON_LIMITS_DN_ATTRIBUTE, config_set_anon_limits_dn,
  763. NULL, 0,
  764. (void**)&global_slapdFrontendConfig.anon_limits_dn,
  765. CONFIG_STRING, NULL, ""},
  766. {CONFIG_SLAPI_COUNTER_ATTRIBUTE, config_set_slapi_counters,
  767. NULL, 0,
  768. (void**)&global_slapdFrontendConfig.slapi_counters,
  769. CONFIG_ON_OFF, (ConfigGetFunc)config_get_slapi_counters,
  770. &init_slapi_counters},
  771. {CONFIG_ACCESSLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  772. log_set_mindiskspace, SLAPD_ACCESS_LOG,
  773. (void**)&global_slapdFrontendConfig.accesslog_minfreespace,
  774. CONFIG_INT, NULL, DEFAULT_LOG_MINFREESPACE},
  775. {CONFIG_ERRORLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  776. log_set_numlogsperdir, SLAPD_ERROR_LOG,
  777. (void**)&global_slapdFrontendConfig.errorlog_maxnumlogs,
  778. CONFIG_INT, NULL, DEFAULT_LOG_MAXNUMLOGS},
  779. {CONFIG_SECURELISTENHOST_ATTRIBUTE, config_set_securelistenhost,
  780. NULL, 0,
  781. (void**)&global_slapdFrontendConfig.securelistenhost,
  782. CONFIG_STRING, NULL, NULL/* NULL value is allowed */},
  783. {CONFIG_AUDITLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  784. log_set_mindiskspace, SLAPD_AUDIT_LOG,
  785. (void**)&global_slapdFrontendConfig.auditlog_minfreespace,
  786. CONFIG_INT, NULL, DEFAULT_LOG_MINFREESPACE},
  787. {CONFIG_ROOTDN_ATTRIBUTE, config_set_rootdn,
  788. NULL, 0,
  789. (void**)&global_slapdFrontendConfig.rootdn,
  790. CONFIG_STRING, NULL, DEFAULT_DIRECTORY_MANAGER},
  791. {CONFIG_PW_MINAGE_ATTRIBUTE, config_set_pw_minage,
  792. NULL, 0,
  793. (void**)&global_slapdFrontendConfig.pw_policy.pw_minage,
  794. CONFIG_LONG, NULL, DEFAULT_PW_MINAGE},
  795. {CONFIG_AUDITFILE_ATTRIBUTE, config_set_auditlog,
  796. NULL, 0,
  797. (void**)&global_slapdFrontendConfig.auditlog,
  798. CONFIG_STRING_OR_EMPTY, NULL, NULL/* deletion is not allowed */},
  799. {CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, config_set_return_exact_case,
  800. NULL, 0,
  801. (void**)&global_slapdFrontendConfig.return_exact_case,
  802. CONFIG_ON_OFF, NULL, &init_return_exact_case},
  803. {CONFIG_RESULT_TWEAK_ATTRIBUTE, config_set_result_tweak,
  804. NULL, 0,
  805. (void**)&global_slapdFrontendConfig.result_tweak,
  806. CONFIG_ON_OFF, NULL, &init_result_tweak},
  807. {CONFIG_PLUGIN_BINDDN_TRACKING_ATTRIBUTE, config_set_plugin_tracking,
  808. NULL, 0,
  809. (void**)&global_slapdFrontendConfig.plugin_track,
  810. CONFIG_ON_OFF, NULL, &init_plugin_track},
  811. {CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, config_set_attrname_exceptions,
  812. NULL, 0,
  813. (void**)&global_slapdFrontendConfig.attrname_exceptions,
  814. CONFIG_ON_OFF, NULL, &init_attrname_exceptions},
  815. {CONFIG_MAXBERSIZE_ATTRIBUTE, config_set_maxbersize,
  816. NULL, 0,
  817. (void**)&global_slapdFrontendConfig.maxbersize,
  818. CONFIG_INT, NULL, DEFAULT_MAX_BERSIZE},
  819. {CONFIG_MAXSASLIOSIZE_ATTRIBUTE, config_set_maxsasliosize,
  820. NULL, 0,
  821. (void**)&global_slapdFrontendConfig.maxsasliosize,
  822. CONFIG_INT, NULL, DEFAULT_MAX_SASLIO_SIZE},
  823. {CONFIG_VERSIONSTRING_ATTRIBUTE, config_set_versionstring,
  824. NULL, 0,
  825. (void**)&global_slapdFrontendConfig.versionstring,
  826. CONFIG_STRING, NULL, SLAPD_VERSION_STR},
  827. {CONFIG_REFERRAL_MODE_ATTRIBUTE, config_set_referral_mode,
  828. NULL, 0,
  829. (void**)&global_slapdFrontendConfig.refer_url,
  830. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  831. #if !defined(_WIN32) && !defined(AIX)
  832. {CONFIG_MAXDESCRIPTORS_ATTRIBUTE, config_set_maxdescriptors,
  833. NULL, 0,
  834. (void**)&global_slapdFrontendConfig.maxdescriptors,
  835. CONFIG_INT, NULL, DEFAULT_MAXDESCRIPTORS},
  836. #endif
  837. {CONFIG_CONNTABLESIZE_ATTRIBUTE, config_set_conntablesize,
  838. NULL, 0,
  839. (void**)&global_slapdFrontendConfig.conntablesize,
  840. CONFIG_INT, NULL, NULL/* deletion is not allowed */},
  841. {CONFIG_SSLCLIENTAUTH_ATTRIBUTE, config_set_SSLclientAuth,
  842. NULL, 0,
  843. (void **)&global_slapdFrontendConfig.SSLclientAuth,
  844. CONFIG_SPECIAL_SSLCLIENTAUTH, NULL, DEFAULT_SSLCLIENTAPTH},
  845. {CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE, config_set_ssl_check_hostname,
  846. NULL, 0, NULL,
  847. CONFIG_ON_OFF, (ConfigGetFunc)config_get_ssl_check_hostname,
  848. &init_ssl_check_hostname},
  849. {CONFIG_CONFIG_ATTRIBUTE, 0,
  850. NULL, 0, (void**)SLAPD_CONFIG_DN,
  851. CONFIG_CONSTANT_STRING, NULL, NULL/* deletion is not allowed */},
  852. {CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
  853. NULL, 0, NULL,
  854. CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters,
  855. NULL/* deletion is not allowed */},
  856. /* instance dir; used by admin tasks */
  857. {CONFIG_INSTDIR_ATTRIBUTE, config_set_instancedir,
  858. NULL, 0,
  859. (void**)&global_slapdFrontendConfig.instancedir,
  860. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  861. /* parameterizing schema dir */
  862. {CONFIG_SCHEMADIR_ATTRIBUTE, config_set_schemadir,
  863. NULL, 0,
  864. (void**)&global_slapdFrontendConfig.schemadir,
  865. CONFIG_STRING, NULL, NULL/* deletion is not allowed */},
  866. /* parameterizing lock dir */
  867. {CONFIG_LOCKDIR_ATTRIBUTE, config_set_lockdir,
  868. NULL, 0,
  869. (void**)&global_slapdFrontendConfig.lockdir,
  870. CONFIG_STRING, (ConfigGetFunc)config_get_lockdir,
  871. NULL/* deletion is not allowed */},
  872. /* parameterizing tmp dir */
  873. {CONFIG_TMPDIR_ATTRIBUTE, config_set_tmpdir,
  874. NULL, 0,
  875. (void**)&global_slapdFrontendConfig.tmpdir,
  876. CONFIG_STRING, (ConfigGetFunc)config_get_tmpdir,
  877. NULL/* deletion is not allowed */},
  878. /* parameterizing cert dir */
  879. {CONFIG_CERTDIR_ATTRIBUTE, config_set_certdir,
  880. NULL, 0,
  881. (void**)&global_slapdFrontendConfig.certdir,
  882. CONFIG_STRING, (ConfigGetFunc)config_get_certdir,
  883. NULL/* deletion is not allowed */},
  884. /* parameterizing ldif dir */
  885. {CONFIG_LDIFDIR_ATTRIBUTE, config_set_ldifdir,
  886. NULL, 0,
  887. (void**)&global_slapdFrontendConfig.ldifdir,
  888. CONFIG_STRING, (ConfigGetFunc)config_get_ldifdir,
  889. NULL/* deletion is not allowed */},
  890. /* parameterizing bak dir */
  891. {CONFIG_BAKDIR_ATTRIBUTE, config_set_bakdir,
  892. NULL, 0,
  893. (void**)&global_slapdFrontendConfig.bakdir,
  894. CONFIG_STRING, (ConfigGetFunc)config_get_bakdir,
  895. NULL/* deletion is not allowed */},
  896. /* parameterizing sasl plugin path */
  897. {CONFIG_SASLPATH_ATTRIBUTE, config_set_saslpath,
  898. NULL, 0,
  899. (void**)&global_slapdFrontendConfig.saslpath,
  900. CONFIG_STRING, (ConfigGetFunc)config_get_saslpath,
  901. NULL/* deletion is not allowed */},
  902. /* parameterizing run dir */
  903. {CONFIG_RUNDIR_ATTRIBUTE, config_set_rundir,
  904. NULL, 0,
  905. (void**)&global_slapdFrontendConfig.rundir,
  906. CONFIG_STRING, (ConfigGetFunc)config_get_rundir,
  907. NULL/* deletion is not allowed */},
  908. {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
  909. NULL, 0,
  910. (void**)&global_slapdFrontendConfig.rewrite_rfc1274,
  911. CONFIG_ON_OFF, NULL, &init_rewrite_rfc1274},
  912. {CONFIG_OUTBOUND_LDAP_IO_TIMEOUT_ATTRIBUTE,
  913. config_set_outbound_ldap_io_timeout,
  914. NULL, 0,
  915. (void **)&global_slapdFrontendConfig.outbound_ldap_io_timeout,
  916. CONFIG_INT, NULL, DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT},
  917. {CONFIG_UNAUTH_BINDS_ATTRIBUTE, config_set_unauth_binds_switch,
  918. NULL, 0,
  919. (void**)&global_slapdFrontendConfig.allow_unauth_binds,
  920. CONFIG_ON_OFF, (ConfigGetFunc)config_get_unauth_binds_switch,
  921. &init_allow_unauth_binds},
  922. {CONFIG_REQUIRE_SECURE_BINDS_ATTRIBUTE, config_set_require_secure_binds,
  923. NULL, 0,
  924. (void**)&global_slapdFrontendConfig.require_secure_binds,
  925. CONFIG_ON_OFF, (ConfigGetFunc)config_get_require_secure_binds,
  926. &init_require_secure_binds},
  927. {CONFIG_ANON_ACCESS_ATTRIBUTE, config_set_anon_access_switch,
  928. NULL, 0,
  929. (void**)&global_slapdFrontendConfig.allow_anon_access,
  930. CONFIG_SPECIAL_ANON_ACCESS_SWITCH,
  931. (ConfigGetFunc)config_get_anon_access_switch,
  932. DEFAULT_ALLOW_ANON_ACCESS},
  933. {CONFIG_LOCALSSF_ATTRIBUTE, config_set_localssf,
  934. NULL, 0,
  935. (void**)&global_slapdFrontendConfig.localssf,
  936. CONFIG_INT, NULL, DEFAULT_LOCAL_SSF},
  937. {CONFIG_MINSSF_ATTRIBUTE, config_set_minssf,
  938. NULL, 0,
  939. (void**)&global_slapdFrontendConfig.minssf,
  940. CONFIG_INT, NULL, DEFAULT_MIN_SSF},
  941. {CONFIG_MINSSF_EXCLUDE_ROOTDSE, config_set_minssf_exclude_rootdse,
  942. NULL, 0,
  943. (void**)&global_slapdFrontendConfig.minssf_exclude_rootdse,
  944. CONFIG_ON_OFF, (ConfigGetFunc)config_get_minssf_exclude_rootdse,
  945. &init_minssf_exclude_rootdse},
  946. {CONFIG_FORCE_SASL_EXTERNAL_ATTRIBUTE, config_set_force_sasl_external,
  947. NULL, 0,
  948. (void**)&global_slapdFrontendConfig.force_sasl_external,
  949. CONFIG_ON_OFF, (ConfigGetFunc)config_get_force_sasl_external,
  950. &init_force_sasl_external},
  951. {CONFIG_ENTRYUSN_GLOBAL, config_set_entryusn_global,
  952. NULL, 0,
  953. (void**)&global_slapdFrontendConfig.entryusn_global,
  954. CONFIG_ON_OFF, (ConfigGetFunc)config_get_entryusn_global,
  955. &init_entryusn_global},
  956. {CONFIG_ENTRYUSN_IMPORT_INITVAL, config_set_entryusn_import_init,
  957. NULL, 0,
  958. (void**)&global_slapdFrontendConfig.entryusn_import_init,
  959. CONFIG_STRING, (ConfigGetFunc)config_get_entryusn_import_init,
  960. ENTRYUSN_IMPORT_INIT},
  961. {CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE, config_set_allowed_to_delete_attrs,
  962. NULL, 0,
  963. (void**)&global_slapdFrontendConfig.allowed_to_delete_attrs,
  964. CONFIG_STRING, (ConfigGetFunc)config_get_allowed_to_delete_attrs,
  965. DEFAULT_ALLOWED_TO_DELETE_ATTRS },
  966. {CONFIG_VALIDATE_CERT_ATTRIBUTE, config_set_validate_cert_switch,
  967. NULL, 0,
  968. (void**)&global_slapdFrontendConfig.validate_cert,
  969. CONFIG_SPECIAL_VALIDATE_CERT_SWITCH,
  970. (ConfigGetFunc)config_get_validate_cert_switch, DEFAULT_VALIDATE_CERT},
  971. {CONFIG_PAGEDSIZELIMIT_ATTRIBUTE, config_set_pagedsizelimit,
  972. NULL, 0,
  973. (void**)&global_slapdFrontendConfig.pagedsizelimit,
  974. CONFIG_INT, NULL, DEFAULT_PAGEDSIZELIMIT},
  975. {CONFIG_DEFAULT_NAMING_CONTEXT, config_set_default_naming_context,
  976. NULL, 0,
  977. (void**)&global_slapdFrontendConfig.default_naming_context,
  978. CONFIG_STRING, (ConfigGetFunc)config_get_default_naming_context, NULL},
  979. {CONFIG_DISK_MONITORING, config_set_disk_monitoring,
  980. NULL, 0,
  981. (void**)&global_slapdFrontendConfig.disk_monitoring,
  982. CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_monitoring,
  983. &init_disk_monitoring},
  984. {CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
  985. NULL, 0,
  986. (void**)&global_slapdFrontendConfig.disk_threshold,
  987. CONFIG_INT, (ConfigGetFunc)config_get_disk_threshold,
  988. DEFAULT_DISK_THRESHOLD},
  989. {CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
  990. NULL, 0,
  991. (void**)&global_slapdFrontendConfig.disk_grace_period,
  992. CONFIG_INT, (ConfigGetFunc)config_get_disk_grace_period,
  993. DEFAULT_DISK_GRACE_PERIOD},
  994. {CONFIG_DISK_LOGGING_CRITICAL, config_set_disk_logging_critical,
  995. NULL, 0,
  996. (void**)&global_slapdFrontendConfig.disk_logging_critical,
  997. CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical,
  998. &init_disk_logging_critical},
  999. {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
  1000. NULL, 0,
  1001. (void**)&global_slapdFrontendConfig.disk_preserve_logging,
  1002. CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging,
  1003. &init_disk_preserve_logging},
  1004. {CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
  1005. NULL, 0,
  1006. (void**)&global_slapdFrontendConfig.ndn_cache_enabled,
  1007. CONFIG_ON_OFF, (ConfigGetFunc)config_get_ndn_cache_enabled,
  1008. &init_ndn_cache_enabled},
  1009. {CONFIG_NDN_CACHE_SIZE, config_set_ndn_cache_max_size,
  1010. NULL, 0,
  1011. (void**)&global_slapdFrontendConfig.ndn_cache_max_size,
  1012. CONFIG_INT, (ConfigGetFunc)config_get_ndn_cache_size, DEFAULT_NDN_SIZE},
  1013. {CONFIG_ALLOWED_SASL_MECHS, config_set_allowed_sasl_mechs,
  1014. NULL, 0,
  1015. (void**)&global_slapdFrontendConfig.allowed_sasl_mechs,
  1016. CONFIG_STRING, (ConfigGetFunc)config_get_allowed_sasl_mechs, DEFAULT_ALLOWED_TO_DELETE_ATTRS},
  1017. {CONFIG_IGNORE_VATTRS, config_set_ignore_vattrs,
  1018. NULL, 0,
  1019. (void**)&global_slapdFrontendConfig.ignore_vattrs,
  1020. CONFIG_ON_OFF, (ConfigGetFunc)config_get_ignore_vattrs, DEFAULT_ALLOWED_TO_DELETE_ATTRS},
  1021. {CONFIG_UNHASHED_PW_SWITCH_ATTRIBUTE, config_set_unhashed_pw_switch,
  1022. NULL, 0,
  1023. (void**)&global_slapdFrontendConfig.unhashed_pw_switch,
  1024. CONFIG_SPECIAL_UNHASHED_PW_SWITCH,
  1025. (ConfigGetFunc)config_get_unhashed_pw_switch,
  1026. DEFAULT_UNHASHED_PW_SWITCH},
  1027. {CONFIG_SASL_MAXBUFSIZE, config_set_sasl_maxbufsize,
  1028. NULL, 0,
  1029. (void**)&global_slapdFrontendConfig.sasl_max_bufsize,
  1030. CONFIG_INT, (ConfigGetFunc)config_get_sasl_maxbufsize,
  1031. DEFAULT_SASL_MAXBUFSIZE},
  1032. {CONFIG_SEARCH_RETURN_ORIGINAL_TYPE, config_set_return_orig_type_switch,
  1033. NULL, 0,
  1034. (void**)&global_slapdFrontendConfig.return_orig_type,
  1035. CONFIG_ON_OFF, (ConfigGetFunc)config_get_return_orig_type_switch, &init_return_orig_type},
  1036. {CONFIG_ENABLE_TURBO_MODE, config_set_enable_turbo_mode,
  1037. NULL, 0,
  1038. (void**)&global_slapdFrontendConfig.enable_turbo_mode,
  1039. CONFIG_ON_OFF, (ConfigGetFunc)config_get_enable_turbo_mode, &init_enable_turbo_mode},
  1040. {CONFIG_CONNECTION_BUFFER, config_set_connection_buffer,
  1041. NULL, 0,
  1042. (void**)&global_slapdFrontendConfig.connection_buffer,
  1043. CONFIG_INT, (ConfigGetFunc)config_get_connection_buffer, &init_connection_buffer},
  1044. {CONFIG_CONNECTION_NOCANON, config_set_connection_nocanon,
  1045. NULL, 0,
  1046. (void**)&global_slapdFrontendConfig.connection_nocanon,
  1047. CONFIG_ON_OFF, (ConfigGetFunc)config_get_connection_nocanon, &init_connection_nocanon}
  1048. #ifdef MEMPOOL_EXPERIMENTAL
  1049. ,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
  1050. NULL, 0,
  1051. (void**)&global_slapdFrontendConfig.mempool_switch,
  1052. CONFIG_ON_OFF, (ConfigGetFunc)config_get_mempool_switch,
  1053. &init_mempool_switch},
  1054. {CONFIG_MEMPOOL_MAXFREELIST_ATTRIBUTE, config_set_mempool_maxfreelist,
  1055. NULL, 0,
  1056. (void**)&global_slapdFrontendConfig.mempool_maxfreelist,
  1057. CONFIG_INT, (ConfigGetFunc)config_get_mempool_maxfreelist,
  1058. DEFAULT_MEMPOOL_MAXFREELIST}
  1059. #endif /* MEMPOOL_EXPERIMENTAL */
  1060. };
  1061. /*
  1062. * hashNocaseString - used for case insensitive hash lookups
  1063. */
  1064. PLHashNumber
  1065. hashNocaseString(const void *key)
  1066. {
  1067. PLHashNumber h = 0;
  1068. const unsigned char *s;
  1069. for (s = key; *s; s++)
  1070. h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
  1071. return h;
  1072. }
  1073. /*
  1074. * hashNocaseCompare - used for case insensitive hash key comparisons
  1075. */
  1076. PRIntn
  1077. hashNocaseCompare(const void *v1, const void *v2)
  1078. {
  1079. return (strcasecmp((char *)v1, (char *)v2) == 0);
  1080. }
  1081. static PLHashTable *confighash = 0;
  1082. static void
  1083. init_config_get_and_set()
  1084. {
  1085. if (!confighash) {
  1086. int ii = 0;
  1087. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  1088. confighash = PL_NewHashTable(tablesize+1, hashNocaseString,
  1089. hashNocaseCompare,
  1090. PL_CompareValues, 0, 0);
  1091. for (ii = 0; ii < tablesize; ++ii) {
  1092. if (PL_HashTableLookup(confighash, ConfigList[ii].attr_name))
  1093. printf("error: %s is already in the list\n",
  1094. ConfigList[ii].attr_name);
  1095. if (!PL_HashTableAdd(confighash, ConfigList[ii].attr_name, &ConfigList[ii]))
  1096. printf("error: could not add %s to the list\n",
  1097. ConfigList[ii].attr_name);
  1098. }
  1099. }
  1100. }
  1101. #if 0
  1102. #define GOLDEN_RATIO 0x9E3779B9U
  1103. PR_IMPLEMENT(PLHashEntry **)
  1104. PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
  1105. {
  1106. PLHashEntry *he, **hep, **hep0;
  1107. PLHashNumber h;
  1108. #ifdef HASHMETER
  1109. ht->nlookups++;
  1110. #endif
  1111. h = keyHash * GOLDEN_RATIO;
  1112. h >>= ht->shift;
  1113. hep = hep0 = &ht->buckets[h];
  1114. while ((he = *hep) != 0) {
  1115. if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
  1116. /* Move to front of chain if not already there */
  1117. if (hep != hep0) {
  1118. *hep = he->next;
  1119. he->next = *hep0;
  1120. *hep0 = he;
  1121. }
  1122. return hep0;
  1123. }
  1124. hep = &he->next;
  1125. #ifdef HASHMETER
  1126. ht->nsteps++;
  1127. #endif
  1128. }
  1129. return hep;
  1130. }
  1131. static void
  1132. debugHashTable(const char *key)
  1133. {
  1134. int ii = 0;
  1135. PLHashEntry **hep = PL_HashTableRawLookup(confighash, hashNocaseString(key),
  1136. key);
  1137. if (!hep || !*hep)
  1138. printf("raw lookup failed for %s\n", key);
  1139. else if (hep && *hep)
  1140. printf("raw lookup found %s -> %ul %s\n", key, (*hep)->keyHash, (*hep)->key);
  1141. printf("hash table has %d entries\n", confighash->nentries);
  1142. for (ii = 0; ii < confighash->nentries; ++ii)
  1143. {
  1144. PLHashEntry *he = confighash->buckets[ii];
  1145. if (!he)
  1146. printf("hash table entry %d is null\n", ii);
  1147. else {
  1148. printf("hash bucket %d:\n", ii);
  1149. while (he) {
  1150. int keys = !hashNocaseCompare(key, he->key);
  1151. int hash = (hashNocaseString(key) == he->keyHash);
  1152. printf("\thashval = %ul key = %s\n", he->keyHash, he->key);
  1153. if (keys && hash) {
  1154. printf("\t\tFOUND\n");
  1155. } else if (keys) {
  1156. printf("\t\tkeys match but hash vals do not\n");
  1157. } else if (hash) {
  1158. printf("\t\thash match but keys do not\n");
  1159. }
  1160. he = he->next;
  1161. }
  1162. }
  1163. }
  1164. }
  1165. #endif
  1166. static void
  1167. bervalarray_free(struct berval **bvec)
  1168. {
  1169. int ii = 0;
  1170. for(ii = 0; bvec && bvec[ii]; ++ii) {
  1171. slapi_ch_free((void **)&bvec[ii]->bv_val);
  1172. slapi_ch_free((void **)&bvec[ii]);
  1173. }
  1174. slapi_ch_free((void**)&bvec);
  1175. }
  1176. static struct berval **
  1177. strarray2bervalarray(const char **strarray)
  1178. {
  1179. int ii = 0;
  1180. struct berval **newlist = 0;
  1181. /* first, count the number of items in the list */
  1182. for (ii = 0; strarray && strarray[ii]; ++ii);
  1183. /* if no items, return null */
  1184. if (!ii)
  1185. return newlist;
  1186. /* allocate the list */
  1187. newlist = (struct berval **)slapi_ch_malloc((ii+1) * sizeof(struct berval *));
  1188. newlist[ii] = 0;
  1189. for (; ii; --ii) {
  1190. newlist[ii-1] = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
  1191. newlist[ii-1]->bv_val = slapi_ch_strdup(strarray[ii-1]);
  1192. newlist[ii-1]->bv_len = strlen(strarray[ii-1]);
  1193. }
  1194. return newlist;
  1195. }
  1196. /*
  1197. * counter for active threads
  1198. */
  1199. static PRInt32 active_threads = 0;
  1200. void
  1201. g_incr_active_threadcnt()
  1202. {
  1203. PR_AtomicIncrement(&active_threads);
  1204. }
  1205. void
  1206. g_decr_active_threadcnt()
  1207. {
  1208. PR_AtomicDecrement(&active_threads);
  1209. }
  1210. int
  1211. g_get_active_threadcnt()
  1212. {
  1213. return (int)active_threads;
  1214. }
  1215. /*
  1216. ** Setting this flag forces the server to shutdown.
  1217. */
  1218. static int slapd_shutdown;
  1219. void g_set_shutdown( int reason )
  1220. {
  1221. slapd_shutdown = reason;
  1222. }
  1223. int g_get_shutdown()
  1224. {
  1225. return slapd_shutdown;
  1226. }
  1227. int slapi_is_shutting_down()
  1228. {
  1229. return slapd_shutdown;
  1230. }
  1231. static int cmd_shutdown;
  1232. void c_set_shutdown()
  1233. {
  1234. cmd_shutdown = SLAPI_SHUTDOWN_SIGNAL;
  1235. }
  1236. int c_get_shutdown()
  1237. {
  1238. return cmd_shutdown;
  1239. }
  1240. slapdFrontendConfig_t *
  1241. getFrontendConfig()
  1242. {
  1243. return &global_slapdFrontendConfig;
  1244. }
  1245. /*
  1246. * FrontendConfig_init:
  1247. * Put all default values for config stuff here.
  1248. * If there's no default value, the value will be NULL if it's not set in dse.ldif
  1249. */
  1250. void
  1251. FrontendConfig_init () {
  1252. slapdFrontendConfig_t *cfg = getFrontendConfig();
  1253. #if SLAPI_CFG_USE_RWLOCK == 1
  1254. /* initialize the read/write configuration lock */
  1255. if ( (cfg->cfg_rwlock = slapi_new_rwlock()) == NULL ) {
  1256. LDAPDebug ( LDAP_DEBUG_ANY, "FrontendConfig_init: "
  1257. "failed to initialize cfg_rwlock. Exiting now.",0,0,0);
  1258. exit(-1);
  1259. }
  1260. #else
  1261. if ((cfg->cfg_lock = PR_NewLock()) == NULL){
  1262. LDAPDebug(LDAP_DEBUG_ANY, "FrontendConfig_init: "
  1263. "failed to initialize cfg_lock. Exiting now.",0,0,0);
  1264. exit(-1);
  1265. }
  1266. #endif
  1267. cfg->port = LDAP_PORT;
  1268. cfg->secureport = LDAPS_PORT;
  1269. cfg->ldapi_filename = slapi_ch_strdup(SLAPD_LDAPI_DEFAULT_FILENAME);
  1270. init_ldapi_switch = cfg->ldapi_switch = LDAP_OFF;
  1271. init_ldapi_bind_switch = cfg->ldapi_bind_switch = LDAP_OFF;
  1272. cfg->ldapi_root_dn = slapi_ch_strdup(DEFAULT_DIRECTORY_MANAGER);
  1273. init_ldapi_map_entries = cfg->ldapi_map_entries = LDAP_OFF;
  1274. cfg->ldapi_uidnumber_type = slapi_ch_strdup(DEFAULT_UIDNUM_TYPE);
  1275. cfg->ldapi_gidnumber_type = slapi_ch_strdup(DEFAULT_GIDNUM_TYPE);
  1276. /* These DNs are no need to be normalized. */
  1277. cfg->ldapi_search_base_dn = slapi_ch_strdup(DEFAULT_LDAPI_SEARCH_BASE);
  1278. #if defined(ENABLE_AUTO_DN_SUFFIX)
  1279. cfg->ldapi_auto_dn_suffix = slapi_ch_strdup(DEFAULT_LDAPI_AUTO_DN);
  1280. #endif
  1281. init_allow_unauth_binds = cfg->allow_unauth_binds = LDAP_OFF;
  1282. init_require_secure_binds = cfg->require_secure_binds = LDAP_OFF;
  1283. cfg->allow_anon_access = SLAPD_ANON_ACCESS_ON;
  1284. init_slapi_counters = cfg->slapi_counters = LDAP_ON;
  1285. cfg->threadnumber = SLAPD_DEFAULT_MAX_THREADS;
  1286. cfg->maxthreadsperconn = SLAPD_DEFAULT_MAX_THREADS_PER_CONN;
  1287. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  1288. cfg->idletimeout = SLAPD_DEFAULT_IDLE_TIMEOUT;
  1289. cfg->ioblocktimeout = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  1290. cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
  1291. cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
  1292. cfg->maxsasliosize = SLAPD_DEFAULT_MAX_SASLIO_SIZE;
  1293. cfg->localssf = SLAPD_DEFAULT_LOCAL_SSF;
  1294. cfg->minssf = SLAPD_DEFAULT_MIN_SSF;
  1295. /* minssf is applied to rootdse, by default */
  1296. init_minssf_exclude_rootdse = cfg->minssf_exclude_rootdse = LDAP_OFF;
  1297. cfg->validate_cert = SLAPD_VALIDATE_CERT_WARN;
  1298. #ifdef _WIN32
  1299. cfg->conntablesize = SLAPD_DEFAULT_CONNTABLESIZE;
  1300. #else
  1301. #ifdef USE_SYSCONF
  1302. cfg->conntablesize = sysconf( _SC_OPEN_MAX );
  1303. #else /* USE_SYSCONF */
  1304. cfg->conntablesize = getdtablesize();
  1305. #endif /* USE_SYSCONF */
  1306. #endif /* _WIN32 */
  1307. init_accesscontrol = cfg->accesscontrol = LDAP_ON;
  1308. #if defined(LINUX)
  1309. /* On Linux, by default, we use TCP_CORK so we must enable nagle */
  1310. init_nagle = cfg->nagle = LDAP_ON;
  1311. #else
  1312. init_nagle = cfg->nagle = LDAP_OFF;
  1313. #endif
  1314. init_security = cfg->security = LDAP_OFF;
  1315. init_ssl_check_hostname = cfg->ssl_check_hostname = LDAP_ON;
  1316. init_return_exact_case = cfg->return_exact_case = LDAP_ON;
  1317. init_result_tweak = cfg->result_tweak = LDAP_OFF;
  1318. init_attrname_exceptions = cfg->attrname_exceptions = LDAP_OFF;
  1319. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  1320. cfg->useroc = slapi_ch_strdup ( "" );
  1321. cfg->userat = slapi_ch_strdup ( "" );
  1322. /* kexcoff: should not be initialized by default here
  1323. cfg->rootpwstoragescheme = pw_name2scheme( SALTED_SHA1_SCHEME_NAME );
  1324. cfg->pw_storagescheme = pw_name2scheme( SALTED_SHA1_SCHEME_NAME );
  1325. */
  1326. cfg->slapd_type = 0;
  1327. cfg->versionstring = SLAPD_VERSION_STR;
  1328. cfg->sizelimit = SLAPD_DEFAULT_SIZELIMIT;
  1329. cfg->pagedsizelimit = 0;
  1330. cfg->timelimit = SLAPD_DEFAULT_TIMELIMIT;
  1331. cfg->anon_limits_dn = slapi_ch_strdup("");
  1332. init_schemacheck = cfg->schemacheck = LDAP_ON;
  1333. init_schemamod = cfg->schemamod = LDAP_ON;
  1334. init_syntaxcheck = cfg->syntaxcheck = LDAP_OFF;
  1335. init_plugin_track = cfg->plugin_track = LDAP_OFF;
  1336. init_syntaxlogging = cfg->syntaxlogging = LDAP_OFF;
  1337. init_dn_validate_strict = cfg->dn_validate_strict = LDAP_OFF;
  1338. init_ds4_compatible_schema = cfg->ds4_compatible_schema = LDAP_OFF;
  1339. init_enquote_sup_oc = cfg->enquote_sup_oc = LDAP_OFF;
  1340. init_lastmod = cfg->lastmod = LDAP_ON;
  1341. init_rewrite_rfc1274 = cfg->rewrite_rfc1274 = LDAP_OFF;
  1342. cfg->schemareplace = slapi_ch_strdup( CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY );
  1343. init_schema_ignore_trailing_spaces = cfg->schema_ignore_trailing_spaces =
  1344. SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES;
  1345. /* do not force sasl external by default -
  1346. * let clients abide by the LDAP standards and send us a SASL/EXTERNAL bind
  1347. * if that's what they want to do */
  1348. init_force_sasl_external = cfg->force_sasl_external = LDAP_OFF;
  1349. init_readonly = cfg->readonly = LDAP_OFF;
  1350. init_pwpolicy_local = cfg->pwpolicy_local = LDAP_OFF;
  1351. init_pw_change = cfg->pw_policy.pw_change = LDAP_ON;
  1352. init_pw_must_change = cfg->pw_policy.pw_must_change = LDAP_OFF;
  1353. init_pw_syntax = cfg->pw_policy.pw_syntax = LDAP_OFF;
  1354. init_pw_exp = cfg->pw_policy.pw_exp = LDAP_OFF;
  1355. cfg->pw_policy.pw_minlength = 8;
  1356. cfg->pw_policy.pw_mindigits = 0;
  1357. cfg->pw_policy.pw_minalphas = 0;
  1358. cfg->pw_policy.pw_minuppers = 0;
  1359. cfg->pw_policy.pw_minlowers = 0;
  1360. cfg->pw_policy.pw_minspecials = 0;
  1361. cfg->pw_policy.pw_min8bit = 0;
  1362. cfg->pw_policy.pw_maxrepeats = 0;
  1363. cfg->pw_policy.pw_mincategories = 3;
  1364. cfg->pw_policy.pw_mintokenlength = 3;
  1365. cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
  1366. cfg->pw_policy.pw_minage = 0;
  1367. cfg->pw_policy.pw_warning = 86400; /* 1 day */
  1368. init_pw_history = cfg->pw_policy.pw_history = LDAP_OFF;
  1369. cfg->pw_policy.pw_inhistory = 6;
  1370. init_pw_lockout = cfg->pw_policy.pw_lockout = LDAP_OFF;
  1371. cfg->pw_policy.pw_maxfailure = 3;
  1372. init_pw_unlock = cfg->pw_policy.pw_unlock = LDAP_ON;
  1373. cfg->pw_policy.pw_lockduration = 3600; /* 60 minutes */
  1374. cfg->pw_policy.pw_resetfailurecount = 600; /* 10 minutes */
  1375. cfg->pw_policy.pw_gracelimit = 0;
  1376. cfg->pw_policy.pw_admin = NULL;
  1377. cfg->pw_policy.pw_admin_user = NULL;
  1378. init_pw_is_legacy = cfg->pw_policy.pw_is_legacy = LDAP_ON;
  1379. init_pw_track_update_time = cfg->pw_policy.pw_track_update_time = LDAP_OFF;
  1380. init_pw_is_global_policy = cfg->pw_is_global_policy = LDAP_OFF;
  1381. init_accesslog_logging_enabled = cfg->accesslog_logging_enabled = LDAP_ON;
  1382. cfg->accesslog_mode = slapi_ch_strdup(INIT_ACCESSLOG_MODE);
  1383. cfg->accesslog_maxnumlogs = 10;
  1384. cfg->accesslog_maxlogsize = 100;
  1385. cfg->accesslog_rotationtime = 1;
  1386. cfg->accesslog_rotationunit = slapi_ch_strdup(INIT_ACCESSLOG_ROTATIONUNIT);
  1387. init_accesslog_rotationsync_enabled =
  1388. cfg->accesslog_rotationsync_enabled = LDAP_OFF;
  1389. cfg->accesslog_rotationsynchour = 0;
  1390. cfg->accesslog_rotationsyncmin = 0;
  1391. cfg->accesslog_maxdiskspace = 500;
  1392. cfg->accesslog_minfreespace = 5;
  1393. cfg->accesslog_exptime = 1;
  1394. cfg->accesslog_exptimeunit = slapi_ch_strdup(INIT_ACCESSLOG_EXPTIMEUNIT);
  1395. cfg->accessloglevel = 256;
  1396. init_accesslogbuffering = cfg->accesslogbuffering = LDAP_ON;
  1397. init_csnlogging = cfg->csnlogging = LDAP_ON;
  1398. init_errorlog_logging_enabled = cfg->errorlog_logging_enabled = LDAP_ON;
  1399. cfg->errorlog_mode = slapi_ch_strdup(INIT_ERRORLOG_MODE);
  1400. cfg->errorlog_maxnumlogs = 1;
  1401. cfg->errorlog_maxlogsize = 100;
  1402. cfg->errorlog_rotationtime = 1;
  1403. cfg->errorlog_rotationunit = slapi_ch_strdup (INIT_ERRORLOG_ROTATIONUNIT);
  1404. init_errorlog_rotationsync_enabled =
  1405. cfg->errorlog_rotationsync_enabled = LDAP_OFF;
  1406. cfg->errorlog_rotationsynchour = 0;
  1407. cfg->errorlog_rotationsyncmin = 0;
  1408. cfg->errorlog_maxdiskspace = 100;
  1409. cfg->errorlog_minfreespace = 5;
  1410. cfg->errorlog_exptime = 1;
  1411. cfg->errorlog_exptimeunit = slapi_ch_strdup(INIT_ERRORLOG_EXPTIMEUNIT);
  1412. cfg->errorloglevel = 0;
  1413. init_auditlog_logging_enabled = cfg->auditlog_logging_enabled = LDAP_OFF;
  1414. cfg->auditlog_mode = slapi_ch_strdup(INIT_AUDITLOG_MODE);
  1415. cfg->auditlog_maxnumlogs = 1;
  1416. cfg->auditlog_maxlogsize = 100;
  1417. cfg->auditlog_rotationtime = 1;
  1418. cfg->auditlog_rotationunit = slapi_ch_strdup(INIT_AUDITLOG_ROTATIONUNIT);
  1419. init_auditlog_rotationsync_enabled =
  1420. cfg->auditlog_rotationsync_enabled = LDAP_OFF;
  1421. cfg->auditlog_rotationsynchour = 0;
  1422. cfg->auditlog_rotationsyncmin = 0;
  1423. cfg->auditlog_maxdiskspace = 100;
  1424. cfg->auditlog_minfreespace = 5;
  1425. cfg->auditlog_exptime = 1;
  1426. cfg->auditlog_exptimeunit = slapi_ch_strdup(INIT_AUDITLOG_EXPTIMEUNIT);
  1427. init_auditlog_logging_hide_unhashed_pw =
  1428. cfg->auditlog_logging_hide_unhashed_pw = LDAP_ON;
  1429. init_entryusn_global = cfg->entryusn_global = LDAP_OFF;
  1430. cfg->entryusn_import_init = slapi_ch_strdup(ENTRYUSN_IMPORT_INIT);
  1431. cfg->allowed_to_delete_attrs = slapi_ch_strdup("nsslapd-listenhost nsslapd-securelistenhost nsslapd-defaultnamingcontext");
  1432. cfg->default_naming_context = NULL; /* store normalized dn */
  1433. cfg->allowed_sasl_mechs = NULL;
  1434. init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF;
  1435. cfg->disk_threshold = 2097152; /* 2 mb */
  1436. cfg->disk_grace_period = 60; /* 1 hour */
  1437. init_disk_preserve_logging = cfg->disk_preserve_logging = LDAP_OFF;
  1438. init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
  1439. init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
  1440. cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
  1441. init_sasl_mapping_fallback = cfg->sasl_mapping_fallback = LDAP_OFF;
  1442. cfg->ignore_vattrs = LDAP_OFF;
  1443. cfg->sasl_max_bufsize = SLAPD_DEFAULT_SASL_MAXBUFSIZE;
  1444. cfg->unhashed_pw_switch = SLAPD_UNHASHED_PW_ON;
  1445. init_return_orig_type = cfg->return_orig_type = LDAP_OFF;
  1446. init_enable_turbo_mode = cfg->enable_turbo_mode = LDAP_ON;
  1447. init_connection_buffer = cfg->connection_buffer = CONNECTION_BUFFER_ON;
  1448. init_connection_nocanon = cfg->connection_nocanon = LDAP_ON;
  1449. #ifdef MEMPOOL_EXPERIMENTAL
  1450. init_mempool_switch = cfg->mempool_switch = LDAP_ON;
  1451. cfg->mempool_maxfreelist = 1024;
  1452. cfg->system_page_size = sysconf(_SC_PAGE_SIZE); /* not to get every time; no set, get only */
  1453. {
  1454. long sc_size = cfg->system_page_size;
  1455. cfg->system_page_bits = 0;
  1456. while ((sc_size >>= 1) > 0) {
  1457. cfg->system_page_bits++; /* to calculate once; no set, get only */
  1458. }
  1459. }
  1460. #endif /* MEMPOOL_EXPERIMENTAL */
  1461. init_config_get_and_set();
  1462. }
  1463. int
  1464. g_get_global_lastmod()
  1465. {
  1466. return config_get_lastmod();
  1467. }
  1468. int g_get_slapd_security_on(){
  1469. return config_get_security();
  1470. }
  1471. #ifdef _WIN32
  1472. void libldap_init_debug_level(int *val_ptr)
  1473. {
  1474. module_ldap_debug = val_ptr;
  1475. }
  1476. #endif
  1477. struct snmp_vars_t global_snmp_vars;
  1478. struct snmp_vars_t * g_get_global_snmp_vars(){
  1479. return &global_snmp_vars;
  1480. }
  1481. static slapdEntryPoints *sep = NULL;
  1482. void
  1483. set_dll_entry_points( slapdEntryPoints *p )
  1484. {
  1485. if ( NULL == sep )
  1486. {
  1487. sep = p;
  1488. }
  1489. }
  1490. int
  1491. get_entry_point( int ep_name, caddr_t *ep_addr )
  1492. {
  1493. int rc = 0;
  1494. if(sep!=NULL)
  1495. {
  1496. switch ( ep_name ) {
  1497. case ENTRY_POINT_PS_WAKEUP_ALL:
  1498. *ep_addr = sep->sep_ps_wakeup_all;
  1499. break;
  1500. case ENTRY_POINT_PS_SERVICE:
  1501. *ep_addr = sep->sep_ps_service;
  1502. break;
  1503. case ENTRY_POINT_DISCONNECT_SERVER:
  1504. *ep_addr = sep->sep_disconnect_server;
  1505. break;
  1506. case ENTRY_POINT_SLAPD_SSL_INIT:
  1507. *ep_addr = sep->sep_slapd_ssl_init;
  1508. break;
  1509. case ENTRY_POINT_SLAPD_SSL_INIT2:
  1510. *ep_addr = sep->sep_slapd_ssl_init2;
  1511. break;
  1512. default:
  1513. rc = -1;
  1514. }
  1515. }
  1516. else
  1517. {
  1518. rc= -1;
  1519. }
  1520. return rc;
  1521. }
  1522. int
  1523. config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf, int apply)
  1524. {
  1525. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1526. int retVal = LDAP_SUCCESS;
  1527. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->auditlog_logging_hide_unhashed_pw),
  1528. errorbuf, apply);
  1529. if(strcasecmp(value,"on") == 0){
  1530. auditlog_hide_unhashed_pw();
  1531. } else {
  1532. auditlog_expose_unhashed_pw();
  1533. }
  1534. return retVal;
  1535. }
  1536. /*
  1537. * Utility function called by many of the config_set_XXX() functions.
  1538. * Returns a non-zero value if 'value' is NULL and zero if not.
  1539. * Also constructs an error message in 'errorbuf' if value is NULL.
  1540. * If or_zero_length is non-zero, zero length values are treated as
  1541. * equivalent to NULL (i.e., they will cause a non-zero value to be
  1542. * returned by this function).
  1543. */
  1544. static int
  1545. config_value_is_null( const char *attrname, const char *value, char *errorbuf,
  1546. int or_zero_length )
  1547. {
  1548. if ( NULL == value || ( or_zero_length && *value == '\0' )) {
  1549. PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1550. "%s: deleting the value is not allowed.", attrname );
  1551. return 1;
  1552. }
  1553. return 0;
  1554. }
  1555. int
  1556. config_set_ignore_vattrs (const char *attrname, char *value, char *errorbuf, int apply )
  1557. {
  1558. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1559. int retVal = LDAP_SUCCESS;
  1560. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->ignore_vattrs), errorbuf, apply);
  1561. return retVal;
  1562. }
  1563. int
  1564. config_set_sasl_mapping_fallback (const char *attrname, char *value, char *errorbuf, int apply )
  1565. {
  1566. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1567. int retVal = LDAP_SUCCESS;
  1568. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->sasl_mapping_fallback), errorbuf, apply);
  1569. return retVal;
  1570. }
  1571. int
  1572. config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int apply )
  1573. {
  1574. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1575. int retVal = LDAP_SUCCESS;
  1576. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_monitoring),
  1577. errorbuf, apply);
  1578. return retVal;
  1579. }
  1580. int
  1581. config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int apply )
  1582. {
  1583. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1584. int retVal = LDAP_SUCCESS;
  1585. long threshold = 0;
  1586. char *endp = NULL;
  1587. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1588. return LDAP_OPERATIONS_ERROR;
  1589. }
  1590. threshold = strtol(value, &endp, 10);
  1591. if ( *endp != '\0' || threshold < 2048 ) {
  1592. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, threshold must be greater than 2048 and less then %ld",
  1593. attrname, value, LONG_MAX );
  1594. retVal = LDAP_OPERATIONS_ERROR;
  1595. return retVal;
  1596. }
  1597. if (apply) {
  1598. CFG_LOCK_WRITE(slapdFrontendConfig);
  1599. slapdFrontendConfig->disk_threshold = threshold;
  1600. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1601. }
  1602. return retVal;
  1603. }
  1604. int
  1605. config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int apply )
  1606. {
  1607. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1608. int retVal = LDAP_SUCCESS;
  1609. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_preserve_logging),
  1610. errorbuf, apply);
  1611. return retVal;
  1612. }
  1613. int
  1614. config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int apply )
  1615. {
  1616. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1617. int retVal = LDAP_SUCCESS;
  1618. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->disk_logging_critical),
  1619. errorbuf, apply);
  1620. return retVal;
  1621. }
  1622. int
  1623. config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int apply )
  1624. {
  1625. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1626. int retVal = LDAP_SUCCESS;
  1627. int period = 0;
  1628. char *endp = NULL;
  1629. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1630. return LDAP_OPERATIONS_ERROR;
  1631. }
  1632. period = strtol(value, &endp, 10);
  1633. if ( *endp != '\0' || period < 1 ) {
  1634. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, grace period must be at least 1 minute",
  1635. attrname, value);
  1636. retVal = LDAP_OPERATIONS_ERROR;
  1637. return retVal;
  1638. }
  1639. if (apply) {
  1640. CFG_LOCK_WRITE(slapdFrontendConfig);
  1641. slapdFrontendConfig->disk_grace_period = period;
  1642. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1643. }
  1644. return retVal;
  1645. }
  1646. int
  1647. config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int apply )
  1648. {
  1649. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1650. int retVal;
  1651. retVal = config_set_onoff ( attrname, value, &(slapdFrontendConfig->ndn_cache_enabled), errorbuf, apply);
  1652. return retVal;
  1653. }
  1654. int
  1655. config_set_ndn_cache_max_size(const char *attrname, char *value, char *errorbuf, int apply )
  1656. {
  1657. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1658. int retVal = LDAP_SUCCESS;
  1659. long size;
  1660. size = atol(value);
  1661. if(size < 0){
  1662. size = 0; /* same as -1 */
  1663. }
  1664. if(size > 0 && size < 1024000){
  1665. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "ndn_cache_max_size too low(%d), changing to "
  1666. "%d bytes.\n",(int)size, NDN_DEFAULT_SIZE);
  1667. size = NDN_DEFAULT_SIZE;
  1668. }
  1669. if(apply){
  1670. CFG_LOCK_WRITE(slapdFrontendConfig);
  1671. slapdFrontendConfig->ndn_cache_max_size = size;
  1672. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1673. }
  1674. return retVal;
  1675. }
  1676. int
  1677. config_set_sasl_maxbufsize(const char *attrname, char *value, char *errorbuf, int apply )
  1678. {
  1679. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1680. int retVal = LDAP_SUCCESS;
  1681. int default_size = atoi(DEFAULT_SASL_MAXBUFSIZE);
  1682. int size;
  1683. size = atoi(value);
  1684. if(size < default_size){
  1685. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "nsslapd-sasl-max-buffer-size is too low (%d), "
  1686. "setting to default value (%d).\n",size, default_size);
  1687. size = default_size;
  1688. }
  1689. if(apply){
  1690. CFG_LOCK_WRITE(slapdFrontendConfig);
  1691. slapdFrontendConfig->sasl_max_bufsize = size;
  1692. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1693. }
  1694. return retVal;
  1695. }
  1696. int
  1697. config_set_return_orig_type_switch(const char *attrname, char *value, char *errorbuf, int apply)
  1698. {
  1699. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1700. int retVal;
  1701. retVal = config_set_onoff(attrname, value, &(slapdFrontendConfig->return_orig_type), errorbuf, apply);
  1702. return retVal;
  1703. }
  1704. int
  1705. config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
  1706. long nPort;
  1707. char *endp = NULL;
  1708. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1709. int retVal = LDAP_SUCCESS;
  1710. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  1711. return LDAP_OPERATIONS_ERROR;
  1712. }
  1713. errno = 0;
  1714. nPort = strtol(port, &endp, 10);
  1715. if ( *endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort < 0 ) {
  1716. retVal = LDAP_OPERATIONS_ERROR;
  1717. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1718. "%s: \"%s\" is invalid, ports must range from 0 to %d",
  1719. attrname, port, LDAP_PORT_MAX );
  1720. return retVal;
  1721. }
  1722. if ( nPort == 0 ) {
  1723. LDAPDebug( LDAP_DEBUG_ANY,
  1724. "Information: Non-Secure Port Disabled\n", 0, 0, 0 );
  1725. }
  1726. if ( apply ) {
  1727. CFG_LOCK_WRITE(slapdFrontendConfig);
  1728. slapdFrontendConfig->port = nPort;
  1729. /* n_port = nPort; */
  1730. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1731. }
  1732. return retVal;
  1733. }
  1734. int
  1735. config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply ) {
  1736. long nPort;
  1737. char *endp = NULL;
  1738. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1739. int retVal = LDAP_SUCCESS;
  1740. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  1741. return LDAP_OPERATIONS_ERROR;
  1742. }
  1743. errno = 0;
  1744. nPort = strtol(port, &endp, 10);
  1745. if (*endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort <= 0 ) {
  1746. retVal = LDAP_OPERATIONS_ERROR;
  1747. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1748. "%s: \"%s\" is invalid, ports must range from 1 to %d",
  1749. attrname, port, LDAP_PORT_MAX );
  1750. }
  1751. if (apply) {
  1752. CFG_LOCK_WRITE(slapdFrontendConfig);
  1753. slapdFrontendConfig->secureport = nPort;
  1754. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1755. }
  1756. return retVal;
  1757. }
  1758. int
  1759. config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
  1760. int retVal = LDAP_SUCCESS;
  1761. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1762. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1763. retVal = LDAP_OPERATIONS_ERROR;
  1764. }
  1765. /* first check the value, return an error if it's invalid */
  1766. else if ( strcasecmp (value, "off") != 0 &&
  1767. strcasecmp (value, "allowed") != 0 &&
  1768. strcasecmp (value, "required")!= 0 ) {
  1769. retVal = LDAP_OPERATIONS_ERROR;
  1770. if( errorbuf )
  1771. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1772. "%s: unsupported value: %s", attrname, value );
  1773. return retVal;
  1774. }
  1775. else if ( !apply ) {
  1776. /* return success now, if we aren't supposed to apply the change */
  1777. return retVal;
  1778. }
  1779. CFG_LOCK_WRITE(slapdFrontendConfig);
  1780. if ( !strcasecmp( value, "off" )) {
  1781. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_OFF;
  1782. }
  1783. else if ( !strcasecmp( value, "allowed" )) {
  1784. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_ALLOWED;
  1785. }
  1786. else if ( !strcasecmp( value, "required" )) {
  1787. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_REQUIRED;
  1788. }
  1789. else {
  1790. retVal = LDAP_OPERATIONS_ERROR;
  1791. if( errorbuf )
  1792. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1793. "%s: unsupported value: %s", attrname, value );
  1794. }
  1795. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1796. return retVal;
  1797. }
  1798. int
  1799. config_set_ssl_check_hostname(const char *attrname, char *value,
  1800. char *errorbuf, int apply)
  1801. {
  1802. int retVal = LDAP_SUCCESS;
  1803. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1804. retVal = config_set_onoff(attrname,
  1805. value,
  1806. &(slapdFrontendConfig->ssl_check_hostname),
  1807. errorbuf,
  1808. apply);
  1809. return retVal;
  1810. }
  1811. int
  1812. config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1813. int retVal = LDAP_SUCCESS;
  1814. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1815. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1816. return LDAP_OPERATIONS_ERROR;
  1817. }
  1818. if (apply) {
  1819. CFG_LOCK_WRITE(slapdFrontendConfig);
  1820. slapi_ch_free ( (void **) &(slapdFrontendConfig->localhost) );
  1821. slapdFrontendConfig->localhost = slapi_ch_strdup ( value );
  1822. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1823. }
  1824. return retVal;
  1825. }
  1826. int
  1827. config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1828. int retVal = LDAP_SUCCESS;
  1829. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1830. if ( apply) {
  1831. CFG_LOCK_WRITE(slapdFrontendConfig);
  1832. slapi_ch_free ( (void **) &(slapdFrontendConfig->listenhost) );
  1833. slapdFrontendConfig->listenhost = slapi_ch_strdup ( value );
  1834. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1835. }
  1836. return retVal;
  1837. }
  1838. int
  1839. config_set_snmp_index(const char *attrname, char *value, char *errorbuf, int apply)
  1840. {
  1841. int retVal = LDAP_SUCCESS;
  1842. long snmp_index;
  1843. long snmp_index_disable;
  1844. char *endp = NULL;
  1845. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1846. snmp_index_disable = atol(DEFAULT_SNMP_INDEX); /* if snmp index is disabled, use the nsslapd-port instead */;
  1847. if (config_value_is_null(attrname, value, errorbuf, 0)) {
  1848. snmp_index = snmp_index_disable;
  1849. } else {
  1850. errno = 0;
  1851. snmp_index = strtol(value, &endp, 10);
  1852. if (*endp != '\0' || errno == ERANGE || snmp_index < snmp_index_disable) {
  1853. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", %s must be greater or equal to %lu (%lu means disabled)",
  1854. attrname, value, CONFIG_SNMP_INDEX_ATTRIBUTE, snmp_index_disable, snmp_index_disable);
  1855. retVal = LDAP_OPERATIONS_ERROR;
  1856. }
  1857. }
  1858. if (apply) {
  1859. CFG_LOCK_WRITE(slapdFrontendConfig);
  1860. slapdFrontendConfig->snmp_index = snmp_index;
  1861. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1862. }
  1863. return retVal;
  1864. }
  1865. int
  1866. config_set_ldapi_filename( const char *attrname, char *value, char *errorbuf, int apply ) {
  1867. int retVal = LDAP_SUCCESS;
  1868. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1869. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1870. return LDAP_OPERATIONS_ERROR;
  1871. }
  1872. if ( apply) {
  1873. CFG_LOCK_WRITE(slapdFrontendConfig);
  1874. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_filename) );
  1875. slapdFrontendConfig->ldapi_filename = slapi_ch_strdup ( value );
  1876. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1877. }
  1878. return retVal;
  1879. }
  1880. int
  1881. config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
  1882. int retVal = LDAP_SUCCESS;
  1883. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1884. retVal = config_set_onoff(attrname,
  1885. value,
  1886. &(slapdFrontendConfig->ldapi_switch),
  1887. errorbuf,
  1888. apply);
  1889. return retVal;
  1890. }
  1891. int config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply )
  1892. {
  1893. int retVal = LDAP_SUCCESS;
  1894. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1895. retVal = config_set_onoff(attrname,
  1896. value,
  1897. &(slapdFrontendConfig->ldapi_bind_switch),
  1898. errorbuf,
  1899. apply);
  1900. return retVal;
  1901. }
  1902. int config_set_ldapi_root_dn( const char *attrname, char *value, char *errorbuf, int apply )
  1903. {
  1904. int retVal = LDAP_SUCCESS;
  1905. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1906. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1907. return LDAP_OPERATIONS_ERROR;
  1908. }
  1909. if ( apply) {
  1910. CFG_LOCK_WRITE(slapdFrontendConfig);
  1911. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_root_dn) );
  1912. slapdFrontendConfig->ldapi_root_dn = slapi_ch_strdup ( value );
  1913. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1914. }
  1915. return retVal;
  1916. }
  1917. int config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply )
  1918. {
  1919. int retVal = LDAP_SUCCESS;
  1920. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1921. retVal = config_set_onoff(attrname,
  1922. value,
  1923. &(slapdFrontendConfig->ldapi_map_entries),
  1924. errorbuf,
  1925. apply);
  1926. return retVal;
  1927. }
  1928. int config_set_ldapi_uidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
  1929. {
  1930. int retVal = LDAP_SUCCESS;
  1931. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1932. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1933. return LDAP_OPERATIONS_ERROR;
  1934. }
  1935. if ( apply) {
  1936. CFG_LOCK_WRITE(slapdFrontendConfig);
  1937. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_uidnumber_type) );
  1938. slapdFrontendConfig->ldapi_uidnumber_type = slapi_ch_strdup ( value );
  1939. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1940. }
  1941. return retVal;
  1942. }
  1943. int config_set_ldapi_gidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
  1944. {
  1945. int retVal = LDAP_SUCCESS;
  1946. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1947. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1948. return LDAP_OPERATIONS_ERROR;
  1949. }
  1950. if ( apply) {
  1951. CFG_LOCK_WRITE(slapdFrontendConfig);
  1952. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_gidnumber_type) );
  1953. slapdFrontendConfig->ldapi_gidnumber_type = slapi_ch_strdup ( value );
  1954. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1955. }
  1956. return retVal;
  1957. }
  1958. int config_set_ldapi_search_base_dn( const char *attrname, char *value, char *errorbuf, int apply )
  1959. {
  1960. int retVal = LDAP_SUCCESS;
  1961. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1962. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1963. return LDAP_OPERATIONS_ERROR;
  1964. }
  1965. if ( apply) {
  1966. CFG_LOCK_WRITE(slapdFrontendConfig);
  1967. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_search_base_dn) );
  1968. slapdFrontendConfig->ldapi_search_base_dn = slapi_ch_strdup ( value );
  1969. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1970. }
  1971. return retVal;
  1972. }
  1973. #if defined(ENABLE_AUTO_DN_SUFFIX)
  1974. int config_set_ldapi_auto_dn_suffix( const char *attrname, char *value, char *errorbuf, int apply )
  1975. {
  1976. int retVal = LDAP_SUCCESS;
  1977. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1978. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1979. return LDAP_OPERATIONS_ERROR;
  1980. }
  1981. if ( apply) {
  1982. CFG_LOCK_WRITE(slapdFrontendConfig);
  1983. slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_auto_dn_suffix) );
  1984. slapdFrontendConfig->ldapi_auto_dn_suffix = slapi_ch_strdup ( value );
  1985. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1986. }
  1987. return retVal;
  1988. }
  1989. #endif
  1990. int config_set_anon_limits_dn( const char *attrname, char *value, char *errorbuf, int apply )
  1991. {
  1992. int retVal = LDAP_SUCCESS;
  1993. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1994. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1995. return LDAP_OPERATIONS_ERROR;
  1996. }
  1997. if ( apply) {
  1998. CFG_LOCK_WRITE(slapdFrontendConfig);
  1999. slapi_ch_free ( (void **) &(slapdFrontendConfig->anon_limits_dn) );
  2000. slapdFrontendConfig->anon_limits_dn =
  2001. slapi_create_dn_string("%s", value);
  2002. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2003. }
  2004. return retVal;
  2005. }
  2006. /*
  2007. * Set nsslapd-counters: on | off to the internal config variable slapi_counters.
  2008. * If set to off, slapi_counters is not initialized and the counters are not
  2009. * incremented. Note: counters which are necessary for the server's running
  2010. * are not disabled.
  2011. */
  2012. int config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply )
  2013. {
  2014. int retVal = LDAP_SUCCESS;
  2015. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2016. retVal = config_set_onoff(attrname, value,
  2017. &(slapdFrontendConfig->slapi_counters), errorbuf, apply);
  2018. return retVal;
  2019. }
  2020. int
  2021. config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  2022. int retVal = LDAP_SUCCESS;
  2023. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2024. if ( apply ) {
  2025. CFG_LOCK_WRITE(slapdFrontendConfig);
  2026. slapi_ch_free ( (void **) &(slapdFrontendConfig->securelistenhost) );
  2027. slapdFrontendConfig->securelistenhost = slapi_ch_strdup ( value );
  2028. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2029. }
  2030. return retVal;
  2031. }
  2032. int
  2033. config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply ) {
  2034. int retVal = LDAP_SUCCESS;
  2035. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2036. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2037. return LDAP_OPERATIONS_ERROR;
  2038. }
  2039. if (apply) {
  2040. CFG_LOCK_WRITE(slapdFrontendConfig);
  2041. slapi_ch_free ( (void **) &(slapdFrontendConfig->srvtab) );
  2042. ldap_srvtab = slapi_ch_strdup ( value );
  2043. slapdFrontendConfig->srvtab = slapi_ch_strdup ( value );
  2044. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2045. }
  2046. return retVal;
  2047. }
  2048. int
  2049. config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2050. int retVal = LDAP_SUCCESS;
  2051. long sizelimit;
  2052. char *endp = NULL;
  2053. Slapi_Backend *be;
  2054. char *cookie;
  2055. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2056. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2057. return LDAP_OPERATIONS_ERROR;
  2058. }
  2059. errno = 0;
  2060. sizelimit = strtol(value, &endp, 10);
  2061. if ( *endp != '\0' || errno == ERANGE || sizelimit < -1 ) {
  2062. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, sizelimit must range from -1 to %ld",
  2063. attrname, value, LONG_MAX );
  2064. retVal = LDAP_OPERATIONS_ERROR;
  2065. return retVal;
  2066. }
  2067. if (apply) {
  2068. CFG_LOCK_WRITE(slapdFrontendConfig);
  2069. slapdFrontendConfig->sizelimit= sizelimit;
  2070. g_set_defsize (sizelimit);
  2071. cookie = NULL;
  2072. be = slapi_get_first_backend(&cookie);
  2073. while (be) {
  2074. be->be_sizelimit = slapdFrontendConfig->sizelimit;
  2075. be = slapi_get_next_backend(cookie);
  2076. }
  2077. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2078. slapi_ch_free ((void **)&cookie);
  2079. }
  2080. return retVal;
  2081. }
  2082. int
  2083. config_set_pagedsizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2084. int retVal = LDAP_SUCCESS;
  2085. long pagedsizelimit;
  2086. char *endp = NULL;
  2087. Slapi_Backend *be;
  2088. char *cookie;
  2089. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2090. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2091. return LDAP_OPERATIONS_ERROR;
  2092. }
  2093. errno = 0;
  2094. pagedsizelimit = strtol(value, &endp, 10);
  2095. if ( *endp != '\0' || errno == ERANGE || pagedsizelimit < -1 ) {
  2096. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, pagedsizelimit must range from -1 to %ld",
  2097. attrname, value, LONG_MAX );
  2098. retVal = LDAP_OPERATIONS_ERROR;
  2099. return retVal;
  2100. }
  2101. if (apply) {
  2102. CFG_LOCK_WRITE(slapdFrontendConfig);
  2103. slapdFrontendConfig->pagedsizelimit= pagedsizelimit;
  2104. cookie = NULL;
  2105. be = slapi_get_first_backend(&cookie);
  2106. while (be) {
  2107. be->be_pagedsizelimit = slapdFrontendConfig->pagedsizelimit;
  2108. be = slapi_get_next_backend(cookie);
  2109. }
  2110. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2111. slapi_ch_free ((void **)&cookie);
  2112. }
  2113. return retVal;
  2114. }
  2115. int
  2116. config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  2117. int retVal = LDAP_SUCCESS;
  2118. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2119. struct pw_scheme *new_scheme = NULL;
  2120. char * scheme_list = NULL;
  2121. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2122. return LDAP_OPERATIONS_ERROR;
  2123. }
  2124. scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  2125. new_scheme = pw_name2scheme(value);
  2126. if ( new_scheme == NULL) {
  2127. if ( scheme_list != NULL ) {
  2128. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2129. "%s: invalid scheme - %s. Valid schemes are: %s",
  2130. attrname, value, scheme_list );
  2131. } else {
  2132. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2133. "%s: invalid scheme - %s (no pwdstorage scheme"
  2134. " plugin loaded)",
  2135. attrname, value);
  2136. }
  2137. retVal = LDAP_OPERATIONS_ERROR;
  2138. slapi_ch_free_string(&scheme_list);
  2139. return retVal;
  2140. }
  2141. else if ( new_scheme->pws_enc == NULL )
  2142. {
  2143. /* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
  2144. compatibility with an Old Messaging Server that was setting passwords in the
  2145. directory already encrypted. The scheme cannot and don't encrypt password if
  2146. they are in clear. We don't take it */
  2147. if ( scheme_list != NULL ) {
  2148. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2149. "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
  2150. }
  2151. retVal = LDAP_UNWILLING_TO_PERFORM;
  2152. slapi_ch_free_string(&scheme_list);
  2153. free_pw_scheme(new_scheme);
  2154. return retVal;
  2155. }
  2156. if ( apply ) {
  2157. CFG_LOCK_WRITE(slapdFrontendConfig);
  2158. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  2159. slapdFrontendConfig->pw_storagescheme = new_scheme;
  2160. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2161. } else {
  2162. free_pw_scheme(new_scheme);
  2163. }
  2164. slapi_ch_free_string(&scheme_list);
  2165. return retVal;
  2166. }
  2167. int
  2168. config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  2169. int retVal = LDAP_SUCCESS;
  2170. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2171. retVal = config_set_onoff ( attrname,
  2172. value,
  2173. &(slapdFrontendConfig->pw_policy.pw_change),
  2174. errorbuf,
  2175. apply);
  2176. if (retVal == LDAP_SUCCESS) {
  2177. /* LP: Update ACI to reflect the value ! */
  2178. if (apply)
  2179. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  2180. !slapdFrontendConfig->pw_policy.pw_must_change);
  2181. }
  2182. return retVal;
  2183. }
  2184. int
  2185. config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) {
  2186. int retVal = LDAP_SUCCESS;
  2187. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2188. retVal = config_set_onoff ( attrname,
  2189. value,
  2190. &(slapdFrontendConfig->pw_policy.pw_history),
  2191. errorbuf,
  2192. apply);
  2193. return retVal;
  2194. }
  2195. int
  2196. config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  2197. int retVal = LDAP_SUCCESS;
  2198. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2199. retVal = config_set_onoff ( attrname,
  2200. value,
  2201. &(slapdFrontendConfig->pw_policy.pw_must_change),
  2202. errorbuf,
  2203. apply);
  2204. if (retVal == LDAP_SUCCESS) {
  2205. /* LP: Update ACI to reflect the value ! */
  2206. if (apply)
  2207. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  2208. !slapdFrontendConfig->pw_policy.pw_must_change);
  2209. }
  2210. return retVal;
  2211. }
  2212. int
  2213. config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) {
  2214. int retVal = LDAP_SUCCESS;
  2215. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2216. retVal = config_set_onoff ( attrname,
  2217. value,
  2218. &(slapdFrontendConfig->pwpolicy_local),
  2219. errorbuf,
  2220. apply);
  2221. return retVal;
  2222. }
  2223. int
  2224. config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) {
  2225. int retVal = LDAP_SUCCESS;
  2226. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2227. retVal = config_set_onoff ( attrname,
  2228. value,
  2229. &(slapdFrontendConfig->pw_policy.pw_syntax),
  2230. errorbuf,
  2231. apply);
  2232. return retVal;
  2233. }
  2234. int
  2235. config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  2236. int retVal = LDAP_SUCCESS;
  2237. long minLength = 0;
  2238. char *endp = NULL;
  2239. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2240. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2241. return LDAP_OPERATIONS_ERROR;
  2242. }
  2243. errno = 0;
  2244. minLength = strtol(value, &endp, 10);
  2245. if ( *endp != '\0' || errno == ERANGE || minLength < 2 || minLength > 512 ) {
  2246. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2247. "password minimum length \"%s\" is invalid. "
  2248. "The minimum length must range from 2 to 512.",
  2249. value );
  2250. retVal = LDAP_OPERATIONS_ERROR;
  2251. return retVal;
  2252. }
  2253. if ( apply ) {
  2254. CFG_LOCK_WRITE(slapdFrontendConfig);
  2255. slapdFrontendConfig->pw_policy.pw_minlength = minLength;
  2256. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2257. }
  2258. return retVal;
  2259. }
  2260. int
  2261. config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int apply ) {
  2262. int retVal = LDAP_SUCCESS;
  2263. long minDigits = 0;
  2264. char *endp = NULL;
  2265. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2266. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2267. return LDAP_OPERATIONS_ERROR;
  2268. }
  2269. errno = 0;
  2270. minDigits = strtol(value, &endp, 10);
  2271. if ( *endp != '\0' || errno == ERANGE || minDigits < 0 || minDigits > 64 ) {
  2272. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2273. "password minimum number of digits \"%s\" is invalid. "
  2274. "The minimum number of digits must range from 0 to 64.",
  2275. value );
  2276. retVal = LDAP_OPERATIONS_ERROR;
  2277. return retVal;
  2278. }
  2279. if ( apply ) {
  2280. CFG_LOCK_WRITE(slapdFrontendConfig);
  2281. slapdFrontendConfig->pw_policy.pw_mindigits = minDigits;
  2282. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2283. }
  2284. return retVal;
  2285. }
  2286. int
  2287. config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int apply ) {
  2288. int retVal = LDAP_SUCCESS;
  2289. long minAlphas = 0;
  2290. char *endp = NULL;
  2291. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2292. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2293. return LDAP_OPERATIONS_ERROR;
  2294. }
  2295. errno = 0;
  2296. minAlphas = strtol(value, &endp, 10);
  2297. if ( *endp != '\0' || errno == ERANGE || minAlphas < 0 || minAlphas > 64 ) {
  2298. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2299. "password minimum number of alphas \"%s\" is invalid. "
  2300. "The minimum number of alphas must range from 0 to 64.",
  2301. value );
  2302. retVal = LDAP_OPERATIONS_ERROR;
  2303. return retVal;
  2304. }
  2305. if ( apply ) {
  2306. CFG_LOCK_WRITE(slapdFrontendConfig);
  2307. slapdFrontendConfig->pw_policy.pw_minalphas = minAlphas;
  2308. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2309. }
  2310. return retVal;
  2311. }
  2312. int
  2313. config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int apply ) {
  2314. int retVal = LDAP_SUCCESS;
  2315. long minUppers = 0;
  2316. char *endp = NULL;
  2317. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2318. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2319. return LDAP_OPERATIONS_ERROR;
  2320. }
  2321. errno = 0;
  2322. minUppers = strtol(value, &endp, 10);
  2323. if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
  2324. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2325. "password minimum number of uppercase characters \"%s\" is invalid. "
  2326. "The minimum number of uppercase characters must range from 0 to 64.",
  2327. value );
  2328. retVal = LDAP_OPERATIONS_ERROR;
  2329. return retVal;
  2330. }
  2331. if ( apply ) {
  2332. CFG_LOCK_WRITE(slapdFrontendConfig);
  2333. slapdFrontendConfig->pw_policy.pw_minuppers = minUppers;
  2334. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2335. }
  2336. return retVal;
  2337. }
  2338. int
  2339. config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int apply ) {
  2340. int retVal = LDAP_SUCCESS;
  2341. long minLowers = 0;
  2342. char *endp = NULL;
  2343. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2344. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2345. return LDAP_OPERATIONS_ERROR;
  2346. }
  2347. errno = 0;
  2348. minLowers = strtol(value, &endp, 10);
  2349. if ( *endp != '\0' || errno == ERANGE || minLowers < 0 || minLowers > 64 ) {
  2350. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2351. "password minimum number of lowercase characters \"%s\" is invalid. "
  2352. "The minimum number of lowercase characters must range from 0 to 64.",
  2353. value );
  2354. retVal = LDAP_OPERATIONS_ERROR;
  2355. return retVal;
  2356. }
  2357. if ( apply ) {
  2358. CFG_LOCK_WRITE(slapdFrontendConfig);
  2359. slapdFrontendConfig->pw_policy.pw_minlowers = minLowers;
  2360. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2361. }
  2362. return retVal;
  2363. }
  2364. int
  2365. config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, int apply ) {
  2366. int retVal = LDAP_SUCCESS;
  2367. long minSpecials = 0;
  2368. char *endp = NULL;
  2369. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2370. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2371. return LDAP_OPERATIONS_ERROR;
  2372. }
  2373. errno = 0;
  2374. minSpecials = strtol(value, &endp, 10);
  2375. if ( *endp != '\0' || errno == ERANGE || minSpecials < 0 || minSpecials > 64 ) {
  2376. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2377. "password minimum number of special characters \"%s\" is invalid. "
  2378. "The minimum number of special characters must range from 0 to 64.",
  2379. value );
  2380. retVal = LDAP_OPERATIONS_ERROR;
  2381. return retVal;
  2382. }
  2383. if ( apply ) {
  2384. CFG_LOCK_WRITE(slapdFrontendConfig);
  2385. slapdFrontendConfig->pw_policy.pw_minspecials = minSpecials;
  2386. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2387. }
  2388. return retVal;
  2389. }
  2390. int
  2391. config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2392. int retVal = LDAP_SUCCESS;
  2393. long min8bit = 0;
  2394. char *endp = NULL;
  2395. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2396. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2397. return LDAP_OPERATIONS_ERROR;
  2398. }
  2399. errno = 0;
  2400. min8bit = strtol(value, &endp, 10);
  2401. if ( *endp != '\0' || errno == ERANGE || min8bit < 0 || min8bit > 64 ) {
  2402. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2403. "password minimum number of 8-bit characters \"%s\" is invalid. "
  2404. "The minimum number of 8-bit characters must range from 0 to 64.",
  2405. value );
  2406. retVal = LDAP_OPERATIONS_ERROR;
  2407. return retVal;
  2408. }
  2409. if ( apply ) {
  2410. CFG_LOCK_WRITE(slapdFrontendConfig);
  2411. slapdFrontendConfig->pw_policy.pw_min8bit = min8bit;
  2412. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2413. }
  2414. return retVal;
  2415. }
  2416. int
  2417. config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int apply ) {
  2418. int retVal = LDAP_SUCCESS;
  2419. long maxRepeats = 0;
  2420. char *endp = NULL;
  2421. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2422. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2423. return LDAP_OPERATIONS_ERROR;
  2424. }
  2425. errno = 0;
  2426. maxRepeats = strtol(value, &endp, 10);
  2427. if ( *endp != '\0' || errno == ERANGE || maxRepeats < 0 || maxRepeats > 64 ) {
  2428. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2429. "password maximum number of repeated characters \"%s\" is invalid. "
  2430. "The maximum number of repeated characters must range from 0 to 64.",
  2431. value );
  2432. retVal = LDAP_OPERATIONS_ERROR;
  2433. return retVal;
  2434. }
  2435. if ( apply ) {
  2436. CFG_LOCK_WRITE(slapdFrontendConfig);
  2437. slapdFrontendConfig->pw_policy.pw_maxrepeats = maxRepeats;
  2438. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2439. }
  2440. return retVal;
  2441. }
  2442. int
  2443. config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf, int apply ) {
  2444. int retVal = LDAP_SUCCESS;
  2445. long minCategories = 0;
  2446. char *endp = NULL;
  2447. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2448. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2449. return LDAP_OPERATIONS_ERROR;
  2450. }
  2451. errno = 0;
  2452. minCategories = strtol(value, &endp, 10);
  2453. if ( *endp != '\0' || errno == ERANGE || minCategories < 1 || minCategories > 5 ) {
  2454. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2455. "password minimum number of categories \"%s\" is invalid. "
  2456. "The minimum number of categories must range from 1 to 5.",
  2457. value );
  2458. retVal = LDAP_OPERATIONS_ERROR;
  2459. return retVal;
  2460. }
  2461. if ( apply ) {
  2462. CFG_LOCK_WRITE(slapdFrontendConfig);
  2463. slapdFrontendConfig->pw_policy.pw_mincategories = minCategories;
  2464. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2465. }
  2466. return retVal;
  2467. }
  2468. int
  2469. config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  2470. int retVal = LDAP_SUCCESS;
  2471. long minTokenLength = 0;
  2472. char *endp = NULL;
  2473. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2474. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2475. return LDAP_OPERATIONS_ERROR;
  2476. }
  2477. errno = 0;
  2478. minTokenLength = strtol(value, &endp, 10);
  2479. if ( *endp != '\0' || errno == ERANGE || minTokenLength < 1 || minTokenLength > 64 ) {
  2480. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2481. "password minimum token length \"%s\" is invalid. "
  2482. "The minimum token length must range from 1 to 64.",
  2483. value );
  2484. retVal = LDAP_OPERATIONS_ERROR;
  2485. return retVal;
  2486. }
  2487. if ( apply ) {
  2488. CFG_LOCK_WRITE(slapdFrontendConfig);
  2489. slapdFrontendConfig->pw_policy.pw_mintokenlength = minTokenLength;
  2490. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2491. }
  2492. return retVal;
  2493. }
  2494. int
  2495. config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int apply ) {
  2496. int retVal = LDAP_SUCCESS;
  2497. long maxFailure = 0;
  2498. char *endp = NULL;
  2499. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2500. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2501. return LDAP_OPERATIONS_ERROR;
  2502. }
  2503. errno = 0;
  2504. maxFailure = strtol(value, &endp, 10);
  2505. if ( *endp != '\0' || errno == ERANGE || maxFailure <= 0 || maxFailure > 32767 ) {
  2506. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2507. "password maximum retry \"%s\" is invalid. "
  2508. "Password maximum failure must range from 1 to 32767",
  2509. value );
  2510. retVal = LDAP_OPERATIONS_ERROR;
  2511. return retVal;
  2512. }
  2513. if ( apply ) {
  2514. CFG_LOCK_WRITE(slapdFrontendConfig);
  2515. slapdFrontendConfig->pw_policy.pw_maxfailure = maxFailure;
  2516. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2517. }
  2518. return retVal;
  2519. }
  2520. int
  2521. config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int apply ) {
  2522. int retVal = LDAP_SUCCESS;
  2523. long history = 0;
  2524. char *endp = NULL;
  2525. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2526. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2527. return LDAP_OPERATIONS_ERROR;
  2528. }
  2529. errno = 0;
  2530. history = strtol(value, &endp, 10);
  2531. if ( *endp != '\0' || errno == ERANGE || history < 2 || history > 24 ) {
  2532. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2533. "password history length \"%s\" is invalid. "
  2534. "The password history must range from 2 to 24",
  2535. value );
  2536. retVal = LDAP_OPERATIONS_ERROR;
  2537. return retVal;
  2538. }
  2539. if ( apply ) {
  2540. CFG_LOCK_WRITE(slapdFrontendConfig);
  2541. slapdFrontendConfig->pw_policy.pw_inhistory = history;
  2542. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2543. }
  2544. return retVal;
  2545. }
  2546. int
  2547. config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, int apply ) {
  2548. int retVal = LDAP_SUCCESS;
  2549. long duration = 0; /* in minutes */
  2550. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2551. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2552. return LDAP_OPERATIONS_ERROR;
  2553. }
  2554. errno = 0;
  2555. /* in seconds */
  2556. duration = parse_duration(value);
  2557. if ( errno == ERANGE || duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  2558. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2559. "password lockout duration \"%s\" is invalid. ",
  2560. value );
  2561. retVal = LDAP_OPERATIONS_ERROR;
  2562. return retVal;
  2563. }
  2564. if ( apply ) {
  2565. slapdFrontendConfig->pw_policy.pw_lockduration = duration;
  2566. }
  2567. return retVal;
  2568. }
  2569. int
  2570. config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorbuf, int apply ) {
  2571. int retVal = LDAP_SUCCESS;
  2572. long duration = 0; /* in minutes */
  2573. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2574. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2575. return LDAP_OPERATIONS_ERROR;
  2576. }
  2577. errno = 0;
  2578. /* in seconds */
  2579. duration = parse_duration(value);
  2580. if ( errno == ERANGE || duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  2581. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2582. "password reset count duration \"%s\" is invalid. ",
  2583. value );
  2584. retVal = LDAP_OPERATIONS_ERROR;
  2585. return retVal;
  2586. }
  2587. if ( apply ) {
  2588. slapdFrontendConfig->pw_policy.pw_resetfailurecount = duration;
  2589. }
  2590. return retVal;
  2591. }
  2592. int
  2593. config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
  2594. int retVal = LDAP_SUCCESS;
  2595. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2596. retVal = config_set_onoff ( attrname,
  2597. value,
  2598. &(slapdFrontendConfig->pw_is_global_policy),
  2599. errorbuf,
  2600. apply);
  2601. return retVal;
  2602. }
  2603. int
  2604. config_set_pw_is_legacy_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
  2605. int retVal = LDAP_SUCCESS;
  2606. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2607. retVal = config_set_onoff ( attrname,
  2608. value,
  2609. &(slapdFrontendConfig->pw_policy.pw_is_legacy),
  2610. errorbuf,
  2611. apply);
  2612. return retVal;
  2613. }
  2614. int
  2615. config_set_pw_admin_dn( const char *attrname, char *value, char *errorbuf, int apply ) {
  2616. int retVal = LDAP_SUCCESS;
  2617. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2618. if ( apply ) {
  2619. CFG_LOCK_WRITE(slapdFrontendConfig);
  2620. slapi_sdn_free(&slapdFrontendConfig->pw_policy.pw_admin);
  2621. slapdFrontendConfig->pw_policy.pw_admin = slapi_sdn_new_dn_byval(value);
  2622. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2623. }
  2624. return retVal;
  2625. }
  2626. int
  2627. config_set_pw_track_last_update_time( const char *attrname, char *value, char *errorbuf, int apply ) {
  2628. int retVal = LDAP_SUCCESS;
  2629. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2630. retVal = config_set_onoff ( attrname,
  2631. value,
  2632. &(slapdFrontendConfig->pw_policy.pw_track_update_time),
  2633. errorbuf,
  2634. apply);
  2635. return retVal;
  2636. }
  2637. int
  2638. config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) {
  2639. int retVal = LDAP_SUCCESS;
  2640. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2641. retVal = config_set_onoff ( attrname,
  2642. value,
  2643. &(slapdFrontendConfig->pw_policy.pw_exp),
  2644. errorbuf,
  2645. apply);
  2646. return retVal;
  2647. }
  2648. int
  2649. config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) {
  2650. int retVal = LDAP_SUCCESS;
  2651. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2652. retVal = config_set_onoff ( attrname,
  2653. value,
  2654. &(slapdFrontendConfig->pw_policy.pw_unlock),
  2655. errorbuf,
  2656. apply);
  2657. return retVal;
  2658. }
  2659. int
  2660. config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) {
  2661. int retVal = LDAP_SUCCESS;
  2662. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2663. retVal = config_set_onoff ( attrname,
  2664. value,
  2665. &(slapdFrontendConfig->pw_policy.pw_lockout),
  2666. errorbuf,
  2667. apply);
  2668. return retVal;
  2669. }
  2670. int
  2671. config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2672. int retVal = LDAP_SUCCESS;
  2673. long gracelimit = 0;
  2674. char *endp = NULL;
  2675. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2676. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2677. return LDAP_OPERATIONS_ERROR;
  2678. }
  2679. errno = 0;
  2680. gracelimit = strtol(value, &endp, 10);
  2681. if ( *endp != '\0' || errno == ERANGE || gracelimit < 0 ) {
  2682. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2683. "password grace limit \"%s\" is invalid, password grace limit must range from 0 to %ld",
  2684. value , LONG_MAX );
  2685. retVal = LDAP_OPERATIONS_ERROR;
  2686. return retVal;
  2687. }
  2688. if ( apply ) {
  2689. CFG_LOCK_WRITE(slapdFrontendConfig);
  2690. slapdFrontendConfig->pw_policy.pw_gracelimit = gracelimit;
  2691. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2692. }
  2693. return retVal;
  2694. }
  2695. int
  2696. config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) {
  2697. int retVal = LDAP_SUCCESS;
  2698. Slapi_Backend *be = NULL;
  2699. char *cookie;
  2700. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2701. retVal = config_set_onoff ( attrname,
  2702. value,
  2703. &(slapdFrontendConfig->lastmod),
  2704. errorbuf,
  2705. apply);
  2706. if ( retVal == LDAP_SUCCESS && apply ) {
  2707. CFG_LOCK_WRITE(slapdFrontendConfig);
  2708. cookie = NULL;
  2709. be = slapi_get_first_backend (&cookie);
  2710. while (be) {
  2711. be->be_lastmod = slapdFrontendConfig->lastmod;
  2712. be = slapi_get_next_backend (cookie);
  2713. }
  2714. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2715. slapi_ch_free ((void **)&cookie);
  2716. }
  2717. return retVal;
  2718. }
  2719. int
  2720. config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) {
  2721. int retVal = LDAP_SUCCESS;
  2722. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2723. retVal = config_set_onoff ( attrname,
  2724. value,
  2725. &(slapdFrontendConfig->nagle),
  2726. errorbuf,
  2727. apply);
  2728. return retVal;
  2729. }
  2730. int
  2731. config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) {
  2732. int retVal = LDAP_SUCCESS;
  2733. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2734. retVal = config_set_onoff ( attrname,
  2735. value,
  2736. &(slapdFrontendConfig->accesscontrol),
  2737. errorbuf,
  2738. apply);
  2739. return retVal;
  2740. }
  2741. int
  2742. config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) {
  2743. int retVal = LDAP_SUCCESS;
  2744. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2745. retVal = config_set_onoff ( attrname,
  2746. value,
  2747. &(slapdFrontendConfig->return_exact_case),
  2748. errorbuf,
  2749. apply);
  2750. return retVal;
  2751. }
  2752. int
  2753. config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) {
  2754. int retVal = LDAP_SUCCESS;
  2755. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2756. retVal = config_set_onoff ( attrname,
  2757. value,
  2758. &(slapdFrontendConfig->result_tweak),
  2759. errorbuf,
  2760. apply);
  2761. return retVal;
  2762. }
  2763. int
  2764. config_set_plugin_tracking( const char *attrname, char *value, char *errorbuf, int apply ) {
  2765. int retVal = LDAP_SUCCESS;
  2766. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2767. retVal = config_set_onoff ( attrname,
  2768. value,
  2769. &(slapdFrontendConfig->plugin_track),
  2770. errorbuf,
  2771. apply);
  2772. return retVal;
  2773. }
  2774. int
  2775. config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) {
  2776. int retVal = LDAP_SUCCESS;
  2777. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2778. retVal = config_set_onoff ( attrname,
  2779. value,
  2780. &(slapdFrontendConfig->security),
  2781. errorbuf,
  2782. apply);
  2783. return retVal;
  2784. }
  2785. static int
  2786. config_set_onoff ( const char *attrname, char *value, int *configvalue,
  2787. char *errorbuf, int apply )
  2788. {
  2789. int retVal = LDAP_SUCCESS;
  2790. slapi_onoff_t newval = -1;
  2791. #ifndef ATOMIC_GETSET_ONOFF
  2792. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2793. #endif
  2794. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2795. return LDAP_OPERATIONS_ERROR;
  2796. }
  2797. CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
  2798. if ( strcasecmp ( value, "on" ) != 0 &&
  2799. strcasecmp ( value, "off") != 0 &&
  2800. /* initializing the value */
  2801. (*(int *)value != LDAP_ON) &&
  2802. (*(int *)value != LDAP_OFF)) {
  2803. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2804. "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
  2805. attrname, value );
  2806. retVal = LDAP_OPERATIONS_ERROR;
  2807. }
  2808. if ( !apply ) {
  2809. /* we can return now if we aren't applying the changes */
  2810. return retVal;
  2811. }
  2812. if ( strcasecmp ( value, "on" ) == 0 ) {
  2813. newval = LDAP_ON;
  2814. } else if ( strcasecmp ( value, "off" ) == 0 ) {
  2815. newval = LDAP_OFF;
  2816. } else { /* assume it is an integer */
  2817. newval = *(slapi_onoff_t *)value;
  2818. }
  2819. #ifdef ATOMIC_GETSET_ONOFF
  2820. PR_AtomicSet(configvalue, newval);
  2821. #else
  2822. *configvalue = newval;
  2823. #endif
  2824. CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig);
  2825. return retVal;
  2826. }
  2827. int
  2828. config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) {
  2829. int retVal = LDAP_SUCCESS;
  2830. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2831. retVal = config_set_onoff ( attrname,
  2832. value,
  2833. &(slapdFrontendConfig->readonly),
  2834. errorbuf,
  2835. apply );
  2836. return retVal;
  2837. }
  2838. int
  2839. config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
  2840. int retVal = LDAP_SUCCESS;
  2841. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2842. retVal = config_set_onoff ( attrname,
  2843. value,
  2844. &(slapdFrontendConfig->schemacheck),
  2845. errorbuf,
  2846. apply);
  2847. return retVal;
  2848. }
  2849. int
  2850. config_set_schemamod( const char *attrname, char *value, char *errorbuf, int apply ) {
  2851. int retVal = LDAP_SUCCESS;
  2852. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2853. retVal = config_set_onoff ( attrname,
  2854. value,
  2855. &(slapdFrontendConfig->schemamod),
  2856. errorbuf,
  2857. apply);
  2858. return retVal;
  2859. }
  2860. int
  2861. config_set_syntaxcheck( const char *attrname, char *value, char *errorbuf, int apply ) {
  2862. int retVal = LDAP_SUCCESS;
  2863. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2864. retVal = config_set_onoff ( attrname,
  2865. value,
  2866. &(slapdFrontendConfig->syntaxcheck),
  2867. errorbuf,
  2868. apply);
  2869. return retVal;
  2870. }
  2871. int
  2872. config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int apply ) {
  2873. int retVal = LDAP_SUCCESS;
  2874. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2875. retVal = config_set_onoff ( attrname,
  2876. value,
  2877. &(slapdFrontendConfig->syntaxlogging),
  2878. errorbuf,
  2879. apply);
  2880. return retVal;
  2881. }
  2882. int
  2883. config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf, int apply ) {
  2884. int retVal = LDAP_SUCCESS;
  2885. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2886. retVal = config_set_onoff ( attrname,
  2887. value,
  2888. &(slapdFrontendConfig->dn_validate_strict),
  2889. errorbuf,
  2890. apply);
  2891. return retVal;
  2892. }
  2893. int
  2894. config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) {
  2895. int retVal = LDAP_SUCCESS;
  2896. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2897. retVal = config_set_onoff ( attrname,
  2898. value,
  2899. &(slapdFrontendConfig->ds4_compatible_schema),
  2900. errorbuf,
  2901. apply);
  2902. return retVal;
  2903. }
  2904. int
  2905. config_set_schema_ignore_trailing_spaces( const char *attrname, char *value,
  2906. char *errorbuf, int apply ) {
  2907. int retVal = LDAP_SUCCESS;
  2908. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2909. retVal = config_set_onoff ( attrname,
  2910. value,
  2911. &(slapdFrontendConfig->schema_ignore_trailing_spaces),
  2912. errorbuf,
  2913. apply);
  2914. return retVal;
  2915. }
  2916. int
  2917. config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) {
  2918. int retVal = LDAP_SUCCESS;
  2919. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2920. retVal = config_set_onoff ( attrname,
  2921. value,
  2922. &(slapdFrontendConfig->enquote_sup_oc),
  2923. errorbuf,
  2924. apply);
  2925. return retVal;
  2926. }
  2927. int
  2928. config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ) {
  2929. int retVal = LDAP_SUCCESS;
  2930. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2931. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2932. return LDAP_OPERATIONS_ERROR;
  2933. }
  2934. if ( apply ) {
  2935. CFG_LOCK_WRITE(slapdFrontendConfig);
  2936. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootdn) );
  2937. slapdFrontendConfig->rootdn = slapi_dn_normalize (slapi_ch_strdup ( value ) );
  2938. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2939. }
  2940. return retVal;
  2941. }
  2942. int
  2943. config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply ) {
  2944. int retVal = LDAP_SUCCESS;
  2945. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2946. struct pw_scheme *is_hashed = NULL;
  2947. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2948. return LDAP_OPERATIONS_ERROR;
  2949. }
  2950. if (!apply) {
  2951. return retVal;
  2952. }
  2953. CFG_LOCK_WRITE(slapdFrontendConfig);
  2954. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootpw) );
  2955. is_hashed = pw_val2scheme ( value, NULL, 0 );
  2956. if ( is_hashed ) {
  2957. slapdFrontendConfig->rootpw = slapi_ch_strdup ( value );
  2958. free_pw_scheme(is_hashed);
  2959. } else if (slapd_nss_is_initialized() ||
  2960. (strcasecmp(slapdFrontendConfig->rootpwstoragescheme->pws_name,
  2961. "clear") == 0)) {
  2962. /* to hash, security library should have been initialized, by now */
  2963. /* pwd enc func returns slapi_ch_malloc memory */
  2964. slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
  2965. } else {
  2966. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2967. "%s: password scheme mismatch (passwd scheme is %s; "
  2968. "password is clear text)", attrname,
  2969. slapdFrontendConfig->rootpwstoragescheme->pws_name);
  2970. retVal = LDAP_PARAM_ERROR;
  2971. }
  2972. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2973. return retVal;
  2974. }
  2975. int
  2976. config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  2977. int retVal = LDAP_SUCCESS;
  2978. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2979. struct pw_scheme *new_scheme = NULL;
  2980. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2981. return LDAP_OPERATIONS_ERROR;
  2982. }
  2983. new_scheme = pw_name2scheme ( value );
  2984. if (new_scheme == NULL ) {
  2985. char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  2986. if ( scheme_list != NULL ) {
  2987. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2988. "%s: invalid scheme - %s. Valid schemes are: %s",
  2989. attrname, value, scheme_list );
  2990. } else {
  2991. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2992. "%s: invalid scheme - %s (no pwdstorage scheme"
  2993. " plugin loaded)", attrname, value);
  2994. }
  2995. slapi_ch_free_string(&scheme_list);
  2996. retVal = LDAP_OPERATIONS_ERROR;
  2997. return retVal;
  2998. }
  2999. CFG_LOCK_WRITE(slapdFrontendConfig);
  3000. free_pw_scheme(slapdFrontendConfig->rootpwstoragescheme);
  3001. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  3002. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3003. return retVal;
  3004. }
  3005. /*
  3006. * kexcoff: to replace default initialization in FrontendConfig_init()
  3007. */
  3008. int config_set_storagescheme() {
  3009. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3010. struct pw_scheme *new_scheme = NULL;
  3011. CFG_LOCK_WRITE(slapdFrontendConfig);
  3012. new_scheme = pw_name2scheme("SSHA");
  3013. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  3014. slapdFrontendConfig->pw_storagescheme = new_scheme;
  3015. new_scheme = pw_name2scheme("SSHA");
  3016. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  3017. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3018. return ( new_scheme == NULL );
  3019. }
  3020. #ifndef _WIN32
  3021. int
  3022. config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply ) {
  3023. int retVal = LDAP_SUCCESS;
  3024. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3025. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3026. return LDAP_OPERATIONS_ERROR;
  3027. }
  3028. if (apply) {
  3029. struct passwd *pw = NULL;
  3030. CFG_LOCK_WRITE(slapdFrontendConfig);
  3031. slapi_ch_free ( (void **) &slapdFrontendConfig->localuser );
  3032. slapdFrontendConfig->localuser = slapi_ch_strdup ( value );
  3033. if (slapdFrontendConfig->localuserinfo != NULL) {
  3034. slapi_ch_free ( (void **) &(slapdFrontendConfig->localuserinfo) );
  3035. }
  3036. pw = getpwnam( value );
  3037. if ( pw ) {
  3038. slapdFrontendConfig->localuserinfo =
  3039. (struct passwd *)slapi_ch_malloc(sizeof(struct passwd));
  3040. memcpy(slapdFrontendConfig->localuserinfo, pw, sizeof(struct passwd));
  3041. }
  3042. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3043. }
  3044. return retVal;
  3045. }
  3046. #endif /* _WIN32 */
  3047. int
  3048. config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply ) {
  3049. int retVal = LDAP_SUCCESS;
  3050. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3051. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3052. return LDAP_OPERATIONS_ERROR;
  3053. }
  3054. if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
  3055. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
  3056. retVal = LDAP_OPERATIONS_ERROR;
  3057. return retVal;
  3058. }
  3059. if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
  3060. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
  3061. retVal = LDAP_OPERATIONS_ERROR;
  3062. return retVal;
  3063. }
  3064. if ( apply) {
  3065. CFG_LOCK_WRITE(slapdFrontendConfig);
  3066. slapdFrontendConfig->workingdir = slapi_ch_strdup ( value );
  3067. #ifdef _WIN32
  3068. dostounixpath(slapdFrontendConfig->workingdir);
  3069. #endif /* _WIN32 */
  3070. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3071. }
  3072. return retVal;
  3073. }
  3074. /* alias of encryption key and certificate files is now retrieved through */
  3075. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  3076. /* where this function is still used to set the global variable */
  3077. int
  3078. config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply ) {
  3079. int retVal = LDAP_SUCCESS;
  3080. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3081. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3082. return LDAP_OPERATIONS_ERROR;
  3083. }
  3084. if (apply) {
  3085. CFG_LOCK_WRITE(slapdFrontendConfig);
  3086. slapi_ch_free ( (void **) &(slapdFrontendConfig->encryptionalias) );
  3087. slapdFrontendConfig->encryptionalias = slapi_ch_strdup ( value );
  3088. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3089. }
  3090. return retVal;
  3091. }
  3092. int
  3093. config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply ) {
  3094. int retVal = LDAP_SUCCESS;
  3095. long threadnum = 0;
  3096. char *endp = NULL;
  3097. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3098. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3099. return LDAP_OPERATIONS_ERROR;
  3100. }
  3101. errno = 0;
  3102. threadnum = strtol(value, &endp, 10);
  3103. if ( *endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535 ) {
  3104. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value );
  3105. retVal = LDAP_OPERATIONS_ERROR;
  3106. }
  3107. if (apply) {
  3108. CFG_LOCK_WRITE(slapdFrontendConfig);
  3109. /* max_threads = threadnum; */
  3110. slapdFrontendConfig->threadnumber = threadnum;
  3111. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3112. }
  3113. return retVal;
  3114. }
  3115. int
  3116. config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply ) {
  3117. int retVal = LDAP_SUCCESS;
  3118. long maxthreadnum = 0;
  3119. char *endp = NULL;
  3120. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3121. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3122. return LDAP_OPERATIONS_ERROR;
  3123. }
  3124. errno = 0;
  3125. maxthreadnum = strtol(value, &endp, 10);
  3126. if ( *endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535 ) {
  3127. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535", attrname, value );
  3128. retVal = LDAP_OPERATIONS_ERROR;
  3129. }
  3130. if (apply) {
  3131. #ifdef ATOMIC_GETSET_MAXTHREADSPERCONN
  3132. PR_AtomicSet(&slapdFrontendConfig->maxthreadsperconn, (slapi_int_t)maxthreadnum);
  3133. #else
  3134. CFG_LOCK_WRITE(slapdFrontendConfig);
  3135. slapdFrontendConfig->maxthreadsperconn = maxthreadnum;
  3136. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3137. #endif
  3138. }
  3139. return retVal;
  3140. }
  3141. #if !defined(_WIN32) && !defined(AIX)
  3142. #include <sys/resource.h>
  3143. int
  3144. config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  3145. int retVal = LDAP_SUCCESS;
  3146. long nValue = 0;
  3147. int maxVal = 65535;
  3148. struct rlimit rlp;
  3149. char *endp = NULL;
  3150. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3151. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3152. return LDAP_OPERATIONS_ERROR;
  3153. }
  3154. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  3155. maxVal = (int)rlp.rlim_max;
  3156. }
  3157. errno = 0;
  3158. nValue = strtol(value, &endp, 10);
  3159. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  3160. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum "
  3161. "file descriptors must range from 1 to %d (the current process limit). "
  3162. "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
  3163. if ( nValue > maxVal ) {
  3164. nValue = maxVal;
  3165. retVal = LDAP_UNWILLING_TO_PERFORM;
  3166. } else {
  3167. retVal = LDAP_OPERATIONS_ERROR;
  3168. }
  3169. }
  3170. if (apply) {
  3171. CFG_LOCK_WRITE(slapdFrontendConfig);
  3172. slapdFrontendConfig->maxdescriptors = nValue;
  3173. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3174. }
  3175. return retVal;
  3176. }
  3177. #endif /* !_WIN32 && !AIX */
  3178. int
  3179. config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int apply ) {
  3180. int retVal = LDAP_SUCCESS;
  3181. long nValue = 0;
  3182. int maxVal = 65535;
  3183. char *endp = NULL;
  3184. #ifndef _WIN32
  3185. struct rlimit rlp;
  3186. #endif
  3187. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3188. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3189. return LDAP_OPERATIONS_ERROR;
  3190. }
  3191. #ifndef _WIN32
  3192. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  3193. maxVal = (int)rlp.rlim_max;
  3194. }
  3195. #endif
  3196. errno = 0;
  3197. nValue = strtol(value, &endp, 0);
  3198. #ifdef _WIN32
  3199. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > 0xfffffe ) {
  3200. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table size must range from 1 to 0xfffffe", attrname, value );
  3201. retVal = LDAP_OPERATIONS_ERROR;
  3202. }
  3203. #elif !defined(AIX)
  3204. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  3205. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table "
  3206. "size must range from 1 to %d (the current process maxdescriptors limit). "
  3207. "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
  3208. if ( nValue > maxVal) {
  3209. nValue = maxVal;
  3210. retVal = LDAP_UNWILLING_TO_PERFORM;
  3211. } else {
  3212. retVal = LDAP_OPERATIONS_ERROR;
  3213. }
  3214. }
  3215. #endif
  3216. if (apply) {
  3217. CFG_LOCK_WRITE(slapdFrontendConfig);
  3218. slapdFrontendConfig->conntablesize = nValue;
  3219. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3220. }
  3221. return retVal;
  3222. }
  3223. int
  3224. config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  3225. int retVal = LDAP_SUCCESS;
  3226. int maxVal = 65535;
  3227. long nValue = 0;
  3228. char *endp = NULL;
  3229. #ifndef _WIN32
  3230. struct rlimit rlp;
  3231. #endif
  3232. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3233. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3234. return LDAP_OPERATIONS_ERROR;
  3235. }
  3236. #ifndef _WIN32
  3237. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  3238. maxVal = (int)rlp.rlim_max;
  3239. }
  3240. #endif
  3241. errno = 0;
  3242. nValue = strtol(value, &endp, 10);
  3243. if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
  3244. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", reserved file "
  3245. "descriptors must range from 1 to %d (the current process maxdescriptors limit). "
  3246. "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
  3247. if ( nValue > maxVal) {
  3248. nValue = maxVal;
  3249. retVal = LDAP_UNWILLING_TO_PERFORM;
  3250. } else {
  3251. retVal = LDAP_OPERATIONS_ERROR;
  3252. }
  3253. }
  3254. if (apply) {
  3255. CFG_LOCK_WRITE(slapdFrontendConfig);
  3256. slapdFrontendConfig->reservedescriptors = nValue;
  3257. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3258. }
  3259. return retVal;
  3260. }
  3261. int
  3262. config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  3263. int retVal = LDAP_SUCCESS;
  3264. long nValue = 0;
  3265. char *endp = NULL;
  3266. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3267. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3268. return LDAP_OPERATIONS_ERROR;
  3269. }
  3270. errno = 0;
  3271. nValue = strtol(value, &endp, 10);
  3272. if ( *endp != '\0' || errno == ERANGE || nValue < 0 ) {
  3273. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %ld",
  3274. attrname, value, LONG_MAX );
  3275. retVal = LDAP_OPERATIONS_ERROR;
  3276. return retVal;
  3277. }
  3278. #if defined(IRIX)
  3279. /* on IRIX poll can only handle timeouts up to
  3280. 2147483 without failing, cap it at 30 minutes */
  3281. if ( nValue > SLAPD_DEFAULT_IOBLOCK_TIMEOUT ) {
  3282. nValue = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  3283. }
  3284. #endif /* IRIX */
  3285. if ( apply ) {
  3286. #ifdef ATOMIC_GETSET_IOBLOCKTIMEOUT
  3287. PR_AtomicSet(&slapdFrontendConfig->ioblocktimeout, (PRInt32)nValue);
  3288. #else
  3289. CFG_LOCK_WRITE(slapdFrontendConfig);
  3290. slapdFrontendConfig->ioblocktimeout = nValue;
  3291. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3292. #endif
  3293. }
  3294. return retVal;
  3295. }
  3296. int
  3297. config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  3298. int retVal = LDAP_SUCCESS;
  3299. long nValue = 0;
  3300. char *endp = NULL;
  3301. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3302. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3303. return LDAP_OPERATIONS_ERROR;
  3304. }
  3305. errno = 0;
  3306. nValue = strtol(value, &endp, 10);
  3307. if (*endp != '\0' || errno == ERANGE || nValue < 0 ) {
  3308. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", idle timeout must range from 0 to %ld",
  3309. attrname, value, LONG_MAX );
  3310. retVal = LDAP_OPERATIONS_ERROR;
  3311. return retVal;
  3312. }
  3313. if (apply) {
  3314. CFG_LOCK_WRITE(slapdFrontendConfig);
  3315. slapdFrontendConfig->idletimeout = nValue;
  3316. /* g_idle_timeout= nValue; */
  3317. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3318. }
  3319. return retVal;
  3320. }
  3321. int
  3322. config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbuf, int apply ) {
  3323. int retVal = LDAP_SUCCESS;
  3324. long nValue = 0;
  3325. char *endp = NULL;
  3326. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3327. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3328. return LDAP_OPERATIONS_ERROR;
  3329. }
  3330. errno = 0;
  3331. nValue = strtol(value, &endp, 10);
  3332. if ( *endp != '\0' || errno == ERANGE || nValue < 0 || nValue > 5 ) {
  3333. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3334. "%s: invalid value \"%s\", group eval nest level must range from 0 to 5",
  3335. attrname, value );
  3336. retVal = LDAP_OPERATIONS_ERROR;
  3337. return retVal;
  3338. }
  3339. if (apply) {
  3340. CFG_LOCK_WRITE(slapdFrontendConfig);
  3341. slapdFrontendConfig->groupevalnestlevel = nValue;
  3342. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3343. }
  3344. return retVal;
  3345. }
  3346. int
  3347. config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply ) {
  3348. int retVal = LDAP_SUCCESS;
  3349. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3350. if ( config_value_is_null( attrname, (char *)value, errorbuf, 0 )) {
  3351. return LDAP_OPERATIONS_ERROR;
  3352. }
  3353. if (apply) {
  3354. CFG_LOCK_WRITE(slapdFrontendConfig);
  3355. g_set_default_referral( value );
  3356. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3357. }
  3358. return retVal;
  3359. }
  3360. int
  3361. config_set_userat( const char *attrname, char *value, char *errorbuf, int apply ) {
  3362. int retVal = LDAP_SUCCESS;
  3363. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3364. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3365. return LDAP_OPERATIONS_ERROR;
  3366. }
  3367. if ( apply ) {
  3368. CFG_LOCK_WRITE(slapdFrontendConfig);
  3369. slapi_ch_free( (void **) &(slapdFrontendConfig->userat) );
  3370. slapdFrontendConfig->userat = slapi_ch_strdup(value);
  3371. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3372. }
  3373. return retVal;
  3374. }
  3375. int
  3376. config_set_timelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  3377. int retVal = LDAP_SUCCESS;
  3378. long nVal = 0;
  3379. char *endp = NULL;
  3380. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3381. Slapi_Backend *be = NULL;
  3382. char *cookie;
  3383. *errorbuf = 0;
  3384. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3385. return LDAP_OPERATIONS_ERROR;
  3386. }
  3387. errno = 0;
  3388. nVal = strtol(value, &endp, 10);
  3389. if ( *endp != '\0' || errno == ERANGE || nVal < -1 ) {
  3390. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3391. "%s: invalid value \"%s\", time limit must range from -1 to %ld",
  3392. attrname, value, LONG_MAX );
  3393. retVal = LDAP_OPERATIONS_ERROR;
  3394. return retVal;
  3395. }
  3396. if ( apply ) {
  3397. CFG_LOCK_WRITE(slapdFrontendConfig);
  3398. g_set_deftime ( nVal );
  3399. slapdFrontendConfig->timelimit = nVal;
  3400. be = slapi_get_first_backend (&cookie);
  3401. while (be) {
  3402. be->be_timelimit = slapdFrontendConfig->timelimit;
  3403. be = slapi_get_next_backend (cookie);
  3404. }
  3405. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3406. slapi_ch_free ((void **)&cookie);
  3407. }
  3408. return retVal;
  3409. }
  3410. int
  3411. config_set_useroc( const char *attrname, char *value, char *errorbuf, int apply ) {
  3412. int retVal = LDAP_SUCCESS;
  3413. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3414. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3415. return LDAP_OPERATIONS_ERROR;
  3416. }
  3417. if ( apply ) {
  3418. CFG_LOCK_WRITE(slapdFrontendConfig);
  3419. slapi_ch_free ( (void **) &(slapdFrontendConfig->useroc) );
  3420. slapdFrontendConfig->useroc = slapi_ch_strdup( value );
  3421. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3422. }
  3423. return retVal;
  3424. }
  3425. int
  3426. config_set_accesslog( const char *attrname, char *value, char *errorbuf, int apply ) {
  3427. int retVal = LDAP_SUCCESS;
  3428. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3429. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3430. return LDAP_OPERATIONS_ERROR;
  3431. }
  3432. retVal = log_update_accesslogdir ( value, apply );
  3433. if ( retVal != LDAP_SUCCESS ) {
  3434. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3435. "Cannot open accesslog directory \"%s\", client accesses will "
  3436. "not be logged.", value );
  3437. }
  3438. if ( apply ) {
  3439. CFG_LOCK_WRITE(slapdFrontendConfig);
  3440. slapi_ch_free ( (void **) &(slapdFrontendConfig->accesslog) );
  3441. slapdFrontendConfig->accesslog = slapi_ch_strdup ( value );
  3442. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3443. }
  3444. return retVal;
  3445. }
  3446. int
  3447. config_set_errorlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  3448. int retVal = LDAP_SUCCESS;
  3449. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3450. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3451. return LDAP_OPERATIONS_ERROR;
  3452. }
  3453. retVal = log_update_errorlogdir ( value, apply );
  3454. if ( retVal != LDAP_SUCCESS ) {
  3455. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3456. "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
  3457. value );
  3458. syslog(LOG_ERR,
  3459. "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
  3460. value );
  3461. g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
  3462. }
  3463. if ( apply ) {
  3464. CFG_LOCK_WRITE(slapdFrontendConfig);
  3465. slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
  3466. slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
  3467. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3468. }
  3469. return retVal;
  3470. }
  3471. int
  3472. config_set_auditlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  3473. int retVal = LDAP_SUCCESS;
  3474. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3475. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3476. return LDAP_OPERATIONS_ERROR;
  3477. }
  3478. retVal = log_update_auditlogdir ( value, apply );
  3479. if ( retVal != LDAP_SUCCESS ) {
  3480. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3481. "Cannot open auditlog directory \"%s\"", value );
  3482. }
  3483. if ( apply ) {
  3484. CFG_LOCK_WRITE(slapdFrontendConfig);
  3485. slapi_ch_free ( (void **) &(slapdFrontendConfig->auditlog) );
  3486. slapdFrontendConfig->auditlog = slapi_ch_strdup ( value );
  3487. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3488. }
  3489. return retVal;
  3490. }
  3491. int
  3492. config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int apply ) {
  3493. int retVal = LDAP_SUCCESS;
  3494. long age;
  3495. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3496. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3497. return LDAP_OPERATIONS_ERROR;
  3498. }
  3499. errno = 0;
  3500. /* age in seconds */
  3501. age = parse_duration(value);
  3502. if ( age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  3503. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3504. "%s: password maximum age \"%s\" is invalid. ",
  3505. attrname, value );
  3506. retVal = LDAP_OPERATIONS_ERROR;
  3507. return retVal;
  3508. }
  3509. if ( apply ) {
  3510. slapdFrontendConfig->pw_policy.pw_maxage = age;
  3511. }
  3512. return retVal;
  3513. }
  3514. int
  3515. config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int apply ) {
  3516. int retVal = LDAP_SUCCESS;
  3517. long age;
  3518. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3519. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3520. return LDAP_OPERATIONS_ERROR;
  3521. }
  3522. errno = 0;
  3523. /* age in seconds */
  3524. age = parse_duration(value);
  3525. if ( age < 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  3526. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3527. "%s: password minimum age \"%s\" is invalid. ",
  3528. attrname, value );
  3529. retVal = LDAP_OPERATIONS_ERROR;
  3530. return retVal;
  3531. }
  3532. if ( apply ) {
  3533. slapdFrontendConfig->pw_policy.pw_minage = age;
  3534. }
  3535. return retVal;
  3536. }
  3537. int
  3538. config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int apply ) {
  3539. int retVal = LDAP_SUCCESS;
  3540. long sec;
  3541. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3542. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3543. return LDAP_OPERATIONS_ERROR;
  3544. }
  3545. errno = 0;
  3546. /* in seconds */
  3547. sec = parse_duration(value);
  3548. if (errno == ERANGE || sec < 0) {
  3549. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  3550. "%s: password warning age \"%s\" is invalid, password warning "
  3551. "age must range from 0 to %ld seconds",
  3552. attrname, value, LONG_MAX );
  3553. retVal = LDAP_OPERATIONS_ERROR;
  3554. return retVal;
  3555. }
  3556. /* translate to seconds */
  3557. if ( apply ) {
  3558. slapdFrontendConfig->pw_policy.pw_warning = sec;
  3559. }
  3560. return retVal;
  3561. }
  3562. int
  3563. config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  3564. int retVal = LDAP_SUCCESS;
  3565. long level = 0;
  3566. char *endp = NULL;
  3567. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3568. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3569. return LDAP_OPERATIONS_ERROR;
  3570. }
  3571. errno = 0;
  3572. level = strtol(value, &endp, 10);
  3573. if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
  3574. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: error log level \"%s\" is invalid,"
  3575. " error log level must range from 0 to %ld", attrname, value, LONG_MAX );
  3576. retVal = LDAP_OPERATIONS_ERROR;
  3577. return retVal;
  3578. }
  3579. if ( apply ) {
  3580. CFG_LOCK_WRITE(slapdFrontendConfig);
  3581. level |= LDAP_DEBUG_ANY;
  3582. #ifdef _WIN32
  3583. *module_ldap_debug = level;
  3584. #else
  3585. slapd_ldap_debug = level;
  3586. #endif
  3587. slapdFrontendConfig->errorloglevel = level;
  3588. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3589. }
  3590. return retVal;
  3591. }
  3592. int
  3593. config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, int apply )
  3594. {
  3595. int retVal = LDAP_SUCCESS;
  3596. long level = 0;
  3597. char *endp = NULL;
  3598. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3599. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  3600. return LDAP_OPERATIONS_ERROR;
  3601. }
  3602. errno = 0;
  3603. level = strtol(value, &endp, 10);
  3604. if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
  3605. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: access log level \"%s\" is invalid,"
  3606. " access log level must range from 0 to %ld", attrname, value, LONG_MAX );
  3607. retVal = LDAP_OPERATIONS_ERROR;
  3608. return retVal;
  3609. }
  3610. if ( apply ) {
  3611. CFG_LOCK_WRITE(slapdFrontendConfig);
  3612. g_set_accesslog_level ( level );
  3613. slapdFrontendConfig->accessloglevel = level;
  3614. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3615. }
  3616. return retVal;
  3617. }
  3618. /* set the referral-mode url (which puts us into referral mode) */
  3619. int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply)
  3620. {
  3621. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3622. slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
  3623. if ((!url) || (!url[0])) {
  3624. strcpy(errorbuf, "referral url must have a value");
  3625. return LDAP_OPERATIONS_ERROR;
  3626. }
  3627. if (apply) {
  3628. CFG_LOCK_WRITE(slapdFrontendConfig);
  3629. slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
  3630. slapdFrontendConfig->refer_mode = REFER_MODE_ON;
  3631. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3632. }
  3633. return LDAP_SUCCESS;
  3634. }
  3635. int
  3636. config_set_versionstring( const char *attrname, char *version, char *errorbuf, int apply ) {
  3637. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3638. if ((!version) || (!version[0])) {
  3639. PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
  3640. return LDAP_OPERATIONS_ERROR;
  3641. }
  3642. if (apply) {
  3643. CFG_LOCK_WRITE(slapdFrontendConfig);
  3644. slapdFrontendConfig->versionstring = slapi_ch_strdup(version);
  3645. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3646. }
  3647. return LDAP_SUCCESS;
  3648. }
  3649. #define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL;
  3650. int
  3651. config_get_port(){
  3652. int retVal;
  3653. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3654. CFG_LOCK_READ(slapdFrontendConfig);
  3655. retVal = slapdFrontendConfig->port;
  3656. CFG_UNLOCK_READ(slapdFrontendConfig);
  3657. return retVal;
  3658. }
  3659. int
  3660. config_get_sasl_maxbufsize()
  3661. {
  3662. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3663. int retVal;
  3664. CFG_LOCK_READ(slapdFrontendConfig);
  3665. retVal = slapdFrontendConfig->sasl_max_bufsize;
  3666. CFG_UNLOCK_READ(slapdFrontendConfig);
  3667. return retVal;
  3668. }
  3669. int
  3670. config_get_ignore_vattrs()
  3671. {
  3672. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3673. return (int)slapdFrontendConfig->ignore_vattrs;
  3674. }
  3675. int
  3676. config_get_sasl_mapping_fallback()
  3677. {
  3678. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3679. int retVal;
  3680. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3681. retVal = (int)slapdFrontendConfig->sasl_mapping_fallback;
  3682. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3683. return retVal;
  3684. }
  3685. int
  3686. config_get_disk_monitoring(){
  3687. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3688. int retVal;
  3689. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3690. retVal = (int)slapdFrontendConfig->disk_monitoring;
  3691. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3692. return retVal;
  3693. }
  3694. int
  3695. config_get_disk_preserve_logging(){
  3696. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3697. int retVal;
  3698. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3699. retVal = (int)slapdFrontendConfig->disk_preserve_logging;
  3700. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3701. return retVal;
  3702. }
  3703. int
  3704. config_get_disk_logging_critical(){
  3705. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3706. int retVal;
  3707. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3708. retVal = (int)slapdFrontendConfig->disk_logging_critical;
  3709. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3710. return retVal;
  3711. }
  3712. int
  3713. config_get_disk_grace_period(){
  3714. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3715. int retVal;
  3716. CFG_LOCK_READ(slapdFrontendConfig);
  3717. retVal = slapdFrontendConfig->disk_grace_period;
  3718. CFG_UNLOCK_READ(slapdFrontendConfig);
  3719. return retVal;
  3720. }
  3721. long
  3722. config_get_disk_threshold(){
  3723. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3724. long retVal;
  3725. CFG_LOCK_READ(slapdFrontendConfig);
  3726. retVal = slapdFrontendConfig->disk_threshold;
  3727. CFG_UNLOCK_READ(slapdFrontendConfig);
  3728. return retVal;
  3729. }
  3730. char *
  3731. config_get_ldapi_filename(){
  3732. char *retVal;
  3733. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3734. CFG_LOCK_READ(slapdFrontendConfig);
  3735. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_filename);
  3736. CFG_UNLOCK_READ(slapdFrontendConfig);
  3737. return retVal;
  3738. }
  3739. int config_get_ldapi_switch(){
  3740. int retVal;
  3741. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3742. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3743. retVal = (int)slapdFrontendConfig->ldapi_switch;
  3744. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3745. return retVal;
  3746. }
  3747. int config_get_ldapi_bind_switch(){
  3748. int retVal;
  3749. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3750. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3751. retVal = (int)slapdFrontendConfig->ldapi_bind_switch;
  3752. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3753. return retVal;
  3754. }
  3755. char *config_get_ldapi_root_dn(){
  3756. char *retVal;
  3757. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3758. CFG_LOCK_READ(slapdFrontendConfig);
  3759. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_root_dn);
  3760. CFG_UNLOCK_READ(slapdFrontendConfig);
  3761. return retVal;
  3762. }
  3763. int config_get_ldapi_map_entries(){
  3764. int retVal;
  3765. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3766. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3767. retVal = (int)slapdFrontendConfig->ldapi_map_entries;
  3768. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3769. return retVal;
  3770. }
  3771. char *config_get_ldapi_uidnumber_type(){
  3772. char *retVal;
  3773. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3774. CFG_LOCK_READ(slapdFrontendConfig);
  3775. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_uidnumber_type);
  3776. CFG_UNLOCK_READ(slapdFrontendConfig);
  3777. return retVal;
  3778. }
  3779. char *config_get_ldapi_gidnumber_type(){
  3780. char *retVal;
  3781. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3782. CFG_LOCK_READ(slapdFrontendConfig);
  3783. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_gidnumber_type);
  3784. CFG_UNLOCK_READ(slapdFrontendConfig);
  3785. return retVal;
  3786. }
  3787. char *config_get_ldapi_search_base_dn(){
  3788. char *retVal;
  3789. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3790. CFG_LOCK_READ(slapdFrontendConfig);
  3791. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_search_base_dn);
  3792. CFG_UNLOCK_READ(slapdFrontendConfig);
  3793. return retVal;
  3794. }
  3795. #if defined(ENABLE_AUTO_DN_SUFFIX)
  3796. char *config_get_ldapi_auto_dn_suffix(){
  3797. char *retVal;
  3798. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3799. CFG_LOCK_READ(slapdFrontendConfig);
  3800. retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_auto_dn_suffix);
  3801. CFG_UNLOCK_READ(slapdFrontendConfig);
  3802. return retVal;
  3803. }
  3804. #endif
  3805. char *config_get_anon_limits_dn(){
  3806. char *retVal;
  3807. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3808. CFG_LOCK_READ(slapdFrontendConfig);
  3809. retVal = slapi_ch_strdup(slapdFrontendConfig->anon_limits_dn);
  3810. CFG_UNLOCK_READ(slapdFrontendConfig);
  3811. return retVal;
  3812. }
  3813. int config_get_slapi_counters()
  3814. {
  3815. int retVal;
  3816. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3817. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3818. retVal = (int)slapdFrontendConfig->slapi_counters;
  3819. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3820. return retVal;
  3821. }
  3822. char *
  3823. config_get_workingdir() {
  3824. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3825. char *retVal;
  3826. CFG_LOCK_READ(slapdFrontendConfig);
  3827. retVal = slapi_ch_strdup(slapdFrontendConfig->workingdir);
  3828. CFG_UNLOCK_READ(slapdFrontendConfig);
  3829. return retVal;
  3830. }
  3831. char *
  3832. config_get_versionstring() {
  3833. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3834. char *retVal;
  3835. CFG_LOCK_READ(slapdFrontendConfig);
  3836. retVal = slapi_ch_strdup(slapdFrontendConfig->versionstring);
  3837. CFG_UNLOCK_READ(slapdFrontendConfig);
  3838. return retVal;
  3839. }
  3840. char *
  3841. config_get_buildnum(void)
  3842. {
  3843. return slapi_ch_strdup(BUILD_NUM);
  3844. }
  3845. int
  3846. config_get_secureport() {
  3847. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3848. int retVal;
  3849. CFG_LOCK_READ(slapdFrontendConfig);
  3850. retVal = slapdFrontendConfig->secureport;
  3851. CFG_UNLOCK_READ(slapdFrontendConfig);
  3852. return retVal;
  3853. }
  3854. int
  3855. config_get_SSLclientAuth() {
  3856. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3857. int retVal;
  3858. CFG_LOCK_READ(slapdFrontendConfig);
  3859. retVal = slapdFrontendConfig->SSLclientAuth;
  3860. CFG_UNLOCK_READ(slapdFrontendConfig);
  3861. return retVal;
  3862. }
  3863. int
  3864. config_get_ssl_check_hostname()
  3865. {
  3866. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3867. return (int)slapdFrontendConfig->ssl_check_hostname;
  3868. }
  3869. char *
  3870. config_get_localhost() {
  3871. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3872. char *retVal;
  3873. CFG_LOCK_READ(slapdFrontendConfig);
  3874. retVal = config_copy_strval ( slapdFrontendConfig->localhost );
  3875. CFG_UNLOCK_READ(slapdFrontendConfig);
  3876. return retVal;
  3877. }
  3878. char *
  3879. config_get_listenhost() {
  3880. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3881. char *retVal;
  3882. CFG_LOCK_READ(slapdFrontendConfig);
  3883. retVal = config_copy_strval ( slapdFrontendConfig->listenhost );
  3884. CFG_UNLOCK_READ(slapdFrontendConfig);
  3885. return retVal;
  3886. }
  3887. char *
  3888. config_get_securelistenhost() {
  3889. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3890. char *retVal;
  3891. CFG_LOCK_READ(slapdFrontendConfig);
  3892. retVal = config_copy_strval( slapdFrontendConfig->securelistenhost );
  3893. CFG_UNLOCK_READ(slapdFrontendConfig);
  3894. return retVal;
  3895. }
  3896. char *
  3897. config_get_srvtab() {
  3898. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3899. char *retVal;
  3900. CFG_LOCK_READ(slapdFrontendConfig);
  3901. retVal = config_copy_strval(slapdFrontendConfig->srvtab);
  3902. CFG_UNLOCK_READ(slapdFrontendConfig);
  3903. return retVal;
  3904. }
  3905. int
  3906. config_get_sizelimit() {
  3907. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3908. int retVal;
  3909. CFG_LOCK_READ(slapdFrontendConfig);
  3910. retVal = slapdFrontendConfig->sizelimit;
  3911. CFG_UNLOCK_READ(slapdFrontendConfig);
  3912. return retVal;
  3913. }
  3914. int
  3915. config_get_pagedsizelimit() {
  3916. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3917. int retVal;
  3918. CFG_LOCK_READ(slapdFrontendConfig);
  3919. retVal = slapdFrontendConfig->pagedsizelimit;
  3920. CFG_UNLOCK_READ(slapdFrontendConfig);
  3921. return retVal;
  3922. }
  3923. char *
  3924. config_get_pw_storagescheme() {
  3925. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3926. char *retVal = 0;
  3927. CFG_LOCK_READ(slapdFrontendConfig);
  3928. retVal = config_copy_strval(slapdFrontendConfig->pw_storagescheme->pws_name);
  3929. CFG_UNLOCK_READ(slapdFrontendConfig);
  3930. return retVal;
  3931. }
  3932. int
  3933. config_get_pw_change() {
  3934. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3935. int retVal;
  3936. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3937. retVal = (int)slapdFrontendConfig->pw_policy.pw_change;
  3938. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3939. return retVal;
  3940. }
  3941. int
  3942. config_get_pw_history() {
  3943. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3944. int retVal;
  3945. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3946. retVal = (int)slapdFrontendConfig->pw_policy.pw_history;
  3947. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3948. return retVal;
  3949. }
  3950. int
  3951. config_get_pw_must_change() {
  3952. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3953. int retVal;
  3954. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3955. retVal = (int)slapdFrontendConfig->pw_policy.pw_must_change;
  3956. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3957. return retVal;
  3958. }
  3959. int
  3960. config_get_pw_syntax() {
  3961. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3962. int retVal;
  3963. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  3964. retVal = (int)slapdFrontendConfig->pw_policy.pw_syntax;
  3965. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  3966. return retVal;
  3967. }
  3968. int
  3969. config_get_pw_minlength() {
  3970. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3971. int retVal;
  3972. CFG_LOCK_READ(slapdFrontendConfig);
  3973. retVal = slapdFrontendConfig->pw_policy.pw_minlength;
  3974. CFG_UNLOCK_READ(slapdFrontendConfig);
  3975. return retVal;
  3976. }
  3977. int
  3978. config_get_pw_mindigits() {
  3979. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3980. int retVal;
  3981. CFG_LOCK_READ(slapdFrontendConfig);
  3982. retVal = slapdFrontendConfig->pw_policy.pw_mindigits;
  3983. CFG_UNLOCK_READ(slapdFrontendConfig);
  3984. return retVal;
  3985. }
  3986. int
  3987. config_get_pw_minalphas() {
  3988. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3989. int retVal;
  3990. CFG_LOCK_READ(slapdFrontendConfig);
  3991. retVal = slapdFrontendConfig->pw_policy.pw_minalphas;
  3992. CFG_UNLOCK_READ(slapdFrontendConfig);
  3993. return retVal;
  3994. }
  3995. int
  3996. config_get_pw_minuppers() {
  3997. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3998. int retVal;
  3999. CFG_LOCK_READ(slapdFrontendConfig);
  4000. retVal = slapdFrontendConfig->pw_policy.pw_minuppers;
  4001. CFG_UNLOCK_READ(slapdFrontendConfig);
  4002. return retVal;
  4003. }
  4004. int
  4005. config_get_pw_minlowers() {
  4006. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4007. int retVal;
  4008. CFG_LOCK_READ(slapdFrontendConfig);
  4009. retVal = slapdFrontendConfig->pw_policy.pw_minlowers;
  4010. CFG_UNLOCK_READ(slapdFrontendConfig);
  4011. return retVal;
  4012. }
  4013. int
  4014. config_get_pw_minspecials() {
  4015. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4016. int retVal;
  4017. CFG_LOCK_READ(slapdFrontendConfig);
  4018. retVal = slapdFrontendConfig->pw_policy.pw_minspecials;
  4019. CFG_UNLOCK_READ(slapdFrontendConfig);
  4020. return retVal;
  4021. }
  4022. int
  4023. config_get_pw_min8bit() {
  4024. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4025. int retVal;
  4026. CFG_LOCK_READ(slapdFrontendConfig);
  4027. retVal = slapdFrontendConfig->pw_policy.pw_min8bit;
  4028. CFG_UNLOCK_READ(slapdFrontendConfig);
  4029. return retVal;
  4030. }
  4031. int
  4032. config_get_pw_maxrepeats() {
  4033. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4034. int retVal;
  4035. CFG_LOCK_READ(slapdFrontendConfig);
  4036. retVal = slapdFrontendConfig->pw_policy.pw_maxrepeats;
  4037. CFG_UNLOCK_READ(slapdFrontendConfig);
  4038. return retVal;
  4039. }
  4040. int
  4041. config_get_pw_mincategories() {
  4042. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4043. int retVal;
  4044. CFG_LOCK_READ(slapdFrontendConfig);
  4045. retVal = slapdFrontendConfig->pw_policy.pw_mincategories;
  4046. CFG_UNLOCK_READ(slapdFrontendConfig);
  4047. return retVal;
  4048. }
  4049. int
  4050. config_get_pw_mintokenlength() {
  4051. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4052. int retVal;
  4053. CFG_LOCK_READ(slapdFrontendConfig);
  4054. retVal = slapdFrontendConfig->pw_policy.pw_mintokenlength;
  4055. CFG_UNLOCK_READ(slapdFrontendConfig);
  4056. return retVal;
  4057. }
  4058. int
  4059. config_get_pw_maxfailure() {
  4060. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4061. int retVal;
  4062. CFG_LOCK_READ(slapdFrontendConfig);
  4063. retVal = slapdFrontendConfig->pw_policy.pw_maxfailure;
  4064. CFG_UNLOCK_READ(slapdFrontendConfig);
  4065. return retVal;
  4066. }
  4067. int
  4068. config_get_pw_inhistory() {
  4069. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4070. int retVal;
  4071. CFG_LOCK_READ(slapdFrontendConfig);
  4072. retVal = slapdFrontendConfig->pw_policy.pw_inhistory;
  4073. CFG_UNLOCK_READ(slapdFrontendConfig);
  4074. return retVal;
  4075. }
  4076. long
  4077. config_get_pw_lockduration() {
  4078. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4079. long retVal;
  4080. CFG_LOCK_READ(slapdFrontendConfig);
  4081. retVal = slapdFrontendConfig->pw_policy.pw_lockduration;
  4082. CFG_UNLOCK_READ(slapdFrontendConfig);
  4083. return retVal;
  4084. }
  4085. long
  4086. config_get_pw_resetfailurecount() {
  4087. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4088. long retVal;
  4089. CFG_LOCK_READ(slapdFrontendConfig);
  4090. retVal = slapdFrontendConfig->pw_policy.pw_resetfailurecount;
  4091. CFG_UNLOCK_READ(slapdFrontendConfig);
  4092. return retVal;
  4093. }
  4094. int
  4095. config_get_pw_is_global_policy() {
  4096. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4097. int retVal;
  4098. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4099. retVal = (int)slapdFrontendConfig->pw_is_global_policy;
  4100. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4101. return retVal;
  4102. }
  4103. int
  4104. config_get_pw_is_legacy_policy() {
  4105. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4106. int retVal;
  4107. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4108. retVal = (int)slapdFrontendConfig->pw_policy.pw_is_legacy;
  4109. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4110. return retVal;
  4111. }
  4112. int
  4113. config_get_pw_exp() {
  4114. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4115. int retVal;
  4116. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4117. retVal = (int)slapdFrontendConfig->pw_policy.pw_exp;
  4118. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4119. return retVal;
  4120. }
  4121. int
  4122. config_get_pw_unlock() {
  4123. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4124. int retVal;
  4125. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4126. retVal = (int)slapdFrontendConfig->pw_policy.pw_unlock;
  4127. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4128. return retVal;
  4129. }
  4130. int
  4131. config_get_pw_lockout(){
  4132. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4133. int retVal;
  4134. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4135. retVal = (int)slapdFrontendConfig->pw_policy.pw_lockout;
  4136. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4137. return retVal;
  4138. }
  4139. int
  4140. config_get_pw_gracelimit() {
  4141. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4142. int retVal=0;
  4143. CFG_LOCK_READ(slapdFrontendConfig);
  4144. retVal = slapdFrontendConfig->pw_policy.pw_gracelimit;
  4145. CFG_UNLOCK_READ(slapdFrontendConfig);
  4146. return retVal;
  4147. }
  4148. int
  4149. config_get_lastmod(){
  4150. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4151. int retVal;
  4152. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4153. retVal = (int)slapdFrontendConfig->lastmod;
  4154. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4155. return retVal;
  4156. }
  4157. int
  4158. config_get_enquote_sup_oc(){
  4159. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4160. int retVal;
  4161. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4162. retVal = (int)slapdFrontendConfig->enquote_sup_oc;
  4163. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4164. return retVal;
  4165. }
  4166. int
  4167. config_get_nagle() {
  4168. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4169. int retVal;
  4170. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4171. retVal = (int)slapdFrontendConfig->nagle;
  4172. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4173. return retVal;
  4174. }
  4175. int
  4176. config_get_accesscontrol() {
  4177. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4178. int retVal;
  4179. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4180. retVal = (int)slapdFrontendConfig->accesscontrol;
  4181. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4182. return retVal;
  4183. }
  4184. int
  4185. config_get_return_exact_case() {
  4186. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4187. int retVal;
  4188. retVal = (int)slapdFrontendConfig->return_exact_case;
  4189. return retVal;
  4190. }
  4191. int
  4192. config_get_result_tweak() {
  4193. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4194. int retVal;
  4195. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4196. retVal = (int)slapdFrontendConfig->result_tweak;
  4197. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4198. return retVal;
  4199. }
  4200. int
  4201. config_get_security() {
  4202. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4203. int retVal;
  4204. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4205. retVal = (int)slapdFrontendConfig->security;
  4206. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4207. return retVal;
  4208. }
  4209. int
  4210. slapi_config_get_readonly() {
  4211. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4212. int retVal;
  4213. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4214. retVal = (int)slapdFrontendConfig->readonly;
  4215. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4216. return retVal;
  4217. }
  4218. int
  4219. config_get_schemacheck() {
  4220. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4221. int retVal;
  4222. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4223. retVal = (int)slapdFrontendConfig->schemacheck;
  4224. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4225. return retVal;
  4226. }
  4227. int
  4228. config_get_schemamod() {
  4229. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4230. int retVal;
  4231. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4232. retVal = (int)slapdFrontendConfig->schemamod;
  4233. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4234. return retVal;
  4235. }
  4236. int
  4237. config_get_syntaxcheck() {
  4238. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4239. int retVal;
  4240. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4241. retVal = (int)slapdFrontendConfig->syntaxcheck;
  4242. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4243. return retVal;
  4244. }
  4245. int
  4246. config_get_syntaxlogging() {
  4247. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4248. int retVal;
  4249. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4250. retVal = (int)slapdFrontendConfig->syntaxlogging;
  4251. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4252. return retVal;
  4253. }
  4254. int
  4255. config_get_dn_validate_strict() {
  4256. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4257. int retVal;
  4258. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4259. retVal = (int)slapdFrontendConfig->dn_validate_strict;
  4260. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4261. return retVal;
  4262. }
  4263. int
  4264. config_get_ds4_compatible_schema() {
  4265. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4266. int retVal;
  4267. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4268. retVal = (int)slapdFrontendConfig->ds4_compatible_schema;
  4269. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4270. return retVal;
  4271. }
  4272. int
  4273. config_get_schema_ignore_trailing_spaces() {
  4274. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4275. int retVal;
  4276. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4277. retVal = (int)slapdFrontendConfig->schema_ignore_trailing_spaces;
  4278. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4279. return retVal;
  4280. }
  4281. char *
  4282. config_get_rootdn() {
  4283. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4284. char *retVal;
  4285. CFG_LOCK_READ(slapdFrontendConfig);
  4286. retVal = config_copy_strval (slapdFrontendConfig->rootdn);
  4287. CFG_UNLOCK_READ(slapdFrontendConfig);
  4288. return retVal;
  4289. }
  4290. char * slapi_get_rootdn() {
  4291. return config_get_rootdn();
  4292. }
  4293. char *
  4294. config_get_rootpw() {
  4295. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4296. char *retVal;
  4297. CFG_LOCK_READ(slapdFrontendConfig);
  4298. retVal = config_copy_strval (slapdFrontendConfig->rootpw);
  4299. CFG_UNLOCK_READ(slapdFrontendConfig);
  4300. return retVal;
  4301. }
  4302. char *
  4303. config_get_rootpwstoragescheme() {
  4304. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4305. char *retVal;
  4306. CFG_LOCK_READ(slapdFrontendConfig);
  4307. retVal = config_copy_strval(slapdFrontendConfig->rootpwstoragescheme->pws_name);
  4308. CFG_UNLOCK_READ(slapdFrontendConfig);
  4309. return retVal;
  4310. }
  4311. #ifndef _WIN32
  4312. char *
  4313. config_get_localuser() {
  4314. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4315. char *retVal;
  4316. CFG_LOCK_READ(slapdFrontendConfig);
  4317. retVal = config_copy_strval(slapdFrontendConfig->localuser);
  4318. CFG_UNLOCK_READ(slapdFrontendConfig);
  4319. return retVal;
  4320. }
  4321. #endif /* _WIN32 */
  4322. /* alias of encryption key and certificate files is now retrieved through */
  4323. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  4324. /* where this function is still used to set the global variable */
  4325. char *
  4326. config_get_encryptionalias() {
  4327. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4328. char *retVal;
  4329. CFG_LOCK_READ(slapdFrontendConfig);
  4330. retVal = config_copy_strval(slapdFrontendConfig->encryptionalias);
  4331. CFG_UNLOCK_READ(slapdFrontendConfig);
  4332. return retVal;
  4333. }
  4334. int
  4335. config_get_threadnumber() {
  4336. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4337. int retVal;
  4338. CFG_LOCK_READ(slapdFrontendConfig);
  4339. retVal = slapdFrontendConfig->threadnumber;
  4340. CFG_UNLOCK_READ(slapdFrontendConfig);
  4341. return retVal;
  4342. }
  4343. int
  4344. config_get_maxthreadsperconn(){
  4345. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4346. int retVal;
  4347. #ifdef ATOMIC_GETSET_MAXTHREADSPERCONN
  4348. retVal = (int)slapdFrontendConfig->maxthreadsperconn;
  4349. #else
  4350. CFG_LOCK_READ(slapdFrontendConfig);
  4351. retVal = slapdFrontendConfig->maxthreadsperconn;
  4352. CFG_UNLOCK_READ(slapdFrontendConfig);
  4353. #endif
  4354. return retVal;
  4355. }
  4356. #if !defined(_WIN32) && !defined(AIX)
  4357. int
  4358. config_get_maxdescriptors() {
  4359. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4360. int retVal;
  4361. CFG_LOCK_READ(slapdFrontendConfig);
  4362. retVal = slapdFrontendConfig->maxdescriptors;
  4363. CFG_UNLOCK_READ(slapdFrontendConfig);
  4364. return retVal;
  4365. }
  4366. #endif /* !_WIN32 && !AIX */
  4367. int
  4368. config_get_reservedescriptors(){
  4369. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4370. int retVal;
  4371. CFG_LOCK_READ(slapdFrontendConfig);
  4372. retVal = slapdFrontendConfig->reservedescriptors;
  4373. CFG_UNLOCK_READ(slapdFrontendConfig);
  4374. return retVal;
  4375. }
  4376. int
  4377. config_get_ioblocktimeout(){
  4378. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4379. int retVal;
  4380. #ifndef ATOMIC_GETSET_IOBLOCKTIMEOUT
  4381. CFG_LOCK_READ(slapdFrontendConfig);
  4382. #endif
  4383. retVal = (int)slapdFrontendConfig->ioblocktimeout;
  4384. #ifndef ATOMIC_GETSET_IOBLOCKTIMEOUT
  4385. CFG_UNLOCK_READ(slapdFrontendConfig);
  4386. #endif
  4387. return retVal;
  4388. }
  4389. int
  4390. config_get_idletimeout(){
  4391. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4392. int retVal;
  4393. CFG_LOCK_READ(slapdFrontendConfig);
  4394. retVal = slapdFrontendConfig->idletimeout;
  4395. CFG_UNLOCK_READ(slapdFrontendConfig);
  4396. return retVal;
  4397. }
  4398. int
  4399. config_get_groupevalnestlevel(){
  4400. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4401. int retVal;
  4402. CFG_LOCK_READ(slapdFrontendConfig);
  4403. retVal = slapdFrontendConfig->groupevalnestlevel;
  4404. CFG_UNLOCK_READ(slapdFrontendConfig);
  4405. return retVal;
  4406. }
  4407. struct berval **
  4408. config_get_defaultreferral() {
  4409. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4410. struct berval **refs;
  4411. int nReferrals = 0;
  4412. CFG_LOCK_READ(slapdFrontendConfig);
  4413. /* count the number of referrals */
  4414. for ( nReferrals = 0;
  4415. slapdFrontendConfig->defaultreferral &&
  4416. slapdFrontendConfig->defaultreferral[nReferrals];
  4417. nReferrals++)
  4418. ;
  4419. refs = (struct berval **)
  4420. slapi_ch_malloc( (nReferrals + 1) * sizeof(struct berval *) );
  4421. /*terminate the end, and add the referrals backwards */
  4422. refs [nReferrals--] = NULL;
  4423. while ( nReferrals >= 0 ) {
  4424. refs[nReferrals] = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
  4425. refs[nReferrals]->bv_val =
  4426. config_copy_strval( slapdFrontendConfig->defaultreferral[nReferrals]->bv_val );
  4427. refs[nReferrals]->bv_len = slapdFrontendConfig->defaultreferral[nReferrals]->bv_len;
  4428. nReferrals--;
  4429. }
  4430. CFG_UNLOCK_READ(slapdFrontendConfig);
  4431. return refs;
  4432. }
  4433. char *
  4434. config_get_userat ( ){
  4435. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4436. char *retVal;
  4437. CFG_LOCK_READ(slapdFrontendConfig);
  4438. retVal = config_copy_strval( slapdFrontendConfig->userat );
  4439. CFG_UNLOCK_READ(slapdFrontendConfig);
  4440. return retVal;
  4441. }
  4442. int
  4443. config_get_timelimit(){
  4444. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4445. int retVal;
  4446. CFG_LOCK_READ(slapdFrontendConfig);
  4447. retVal= slapdFrontendConfig->timelimit;
  4448. CFG_UNLOCK_READ(slapdFrontendConfig);
  4449. return retVal;
  4450. }
  4451. char*
  4452. config_get_useroc(){
  4453. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4454. char *retVal;
  4455. CFG_LOCK_WRITE(slapdFrontendConfig);
  4456. retVal = config_copy_strval(slapdFrontendConfig->useroc );
  4457. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4458. return retVal;
  4459. }
  4460. char *
  4461. config_get_accesslog(){
  4462. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4463. char *retVal;
  4464. CFG_LOCK_READ(slapdFrontendConfig);
  4465. retVal = config_copy_strval(slapdFrontendConfig->accesslog);
  4466. CFG_UNLOCK_READ(slapdFrontendConfig);
  4467. return retVal;
  4468. }
  4469. char *
  4470. config_get_errorlog(){
  4471. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4472. char *retVal;
  4473. CFG_LOCK_READ(slapdFrontendConfig);
  4474. retVal = config_copy_strval(slapdFrontendConfig->errorlog);
  4475. CFG_UNLOCK_READ(slapdFrontendConfig);
  4476. return retVal;
  4477. }
  4478. char *
  4479. config_get_auditlog( ){
  4480. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4481. char *retVal;
  4482. CFG_LOCK_READ(slapdFrontendConfig);
  4483. retVal = config_copy_strval(slapdFrontendConfig->auditlog);
  4484. CFG_UNLOCK_READ(slapdFrontendConfig);
  4485. return retVal;
  4486. }
  4487. long
  4488. config_get_pw_maxage() {
  4489. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4490. long retVal;
  4491. CFG_LOCK_READ(slapdFrontendConfig);
  4492. retVal = slapdFrontendConfig->pw_policy.pw_maxage;
  4493. CFG_UNLOCK_READ(slapdFrontendConfig);
  4494. return retVal;
  4495. }
  4496. long
  4497. config_get_pw_minage(){
  4498. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4499. long retVal;
  4500. CFG_LOCK_READ(slapdFrontendConfig);
  4501. retVal = slapdFrontendConfig->pw_policy.pw_minage;
  4502. CFG_UNLOCK_READ(slapdFrontendConfig);
  4503. return retVal;
  4504. }
  4505. long
  4506. config_get_pw_warning() {
  4507. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4508. long retVal;
  4509. CFG_LOCK_READ(slapdFrontendConfig);
  4510. retVal = slapdFrontendConfig->pw_policy.pw_warning;
  4511. CFG_UNLOCK_READ(slapdFrontendConfig);
  4512. return retVal;
  4513. }
  4514. int
  4515. config_get_errorlog_level(){
  4516. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4517. int retVal;
  4518. CFG_LOCK_READ(slapdFrontendConfig);
  4519. retVal = slapdFrontendConfig->errorloglevel;
  4520. CFG_UNLOCK_READ(slapdFrontendConfig);
  4521. return retVal;
  4522. }
  4523. /* return integer -- don't worry about locking similar to config_check_referral_mode
  4524. below */
  4525. int
  4526. config_get_accesslog_level(){
  4527. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4528. int retVal;
  4529. retVal = slapdFrontendConfig->accessloglevel;
  4530. return retVal;
  4531. }
  4532. /* return integer -- don't worry about locking similar to config_check_referral_mode
  4533. below */
  4534. int
  4535. config_get_auditlog_logging_enabled(){
  4536. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4537. int retVal;
  4538. retVal = (int)slapdFrontendConfig->auditlog_logging_enabled;
  4539. return retVal;
  4540. }
  4541. int
  4542. config_get_accesslog_logging_enabled(){
  4543. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4544. int retVal;
  4545. retVal = (int)slapdFrontendConfig->accesslog_logging_enabled;
  4546. return retVal;
  4547. }
  4548. char *config_get_referral_mode(void)
  4549. {
  4550. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4551. char *ret;
  4552. CFG_LOCK_READ(slapdFrontendConfig);
  4553. ret = config_copy_strval(slapdFrontendConfig->refer_url);
  4554. CFG_UNLOCK_READ(slapdFrontendConfig);
  4555. return ret;
  4556. }
  4557. int
  4558. config_get_conntablesize(void){
  4559. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4560. int retVal;
  4561. CFG_LOCK_READ(slapdFrontendConfig);
  4562. retVal = slapdFrontendConfig->conntablesize;
  4563. CFG_UNLOCK_READ(slapdFrontendConfig);
  4564. return retVal;
  4565. }
  4566. /* return yes/no without actually copying the referral url
  4567. we don't worry about another thread changing this value
  4568. since we now return an integer */
  4569. int config_check_referral_mode(void)
  4570. {
  4571. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4572. return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
  4573. }
  4574. int
  4575. config_get_outbound_ldap_io_timeout(void)
  4576. {
  4577. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4578. int retVal;
  4579. CFG_LOCK_READ(slapdFrontendConfig);
  4580. retVal = slapdFrontendConfig->outbound_ldap_io_timeout;
  4581. CFG_UNLOCK_READ(slapdFrontendConfig);
  4582. return retVal;
  4583. }
  4584. int
  4585. config_get_unauth_binds_switch(void)
  4586. {
  4587. int retVal;
  4588. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4589. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4590. retVal = (int)slapdFrontendConfig->allow_unauth_binds;
  4591. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4592. return retVal;
  4593. }
  4594. int
  4595. config_get_require_secure_binds(void)
  4596. {
  4597. int retVal;
  4598. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4599. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4600. retVal = (int)slapdFrontendConfig->require_secure_binds;
  4601. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4602. return retVal;
  4603. }
  4604. int
  4605. config_get_anon_access_switch(void)
  4606. {
  4607. int retVal = 0;
  4608. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4609. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4610. retVal = (int)slapdFrontendConfig->allow_anon_access;
  4611. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4612. return retVal;
  4613. }
  4614. int
  4615. config_get_validate_cert_switch(void)
  4616. {
  4617. int retVal = 0;
  4618. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4619. CFG_LOCK_READ(slapdFrontendConfig);
  4620. retVal = slapdFrontendConfig->validate_cert;
  4621. CFG_UNLOCK_READ(slapdFrontendConfig);
  4622. return retVal;
  4623. }
  4624. int
  4625. config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
  4626. {
  4627. int retVal = LDAP_SUCCESS;
  4628. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4629. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4630. return LDAP_OPERATIONS_ERROR;
  4631. }
  4632. if ( !apply ) {
  4633. return retVal;
  4634. }
  4635. CFG_LOCK_WRITE(slapdFrontendConfig);
  4636. slapdFrontendConfig->maxbersize = atoi(value);
  4637. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4638. return retVal;
  4639. }
  4640. ber_len_t
  4641. config_get_maxbersize()
  4642. {
  4643. ber_len_t maxbersize;
  4644. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4645. maxbersize = slapdFrontendConfig->maxbersize;
  4646. if(maxbersize==0)
  4647. maxbersize= 2 * 1024 * 1024; /* Default: 2Mb */
  4648. return maxbersize;
  4649. }
  4650. int
  4651. config_set_maxsasliosize( const char *attrname, char *value, char *errorbuf, int apply )
  4652. {
  4653. int retVal = LDAP_SUCCESS;
  4654. long maxsasliosize;
  4655. char *endptr;
  4656. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4657. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4658. return LDAP_OPERATIONS_ERROR;
  4659. }
  4660. maxsasliosize = strtol(value, &endptr, 10);
  4661. /* Check for non-numeric garbage in the value */
  4662. if (*endptr != '\0') {
  4663. retVal = LDAP_OPERATIONS_ERROR;
  4664. }
  4665. /* Check for a value overflow */
  4666. if (((maxsasliosize == LONG_MAX) || (maxsasliosize == LONG_MIN)) && (errno == ERANGE)){
  4667. retVal = LDAP_OPERATIONS_ERROR;
  4668. }
  4669. /* A setting of -1 means unlimited. Don't allow other negative values. */
  4670. if ((maxsasliosize < 0) && (maxsasliosize != -1)) {
  4671. retVal = LDAP_OPERATIONS_ERROR;
  4672. }
  4673. if (retVal != LDAP_SUCCESS) {
  4674. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  4675. "%s: \"%s\" is invalid. Value must range from -1 to %ld",
  4676. attrname, value, LONG_MAX );
  4677. } else if (apply) {
  4678. CFG_LOCK_WRITE(slapdFrontendConfig);
  4679. slapdFrontendConfig->maxsasliosize = maxsasliosize;
  4680. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4681. }
  4682. return retVal;
  4683. }
  4684. size_t
  4685. config_get_maxsasliosize()
  4686. {
  4687. size_t maxsasliosize;
  4688. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4689. maxsasliosize = slapdFrontendConfig->maxsasliosize;
  4690. return maxsasliosize;
  4691. }
  4692. int
  4693. config_set_localssf( const char *attrname, char *value, char *errorbuf, int apply )
  4694. {
  4695. int retVal = LDAP_SUCCESS;
  4696. int localssf;
  4697. char *endptr;
  4698. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4699. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4700. return LDAP_OPERATIONS_ERROR;
  4701. }
  4702. localssf = (int) strtol(value, &endptr, 10);
  4703. /* Check for non-numeric garbage in the value */
  4704. if (*endptr != '\0') {
  4705. retVal = LDAP_OPERATIONS_ERROR;
  4706. }
  4707. /* Check for a value overflow */
  4708. if (((localssf == INT_MAX) || (localssf == INT_MIN)) && (errno == ERANGE)){
  4709. retVal = LDAP_OPERATIONS_ERROR;
  4710. }
  4711. /* Don't allow negative values. */
  4712. if (localssf < 0) {
  4713. retVal = LDAP_OPERATIONS_ERROR;
  4714. }
  4715. if (retVal != LDAP_SUCCESS) {
  4716. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  4717. "%s: \"%s\" is invalid. Value must range from 0 to %d",
  4718. attrname, value, INT_MAX );
  4719. } else if (apply) {
  4720. CFG_LOCK_WRITE(slapdFrontendConfig);
  4721. slapdFrontendConfig->localssf = localssf;
  4722. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4723. }
  4724. return retVal;
  4725. }
  4726. int
  4727. config_set_minssf( const char *attrname, char *value, char *errorbuf, int apply )
  4728. {
  4729. int retVal = LDAP_SUCCESS;
  4730. int minssf;
  4731. char *endptr;
  4732. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4733. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4734. return LDAP_OPERATIONS_ERROR;
  4735. }
  4736. minssf = (int) strtol(value, &endptr, 10);
  4737. /* Check for non-numeric garbage in the value */
  4738. if (*endptr != '\0') {
  4739. retVal = LDAP_OPERATIONS_ERROR;
  4740. }
  4741. /* Check for a value overflow */
  4742. if (((minssf == INT_MAX) || (minssf == INT_MIN)) && (errno == ERANGE)){
  4743. retVal = LDAP_OPERATIONS_ERROR;
  4744. }
  4745. /* Don't allow negative values. */
  4746. if (minssf < 0) {
  4747. retVal = LDAP_OPERATIONS_ERROR;
  4748. }
  4749. if (retVal != LDAP_SUCCESS) {
  4750. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  4751. "%s: \"%s\" is invalid. Value must range from 0 to %d",
  4752. attrname, value, INT_MAX );
  4753. } else if (apply) {
  4754. CFG_LOCK_WRITE(slapdFrontendConfig);
  4755. slapdFrontendConfig->minssf = minssf;
  4756. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4757. }
  4758. return retVal;
  4759. }
  4760. int
  4761. config_set_minssf_exclude_rootdse( const char *attrname, char *value,
  4762. char *errorbuf, int apply )
  4763. {
  4764. int retVal = LDAP_SUCCESS;
  4765. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4766. retVal = config_set_onoff ( attrname,
  4767. value,
  4768. &(slapdFrontendConfig->minssf_exclude_rootdse),
  4769. errorbuf,
  4770. apply );
  4771. return retVal;
  4772. }
  4773. int
  4774. config_get_localssf()
  4775. {
  4776. int localssf;
  4777. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4778. localssf = slapdFrontendConfig->localssf;
  4779. return localssf;
  4780. }
  4781. int
  4782. config_get_minssf()
  4783. {
  4784. int minssf;
  4785. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4786. minssf = slapdFrontendConfig->minssf;
  4787. return minssf;
  4788. }
  4789. int
  4790. config_get_minssf_exclude_rootdse()
  4791. {
  4792. int retVal;
  4793. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4794. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4795. retVal = (int)slapdFrontendConfig->minssf_exclude_rootdse;
  4796. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4797. return retVal;
  4798. }
  4799. int
  4800. config_set_max_filter_nest_level( const char *attrname, char *value,
  4801. char *errorbuf, int apply )
  4802. {
  4803. int retVal = LDAP_SUCCESS;
  4804. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4805. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4806. return LDAP_OPERATIONS_ERROR;
  4807. }
  4808. if ( !apply ) {
  4809. return retVal;
  4810. }
  4811. #ifdef ATOMIC_GETSET_FILTER_NEST_LEVEL
  4812. PR_AtomicSet(&slapdFrontendConfig->max_filter_nest_level, atoi(value));
  4813. #else
  4814. CFG_LOCK_WRITE(slapdFrontendConfig);
  4815. slapdFrontendConfig->max_filter_nest_level = atoi(value);
  4816. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4817. #endif
  4818. return retVal;
  4819. }
  4820. int
  4821. config_get_max_filter_nest_level()
  4822. {
  4823. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4824. int retVal;
  4825. #ifndef ATOMIC_GETSET_FILTER_NEST_LEVEL
  4826. CFG_LOCK_READ(slapdFrontendConfig);
  4827. #endif
  4828. retVal = (int)slapdFrontendConfig->max_filter_nest_level;
  4829. #ifndef ATOMIC_GETSET_FILTER_NEST_LEVEL
  4830. CFG_UNLOCK_READ(slapdFrontendConfig);
  4831. #endif
  4832. return retVal;
  4833. }
  4834. size_t
  4835. config_get_ndn_cache_size(){
  4836. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4837. size_t retVal;
  4838. CFG_LOCK_READ(slapdFrontendConfig);
  4839. retVal = slapdFrontendConfig->ndn_cache_max_size;
  4840. CFG_UNLOCK_READ(slapdFrontendConfig);
  4841. return retVal;
  4842. }
  4843. int
  4844. config_get_ndn_cache_enabled(){
  4845. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4846. int retVal;
  4847. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4848. retVal = (int)slapdFrontendConfig->ndn_cache_enabled;
  4849. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4850. return retVal;
  4851. }
  4852. int
  4853. config_get_return_orig_type_switch()
  4854. {
  4855. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4856. int retVal;
  4857. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  4858. retVal = (int)slapdFrontendConfig->return_orig_type;
  4859. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  4860. return retVal;
  4861. }
  4862. char *
  4863. config_get_basedn() {
  4864. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4865. char *retVal;
  4866. CFG_LOCK_READ(slapdFrontendConfig);
  4867. retVal = config_copy_strval ( slapdFrontendConfig->certmap_basedn );
  4868. CFG_UNLOCK_READ(slapdFrontendConfig);
  4869. return retVal;
  4870. }
  4871. int
  4872. config_set_basedn ( const char *attrname, char *value, char *errorbuf, int apply ) {
  4873. int retVal = LDAP_SUCCESS;
  4874. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4875. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4876. return LDAP_OPERATIONS_ERROR;
  4877. }
  4878. if ( !apply ) {
  4879. return retVal;
  4880. }
  4881. CFG_LOCK_WRITE(slapdFrontendConfig);
  4882. slapi_ch_free ( (void **) &slapdFrontendConfig->certmap_basedn );
  4883. slapdFrontendConfig->certmap_basedn = slapi_dn_normalize( slapi_ch_strdup(value) );
  4884. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4885. return retVal;
  4886. }
  4887. char *
  4888. config_get_configdir()
  4889. {
  4890. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4891. char *retVal;
  4892. CFG_LOCK_READ(slapdFrontendConfig);
  4893. retVal = config_copy_strval(slapdFrontendConfig->configdir);
  4894. CFG_UNLOCK_READ(slapdFrontendConfig);
  4895. return retVal;
  4896. }
  4897. int
  4898. config_set_configdir(const char *attrname, char *value, char *errorbuf, int apply)
  4899. {
  4900. int retVal = LDAP_SUCCESS;
  4901. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4902. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4903. return LDAP_OPERATIONS_ERROR;
  4904. }
  4905. if (!apply) {
  4906. return retVal;
  4907. }
  4908. CFG_LOCK_WRITE(slapdFrontendConfig);
  4909. slapi_ch_free((void **)&slapdFrontendConfig->configdir);
  4910. slapdFrontendConfig->configdir = slapi_ch_strdup(value);
  4911. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4912. return retVal;
  4913. }
  4914. char *
  4915. config_get_instancedir()
  4916. {
  4917. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4918. char *retVal;
  4919. CFG_LOCK_READ(slapdFrontendConfig);
  4920. retVal = config_copy_strval(slapdFrontendConfig->instancedir);
  4921. CFG_UNLOCK_READ(slapdFrontendConfig);
  4922. return retVal;
  4923. }
  4924. int
  4925. config_set_instancedir(const char *attrname, char *value, char *errorbuf, int apply)
  4926. {
  4927. int retVal = LDAP_SUCCESS;
  4928. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4929. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4930. return LDAP_OPERATIONS_ERROR;
  4931. }
  4932. if (!apply) {
  4933. return retVal;
  4934. }
  4935. CFG_LOCK_WRITE(slapdFrontendConfig);
  4936. /* We don't want to allow users to modify instance dir.
  4937. * Set it once when the server starts. */
  4938. if (NULL == slapdFrontendConfig->instancedir) {
  4939. slapdFrontendConfig->instancedir = slapi_ch_strdup(value);
  4940. }
  4941. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4942. return retVal;
  4943. }
  4944. char *
  4945. config_get_schemadir()
  4946. {
  4947. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4948. char *retVal;
  4949. CFG_LOCK_READ(slapdFrontendConfig);
  4950. retVal = config_copy_strval(slapdFrontendConfig->schemadir);
  4951. CFG_UNLOCK_READ(slapdFrontendConfig);
  4952. return retVal;
  4953. }
  4954. int
  4955. config_set_schemadir(const char *attrname, char *value, char *errorbuf, int apply)
  4956. {
  4957. int retVal = LDAP_SUCCESS;
  4958. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4959. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4960. return LDAP_OPERATIONS_ERROR;
  4961. }
  4962. if (!apply) {
  4963. return retVal;
  4964. }
  4965. CFG_LOCK_WRITE(slapdFrontendConfig);
  4966. slapi_ch_free((void **)&slapdFrontendConfig->schemadir);
  4967. slapdFrontendConfig->schemadir = slapi_ch_strdup(value);
  4968. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4969. return retVal;
  4970. }
  4971. char *
  4972. config_get_lockdir()
  4973. {
  4974. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4975. char *retVal;
  4976. CFG_LOCK_READ(slapdFrontendConfig);
  4977. retVal = config_copy_strval(slapdFrontendConfig->lockdir);
  4978. CFG_UNLOCK_READ(slapdFrontendConfig);
  4979. return retVal;
  4980. }
  4981. int
  4982. config_set_lockdir(const char *attrname, char *value, char *errorbuf, int apply)
  4983. {
  4984. int retVal = LDAP_SUCCESS;
  4985. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  4986. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  4987. return LDAP_OPERATIONS_ERROR;
  4988. }
  4989. if (!apply) {
  4990. return retVal;
  4991. }
  4992. CFG_LOCK_WRITE(slapdFrontendConfig);
  4993. slapi_ch_free((void **)&slapdFrontendConfig->lockdir);
  4994. slapdFrontendConfig->lockdir = slapi_ch_strdup(value);
  4995. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  4996. return retVal;
  4997. }
  4998. char *
  4999. config_get_tmpdir()
  5000. {
  5001. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5002. char *retVal;
  5003. CFG_LOCK_READ(slapdFrontendConfig);
  5004. retVal = config_copy_strval(slapdFrontendConfig->tmpdir);
  5005. CFG_UNLOCK_READ(slapdFrontendConfig);
  5006. return retVal;
  5007. }
  5008. int
  5009. config_set_tmpdir(const char *attrname, char *value, char *errorbuf, int apply)
  5010. {
  5011. int retVal = LDAP_SUCCESS;
  5012. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5013. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5014. return LDAP_OPERATIONS_ERROR;
  5015. }
  5016. if (!apply) {
  5017. return retVal;
  5018. }
  5019. CFG_LOCK_WRITE(slapdFrontendConfig);
  5020. slapi_ch_free((void **)&slapdFrontendConfig->tmpdir);
  5021. slapdFrontendConfig->tmpdir = slapi_ch_strdup(value);
  5022. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5023. return retVal;
  5024. }
  5025. char *
  5026. config_get_certdir()
  5027. {
  5028. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5029. char *retVal;
  5030. CFG_LOCK_READ(slapdFrontendConfig);
  5031. retVal = config_copy_strval(slapdFrontendConfig->certdir);
  5032. CFG_UNLOCK_READ(slapdFrontendConfig);
  5033. return retVal;
  5034. }
  5035. int
  5036. config_set_certdir(const char *attrname, char *value, char *errorbuf, int apply)
  5037. {
  5038. int retVal = LDAP_SUCCESS;
  5039. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5040. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5041. return LDAP_OPERATIONS_ERROR;
  5042. }
  5043. if (!apply) {
  5044. return retVal;
  5045. }
  5046. CFG_LOCK_WRITE(slapdFrontendConfig);
  5047. slapi_ch_free((void **)&slapdFrontendConfig->certdir);
  5048. slapdFrontendConfig->certdir = slapi_ch_strdup(value);
  5049. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5050. return retVal;
  5051. }
  5052. char *
  5053. config_get_ldifdir()
  5054. {
  5055. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5056. char *retVal;
  5057. CFG_LOCK_READ(slapdFrontendConfig);
  5058. retVal = config_copy_strval(slapdFrontendConfig->ldifdir);
  5059. CFG_UNLOCK_READ(slapdFrontendConfig);
  5060. return retVal;
  5061. }
  5062. int
  5063. config_set_ldifdir(const char *attrname, char *value, char *errorbuf, int apply)
  5064. {
  5065. int retVal = LDAP_SUCCESS;
  5066. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5067. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5068. return LDAP_OPERATIONS_ERROR;
  5069. }
  5070. if (!apply) {
  5071. return retVal;
  5072. }
  5073. CFG_LOCK_WRITE(slapdFrontendConfig);
  5074. slapi_ch_free((void **)&slapdFrontendConfig->ldifdir);
  5075. slapdFrontendConfig->ldifdir = slapi_ch_strdup(value);
  5076. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5077. return retVal;
  5078. }
  5079. char *
  5080. config_get_bakdir()
  5081. {
  5082. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5083. char *retVal;
  5084. CFG_LOCK_READ(slapdFrontendConfig);
  5085. retVal = config_copy_strval(slapdFrontendConfig->bakdir);
  5086. CFG_UNLOCK_READ(slapdFrontendConfig);
  5087. return retVal;
  5088. }
  5089. int
  5090. config_set_bakdir(const char *attrname, char *value, char *errorbuf, int apply)
  5091. {
  5092. int retVal = LDAP_SUCCESS;
  5093. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5094. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5095. return LDAP_OPERATIONS_ERROR;
  5096. }
  5097. if (!apply) {
  5098. return retVal;
  5099. }
  5100. CFG_LOCK_WRITE(slapdFrontendConfig);
  5101. slapi_ch_free((void **)&slapdFrontendConfig->bakdir);
  5102. slapdFrontendConfig->bakdir = slapi_ch_strdup(value);
  5103. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5104. return retVal;
  5105. }
  5106. char *
  5107. config_get_rundir()
  5108. {
  5109. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5110. char *retVal;
  5111. CFG_LOCK_READ(slapdFrontendConfig);
  5112. retVal = config_copy_strval(slapdFrontendConfig->rundir);
  5113. CFG_UNLOCK_READ(slapdFrontendConfig);
  5114. return retVal;
  5115. }
  5116. int
  5117. config_set_rundir(const char *attrname, char *value, char *errorbuf, int apply)
  5118. {
  5119. int retVal = LDAP_SUCCESS;
  5120. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5121. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5122. return LDAP_OPERATIONS_ERROR;
  5123. }
  5124. if (!apply) {
  5125. return retVal;
  5126. }
  5127. CFG_LOCK_WRITE(slapdFrontendConfig);
  5128. slapi_ch_free((void **)&slapdFrontendConfig->rundir);
  5129. slapdFrontendConfig->rundir = slapi_ch_strdup(value);
  5130. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5131. return retVal;
  5132. }
  5133. char *
  5134. config_get_saslpath()
  5135. {
  5136. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5137. char *retVal;
  5138. CFG_LOCK_READ(slapdFrontendConfig);
  5139. retVal = config_copy_strval(slapdFrontendConfig->saslpath);
  5140. CFG_UNLOCK_READ(slapdFrontendConfig);
  5141. return retVal;
  5142. }
  5143. int
  5144. config_set_saslpath(const char *attrname, char *value, char *errorbuf, int apply)
  5145. {
  5146. int retVal = LDAP_SUCCESS;
  5147. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5148. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5149. return LDAP_OPERATIONS_ERROR;
  5150. }
  5151. if (!apply) {
  5152. return retVal;
  5153. }
  5154. CFG_LOCK_WRITE(slapdFrontendConfig);
  5155. slapi_ch_free((void **)&slapdFrontendConfig->saslpath);
  5156. slapdFrontendConfig->saslpath = slapi_ch_strdup(value);
  5157. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5158. return retVal;
  5159. }
  5160. char **
  5161. config_get_errorlog_list()
  5162. {
  5163. return log_get_loglist(SLAPD_ERROR_LOG);
  5164. }
  5165. char **
  5166. config_get_accesslog_list()
  5167. {
  5168. return log_get_loglist(SLAPD_ACCESS_LOG);
  5169. }
  5170. char **
  5171. config_get_auditlog_list()
  5172. {
  5173. return log_get_loglist(SLAPD_AUDIT_LOG);
  5174. }
  5175. int
  5176. config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
  5177. {
  5178. int retVal = LDAP_SUCCESS;
  5179. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5180. retVal = config_set_onoff(attrname,
  5181. value,
  5182. &(slapdFrontendConfig->accesslogbuffering),
  5183. errorbuf,
  5184. apply);
  5185. return retVal;
  5186. }
  5187. #ifdef MEMPOOL_EXPERIMENTAL
  5188. int
  5189. config_set_mempool_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
  5190. int retVal = LDAP_SUCCESS;
  5191. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5192. retVal = config_set_onoff(attrname,
  5193. value,
  5194. &(slapdFrontendConfig->mempool_switch),
  5195. errorbuf,
  5196. apply);
  5197. return retVal;
  5198. }
  5199. int
  5200. config_get_mempool_switch()
  5201. {
  5202. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5203. return (int)slapdFrontendConfig->mempool_switch;
  5204. }
  5205. int
  5206. config_set_mempool_maxfreelist( const char *attrname, char *value, char *errorbuf, int apply )
  5207. {
  5208. int retVal = LDAP_SUCCESS;
  5209. char *endp = NULL;
  5210. int maxfreelist;
  5211. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5212. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5213. return LDAP_OPERATIONS_ERROR;
  5214. }
  5215. errno = 0;
  5216. maxfreelist = strtol(value, &endp, 10);
  5217. if (0 != errno ) {
  5218. return LDAP_OPERATIONS_ERROR;
  5219. }
  5220. if ( apply ) {
  5221. CFG_LOCK_WRITE(slapdFrontendConfig);
  5222. slapdFrontendConfig->mempool_maxfreelist = maxfreelist;
  5223. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5224. }
  5225. return retVal;
  5226. }
  5227. int
  5228. config_get_mempool_maxfreelist()
  5229. {
  5230. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5231. return slapdFrontendConfig->mempool_maxfreelist;
  5232. }
  5233. long
  5234. config_get_system_page_size()
  5235. {
  5236. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5237. return slapdFrontendConfig->system_page_size;
  5238. }
  5239. int
  5240. config_get_system_page_bits()
  5241. {
  5242. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5243. return slapdFrontendConfig->system_page_bits;
  5244. }
  5245. #endif /* MEMPOOL_EXPERIMENTAL */
  5246. int
  5247. config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply)
  5248. {
  5249. int retVal = LDAP_SUCCESS;
  5250. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5251. retVal = config_set_onoff(attrname,
  5252. value,
  5253. &(slapdFrontendConfig->csnlogging),
  5254. errorbuf,
  5255. apply);
  5256. return retVal;
  5257. }
  5258. int
  5259. config_get_csnlogging()
  5260. {
  5261. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5262. return (int)slapdFrontendConfig->csnlogging;
  5263. }
  5264. int
  5265. config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply)
  5266. {
  5267. int retVal = LDAP_SUCCESS;
  5268. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5269. retVal = config_set_onoff(attrname,
  5270. value,
  5271. &(slapdFrontendConfig->attrname_exceptions),
  5272. errorbuf,
  5273. apply);
  5274. return retVal;
  5275. }
  5276. int
  5277. config_get_attrname_exceptions()
  5278. {
  5279. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5280. return (int)slapdFrontendConfig->attrname_exceptions;
  5281. }
  5282. int
  5283. config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply)
  5284. {
  5285. int val = 0;
  5286. int retVal = LDAP_SUCCESS;
  5287. retVal = config_set_onoff(attrname,
  5288. value,
  5289. &val,
  5290. errorbuf,
  5291. apply);
  5292. if (retVal == LDAP_SUCCESS) {
  5293. set_hash_filters(val);
  5294. }
  5295. return retVal;
  5296. }
  5297. int
  5298. config_get_hash_filters()
  5299. {
  5300. return 0; /* for now */
  5301. }
  5302. int
  5303. config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply)
  5304. {
  5305. int retVal = LDAP_SUCCESS;
  5306. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5307. retVal = config_set_onoff(attrname,
  5308. value,
  5309. &(slapdFrontendConfig->rewrite_rfc1274),
  5310. errorbuf,
  5311. apply);
  5312. return retVal;
  5313. }
  5314. /* we don't worry about another thread changing this flag since it is an
  5315. integer */
  5316. int
  5317. config_get_rewrite_rfc1274()
  5318. {
  5319. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5320. int retVal;
  5321. retVal = (int)slapdFrontendConfig->rewrite_rfc1274;
  5322. return retVal;
  5323. }
  5324. static int
  5325. config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int apply )
  5326. {
  5327. int retVal = LDAP_SUCCESS;
  5328. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5329. retVal = LDAP_OPERATIONS_ERROR;
  5330. } else {
  5331. /*
  5332. * check that the value is one we allow.
  5333. */
  5334. if ( 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_OFF ) &&
  5335. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
  5336. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
  5337. retVal = LDAP_OPERATIONS_ERROR;
  5338. if( errorbuf ) {
  5339. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
  5340. }
  5341. }
  5342. }
  5343. if ( LDAP_SUCCESS == retVal && apply ) {
  5344. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5345. CFG_LOCK_WRITE(slapdFrontendConfig);
  5346. slapi_ch_free( (void **)&slapdFrontendConfig->schemareplace );
  5347. slapdFrontendConfig->schemareplace = slapi_ch_strdup( value );
  5348. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5349. }
  5350. return retVal;
  5351. }
  5352. int
  5353. config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
  5354. char *errorbuf, int apply )
  5355. {
  5356. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5357. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5358. return LDAP_OPERATIONS_ERROR;
  5359. }
  5360. if ( apply ) {
  5361. CFG_LOCK_WRITE(slapdFrontendConfig);
  5362. slapdFrontendConfig->outbound_ldap_io_timeout = atoi( value );
  5363. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5364. }
  5365. return LDAP_SUCCESS;
  5366. }
  5367. int
  5368. config_set_unauth_binds_switch( const char *attrname, char *value,
  5369. char *errorbuf, int apply )
  5370. {
  5371. int retVal = LDAP_SUCCESS;
  5372. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5373. retVal = config_set_onoff(attrname,
  5374. value,
  5375. &(slapdFrontendConfig->allow_unauth_binds),
  5376. errorbuf,
  5377. apply);
  5378. return retVal;
  5379. }
  5380. int
  5381. config_set_require_secure_binds( const char *attrname, char *value,
  5382. char *errorbuf, int apply )
  5383. {
  5384. int retVal = LDAP_SUCCESS;
  5385. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5386. retVal = config_set_onoff(attrname,
  5387. value,
  5388. &(slapdFrontendConfig->require_secure_binds),
  5389. errorbuf,
  5390. apply);
  5391. return retVal;
  5392. }
  5393. int
  5394. config_set_anon_access_switch( const char *attrname, char *value,
  5395. char *errorbuf, int apply )
  5396. {
  5397. int retVal = LDAP_SUCCESS;
  5398. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5399. if (config_value_is_null(attrname, value, errorbuf, 0)) {
  5400. return LDAP_OPERATIONS_ERROR;
  5401. }
  5402. if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
  5403. (strcasecmp(value, "rootdse") != 0)) {
  5404. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5405. "%s: invalid value \"%s\". Valid values are \"on\", "
  5406. "\"off\", or \"rootdse\".", attrname, value);
  5407. retVal = LDAP_OPERATIONS_ERROR;
  5408. }
  5409. if (!apply) {
  5410. /* we can return now if we aren't applying the changes */
  5411. return retVal;
  5412. }
  5413. CFG_LOCK_WRITE(slapdFrontendConfig);
  5414. if (strcasecmp(value, "on") == 0 ) {
  5415. slapdFrontendConfig->allow_anon_access = SLAPD_ANON_ACCESS_ON;
  5416. } else if (strcasecmp(value, "off") == 0 ) {
  5417. slapdFrontendConfig->allow_anon_access = SLAPD_ANON_ACCESS_OFF;
  5418. } else if (strcasecmp(value, "rootdse") == 0) {
  5419. slapdFrontendConfig->allow_anon_access = SLAPD_ANON_ACCESS_ROOTDSE;
  5420. }
  5421. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5422. return retVal;
  5423. }
  5424. int
  5425. config_set_validate_cert_switch( const char *attrname, char *value,
  5426. char *errorbuf, int apply )
  5427. {
  5428. int retVal = LDAP_SUCCESS;
  5429. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5430. if (config_value_is_null(attrname, value, errorbuf, 0)) {
  5431. return LDAP_OPERATIONS_ERROR;
  5432. }
  5433. if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
  5434. (strcasecmp(value, "warn") != 0)) {
  5435. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5436. "%s: invalid value \"%s\". Valid values are \"on\", "
  5437. "\"off\", or \"warn\".", attrname, value);
  5438. retVal = LDAP_OPERATIONS_ERROR;
  5439. }
  5440. if (!apply) {
  5441. /* we can return now if we aren't applying the changes */
  5442. return retVal;
  5443. }
  5444. CFG_LOCK_WRITE(slapdFrontendConfig);
  5445. if (strcasecmp(value, "on") == 0 ) {
  5446. slapdFrontendConfig->validate_cert = SLAPD_VALIDATE_CERT_ON;
  5447. } else if (strcasecmp(value, "off") == 0 ) {
  5448. slapdFrontendConfig->validate_cert = SLAPD_VALIDATE_CERT_OFF;
  5449. } else if (strcasecmp(value, "warn") == 0) {
  5450. slapdFrontendConfig->validate_cert = SLAPD_VALIDATE_CERT_WARN;
  5451. }
  5452. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5453. return retVal;
  5454. }
  5455. int
  5456. config_get_force_sasl_external(void)
  5457. {
  5458. int retVal;
  5459. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5460. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  5461. retVal = (int)slapdFrontendConfig->force_sasl_external;
  5462. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  5463. return retVal;
  5464. }
  5465. int
  5466. config_set_force_sasl_external( const char *attrname, char *value,
  5467. char *errorbuf, int apply )
  5468. {
  5469. int retVal = LDAP_SUCCESS;
  5470. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5471. retVal = config_set_onoff(attrname,
  5472. value,
  5473. &(slapdFrontendConfig->force_sasl_external),
  5474. errorbuf,
  5475. apply);
  5476. return retVal;
  5477. }
  5478. int
  5479. config_get_entryusn_global(void)
  5480. {
  5481. int retVal;
  5482. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5483. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  5484. retVal = (int)slapdFrontendConfig->entryusn_global;
  5485. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  5486. return retVal;
  5487. }
  5488. int
  5489. config_set_entryusn_global( const char *attrname, char *value,
  5490. char *errorbuf, int apply )
  5491. {
  5492. int retVal = LDAP_SUCCESS;
  5493. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5494. retVal = config_set_onoff(attrname, value,
  5495. &(slapdFrontendConfig->entryusn_global),
  5496. errorbuf, apply);
  5497. return retVal;
  5498. }
  5499. char *
  5500. config_get_entryusn_import_init(void)
  5501. {
  5502. char *retVal;
  5503. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5504. CFG_LOCK_READ(slapdFrontendConfig);
  5505. retVal = slapi_ch_strdup(slapdFrontendConfig->entryusn_import_init);
  5506. CFG_UNLOCK_READ(slapdFrontendConfig);
  5507. return retVal;
  5508. }
  5509. int
  5510. config_set_entryusn_import_init( const char *attrname, char *value,
  5511. char *errorbuf, int apply )
  5512. {
  5513. int retVal = LDAP_SUCCESS;
  5514. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5515. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  5516. return LDAP_OPERATIONS_ERROR;
  5517. }
  5518. if (apply) {
  5519. CFG_LOCK_WRITE(slapdFrontendConfig);
  5520. slapi_ch_free_string(&(slapdFrontendConfig->entryusn_import_init));
  5521. slapdFrontendConfig->entryusn_import_init = slapi_ch_strdup(value);
  5522. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5523. }
  5524. return retVal;
  5525. }
  5526. char *
  5527. config_get_allowed_to_delete_attrs(void)
  5528. {
  5529. char *retVal;
  5530. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5531. CFG_LOCK_READ(slapdFrontendConfig);
  5532. retVal = slapi_ch_strdup(slapdFrontendConfig->allowed_to_delete_attrs);
  5533. CFG_UNLOCK_READ(slapdFrontendConfig);
  5534. return retVal;
  5535. }
  5536. int
  5537. config_set_allowed_to_delete_attrs( const char *attrname, char *value,
  5538. char *errorbuf, int apply )
  5539. {
  5540. int retVal = LDAP_SUCCESS;
  5541. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5542. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  5543. return LDAP_OPERATIONS_ERROR;
  5544. }
  5545. if (apply) {
  5546. char *vcopy = slapi_ch_strdup(value);
  5547. char **allowed = NULL, **s, *d;
  5548. struct config_get_and_set *cgas = 0;
  5549. int needcopy = 0;
  5550. allowed = slapi_str2charray_ext(vcopy, " ", 0);
  5551. for (s = allowed; s && *s; s++) ;
  5552. for (--s; s && *s && (s >= allowed); s--) {
  5553. cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash,
  5554. *s);
  5555. if (!cgas && PL_strcasecmp(*s, "aci") /* aci is an exception */) {
  5556. slapi_log_error(SLAPI_LOG_FATAL, "config",
  5557. "%s: Unknown attribute %s will be ignored\n",
  5558. CONFIG_ALLOWED_TO_DELETE_ATTRIBUTE, *s);
  5559. charray_remove(allowed, *s, 1);
  5560. needcopy = 1;
  5561. s--;
  5562. }
  5563. }
  5564. if (needcopy) {
  5565. /* given value included unknown attribute,
  5566. * we need to re-create a value. */
  5567. /* reuse the duplicated string for the new attr value. */
  5568. for (s = allowed, d = vcopy; s && *s; s++) {
  5569. size_t slen = strlen(*s);
  5570. memmove(d, *s, slen);
  5571. d += slen;
  5572. memmove(d, " ", 1);
  5573. d++;
  5574. }
  5575. *(d-1) = '\0';
  5576. strcpy(value, vcopy); /* original value needs to be refreshed */
  5577. } else {
  5578. slapi_ch_free_string(&vcopy);
  5579. vcopy = slapi_ch_strdup(value);
  5580. }
  5581. slapi_ch_array_free(allowed);
  5582. CFG_LOCK_WRITE(slapdFrontendConfig);
  5583. slapi_ch_free_string(&(slapdFrontendConfig->allowed_to_delete_attrs));
  5584. slapdFrontendConfig->allowed_to_delete_attrs = vcopy;
  5585. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5586. }
  5587. return retVal;
  5588. }
  5589. char *
  5590. config_get_allowed_sasl_mechs()
  5591. {
  5592. char *retVal;
  5593. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5594. CFG_LOCK_READ(slapdFrontendConfig);
  5595. retVal = slapdFrontendConfig->allowed_sasl_mechs;
  5596. CFG_UNLOCK_READ(slapdFrontendConfig);
  5597. return retVal;
  5598. }
  5599. /* separated list of sasl mechs to allow */
  5600. int
  5601. config_set_allowed_sasl_mechs(const char *attrname, char *value, char *errorbuf, int apply )
  5602. {
  5603. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5604. if(!apply || slapdFrontendConfig->allowed_sasl_mechs){
  5605. /* we only set this at startup, if we try again just return SUCCESS */
  5606. return LDAP_SUCCESS;
  5607. }
  5608. CFG_LOCK_WRITE(slapdFrontendConfig);
  5609. slapdFrontendConfig->allowed_sasl_mechs = slapi_ch_strdup(value);
  5610. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5611. return LDAP_SUCCESS;
  5612. }
  5613. char *
  5614. config_get_default_naming_context(void)
  5615. {
  5616. char *retVal;
  5617. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5618. CFG_LOCK_READ(slapdFrontendConfig);
  5619. retVal = slapdFrontendConfig->default_naming_context;
  5620. CFG_UNLOCK_READ(slapdFrontendConfig);
  5621. return retVal;
  5622. }
  5623. int
  5624. config_set_default_naming_context(const char *attrname,
  5625. char *value, char *errorbuf, int apply)
  5626. {
  5627. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5628. void *node;
  5629. Slapi_DN *sdn;
  5630. char *suffix = NULL;
  5631. if (value && *value) {
  5632. int in_init = 0;
  5633. suffix = slapi_create_dn_string("%s", value);
  5634. if (NULL == suffix) {
  5635. if (errorbuf) {
  5636. PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5637. "%s is not a valid suffix.", value);
  5638. }
  5639. return LDAP_INVALID_DN_SYNTAX;
  5640. }
  5641. sdn = slapi_get_first_suffix(&node, 0);
  5642. if (NULL == sdn) {
  5643. in_init = 1; /* at the startup time, no suffix is set yet */
  5644. }
  5645. while (sdn) {
  5646. if (0 == strcasecmp(suffix, slapi_sdn_get_dn(sdn))) {
  5647. /* matched */
  5648. break;
  5649. }
  5650. sdn = slapi_get_next_suffix(&node, 0);
  5651. }
  5652. if (!in_init && (NULL == sdn)) { /* not in startup && no match */
  5653. if (errorbuf) {
  5654. PR_snprintf (errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5655. "%s is not an existing suffix.", value);
  5656. }
  5657. slapi_ch_free_string(&suffix);
  5658. return LDAP_NO_SUCH_OBJECT;
  5659. }
  5660. } else {
  5661. /* reset */
  5662. suffix = NULL;
  5663. }
  5664. if (!apply) {
  5665. slapi_ch_free_string(&suffix);
  5666. return LDAP_SUCCESS;
  5667. }
  5668. if (errorbuf) {
  5669. *errorbuf = '\0';
  5670. }
  5671. if (apply) {
  5672. CFG_LOCK_WRITE(slapdFrontendConfig);
  5673. slapi_ch_free_string(&slapdFrontendConfig->default_naming_context);
  5674. /* normalized suffix*/
  5675. slapdFrontendConfig->default_naming_context = suffix;
  5676. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5677. }
  5678. return LDAP_SUCCESS;
  5679. }
  5680. int
  5681. config_set_unhashed_pw_switch(const char *attrname, char *value,
  5682. char *errorbuf, int apply)
  5683. {
  5684. int retVal = LDAP_SUCCESS;
  5685. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5686. if (config_value_is_null(attrname, value, errorbuf, 0)) {
  5687. return LDAP_OPERATIONS_ERROR;
  5688. }
  5689. if ((strcasecmp(value, "on") != 0) && (strcasecmp(value, "off") != 0) &&
  5690. (strcasecmp(value, "nolog") != 0)) {
  5691. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5692. "%s: invalid value \"%s\". Valid values are \"on\", "
  5693. "\"off\", or \"nolog\".", attrname, value);
  5694. retVal = LDAP_OPERATIONS_ERROR;
  5695. }
  5696. if (!apply) {
  5697. /* we can return now if we aren't applying the changes */
  5698. return retVal;
  5699. }
  5700. CFG_LOCK_WRITE(slapdFrontendConfig);
  5701. if (strcasecmp(value, "on") == 0 ) {
  5702. slapdFrontendConfig->unhashed_pw_switch = SLAPD_UNHASHED_PW_ON;
  5703. } else if (strcasecmp(value, "off") == 0 ) {
  5704. slapdFrontendConfig->unhashed_pw_switch = SLAPD_UNHASHED_PW_OFF;
  5705. } else if (strcasecmp(value, "nolog") == 0) {
  5706. slapdFrontendConfig->unhashed_pw_switch = SLAPD_UNHASHED_PW_NOLOG;
  5707. }
  5708. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  5709. return retVal;
  5710. }
  5711. int
  5712. config_get_enable_turbo_mode(void)
  5713. {
  5714. int retVal;
  5715. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5716. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  5717. retVal = (int)slapdFrontendConfig->enable_turbo_mode;
  5718. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  5719. return retVal;
  5720. }
  5721. int
  5722. config_get_connection_nocanon(void)
  5723. {
  5724. int retVal;
  5725. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5726. CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
  5727. retVal = (int)slapdFrontendConfig->connection_nocanon;
  5728. CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
  5729. return retVal;
  5730. }
  5731. int
  5732. slapi_config_get_unhashed_pw_switch()
  5733. {
  5734. return config_get_unhashed_pw_switch();
  5735. }
  5736. int
  5737. config_get_unhashed_pw_switch()
  5738. {
  5739. int retVal = 0;
  5740. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5741. CFG_LOCK_READ(slapdFrontendConfig);
  5742. retVal = slapdFrontendConfig->unhashed_pw_switch;
  5743. CFG_UNLOCK_READ(slapdFrontendConfig);
  5744. return retVal;
  5745. }
  5746. int
  5747. config_set_enable_turbo_mode( const char *attrname, char *value,
  5748. char *errorbuf, int apply )
  5749. {
  5750. int retVal = LDAP_SUCCESS;
  5751. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5752. retVal = config_set_onoff(attrname, value,
  5753. &(slapdFrontendConfig->enable_turbo_mode),
  5754. errorbuf, apply);
  5755. return retVal;
  5756. }
  5757. int
  5758. config_set_connection_nocanon( const char *attrname, char *value,
  5759. char *errorbuf, int apply )
  5760. {
  5761. int retVal = LDAP_SUCCESS;
  5762. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5763. retVal = config_set_onoff(attrname, value,
  5764. &(slapdFrontendConfig->connection_nocanon),
  5765. errorbuf, apply);
  5766. return retVal;
  5767. }
  5768. int
  5769. config_get_connection_buffer(void)
  5770. {
  5771. int retVal;
  5772. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5773. retVal = (int)slapdFrontendConfig->connection_buffer;
  5774. return retVal;
  5775. }
  5776. int
  5777. config_set_connection_buffer( const char *attrname, char *value,
  5778. char *errorbuf, int apply )
  5779. {
  5780. int retVal = LDAP_SUCCESS;
  5781. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  5782. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  5783. return LDAP_OPERATIONS_ERROR;
  5784. }
  5785. if ((strcasecmp(value, "0") != 0) && (strcasecmp(value, "1") != 0) &&
  5786. (strcasecmp(value, "2") != 0)) {
  5787. PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  5788. "%s: invalid value \"%s\". Valid values are \"0\", "
  5789. "\"1\", or \"2\".", attrname, value);
  5790. retVal = LDAP_OPERATIONS_ERROR;
  5791. }
  5792. if ( !apply ) {
  5793. return retVal;
  5794. }
  5795. PR_AtomicSet(&slapdFrontendConfig->connection_buffer, atoi(value));
  5796. return retVal;
  5797. }
  5798. /*
  5799. * This function is intended to be used from the dse code modify callback. It
  5800. * is "optimized" for that case because it takes a berval** of values, which is
  5801. * currently what is used by ldapmod to hold the values. We could easily switch
  5802. * this to take a Slapi_Value array or even a Slapi_Attr. Most config params
  5803. * have simple config_set_XXX functions which take a char* argument holding the
  5804. * value. The log_set_XXX functions have an additional parameter which
  5805. * discriminates the log to use. The config parameters with types CONFIG_SPECIAL_XXX
  5806. * require special handling to set their values.
  5807. */
  5808. int
  5809. config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
  5810. {
  5811. int ii = 0;
  5812. int retval = LDAP_SUCCESS;
  5813. struct config_get_and_set *cgas = 0;
  5814. cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash, attr);
  5815. if (!cgas)
  5816. {
  5817. #if 0
  5818. debugHashTable(attr);
  5819. #endif
  5820. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
  5821. slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
  5822. return LDAP_NO_SUCH_ATTRIBUTE;
  5823. }
  5824. switch (cgas->config_var_type)
  5825. {
  5826. case CONFIG_SPECIAL_REFERRALLIST:
  5827. if (NULL == values) /* special token which means to remove referrals */
  5828. {
  5829. struct berval val;
  5830. struct berval *vals[2] = {0, 0};
  5831. vals[0] = &val;
  5832. val.bv_val = REFERRAL_REMOVE_CMD;
  5833. val.bv_len = strlen(REFERRAL_REMOVE_CMD);
  5834. retval = config_set_defaultreferral(attr, vals, errorbuf, apply);
  5835. }
  5836. else
  5837. {
  5838. retval = config_set_defaultreferral(attr, values, errorbuf, apply);
  5839. }
  5840. break;
  5841. default:
  5842. if ((NULL == values) &&
  5843. config_allowed_to_delete_attrs(cgas->attr_name)) {
  5844. if (cgas->setfunc) {
  5845. retval = (cgas->setfunc)(cgas->attr_name, cgas->initvalue,
  5846. errorbuf, apply);
  5847. } else if (cgas->logsetfunc) {
  5848. retval = (cgas->logsetfunc)(cgas->attr_name, cgas->initvalue,
  5849. cgas->whichlog, errorbuf, apply);
  5850. } else {
  5851. LDAPDebug1Arg(LDAP_DEBUG_ANY,
  5852. "config_set: the attribute %s is read only; "
  5853. "ignoring setting NULL value\n", attr);
  5854. }
  5855. }
  5856. for (ii = 0; !retval && values && values[ii]; ++ii)
  5857. {
  5858. if (cgas->setfunc) {
  5859. retval = (cgas->setfunc)(cgas->attr_name,
  5860. (char *)values[ii]->bv_val, errorbuf, apply);
  5861. } else if (cgas->logsetfunc) {
  5862. retval = (cgas->logsetfunc)(cgas->attr_name,
  5863. (char *)values[ii]->bv_val, cgas->whichlog,
  5864. errorbuf, apply);
  5865. } else {
  5866. LDAPDebug(LDAP_DEBUG_ANY,
  5867. "config_set: the attribute %s is read only; ignoring new value %s\n",
  5868. attr, values[ii]->bv_val, 0);
  5869. }
  5870. values[ii]->bv_len = strlen((char *)values[ii]->bv_val);
  5871. }
  5872. break;
  5873. }
  5874. return retval;
  5875. }
  5876. static void
  5877. config_set_value(
  5878. Slapi_Entry *e,
  5879. struct config_get_and_set *cgas,
  5880. void **value
  5881. )
  5882. {
  5883. struct berval **values = 0;
  5884. char *sval = 0;
  5885. int ival = 0;
  5886. uintptr_t pval;
  5887. switch (cgas->config_var_type) {
  5888. case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */
  5889. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  5890. (value && *((int *)value)) ? "on" : "off");
  5891. break;
  5892. case CONFIG_INT:
  5893. if (value)
  5894. slapi_entry_attr_set_int(e, cgas->attr_name, *((int *)value));
  5895. else
  5896. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5897. break;
  5898. case CONFIG_LONG:
  5899. if (value)
  5900. slapi_entry_attr_set_long(e, cgas->attr_name, *((long *)value));
  5901. else
  5902. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5903. break;
  5904. case CONFIG_STRING:
  5905. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  5906. (value && *((char **)value)) ?
  5907. *((char **)value) : "");
  5908. break;
  5909. case CONFIG_CHARRAY:
  5910. if (value) {
  5911. values = strarray2bervalarray((const char **)*((char ***)value));
  5912. if (!values) {
  5913. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5914. } else {
  5915. slapi_entry_attr_replace(e, cgas->attr_name, values);
  5916. bervalarray_free(values);
  5917. }
  5918. } else {
  5919. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5920. }
  5921. break;
  5922. case CONFIG_SPECIAL_REFERRALLIST:
  5923. /* referral list is already an array of berval* */
  5924. if (value)
  5925. slapi_entry_attr_replace(e, cgas->attr_name, (struct berval**)*value);
  5926. else
  5927. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5928. break;
  5929. case CONFIG_CONSTANT_STRING:
  5930. PR_ASSERT(value); /* should be a constant value */
  5931. slapi_entry_attr_set_charptr(e, cgas->attr_name, (char*)value);
  5932. break;
  5933. case CONFIG_CONSTANT_INT:
  5934. PR_ASSERT(value); /* should be a constant value */
  5935. pval = (uintptr_t)value;
  5936. ival = (int)pval;
  5937. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  5938. break;
  5939. case CONFIG_SPECIAL_SSLCLIENTAUTH:
  5940. if (!value) {
  5941. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  5942. break;
  5943. }
  5944. if (*((int *)value) == SLAPD_SSLCLIENTAUTH_ALLOWED) {
  5945. sval = "allowed";
  5946. } else if (*((int *)value) == SLAPD_SSLCLIENTAUTH_REQUIRED) {
  5947. sval = "required";
  5948. } else {
  5949. sval = "off";
  5950. }
  5951. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  5952. break;
  5953. case CONFIG_STRING_OR_OFF:
  5954. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  5955. (value && *((char **)value)) ?
  5956. *((char **)value) : "off");
  5957. break;
  5958. case CONFIG_STRING_OR_EMPTY:
  5959. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  5960. (value && *((char **)value)) ?
  5961. *((char **)value) : "");
  5962. break;
  5963. case CONFIG_STRING_OR_UNKNOWN:
  5964. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  5965. (value && *((char **)value)) ?
  5966. *((char **)value) : "unknown");
  5967. break;
  5968. case CONFIG_SPECIAL_ERRORLOGLEVEL:
  5969. if (value) {
  5970. int ival = *(int *)value;
  5971. ival &= ~LDAP_DEBUG_ANY;
  5972. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  5973. }
  5974. else
  5975. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  5976. break;
  5977. case CONFIG_SPECIAL_ANON_ACCESS_SWITCH:
  5978. if (!value) {
  5979. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  5980. break;
  5981. }
  5982. if (*((int *)value) == SLAPD_ANON_ACCESS_ON) {
  5983. sval = "on";
  5984. } else if (*((int *)value) == SLAPD_ANON_ACCESS_ROOTDSE) {
  5985. sval = "rootdse";
  5986. } else {
  5987. sval = "off";
  5988. }
  5989. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  5990. break;
  5991. case CONFIG_SPECIAL_UNHASHED_PW_SWITCH:
  5992. if (!value) {
  5993. slapi_entry_attr_set_charptr(e, cgas->attr_name, "on");
  5994. break;
  5995. }
  5996. if (*((int *)value) == SLAPD_UNHASHED_PW_OFF) {
  5997. sval = "off";
  5998. } else if (*((int *)value) == SLAPD_UNHASHED_PW_NOLOG) {
  5999. sval = "nolog";
  6000. } else {
  6001. sval = "on";
  6002. }
  6003. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  6004. break;
  6005. case CONFIG_SPECIAL_VALIDATE_CERT_SWITCH:
  6006. if (!value) {
  6007. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  6008. break;
  6009. }
  6010. if (*((int *)value) == SLAPD_VALIDATE_CERT_ON) {
  6011. sval = "on";
  6012. } else if (*((int *)value) == SLAPD_VALIDATE_CERT_WARN) {
  6013. sval = "warn";
  6014. } else {
  6015. sval = "off";
  6016. }
  6017. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  6018. break;
  6019. default:
  6020. PR_ASSERT(0); /* something went horribly wrong . . . */
  6021. break;
  6022. }
  6023. return;
  6024. }
  6025. /*
  6026. * Fill in the given slapi_entry with the config attributes and values
  6027. */
  6028. int
  6029. config_set_entry(Slapi_Entry *e)
  6030. {
  6031. int ii = 0;
  6032. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  6033. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  6034. /*
  6035. * Avoid recursive calls to the readers/writer
  6036. * lock as it causes deadlock under stress. Each
  6037. * individual config get function acquires a read
  6038. * lock where necessary.
  6039. */
  6040. /*
  6041. * Pass 1: Values which do not have a get function.
  6042. */
  6043. CFG_LOCK_READ(slapdFrontendConfig);
  6044. for (ii = 0; ii < tablesize; ++ii) {
  6045. struct config_get_and_set *cgas = &ConfigList[ii];
  6046. void **value = 0;
  6047. PR_ASSERT(cgas);
  6048. value = cgas->config_var_addr;
  6049. PR_ASSERT(cgas->attr_name);
  6050. /* Skip values handled in pass 2 */
  6051. if (NULL == value && cgas->getfunc) {
  6052. continue;
  6053. }
  6054. config_set_value(e, cgas, value);
  6055. }
  6056. CFG_UNLOCK_READ(slapdFrontendConfig);
  6057. /*
  6058. * Pass 2: Values which do have a get function.
  6059. */
  6060. for (ii = 0; ii < tablesize; ++ii) {
  6061. struct config_get_and_set *cgas = &ConfigList[ii];
  6062. int ival = 0;
  6063. long lval = 0;
  6064. void **value = NULL;
  6065. void *alloc_val = NULL;
  6066. int needs_free = 0;
  6067. PR_ASSERT(cgas);
  6068. value = cgas->config_var_addr;
  6069. PR_ASSERT(cgas->attr_name);
  6070. /* Skip values handled in pass 1 */
  6071. if (NULL != value || cgas->getfunc == NULL) {
  6072. continue;
  6073. }
  6074. /* must cast return of getfunc and store in variable of correct sized type */
  6075. /* otherwise endianness problems will ensue */
  6076. if (isInt(cgas->config_var_type)) {
  6077. ival = (int)(intptr_t)(cgas->getfunc)();
  6078. value = (void **)&ival; /* value must be address of int */
  6079. } else if (cgas->config_var_type == CONFIG_LONG) {
  6080. lval = (long)(intptr_t)(cgas->getfunc)();
  6081. value = (void **)&lval; /* value must be address of long */
  6082. } else {
  6083. alloc_val = (cgas->getfunc)();
  6084. value = &alloc_val; /* value must be address of pointer */
  6085. needs_free = 1; /* get funcs must return alloc'd memory except for get
  6086. funcs which return a simple integral type e.g. int */
  6087. }
  6088. config_set_value(e, cgas, value);
  6089. if (needs_free && value) { /* assumes memory allocated by slapi_ch_Xalloc */
  6090. if (CONFIG_CHARRAY == cgas->config_var_type) {
  6091. charray_free((char **)*value);
  6092. } else if (CONFIG_SPECIAL_REFERRALLIST == cgas->config_var_type) {
  6093. ber_bvecfree((struct berval **)*value);
  6094. } else if ((CONFIG_CONSTANT_INT != cgas->config_var_type) && /* do not free constants */
  6095. (CONFIG_CONSTANT_STRING != cgas->config_var_type)) {
  6096. slapi_ch_free(value);
  6097. }
  6098. }
  6099. }
  6100. return 1;
  6101. }
  6102. /* these attr types are allowed to delete */
  6103. int
  6104. config_allowed_to_delete_attrs(const char *attr_type)
  6105. {
  6106. int rc = 0;
  6107. if (attr_type) {
  6108. char *delattrs = config_get_allowed_to_delete_attrs();
  6109. char **allowed = slapi_str2charray_ext(delattrs, " ", 0);
  6110. char **ap;
  6111. for (ap = allowed; ap && *ap; ap++) {
  6112. if (strcasecmp (attr_type, *ap) == 0) {
  6113. rc = 1;
  6114. break;
  6115. }
  6116. }
  6117. slapi_ch_array_free(allowed);
  6118. slapi_ch_free_string(&delattrs);
  6119. }
  6120. return rc;
  6121. }
  6122. void
  6123. config_set_accesslog_enabled(int value){
  6124. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  6125. char errorbuf[BUFSIZ];
  6126. CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
  6127. slapdFrontendConfig->accesslog_logging_enabled = (int)value;
  6128. if(value){
  6129. log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY);
  6130. } else {
  6131. log_set_logging(CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_ACCESS_LOG, errorbuf, CONFIG_APPLY);
  6132. }
  6133. CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig);
  6134. }
  6135. void
  6136. config_set_auditlog_enabled(int value){
  6137. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  6138. char errorbuf[BUFSIZ];
  6139. CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);
  6140. slapdFrontendConfig->auditlog_logging_enabled = (int)value;
  6141. if(value){
  6142. log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "on", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY);
  6143. } else {
  6144. log_set_logging(CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, "off", SLAPD_AUDIT_LOG, errorbuf, CONFIG_APPLY);
  6145. }
  6146. CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig);
  6147. }
  6148. char *
  6149. slapi_err2string(int result)
  6150. {
  6151. /*
  6152. * If we are using openldap, then we can safely use ldap_err2string with
  6153. * positive and negative result codes. MozLDAP's ldap_err2string can
  6154. * only handle positive result codes.
  6155. */
  6156. #if defined (USE_OPENLDAP)
  6157. return ldap_err2string(result);
  6158. #else
  6159. if(result >= 0){
  6160. return ldap_err2string(result);
  6161. }
  6162. switch (result)
  6163. {
  6164. case -1:
  6165. return ("Can't contact LDAP server");
  6166. case -2:
  6167. return ("Local error");
  6168. case -3:
  6169. return ("Encoding error");
  6170. case -4:
  6171. return ("Decoding error");
  6172. case -5:
  6173. return ("Timed out");
  6174. case -6:
  6175. return ("Unknown authentication method");
  6176. case -7:
  6177. return ("Bad search filter");
  6178. case -8:
  6179. return ("User canceled operation");
  6180. case -9:
  6181. return ("Bad parameter to an ldap routine");
  6182. case -10:
  6183. return ("Out of memory");
  6184. case -11:
  6185. return ("Connect error");
  6186. case -12:
  6187. return ("Not Supported");
  6188. case -13:
  6189. return ("Control not found");
  6190. case -14:
  6191. return ("No results returned");
  6192. case -15:
  6193. return ("More results to return");
  6194. case -16:
  6195. return ("Client Loop");
  6196. case -17:
  6197. return ("Referral Limit Exceeded");
  6198. default:
  6199. return ("Unknown system error");
  6200. }
  6201. #endif
  6202. }