libglobs.c 288 KB

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