| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629 |
- /** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
- /*
- *
- * libglobs.c -- SLAPD library global variables
- */
- /* for windows only
- we define slapd_ldap_debug here, so we don't want to declare
- it in any header file which might conflict with our definition
- */
- #define DONT_DECLARE_SLAPD_LDAP_DEBUG /* see ldaplog.h */
- #include "ldap.h"
- #include <sslproto.h>
- #undef OFF
- #undef LITTLE_ENDIAN
- #include <stdio.h>
- #include <string.h>
- #include <sys/types.h>
- #include <time.h>
- #include <stdarg.h>
- #include <stdlib.h>
- #if defined( _WIN32 )
- #define R_OK 04
- #include "ntslapdmessages.h"
- #include "proto-ntutil.h"
- #else
- #include <sys/time.h>
- #include <sys/param.h> /* MAXPATHLEN */
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <unistd.h>
- #include <pwd.h> /* pwdnam */
- #endif
- #ifdef USE_SYSCONF
- #include <unistd.h>
- #endif /* USE_SYSCONF */
- #include "slap.h"
- #include "plhash.h"
- #define REMOVE_CHANGELOG_CMD "remove"
- /* On UNIX, there's only one copy of slapd_ldap_debug */
- /* On NT, each module keeps its own module_ldap_debug, which */
- /* points to the process' slapd_ldap_debug */
- #ifdef _WIN32
- int *module_ldap_debug;
- int __declspec(dllexport) slapd_ldap_debug = LDAP_DEBUG_ANY;
- #else
- int slapd_ldap_debug = LDAP_DEBUG_ANY;
- #endif
- char *ldap_srvtab = "";
- /* Note that the 'attrname' arguments are used only for log messages */
- typedef int (*ConfigSetFunc)(const char *attrname, char *value,
- char *errorbuf, int apply);
- typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
- char *errorbuf, int apply);
- typedef enum {
- CONFIG_INT, /* maps to int */
- CONFIG_LONG, /* maps to long */
- CONFIG_STRING, /* maps to char* */
- CONFIG_CHARRAY, /* maps to char** */
- CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
- CONFIG_STRING_OR_OFF, /* use "off" instead of null or an empty string */
- CONFIG_STRING_OR_UNKNOWN, /* use "unknown" instead of an empty string */
- CONFIG_CONSTANT_INT, /* for #define values, e.g. */
- CONFIG_CONSTANT_STRING, /* for #define values, e.g. */
- CONFIG_SPECIAL_REFERRALLIST, /* this is a berval list */
- CONFIG_SPECIAL_SSLCLIENTAUTH, /* maps strings to an enumeration */
- CONFIG_SPECIAL_ERRORLOGLEVEL, /* requires & with LDAP_DEBUG_ANY */
- CONFIG_STRING_OR_EMPTY /* use an empty string */
- } ConfigVarType;
- static int config_set_onoff( const char *attrname, char *value,
- int *configvalue, char *errorbuf, int apply );
- static int config_set_schemareplace ( const char *attrname, char *value,
- char *errorbuf, int apply );
- static int
- isInt(ConfigVarType type)
- {
- return type == CONFIG_INT || type == CONFIG_ON_OFF || type == CONFIG_SPECIAL_SSLCLIENTAUTH || type == CONFIG_SPECIAL_ERRORLOGLEVEL;
- }
- /* the caller will typically have to cast the result based on the ConfigVarType */
- typedef void *(*ConfigGetFunc)(void);
- /* static Ref_Array global_referrals; */
- static slapdFrontendConfig_t global_slapdFrontendConfig;
- static struct config_get_and_set {
- const char *attr_name; /* the name of the attribute */
- ConfigSetFunc setfunc; /* the function to call to set the value */
- LogSetFunc logsetfunc; /* log functions are special */
- int whichlog; /* ACCESS, ERROR, AUDIT, etc. */
- void** config_var_addr; /* address of member of slapdFrontendConfig struct */
- ConfigVarType config_var_type; /* cast to this type when getting */
- ConfigGetFunc getfunc; /* for special handling */
- } ConfigList[] = {
- {CONFIG_AUDITLOG_MODE_ATTRIBUTE, NULL,
- log_set_mode, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_mode, CONFIG_STRING, NULL},
- {CONFIG_AUDITLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
- log_set_rotationsync_enabled, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_AUDITLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
- log_set_rotationsynchour, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_rotationsynchour, CONFIG_INT, NULL},
- {CONFIG_AUDITLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
- log_set_rotationsyncmin, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_rotationsyncmin, CONFIG_INT, NULL},
- {CONFIG_AUDITLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
- log_set_rotationtime, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_rotationtime, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_MODE_ATTRIBUTE, NULL,
- log_set_mode, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_mode, CONFIG_STRING, NULL},
- {CONFIG_ACCESSLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
- log_set_numlogsperdir, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_maxnumlogs, CONFIG_INT, NULL},
- {CONFIG_LOGLEVEL_ATTRIBUTE, config_set_errorlog_level,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.errorloglevel,
- CONFIG_SPECIAL_ERRORLOGLEVEL, NULL},
- {CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
- log_set_logging, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_logging_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_ERRORLOG_MODE_ATTRIBUTE, NULL,
- log_set_mode, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_mode, CONFIG_STRING, NULL},
- {CONFIG_ERRORLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
- log_set_expirationtime, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_exptime, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
- log_set_logging, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_logging_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_PORT_ATTRIBUTE, config_set_port,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.port, CONFIG_INT, NULL},
- {CONFIG_WORKINGDIR_ATTRIBUTE, config_set_workingdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.workingdir, CONFIG_STRING_OR_EMPTY, NULL},
- {CONFIG_MAXTHREADSPERCONN_ATTRIBUTE, config_set_maxthreadsperconn,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.maxthreadsperconn, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
- log_set_expirationtime, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_exptime, CONFIG_INT, NULL},
- #ifndef _WIN32
- {CONFIG_LOCALUSER_ATTRIBUTE, config_set_localuser,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.localuser, CONFIG_STRING, NULL},
- #endif
- {CONFIG_ERRORLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
- log_set_rotationsync_enabled, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_ERRORLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
- log_set_rotationsynchour, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_rotationsynchour, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
- log_set_rotationsyncmin, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_rotationsyncmin, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
- log_set_rotationtime, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_rotationtime, CONFIG_INT, NULL},
- {CONFIG_PW_INHISTORY_ATTRIBUTE, config_set_pw_inhistory,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_inhistory, CONFIG_INT, NULL},
- {CONFIG_PW_STORAGESCHEME_ATTRIBUTE, config_set_pw_storagescheme,
- NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_pw_storagescheme},
- {CONFIG_PW_UNLOCK_ATTRIBUTE, config_set_pw_unlock,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_unlock, CONFIG_ON_OFF, NULL},
- {CONFIG_PW_GRACELIMIT_ATTRIBUTE, config_set_pw_gracelimit,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_gracelimit, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGROTATIONSYNCENABLED_ATTRIBUTE, NULL,
- log_set_rotationsync_enabled, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_rotationsync_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_ACCESSLOG_LOGROTATIONSYNCHOUR_ATTRIBUTE, NULL,
- log_set_rotationsynchour, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_rotationsynchour, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGROTATIONSYNCMIN_ATTRIBUTE, NULL,
- log_set_rotationsyncmin, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_rotationsyncmin, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGROTATIONTIME_ATTRIBUTE, NULL,
- log_set_rotationtime, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_rotationtime, CONFIG_INT, NULL},
- {CONFIG_PW_MUSTCHANGE_ATTRIBUTE, config_set_pw_must_change,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_must_change, CONFIG_ON_OFF, NULL},
- {CONFIG_PWPOLICY_LOCAL_ATTRIBUTE, config_set_pwpolicy_local,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pwpolicy_local, CONFIG_ON_OFF, NULL},
- {CONFIG_AUDITLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
- log_set_maxdiskspace, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_maxdiskspace, CONFIG_INT, NULL},
- {CONFIG_SIZELIMIT_ATTRIBUTE, config_set_sizelimit,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.sizelimit, CONFIG_INT, NULL},
- {CONFIG_AUDITLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
- log_set_logsize, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_maxlogsize, CONFIG_INT, NULL},
- {CONFIG_PW_WARNING_ATTRIBUTE, config_set_pw_warning,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_warning, CONFIG_LONG, NULL},
- {CONFIG_READONLY_ATTRIBUTE, config_set_readonly,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.readonly, CONFIG_ON_OFF, NULL},
- {CONFIG_THREADNUMBER_ATTRIBUTE, config_set_threadnumber,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.threadnumber, CONFIG_INT, NULL},
- {CONFIG_PW_LOCKOUT_ATTRIBUTE, config_set_pw_lockout,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_lockout, CONFIG_ON_OFF, NULL},
- {CONFIG_ENQUOTE_SUP_OC_ATTRIBUTE, config_set_enquote_sup_oc,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.enquote_sup_oc, CONFIG_ON_OFF, NULL},
- {CONFIG_LOCALHOST_ATTRIBUTE, config_set_localhost,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.localhost, CONFIG_STRING, NULL},
- {CONFIG_IOBLOCKTIMEOUT_ATTRIBUTE, config_set_ioblocktimeout,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ioblocktimeout, CONFIG_INT, NULL},
- {CONFIG_MAX_FILTER_NEST_LEVEL_ATTRIBUTE, config_set_max_filter_nest_level,
- NULL, 0, (void**)&global_slapdFrontendConfig.max_filter_nest_level,
- CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
- log_set_maxdiskspace, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_maxdiskspace, CONFIG_INT, NULL},
- {CONFIG_PW_MINLENGTH_ATTRIBUTE, config_set_pw_minlength,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minlength, CONFIG_INT, NULL},
- {CONFIG_PW_MINDIGITS_ATTRIBUTE, config_set_pw_mindigits,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_mindigits, CONFIG_INT, NULL},
- {CONFIG_PW_MINALPHAS_ATTRIBUTE, config_set_pw_minalphas,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minalphas, CONFIG_INT, NULL},
- {CONFIG_PW_MINUPPERS_ATTRIBUTE, config_set_pw_minuppers,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minuppers, CONFIG_INT, NULL},
- {CONFIG_PW_MINLOWERS_ATTRIBUTE, config_set_pw_minlowers,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minlowers, CONFIG_INT, NULL},
- {CONFIG_PW_MINSPECIALS_ATTRIBUTE, config_set_pw_minspecials,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minspecials, CONFIG_INT, NULL},
- {CONFIG_PW_MIN8BIT_ATTRIBUTE, config_set_pw_min8bit,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_min8bit, CONFIG_INT, NULL},
- {CONFIG_PW_MAXREPEATS_ATTRIBUTE, config_set_pw_maxrepeats,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_maxrepeats, CONFIG_INT, NULL},
- {CONFIG_PW_MINCATEGORIES_ATTRIBUTE, config_set_pw_mincategories,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_mincategories, CONFIG_INT, NULL},
- {CONFIG_PW_MINTOKENLENGTH_ATTRIBUTE, config_set_pw_mintokenlength,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_mintokenlength, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_ATTRIBUTE, config_set_errorlog,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.errorlog, CONFIG_STRING_OR_EMPTY, NULL},
- {CONFIG_AUDITLOG_LOGEXPIRATIONTIME_ATTRIBUTE, NULL,
- log_set_expirationtime, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_exptime, CONFIG_INT, NULL},
- {CONFIG_SCHEMACHECK_ATTRIBUTE, config_set_schemacheck,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.schemacheck, CONFIG_ON_OFF, NULL},
- {CONFIG_SYNTAXCHECK_ATTRIBUTE, config_set_syntaxcheck,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.syntaxcheck, CONFIG_ON_OFF, NULL},
- {CONFIG_SYNTAXLOGGING_ATTRIBUTE, config_set_syntaxlogging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.syntaxlogging, CONFIG_ON_OFF, NULL},
- {CONFIG_DN_VALIDATE_STRICT_ATTRIBUTE, config_set_dn_validate_strict,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.dn_validate_strict, CONFIG_ON_OFF, NULL},
- {CONFIG_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ds4_compatible_schema,
- CONFIG_ON_OFF, NULL},
- {CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
- config_set_schema_ignore_trailing_spaces, NULL, 0,
- (void**)&global_slapdFrontendConfig.schema_ignore_trailing_spaces,
- CONFIG_ON_OFF, NULL},
- {CONFIG_SCHEMAREPLACE_ATTRIBUTE, config_set_schemareplace, NULL, 0,
- (void**)&global_slapdFrontendConfig.schemareplace,
- CONFIG_STRING_OR_OFF, NULL},
- {CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
- log_set_maxdiskspace, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_maxdiskspace, CONFIG_INT, NULL},
- {CONFIG_REFERRAL_ATTRIBUTE, (ConfigSetFunc)config_set_defaultreferral,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.defaultreferral,
- CONFIG_SPECIAL_REFERRALLIST, NULL},
- {CONFIG_PW_MAXFAILURE_ATTRIBUTE, config_set_pw_maxfailure,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_maxfailure, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_ATTRIBUTE, config_set_accesslog,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.accesslog, CONFIG_STRING_OR_EMPTY, NULL},
- {CONFIG_LASTMOD_ATTRIBUTE, config_set_lastmod,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.lastmod, CONFIG_ON_OFF, NULL},
- {CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
- NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme},
- {CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_history, CONFIG_ON_OFF, NULL},
- {CONFIG_SECURITY_ATTRIBUTE, config_set_security,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.security, CONFIG_ON_OFF, NULL},
- {CONFIG_PW_MAXAGE_ATTRIBUTE, config_set_pw_maxage,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_maxage, CONFIG_LONG, NULL},
- {CONFIG_AUDITLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_rotationtimeunit, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_rotationunit,
- CONFIG_STRING_OR_UNKNOWN, NULL},
- {CONFIG_PW_RESETFAILURECOUNT_ATTRIBUTE, config_set_pw_resetfailurecount,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_resetfailurecount, CONFIG_LONG, NULL},
- {CONFIG_PW_ISGLOBAL_ATTRIBUTE, config_set_pw_is_global_policy,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_is_global_policy, CONFIG_ON_OFF, NULL},
- {CONFIG_AUDITLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
- log_set_numlogsperdir, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_maxnumlogs, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_expirationtimeunit, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_exptimeunit,
- CONFIG_STRING_OR_UNKNOWN, NULL},
- /* errorlog list is read only, so no set func and no config var addr */
- {CONFIG_ERRORLOG_LIST_ATTRIBUTE, NULL, NULL, 0, NULL,
- CONFIG_CHARRAY, (ConfigGetFunc)config_get_errorlog_list},
- {CONFIG_GROUPEVALNESTLEVEL_ATTRIBUTE, config_set_groupevalnestlevel,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.groupevalnestlevel, CONFIG_INT, NULL},
- {CONFIG_ACCESSLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_expirationtimeunit, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_exptimeunit,
- CONFIG_STRING_OR_UNKNOWN, NULL},
- {CONFIG_ROOTPW_ATTRIBUTE, config_set_rootpw,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.rootpw, CONFIG_STRING, NULL},
- {CONFIG_PW_CHANGE_ATTRIBUTE, config_set_pw_change,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_change, CONFIG_ON_OFF, NULL},
- {CONFIG_ACCESSLOGLEVEL_ATTRIBUTE, config_set_accesslog_level,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.accessloglevel, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_rotationtimeunit, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_rotationunit,
- CONFIG_STRING_OR_UNKNOWN, NULL},
- {CONFIG_SECUREPORT_ATTRIBUTE, config_set_secureport,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.secureport, CONFIG_INT, NULL},
- {CONFIG_BASEDN_ATTRIBUTE, config_set_basedn,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.certmap_basedn, CONFIG_STRING, NULL},
- {CONFIG_TIMELIMIT_ATTRIBUTE, config_set_timelimit,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.timelimit, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
- log_set_logsize, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_maxlogsize, CONFIG_INT, NULL},
- {CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE, config_set_reservedescriptors,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.reservedescriptors, CONFIG_INT, NULL},
- /* access log list is read only, no set func, no config var addr */
- {CONFIG_ACCESSLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
- NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_accesslog_list},
- {CONFIG_SVRTAB_ATTRIBUTE, config_set_srvtab,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.srvtab, CONFIG_STRING, NULL},
- {CONFIG_PW_EXP_ATTRIBUTE, config_set_pw_exp,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_exp, CONFIG_ON_OFF, NULL},
- {CONFIG_ACCESSCONTROL_ATTRIBUTE, config_set_accesscontrol,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.accesscontrol, CONFIG_ON_OFF, NULL},
- {CONFIG_AUDITLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
- NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_auditlog_list},
- {CONFIG_ACCESSLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_rotationtimeunit, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_rotationunit, CONFIG_STRING, NULL},
- {CONFIG_PW_LOCKDURATION_ATTRIBUTE, config_set_pw_lockduration,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_lockduration, CONFIG_LONG, NULL},
- {CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
- log_set_logsize, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_maxlogsize, CONFIG_INT, NULL},
- {CONFIG_IDLETIMEOUT_ATTRIBUTE, config_set_idletimeout,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.idletimeout, CONFIG_INT, NULL},
- {CONFIG_NAGLE_ATTRIBUTE, config_set_nagle,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.nagle, CONFIG_ON_OFF, NULL},
- {CONFIG_ERRORLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
- log_set_mindiskspace, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_minfreespace, CONFIG_INT, NULL},
- {CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
- log_set_logging, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_logging_enabled, CONFIG_ON_OFF, NULL},
- {CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL},
- {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.csnlogging, CONFIG_ON_OFF, NULL},
- {CONFIG_AUDITLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
- log_set_expirationtimeunit, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_exptimeunit,
- CONFIG_STRING_OR_UNKNOWN, NULL},
- {CONFIG_PW_SYNTAX_ATTRIBUTE, config_set_pw_syntax,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_syntax, CONFIG_ON_OFF, NULL},
- {CONFIG_LISTENHOST_ATTRIBUTE, config_set_listenhost,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.listenhost, CONFIG_STRING, NULL},
- {CONFIG_LDAPI_FILENAME_ATTRIBUTE, config_set_ldapi_filename,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_filename, CONFIG_STRING, NULL},
- {CONFIG_LDAPI_SWITCH_ATTRIBUTE, config_set_ldapi_switch,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_switch, CONFIG_ON_OFF, NULL},
- {CONFIG_LDAPI_BIND_SWITCH_ATTRIBUTE, config_set_ldapi_bind_switch,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_bind_switch, CONFIG_ON_OFF, NULL},
- {CONFIG_LDAPI_ROOT_DN_ATTRIBUTE, config_set_ldapi_root_dn,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_root_dn, CONFIG_STRING, NULL},
- {CONFIG_LDAPI_MAP_ENTRIES_ATTRIBUTE, config_set_ldapi_map_entries,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_map_entries, CONFIG_ON_OFF, NULL},
- {CONFIG_LDAPI_UIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_uidnumber_type,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_uidnumber_type, CONFIG_STRING, NULL},
- {CONFIG_LDAPI_GIDNUMBER_TYPE_ATTRIBUTE, config_set_ldapi_gidnumber_type,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_gidnumber_type, CONFIG_STRING, NULL},
- {CONFIG_LDAPI_SEARCH_BASE_DN_ATTRIBUTE, config_set_ldapi_search_base_dn,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_search_base_dn, CONFIG_STRING, NULL},
- #if defined(ENABLE_AUTO_DN_SUFFIX)
- {CONFIG_LDAPI_AUTO_DN_SUFFIX_ATTRIBUTE, config_set_ldapi_auto_dn_suffix,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldapi_auto_dn_suffix, CONFIG_STRING, NULL},
- #endif
- {CONFIG_SLAPI_COUNTER_ATTRIBUTE, config_set_slapi_counters,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.slapi_counters, CONFIG_ON_OFF,
- (ConfigGetFunc)config_get_slapi_counters},
- {CONFIG_ACCESSLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
- log_set_mindiskspace, SLAPD_ACCESS_LOG,
- (void**)&global_slapdFrontendConfig.accesslog_minfreespace, CONFIG_INT, NULL},
- {CONFIG_ERRORLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
- log_set_numlogsperdir, SLAPD_ERROR_LOG,
- (void**)&global_slapdFrontendConfig.errorlog_maxnumlogs, CONFIG_INT, NULL},
- {CONFIG_SECURELISTENHOST_ATTRIBUTE, config_set_securelistenhost,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.securelistenhost, CONFIG_STRING, NULL},
- {CONFIG_AUDITLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
- log_set_mindiskspace, SLAPD_AUDIT_LOG,
- (void**)&global_slapdFrontendConfig.auditlog_minfreespace, CONFIG_INT, NULL},
- {CONFIG_ROOTDN_ATTRIBUTE, config_set_rootdn,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.rootdn, CONFIG_STRING, NULL},
- {CONFIG_PW_MINAGE_ATTRIBUTE, config_set_pw_minage,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.pw_policy.pw_minage, CONFIG_LONG, NULL},
- {CONFIG_AUDITFILE_ATTRIBUTE, config_set_auditlog,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.auditlog, CONFIG_STRING_OR_EMPTY, NULL},
- {CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, config_set_return_exact_case,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.return_exact_case, CONFIG_ON_OFF, NULL},
- {CONFIG_RESULT_TWEAK_ATTRIBUTE, config_set_result_tweak,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.result_tweak, CONFIG_ON_OFF, NULL},
- {CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, config_set_attrname_exceptions,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.attrname_exceptions, CONFIG_ON_OFF, NULL},
- {CONFIG_MAXBERSIZE_ATTRIBUTE, config_set_maxbersize,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.maxbersize, CONFIG_INT, NULL},
- {CONFIG_MAXSASLIOSIZE_ATTRIBUTE, config_set_maxsasliosize,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.maxsasliosize, CONFIG_INT, NULL},
- {CONFIG_VERSIONSTRING_ATTRIBUTE, config_set_versionstring,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.versionstring, CONFIG_STRING, NULL},
- {CONFIG_REFERRAL_MODE_ATTRIBUTE, config_set_referral_mode,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.refer_url, CONFIG_STRING, NULL},
- #if !defined(_WIN32) && !defined(AIX)
- {CONFIG_MAXDESCRIPTORS_ATTRIBUTE, config_set_maxdescriptors,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.maxdescriptors, CONFIG_INT, NULL},
- #endif
- {CONFIG_CONNTABLESIZE_ATTRIBUTE, config_set_conntablesize,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.conntablesize, CONFIG_INT, NULL},
- {CONFIG_SSLCLIENTAUTH_ATTRIBUTE, config_set_SSLclientAuth,
- NULL, 0,
- (void **)&global_slapdFrontendConfig.SSLclientAuth, CONFIG_SPECIAL_SSLCLIENTAUTH, NULL},
- {CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE, config_set_ssl_check_hostname,
- NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_ssl_check_hostname},
- {CONFIG_CONFIG_ATTRIBUTE, 0, NULL, 0, (void**)SLAPD_CONFIG_DN,
- CONFIG_CONSTANT_STRING, NULL},
- {CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
- NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters},
- /* instance dir; used by admin tasks */
- {CONFIG_INSTDIR_ATTRIBUTE, config_set_instancedir,
- NULL, 0, NULL, CONFIG_STRING, NULL},
- /* parameterizing schema dir */
- {CONFIG_SCHEMADIR_ATTRIBUTE, config_set_schemadir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.schemadir, CONFIG_STRING, NULL},
- /* parameterizing lock dir */
- {CONFIG_LOCKDIR_ATTRIBUTE, config_set_lockdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.lockdir, CONFIG_STRING, (ConfigGetFunc)config_get_lockdir},
- /* parameterizing tmp dir */
- {CONFIG_TMPDIR_ATTRIBUTE, config_set_tmpdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.tmpdir, CONFIG_STRING, (ConfigGetFunc)config_get_tmpdir},
- /* parameterizing cert dir */
- {CONFIG_CERTDIR_ATTRIBUTE, config_set_certdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.certdir, CONFIG_STRING, (ConfigGetFunc)config_get_certdir},
- /* parameterizing ldif dir */
- {CONFIG_LDIFDIR_ATTRIBUTE, config_set_ldifdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.ldifdir, CONFIG_STRING, (ConfigGetFunc)config_get_ldifdir},
- /* parameterizing bak dir */
- {CONFIG_BAKDIR_ATTRIBUTE, config_set_bakdir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.bakdir, CONFIG_STRING, (ConfigGetFunc)config_get_bakdir},
- /* parameterizing sasl plugin path */
- {CONFIG_SASLPATH_ATTRIBUTE, config_set_saslpath,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.saslpath, CONFIG_STRING, (ConfigGetFunc)config_get_saslpath},
- /* parameterizing run dir */
- {CONFIG_RUNDIR_ATTRIBUTE, config_set_rundir,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.rundir, CONFIG_STRING, (ConfigGetFunc)config_get_rundir},
- {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
- {CONFIG_OUTBOUND_LDAP_IO_TIMEOUT_ATTRIBUTE,
- config_set_outbound_ldap_io_timeout,
- NULL, 0,
- (void **)&global_slapdFrontendConfig.outbound_ldap_io_timeout,
- CONFIG_INT, NULL},
- {CONFIG_UNAUTH_BINDS_ATTRIBUTE, config_set_unauth_binds_switch,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.allow_unauth_binds, CONFIG_ON_OFF,
- (ConfigGetFunc)config_get_unauth_binds_switch},
- {CONFIG_REQUIRE_SECURE_BINDS_ATTRIBUTE, config_set_require_secure_binds,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.require_secure_binds, CONFIG_ON_OFF,
- (ConfigGetFunc)config_get_require_secure_binds}
- #ifdef MEMPOOL_EXPERIMENTAL
- ,{CONFIG_MEMPOOL_SWITCH_ATTRIBUTE, config_set_mempool_switch,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.mempool_switch, CONFIG_ON_OFF, (ConfigGetFunc)config_get_mempool_switch},
- {CONFIG_MEMPOOL_MAXFREELIST_ATTRIBUTE, config_set_mempool_maxfreelist,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.mempool_maxfreelist, CONFIG_INT, (ConfigGetFunc)config_get_mempool_maxfreelist}
- #endif /* MEMPOOL_EXPERIMENTAL */
- };
- /*
- * hashNocaseString - used for case insensitive hash lookups
- */
- static PLHashNumber
- hashNocaseString(const void *key)
- {
- PLHashNumber h = 0;
- const unsigned char *s;
-
- for (s = key; *s; s++)
- h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
- return h;
- }
- /*
- * hashNocaseCompare - used for case insensitive hash key comparisons
- */
- static PRIntn
- hashNocaseCompare(const void *v1, const void *v2)
- {
- return (strcasecmp((char *)v1, (char *)v2) == 0);
- }
- static PLHashTable *confighash = 0;
- static void
- init_config_get_and_set()
- {
- if (!confighash) {
- int ii = 0;
- int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
- confighash = PL_NewHashTable(tablesize+1, hashNocaseString,
- hashNocaseCompare,
- PL_CompareValues, 0, 0);
- for (ii = 0; ii < tablesize; ++ii) {
- if (PL_HashTableLookup(confighash, ConfigList[ii].attr_name))
- printf("error: %s is already in the list\n",
- ConfigList[ii].attr_name);
- if (!PL_HashTableAdd(confighash, ConfigList[ii].attr_name, &ConfigList[ii]))
- printf("error: could not add %s to the list\n",
- ConfigList[ii].attr_name);
- }
- }
- }
- #if 0
- #define GOLDEN_RATIO 0x9E3779B9U
- PR_IMPLEMENT(PLHashEntry **)
- PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
- {
- PLHashEntry *he, **hep, **hep0;
- PLHashNumber h;
- #ifdef HASHMETER
- ht->nlookups++;
- #endif
- h = keyHash * GOLDEN_RATIO;
- h >>= ht->shift;
- hep = hep0 = &ht->buckets[h];
- while ((he = *hep) != 0) {
- if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
- /* Move to front of chain if not already there */
- if (hep != hep0) {
- *hep = he->next;
- he->next = *hep0;
- *hep0 = he;
- }
- return hep0;
- }
- hep = &he->next;
- #ifdef HASHMETER
- ht->nsteps++;
- #endif
- }
- return hep;
- }
- static void
- debugHashTable(const char *key)
- {
- int ii = 0;
- PLHashEntry **hep = PL_HashTableRawLookup(confighash, hashNocaseString(key),
- key);
- if (!hep || !*hep)
- printf("raw lookup failed for %s\n", key);
- else if (hep && *hep)
- printf("raw lookup found %s -> %ul %s\n", key, (*hep)->keyHash, (*hep)->key);
- printf("hash table has %d entries\n", confighash->nentries);
- for (ii = 0; ii < confighash->nentries; ++ii)
- {
- PLHashEntry *he = confighash->buckets[ii];
- if (!he)
- printf("hash table entry %d is null\n", ii);
- else {
- printf("hash bucket %d:\n", ii);
- while (he) {
- int keys = !hashNocaseCompare(key, he->key);
- int hash = (hashNocaseString(key) == he->keyHash);
- printf("\thashval = %ul key = %s\n", he->keyHash, he->key);
- if (keys && hash) {
- printf("\t\tFOUND\n");
- } else if (keys) {
- printf("\t\tkeys match but hash vals do not\n");
- } else if (hash) {
- printf("\t\thash match but keys do not\n");
- }
- he = he->next;
- }
- }
- }
- }
- #endif
- static void
- bervalarray_free(struct berval **bvec)
- {
- int ii = 0;
- for(ii = 0; bvec && bvec[ii]; ++ii) {
- slapi_ch_free((void **)&bvec[ii]->bv_val);
- slapi_ch_free((void **)&bvec[ii]);
- }
- slapi_ch_free((void**)&bvec);
- }
- static struct berval **
- strarray2bervalarray(const char **strarray)
- {
- int ii = 0;
- struct berval **newlist = 0;
- /* first, count the number of items in the list */
- for (ii = 0; strarray && strarray[ii]; ++ii);
- /* if no items, return null */
- if (!ii)
- return newlist;
- /* allocate the list */
- newlist = (struct berval **)slapi_ch_malloc((ii+1) * sizeof(struct berval *));
- newlist[ii] = 0;
- for (; ii; --ii) {
- newlist[ii-1] = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
- newlist[ii-1]->bv_val = slapi_ch_strdup(strarray[ii-1]);
- newlist[ii-1]->bv_len = strlen(strarray[ii-1]);
- }
- return newlist;
- }
- /*
- * counter for active threads
- */
- static PRInt32 active_threads = 0;
- void
- g_incr_active_threadcnt()
- {
- PR_AtomicIncrement(&active_threads);
- }
- void
- g_decr_active_threadcnt()
- {
- PR_AtomicDecrement(&active_threads);
- }
- int
- g_get_active_threadcnt()
- {
- return (int)active_threads;
- }
- /*
- ** Setting this flag forces the server to shutdown.
- */
- static int slapd_shutdown;
- void g_set_shutdown( int reason )
- {
- slapd_shutdown = reason;
- }
- int g_get_shutdown()
- {
- return slapd_shutdown;
- }
- static int cmd_shutdown;
- void c_set_shutdown()
- {
- cmd_shutdown = SLAPI_SHUTDOWN_SIGNAL;
- }
- int c_get_shutdown()
- {
- return cmd_shutdown;
- }
- slapdFrontendConfig_t *
- getFrontendConfig()
- {
- return &global_slapdFrontendConfig;
- }
- /*
- * FrontendConfig_init:
- * Put all default values for config stuff here.
- * If there's no default value, the value will be NULL if it's not set in dse.ldif
- */
- void
- FrontendConfig_init () {
- slapdFrontendConfig_t *cfg = getFrontendConfig();
- /* initialize the read/write configuration lock */
- if ( (cfg->cfg_rwlock = rwl_new()) == NULL ) {
- LDAPDebug ( LDAP_DEBUG_ANY,
- "FrontendConfig_init: failed to initialize cfg_rwlock. Exiting now.",
- 0,0,0 );
- exit(-1);
- }
-
- cfg->port = LDAP_PORT;
- cfg->secureport = LDAPS_PORT;
- cfg->ldapi_filename = slapi_ch_strdup(SLAPD_LDAPI_DEFAULT_FILENAME);
- cfg->ldapi_switch = LDAP_OFF;
- cfg->ldapi_bind_switch = LDAP_OFF;
- cfg->ldapi_root_dn = slapi_ch_strdup("cn=Directory Manager");
- cfg->ldapi_map_entries = LDAP_OFF;
- cfg->ldapi_uidnumber_type = slapi_ch_strdup("uidNumber");
- cfg->ldapi_gidnumber_type = slapi_ch_strdup("gidNumber");
- cfg->ldapi_search_base_dn = slapi_ch_strdup("dc=example, dc=com");
- #if defined(ENABLE_AUTO_DN_SUFFIX)
- cfg->ldapi_auto_dn_suffix = slapi_ch_strdup("cn=peercred,cn=external,cn=auth");
- #endif
- cfg->allow_unauth_binds = LDAP_OFF;
- cfg->require_secure_binds = LDAP_OFF;
- cfg->slapi_counters = LDAP_ON;
- cfg->threadnumber = SLAPD_DEFAULT_MAX_THREADS;
- cfg->maxthreadsperconn = SLAPD_DEFAULT_MAX_THREADS_PER_CONN;
- cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
- cfg->idletimeout = SLAPD_DEFAULT_IDLE_TIMEOUT;
- cfg->ioblocktimeout = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
- cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
- cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
- cfg->maxsasliosize = SLAPD_DEFAULT_MAX_SASLIO_SIZE;
- #ifdef _WIN32
- cfg->conntablesize = SLAPD_DEFAULT_CONNTABLESIZE;
- #else
- #ifdef USE_SYSCONF
- cfg->conntablesize = sysconf( _SC_OPEN_MAX );
- #else /* USE_SYSCONF */
- cfg->conntablesize = getdtablesize();
- #endif /* USE_SYSCONF */
- #endif /* _WIN32 */
- cfg->accesscontrol = LDAP_ON;
- cfg->security = LDAP_OFF;
- cfg->ssl_check_hostname = LDAP_ON;
- cfg->return_exact_case = LDAP_ON;
- cfg->result_tweak = LDAP_OFF;
- cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
- cfg->useroc = slapi_ch_strdup ( "" );
- cfg->userat = slapi_ch_strdup ( "" );
- /* kexcoff: should not be initialized by default here
- cfg->rootpwstoragescheme = pw_name2scheme( SHA1_SCHEME_NAME );
- cfg->pw_storagescheme = pw_name2scheme( SHA1_SCHEME_NAME );
- */
- cfg->slapd_type = 0;
- cfg->versionstring = SLAPD_VERSION_STR;
- cfg->sizelimit = SLAPD_DEFAULT_SIZELIMIT;
- cfg->timelimit = SLAPD_DEFAULT_TIMELIMIT;
- cfg->schemacheck = LDAP_ON;
- cfg->syntaxcheck = LDAP_OFF;
- cfg->syntaxlogging = LDAP_OFF;
- cfg->dn_validate_strict = LDAP_OFF;
- cfg->ds4_compatible_schema = LDAP_OFF;
- cfg->enquote_sup_oc = LDAP_OFF;
- cfg->lastmod = LDAP_ON;
- cfg->rewrite_rfc1274 = LDAP_OFF;
- cfg->schemareplace = slapi_ch_strdup( CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY );
- cfg->schema_ignore_trailing_spaces = SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES;
- cfg->pwpolicy_local = LDAP_OFF;
- cfg->pw_policy.pw_change = LDAP_ON;
- cfg->pw_policy.pw_must_change = LDAP_OFF;
- cfg->pw_policy.pw_syntax = LDAP_OFF;
- cfg->pw_policy.pw_exp = LDAP_OFF;
- cfg->pw_policy.pw_minlength = 8;
- cfg->pw_policy.pw_mindigits = 0;
- cfg->pw_policy.pw_minalphas = 0;
- cfg->pw_policy.pw_minuppers = 0;
- cfg->pw_policy.pw_minlowers = 0;
- cfg->pw_policy.pw_minspecials = 0;
- cfg->pw_policy.pw_min8bit = 0;
- cfg->pw_policy.pw_maxrepeats = 0;
- cfg->pw_policy.pw_mincategories = 3;
- cfg->pw_policy.pw_mintokenlength = 3;
- cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
- cfg->pw_policy.pw_minage = 0;
- cfg->pw_policy.pw_warning = 86400; /* 1 day */
- cfg->pw_policy.pw_history = LDAP_OFF;
- cfg->pw_policy.pw_inhistory = 6;
- cfg->pw_policy.pw_lockout = LDAP_OFF;
- cfg->pw_policy.pw_maxfailure = 3;
- cfg->pw_policy.pw_unlock = LDAP_ON;
- cfg->pw_policy.pw_lockduration = 3600; /* 60 minutes */
- cfg->pw_policy.pw_resetfailurecount = 600; /* 10 minutes */
- cfg->pw_policy.pw_gracelimit = 0;
- cfg->pw_is_global_policy = LDAP_OFF;
- cfg->accesslog_logging_enabled = LDAP_ON;
- cfg->accesslog_mode = slapi_ch_strdup("600");
- cfg->accesslog_maxnumlogs = 10;
- cfg->accesslog_maxlogsize = 100;
- cfg->accesslog_rotationtime = 1;
- cfg->accesslog_rotationunit = slapi_ch_strdup("day");
- cfg->accesslog_rotationsync_enabled = LDAP_OFF;
- cfg->accesslog_rotationsynchour = 0;
- cfg->accesslog_rotationsyncmin = 0;
- cfg->accesslog_maxdiskspace = 500;
- cfg->accesslog_minfreespace = 5;
- cfg->accesslog_exptime = 1;
- cfg->accesslog_exptimeunit = slapi_ch_strdup("month");
- cfg->accessloglevel = 256;
- cfg->accesslogbuffering = LDAP_ON;
- cfg->csnlogging = LDAP_ON;
- cfg->errorlog_logging_enabled = LDAP_ON;
- cfg->errorlog_mode = slapi_ch_strdup("600");
- cfg->errorlog_maxnumlogs = 1;
- cfg->errorlog_maxlogsize = 100;
- cfg->errorlog_rotationtime = 1;
- cfg->errorlog_rotationunit = slapi_ch_strdup ("week");
- cfg->errorlog_rotationsync_enabled = LDAP_OFF;
- cfg->errorlog_rotationsynchour = 0;
- cfg->errorlog_rotationsyncmin = 0;
- cfg->errorlog_maxdiskspace = 100;
- cfg->errorlog_minfreespace = 5;
- cfg->errorlog_exptime = 1;
- cfg->errorlog_exptimeunit = slapi_ch_strdup("month");
- cfg->errorloglevel = 0;
- cfg->auditlog_logging_enabled = LDAP_OFF;
- cfg->auditlog_mode = slapi_ch_strdup("600");
- cfg->auditlog_maxnumlogs = 1;
- cfg->auditlog_maxlogsize = 100;
- cfg->auditlog_rotationtime = 1;
- cfg->auditlog_rotationunit = slapi_ch_strdup ("week");
- cfg->auditlog_rotationsync_enabled = LDAP_OFF;
- cfg->auditlog_rotationsynchour = 0;
- cfg->auditlog_rotationsyncmin = 0;
- cfg->auditlog_maxdiskspace = 100;
- cfg->auditlog_minfreespace = 5;
- cfg->auditlog_exptime = 1;
- cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
- #ifdef MEMPOOL_EXPERIMENTAL
- cfg->mempool_switch = LDAP_ON;
- cfg->mempool_maxfreelist = 1024;
- cfg->system_page_size = sysconf(_SC_PAGE_SIZE); /* not to get every time; no set, get only */
- {
- long sc_size = cfg->system_page_size;
- cfg->system_page_bits = 0;
- while ((sc_size >>= 1) > 0) {
- cfg->system_page_bits++; /* to calculate once; no set, get only */
- }
- }
- #endif /* MEMPOOL_EXPERIMENTAL */
- init_config_get_and_set();
- }
- int
- g_get_global_lastmod()
- {
- return config_get_lastmod();
- }
- int g_get_slapd_security_on(){
- return config_get_security();
- }
- #ifdef _WIN32
- void libldap_init_debug_level(int *val_ptr)
- {
- module_ldap_debug = val_ptr;
- }
- #endif
- struct snmp_vars_t global_snmp_vars;
- struct snmp_vars_t * g_get_global_snmp_vars(){
- return &global_snmp_vars;
- }
- static slapdEntryPoints *sep = NULL;
- void
- set_dll_entry_points( slapdEntryPoints *p )
- {
- if ( NULL == sep )
- {
- sep = p;
- }
- }
- int
- get_entry_point( int ep_name, caddr_t *ep_addr )
- {
- int rc = 0;
- if(sep!=NULL)
- {
- switch ( ep_name ) {
- case ENTRY_POINT_PS_WAKEUP_ALL:
- *ep_addr = sep->sep_ps_wakeup_all;
- break;
- case ENTRY_POINT_PS_SERVICE:
- *ep_addr = sep->sep_ps_service;
- break;
- case ENTRY_POINT_DISCONNECT_SERVER:
- *ep_addr = sep->sep_disconnect_server;
- break;
- case ENTRY_POINT_SLAPD_SSL_INIT:
- *ep_addr = sep->sep_slapd_ssl_init;
- break;
- case ENTRY_POINT_SLAPD_SSL_INIT2:
- *ep_addr = sep->sep_slapd_ssl_init2;
- break;
- default:
- rc = -1;
- }
- }
- else
- {
- rc= -1;
- }
- return rc;
- }
- /*
- * Utility function called by many of the config_set_XXX() functions.
- * Returns a non-zero value if 'value' is NULL and zero if not.
- * Also constructs an error message in 'errorbuf' if value is NULL.
- * If or_zero_length is non-zero, zero length values are treated as
- * equivalent to NULL (i.e., they will cause a non-zero value to be
- * returned by this function).
- */
- static int
- config_value_is_null( const char *attrname, const char *value, char *errorbuf,
- int or_zero_length )
- {
- if ( NULL == value || ( or_zero_length && *value == '\0' )) {
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value",
- attrname );
- return 1;
- }
- return 0;
- }
- int
- config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
- long nPort;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- nPort = strtol(port, &endp, 10);
-
- if ( *endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort < 0 ) {
- retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, ports must range from 0 to %d",
- attrname, port, LDAP_PORT_MAX );
- return retVal;
- }
- if ( nPort == 0 ) {
- LDAPDebug( LDAP_DEBUG_ANY,
- "Information: Non-Secure Port Disabled\n", 0, 0, 0 );
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->port = nPort;
- /* n_port = nPort; */
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply ) {
- long nPort;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
- if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- nPort = strtol(port, &endp, 10);
-
- if (*endp != '\0' || errno == ERANGE || nPort > LDAP_PORT_MAX || nPort <= 0 ) {
- retVal = LDAP_OPERATIONS_ERROR;
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid, ports must range from 1 to %d",
- attrname, port, LDAP_PORT_MAX );
- }
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- slapdFrontendConfig->secureport = nPort;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
-
- int
- config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
-
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- /* first check the value, return an error if it's invalid */
- else if ( strcasecmp (value, "off") != 0 &&
- strcasecmp (value, "allowed") != 0 &&
- strcasecmp (value, "required")!= 0 ) {
- retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf )
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: unsupported value: %s", attrname, value );
- return retVal;
- }
- else if ( !apply ) {
- /* return success now, if we aren't supposed to apply the change */
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- if ( !strcasecmp( value, "off" )) {
- slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_OFF;
- }
- else if ( !strcasecmp( value, "allowed" )) {
- slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_ALLOWED;
- }
- else if ( !strcasecmp( value, "required" )) {
- slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_REQUIRED;
- }
- else {
- retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf )
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: unsupported value: %s", attrname, value );
- }
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_set_ssl_check_hostname(const char *attrname, char *value,
- char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->ssl_check_hostname),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->localhost) );
- slapdFrontendConfig->localhost = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- slapi_ch_free ( (void **) &(slapdFrontendConfig->listenhost) );
- slapdFrontendConfig->listenhost = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_ldapi_filename( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_filename) );
- slapdFrontendConfig->ldapi_filename = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->ldapi_switch),
- errorbuf,
- apply);
- return retVal;
- }
- int config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->ldapi_bind_switch),
- errorbuf,
- apply);
- return retVal;
- }
- int config_set_ldapi_root_dn( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_root_dn) );
- slapdFrontendConfig->ldapi_root_dn = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->ldapi_map_entries),
- errorbuf,
- apply);
- return retVal;
- }
- int config_set_ldapi_uidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_uidnumber_type) );
- slapdFrontendConfig->ldapi_uidnumber_type = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int config_set_ldapi_gidnumber_type( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_gidnumber_type) );
- slapdFrontendConfig->ldapi_gidnumber_type = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int config_set_ldapi_search_base_dn( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_search_base_dn) );
- slapdFrontendConfig->ldapi_search_base_dn = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- #if defined(ENABLE_AUTO_DN_SUFFIX)
- int config_set_ldapi_auto_dn_suffix( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->ldapi_auto_dn_suffix) );
- slapdFrontendConfig->ldapi_auto_dn_suffix = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- #endif
- /*
- * Set nsslapd-counters: on | off to the internal config variable slapi_counters.
- * If set to off, slapi_counters is not initialized and the counters are not
- * incremented. Note: counters which are necessary for the server's running
- * are not disabled.
- */
- int config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname, value,
- &(slapdFrontendConfig->slapi_counters), errorbuf, apply);
- return retVal;
- }
- int
- config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- slapi_ch_free ( (void **) &(slapdFrontendConfig->securelistenhost) );
- slapdFrontendConfig->securelistenhost = slapi_ch_strdup ( value );
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- slapi_ch_free ( (void **) &(slapdFrontendConfig->srvtab) );
- ldap_srvtab = slapi_ch_strdup ( value );
- slapdFrontendConfig->srvtab = slapi_ch_strdup ( value );
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long sizelimit;
- char *endp = NULL;
- Slapi_Backend *be;
- char *cookie;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- sizelimit = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || sizelimit < -1 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: \"%s\" is invalid, sizelimit must range from -1 to %ld",
- attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if (apply) {
-
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- slapdFrontendConfig->sizelimit= sizelimit;
- g_set_defsize (sizelimit);
- cookie = NULL;
- be = slapi_get_first_backend(&cookie);
- while (be) {
- be->be_sizelimit = slapdFrontendConfig->sizelimit;
- be = slapi_get_next_backend(cookie);
- }
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ((void **)&cookie);
- }
- return retVal;
- }
- int
- config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct pw_scheme *new_scheme = NULL;
- char * scheme_list = NULL;
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
-
- new_scheme = pw_name2scheme(value);
- if ( new_scheme == NULL) {
- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s. Valid schemes are: %s",
- attrname, value, scheme_list );
- } else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s (no pwdstorage scheme"
- " plugin loaded)",
- attrname, value);
- }
- retVal = LDAP_OPERATIONS_ERROR;
- slapi_ch_free_string(&scheme_list);
- return retVal;
- }
- else if ( new_scheme->pws_enc == NULL )
- {
- /* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
- compatibility with an Old Messaging Server that was setting passwords in the
- directory already encrypted. The scheme cannot and don't encrypt password if
- they are in clear. We don't take it */
- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
- }
- retVal = LDAP_UNWILLING_TO_PERFORM;
- slapi_ch_free_string(&scheme_list);
- return retVal;
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
- slapdFrontendConfig->pw_storagescheme = new_scheme;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- } else {
- free_pw_scheme(new_scheme);
- }
- slapi_ch_free_string(&scheme_list);
- return retVal;
- }
-
- int
- config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_change),
- errorbuf,
- apply);
-
- if (retVal == LDAP_SUCCESS) {
- /* LP: Update ACI to reflect the value ! */
- if (apply)
- pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
- !slapdFrontendConfig->pw_policy.pw_must_change);
- }
-
- return retVal;
- }
- int
- config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_history),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_must_change),
- errorbuf,
- apply);
-
- if (retVal == LDAP_SUCCESS) {
- /* LP: Update ACI to reflect the value ! */
- if (apply)
- pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
- !slapdFrontendConfig->pw_policy.pw_must_change);
- }
-
- return retVal;
- }
- int
- config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pwpolicy_local),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_syntax),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minLength = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- minLength = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minLength < 2 || minLength > 512 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum length \"%s\" is invalid. "
- "The minimum length must range from 2 to 512.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_minlength = minLength;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minDigits = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minDigits = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minDigits < 0 || minDigits > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of digits \"%s\" is invalid. "
- "The minimum number of digits must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_mindigits = minDigits;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minAlphas = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minAlphas = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minAlphas < 0 || minAlphas > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of alphas \"%s\" is invalid. "
- "The minimum number of alphas must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_minalphas = minAlphas;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minUppers = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minUppers = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minUppers < 0 || minUppers > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of uppercase characters \"%s\" is invalid. "
- "The minimum number of uppercase characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_minuppers = minUppers;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minLowers = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minLowers = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minLowers < 0 || minLowers > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of lowercase characters \"%s\" is invalid. "
- "The minimum number of lowercase characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_minlowers = minLowers;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minSpecials = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minSpecials = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minSpecials < 0 || minSpecials > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of special characters \"%s\" is invalid. "
- "The minimum number of special characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_minspecials = minSpecials;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long min8bit = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- min8bit = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || min8bit < 0 || min8bit > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of 8-bit characters \"%s\" is invalid. "
- "The minimum number of 8-bit characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_min8bit = min8bit;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long maxRepeats = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- maxRepeats = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || maxRepeats < 0 || maxRepeats > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password maximum number of repeated characters \"%s\" is invalid. "
- "The maximum number of repeated characters must range from 0 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_maxrepeats = maxRepeats;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minCategories = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minCategories = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minCategories < 1 || minCategories > 5 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum number of categories \"%s\" is invalid. "
- "The minimum number of categories must range from 1 to 5.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_mincategories = minCategories;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long minTokenLength = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- minTokenLength = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || minTokenLength < 1 || minTokenLength > 64 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password minimum token length \"%s\" is invalid. "
- "The minimum token length must range from 1 to 64.",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_mintokenlength = minTokenLength;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long maxFailure = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- maxFailure = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || maxFailure <= 0 || maxFailure > 32767 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password maximum retry \"%s\" is invalid. "
- "Password maximum failure must range from 1 to 32767",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_maxfailure = maxFailure;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long history = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- history = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || history < 2 || history > 24 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password history length \"%s\" is invalid. "
- "The password history must range from 2 to 24",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_inhistory = history;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long duration = 0; /* in minutes */
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- /* in seconds */
- duration = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password lockout duration \"%s\" seconds is invalid. ",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- slapdFrontendConfig->pw_policy.pw_lockduration = duration;
- }
-
- return retVal;
- }
- int
- config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long duration = 0; /* in minutes */
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- /* in seconds */
- duration = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password reset count duration \"%s\" seconds is invalid. ",
- value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- slapdFrontendConfig->pw_policy.pw_resetfailurecount = duration;
- }
-
- return retVal;
- }
- int
- config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_is_global_policy),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_exp),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_unlock),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->pw_policy.pw_lockout),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long gracelimit = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- gracelimit = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || gracelimit < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "password grace limit \"%s\" is invalid, password grace limit must range from 0 to %ld",
- value , LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->pw_policy.pw_gracelimit = gracelimit;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- Slapi_Backend *be = NULL;
- char *cookie;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->lastmod),
- errorbuf,
- apply);
-
- if ( retVal == LDAP_SUCCESS && apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- cookie = NULL;
- be = slapi_get_first_backend (&cookie);
- while (be) {
- be->be_lastmod = slapdFrontendConfig->lastmod;
- be = slapi_get_next_backend (cookie);
- }
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ((void **)&cookie);
- }
-
- return retVal;
- }
- int
- config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->nagle),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->accesscontrol),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->return_exact_case),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->result_tweak),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->security),
- errorbuf,
- apply);
-
- return retVal;
- }
- static int
- config_set_onoff ( const char *attrname, char *value, int *configvalue,
- char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( strcasecmp ( value, "on" ) != 0 &&
- strcasecmp ( value, "off") != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- }
-
- if ( !apply ) {
- /* we can return now if we aren't applying the changes */
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
-
- if ( strcasecmp ( value, "on" ) == 0 ) {
- *configvalue = LDAP_ON;
- }
- else if ( strcasecmp ( value, "off" ) == 0 ) {
- *configvalue = LDAP_OFF;
- }
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
-
- int
- config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->readonly),
- errorbuf,
- apply );
-
- return retVal;
- }
- int
- config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->schemacheck),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_syntaxcheck( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->syntaxcheck),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_set_syntaxlogging( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->syntaxlogging),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_set_dn_validate_strict( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->dn_validate_strict),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->ds4_compatible_schema),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_schema_ignore_trailing_spaces( const char *attrname, char *value,
- char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->schema_ignore_trailing_spaces),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff ( attrname,
- value,
- &(slapdFrontendConfig->enquote_sup_oc),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->rootdn) );
- slapdFrontendConfig->rootdn = slapi_dn_normalize (slapi_ch_strdup ( value ) );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct pw_scheme *is_hashed = NULL;
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->rootpw) );
-
- is_hashed = pw_val2scheme ( value, NULL, 0 );
-
- if ( is_hashed ) {
- slapdFrontendConfig->rootpw = slapi_ch_strdup ( value );
- free_pw_scheme(is_hashed);
- } else if (slapd_nss_is_initialized() ||
- (strcasecmp(slapdFrontendConfig->rootpwstoragescheme->pws_name,
- "clear") == 0)) {
- /* to hash, security library should have been initialized, by now */
- /* pwd enc func returns slapi_ch_malloc memory */
- slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
- } else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password scheme mismatch (passwd scheme is %s; "
- "password is clear text)", attrname,
- slapdFrontendConfig->rootpwstoragescheme->pws_name);
- retVal = LDAP_PARAM_ERROR;
- }
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct pw_scheme *new_scheme = NULL;
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- new_scheme = pw_name2scheme ( value );
- if (new_scheme == NULL ) {
- char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
- if ( scheme_list != NULL ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s. Valid schemes are: %s",
- attrname, value, scheme_list );
- } else {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid scheme - %s (no pwdstorage scheme"
- " plugin loaded)", attrname, value);
- }
- slapi_ch_free_string(&scheme_list);
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
-
- CFG_LOCK_WRITE(slapdFrontendConfig);
- free_pw_scheme(slapdFrontendConfig->rootpwstoragescheme);
- slapdFrontendConfig->rootpwstoragescheme = new_scheme;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
-
- return retVal;
- }
-
- /*
- * kexcoff: to replace default initialization in FrontendConfig_init()
- */
- int config_set_storagescheme() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct pw_scheme *new_scheme = NULL;
- CFG_LOCK_WRITE(slapdFrontendConfig);
- new_scheme = pw_name2scheme("SSHA");
- free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
- slapdFrontendConfig->pw_storagescheme = new_scheme;
- new_scheme = pw_name2scheme("SSHA");
- slapdFrontendConfig->rootpwstoragescheme = new_scheme;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return ( new_scheme == NULL );
- }
- #ifndef _WIN32
- int
- config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- struct passwd *pw = NULL;
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &slapdFrontendConfig->localuser );
- slapdFrontendConfig->localuser = slapi_ch_strdup ( value );
- if (slapdFrontendConfig->localuserinfo != NULL) {
- slapi_ch_free ( (void **) &(slapdFrontendConfig->localuserinfo) );
- }
- pw = getpwnam( value );
- if ( pw ) {
- slapdFrontendConfig->localuserinfo =
- (struct passwd *)slapi_ch_malloc(sizeof(struct passwd));
- memcpy(slapdFrontendConfig->localuserinfo, pw, sizeof(struct passwd));
- }
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- #endif /* _WIN32 */
- int
- config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->workingdir = slapi_ch_strdup ( value );
- #ifdef _WIN32
- dostounixpath(slapdFrontendConfig->workingdir);
- #endif /* _WIN32 */
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- /* alias of encryption key and certificate files is now retrieved through */
- /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
- /* where this function is still used to set the global variable */
- int
- config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->encryptionalias) );
-
- slapdFrontendConfig->encryptionalias = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long threadnum = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- threadnum = strtol(value, &endp, 10);
-
- if ( *endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number must range from 1 to 65535", attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- }
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- /* max_threads = threadnum; */
- slapdFrontendConfig->threadnumber = threadnum;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long maxthreadnum = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- maxthreadnum = strtol(value, &endp, 10);
-
- if ( *endp != '\0' || errno == ERANGE || maxthreadnum < 1 || maxthreadnum > 65535 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum thread number per connection must range from 1 to 65535", attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- }
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- /* max_threads_per_conn = maxthreadnum; */
- slapdFrontendConfig->maxthreadsperconn = maxthreadnum;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- #if !defined(_WIN32) && !defined(AIX)
- #include <sys/resource.h>
- int
- config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nValue = 0;
- int maxVal = 65535;
- struct rlimit rlp;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
- maxVal = (int)rlp.rlim_max;
- }
- errno = 0;
- nValue = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", maximum "
- "file descriptors must range from 1 to %d (the current process limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal);
- if ( nValue > maxVal ) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- }
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->maxdescriptors = nValue;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- #endif /* !_WIN32 && !AIX */
- int
- config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nValue = 0;
- int maxVal = 65535;
- char *endp = NULL;
- #ifndef _WIN32
- struct rlimit rlp;
- #endif
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- #ifndef _WIN32
- if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
- maxVal = (int)rlp.rlim_max;
- }
- #endif
- errno = 0;
- nValue = strtol(value, &endp, 0);
-
- #ifdef _WIN32
- if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > 0xfffffe ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table size must range from 1 to 0xfffffe", attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- }
- #elif !defined(AIX)
- if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", connection table "
- "size must range from 1 to %d (the current process maxdescriptors limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
- if ( nValue > maxVal) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- }
- #endif
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->conntablesize = nValue;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- int maxVal = 65535;
- long nValue = 0;
- char *endp = NULL;
- #ifndef _WIN32
- struct rlimit rlp;
- #endif
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- #ifndef _WIN32
- if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
- maxVal = (int)rlp.rlim_max;
- }
- #endif
- errno = 0;
- nValue = strtol(value, &endp, 10);
-
- if ( *endp != '\0' || errno == ERANGE || nValue < 1 || nValue > maxVal ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", reserved file "
- "descriptors must range from 1 to %d (the current process maxdescriptors limit). "
- "Server will use a setting of %d.", attrname, value, maxVal, maxVal );
- if ( nValue > maxVal) {
- nValue = maxVal;
- retVal = LDAP_UNWILLING_TO_PERFORM;
- } else {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- }
-
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->reservedescriptors = nValue;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nValue = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- nValue = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || nValue < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", I/O block timeout must range from 0 to %ld",
- attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- #if defined(IRIX)
- /* on IRIX poll can only handle timeouts up to
- 2147483 without failing, cap it at 30 minutes */
- if ( nValue > SLAPD_DEFAULT_IOBLOCK_TIMEOUT ) {
- nValue = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
- }
- #endif /* IRIX */
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->ioblocktimeout = nValue;
- /* g_ioblock_timeout= nValue; */
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nValue = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- nValue = strtol(value, &endp, 10);
- if (*endp != '\0' || errno == ERANGE || nValue < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value \"%s\", idle timeout must range from 0 to %ld",
- attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->idletimeout = nValue;
- /* g_idle_timeout= nValue; */
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nValue = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- nValue = strtol(value, &endp, 10);
-
- if ( *endp != '\0' || errno == ERANGE || nValue < 0 || nValue > 5 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\", group eval nest level must range from 0 to 5",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->groupevalnestlevel = nValue;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, (char *)value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- g_set_default_referral( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_userat( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free( (void **) &(slapdFrontendConfig->userat) );
- slapdFrontendConfig->userat = slapi_ch_strdup(value);
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_timelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long nVal = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- Slapi_Backend *be = NULL;
- char *cookie;
-
- *errorbuf = 0;
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- nVal = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || nVal < -1 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid value \"%s\", time limit must range from -1 to %ld",
- attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- g_set_deftime ( nVal );
- slapdFrontendConfig->timelimit = nVal;
- be = slapi_get_first_backend (&cookie);
- while (be) {
- be->be_timelimit = slapdFrontendConfig->timelimit;
- be = slapi_get_next_backend (cookie);
- }
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ((void **)&cookie);
- }
- return retVal;
- }
- int
- config_set_useroc( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->useroc) );
- slapdFrontendConfig->useroc = slapi_ch_strdup( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_accesslog( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- retVal = log_update_accesslogdir ( value, apply );
-
- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open accesslog directory \"%s\", client accesses will "
- "not be logged.", value );
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->accesslog) );
- slapdFrontendConfig->accesslog = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_errorlog( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- retVal = log_update_errorlogdir ( value, apply );
-
- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
- value );
- syslog(LOG_ERR,
- "Cannot open errorlog file \"%s\", errors cannot be logged. Exiting...",
- value );
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
- slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_auditlog( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- retVal = log_update_auditlogdir ( value, apply );
-
- if ( retVal != LDAP_SUCCESS ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "Cannot open auditlog directory \"%s\"", value );
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &(slapdFrontendConfig->auditlog) );
- slapdFrontendConfig->auditlog = slapi_ch_strdup ( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long age;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- /* age in seconds */
- age = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password maximum age \"%s\" seconds is invalid. ",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
-
- if ( apply ) {
- slapdFrontendConfig->pw_policy.pw_maxage = age;
- }
- return retVal;
- }
- int
- config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long age;
- char *endPtr = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- /* age in seconds */
- age = strtol(value, &endPtr, 0 );
- /* endPtr should never be NULL, but we check just in case; if the
- value contains no digits, or a string that does not begin with
- a valid digit (e.g. "z2"), the days will be 0, and endPtr will
- point to the beginning of value; if days contains at least 1
- valid digit string, endPtr will point to the character after
- the end of the first valid digit string in value. Example:
- value = " 2 3 " endPtr will point at the space character
- between the 2 and the 3. So, we should be able to simply
- check to see if the character at *(endPtr - 1) is a digit.
- */
- if ( (age < 0) ||
- (age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
- (endPtr == NULL) || (endPtr == value) || !isdigit(*(endPtr-1)) ||
- errno == ERANGE ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password minimum age \"%s\" seconds is invalid. ",
- attrname, value );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- if ( apply ) {
- slapdFrontendConfig->pw_policy.pw_minage = age;
- }
- return retVal;
- }
- int
- config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long sec;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- errno = 0;
- /* in seconds */
- sec = strtol(value, &endp, 10);
- if (*endp != '\0' || errno == ERANGE || sec < 0) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: password warning age \"%s\" seconds is invalid, password warning "
- "age must range from 0 to %ld seconds",
- attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
- /* translate to seconds */
- if ( apply ) {
- slapdFrontendConfig->pw_policy.pw_warning = sec;
- }
- return retVal;
- }
- int
- config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long level = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- level = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: error log level \"%s\" is invalid,"
- " error log level must range from 0 to %ld", attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- level |= LDAP_DEBUG_ANY;
- #ifdef _WIN32
- *module_ldap_debug = level;
- #else
- slapd_ldap_debug = level;
- #endif
- slapdFrontendConfig->errorloglevel = level;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- int
- config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- long level = 0;
- char *endp = NULL;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- level = strtol(value, &endp, 10);
- if ( *endp != '\0' || errno == ERANGE || level < 0 ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: access log level \"%s\" is invalid,"
- " access log level must range from 0 to %ld", attrname, value, LONG_MAX );
- retVal = LDAP_OPERATIONS_ERROR;
- return retVal;
- }
-
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- g_set_accesslog_level ( level );
- slapdFrontendConfig->accessloglevel = level;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- /* set the referral-mode url (which puts us into referral mode) */
- int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply)
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
- if ((!url) || (!url[0])) {
- strcpy(errorbuf, "referral url must have a value");
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
- slapdFrontendConfig->refer_mode = REFER_MODE_ON;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return LDAP_SUCCESS;
- }
- int
- config_set_versionstring( const char *attrname, char *version, char *errorbuf, int apply ) {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ((!version) || (!version[0])) {
- PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
- return LDAP_OPERATIONS_ERROR;
- }
- if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->versionstring = slapi_ch_strdup(version);
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return LDAP_SUCCESS;
- }
- #define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL;
- int
- config_get_port(){
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->port;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_ldapi_filename(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_filename);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int config_get_ldapi_switch(){
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->ldapi_switch;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int config_get_ldapi_bind_switch(){
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->ldapi_bind_switch;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *config_get_ldapi_root_dn(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_root_dn);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int config_get_ldapi_map_entries(){
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->ldapi_map_entries;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *config_get_ldapi_uidnumber_type(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_uidnumber_type);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *config_get_ldapi_gidnumber_type(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_gidnumber_type);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *config_get_ldapi_search_base_dn(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_search_base_dn);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #if defined(ENABLE_AUTO_DN_SUFFIX)
- char *config_get_ldapi_auto_dn_suffix(){
- char *retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->ldapi_auto_dn_suffix);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #endif
- int config_get_slapi_counters()
- {
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->slapi_counters;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_workingdir() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->workingdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_versionstring() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapi_ch_strdup(slapdFrontendConfig->versionstring);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
-
- }
-
- char *
- config_get_buildnum(void)
- {
- return slapi_ch_strdup(BUILD_NUM);
- }
- int
- config_get_secureport() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->secureport;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
-
- int
- config_get_SSLclientAuth() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->SSLclientAuth;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_ssl_check_hostname()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->ssl_check_hostname;
- }
- char *
- config_get_localhost() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval ( slapdFrontendConfig->localhost );
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- char *
- config_get_listenhost() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval ( slapdFrontendConfig->listenhost );
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- char *
- config_get_securelistenhost() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval( slapdFrontendConfig->securelistenhost );
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- char *
- config_get_srvtab() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->srvtab);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_sizelimit() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->sizelimit;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_pw_storagescheme() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal = 0;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->pw_storagescheme->pws_name);
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
-
- int
- config_get_pw_change() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_change;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_history() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_history;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_must_change() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_must_change;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_syntax() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_syntax;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_minlength() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minlength;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_mindigits() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_mindigits;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_minalphas() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minalphas;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_minuppers() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minuppers;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_minlowers() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minlowers;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_minspecials() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minspecials;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_min8bit() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_min8bit;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_maxrepeats() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_maxrepeats;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_mincategories() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_mincategories;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_mintokenlength() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_mintokenlength;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_maxfailure() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_maxfailure;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_inhistory() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_inhistory;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- long
- config_get_pw_lockduration() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_lockduration;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- long
- config_get_pw_resetfailurecount() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_resetfailurecount;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_is_global_policy() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_is_global_policy;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_exp() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_exp;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_unlock() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_unlock;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_pw_lockout(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_lockout;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_pw_gracelimit() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal=0;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_gracelimit;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_lastmod(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->lastmod;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_enquote_sup_oc(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->enquote_sup_oc;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_nagle() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->nagle;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal; }
- int
- config_get_accesscontrol() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->accesscontrol;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_return_exact_case() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- retVal = slapdFrontendConfig->return_exact_case;
- return retVal;
- }
- int
- config_get_result_tweak() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->result_tweak;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_security() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->security;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
-
- int
- slapi_config_get_readonly() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->readonly;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_schemacheck() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->schemacheck;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_syntaxcheck() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->syntaxcheck;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_syntaxlogging() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->syntaxlogging;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_dn_validate_strict() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->dn_validate_strict;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_ds4_compatible_schema() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->ds4_compatible_schema;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_schema_ignore_trailing_spaces() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->schema_ignore_trailing_spaces;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- char *
- config_get_rootdn() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval (slapdFrontendConfig->rootdn);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char * slapi_get_rootdn() {
- return config_get_rootdn();
- }
- char *
- config_get_rootpw() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval (slapdFrontendConfig->rootpw);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_rootpwstoragescheme() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->rootpwstoragescheme->pws_name);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #ifndef _WIN32
- char *
- config_get_localuser() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->localuser);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #endif /* _WIN32 */
- /* alias of encryption key and certificate files is now retrieved through */
- /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
- /* where this function is still used to set the global variable */
- char *
- config_get_encryptionalias() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->encryptionalias);
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_threadnumber() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->threadnumber;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_maxthreadsperconn(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->maxthreadsperconn;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #if !defined(_WIN32) && !defined(AIX)
- int
- config_get_maxdescriptors() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->maxdescriptors;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- #endif /* !_WIN32 && !AIX */
- int
- config_get_reservedescriptors(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->reservedescriptors;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- int
- config_get_ioblocktimeout(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->ioblocktimeout;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_idletimeout(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->idletimeout;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_groupevalnestlevel(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->groupevalnestlevel;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- struct berval **
- config_get_defaultreferral() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- struct berval **refs;
- int nReferrals = 0;
- CFG_LOCK_READ(slapdFrontendConfig);
- /* count the number of referrals */
- for ( nReferrals = 0;
- slapdFrontendConfig->defaultreferral &&
- slapdFrontendConfig->defaultreferral[nReferrals];
- nReferrals++)
- ;
-
- refs = (struct berval **)
- slapi_ch_malloc( (nReferrals + 1) * sizeof(struct berval *) );
-
- /*terminate the end, and add the referrals backwards */
- refs [nReferrals--] = NULL;
- while ( nReferrals >= 0 ) {
- refs[nReferrals] = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
- refs[nReferrals]->bv_val =
- config_copy_strval( slapdFrontendConfig->defaultreferral[nReferrals]->bv_val );
- refs[nReferrals]->bv_len = slapdFrontendConfig->defaultreferral[nReferrals]->bv_len;
- nReferrals--;
- }
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return refs;
- }
- char *
- config_get_userat ( ){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval( slapdFrontendConfig->userat );
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_timelimit(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal= slapdFrontendConfig->timelimit;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char*
- config_get_useroc(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_WRITE(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->useroc );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_accesslog(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->accesslog);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_errorlog( ){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->errorlog);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_auditlog( ){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->auditlog);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- long
- config_get_pw_maxage() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_maxage;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- long
- config_get_pw_minage(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_minage;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- long
- config_get_pw_warning() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->pw_policy.pw_warning;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_errorlog_level(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->errorloglevel;
- CFG_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
- }
- /* return integer -- don't worry about locking similar to config_check_referral_mode
- below */
- int
- config_get_accesslog_level(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- retVal = slapdFrontendConfig->accessloglevel;
- return retVal;
- }
- /* return integer -- don't worry about locking similar to config_check_referral_mode
- below */
- int
- config_get_auditlog_logging_enabled(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- retVal = slapdFrontendConfig->auditlog_logging_enabled;
- return retVal;
- }
- char *config_get_referral_mode(void)
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *ret;
- CFG_LOCK_READ(slapdFrontendConfig);
- ret = config_copy_strval(slapdFrontendConfig->refer_url);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return ret;
- }
- int
- config_get_conntablesize(void){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->conntablesize;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- /* return yes/no without actually copying the referral url
- we don't worry about another thread changing this value
- since we now return an integer */
- int config_check_referral_mode(void)
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
- }
- int
- config_get_outbound_ldap_io_timeout(void)
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->outbound_ldap_io_timeout;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_unauth_binds_switch(void)
- {
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->allow_unauth_binds;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_require_secure_binds(void)
- {
- int retVal;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->require_secure_binds;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_is_slapd_lite ()
- {
- return ( SLAPD_FULL );
- }
- int
- config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( !apply ) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->maxbersize = atoi(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- ber_len_t
- config_get_maxbersize()
- {
- ber_len_t maxbersize;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- maxbersize = slapdFrontendConfig->maxbersize;
- if(maxbersize==0)
- maxbersize= 2 * 1024 * 1024; /* Default: 2Mb */
- return maxbersize;
- }
- int
- config_set_maxsasliosize( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- long maxsasliosize;
- char *endptr;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- maxsasliosize = strtol(value, &endptr, 10);
- /* Check for non-numeric garbage in the value */
- if (*endptr != '\0') {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- /* Check for a value overflow */
- if (((maxsasliosize == LONG_MAX) || (maxsasliosize == LONG_MIN)) && (errno == ERANGE)){
- retVal = LDAP_OPERATIONS_ERROR;
- }
- /* A setting of -1 means unlimited. Don't allow other negative values. */
- if ((maxsasliosize < 0) && (maxsasliosize != -1)) {
- retVal = LDAP_OPERATIONS_ERROR;
- }
- if (retVal != LDAP_SUCCESS) {
- PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: \"%s\" is invalid. Value must range from -1 to %ld",
- attrname, value, LONG_MAX );
- } else if (apply) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->maxsasliosize = maxsasliosize;
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return retVal;
- }
- size_t
- config_get_maxsasliosize()
- {
- size_t maxsasliosize;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- maxsasliosize = slapdFrontendConfig->maxsasliosize;
- return maxsasliosize;
- }
- int
- config_set_max_filter_nest_level( const char *attrname, char *value,
- char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( !apply ) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->max_filter_nest_level = atoi(value);
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- int
- config_get_max_filter_nest_level()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = slapdFrontendConfig->max_filter_nest_level;
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_basedn() {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval ( slapdFrontendConfig->certmap_basedn );
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_basedn ( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if ( !apply ) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free ( (void **) &slapdFrontendConfig->certmap_basedn );
- slapdFrontendConfig->certmap_basedn = slapi_dn_normalize( slapi_ch_strdup(value) );
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_configdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->configdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_configdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->configdir);
- slapdFrontendConfig->configdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- /* W/o the setter, "config_set: the attribute nsslapd-instancedir is read only" is printed out. */
- int
- config_set_instancedir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- return LDAP_SUCCESS;
- }
- char *
- config_get_schemadir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->schemadir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_schemadir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->schemadir);
- slapdFrontendConfig->schemadir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_lockdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->lockdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_lockdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->lockdir);
- slapdFrontendConfig->lockdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_tmpdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->tmpdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_tmpdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->tmpdir);
- slapdFrontendConfig->tmpdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_certdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->certdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_certdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->certdir);
- slapdFrontendConfig->certdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_ldifdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->ldifdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_ldifdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->ldifdir);
- slapdFrontendConfig->ldifdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_bakdir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->bakdir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_bakdir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->bakdir);
- slapdFrontendConfig->bakdir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_rundir()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->rundir);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_rundir(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
-
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->rundir);
- slapdFrontendConfig->rundir = slapi_ch_strdup(value);
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char *
- config_get_saslpath()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- char *retVal;
- CFG_LOCK_READ(slapdFrontendConfig);
- retVal = config_copy_strval(slapdFrontendConfig->saslpath);
- CFG_UNLOCK_READ(slapdFrontendConfig);
- return retVal;
- }
- int
- config_set_saslpath(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if (!apply) {
- return retVal;
- }
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free((void **)&slapdFrontendConfig->saslpath);
- slapdFrontendConfig->saslpath = slapi_ch_strdup(value);
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- return retVal;
- }
- char **
- config_get_errorlog_list()
- {
- return log_get_loglist(SLAPD_ERROR_LOG);
- }
- char **
- config_get_accesslog_list()
- {
- return log_get_loglist(SLAPD_ACCESS_LOG);
- }
- char **
- config_get_auditlog_list()
- {
- return log_get_loglist(SLAPD_AUDIT_LOG);
- }
- int
- config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->accesslogbuffering),
- errorbuf,
- apply);
-
- return retVal;
- }
- #ifdef MEMPOOL_EXPERIMENTAL
- int
- config_set_mempool_switch( const char *attrname, char *value, char *errorbuf, int apply ) {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->mempool_switch),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_get_mempool_switch()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->mempool_switch;
- }
- int
- config_set_mempool_maxfreelist( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- char *endp = NULL;
- int maxfreelist;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- errno = 0;
- maxfreelist = strtol(value, &endp, 10);
- if (0 != errno ) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->mempool_maxfreelist = maxfreelist;
-
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_get_mempool_maxfreelist()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->mempool_maxfreelist;
- }
- long
- config_get_system_page_size()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->system_page_size;
- }
- int
- config_get_system_page_bits()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->system_page_bits;
- }
- #endif /* MEMPOOL_EXPERIMENTAL */
- int
- config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->csnlogging),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_get_csnlogging()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->csnlogging;
- }
- int
- config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->attrname_exceptions),
- errorbuf,
- apply);
-
- return retVal;
- }
- int
- config_get_attrname_exceptions()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- return slapdFrontendConfig->attrname_exceptions;
- }
- int
- config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int val = 0;
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff(attrname,
- value,
- &val,
- errorbuf,
- apply);
-
- if (retVal == LDAP_SUCCESS) {
- set_hash_filters(val);
- }
- return retVal;
- }
- int
- config_get_hash_filters()
- {
- return 0; /* for now */
- }
- int
- config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply)
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->rewrite_rfc1274),
- errorbuf,
- apply);
-
- return retVal;
- }
- /* we don't worry about another thread changing this flag since it is an
- integer */
- int
- config_get_rewrite_rfc1274()
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
- retVal = slapdFrontendConfig->rewrite_rfc1274;
- return retVal;
- }
- static int
- config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- retVal = LDAP_OPERATIONS_ERROR;
- } else {
- /*
- * check that the value is one we allow.
- */
- if ( 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_OFF ) &&
- 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
- 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
- retVal = LDAP_OPERATIONS_ERROR;
- if( errorbuf ) {
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
- }
- }
- }
- if ( LDAP_SUCCESS == retVal && apply ) {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapi_ch_free( (void **)&slapdFrontendConfig->schemareplace );
- slapdFrontendConfig->schemareplace = slapi_ch_strdup( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
-
- return retVal;
- }
- int
- config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
- char *errorbuf, int apply )
- {
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
-
- if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
- return LDAP_OPERATIONS_ERROR;
- }
- if ( apply ) {
- CFG_LOCK_WRITE(slapdFrontendConfig);
- slapdFrontendConfig->outbound_ldap_io_timeout = atoi( value );
- CFG_UNLOCK_WRITE(slapdFrontendConfig);
- }
- return LDAP_SUCCESS;
- }
- int
- config_set_unauth_binds_switch( const char *attrname, char *value,
- char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->allow_unauth_binds),
- errorbuf,
- apply);
- return retVal;
- }
- int
- config_set_require_secure_binds( const char *attrname, char *value,
- char *errorbuf, int apply )
- {
- int retVal = LDAP_SUCCESS;
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- retVal = config_set_onoff(attrname,
- value,
- &(slapdFrontendConfig->require_secure_binds),
- errorbuf,
- apply);
- return retVal;
- }
- /*
- * This function is intended to be used from the dse code modify callback. It
- * is "optimized" for that case because it takes a berval** of values, which is
- * currently what is used by ldapmod to hold the values. We could easily switch
- * this to take a Slapi_Value array or even a Slapi_Attr. Most config params
- * have simple config_set_XXX functions which take a char* argument holding the
- * value. The log_set_XXX functions have an additional parameter which
- * discriminates the log to use. The config parameters with types CONFIG_SPECIAL_XXX
- * require special handling to set their values.
- */
- int
- config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
- {
- int ii = 0;
- int retval = LDAP_SUCCESS;
- struct config_get_and_set *cgas = 0;
- cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash, attr);
- if (!cgas)
- {
- #if 0
- debugHashTable(attr);
- #endif
- PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
- slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
- return retval;
- }
- switch (cgas->config_var_type)
- {
- case CONFIG_SPECIAL_REFERRALLIST:
- if (NULL == values) /* special token which means to remove referrals */
- {
- struct berval val;
- struct berval *vals[2] = {0, 0};
- vals[0] = &val;
- val.bv_val = REFERRAL_REMOVE_CMD;
- val.bv_len = strlen(REFERRAL_REMOVE_CMD);
- retval = config_set_defaultreferral(attr, vals, errorbuf, apply);
- }
- else
- {
- retval = config_set_defaultreferral(attr, values, errorbuf, apply);
- }
- break;
- default:
- for (ii = 0; !retval && values && values[ii]; ++ii)
- {
- if (cgas->setfunc)
- retval = (cgas->setfunc)(cgas->attr_name,
- (char *)values[ii]->bv_val, errorbuf, apply);
- else if (cgas->logsetfunc)
- retval = (cgas->logsetfunc)(cgas->attr_name,
- (char *)values[ii]->bv_val, cgas->whichlog,
- errorbuf, apply);
- else
- LDAPDebug(LDAP_DEBUG_ANY,
- "config_set: the attribute %s is read only; ignoring new value %s\n",
- attr, values[ii]->bv_val, 0);
- }
- break;
- }
- return retval;
- }
- static void
- config_set_value(
- Slapi_Entry *e,
- struct config_get_and_set *cgas,
- void **value
- )
- {
- struct berval **values = 0;
- char *sval = 0;
- int ival = 0;
- uintptr_t pval;
- /* for null values, just set the attr value to the empty
- string */
- if (!value) {
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- return;
- }
- switch (cgas->config_var_type) {
- case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */
- slapi_entry_attr_set_charptr(e, cgas->attr_name,
- (value && *((int *)value)) ? "on" : "off");
- break;
- case CONFIG_INT:
- if (value)
- slapi_entry_attr_set_int(e, cgas->attr_name, *((int *)value));
- else
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- break;
- case CONFIG_LONG:
- if (value)
- slapi_entry_attr_set_long(e, cgas->attr_name, *((long *)value));
- else
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- break;
- case CONFIG_STRING:
- slapi_entry_attr_set_charptr(e, cgas->attr_name,
- (value && *((char **)value)) ?
- *((char **)value) : "");
- break;
- case CONFIG_CHARRAY:
- values = strarray2bervalarray((const char **)*((char ***)value));
- if (!values) {
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- } else {
- slapi_entry_attr_replace(e, cgas->attr_name, values);
- bervalarray_free(values);
- }
- break;
- case CONFIG_SPECIAL_REFERRALLIST:
- /* referral list is already an array of berval* */
- if (value)
- slapi_entry_attr_replace(e, cgas->attr_name, (struct berval**)*value);
- else
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- break;
- case CONFIG_CONSTANT_STRING:
- PR_ASSERT(value); /* should be a constant value */
- slapi_entry_attr_set_charptr(e, cgas->attr_name, (char*)value);
- break;
- case CONFIG_CONSTANT_INT:
- PR_ASSERT(value); /* should be a constant value */
- pval = (uintptr_t)value;
- ival = (int)pval;
- slapi_entry_attr_set_int(e, cgas->attr_name, ival);
- break;
- case CONFIG_SPECIAL_SSLCLIENTAUTH:
- if (!value) {
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
- break;
- }
- if (*((int *)value) == SLAPD_SSLCLIENTAUTH_ALLOWED) {
- sval = "allowed";
- } else if (*((int *)value) == SLAPD_SSLCLIENTAUTH_REQUIRED) {
- sval = "required";
- } else {
- sval = "off";
- }
- slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
- break;
- case CONFIG_STRING_OR_OFF:
- slapi_entry_attr_set_charptr(e, cgas->attr_name,
- (value && *((char **)value)) ?
- *((char **)value) : "off");
- break;
- case CONFIG_STRING_OR_EMPTY:
- slapi_entry_attr_set_charptr(e, cgas->attr_name,
- (value && *((char **)value)) ?
- *((char **)value) : "");
- break;
- case CONFIG_STRING_OR_UNKNOWN:
- slapi_entry_attr_set_charptr(e, cgas->attr_name,
- (value && *((char **)value)) ?
- *((char **)value) : "unknown");
- break;
- case CONFIG_SPECIAL_ERRORLOGLEVEL:
- if (value) {
- int ival = *(int *)value;
- ival &= ~LDAP_DEBUG_ANY;
- slapi_entry_attr_set_int(e, cgas->attr_name, ival);
- }
- else
- slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
- break;
- default:
- PR_ASSERT(0); /* something went horribly wrong . . . */
- break;
- }
- return;
- }
- /*
- * Fill in the given slapi_entry with the config attributes and values
- */
- int
- config_set_entry(Slapi_Entry *e)
- {
- int ii = 0;
- int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- /*
- * Avoid recursive calls to the readers/writer
- * lock as it causes deadlock under stress. Each
- * individual config get function acquires a read
- * lock where necessary.
- */
- /*
- * Pass 1: Values which do not have a get function.
- */
- CFG_LOCK_READ(slapdFrontendConfig);
- for (ii = 0; ii < tablesize; ++ii) {
- struct config_get_and_set *cgas = &ConfigList[ii];
- void **value = 0;
- PR_ASSERT(cgas);
- value = cgas->config_var_addr;
- PR_ASSERT(cgas->attr_name);
- /* Skip values handled in pass 2 */
- if (NULL == value && cgas->getfunc) {
- continue;
- }
- config_set_value(e, cgas, value);
- }
- CFG_UNLOCK_READ(slapdFrontendConfig);
- /*
- * Pass 2: Values which do have a get function.
- */
- for (ii = 0; ii < tablesize; ++ii) {
- struct config_get_and_set *cgas = &ConfigList[ii];
- int ival = 0;
- long lval = 0;
- void **value = NULL;
- void *alloc_val = NULL;
- int needs_free = 0;
- PR_ASSERT(cgas);
- value = cgas->config_var_addr;
- PR_ASSERT(cgas->attr_name);
- /* Skip values handled in pass 1 */
- if (NULL != value || cgas->getfunc == NULL) {
- continue;
- }
- /* must cast return of getfunc and store in variable of correct sized type */
- /* otherwise endianness problems will ensue */
- if (isInt(cgas->config_var_type)) {
- ival = (int)(intptr_t)(cgas->getfunc)();
- value = (void **)&ival; /* value must be address of int */
- } else if (cgas->config_var_type == CONFIG_LONG) {
- lval = (long)(intptr_t)(cgas->getfunc)();
- value = (void **)&lval; /* value must be address of long */
- } else {
- alloc_val = (cgas->getfunc)();
- value = &alloc_val; /* value must be address of pointer */
- needs_free = 1; /* get funcs must return alloc'd memory except for get
- funcs which return a simple integral type e.g. int */
- }
- config_set_value(e, cgas, value);
- if (needs_free && value) { /* assumes memory allocated by slapi_ch_Xalloc */
- if (CONFIG_CHARRAY == cgas->config_var_type) {
- charray_free(*((char ***)value));
- } else if (CONFIG_SPECIAL_REFERRALLIST == cgas->config_var_type) {
- ber_bvecfree(*((struct berval ***)value));
- } else if ((CONFIG_CONSTANT_INT != cgas->config_var_type) && /* do not free constants */
- (CONFIG_CONSTANT_STRING != cgas->config_var_type)) {
- slapi_ch_free(value);
- }
- }
- }
- return 1;
- }
|