libglobs.c 157 KB

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