libglobs.c 125 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480
  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. /*
  39. *
  40. * libglobs.c -- SLAPD library global variables
  41. */
  42. /* for windows only
  43. we define slapd_ldap_debug here, so we don't want to declare
  44. it in any header file which might conflict with our definition
  45. */
  46. #define DONT_DECLARE_SLAPD_LDAP_DEBUG /* see ldaplog.h */
  47. #if defined(NET_SSL)
  48. #include "ldap.h"
  49. #include <sslproto.h>
  50. #include <ldap_ssl.h>
  51. #undef OFF
  52. #undef LITTLE_ENDIAN
  53. #endif
  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. isIntegralType(ConfigVarType type)
  116. {
  117. return type == CONFIG_INT || type == CONFIG_LONG || type == CONFIG_ON_OFF;
  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_DS4_COMPATIBLE_SCHEMA_ATTRIBUTE, config_set_ds4_compatible_schema,
  303. NULL, 0,
  304. (void**)&global_slapdFrontendConfig.ds4_compatible_schema,
  305. CONFIG_ON_OFF, NULL},
  306. {CONFIG_SCHEMA_IGNORE_TRAILING_SPACES,
  307. config_set_schema_ignore_trailing_spaces, NULL, 0,
  308. (void**)&global_slapdFrontendConfig.schema_ignore_trailing_spaces,
  309. CONFIG_ON_OFF, NULL},
  310. {CONFIG_SCHEMAREPLACE_ATTRIBUTE, config_set_schemareplace, NULL, 0,
  311. (void**)&global_slapdFrontendConfig.schemareplace,
  312. CONFIG_STRING_OR_OFF, NULL},
  313. {CONFIG_ACCESSLOG_MAXLOGDISKSPACE_ATTRIBUTE, NULL,
  314. log_set_maxdiskspace, SLAPD_ACCESS_LOG,
  315. (void**)&global_slapdFrontendConfig.accesslog_maxdiskspace, CONFIG_INT, NULL},
  316. {CONFIG_REFERRAL_ATTRIBUTE, (ConfigSetFunc)config_set_defaultreferral,
  317. NULL, 0,
  318. (void**)&global_slapdFrontendConfig.defaultreferral,
  319. CONFIG_SPECIAL_REFERRALLIST, NULL},
  320. {CONFIG_PW_MAXFAILURE_ATTRIBUTE, config_set_pw_maxfailure,
  321. NULL, 0,
  322. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxfailure, CONFIG_INT, NULL},
  323. {CONFIG_ACCESSLOG_ATTRIBUTE, config_set_accesslog,
  324. NULL, 0,
  325. (void**)&global_slapdFrontendConfig.accesslog, CONFIG_STRING_OR_EMPTY, NULL},
  326. {CONFIG_LASTMOD_ATTRIBUTE, config_set_lastmod,
  327. NULL, 0,
  328. (void**)&global_slapdFrontendConfig.lastmod, CONFIG_ON_OFF, NULL},
  329. {CONFIG_ROOTPWSTORAGESCHEME_ATTRIBUTE, config_set_rootpwstoragescheme,
  330. NULL, 0, NULL, CONFIG_STRING, (ConfigGetFunc)config_get_rootpwstoragescheme},
  331. {CONFIG_PW_HISTORY_ATTRIBUTE, config_set_pw_history,
  332. NULL, 0,
  333. (void**)&global_slapdFrontendConfig.pw_policy.pw_history, CONFIG_ON_OFF, NULL},
  334. {CONFIG_SECURITY_ATTRIBUTE, config_set_security,
  335. NULL, 0,
  336. (void**)&global_slapdFrontendConfig.security, CONFIG_ON_OFF, NULL},
  337. {CONFIG_PW_MAXAGE_ATTRIBUTE, config_set_pw_maxage,
  338. NULL, 0,
  339. (void**)&global_slapdFrontendConfig.pw_policy.pw_maxage, CONFIG_LONG, NULL},
  340. {CONFIG_AUDITLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  341. log_set_rotationtimeunit, SLAPD_AUDIT_LOG,
  342. (void**)&global_slapdFrontendConfig.auditlog_rotationunit,
  343. CONFIG_STRING_OR_UNKNOWN, NULL},
  344. {CONFIG_PW_RESETFAILURECOUNT_ATTRIBUTE, config_set_pw_resetfailurecount,
  345. NULL, 0,
  346. (void**)&global_slapdFrontendConfig.pw_policy.pw_resetfailurecount, CONFIG_LONG, NULL},
  347. {CONFIG_PW_ISGLOBAL_ATTRIBUTE, config_set_pw_is_global_policy,
  348. NULL, 0,
  349. (void**)&global_slapdFrontendConfig.pw_is_global_policy, CONFIG_ON_OFF, NULL},
  350. {CONFIG_AUDITLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  351. log_set_numlogsperdir, SLAPD_AUDIT_LOG,
  352. (void**)&global_slapdFrontendConfig.auditlog_maxnumlogs, CONFIG_INT, NULL},
  353. {CONFIG_ERRORLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  354. log_set_expirationtimeunit, SLAPD_ERROR_LOG,
  355. (void**)&global_slapdFrontendConfig.errorlog_exptimeunit,
  356. CONFIG_STRING_OR_UNKNOWN, NULL},
  357. /* errorlog list is read only, so no set func and no config var addr */
  358. {CONFIG_ERRORLOG_LIST_ATTRIBUTE, NULL, NULL, 0, NULL,
  359. CONFIG_CHARRAY, (ConfigGetFunc)config_get_errorlog_list},
  360. {CONFIG_GROUPEVALNESTLEVEL_ATTRIBUTE, config_set_groupevalnestlevel,
  361. NULL, 0,
  362. (void**)&global_slapdFrontendConfig.groupevalnestlevel, CONFIG_INT, NULL},
  363. {CONFIG_ACCESSLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  364. log_set_expirationtimeunit, SLAPD_ACCESS_LOG,
  365. (void**)&global_slapdFrontendConfig.accesslog_exptimeunit,
  366. CONFIG_STRING_OR_UNKNOWN, NULL},
  367. {CONFIG_ROOTPW_ATTRIBUTE, config_set_rootpw,
  368. NULL, 0,
  369. (void**)&global_slapdFrontendConfig.rootpw, CONFIG_STRING, NULL},
  370. {CONFIG_PW_CHANGE_ATTRIBUTE, config_set_pw_change,
  371. NULL, 0,
  372. (void**)&global_slapdFrontendConfig.pw_policy.pw_change, CONFIG_ON_OFF, NULL},
  373. {CONFIG_ACCESSLOGLEVEL_ATTRIBUTE, config_set_accesslog_level,
  374. NULL, 0,
  375. (void**)&global_slapdFrontendConfig.accessloglevel, CONFIG_INT, NULL},
  376. {CONFIG_ERRORLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  377. log_set_rotationtimeunit, SLAPD_ERROR_LOG,
  378. (void**)&global_slapdFrontendConfig.errorlog_rotationunit,
  379. CONFIG_STRING_OR_UNKNOWN, NULL},
  380. {CONFIG_SECUREPORT_ATTRIBUTE, config_set_secureport,
  381. NULL, 0,
  382. (void**)&global_slapdFrontendConfig.secureport, CONFIG_INT, NULL},
  383. {CONFIG_BASEDN_ATTRIBUTE, config_set_basedn,
  384. NULL, 0,
  385. (void**)&global_slapdFrontendConfig.certmap_basedn, CONFIG_STRING, NULL},
  386. {CONFIG_TIMELIMIT_ATTRIBUTE, config_set_timelimit,
  387. NULL, 0,
  388. (void**)&global_slapdFrontendConfig.timelimit, CONFIG_INT, NULL},
  389. {CONFIG_ERRORLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  390. log_set_logsize, SLAPD_ERROR_LOG,
  391. (void**)&global_slapdFrontendConfig.errorlog_maxlogsize, CONFIG_INT, NULL},
  392. {CONFIG_RESERVEDESCRIPTORS_ATTRIBUTE, config_set_reservedescriptors,
  393. NULL, 0,
  394. (void**)&global_slapdFrontendConfig.reservedescriptors, CONFIG_INT, NULL},
  395. /* access log list is read only, no set func, no config var addr */
  396. {CONFIG_ACCESSLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  397. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_accesslog_list},
  398. {CONFIG_SVRTAB_ATTRIBUTE, config_set_srvtab,
  399. NULL, 0,
  400. (void**)&global_slapdFrontendConfig.srvtab, CONFIG_STRING, NULL},
  401. {CONFIG_PW_EXP_ATTRIBUTE, config_set_pw_exp,
  402. NULL, 0,
  403. (void**)&global_slapdFrontendConfig.pw_policy.pw_exp, CONFIG_ON_OFF, NULL},
  404. {CONFIG_ACCESSCONTROL_ATTRIBUTE, config_set_accesscontrol,
  405. NULL, 0,
  406. (void**)&global_slapdFrontendConfig.accesscontrol, CONFIG_ON_OFF, NULL},
  407. {CONFIG_AUDITLOG_LIST_ATTRIBUTE, NULL, NULL, 0,
  408. NULL, CONFIG_CHARRAY, (ConfigGetFunc)config_get_auditlog_list},
  409. {CONFIG_ACCESSLOG_LOGROTATIONTIMEUNIT_ATTRIBUTE, NULL,
  410. log_set_rotationtimeunit, SLAPD_ACCESS_LOG,
  411. (void**)&global_slapdFrontendConfig.accesslog_rotationunit, CONFIG_STRING, NULL},
  412. {CONFIG_PW_LOCKDURATION_ATTRIBUTE, config_set_pw_lockduration,
  413. NULL, 0,
  414. (void**)&global_slapdFrontendConfig.pw_policy.pw_lockduration, CONFIG_LONG, NULL},
  415. {CONFIG_ACCESSLOG_MAXLOGSIZE_ATTRIBUTE, NULL,
  416. log_set_logsize, SLAPD_ACCESS_LOG,
  417. (void**)&global_slapdFrontendConfig.accesslog_maxlogsize, CONFIG_INT, NULL},
  418. {CONFIG_IDLETIMEOUT_ATTRIBUTE, config_set_idletimeout,
  419. NULL, 0,
  420. (void**)&global_slapdFrontendConfig.idletimeout, CONFIG_INT, NULL},
  421. {CONFIG_NAGLE_ATTRIBUTE, config_set_nagle,
  422. NULL, 0,
  423. (void**)&global_slapdFrontendConfig.nagle, CONFIG_ON_OFF, NULL},
  424. {CONFIG_ERRORLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  425. log_set_mindiskspace, SLAPD_ERROR_LOG,
  426. (void**)&global_slapdFrontendConfig.errorlog_minfreespace, CONFIG_INT, NULL},
  427. {CONFIG_AUDITLOG_LOGGING_ENABLED_ATTRIBUTE, NULL,
  428. log_set_logging, SLAPD_AUDIT_LOG,
  429. (void**)&global_slapdFrontendConfig.auditlog_logging_enabled, CONFIG_ON_OFF, NULL},
  430. {CONFIG_ACCESSLOG_BUFFERING_ATTRIBUTE, config_set_accesslogbuffering,
  431. NULL, 0,
  432. (void**)&global_slapdFrontendConfig.accesslogbuffering, CONFIG_ON_OFF, NULL},
  433. {CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
  434. NULL, 0,
  435. (void**)&global_slapdFrontendConfig.csnlogging, CONFIG_ON_OFF, NULL},
  436. {CONFIG_AUDITLOG_LOGEXPIRATIONTIMEUNIT_ATTRIBUTE, NULL,
  437. log_set_expirationtimeunit, SLAPD_AUDIT_LOG,
  438. (void**)&global_slapdFrontendConfig.auditlog_exptimeunit,
  439. CONFIG_STRING_OR_UNKNOWN, NULL},
  440. {CONFIG_PW_SYNTAX_ATTRIBUTE, config_set_pw_syntax,
  441. NULL, 0,
  442. (void**)&global_slapdFrontendConfig.pw_policy.pw_syntax, CONFIG_ON_OFF, NULL},
  443. {CONFIG_LISTENHOST_ATTRIBUTE, config_set_listenhost,
  444. NULL, 0,
  445. (void**)&global_slapdFrontendConfig.listenhost, CONFIG_STRING, NULL},
  446. {CONFIG_ACCESSLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  447. log_set_mindiskspace, SLAPD_ACCESS_LOG,
  448. (void**)&global_slapdFrontendConfig.accesslog_minfreespace, CONFIG_INT, NULL},
  449. {CONFIG_ERRORLOG_MAXNUMOFLOGSPERDIR_ATTRIBUTE, NULL,
  450. log_set_numlogsperdir, SLAPD_ERROR_LOG,
  451. (void**)&global_slapdFrontendConfig.errorlog_maxnumlogs, CONFIG_INT, NULL},
  452. {CONFIG_SECURELISTENHOST_ATTRIBUTE, config_set_securelistenhost,
  453. NULL, 0,
  454. (void**)&global_slapdFrontendConfig.securelistenhost, CONFIG_STRING, NULL},
  455. {CONFIG_AUDITLOG_MINFREEDISKSPACE_ATTRIBUTE, NULL,
  456. log_set_mindiskspace, SLAPD_AUDIT_LOG,
  457. (void**)&global_slapdFrontendConfig.auditlog_minfreespace, CONFIG_INT, NULL},
  458. {CONFIG_ROOTDN_ATTRIBUTE, config_set_rootdn,
  459. NULL, 0,
  460. (void**)&global_slapdFrontendConfig.rootdn, CONFIG_STRING, NULL},
  461. {CONFIG_PW_MINAGE_ATTRIBUTE, config_set_pw_minage,
  462. NULL, 0,
  463. (void**)&global_slapdFrontendConfig.pw_policy.pw_minage, CONFIG_LONG, NULL},
  464. {CONFIG_AUDITFILE_ATTRIBUTE, config_set_auditlog,
  465. NULL, 0,
  466. (void**)&global_slapdFrontendConfig.auditlog, CONFIG_STRING_OR_EMPTY, NULL},
  467. {CONFIG_RETURN_EXACT_CASE_ATTRIBUTE, config_set_return_exact_case,
  468. NULL, 0,
  469. (void**)&global_slapdFrontendConfig.return_exact_case, CONFIG_ON_OFF, NULL},
  470. {CONFIG_RESULT_TWEAK_ATTRIBUTE, config_set_result_tweak,
  471. NULL, 0,
  472. (void**)&global_slapdFrontendConfig.result_tweak, CONFIG_ON_OFF, NULL},
  473. {CONFIG_ATTRIBUTE_NAME_EXCEPTION_ATTRIBUTE, config_set_attrname_exceptions,
  474. NULL, 0,
  475. (void**)&global_slapdFrontendConfig.attrname_exceptions, CONFIG_ON_OFF, NULL},
  476. {CONFIG_MAXBERSIZE_ATTRIBUTE, config_set_maxbersize,
  477. NULL, 0,
  478. (void**)&global_slapdFrontendConfig.maxbersize, CONFIG_INT, NULL},
  479. {CONFIG_VERSIONSTRING_ATTRIBUTE, config_set_versionstring,
  480. NULL, 0,
  481. (void**)&global_slapdFrontendConfig.versionstring, CONFIG_STRING, NULL},
  482. {CONFIG_REFERRAL_MODE_ATTRIBUTE, config_set_referral_mode,
  483. NULL, 0,
  484. (void**)&global_slapdFrontendConfig.refer_url, CONFIG_STRING, NULL},
  485. #if !defined(_WIN32) && !defined(AIX)
  486. {CONFIG_MAXDESCRIPTORS_ATTRIBUTE, config_set_maxdescriptors,
  487. NULL, 0,
  488. (void**)&global_slapdFrontendConfig.maxdescriptors, CONFIG_INT, NULL},
  489. #endif
  490. {CONFIG_CONNTABLESIZE_ATTRIBUTE, config_set_conntablesize,
  491. NULL, 0,
  492. (void**)&global_slapdFrontendConfig.conntablesize, CONFIG_INT, NULL},
  493. {CONFIG_SSLCLIENTAUTH_ATTRIBUTE, config_set_SSLclientAuth,
  494. NULL, 0,
  495. (void **)&global_slapdFrontendConfig.SSLclientAuth, CONFIG_SPECIAL_SSLCLIENTAUTH, NULL},
  496. {CONFIG_SSL_CHECK_HOSTNAME_ATTRIBUTE, config_set_ssl_check_hostname,
  497. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_ssl_check_hostname},
  498. {CONFIG_CONFIG_ATTRIBUTE, 0, NULL, 0, (void**)SLAPD_CONFIG_DN,
  499. CONFIG_CONSTANT_STRING, NULL},
  500. {CONFIG_HASH_FILTERS_ATTRIBUTE, config_set_hash_filters,
  501. NULL, 0, NULL, CONFIG_ON_OFF, (ConfigGetFunc)config_get_hash_filters},
  502. {CONFIG_INSTANCEDIR_ATTRIBUTE, NULL /* read only */,
  503. NULL, 0,
  504. (void**)&global_slapdFrontendConfig.instancedir, CONFIG_STRING, NULL},
  505. {CONFIG_REWRITE_RFC1274_ATTRIBUTE, config_set_rewrite_rfc1274,
  506. NULL, 0,
  507. (void**)&global_slapdFrontendConfig.rewrite_rfc1274, CONFIG_ON_OFF, NULL},
  508. {CONFIG_OUTBOUND_LDAP_IO_TIMEOUT_ATTRIBUTE,
  509. config_set_outbound_ldap_io_timeout,
  510. NULL, 0,
  511. (void **)&global_slapdFrontendConfig.outbound_ldap_io_timeout,
  512. CONFIG_INT, NULL}
  513. };
  514. /*
  515. * hashNocaseString - used for case insensitive hash lookups
  516. */
  517. static PLHashNumber
  518. hashNocaseString(const void *key)
  519. {
  520. PLHashNumber h = 0;
  521. const unsigned char *s;
  522. for (s = key; *s; s++)
  523. h = (h >> 28) ^ (h << 4) ^ (tolower(*s));
  524. return h;
  525. }
  526. /*
  527. * hashNocaseCompare - used for case insensitive hash key comparisons
  528. */
  529. static PRIntn
  530. hashNocaseCompare(const void *v1, const void *v2)
  531. {
  532. return (strcasecmp((char *)v1, (char *)v2) == 0);
  533. }
  534. static PLHashTable *confighash = 0;
  535. static void
  536. init_config_get_and_set()
  537. {
  538. if (!confighash) {
  539. int ii = 0;
  540. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  541. confighash = PL_NewHashTable(tablesize+1, hashNocaseString,
  542. hashNocaseCompare,
  543. PL_CompareValues, 0, 0);
  544. for (ii = 0; ii < tablesize; ++ii) {
  545. if (PL_HashTableLookup(confighash, ConfigList[ii].attr_name))
  546. printf("error: %s is already in the list\n",
  547. ConfigList[ii].attr_name);
  548. if (!PL_HashTableAdd(confighash, ConfigList[ii].attr_name, &ConfigList[ii]))
  549. printf("error: could not add %s to the list\n",
  550. ConfigList[ii].attr_name);
  551. }
  552. }
  553. }
  554. #if 0
  555. #define GOLDEN_RATIO 0x9E3779B9U
  556. PR_IMPLEMENT(PLHashEntry **)
  557. PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
  558. {
  559. PLHashEntry *he, **hep, **hep0;
  560. PLHashNumber h;
  561. #ifdef HASHMETER
  562. ht->nlookups++;
  563. #endif
  564. h = keyHash * GOLDEN_RATIO;
  565. h >>= ht->shift;
  566. hep = hep0 = &ht->buckets[h];
  567. while ((he = *hep) != 0) {
  568. if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
  569. /* Move to front of chain if not already there */
  570. if (hep != hep0) {
  571. *hep = he->next;
  572. he->next = *hep0;
  573. *hep0 = he;
  574. }
  575. return hep0;
  576. }
  577. hep = &he->next;
  578. #ifdef HASHMETER
  579. ht->nsteps++;
  580. #endif
  581. }
  582. return hep;
  583. }
  584. static void
  585. debugHashTable(const char *key)
  586. {
  587. int ii = 0;
  588. PLHashEntry **hep = PL_HashTableRawLookup(confighash, hashNocaseString(key),
  589. key);
  590. if (!hep || !*hep)
  591. printf("raw lookup failed for %s\n", key);
  592. else if (hep && *hep)
  593. printf("raw lookup found %s -> %ul %s\n", key, (*hep)->keyHash, (*hep)->key);
  594. printf("hash table has %d entries\n", confighash->nentries);
  595. for (ii = 0; ii < confighash->nentries; ++ii)
  596. {
  597. PLHashEntry *he = confighash->buckets[ii];
  598. if (!he)
  599. printf("hash table entry %d is null\n", ii);
  600. else {
  601. printf("hash bucket %d:\n", ii);
  602. while (he) {
  603. int keys = !hashNocaseCompare(key, he->key);
  604. int hash = (hashNocaseString(key) == he->keyHash);
  605. printf("\thashval = %ul key = %s\n", he->keyHash, he->key);
  606. if (keys && hash) {
  607. printf("\t\tFOUND\n");
  608. } else if (keys) {
  609. printf("\t\tkeys match but hash vals do not\n");
  610. } else if (hash) {
  611. printf("\t\thash match but keys do not\n");
  612. }
  613. he = he->next;
  614. }
  615. }
  616. }
  617. }
  618. #endif
  619. static void
  620. bervalarray_free(struct berval **bvec)
  621. {
  622. int ii = 0;
  623. for(ii = 0; bvec && bvec[ii]; ++ii) {
  624. slapi_ch_free((void **)&bvec[ii]->bv_val);
  625. slapi_ch_free((void **)&bvec[ii]);
  626. }
  627. slapi_ch_free((void**)&bvec);
  628. }
  629. static struct berval **
  630. strarray2bervalarray(const char **strarray)
  631. {
  632. int ii = 0;
  633. struct berval **newlist = 0;
  634. /* first, count the number of items in the list */
  635. for (ii = 0; strarray && strarray[ii]; ++ii);
  636. /* if no items, return null */
  637. if (!ii)
  638. return newlist;
  639. /* allocate the list */
  640. newlist = (struct berval **)slapi_ch_malloc((ii+1) * sizeof(struct berval *));
  641. newlist[ii] = 0;
  642. for (; ii; --ii) {
  643. newlist[ii-1] = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
  644. newlist[ii-1]->bv_val = slapi_ch_strdup(strarray[ii-1]);
  645. newlist[ii-1]->bv_len = strlen(strarray[ii-1]);
  646. }
  647. return newlist;
  648. }
  649. /*
  650. ** Setting this flag forces the server to shutdown.
  651. */
  652. static int slapd_shutdown;
  653. void g_set_shutdown( int reason )
  654. {
  655. slapd_shutdown = reason;
  656. }
  657. int g_get_shutdown()
  658. {
  659. return slapd_shutdown;
  660. }
  661. static int cmd_shutdown;
  662. void c_set_shutdown()
  663. {
  664. cmd_shutdown = SLAPI_SHUTDOWN_SIGNAL;
  665. }
  666. int c_get_shutdown()
  667. {
  668. return cmd_shutdown;
  669. }
  670. slapdFrontendConfig_t *
  671. getFrontendConfig()
  672. {
  673. return &global_slapdFrontendConfig;
  674. }
  675. /*
  676. * FrontendConfig_init:
  677. * Put all default values for config stuff here.
  678. * If there's no default value, the value will be NULL if it's not set in dse.ldif
  679. */
  680. void
  681. FrontendConfig_init () {
  682. slapdFrontendConfig_t *cfg = getFrontendConfig();
  683. /* initialize the read/write configuration lock */
  684. if ( (cfg->cfg_rwlock = rwl_new()) == NULL ) {
  685. LDAPDebug ( LDAP_DEBUG_ANY,
  686. "FrontendConfig_init: failed to initialize cfg_rwlock. Exiting now.",
  687. 0,0,0 );
  688. exit(-1);
  689. }
  690. cfg->port = LDAP_PORT;
  691. cfg->secureport = LDAPS_PORT;
  692. cfg->threadnumber = SLAPD_DEFAULT_MAX_THREADS;
  693. cfg->maxthreadsperconn = SLAPD_DEFAULT_MAX_THREADS_PER_CONN;
  694. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  695. cfg->idletimeout = SLAPD_DEFAULT_IDLE_TIMEOUT;
  696. cfg->ioblocktimeout = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  697. cfg->outbound_ldap_io_timeout = SLAPD_DEFAULT_OUTBOUND_LDAP_IO_TIMEOUT;
  698. cfg->max_filter_nest_level = SLAPD_DEFAULT_MAX_FILTER_NEST_LEVEL;
  699. #ifdef _WIN32
  700. cfg->conntablesize = SLAPD_DEFAULT_CONNTABLESIZE;
  701. #else
  702. #ifdef USE_SYSCONF
  703. cfg->conntablesize = sysconf( _SC_OPEN_MAX );
  704. #else /* USE_SYSCONF */
  705. cfg->conntablesize = getdtablesize();
  706. #endif /* USE_SYSCONF */
  707. #endif /* _WIN32 */
  708. cfg->accesscontrol = LDAP_ON;
  709. cfg->security = LDAP_OFF;
  710. cfg->ssl_check_hostname = LDAP_ON;
  711. cfg->return_exact_case = LDAP_ON;
  712. cfg->result_tweak = LDAP_OFF;
  713. cfg->reservedescriptors = SLAPD_DEFAULT_RESERVE_FDS;
  714. cfg->useroc = slapi_ch_strdup ( "" );
  715. cfg->userat = slapi_ch_strdup ( "" );
  716. /* kexcoff: should not be initialized by default here
  717. cfg->rootpwstoragescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  718. cfg->pw_storagescheme = pw_name2scheme( SHA1_SCHEME_NAME );
  719. */
  720. cfg->slapd_type = 0;
  721. cfg->versionstring = SLAPD_VERSION_STR;
  722. cfg->sizelimit = SLAPD_DEFAULT_SIZELIMIT;
  723. cfg->timelimit = SLAPD_DEFAULT_TIMELIMIT;
  724. cfg->schemacheck = LDAP_ON;
  725. cfg->ds4_compatible_schema = LDAP_OFF;
  726. cfg->enquote_sup_oc = LDAP_OFF;
  727. cfg->lastmod = LDAP_ON;
  728. cfg->rewrite_rfc1274 = LDAP_OFF;
  729. cfg->schemareplace = slapi_ch_strdup( CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY );
  730. cfg->schema_ignore_trailing_spaces = SLAPD_DEFAULT_SCHEMA_IGNORE_TRAILING_SPACES;
  731. cfg->pwpolicy_local = LDAP_OFF;
  732. cfg->pw_policy.pw_change = LDAP_ON;
  733. cfg->pw_policy.pw_must_change = LDAP_OFF;
  734. cfg->pw_policy.pw_syntax = LDAP_OFF;
  735. cfg->pw_policy.pw_exp = LDAP_OFF;
  736. cfg->pw_policy.pw_minlength = 8;
  737. cfg->pw_policy.pw_mindigits = 0;
  738. cfg->pw_policy.pw_minalphas = 0;
  739. cfg->pw_policy.pw_minuppers = 0;
  740. cfg->pw_policy.pw_minlowers = 0;
  741. cfg->pw_policy.pw_minspecials = 0;
  742. cfg->pw_policy.pw_min8bit = 0;
  743. cfg->pw_policy.pw_maxrepeats = 0;
  744. cfg->pw_policy.pw_mincategories = 3;
  745. cfg->pw_policy.pw_mintokenlength = 3;
  746. cfg->pw_policy.pw_maxage = 8640000; /* 100 days */
  747. cfg->pw_policy.pw_minage = 0;
  748. cfg->pw_policy.pw_warning = 86400; /* 1 day */
  749. cfg->pw_policy.pw_history = LDAP_OFF;
  750. cfg->pw_policy.pw_inhistory = 6;
  751. cfg->pw_policy.pw_lockout = LDAP_OFF;
  752. cfg->pw_policy.pw_maxfailure = 3;
  753. cfg->pw_policy.pw_unlock = LDAP_ON;
  754. cfg->pw_policy.pw_lockduration = 3600; /* 60 minutes */
  755. cfg->pw_policy.pw_resetfailurecount = 600; /* 10 minutes */
  756. cfg->pw_policy.pw_gracelimit = 0;
  757. cfg->pw_is_global_policy = LDAP_OFF;
  758. cfg->accesslog_logging_enabled = LDAP_ON;
  759. cfg->accesslog_mode = slapi_ch_strdup("600");
  760. cfg->accesslog_maxnumlogs = 10;
  761. cfg->accesslog_maxlogsize = 100;
  762. cfg->accesslog_rotationtime = 1;
  763. cfg->accesslog_rotationunit = slapi_ch_strdup("day");
  764. cfg->accesslog_rotationsync_enabled = LDAP_OFF;
  765. cfg->accesslog_rotationsynchour = 0;
  766. cfg->accesslog_rotationsyncmin = 0;
  767. cfg->accesslog_maxdiskspace = 500;
  768. cfg->accesslog_minfreespace = 5;
  769. cfg->accesslog_exptime = 1;
  770. cfg->accesslog_exptimeunit = slapi_ch_strdup("month");
  771. cfg->accessloglevel = 256;
  772. cfg->accesslogbuffering = LDAP_ON;
  773. cfg->csnlogging = LDAP_ON;
  774. cfg->errorlog_logging_enabled = LDAP_ON;
  775. cfg->errorlog_mode = slapi_ch_strdup("600");
  776. cfg->errorlog_maxnumlogs = 1;
  777. cfg->errorlog_maxlogsize = 100;
  778. cfg->errorlog_rotationtime = 1;
  779. cfg->errorlog_rotationunit = slapi_ch_strdup ("week");
  780. cfg->errorlog_rotationsync_enabled = LDAP_OFF;
  781. cfg->errorlog_rotationsynchour = 0;
  782. cfg->errorlog_rotationsyncmin = 0;
  783. cfg->errorlog_maxdiskspace = 100;
  784. cfg->errorlog_minfreespace = 5;
  785. cfg->errorlog_exptime = 1;
  786. cfg->errorlog_exptimeunit = slapi_ch_strdup("month");
  787. cfg->errorloglevel = 0;
  788. cfg->auditlog_logging_enabled = LDAP_OFF;
  789. cfg->auditlog_mode = slapi_ch_strdup("600");
  790. cfg->auditlog_maxnumlogs = 1;
  791. cfg->auditlog_maxlogsize = 100;
  792. cfg->auditlog_rotationtime = 1;
  793. cfg->auditlog_rotationunit = slapi_ch_strdup ("week");
  794. cfg->auditlog_rotationsync_enabled = LDAP_OFF;
  795. cfg->auditlog_rotationsynchour = 0;
  796. cfg->auditlog_rotationsyncmin = 0;
  797. cfg->auditlog_maxdiskspace = 100;
  798. cfg->auditlog_minfreespace = 5;
  799. cfg->auditlog_exptime = 1;
  800. cfg->auditlog_exptimeunit = slapi_ch_strdup("month");
  801. init_config_get_and_set();
  802. }
  803. int
  804. g_get_global_lastmod()
  805. {
  806. return config_get_lastmod();
  807. }
  808. int g_get_slapd_security_on(){
  809. return config_get_security();
  810. }
  811. #ifdef _WIN32
  812. void libldap_init_debug_level(int *val_ptr)
  813. {
  814. module_ldap_debug = val_ptr;
  815. }
  816. #endif
  817. struct snmp_vars_t global_snmp_vars;
  818. struct snmp_vars_t * g_get_global_snmp_vars(){
  819. return &global_snmp_vars;
  820. }
  821. static slapdEntryPoints *sep = NULL;
  822. void
  823. set_dll_entry_points( slapdEntryPoints *p )
  824. {
  825. if ( NULL == sep )
  826. {
  827. sep = p;
  828. }
  829. }
  830. int
  831. get_entry_point( int ep_name, caddr_t *ep_addr )
  832. {
  833. int rc = 0;
  834. if(sep!=NULL)
  835. {
  836. switch ( ep_name ) {
  837. case ENTRY_POINT_PS_WAKEUP_ALL:
  838. *ep_addr = sep->sep_ps_wakeup_all;
  839. break;
  840. case ENTRY_POINT_PS_SERVICE:
  841. *ep_addr = sep->sep_ps_service;
  842. break;
  843. case ENTRY_POINT_DISCONNECT_SERVER:
  844. *ep_addr = sep->sep_disconnect_server;
  845. break;
  846. case ENTRY_POINT_SLAPD_SSL_CLIENT_INIT:
  847. *ep_addr = sep->sep_slapd_SSL_client_init;
  848. break;
  849. case ENTRY_POINT_SLAPD_SSL_INIT:
  850. *ep_addr = sep->sep_slapd_ssl_init;
  851. break;
  852. case ENTRY_POINT_SLAPD_SSL_INIT2:
  853. *ep_addr = sep->sep_slapd_ssl_init2;
  854. break;
  855. default:
  856. rc = -1;
  857. }
  858. }
  859. else
  860. {
  861. rc= -1;
  862. }
  863. return rc;
  864. }
  865. /*
  866. * Utility function called by many of the config_set_XXX() functions.
  867. * Returns a non-zero value if 'value' is NULL and zero if not.
  868. * Also constructs an error message in 'errorbuf' if value is NULL.
  869. * If or_zero_length is non-zero, zero length values are treated as
  870. * equivalent to NULL (i.e., they will cause a non-zero value to be
  871. * returned by this function).
  872. */
  873. static int
  874. config_value_is_null( const char *attrname, const char *value, char *errorbuf,
  875. int or_zero_length )
  876. {
  877. if ( NULL == value || ( or_zero_length && *value == '\0' )) {
  878. PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: NULL value",
  879. attrname );
  880. return 1;
  881. }
  882. return 0;
  883. }
  884. int
  885. config_set_port( const char *attrname, char *port, char *errorbuf, int apply ) {
  886. int nPort;
  887. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  888. int retVal = LDAP_SUCCESS;
  889. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  890. return LDAP_OPERATIONS_ERROR;
  891. }
  892. nPort = atoi( port );
  893. if ( nPort == 0 ) {
  894. LDAPDebug( LDAP_DEBUG_ANY,
  895. "Information: Non-Secure Port Disabled, server only contactable via secure port\n", 0, 0, 0 );
  896. }
  897. else if (nPort > LDAP_PORT_MAX || nPort < 0 ) {
  898. retVal = LDAP_OPERATIONS_ERROR;
  899. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  900. "%s: %d is invalid, ports must range from 1 to %d",
  901. attrname, nPort, LDAP_PORT_MAX );
  902. }
  903. if ( apply ) {
  904. CFG_LOCK_WRITE(slapdFrontendConfig);
  905. slapdFrontendConfig->port = nPort;
  906. /* n_port = nPort; */
  907. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  908. }
  909. return retVal;
  910. }
  911. int
  912. config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply ) {
  913. int nPort = atoi ( port );
  914. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  915. int retVal = LDAP_SUCCESS;
  916. if ( config_value_is_null( attrname, port, errorbuf, 0 )) {
  917. return LDAP_OPERATIONS_ERROR;
  918. }
  919. if (nPort > LDAP_PORT_MAX || nPort <= 0 ) {
  920. retVal = LDAP_OPERATIONS_ERROR;
  921. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  922. "%s: %d is invalid, ports must range from 1 to %d",
  923. attrname, nPort, LDAP_PORT_MAX );
  924. }
  925. if (apply) {
  926. CFG_LOCK_WRITE(slapdFrontendConfig);
  927. slapdFrontendConfig->secureport = nPort;
  928. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  929. }
  930. return retVal;
  931. }
  932. int
  933. config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply ) {
  934. int retVal = LDAP_SUCCESS;
  935. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  936. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  937. retVal = LDAP_OPERATIONS_ERROR;
  938. }
  939. /* first check the value, return an error if it's invalid */
  940. else if ( strcasecmp (value, "off") != 0 &&
  941. strcasecmp (value, "allowed") != 0 &&
  942. strcasecmp (value, "required")!= 0 ) {
  943. retVal = LDAP_OPERATIONS_ERROR;
  944. if( errorbuf )
  945. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  946. "%s: unsupported value: %s", attrname, value );
  947. return retVal;
  948. }
  949. else if ( !apply ) {
  950. /* return success now, if we aren't supposed to apply the change */
  951. return retVal;
  952. }
  953. CFG_LOCK_WRITE(slapdFrontendConfig);
  954. if ( !strcasecmp( value, "off" )) {
  955. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_OFF;
  956. }
  957. else if ( !strcasecmp( value, "allowed" )) {
  958. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_ALLOWED;
  959. }
  960. else if ( !strcasecmp( value, "required" )) {
  961. slapdFrontendConfig->SSLclientAuth = SLAPD_SSLCLIENTAUTH_REQUIRED;
  962. }
  963. else {
  964. retVal = LDAP_OPERATIONS_ERROR;
  965. if( errorbuf )
  966. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  967. "%s: unsupported value: %s", attrname, value );
  968. }
  969. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  970. return retVal;
  971. }
  972. int
  973. config_set_ssl_check_hostname(const char *attrname, char *value,
  974. char *errorbuf, int apply)
  975. {
  976. int retVal = LDAP_SUCCESS;
  977. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  978. retVal = config_set_onoff(attrname,
  979. value,
  980. &(slapdFrontendConfig->ssl_check_hostname),
  981. errorbuf,
  982. apply);
  983. return retVal;
  984. }
  985. int
  986. config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  987. int retVal = LDAP_SUCCESS;
  988. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  989. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  990. return LDAP_OPERATIONS_ERROR;
  991. }
  992. if (apply) {
  993. CFG_LOCK_WRITE(slapdFrontendConfig);
  994. slapi_ch_free ( (void **) &(slapdFrontendConfig->localhost) );
  995. slapdFrontendConfig->localhost = slapi_ch_strdup ( value );
  996. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  997. }
  998. return retVal;
  999. }
  1000. int
  1001. config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1002. int retVal = LDAP_SUCCESS;
  1003. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1004. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1005. return LDAP_OPERATIONS_ERROR;
  1006. }
  1007. if ( apply) {
  1008. CFG_LOCK_WRITE(slapdFrontendConfig);
  1009. slapi_ch_free ( (void **) &(slapdFrontendConfig->listenhost) );
  1010. slapdFrontendConfig->listenhost = slapi_ch_strdup ( value );
  1011. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1012. }
  1013. return retVal;
  1014. }
  1015. int
  1016. config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply ) {
  1017. int retVal = LDAP_SUCCESS;
  1018. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1019. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1020. return LDAP_OPERATIONS_ERROR;
  1021. }
  1022. if ( apply ) {
  1023. CFG_LOCK_WRITE(slapdFrontendConfig);
  1024. slapi_ch_free ( (void **) &(slapdFrontendConfig->securelistenhost) );
  1025. slapdFrontendConfig->securelistenhost = slapi_ch_strdup ( value );
  1026. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1027. }
  1028. return retVal;
  1029. }
  1030. int
  1031. config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply ) {
  1032. int retVal = LDAP_SUCCESS;
  1033. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1034. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1035. return LDAP_OPERATIONS_ERROR;
  1036. }
  1037. if (apply) {
  1038. CFG_LOCK_WRITE(slapdFrontendConfig);
  1039. slapi_ch_free ( (void **) &(slapdFrontendConfig->srvtab) );
  1040. ldap_srvtab = slapi_ch_strdup ( value );
  1041. slapdFrontendConfig->srvtab = slapi_ch_strdup ( value );
  1042. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1043. }
  1044. return retVal;
  1045. }
  1046. int
  1047. config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1048. int retVal = LDAP_SUCCESS;
  1049. Slapi_Backend *be;
  1050. char *cookie;
  1051. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1052. int sizelimit = atoi ( value );
  1053. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1054. return LDAP_OPERATIONS_ERROR;
  1055. }
  1056. if ( sizelimit < -1 ) {
  1057. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: %d is too small",
  1058. attrname, sizelimit );
  1059. retVal = LDAP_OPERATIONS_ERROR;
  1060. return retVal;
  1061. }
  1062. if (apply) {
  1063. CFG_LOCK_WRITE(slapdFrontendConfig);
  1064. slapdFrontendConfig->sizelimit= sizelimit;
  1065. g_set_defsize (sizelimit);
  1066. cookie = NULL;
  1067. be = slapi_get_first_backend(&cookie);
  1068. while (be) {
  1069. be->be_sizelimit = slapdFrontendConfig->sizelimit;
  1070. be = slapi_get_next_backend(cookie);
  1071. }
  1072. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1073. slapi_ch_free ((void **)&cookie);
  1074. }
  1075. return retVal;
  1076. }
  1077. int
  1078. config_set_pw_storagescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  1079. int retVal = LDAP_SUCCESS;
  1080. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1081. struct pw_scheme *new_scheme = NULL;
  1082. char * scheme_list = NULL;
  1083. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  1084. return LDAP_OPERATIONS_ERROR;
  1085. }
  1086. scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  1087. new_scheme = pw_name2scheme(value);
  1088. if ( new_scheme == NULL) {
  1089. if ( scheme_list != NULL ) {
  1090. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1091. "%s: invalid scheme - %s. Valid schemes are: %s",
  1092. attrname, value, scheme_list );
  1093. } else {
  1094. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1095. "%s: invalid scheme - %s (no pwdstorage scheme"
  1096. " plugin loaded)",
  1097. attrname, value);
  1098. }
  1099. retVal = LDAP_OPERATIONS_ERROR;
  1100. slapi_ch_free_string(&scheme_list);
  1101. return retVal;
  1102. }
  1103. else if ( new_scheme->pws_enc == NULL )
  1104. {
  1105. /* For example: the NS-MTA-MD5 password scheme is for comparision only and for backward
  1106. compatibility with an Old Messaging Server that was setting passwords in the
  1107. directory already encrypted. The scheme cannot and don't encrypt password if
  1108. they are in clear. We don't take it */
  1109. if ( scheme_list != NULL ) {
  1110. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1111. "pw_storagescheme: invalid encoding scheme - %s\nValid values are: %s\n", value, scheme_list );
  1112. }
  1113. retVal = LDAP_UNWILLING_TO_PERFORM;
  1114. slapi_ch_free_string(&scheme_list);
  1115. return retVal;
  1116. }
  1117. if ( apply ) {
  1118. CFG_LOCK_WRITE(slapdFrontendConfig);
  1119. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  1120. slapdFrontendConfig->pw_storagescheme = new_scheme;
  1121. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1122. }
  1123. slapi_ch_free_string(&scheme_list);
  1124. return retVal;
  1125. }
  1126. int
  1127. config_set_pw_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1128. int retVal = LDAP_SUCCESS;
  1129. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1130. retVal = config_set_onoff ( attrname,
  1131. value,
  1132. &(slapdFrontendConfig->pw_policy.pw_change),
  1133. errorbuf,
  1134. apply);
  1135. if (retVal == LDAP_SUCCESS) {
  1136. /* LP: Update ACI to reflect the value ! */
  1137. if (apply)
  1138. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1139. !slapdFrontendConfig->pw_policy.pw_must_change);
  1140. }
  1141. return retVal;
  1142. }
  1143. int
  1144. config_set_pw_history( const char *attrname, char *value, char *errorbuf, int apply ) {
  1145. int retVal = LDAP_SUCCESS;
  1146. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1147. retVal = config_set_onoff ( attrname,
  1148. value,
  1149. &(slapdFrontendConfig->pw_policy.pw_history),
  1150. errorbuf,
  1151. apply);
  1152. return retVal;
  1153. }
  1154. int
  1155. config_set_pw_must_change( const char *attrname, char *value, char *errorbuf, int apply ) {
  1156. int retVal = LDAP_SUCCESS;
  1157. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1158. retVal = config_set_onoff ( attrname,
  1159. value,
  1160. &(slapdFrontendConfig->pw_policy.pw_must_change),
  1161. errorbuf,
  1162. apply);
  1163. if (retVal == LDAP_SUCCESS) {
  1164. /* LP: Update ACI to reflect the value ! */
  1165. if (apply)
  1166. pw_mod_allowchange_aci(!slapdFrontendConfig->pw_policy.pw_change &&
  1167. !slapdFrontendConfig->pw_policy.pw_must_change);
  1168. }
  1169. return retVal;
  1170. }
  1171. int
  1172. config_set_pwpolicy_local( const char *attrname, char *value, char *errorbuf, int apply ) {
  1173. int retVal = LDAP_SUCCESS;
  1174. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1175. retVal = config_set_onoff ( attrname,
  1176. value,
  1177. &(slapdFrontendConfig->pwpolicy_local),
  1178. errorbuf,
  1179. apply);
  1180. return retVal;
  1181. }
  1182. int
  1183. config_set_pw_syntax( const char *attrname, char *value, char *errorbuf, int apply ) {
  1184. int retVal = LDAP_SUCCESS;
  1185. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1186. retVal = config_set_onoff ( attrname,
  1187. value,
  1188. &(slapdFrontendConfig->pw_policy.pw_syntax),
  1189. errorbuf,
  1190. apply);
  1191. return retVal;
  1192. }
  1193. int
  1194. config_set_pw_minlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  1195. int retVal = LDAP_SUCCESS, minLength = 0;
  1196. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1197. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1198. return LDAP_OPERATIONS_ERROR;
  1199. }
  1200. minLength = atoi(value);
  1201. if ( minLength < 2 || minLength > 512 ) {
  1202. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1203. "password minimum length \"%s\" is invalid. "
  1204. "The minimum length must range from 2 to 512.",
  1205. value );
  1206. retVal = LDAP_OPERATIONS_ERROR;
  1207. return retVal;
  1208. }
  1209. if ( apply ) {
  1210. CFG_LOCK_WRITE(slapdFrontendConfig);
  1211. slapdFrontendConfig->pw_policy.pw_minlength = minLength;
  1212. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1213. }
  1214. return retVal;
  1215. }
  1216. int
  1217. config_set_pw_mindigits( const char *attrname, char *value, char *errorbuf, int apply ) {
  1218. int retVal = LDAP_SUCCESS, minDigits = 0;
  1219. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1220. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1221. return LDAP_OPERATIONS_ERROR;
  1222. }
  1223. minDigits = atoi(value);
  1224. if ( minDigits < 0 || minDigits > 64 ) {
  1225. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1226. "password minimum number of digits \"%s\" is invalid. "
  1227. "The minimum number of digits must range from 0 to 64.",
  1228. value );
  1229. retVal = LDAP_OPERATIONS_ERROR;
  1230. return retVal;
  1231. }
  1232. if ( apply ) {
  1233. CFG_LOCK_WRITE(slapdFrontendConfig);
  1234. slapdFrontendConfig->pw_policy.pw_mindigits = minDigits;
  1235. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1236. }
  1237. return retVal;
  1238. }
  1239. int
  1240. config_set_pw_minalphas( const char *attrname, char *value, char *errorbuf, int apply ) {
  1241. int retVal = LDAP_SUCCESS, minAlphas = 0;
  1242. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1243. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1244. return LDAP_OPERATIONS_ERROR;
  1245. }
  1246. minAlphas = atoi(value);
  1247. if ( minAlphas < 0 || minAlphas > 64 ) {
  1248. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1249. "password minimum number of alphas \"%s\" is invalid. "
  1250. "The minimum number of alphas must range from 0 to 64.",
  1251. value );
  1252. retVal = LDAP_OPERATIONS_ERROR;
  1253. return retVal;
  1254. }
  1255. if ( apply ) {
  1256. CFG_LOCK_WRITE(slapdFrontendConfig);
  1257. slapdFrontendConfig->pw_policy.pw_minalphas = minAlphas;
  1258. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1259. }
  1260. return retVal;
  1261. }
  1262. int
  1263. config_set_pw_minuppers( const char *attrname, char *value, char *errorbuf, int apply ) {
  1264. int retVal = LDAP_SUCCESS, minUppers = 0;
  1265. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1266. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1267. return LDAP_OPERATIONS_ERROR;
  1268. }
  1269. minUppers = atoi(value);
  1270. if ( minUppers < 0 || minUppers > 64 ) {
  1271. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1272. "password minimum number of uppercase characters \"%s\" is invalid. "
  1273. "The minimum number of uppercase characters must range from 0 to 64.",
  1274. value );
  1275. retVal = LDAP_OPERATIONS_ERROR;
  1276. return retVal;
  1277. }
  1278. if ( apply ) {
  1279. CFG_LOCK_WRITE(slapdFrontendConfig);
  1280. slapdFrontendConfig->pw_policy.pw_minuppers = minUppers;
  1281. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1282. }
  1283. return retVal;
  1284. }
  1285. int
  1286. config_set_pw_minlowers( const char *attrname, char *value, char *errorbuf, int apply ) {
  1287. int retVal = LDAP_SUCCESS, minLowers = 0;
  1288. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1289. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1290. return LDAP_OPERATIONS_ERROR;
  1291. }
  1292. minLowers = atoi(value);
  1293. if ( minLowers < 0 || minLowers > 64 ) {
  1294. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1295. "password minimum number of lowercase characters \"%s\" is invalid. "
  1296. "The minimum number of lowercase characters must range from 0 to 64.",
  1297. value );
  1298. retVal = LDAP_OPERATIONS_ERROR;
  1299. return retVal;
  1300. }
  1301. if ( apply ) {
  1302. CFG_LOCK_WRITE(slapdFrontendConfig);
  1303. slapdFrontendConfig->pw_policy.pw_minlowers = minLowers;
  1304. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1305. }
  1306. return retVal;
  1307. }
  1308. int
  1309. config_set_pw_minspecials( const char *attrname, char *value, char *errorbuf, int apply ) {
  1310. int retVal = LDAP_SUCCESS, minSpecials = 0;
  1311. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1312. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1313. return LDAP_OPERATIONS_ERROR;
  1314. }
  1315. minSpecials = atoi(value);
  1316. if ( minSpecials < 0 || minSpecials > 64 ) {
  1317. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1318. "password minimum number of special characters \"%s\" is invalid. "
  1319. "The minimum number of special characters must range from 0 to 64.",
  1320. value );
  1321. retVal = LDAP_OPERATIONS_ERROR;
  1322. return retVal;
  1323. }
  1324. if ( apply ) {
  1325. CFG_LOCK_WRITE(slapdFrontendConfig);
  1326. slapdFrontendConfig->pw_policy.pw_minspecials = minSpecials;
  1327. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1328. }
  1329. return retVal;
  1330. }
  1331. int
  1332. config_set_pw_min8bit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1333. int retVal = LDAP_SUCCESS, min8bit = 0;
  1334. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1335. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1336. return LDAP_OPERATIONS_ERROR;
  1337. }
  1338. min8bit = atoi(value);
  1339. if ( min8bit < 0 || min8bit > 64 ) {
  1340. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1341. "password minimum number of 8-bit characters \"%s\" is invalid. "
  1342. "The minimum number of 8-bit characters must range from 0 to 64.",
  1343. value );
  1344. retVal = LDAP_OPERATIONS_ERROR;
  1345. return retVal;
  1346. }
  1347. if ( apply ) {
  1348. CFG_LOCK_WRITE(slapdFrontendConfig);
  1349. slapdFrontendConfig->pw_policy.pw_min8bit = min8bit;
  1350. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1351. }
  1352. return retVal;
  1353. }
  1354. int
  1355. config_set_pw_maxrepeats( const char *attrname, char *value, char *errorbuf, int apply ) {
  1356. int retVal = LDAP_SUCCESS, maxRepeats = 0;
  1357. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1358. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1359. return LDAP_OPERATIONS_ERROR;
  1360. }
  1361. maxRepeats = atoi(value);
  1362. if ( maxRepeats < 0 || maxRepeats > 64 ) {
  1363. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1364. "password maximum number of repeated characters \"%s\" is invalid. "
  1365. "The maximum number of repeated characters must range from 0 to 64.",
  1366. value );
  1367. retVal = LDAP_OPERATIONS_ERROR;
  1368. return retVal;
  1369. }
  1370. if ( apply ) {
  1371. CFG_LOCK_WRITE(slapdFrontendConfig);
  1372. slapdFrontendConfig->pw_policy.pw_maxrepeats = maxRepeats;
  1373. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1374. }
  1375. return retVal;
  1376. }
  1377. int
  1378. config_set_pw_mincategories( const char *attrname, char *value, char *errorbuf, int apply ) {
  1379. int retVal = LDAP_SUCCESS, minCategories = 0;
  1380. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1381. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1382. return LDAP_OPERATIONS_ERROR;
  1383. }
  1384. minCategories = atoi(value);
  1385. if ( minCategories < 1 || minCategories > 5 ) {
  1386. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1387. "password minimum number of categories \"%s\" is invalid. "
  1388. "The minimum number of categories must range from 1 to 5.",
  1389. value );
  1390. retVal = LDAP_OPERATIONS_ERROR;
  1391. return retVal;
  1392. }
  1393. if ( apply ) {
  1394. CFG_LOCK_WRITE(slapdFrontendConfig);
  1395. slapdFrontendConfig->pw_policy.pw_mincategories = minCategories;
  1396. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1397. }
  1398. return retVal;
  1399. }
  1400. int
  1401. config_set_pw_mintokenlength( const char *attrname, char *value, char *errorbuf, int apply ) {
  1402. int retVal = LDAP_SUCCESS, minTokenLength = 0;
  1403. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1404. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1405. return LDAP_OPERATIONS_ERROR;
  1406. }
  1407. minTokenLength = atoi(value);
  1408. if ( minTokenLength < 1 || minTokenLength > 64 ) {
  1409. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1410. "password minimum token length \"%s\" is invalid. "
  1411. "The minimum token length must range from 1 to 64.",
  1412. value );
  1413. retVal = LDAP_OPERATIONS_ERROR;
  1414. return retVal;
  1415. }
  1416. if ( apply ) {
  1417. CFG_LOCK_WRITE(slapdFrontendConfig);
  1418. slapdFrontendConfig->pw_policy.pw_mintokenlength = minTokenLength;
  1419. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1420. }
  1421. return retVal;
  1422. }
  1423. int
  1424. config_set_pw_maxfailure( const char *attrname, char *value, char *errorbuf, int apply ) {
  1425. int retVal = LDAP_SUCCESS, maxFailure = 0;
  1426. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1427. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1428. return LDAP_OPERATIONS_ERROR;
  1429. }
  1430. maxFailure = atoi(value);
  1431. if ( maxFailure <= 0 || maxFailure > 32767 ) {
  1432. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1433. "password maximum retry \"%s\" is invalid. "
  1434. "Password maximum failure must range from 1 to 32767",
  1435. value );
  1436. retVal = LDAP_OPERATIONS_ERROR;
  1437. return retVal;
  1438. }
  1439. if ( apply ) {
  1440. CFG_LOCK_WRITE(slapdFrontendConfig);
  1441. slapdFrontendConfig->pw_policy.pw_maxfailure = maxFailure;
  1442. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1443. }
  1444. return retVal;
  1445. }
  1446. int
  1447. config_set_pw_inhistory( const char *attrname, char *value, char *errorbuf, int apply ) {
  1448. int retVal = LDAP_SUCCESS, history = 0;
  1449. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1450. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1451. return LDAP_OPERATIONS_ERROR;
  1452. }
  1453. history = atoi(value);
  1454. if ( history < 2 || history > 24 ) {
  1455. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1456. "password history length \"%s\" is invalid. "
  1457. "The password history must range from 2 to 24",
  1458. value );
  1459. retVal = LDAP_OPERATIONS_ERROR;
  1460. return retVal;
  1461. }
  1462. if ( apply ) {
  1463. CFG_LOCK_WRITE(slapdFrontendConfig);
  1464. slapdFrontendConfig->pw_policy.pw_inhistory = history;
  1465. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1466. }
  1467. return retVal;
  1468. }
  1469. int
  1470. config_set_pw_lockduration( const char *attrname, char *value, char *errorbuf, int apply ) {
  1471. int retVal = LDAP_SUCCESS;
  1472. long duration = 0; /* in minutes */
  1473. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1474. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1475. return LDAP_OPERATIONS_ERROR;
  1476. }
  1477. /* in seconds */
  1478. duration = strtol (value, NULL, 0);
  1479. if ( duration <= 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1480. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1481. "password lockout duration \"%s\" seconds is invalid. ",
  1482. value );
  1483. retVal = LDAP_OPERATIONS_ERROR;
  1484. return retVal;
  1485. }
  1486. if ( apply ) {
  1487. slapdFrontendConfig->pw_policy.pw_lockduration = duration;
  1488. }
  1489. return retVal;
  1490. }
  1491. int
  1492. config_set_pw_resetfailurecount( const char *attrname, char *value, char *errorbuf, int apply ) {
  1493. int retVal = LDAP_SUCCESS;
  1494. long duration = 0; /* in minutes */
  1495. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1496. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1497. return LDAP_OPERATIONS_ERROR;
  1498. }
  1499. /* in seconds */
  1500. duration = strtol (value, NULL, 0);
  1501. if ( duration < 0 || duration > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  1502. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1503. "password reset count duration \"%s\" seconds is invalid. ",
  1504. value );
  1505. retVal = LDAP_OPERATIONS_ERROR;
  1506. return retVal;
  1507. }
  1508. if ( apply ) {
  1509. slapdFrontendConfig->pw_policy.pw_resetfailurecount = duration;
  1510. }
  1511. return retVal;
  1512. }
  1513. int
  1514. config_set_pw_is_global_policy( const char *attrname, char *value, char *errorbuf, int apply ) {
  1515. int retVal = LDAP_SUCCESS;
  1516. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1517. retVal = config_set_onoff ( attrname,
  1518. value,
  1519. &(slapdFrontendConfig->pw_is_global_policy),
  1520. errorbuf,
  1521. apply);
  1522. return retVal;
  1523. }
  1524. int
  1525. config_set_pw_exp( const char *attrname, char *value, char *errorbuf, int apply ) {
  1526. int retVal = LDAP_SUCCESS;
  1527. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1528. retVal = config_set_onoff ( attrname,
  1529. value,
  1530. &(slapdFrontendConfig->pw_policy.pw_exp),
  1531. errorbuf,
  1532. apply);
  1533. return retVal;
  1534. }
  1535. int
  1536. config_set_pw_unlock( const char *attrname, char *value, char *errorbuf, int apply ) {
  1537. int retVal = LDAP_SUCCESS;
  1538. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1539. retVal = config_set_onoff ( attrname,
  1540. value,
  1541. &(slapdFrontendConfig->pw_policy.pw_unlock),
  1542. errorbuf,
  1543. apply);
  1544. return retVal;
  1545. }
  1546. int
  1547. config_set_pw_lockout( const char *attrname, char *value, char *errorbuf, int apply ) {
  1548. int retVal = LDAP_SUCCESS;
  1549. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1550. retVal = config_set_onoff ( attrname,
  1551. value,
  1552. &(slapdFrontendConfig->pw_policy.pw_lockout),
  1553. errorbuf,
  1554. apply);
  1555. return retVal;
  1556. }
  1557. int
  1558. config_set_pw_gracelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  1559. int retVal = LDAP_SUCCESS, gracelimit = 0;
  1560. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1561. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1562. return LDAP_OPERATIONS_ERROR;
  1563. }
  1564. gracelimit = atoi(value);
  1565. if ( gracelimit < 0 ) {
  1566. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1567. "password grace limit \"%s\" is invalid.",
  1568. value );
  1569. retVal = LDAP_OPERATIONS_ERROR;
  1570. return retVal;
  1571. }
  1572. if ( apply ) {
  1573. CFG_LOCK_WRITE(slapdFrontendConfig);
  1574. slapdFrontendConfig->pw_policy.pw_gracelimit = gracelimit;
  1575. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1576. }
  1577. return retVal;
  1578. }
  1579. int
  1580. config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply ) {
  1581. int retVal = LDAP_SUCCESS;
  1582. Slapi_Backend *be = NULL;
  1583. char *cookie;
  1584. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1585. retVal = config_set_onoff ( attrname,
  1586. value,
  1587. &(slapdFrontendConfig->lastmod),
  1588. errorbuf,
  1589. apply);
  1590. if ( retVal == LDAP_SUCCESS && apply ) {
  1591. CFG_LOCK_WRITE(slapdFrontendConfig);
  1592. cookie = NULL;
  1593. be = slapi_get_first_backend (&cookie);
  1594. while (be) {
  1595. be->be_lastmod = slapdFrontendConfig->lastmod;
  1596. be = slapi_get_next_backend (cookie);
  1597. }
  1598. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1599. slapi_ch_free ((void **)&cookie);
  1600. }
  1601. return retVal;
  1602. }
  1603. int
  1604. config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply ) {
  1605. int retVal = LDAP_SUCCESS;
  1606. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1607. retVal = config_set_onoff ( attrname,
  1608. value,
  1609. &(slapdFrontendConfig->nagle),
  1610. errorbuf,
  1611. apply);
  1612. return retVal;
  1613. }
  1614. int
  1615. config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply ) {
  1616. int retVal = LDAP_SUCCESS;
  1617. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1618. retVal = config_set_onoff ( attrname,
  1619. value,
  1620. &(slapdFrontendConfig->accesscontrol),
  1621. errorbuf,
  1622. apply);
  1623. return retVal;
  1624. }
  1625. int
  1626. config_set_return_exact_case( const char *attrname, char *value, char *errorbuf, int apply ) {
  1627. int retVal = LDAP_SUCCESS;
  1628. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1629. retVal = config_set_onoff ( attrname,
  1630. value,
  1631. &(slapdFrontendConfig->return_exact_case),
  1632. errorbuf,
  1633. apply);
  1634. return retVal;
  1635. }
  1636. int
  1637. config_set_result_tweak( const char *attrname, char *value, char *errorbuf, int apply ) {
  1638. int retVal = LDAP_SUCCESS;
  1639. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1640. retVal = config_set_onoff ( attrname,
  1641. value,
  1642. &(slapdFrontendConfig->result_tweak),
  1643. errorbuf,
  1644. apply);
  1645. return retVal;
  1646. }
  1647. int
  1648. config_set_security( const char *attrname, char *value, char *errorbuf, int apply ) {
  1649. int retVal = LDAP_SUCCESS;
  1650. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1651. retVal = config_set_onoff ( attrname,
  1652. value,
  1653. &(slapdFrontendConfig->security),
  1654. errorbuf,
  1655. apply);
  1656. return retVal;
  1657. }
  1658. static int
  1659. config_set_onoff ( const char *attrname, char *value, int *configvalue,
  1660. char *errorbuf, int apply )
  1661. {
  1662. int retVal = LDAP_SUCCESS;
  1663. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1664. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1665. return LDAP_OPERATIONS_ERROR;
  1666. }
  1667. if ( strcasecmp ( value, "on" ) != 0 &&
  1668. strcasecmp ( value, "off") != 0 ) {
  1669. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1670. "%s: invalid value \"%s\". Valid values are \"on\" or \"off\".",
  1671. attrname, value );
  1672. retVal = LDAP_OPERATIONS_ERROR;
  1673. }
  1674. if ( !apply ) {
  1675. /* we can return now if we aren't applying the changes */
  1676. return retVal;
  1677. }
  1678. CFG_LOCK_WRITE(slapdFrontendConfig);
  1679. if ( strcasecmp ( value, "on" ) == 0 ) {
  1680. *configvalue = LDAP_ON;
  1681. }
  1682. else if ( strcasecmp ( value, "off" ) == 0 ) {
  1683. *configvalue = LDAP_OFF;
  1684. }
  1685. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1686. return retVal;
  1687. }
  1688. int
  1689. config_set_readonly( const char *attrname, char *value, char *errorbuf, int apply ) {
  1690. int retVal = LDAP_SUCCESS;
  1691. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1692. retVal = config_set_onoff ( attrname,
  1693. value,
  1694. &(slapdFrontendConfig->readonly),
  1695. errorbuf,
  1696. apply );
  1697. return retVal;
  1698. }
  1699. int
  1700. config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply ) {
  1701. int retVal = LDAP_SUCCESS;
  1702. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1703. retVal = config_set_onoff ( attrname,
  1704. value,
  1705. &(slapdFrontendConfig->schemacheck),
  1706. errorbuf,
  1707. apply);
  1708. return retVal;
  1709. }
  1710. int
  1711. config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply ) {
  1712. int retVal = LDAP_SUCCESS;
  1713. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1714. retVal = config_set_onoff ( attrname,
  1715. value,
  1716. &(slapdFrontendConfig->ds4_compatible_schema),
  1717. errorbuf,
  1718. apply);
  1719. return retVal;
  1720. }
  1721. int
  1722. config_set_schema_ignore_trailing_spaces( const char *attrname, char *value,
  1723. char *errorbuf, int apply ) {
  1724. int retVal = LDAP_SUCCESS;
  1725. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1726. retVal = config_set_onoff ( attrname,
  1727. value,
  1728. &(slapdFrontendConfig->schema_ignore_trailing_spaces),
  1729. errorbuf,
  1730. apply);
  1731. return retVal;
  1732. }
  1733. int
  1734. config_set_enquote_sup_oc( const char *attrname, char *value, char *errorbuf, int apply ) {
  1735. int retVal = LDAP_SUCCESS;
  1736. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1737. retVal = config_set_onoff ( attrname,
  1738. value,
  1739. &(slapdFrontendConfig->enquote_sup_oc),
  1740. errorbuf,
  1741. apply);
  1742. return retVal;
  1743. }
  1744. int
  1745. config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply ) {
  1746. int retVal = LDAP_SUCCESS;
  1747. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1748. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1749. return LDAP_OPERATIONS_ERROR;
  1750. }
  1751. if ( apply ) {
  1752. CFG_LOCK_WRITE(slapdFrontendConfig);
  1753. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootdn) );
  1754. slapdFrontendConfig->rootdn = slapi_dn_normalize (slapi_ch_strdup ( value ) );
  1755. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1756. }
  1757. return retVal;
  1758. }
  1759. int
  1760. config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply ) {
  1761. int retVal = LDAP_SUCCESS;
  1762. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1763. struct pw_scheme *is_hashed = NULL;
  1764. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1765. return LDAP_OPERATIONS_ERROR;
  1766. }
  1767. if (!apply) {
  1768. return retVal;
  1769. }
  1770. CFG_LOCK_WRITE(slapdFrontendConfig);
  1771. slapi_ch_free ( (void **) &(slapdFrontendConfig->rootpw) );
  1772. is_hashed = pw_val2scheme ( value, NULL, 0 );
  1773. if ( is_hashed ) {
  1774. slapdFrontendConfig->rootpw = slapi_ch_strdup ( value );
  1775. free_pw_scheme(is_hashed);
  1776. }
  1777. else {
  1778. /* pwd enc func returns slapi_ch_malloc memory */
  1779. slapdFrontendConfig->rootpw = (slapdFrontendConfig->rootpwstoragescheme->pws_enc)(value);
  1780. }
  1781. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1782. return retVal;
  1783. }
  1784. int
  1785. config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply ) {
  1786. int retVal = LDAP_SUCCESS;
  1787. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1788. struct pw_scheme *new_scheme = NULL;
  1789. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1790. return LDAP_OPERATIONS_ERROR;
  1791. }
  1792. new_scheme = pw_name2scheme ( value );
  1793. if (new_scheme == NULL ) {
  1794. char * scheme_list = plugin_get_pwd_storage_scheme_list(PLUGIN_LIST_PWD_STORAGE_SCHEME);
  1795. if ( scheme_list != NULL ) {
  1796. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1797. "%s: invalid scheme - %s. Valid schemes are: %s",
  1798. attrname, value, scheme_list );
  1799. } else {
  1800. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  1801. "%s: invalid scheme - %s (no pwdstorage scheme"
  1802. " plugin loaded)", attrname, value);
  1803. }
  1804. slapi_ch_free_string(&scheme_list);
  1805. retVal = LDAP_OPERATIONS_ERROR;
  1806. return retVal;
  1807. }
  1808. CFG_LOCK_WRITE(slapdFrontendConfig);
  1809. free_pw_scheme(slapdFrontendConfig->rootpwstoragescheme);
  1810. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  1811. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1812. return retVal;
  1813. }
  1814. /*
  1815. * kexcoff: to replace default initialization in FrontendConfig_init()
  1816. */
  1817. int config_set_storagescheme() {
  1818. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1819. struct pw_scheme *new_scheme = NULL;
  1820. CFG_LOCK_WRITE(slapdFrontendConfig);
  1821. new_scheme = pw_name2scheme("SSHA");
  1822. free_pw_scheme(slapdFrontendConfig->pw_storagescheme);
  1823. slapdFrontendConfig->pw_storagescheme = new_scheme;
  1824. new_scheme = pw_name2scheme("SSHA");
  1825. slapdFrontendConfig->rootpwstoragescheme = new_scheme;
  1826. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1827. return ( new_scheme == NULL );
  1828. }
  1829. #ifndef _WIN32
  1830. int
  1831. config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply ) {
  1832. int retVal = LDAP_SUCCESS;
  1833. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1834. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1835. return LDAP_OPERATIONS_ERROR;
  1836. }
  1837. if (apply) {
  1838. CFG_LOCK_WRITE(slapdFrontendConfig);
  1839. slapi_ch_free ( (void **) &slapdFrontendConfig->localuser );
  1840. slapdFrontendConfig->localuser = slapi_ch_strdup ( value );
  1841. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1842. }
  1843. return retVal;
  1844. }
  1845. #endif /* _WIN32 */
  1846. int
  1847. config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply ) {
  1848. int retVal = LDAP_SUCCESS;
  1849. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1850. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1851. return LDAP_OPERATIONS_ERROR;
  1852. }
  1853. if ( PR_Access ( value, PR_ACCESS_EXISTS ) != 0 ) {
  1854. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" does not exist.", value );
  1855. retVal = LDAP_OPERATIONS_ERROR;
  1856. return retVal;
  1857. }
  1858. if ( PR_Access ( value, PR_ACCESS_WRITE_OK ) != 0 ) {
  1859. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Working directory \"%s\" is not writeable.", value );
  1860. retVal = LDAP_OPERATIONS_ERROR;
  1861. return retVal;
  1862. }
  1863. if ( apply) {
  1864. CFG_LOCK_WRITE(slapdFrontendConfig);
  1865. slapdFrontendConfig->workingdir = slapi_ch_strdup ( value );
  1866. #ifdef _WIN32
  1867. dostounixpath(slapdFrontendConfig->workingdir);
  1868. #endif /* _WIN32 */
  1869. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1870. }
  1871. return retVal;
  1872. }
  1873. int
  1874. config_set_instancedir( const char *attrname, char *value, char *errorbuf, int apply ) {
  1875. int retVal = LDAP_SUCCESS;
  1876. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1877. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1878. return LDAP_OPERATIONS_ERROR;
  1879. }
  1880. if ( PR_Access ( value, PR_ACCESS_READ_OK ) != 0 ) {
  1881. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Directory \"%s\" is not accessible.", value );
  1882. retVal = LDAP_OPERATIONS_ERROR;
  1883. return retVal;
  1884. }
  1885. if ( apply) {
  1886. CFG_LOCK_WRITE(slapdFrontendConfig);
  1887. slapdFrontendConfig->instancedir = slapi_ch_strdup ( value );
  1888. #ifdef _WIN32
  1889. dostounixpath(slapdFrontendConfig->instancedir);
  1890. #endif /* _WIN32 */
  1891. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1892. /* Set the slapd type also */
  1893. config_set_slapd_type ();
  1894. /* Set the configdir if not set */
  1895. if (!slapdFrontendConfig->configdir)
  1896. {
  1897. char newdir[MAXPATHLEN+1];
  1898. PR_snprintf ( newdir, sizeof(newdir), "%s/%s",
  1899. slapdFrontendConfig->instancedir, CONFIG_SUBDIR_NAME);
  1900. retVal = config_set_configdir(attrname, newdir, errorbuf, apply);
  1901. }
  1902. }
  1903. return retVal;
  1904. }
  1905. /* alias of encryption key and certificate files is now retrieved through */
  1906. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  1907. /* where this function is still used to set the global variable */
  1908. int
  1909. config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply ) {
  1910. int retVal = LDAP_SUCCESS;
  1911. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1912. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1913. return LDAP_OPERATIONS_ERROR;
  1914. }
  1915. if (apply) {
  1916. CFG_LOCK_WRITE(slapdFrontendConfig);
  1917. slapi_ch_free ( (void **) &(slapdFrontendConfig->encryptionalias) );
  1918. slapdFrontendConfig->encryptionalias = slapi_ch_strdup ( value );
  1919. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1920. }
  1921. return retVal;
  1922. }
  1923. int
  1924. config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply ) {
  1925. int retVal = LDAP_SUCCESS, threadnum = 0;
  1926. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1927. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1928. return LDAP_OPERATIONS_ERROR;
  1929. }
  1930. threadnum = atoi ( value );
  1931. if ( threadnum < 1 || threadnum > 65535 ) {
  1932. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum thread number must range from 1 to 65535", attrname, threadnum );
  1933. retVal = LDAP_OPERATIONS_ERROR;
  1934. }
  1935. if (apply) {
  1936. CFG_LOCK_WRITE(slapdFrontendConfig);
  1937. /* max_threads = threadnum; */
  1938. slapdFrontendConfig->threadnumber = threadnum;
  1939. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1940. }
  1941. return retVal;
  1942. }
  1943. int
  1944. config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply ) {
  1945. int retVal = LDAP_SUCCESS, maxthreadnum = 0;
  1946. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1947. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1948. return LDAP_OPERATIONS_ERROR;
  1949. }
  1950. maxthreadnum = atoi ( value );
  1951. if ( maxthreadnum < 1 || maxthreadnum > 65535 ) {
  1952. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum thread number per connection must range from 1 to 65535", attrname, maxthreadnum );
  1953. retVal = LDAP_OPERATIONS_ERROR;
  1954. }
  1955. if (apply) {
  1956. CFG_LOCK_WRITE(slapdFrontendConfig);
  1957. /* max_threads_per_conn = maxthreadnum; */
  1958. slapdFrontendConfig->maxthreadsperconn = maxthreadnum;
  1959. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1960. }
  1961. return retVal;
  1962. }
  1963. #if !defined(_WIN32) && !defined(AIX)
  1964. #include <sys/resource.h>
  1965. int
  1966. config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  1967. int retVal = LDAP_SUCCESS, nValue = 0;
  1968. int maxVal = 65535;
  1969. struct rlimit rlp;
  1970. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  1971. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  1972. return LDAP_OPERATIONS_ERROR;
  1973. }
  1974. nValue = atoi ( value );
  1975. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  1976. maxVal = (int)rlp.rlim_max;
  1977. }
  1978. if ( nValue < 1 || nValue > maxVal ) {
  1979. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, maximum file descriptors must range from 1 to %d (the current process limit)",
  1980. attrname, nValue, maxVal );
  1981. if ( nValue < 1 ) {
  1982. retVal = LDAP_OPERATIONS_ERROR;
  1983. } else {
  1984. nValue = maxVal;
  1985. retVal = LDAP_UNWILLING_TO_PERFORM;
  1986. }
  1987. }
  1988. if (apply) {
  1989. CFG_LOCK_WRITE(slapdFrontendConfig);
  1990. slapdFrontendConfig->maxdescriptors = nValue;
  1991. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  1992. }
  1993. return retVal;
  1994. }
  1995. #endif /* !_WIN32 && !AIX */
  1996. int
  1997. config_set_conntablesize( const char *attrname, char *value, char *errorbuf, int apply ) {
  1998. int retVal = LDAP_SUCCESS, nValue = 0;
  1999. int maxVal = 65535;
  2000. #ifndef _WIN32
  2001. struct rlimit rlp;
  2002. #endif
  2003. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2004. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2005. return LDAP_OPERATIONS_ERROR;
  2006. }
  2007. nValue = atoi ( value );
  2008. #ifdef _WIN32
  2009. if ( nValue < 1 || nValue > 0xfffffe ) {
  2010. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, connection table size must range from 1 to 0xfffffe", attrname, nValue );
  2011. retVal = LDAP_OPERATIONS_ERROR;
  2012. }
  2013. #elif !defined(AIX)
  2014. if ( 0 == getrlimit( RLIMIT_NOFILE, &rlp ) ) {
  2015. maxVal = (int)rlp.rlim_max;
  2016. }
  2017. if ( nValue < 1 || nValue > maxVal ) {
  2018. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, connection table size must range from 1 to %d (the current process maxdescriptors limit)",
  2019. attrname, nValue, maxVal );
  2020. if ( nValue < 1 ) {
  2021. retVal = LDAP_OPERATIONS_ERROR;
  2022. } else {
  2023. nValue = maxVal;
  2024. retVal = LDAP_UNWILLING_TO_PERFORM;
  2025. }
  2026. }
  2027. #endif
  2028. if (apply) {
  2029. CFG_LOCK_WRITE(slapdFrontendConfig);
  2030. slapdFrontendConfig->conntablesize = nValue;
  2031. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2032. }
  2033. return retVal;
  2034. }
  2035. int
  2036. config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply ) {
  2037. int retVal = LDAP_SUCCESS, nValue = 0;
  2038. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2039. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2040. return LDAP_OPERATIONS_ERROR;
  2041. }
  2042. nValue = atoi ( value );
  2043. if ( nValue < 1 || nValue > 65535 ) {
  2044. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "%s: invalid value %d, reserved file descriptors must range from 1 to 65535", attrname, nValue );
  2045. retVal = LDAP_OPERATIONS_ERROR;
  2046. }
  2047. if (apply) {
  2048. CFG_LOCK_WRITE(slapdFrontendConfig);
  2049. slapdFrontendConfig->reservedescriptors = nValue;
  2050. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2051. }
  2052. return retVal;
  2053. }
  2054. int
  2055. config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  2056. int retVal = LDAP_SUCCESS, nValue = 0;
  2057. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2058. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2059. return LDAP_OPERATIONS_ERROR;
  2060. }
  2061. nValue = atoi ( value );
  2062. #if defined(IRIX)
  2063. /* on IRIX poll can only handle timeouts up to
  2064. 2147483 without failing, cap it at 30 minutes */
  2065. if ( nValue > SLAPD_DEFAULT_IOBLOCK_TIMEOUT ) {
  2066. nValue = SLAPD_DEFAULT_IOBLOCK_TIMEOUT;
  2067. }
  2068. #endif /* IRIX */
  2069. if ( apply ) {
  2070. CFG_LOCK_WRITE(slapdFrontendConfig);
  2071. slapdFrontendConfig->ioblocktimeout = nValue;
  2072. /* g_ioblock_timeout= nValue; */
  2073. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2074. }
  2075. return retVal;
  2076. }
  2077. int
  2078. config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply ) {
  2079. int retVal = LDAP_SUCCESS, nValue = 0;
  2080. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2081. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2082. return LDAP_OPERATIONS_ERROR;
  2083. }
  2084. nValue = atoi ( value );
  2085. if (apply) {
  2086. CFG_LOCK_WRITE(slapdFrontendConfig);
  2087. slapdFrontendConfig->idletimeout = nValue;
  2088. /* g_idle_timeout= nValue; */
  2089. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2090. }
  2091. return retVal;
  2092. }
  2093. int
  2094. config_set_groupevalnestlevel( const char *attrname, char * value, char *errorbuf, int apply ) {
  2095. int retVal = LDAP_SUCCESS, nValue = 0;
  2096. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2097. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  2098. return LDAP_OPERATIONS_ERROR;
  2099. }
  2100. nValue = atoi ( value );
  2101. if ( nValue < 1 ) {
  2102. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2103. "%s: invalid value %d, must be a positive number",
  2104. attrname, nValue );
  2105. }
  2106. if (apply) {
  2107. CFG_LOCK_WRITE(slapdFrontendConfig);
  2108. slapdFrontendConfig->groupevalnestlevel = nValue;
  2109. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2110. }
  2111. return retVal;
  2112. }
  2113. int
  2114. config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply ) {
  2115. int retVal = LDAP_SUCCESS;
  2116. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2117. if ( config_value_is_null( attrname, (char *)value, errorbuf, 0 )) {
  2118. return LDAP_OPERATIONS_ERROR;
  2119. }
  2120. if (apply) {
  2121. CFG_LOCK_WRITE(slapdFrontendConfig);
  2122. g_set_default_referral( value );
  2123. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2124. }
  2125. return retVal;
  2126. }
  2127. int
  2128. config_set_userat( const char *attrname, char *value, char *errorbuf, int apply ) {
  2129. int retVal = LDAP_SUCCESS;
  2130. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2131. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2132. return LDAP_OPERATIONS_ERROR;
  2133. }
  2134. if ( apply ) {
  2135. CFG_LOCK_WRITE(slapdFrontendConfig);
  2136. slapi_ch_free( (void **) &(slapdFrontendConfig->userat) );
  2137. slapdFrontendConfig->userat = slapi_ch_strdup(value);
  2138. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2139. }
  2140. return retVal;
  2141. }
  2142. int
  2143. config_set_timelimit( const char *attrname, char *value, char *errorbuf, int apply ) {
  2144. int retVal = LDAP_SUCCESS, nVal = 0;
  2145. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2146. Slapi_Backend *be = NULL;
  2147. char *cookie;
  2148. *errorbuf = 0;
  2149. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2150. return LDAP_OPERATIONS_ERROR;
  2151. }
  2152. nVal = atoi(value);
  2153. if ( nVal < 0 ) {
  2154. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2155. "%s: invalid value %d", attrname, nVal );
  2156. }
  2157. if ( apply ) {
  2158. CFG_LOCK_WRITE(slapdFrontendConfig);
  2159. g_set_deftime ( nVal );
  2160. slapdFrontendConfig->timelimit = nVal;
  2161. be = slapi_get_first_backend (&cookie);
  2162. while (be) {
  2163. be->be_timelimit = slapdFrontendConfig->timelimit;
  2164. be = slapi_get_next_backend (cookie);
  2165. }
  2166. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2167. slapi_ch_free ((void **)&cookie);
  2168. }
  2169. return retVal;
  2170. }
  2171. int
  2172. config_set_useroc( const char *attrname, char *value, char *errorbuf, int apply ) {
  2173. int retVal = LDAP_SUCCESS;
  2174. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2175. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2176. return LDAP_OPERATIONS_ERROR;
  2177. }
  2178. if ( apply ) {
  2179. CFG_LOCK_WRITE(slapdFrontendConfig);
  2180. slapi_ch_free ( (void **) &(slapdFrontendConfig->useroc) );
  2181. slapdFrontendConfig->useroc = slapi_ch_strdup( value );
  2182. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2183. }
  2184. return retVal;
  2185. }
  2186. int
  2187. config_set_accesslog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2188. int retVal = LDAP_SUCCESS;
  2189. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2190. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2191. return LDAP_OPERATIONS_ERROR;
  2192. }
  2193. retVal = log_update_accesslogdir ( value, apply );
  2194. if ( retVal != LDAP_SUCCESS ) {
  2195. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2196. "Cannot open accesslog directory \"%s\", client accesses will "
  2197. "not be logged.", value );
  2198. }
  2199. if ( apply ) {
  2200. CFG_LOCK_WRITE(slapdFrontendConfig);
  2201. slapi_ch_free ( (void **) &(slapdFrontendConfig->accesslog) );
  2202. slapdFrontendConfig->accesslog = slapi_ch_strdup ( value );
  2203. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2204. }
  2205. return retVal;
  2206. }
  2207. int
  2208. config_set_errorlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2209. int retVal = LDAP_SUCCESS;
  2210. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2211. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2212. return LDAP_OPERATIONS_ERROR;
  2213. }
  2214. retVal = log_update_errorlogdir ( value, apply );
  2215. if ( retVal != LDAP_SUCCESS ) {
  2216. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2217. "Cannot open errorlog directory \"%s\", errors will "
  2218. "not be logged.", value );
  2219. }
  2220. if ( apply ) {
  2221. CFG_LOCK_WRITE(slapdFrontendConfig);
  2222. slapi_ch_free ( (void **) &(slapdFrontendConfig->errorlog) );
  2223. slapdFrontendConfig->errorlog = slapi_ch_strdup ( value );
  2224. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2225. }
  2226. return retVal;
  2227. }
  2228. int
  2229. config_set_auditlog( const char *attrname, char *value, char *errorbuf, int apply ) {
  2230. int retVal = LDAP_SUCCESS;
  2231. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2232. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2233. return LDAP_OPERATIONS_ERROR;
  2234. }
  2235. retVal = log_update_auditlogdir ( value, apply );
  2236. if ( retVal != LDAP_SUCCESS ) {
  2237. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2238. "Cannot open auditlog directory \"%s\"", value );
  2239. }
  2240. if ( apply ) {
  2241. CFG_LOCK_WRITE(slapdFrontendConfig);
  2242. slapi_ch_free ( (void **) &(slapdFrontendConfig->auditlog) );
  2243. slapdFrontendConfig->auditlog = slapi_ch_strdup ( value );
  2244. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2245. }
  2246. return retVal;
  2247. }
  2248. int
  2249. config_set_pw_maxage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2250. int retVal = LDAP_SUCCESS;
  2251. long age;
  2252. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2253. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2254. return LDAP_OPERATIONS_ERROR;
  2255. }
  2256. /* age in seconds */
  2257. age = strtol(value, NULL, 0 );
  2258. if ( age <= 0 || age > (MAX_ALLOWED_TIME_IN_SECS - current_time()) ) {
  2259. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2260. "password maximum age \"%s\" seconds is invalid. ",
  2261. value );
  2262. retVal = LDAP_OPERATIONS_ERROR;
  2263. return retVal;
  2264. }
  2265. if ( apply ) {
  2266. slapdFrontendConfig->pw_policy.pw_maxage = age;
  2267. }
  2268. return retVal;
  2269. }
  2270. int
  2271. config_set_pw_minage( const char *attrname, char *value, char *errorbuf, int apply ) {
  2272. int retVal = LDAP_SUCCESS;
  2273. long age;
  2274. char *endPtr = NULL;
  2275. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2276. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2277. return LDAP_OPERATIONS_ERROR;
  2278. }
  2279. /* age in seconds */
  2280. age = strtol(value, &endPtr, 0 );
  2281. /* endPtr should never be NULL, but we check just in case; if the
  2282. value contains no digits, or a string that does not begin with
  2283. a valid digit (e.g. "z2"), the days will be 0, and endPtr will
  2284. point to the beginning of value; if days contains at least 1
  2285. valid digit string, endPtr will point to the character after
  2286. the end of the first valid digit string in value. Example:
  2287. value = " 2 3 " endPtr will point at the space character
  2288. between the 2 and the 3. So, we should be able to simply
  2289. check to see if the character at *(endPtr - 1) is a digit.
  2290. */
  2291. if ( (age < 0) ||
  2292. (age > (MAX_ALLOWED_TIME_IN_SECS - current_time())) ||
  2293. (endPtr == NULL) || (endPtr == value) || !isdigit(*(endPtr-1)) ) {
  2294. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2295. "password minimum age \"%s\" seconds is invalid. ",
  2296. value );
  2297. retVal = LDAP_OPERATIONS_ERROR;
  2298. return retVal;
  2299. }
  2300. if ( apply ) {
  2301. slapdFrontendConfig->pw_policy.pw_minage = age;
  2302. }
  2303. return retVal;
  2304. }
  2305. int
  2306. config_set_pw_warning( const char *attrname, char *value, char *errorbuf, int apply ) {
  2307. int retVal = LDAP_SUCCESS;
  2308. long sec;
  2309. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2310. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2311. return LDAP_OPERATIONS_ERROR;
  2312. }
  2313. /* in seconds */
  2314. sec = strtol(value, NULL, 0);
  2315. if (sec < 0) {
  2316. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
  2317. "password warning age \"%s\" seconds is invalid, password warning "
  2318. "age must be >= 0 seconds",
  2319. value );
  2320. retVal = LDAP_OPERATIONS_ERROR;
  2321. return retVal;
  2322. }
  2323. /* translate to seconds */
  2324. if ( apply ) {
  2325. slapdFrontendConfig->pw_policy.pw_warning = sec;
  2326. }
  2327. return retVal;
  2328. }
  2329. int
  2330. config_set_errorlog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2331. int retVal = LDAP_SUCCESS, level = 0;
  2332. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2333. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2334. return LDAP_OPERATIONS_ERROR;
  2335. }
  2336. if ( apply ) {
  2337. CFG_LOCK_WRITE(slapdFrontendConfig);
  2338. level = atoi ( value );
  2339. level |= LDAP_DEBUG_ANY;
  2340. #ifdef _WIN32
  2341. *module_ldap_debug = level;
  2342. #else
  2343. slapd_ldap_debug = level;
  2344. #endif
  2345. slapdFrontendConfig->errorloglevel = level;
  2346. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2347. }
  2348. return retVal;
  2349. }
  2350. int
  2351. config_set_accesslog_level( const char *attrname, char *value, char *errorbuf, int apply ) {
  2352. int retVal = LDAP_SUCCESS, level = 0;
  2353. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2354. if ( config_value_is_null( attrname, value, errorbuf, 1 )) {
  2355. return LDAP_OPERATIONS_ERROR;
  2356. }
  2357. if ( apply ) {
  2358. CFG_LOCK_WRITE(slapdFrontendConfig);
  2359. level = atoi ( value );
  2360. g_set_accesslog_level ( level );
  2361. slapdFrontendConfig->accessloglevel = level;
  2362. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2363. }
  2364. return retVal;
  2365. }
  2366. /* set the referral-mode url (which puts us into referral mode) */
  2367. int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply)
  2368. {
  2369. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2370. slapdFrontendConfig->refer_mode=REFER_MODE_OFF;
  2371. if ((!url) || (!url[0])) {
  2372. strcpy(errorbuf, "referral url must have a value");
  2373. return LDAP_OPERATIONS_ERROR;
  2374. }
  2375. if (apply) {
  2376. CFG_LOCK_WRITE(slapdFrontendConfig);
  2377. slapdFrontendConfig->refer_url = slapi_ch_strdup(url);
  2378. slapdFrontendConfig->refer_mode = REFER_MODE_ON;
  2379. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2380. }
  2381. return LDAP_SUCCESS;
  2382. }
  2383. int
  2384. config_set_versionstring( const char *attrname, char *version, char *errorbuf, int apply ) {
  2385. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2386. if ((!version) || (!version[0])) {
  2387. PL_strncpyz(errorbuf, "versionstring must have a value", SLAPI_DSE_RETURNTEXT_SIZE);
  2388. return LDAP_OPERATIONS_ERROR;
  2389. }
  2390. if (apply) {
  2391. CFG_LOCK_WRITE(slapdFrontendConfig);
  2392. slapdFrontendConfig->versionstring = slapi_ch_strdup(version);
  2393. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2394. }
  2395. return LDAP_SUCCESS;
  2396. }
  2397. #define config_copy_strval( s ) s ? slapi_ch_strdup (s) : NULL;
  2398. int
  2399. config_get_port(){
  2400. int retVal;
  2401. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2402. CFG_LOCK_READ(slapdFrontendConfig);
  2403. retVal = slapdFrontendConfig->port;
  2404. CFG_UNLOCK_READ(slapdFrontendConfig);
  2405. return retVal;
  2406. }
  2407. char *
  2408. config_get_workingdir() {
  2409. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2410. char *retVal;
  2411. CFG_LOCK_READ(slapdFrontendConfig);
  2412. retVal = slapi_ch_strdup(slapdFrontendConfig->workingdir);
  2413. CFG_UNLOCK_READ(slapdFrontendConfig);
  2414. return retVal;
  2415. }
  2416. char *
  2417. config_get_versionstring() {
  2418. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2419. char *retVal;
  2420. CFG_LOCK_READ(slapdFrontendConfig);
  2421. retVal = slapi_ch_strdup(slapdFrontendConfig->versionstring);
  2422. CFG_UNLOCK_READ(slapdFrontendConfig);
  2423. return retVal;
  2424. }
  2425. char *
  2426. config_get_buildnum(void)
  2427. {
  2428. return slapi_ch_strdup(BUILD_NUM);
  2429. }
  2430. int
  2431. config_get_secureport() {
  2432. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2433. int retVal;
  2434. CFG_LOCK_READ(slapdFrontendConfig);
  2435. retVal = slapdFrontendConfig->secureport;
  2436. CFG_UNLOCK_READ(slapdFrontendConfig);
  2437. return retVal;
  2438. }
  2439. int
  2440. config_get_SSLclientAuth() {
  2441. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2442. int retVal;
  2443. CFG_LOCK_READ(slapdFrontendConfig);
  2444. retVal = slapdFrontendConfig->SSLclientAuth;
  2445. CFG_UNLOCK_READ(slapdFrontendConfig);
  2446. return retVal;
  2447. }
  2448. int
  2449. config_get_ssl_check_hostname()
  2450. {
  2451. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2452. return slapdFrontendConfig->ssl_check_hostname;
  2453. }
  2454. char *
  2455. config_get_localhost() {
  2456. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2457. char *retVal;
  2458. CFG_LOCK_READ(slapdFrontendConfig);
  2459. retVal = config_copy_strval ( slapdFrontendConfig->localhost );
  2460. CFG_UNLOCK_READ(slapdFrontendConfig);
  2461. return retVal;
  2462. }
  2463. char *
  2464. config_get_listenhost() {
  2465. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2466. char *retVal;
  2467. CFG_LOCK_READ(slapdFrontendConfig);
  2468. retVal = config_copy_strval ( slapdFrontendConfig->listenhost );
  2469. CFG_UNLOCK_READ(slapdFrontendConfig);
  2470. return retVal;
  2471. }
  2472. char *
  2473. config_get_securelistenhost() {
  2474. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2475. char *retVal;
  2476. CFG_LOCK_READ(slapdFrontendConfig);
  2477. retVal = config_copy_strval( slapdFrontendConfig->securelistenhost );
  2478. CFG_UNLOCK_READ(slapdFrontendConfig);
  2479. return retVal;
  2480. }
  2481. char *
  2482. config_get_srvtab() {
  2483. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2484. char *retVal;
  2485. CFG_LOCK_READ(slapdFrontendConfig);
  2486. retVal = config_copy_strval(slapdFrontendConfig->srvtab);
  2487. CFG_UNLOCK_READ(slapdFrontendConfig);
  2488. return retVal;
  2489. }
  2490. int
  2491. config_get_sizelimit() {
  2492. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2493. int retVal;
  2494. CFG_LOCK_READ(slapdFrontendConfig);
  2495. retVal = slapdFrontendConfig->sizelimit;
  2496. CFG_UNLOCK_READ(slapdFrontendConfig);
  2497. return retVal;
  2498. }
  2499. char *
  2500. config_get_pw_storagescheme() {
  2501. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2502. char *retVal = 0;
  2503. CFG_LOCK_READ(slapdFrontendConfig);
  2504. retVal = config_copy_strval(slapdFrontendConfig->pw_storagescheme->pws_name);
  2505. CFG_UNLOCK_READ(slapdFrontendConfig);
  2506. return retVal;
  2507. }
  2508. int
  2509. config_get_pw_change() {
  2510. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2511. int retVal;
  2512. CFG_LOCK_READ(slapdFrontendConfig);
  2513. retVal = slapdFrontendConfig->pw_policy.pw_change;
  2514. CFG_UNLOCK_READ(slapdFrontendConfig);
  2515. return retVal;
  2516. }
  2517. int
  2518. config_get_pw_history() {
  2519. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2520. int retVal;
  2521. CFG_LOCK_READ(slapdFrontendConfig);
  2522. retVal = slapdFrontendConfig->pw_policy.pw_history;
  2523. CFG_UNLOCK_READ(slapdFrontendConfig);
  2524. return retVal;
  2525. }
  2526. int
  2527. config_get_pw_must_change() {
  2528. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2529. int retVal;
  2530. CFG_LOCK_READ(slapdFrontendConfig);
  2531. retVal = slapdFrontendConfig->pw_policy.pw_must_change;
  2532. CFG_UNLOCK_READ(slapdFrontendConfig);
  2533. return retVal;
  2534. }
  2535. int
  2536. config_get_pw_syntax() {
  2537. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2538. int retVal;
  2539. CFG_LOCK_READ(slapdFrontendConfig);
  2540. retVal = slapdFrontendConfig->pw_policy.pw_syntax;
  2541. CFG_UNLOCK_READ(slapdFrontendConfig);
  2542. return retVal;
  2543. }
  2544. int
  2545. config_get_pw_minlength() {
  2546. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2547. int retVal;
  2548. CFG_LOCK_READ(slapdFrontendConfig);
  2549. retVal = slapdFrontendConfig->pw_policy.pw_minlength;
  2550. CFG_UNLOCK_READ(slapdFrontendConfig);
  2551. return retVal;
  2552. }
  2553. int
  2554. config_get_pw_mindigits() {
  2555. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2556. int retVal;
  2557. CFG_LOCK_READ(slapdFrontendConfig);
  2558. retVal = slapdFrontendConfig->pw_policy.pw_mindigits;
  2559. CFG_UNLOCK_READ(slapdFrontendConfig);
  2560. return retVal;
  2561. }
  2562. int
  2563. config_get_pw_minalphas() {
  2564. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2565. int retVal;
  2566. CFG_LOCK_READ(slapdFrontendConfig);
  2567. retVal = slapdFrontendConfig->pw_policy.pw_minalphas;
  2568. CFG_UNLOCK_READ(slapdFrontendConfig);
  2569. return retVal;
  2570. }
  2571. int
  2572. config_get_pw_minuppers() {
  2573. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2574. int retVal;
  2575. CFG_LOCK_READ(slapdFrontendConfig);
  2576. retVal = slapdFrontendConfig->pw_policy.pw_minuppers;
  2577. CFG_UNLOCK_READ(slapdFrontendConfig);
  2578. return retVal;
  2579. }
  2580. int
  2581. config_get_pw_minlowers() {
  2582. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2583. int retVal;
  2584. CFG_LOCK_READ(slapdFrontendConfig);
  2585. retVal = slapdFrontendConfig->pw_policy.pw_minlowers;
  2586. CFG_UNLOCK_READ(slapdFrontendConfig);
  2587. return retVal;
  2588. }
  2589. int
  2590. config_get_pw_minspecials() {
  2591. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2592. int retVal;
  2593. CFG_LOCK_READ(slapdFrontendConfig);
  2594. retVal = slapdFrontendConfig->pw_policy.pw_minspecials;
  2595. CFG_UNLOCK_READ(slapdFrontendConfig);
  2596. return retVal;
  2597. }
  2598. int
  2599. config_get_pw_min8bit() {
  2600. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2601. int retVal;
  2602. CFG_LOCK_READ(slapdFrontendConfig);
  2603. retVal = slapdFrontendConfig->pw_policy.pw_min8bit;
  2604. CFG_UNLOCK_READ(slapdFrontendConfig);
  2605. return retVal;
  2606. }
  2607. int
  2608. config_get_pw_maxrepeats() {
  2609. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2610. int retVal;
  2611. CFG_LOCK_READ(slapdFrontendConfig);
  2612. retVal = slapdFrontendConfig->pw_policy.pw_maxrepeats;
  2613. CFG_UNLOCK_READ(slapdFrontendConfig);
  2614. return retVal;
  2615. }
  2616. int
  2617. config_get_pw_mincategories() {
  2618. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2619. int retVal;
  2620. CFG_LOCK_READ(slapdFrontendConfig);
  2621. retVal = slapdFrontendConfig->pw_policy.pw_mincategories;
  2622. CFG_UNLOCK_READ(slapdFrontendConfig);
  2623. return retVal;
  2624. }
  2625. int
  2626. config_get_pw_mintokenlength() {
  2627. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2628. int retVal;
  2629. CFG_LOCK_READ(slapdFrontendConfig);
  2630. retVal = slapdFrontendConfig->pw_policy.pw_mintokenlength;
  2631. CFG_UNLOCK_READ(slapdFrontendConfig);
  2632. return retVal;
  2633. }
  2634. int
  2635. config_get_pw_maxfailure() {
  2636. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2637. int retVal;
  2638. CFG_LOCK_READ(slapdFrontendConfig);
  2639. retVal = slapdFrontendConfig->pw_policy.pw_maxfailure;
  2640. CFG_UNLOCK_READ(slapdFrontendConfig);
  2641. return retVal;
  2642. }
  2643. int
  2644. config_get_pw_inhistory() {
  2645. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2646. int retVal;
  2647. CFG_LOCK_READ(slapdFrontendConfig);
  2648. retVal = slapdFrontendConfig->pw_policy.pw_inhistory;
  2649. CFG_UNLOCK_READ(slapdFrontendConfig);
  2650. return retVal;
  2651. }
  2652. long
  2653. config_get_pw_lockduration() {
  2654. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2655. long retVal;
  2656. CFG_LOCK_READ(slapdFrontendConfig);
  2657. retVal = slapdFrontendConfig->pw_policy.pw_lockduration;
  2658. CFG_UNLOCK_READ(slapdFrontendConfig);
  2659. return retVal;
  2660. }
  2661. long
  2662. config_get_pw_resetfailurecount() {
  2663. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2664. long retVal;
  2665. CFG_LOCK_READ(slapdFrontendConfig);
  2666. retVal = slapdFrontendConfig->pw_policy.pw_resetfailurecount;
  2667. CFG_UNLOCK_READ(slapdFrontendConfig);
  2668. return retVal;
  2669. }
  2670. int
  2671. config_get_pw_is_global_policy() {
  2672. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2673. int retVal;
  2674. CFG_LOCK_READ(slapdFrontendConfig);
  2675. retVal = slapdFrontendConfig->pw_is_global_policy;
  2676. CFG_UNLOCK_READ(slapdFrontendConfig);
  2677. return retVal;
  2678. }
  2679. int
  2680. config_get_pw_exp() {
  2681. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2682. int retVal;
  2683. CFG_LOCK_READ(slapdFrontendConfig);
  2684. retVal = slapdFrontendConfig->pw_policy.pw_exp;
  2685. CFG_UNLOCK_READ(slapdFrontendConfig);
  2686. return retVal;
  2687. }
  2688. int
  2689. config_get_pw_unlock() {
  2690. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2691. int retVal;
  2692. CFG_LOCK_READ(slapdFrontendConfig);
  2693. retVal = slapdFrontendConfig->pw_policy.pw_unlock;
  2694. CFG_UNLOCK_READ(slapdFrontendConfig);
  2695. return retVal;
  2696. }
  2697. int
  2698. config_get_pw_lockout(){
  2699. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2700. int retVal;
  2701. CFG_LOCK_READ(slapdFrontendConfig);
  2702. retVal = slapdFrontendConfig->pw_policy.pw_lockout;
  2703. CFG_UNLOCK_READ(slapdFrontendConfig);
  2704. return retVal;
  2705. }
  2706. int
  2707. config_get_pw_gracelimit() {
  2708. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2709. int retVal=0;
  2710. CFG_LOCK_READ(slapdFrontendConfig);
  2711. retVal = slapdFrontendConfig->pw_policy.pw_gracelimit;
  2712. CFG_UNLOCK_READ(slapdFrontendConfig);
  2713. return retVal;
  2714. }
  2715. int
  2716. config_get_lastmod(){
  2717. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2718. int retVal;
  2719. CFG_LOCK_READ(slapdFrontendConfig);
  2720. retVal = slapdFrontendConfig->lastmod;
  2721. CFG_UNLOCK_READ(slapdFrontendConfig);
  2722. return retVal;
  2723. }
  2724. int
  2725. config_get_enquote_sup_oc(){
  2726. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2727. int retVal;
  2728. CFG_LOCK_READ(slapdFrontendConfig);
  2729. retVal = slapdFrontendConfig->enquote_sup_oc;
  2730. CFG_UNLOCK_READ(slapdFrontendConfig);
  2731. return retVal;
  2732. }
  2733. int
  2734. config_get_nagle() {
  2735. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2736. int retVal;
  2737. CFG_LOCK_READ(slapdFrontendConfig);
  2738. retVal = slapdFrontendConfig->nagle;
  2739. CFG_UNLOCK_READ(slapdFrontendConfig);
  2740. return retVal; }
  2741. int
  2742. config_get_accesscontrol() {
  2743. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2744. int retVal;
  2745. CFG_LOCK_READ(slapdFrontendConfig);
  2746. retVal = slapdFrontendConfig->accesscontrol;
  2747. CFG_UNLOCK_READ(slapdFrontendConfig);
  2748. return retVal;
  2749. }
  2750. int
  2751. config_get_return_exact_case() {
  2752. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2753. int retVal;
  2754. retVal = slapdFrontendConfig->return_exact_case;
  2755. return retVal;
  2756. }
  2757. int
  2758. config_get_result_tweak() {
  2759. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2760. int retVal;
  2761. CFG_LOCK_READ(slapdFrontendConfig);
  2762. retVal = slapdFrontendConfig->result_tweak;
  2763. CFG_UNLOCK_READ(slapdFrontendConfig);
  2764. return retVal;
  2765. }
  2766. int
  2767. config_get_security() {
  2768. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2769. int retVal;
  2770. CFG_LOCK_READ(slapdFrontendConfig);
  2771. retVal = slapdFrontendConfig->security;
  2772. CFG_UNLOCK_READ(slapdFrontendConfig);
  2773. return retVal;
  2774. }
  2775. int
  2776. slapi_config_get_readonly() {
  2777. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2778. int retVal;
  2779. CFG_LOCK_READ(slapdFrontendConfig);
  2780. retVal = slapdFrontendConfig->readonly;
  2781. CFG_UNLOCK_READ(slapdFrontendConfig);
  2782. return retVal;
  2783. }
  2784. int
  2785. config_get_schemacheck() {
  2786. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2787. int retVal;
  2788. CFG_LOCK_READ(slapdFrontendConfig);
  2789. retVal = slapdFrontendConfig->schemacheck;
  2790. CFG_UNLOCK_READ(slapdFrontendConfig);
  2791. return retVal;
  2792. }
  2793. int
  2794. config_get_ds4_compatible_schema() {
  2795. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2796. int retVal;
  2797. CFG_LOCK_READ(slapdFrontendConfig);
  2798. retVal = slapdFrontendConfig->ds4_compatible_schema;
  2799. CFG_UNLOCK_READ(slapdFrontendConfig);
  2800. return retVal;
  2801. }
  2802. int
  2803. config_get_schema_ignore_trailing_spaces() {
  2804. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2805. int retVal;
  2806. CFG_LOCK_READ(slapdFrontendConfig);
  2807. retVal = slapdFrontendConfig->schema_ignore_trailing_spaces;
  2808. CFG_UNLOCK_READ(slapdFrontendConfig);
  2809. return retVal;
  2810. }
  2811. char *
  2812. config_get_rootdn() {
  2813. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2814. char *retVal;
  2815. CFG_LOCK_READ(slapdFrontendConfig);
  2816. retVal = config_copy_strval (slapdFrontendConfig->rootdn);
  2817. CFG_UNLOCK_READ(slapdFrontendConfig);
  2818. return retVal;
  2819. }
  2820. char * slapi_get_rootdn() {
  2821. return config_get_rootdn();
  2822. }
  2823. char *
  2824. config_get_rootpw() {
  2825. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2826. char *retVal;
  2827. CFG_LOCK_READ(slapdFrontendConfig);
  2828. retVal = config_copy_strval (slapdFrontendConfig->rootpw);
  2829. CFG_UNLOCK_READ(slapdFrontendConfig);
  2830. return retVal;
  2831. }
  2832. char *
  2833. config_get_rootpwstoragescheme() {
  2834. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2835. char *retVal;
  2836. CFG_LOCK_READ(slapdFrontendConfig);
  2837. retVal = config_copy_strval(slapdFrontendConfig->rootpwstoragescheme->pws_name);
  2838. CFG_UNLOCK_READ(slapdFrontendConfig);
  2839. return retVal;
  2840. }
  2841. #ifndef _WIN32
  2842. char *
  2843. config_get_localuser() {
  2844. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2845. char *retVal;
  2846. CFG_LOCK_READ(slapdFrontendConfig);
  2847. retVal = config_copy_strval(slapdFrontendConfig->localuser);
  2848. CFG_UNLOCK_READ(slapdFrontendConfig);
  2849. return retVal;
  2850. }
  2851. #endif /* _WIN32 */
  2852. char *
  2853. config_get_instancedir() {
  2854. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2855. char *retVal;
  2856. CFG_LOCK_READ(slapdFrontendConfig);
  2857. retVal = config_copy_strval( slapdFrontendConfig->instancedir );
  2858. CFG_UNLOCK_READ(slapdFrontendConfig);
  2859. return retVal;
  2860. }
  2861. /* alias of encryption key and certificate files is now retrieved through */
  2862. /* calls to psetFullCreate() and psetGetAttrSingleValue(). See ssl.c, */
  2863. /* where this function is still used to set the global variable */
  2864. char *
  2865. config_get_encryptionalias() {
  2866. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2867. char *retVal;
  2868. CFG_LOCK_READ(slapdFrontendConfig);
  2869. retVal = config_copy_strval(slapdFrontendConfig->encryptionalias);
  2870. CFG_UNLOCK_READ(slapdFrontendConfig);
  2871. return retVal;
  2872. }
  2873. int
  2874. config_get_threadnumber() {
  2875. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2876. int retVal;
  2877. CFG_LOCK_READ(slapdFrontendConfig);
  2878. retVal = slapdFrontendConfig->threadnumber;
  2879. CFG_UNLOCK_READ(slapdFrontendConfig);
  2880. return retVal;
  2881. }
  2882. int
  2883. config_get_maxthreadsperconn(){
  2884. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2885. int retVal;
  2886. CFG_LOCK_READ(slapdFrontendConfig);
  2887. retVal = slapdFrontendConfig->maxthreadsperconn;
  2888. CFG_UNLOCK_READ(slapdFrontendConfig);
  2889. return retVal;
  2890. }
  2891. #if !defined(_WIN32) && !defined(AIX)
  2892. int
  2893. config_get_maxdescriptors() {
  2894. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2895. int retVal;
  2896. CFG_LOCK_READ(slapdFrontendConfig);
  2897. retVal = slapdFrontendConfig->maxdescriptors;
  2898. CFG_UNLOCK_READ(slapdFrontendConfig);
  2899. return retVal;
  2900. }
  2901. #endif /* !_WIN32 && !AIX */
  2902. int
  2903. config_get_reservedescriptors(){
  2904. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2905. int retVal;
  2906. CFG_LOCK_READ(slapdFrontendConfig);
  2907. retVal = slapdFrontendConfig->reservedescriptors;
  2908. CFG_UNLOCK_READ(slapdFrontendConfig);
  2909. return retVal;
  2910. }
  2911. int
  2912. config_get_ioblocktimeout(){
  2913. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2914. int retVal;
  2915. CFG_LOCK_READ(slapdFrontendConfig);
  2916. retVal = slapdFrontendConfig->ioblocktimeout;
  2917. CFG_UNLOCK_READ(slapdFrontendConfig);
  2918. return retVal;
  2919. }
  2920. int
  2921. config_get_idletimeout(){
  2922. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2923. int retVal;
  2924. CFG_LOCK_READ(slapdFrontendConfig);
  2925. retVal = slapdFrontendConfig->idletimeout;
  2926. CFG_UNLOCK_READ(slapdFrontendConfig);
  2927. return retVal;
  2928. }
  2929. int
  2930. config_get_groupevalnestlevel(){
  2931. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2932. int retVal;
  2933. CFG_LOCK_READ(slapdFrontendConfig);
  2934. retVal = slapdFrontendConfig->groupevalnestlevel;
  2935. CFG_UNLOCK_READ(slapdFrontendConfig);
  2936. return retVal;
  2937. }
  2938. struct berval **
  2939. config_get_defaultreferral() {
  2940. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2941. struct berval **refs;
  2942. int nReferrals = 0;
  2943. CFG_LOCK_READ(slapdFrontendConfig);
  2944. /* count the number of referrals */
  2945. for ( nReferrals = 0;
  2946. slapdFrontendConfig->defaultreferral &&
  2947. slapdFrontendConfig->defaultreferral[nReferrals];
  2948. nReferrals++)
  2949. ;
  2950. refs = (struct berval **)
  2951. slapi_ch_malloc( (nReferrals + 1) * sizeof(struct berval *) );
  2952. /*terminate the end, and add the referrals backwards */
  2953. refs [nReferrals--] = NULL;
  2954. while ( nReferrals >= 0 ) {
  2955. refs[nReferrals] = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
  2956. refs[nReferrals]->bv_val =
  2957. config_copy_strval( slapdFrontendConfig->defaultreferral[nReferrals]->bv_val );
  2958. refs[nReferrals]->bv_len = slapdFrontendConfig->defaultreferral[nReferrals]->bv_len;
  2959. nReferrals--;
  2960. }
  2961. CFG_UNLOCK_READ(slapdFrontendConfig);
  2962. return refs;
  2963. }
  2964. char *
  2965. config_get_userat ( ){
  2966. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2967. char *retVal;
  2968. CFG_LOCK_READ(slapdFrontendConfig);
  2969. retVal = config_copy_strval( slapdFrontendConfig->userat );
  2970. CFG_UNLOCK_READ(slapdFrontendConfig);
  2971. return retVal;
  2972. }
  2973. int
  2974. config_get_timelimit(){
  2975. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2976. int retVal;
  2977. CFG_LOCK_READ(slapdFrontendConfig);
  2978. retVal= slapdFrontendConfig->timelimit;
  2979. CFG_UNLOCK_READ(slapdFrontendConfig);
  2980. return retVal;
  2981. }
  2982. char*
  2983. config_get_useroc(){
  2984. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2985. char *retVal;
  2986. CFG_LOCK_WRITE(slapdFrontendConfig);
  2987. retVal = config_copy_strval(slapdFrontendConfig->useroc );
  2988. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  2989. return retVal;
  2990. }
  2991. char *
  2992. config_get_accesslog(){
  2993. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  2994. char *retVal;
  2995. CFG_LOCK_READ(slapdFrontendConfig);
  2996. retVal = config_copy_strval(slapdFrontendConfig->accesslog);
  2997. CFG_UNLOCK_READ(slapdFrontendConfig);
  2998. return retVal;
  2999. }
  3000. char *
  3001. config_get_errorlog( ){
  3002. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3003. char *retVal;
  3004. CFG_LOCK_READ(slapdFrontendConfig);
  3005. retVal = config_copy_strval(slapdFrontendConfig->errorlog);
  3006. CFG_UNLOCK_READ(slapdFrontendConfig);
  3007. return retVal;
  3008. }
  3009. char *
  3010. config_get_auditlog( ){
  3011. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3012. char *retVal;
  3013. CFG_LOCK_READ(slapdFrontendConfig);
  3014. retVal = config_copy_strval(slapdFrontendConfig->auditlog);
  3015. CFG_UNLOCK_READ(slapdFrontendConfig);
  3016. return retVal;
  3017. }
  3018. long
  3019. config_get_pw_maxage() {
  3020. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3021. long retVal;
  3022. CFG_LOCK_READ(slapdFrontendConfig);
  3023. retVal = slapdFrontendConfig->pw_policy.pw_maxage;
  3024. CFG_UNLOCK_READ(slapdFrontendConfig);
  3025. return retVal;
  3026. }
  3027. long
  3028. config_get_pw_minage(){
  3029. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3030. long retVal;
  3031. CFG_LOCK_READ(slapdFrontendConfig);
  3032. retVal = slapdFrontendConfig->pw_policy.pw_minage;
  3033. CFG_UNLOCK_READ(slapdFrontendConfig);
  3034. return retVal;
  3035. }
  3036. long
  3037. config_get_pw_warning() {
  3038. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3039. long retVal;
  3040. CFG_LOCK_READ(slapdFrontendConfig);
  3041. retVal = slapdFrontendConfig->pw_policy.pw_warning;
  3042. CFG_UNLOCK_READ(slapdFrontendConfig);
  3043. return retVal;
  3044. }
  3045. int
  3046. config_get_errorlog_level(){
  3047. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3048. int retVal;
  3049. CFG_LOCK_READ(slapdFrontendConfig);
  3050. retVal = slapdFrontendConfig->errorloglevel;
  3051. CFG_UNLOCK_READ(slapdFrontendConfig);
  3052. return retVal;
  3053. }
  3054. /* return integer -- don't worry about locking similar to config_check_referral_mode
  3055. below */
  3056. int
  3057. config_get_accesslog_level(){
  3058. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3059. int retVal;
  3060. retVal = slapdFrontendConfig->accessloglevel;
  3061. return retVal;
  3062. }
  3063. /* return integer -- don't worry about locking similar to config_check_referral_mode
  3064. below */
  3065. int
  3066. config_get_auditlog_logging_enabled(){
  3067. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3068. int retVal;
  3069. retVal = slapdFrontendConfig->auditlog_logging_enabled;
  3070. return retVal;
  3071. }
  3072. char *config_get_referral_mode(void)
  3073. {
  3074. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3075. char *ret;
  3076. CFG_LOCK_READ(slapdFrontendConfig);
  3077. ret = config_copy_strval(slapdFrontendConfig->refer_url);
  3078. CFG_UNLOCK_READ(slapdFrontendConfig);
  3079. return ret;
  3080. }
  3081. int
  3082. config_get_conntablesize(void){
  3083. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3084. int retVal;
  3085. CFG_LOCK_READ(slapdFrontendConfig);
  3086. retVal = slapdFrontendConfig->conntablesize;
  3087. CFG_UNLOCK_READ(slapdFrontendConfig);
  3088. return retVal;
  3089. }
  3090. /* return yes/no without actually copying the referral url
  3091. we don't worry about another thread changing this value
  3092. since we now return an integer */
  3093. int config_check_referral_mode(void)
  3094. {
  3095. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3096. return(slapdFrontendConfig->refer_mode & REFER_MODE_ON);
  3097. }
  3098. int
  3099. config_get_outbound_ldap_io_timeout(void)
  3100. {
  3101. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3102. int retVal;
  3103. CFG_LOCK_READ(slapdFrontendConfig);
  3104. retVal = slapdFrontendConfig->outbound_ldap_io_timeout;
  3105. CFG_UNLOCK_READ(slapdFrontendConfig);
  3106. return retVal;
  3107. }
  3108. int
  3109. config_is_slapd_lite ()
  3110. {
  3111. return ( SLAPD_FULL );
  3112. }
  3113. /* This function is called once at the startup time and no more */
  3114. void
  3115. config_set_slapd_type( )
  3116. {
  3117. char *root = NULL;
  3118. char *s_root = NULL;
  3119. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3120. CFG_LOCK_WRITE(slapdFrontendConfig);
  3121. if ( slapdFrontendConfig->instancedir )
  3122. s_root = root = slapi_ch_strdup ( slapdFrontendConfig->instancedir );
  3123. if ( (root = strrchr( root, '/' )) != NULL ) {
  3124. *root = '\0';
  3125. }
  3126. slapdFrontendConfig->slapd_type = 0;
  3127. slapdFrontendConfig->versionstring = SLAPD_VERSION_STR;
  3128. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3129. slapi_ch_free ( (void **) &s_root );
  3130. }
  3131. int
  3132. config_set_maxbersize( const char *attrname, char *value, char *errorbuf, int apply )
  3133. {
  3134. int retVal = LDAP_SUCCESS;
  3135. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3136. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3137. return LDAP_OPERATIONS_ERROR;
  3138. }
  3139. if ( !apply ) {
  3140. return retVal;
  3141. }
  3142. CFG_LOCK_WRITE(slapdFrontendConfig);
  3143. slapdFrontendConfig->maxbersize = atoi(value);
  3144. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3145. return retVal;
  3146. }
  3147. unsigned long
  3148. config_get_maxbersize()
  3149. {
  3150. unsigned long maxbersize;
  3151. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3152. maxbersize = slapdFrontendConfig->maxbersize;
  3153. if(maxbersize==0)
  3154. maxbersize= 2 * 1024 * 1024; /* Default: 2Mb */
  3155. return maxbersize;
  3156. }
  3157. int
  3158. config_set_max_filter_nest_level( const char *attrname, char *value,
  3159. char *errorbuf, int apply )
  3160. {
  3161. int retVal = LDAP_SUCCESS;
  3162. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3163. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3164. return LDAP_OPERATIONS_ERROR;
  3165. }
  3166. if ( !apply ) {
  3167. return retVal;
  3168. }
  3169. CFG_LOCK_WRITE(slapdFrontendConfig);
  3170. slapdFrontendConfig->max_filter_nest_level = atoi(value);
  3171. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3172. return retVal;
  3173. }
  3174. int
  3175. config_get_max_filter_nest_level()
  3176. {
  3177. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3178. int retVal;
  3179. CFG_LOCK_READ(slapdFrontendConfig);
  3180. retVal = slapdFrontendConfig->max_filter_nest_level;
  3181. CFG_UNLOCK_READ(slapdFrontendConfig);
  3182. return retVal;
  3183. }
  3184. char *
  3185. config_get_basedn() {
  3186. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3187. char *retVal;
  3188. CFG_LOCK_READ(slapdFrontendConfig);
  3189. retVal = config_copy_strval ( slapdFrontendConfig->certmap_basedn );
  3190. CFG_UNLOCK_READ(slapdFrontendConfig);
  3191. return retVal;
  3192. }
  3193. int
  3194. config_set_basedn ( const char *attrname, char *value, char *errorbuf, int apply ) {
  3195. int retVal = LDAP_SUCCESS;
  3196. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3197. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3198. return LDAP_OPERATIONS_ERROR;
  3199. }
  3200. if ( !apply ) {
  3201. return retVal;
  3202. }
  3203. CFG_LOCK_WRITE(slapdFrontendConfig);
  3204. slapi_ch_free ( (void **) &slapdFrontendConfig->certmap_basedn );
  3205. slapdFrontendConfig->certmap_basedn = slapi_dn_normalize( slapi_ch_strdup(value) );
  3206. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3207. return retVal;
  3208. }
  3209. char *
  3210. config_get_configdir()
  3211. {
  3212. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3213. char *retVal;
  3214. CFG_LOCK_READ(slapdFrontendConfig);
  3215. retVal = config_copy_strval(slapdFrontendConfig->configdir);
  3216. CFG_UNLOCK_READ(slapdFrontendConfig);
  3217. return retVal;
  3218. }
  3219. int
  3220. config_set_configdir(const char *attrname, char *value, char *errorbuf, int apply)
  3221. {
  3222. int retVal = LDAP_SUCCESS;
  3223. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3224. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3225. return LDAP_OPERATIONS_ERROR;
  3226. }
  3227. if (!apply) {
  3228. return retVal;
  3229. }
  3230. CFG_LOCK_WRITE(slapdFrontendConfig);
  3231. slapi_ch_free((void **)&slapdFrontendConfig->configdir);
  3232. slapdFrontendConfig->configdir = slapi_ch_strdup(value);
  3233. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3234. return retVal;
  3235. }
  3236. char **
  3237. config_get_errorlog_list()
  3238. {
  3239. return log_get_loglist(SLAPD_ERROR_LOG);
  3240. }
  3241. char **
  3242. config_get_accesslog_list()
  3243. {
  3244. return log_get_loglist(SLAPD_ACCESS_LOG);
  3245. }
  3246. char **
  3247. config_get_auditlog_list()
  3248. {
  3249. return log_get_loglist(SLAPD_AUDIT_LOG);
  3250. }
  3251. int
  3252. config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
  3253. {
  3254. int retVal = LDAP_SUCCESS;
  3255. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3256. retVal = config_set_onoff(attrname,
  3257. value,
  3258. &(slapdFrontendConfig->accesslogbuffering),
  3259. errorbuf,
  3260. apply);
  3261. return retVal;
  3262. }
  3263. int
  3264. config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply)
  3265. {
  3266. int retVal = LDAP_SUCCESS;
  3267. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3268. retVal = config_set_onoff(attrname,
  3269. value,
  3270. &(slapdFrontendConfig->csnlogging),
  3271. errorbuf,
  3272. apply);
  3273. return retVal;
  3274. }
  3275. int
  3276. config_get_csnlogging()
  3277. {
  3278. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3279. return slapdFrontendConfig->csnlogging;
  3280. }
  3281. int
  3282. config_set_attrname_exceptions(const char *attrname, char *value, char *errorbuf, int apply)
  3283. {
  3284. int retVal = LDAP_SUCCESS;
  3285. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3286. retVal = config_set_onoff(attrname,
  3287. value,
  3288. &(slapdFrontendConfig->attrname_exceptions),
  3289. errorbuf,
  3290. apply);
  3291. return retVal;
  3292. }
  3293. int
  3294. config_get_attrname_exceptions()
  3295. {
  3296. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3297. return slapdFrontendConfig->attrname_exceptions;
  3298. }
  3299. int
  3300. config_set_hash_filters(const char *attrname, char *value, char *errorbuf, int apply)
  3301. {
  3302. int val = 0;
  3303. int retVal = LDAP_SUCCESS;
  3304. retVal = config_set_onoff(attrname,
  3305. value,
  3306. &val,
  3307. errorbuf,
  3308. apply);
  3309. if (retVal == LDAP_SUCCESS) {
  3310. set_hash_filters(val);
  3311. }
  3312. return retVal;
  3313. }
  3314. int
  3315. config_get_hash_filters()
  3316. {
  3317. return 0; /* for now */
  3318. }
  3319. int
  3320. config_set_rewrite_rfc1274(const char *attrname, char *value, char *errorbuf, int apply)
  3321. {
  3322. int retVal = LDAP_SUCCESS;
  3323. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3324. retVal = config_set_onoff(attrname,
  3325. value,
  3326. &(slapdFrontendConfig->rewrite_rfc1274),
  3327. errorbuf,
  3328. apply);
  3329. return retVal;
  3330. }
  3331. /* we don't worry about another thread changing this flag since it is an
  3332. integer */
  3333. int
  3334. config_get_rewrite_rfc1274()
  3335. {
  3336. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3337. int retVal;
  3338. retVal = slapdFrontendConfig->rewrite_rfc1274;
  3339. return retVal;
  3340. }
  3341. static int
  3342. config_set_schemareplace( const char *attrname, char *value, char *errorbuf, int apply )
  3343. {
  3344. int retVal = LDAP_SUCCESS;
  3345. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3346. retVal = LDAP_OPERATIONS_ERROR;
  3347. } else {
  3348. /*
  3349. * check that the value is one we allow.
  3350. */
  3351. if ( 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_OFF ) &&
  3352. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_ON ) &&
  3353. 0 != strcasecmp( value, CONFIG_SCHEMAREPLACE_STR_REPLICATION_ONLY )) {
  3354. retVal = LDAP_OPERATIONS_ERROR;
  3355. if( errorbuf ) {
  3356. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "unsupported value: %s", value );
  3357. }
  3358. }
  3359. }
  3360. if ( LDAP_SUCCESS == retVal && apply ) {
  3361. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3362. CFG_LOCK_WRITE(slapdFrontendConfig);
  3363. slapi_ch_free( (void **)&slapdFrontendConfig->schemareplace );
  3364. slapdFrontendConfig->schemareplace = slapi_ch_strdup( value );
  3365. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3366. }
  3367. return retVal;
  3368. }
  3369. int
  3370. config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
  3371. char *errorbuf, int apply )
  3372. {
  3373. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3374. if ( config_value_is_null( attrname, value, errorbuf, 0 )) {
  3375. return LDAP_OPERATIONS_ERROR;
  3376. }
  3377. if ( apply ) {
  3378. CFG_LOCK_WRITE(slapdFrontendConfig);
  3379. slapdFrontendConfig->outbound_ldap_io_timeout = atoi( value );
  3380. CFG_UNLOCK_WRITE(slapdFrontendConfig);
  3381. }
  3382. return LDAP_SUCCESS;
  3383. }
  3384. /*
  3385. * This function is intended to be used from the dse code modify callback. It
  3386. * is "optimized" for that case because it takes a berval** of values, which is
  3387. * currently what is used by ldapmod to hold the values. We could easily switch
  3388. * this to take a Slapi_Value array or even a Slapi_Attr. Most config params
  3389. * have simple config_set_XXX functions which take a char* argument holding the
  3390. * value. The log_set_XXX functions have an additional parameter which
  3391. * discriminates the log to use. The config parameters with types CONFIG_SPECIAL_XXX
  3392. * require special handling to set their values.
  3393. */
  3394. int
  3395. config_set(const char *attr, struct berval **values, char *errorbuf, int apply)
  3396. {
  3397. int ii = 0;
  3398. int retval = LDAP_SUCCESS;
  3399. struct config_get_and_set *cgas = 0;
  3400. cgas = (struct config_get_and_set *)PL_HashTableLookup(confighash, attr);
  3401. if (!cgas)
  3402. {
  3403. #if 0
  3404. debugHashTable(attr);
  3405. #endif
  3406. PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Unknown attribute %s will be ignored", attr);
  3407. slapi_log_error(SLAPI_LOG_FATAL, "config", "%s\n", errorbuf);
  3408. return retval;
  3409. }
  3410. switch (cgas->config_var_type)
  3411. {
  3412. case CONFIG_SPECIAL_REFERRALLIST:
  3413. if (NULL == values) /* special token which means to remove referrals */
  3414. {
  3415. struct berval val;
  3416. struct berval *vals[2] = {0, 0};
  3417. vals[0] = &val;
  3418. val.bv_val = REFERRAL_REMOVE_CMD;
  3419. val.bv_len = strlen(REFERRAL_REMOVE_CMD);
  3420. retval = config_set_defaultreferral(attr, vals, errorbuf, apply);
  3421. }
  3422. else
  3423. {
  3424. retval = config_set_defaultreferral(attr, values, errorbuf, apply);
  3425. }
  3426. break;
  3427. default:
  3428. for (ii = 0; !retval && values && values[ii]; ++ii)
  3429. {
  3430. if (cgas->setfunc)
  3431. retval = (cgas->setfunc)(cgas->attr_name,
  3432. (char *)values[ii]->bv_val, errorbuf, apply);
  3433. else if (cgas->logsetfunc)
  3434. retval = (cgas->logsetfunc)(cgas->attr_name,
  3435. (char *)values[ii]->bv_val, cgas->whichlog,
  3436. errorbuf, apply);
  3437. else
  3438. LDAPDebug(LDAP_DEBUG_ANY,
  3439. "config_set: the attribute %s is read only; ignoring new value %s\n",
  3440. attr, values[ii]->bv_val, 0);
  3441. }
  3442. break;
  3443. }
  3444. return retval;
  3445. }
  3446. static void
  3447. config_set_value(
  3448. Slapi_Entry *e,
  3449. struct config_get_and_set *cgas,
  3450. void **value
  3451. )
  3452. {
  3453. struct berval **values = 0;
  3454. char *sval = 0;
  3455. /* for null values, just set the attr value to the empty
  3456. string */
  3457. if (!value) {
  3458. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3459. return;
  3460. }
  3461. switch (cgas->config_var_type) {
  3462. case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */
  3463. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3464. (value && *((int *)value)) ? "on" : "off");
  3465. break;
  3466. case CONFIG_INT:
  3467. if (value)
  3468. slapi_entry_attr_set_int(e, cgas->attr_name, *((int *)value));
  3469. else
  3470. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3471. break;
  3472. case CONFIG_LONG:
  3473. if (value)
  3474. slapi_entry_attr_set_long(e, cgas->attr_name, *((long *)value));
  3475. else
  3476. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3477. break;
  3478. case CONFIG_STRING:
  3479. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3480. (value && *((char **)value)) ?
  3481. *((char **)value) : "");
  3482. break;
  3483. case CONFIG_CHARRAY:
  3484. values = strarray2bervalarray((const char **)*((char ***)value));
  3485. if (!values) {
  3486. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3487. } else {
  3488. slapi_entry_attr_replace(e, cgas->attr_name, values);
  3489. bervalarray_free(values);
  3490. }
  3491. break;
  3492. case CONFIG_SPECIAL_REFERRALLIST:
  3493. /* referral list is already an array of berval* */
  3494. if (value)
  3495. slapi_entry_attr_replace(e, cgas->attr_name, (struct berval**)*value);
  3496. else
  3497. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3498. break;
  3499. case CONFIG_CONSTANT_STRING:
  3500. PR_ASSERT(value); /* should be a constant value */
  3501. slapi_entry_attr_set_charptr(e, cgas->attr_name, (char*)value);
  3502. break;
  3503. case CONFIG_CONSTANT_INT:
  3504. PR_ASSERT(value); /* should be a constant value */
  3505. slapi_entry_attr_set_int(e, cgas->attr_name, (int)value);
  3506. break;
  3507. case CONFIG_SPECIAL_SSLCLIENTAUTH:
  3508. if (!value) {
  3509. slapi_entry_attr_set_charptr(e, cgas->attr_name, "off");
  3510. break;
  3511. }
  3512. if (*((int *)value) == SLAPD_SSLCLIENTAUTH_ALLOWED) {
  3513. sval = "allowed";
  3514. } else if (*((int *)value) == SLAPD_SSLCLIENTAUTH_REQUIRED) {
  3515. sval = "required";
  3516. } else {
  3517. sval = "off";
  3518. }
  3519. slapi_entry_attr_set_charptr(e, cgas->attr_name, sval);
  3520. break;
  3521. case CONFIG_STRING_OR_OFF:
  3522. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3523. (value && *((char **)value)) ?
  3524. *((char **)value) : "off");
  3525. break;
  3526. case CONFIG_STRING_OR_EMPTY:
  3527. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3528. (value && *((char **)value)) ?
  3529. *((char **)value) : "");
  3530. break;
  3531. case CONFIG_STRING_OR_UNKNOWN:
  3532. slapi_entry_attr_set_charptr(e, cgas->attr_name,
  3533. (value && *((char **)value)) ?
  3534. *((char **)value) : "unknown");
  3535. break;
  3536. case CONFIG_SPECIAL_ERRORLOGLEVEL:
  3537. if (value) {
  3538. int ival = *(int *)value;
  3539. ival &= ~LDAP_DEBUG_ANY;
  3540. slapi_entry_attr_set_int(e, cgas->attr_name, ival);
  3541. }
  3542. else
  3543. slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
  3544. break;
  3545. default:
  3546. PR_ASSERT(0); /* something went horribly wrong . . . */
  3547. break;
  3548. }
  3549. return;
  3550. }
  3551. /*
  3552. * Fill in the given slapi_entry with the config attributes and values
  3553. */
  3554. int
  3555. config_set_entry(Slapi_Entry *e)
  3556. {
  3557. int ii = 0;
  3558. int tablesize = sizeof(ConfigList)/sizeof(ConfigList[0]);
  3559. slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
  3560. /*
  3561. * Avoid recursive calls to the readers/writer
  3562. * lock as it causes deadlock under stress. Each
  3563. * individual config get function acquires a read
  3564. * lock where necessary.
  3565. */
  3566. /*
  3567. * Pass 1: Values which do not have a get function.
  3568. */
  3569. CFG_LOCK_READ(slapdFrontendConfig);
  3570. for (ii = 0; ii < tablesize; ++ii) {
  3571. struct config_get_and_set *cgas = &ConfigList[ii];
  3572. void **value = 0;
  3573. PR_ASSERT(cgas);
  3574. value = cgas->config_var_addr;
  3575. PR_ASSERT(cgas->attr_name);
  3576. /* Skip values handled in pass 2 */
  3577. if (NULL == value && cgas->getfunc) {
  3578. continue;
  3579. }
  3580. config_set_value(e, cgas, value);
  3581. }
  3582. CFG_UNLOCK_READ(slapdFrontendConfig);
  3583. /*
  3584. * Pass 2: Values which do have a get function.
  3585. */
  3586. for (ii = 0; ii < tablesize; ++ii) {
  3587. struct config_get_and_set *cgas = &ConfigList[ii];
  3588. void **value = 0;
  3589. void *alloc_val;
  3590. int needs_free = 0;
  3591. PR_ASSERT(cgas);
  3592. value = cgas->config_var_addr;
  3593. PR_ASSERT(cgas->attr_name);
  3594. /* Skip values handled in pass 1 */
  3595. if (NULL != value || cgas->getfunc == NULL) {
  3596. continue;
  3597. }
  3598. alloc_val = (cgas->getfunc)();
  3599. value = &alloc_val; /* value must be address of pointer */
  3600. if (!isIntegralType(cgas->config_var_type))
  3601. needs_free = 1; /* get funcs must return alloc'd memory except for get
  3602. funcs which return a simple integral type e.g. int */
  3603. config_set_value(e, cgas, value);
  3604. if (needs_free && value) { /* assumes memory allocated by slapi_ch_Xalloc */
  3605. if (CONFIG_CHARRAY == cgas->config_var_type) {
  3606. charray_free(*((char ***)value));
  3607. } else {
  3608. slapi_ch_free(value);
  3609. }
  3610. }
  3611. }
  3612. return 1;
  3613. }