libglobs.c 241 KB

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