| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341 |
- /** BEGIN COPYRIGHT BLOCK
- * This Program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; version 2 of the License.
- *
- * This Program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * In addition, as a special exception, Red Hat, Inc. gives You the additional
- * right to link the code of this Program with code not covered under the GNU
- * General Public License ("Non-GPL Code") and to distribute linked combinations
- * including the two, subject to the limitations in this paragraph. Non-GPL Code
- * permitted under this exception must only link to the code of this Program
- * through those well defined interfaces identified in the file named EXCEPTION
- * found in the source code files (the "Approved Interfaces"). The files of
- * Non-GPL Code may instantiate templates or use macros or inline functions from
- * the Approved Interfaces without causing the resulting work to be covered by
- * the GNU General Public License. Only Red Hat, Inc. may make changes or
- * additions to the list of Approved Interfaces. You must obey the GNU General
- * Public License in all respects for all of the Program code and other code used
- * in conjunction with the Program except the Non-GPL Code covered by this
- * exception. If you modify this file, you may extend this exception to your
- * version of the file, but you are not obligated to do so. If you do not wish to
- * provide this exception without modification, you must delete this exception
- * statement from your version and license this file solely under the GPL without
- * exception.
- *
- *
- * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
- * Copyright (C) 2005 Red Hat, Inc.
- * All rights reserved.
- * END COPYRIGHT BLOCK **/
- /*********************************************************************
- **
- ** NAME:
- ** ux-dialog.cc
- **
- ** DESCRIPTION:
- ** Netscape Directory Server Pre-installation Program
- ** Definitions for UI dialogs.
- **
- ** NOTES:
- **
- **
- *********************************************************************/
- #if !defined(HPUX) || defined(_HP_NAMESPACE_STD)
- #include <iostream>
- #include <strstream>
- #include <fstream>
- using namespace std;
- using std::ostrstream;
- #else
- /* older HP-UX compiler, using libstd 1 (no -AA) */
- #include <iostream.h> /* use old name on older systems */
- #include <strstream.h>
- #include <fstream.h>
- #endif
- #include <errno.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <ctype.h>
- #include <string.h>
- #include <strings.h>
- #include "utf8.h"
- #include "ux-util.h"
- #include "dialog.h"
- #include "ux-dialog.h"
- #include "ux-config.h"
- #include "install_keywords.h"
- extern "C" {
- #include "dsalib.h"
- #include "nspr.h"
- #include "plstr.h"
- }
- static const char *DEFAULT_SLAPDUSER = "cn=Directory Manager";
- // #define DEBUG 2
- /*
- ** Forward References
- */
- static DialogAction askSlapdPortSetup (Dialog *me);
- static DialogAction askSlapdPortNext(Dialog *me);
- static DialogAction askSlapdServerIDSetup (Dialog *me);
- static DialogAction askSlapdServerIDNext(Dialog *me);
- static DialogAction askSlapdRootDNSetup(Dialog *me);
- static DialogAction askSlapdRootDNNext (Dialog *me);
- static DialogAction askMCAdminIDSetup (Dialog *me);
- static DialogAction askMCAdminIDNext (Dialog *me);
- static DialogAction askReconfigMCAdminPwdSetup (Dialog *me);
- static DialogAction askReconfigMCAdminPwdNext (Dialog *me);
- static DialogAction askSlapdSuffixSetup (Dialog *me);
- static DialogAction askSlapdSuffixNext (Dialog *me);
- static DialogAction askSampleSetup (Dialog *me);
- static DialogAction askSampleNext (Dialog *me);
- static DialogAction askPopulateSetup (Dialog *me);
- static DialogAction askPopulateNext (Dialog *me);
- static DialogAction askOrgSizeSetup (Dialog *me);
- static DialogAction askOrgSizeNext (Dialog *me);
- static DialogAction askCIRSetup(Dialog *me);
- static DialogAction askCIRNext(Dialog *me);
- static DialogAction askCIRHostSetup(Dialog *me);
- static DialogAction askCIRHostNext(Dialog *me);
- static DialogAction askCIRPortSetup(Dialog *me);
- static DialogAction askCIRPortNext(Dialog *me);
- static DialogAction askCIRDNSetup(Dialog *me);
- static DialogAction askCIRDNNext(Dialog *me);
- static DialogAction askCIRSuffixSetup(Dialog *me);
- static DialogAction askCIRSuffixNext(Dialog *me);
- static DialogAction askCIRSSLSetup(Dialog *me);
- static DialogAction askCIRSSLNext(Dialog *me);
- static DialogAction askCIRIntervalSetup(Dialog *me);
- static DialogAction askCIRIntervalNext(Dialog *me);
- static DialogAction askCIRDaysSetup(Dialog *me);
- static DialogAction askCIRDaysNext(Dialog *me);
- static DialogAction askCIRTimesSetup(Dialog *me);
- static DialogAction askCIRTimesNext(Dialog *me);
- static DialogAction askSIRSetup(Dialog *me);
- static DialogAction askSIRNext(Dialog *me);
- static DialogAction askChangeLogSuffixSetup(Dialog *me);
- static DialogAction askChangeLogSuffixNext(Dialog *me);
- static DialogAction askChangeLogDirSetup(Dialog *me);
- static DialogAction askChangeLogDirNext(Dialog *me);
- static DialogAction askReplicationDNSetup(Dialog *me);
- static DialogAction askReplicationDNNext(Dialog *me);
- static DialogAction askReplicationSetup(Dialog *me);
- static DialogAction askReplicationNext(Dialog *me);
- static DialogAction askConsumerDNSetup(Dialog *me);
- static DialogAction askConsumerDNNext(Dialog *me);
- static DialogAction askSIRHostSetup(Dialog *me);
- static DialogAction askSIRHostNext(Dialog *me);
- static DialogAction askSIRPortSetup(Dialog *me);
- static DialogAction askSIRPortNext(Dialog *me);
- static DialogAction askSIRDNSetup(Dialog *me);
- static DialogAction askSIRDNNext(Dialog *me);
- static DialogAction askSIRSuffixSetup(Dialog *me);
- static DialogAction askSIRSuffixNext(Dialog *me);
- static DialogAction askSIRSSLSetup(Dialog *me);
- static DialogAction askSIRSSLNext(Dialog *me);
- static DialogAction askSIRDaysSetup(Dialog *me);
- static DialogAction askSIRDaysNext(Dialog *me);
- static DialogAction askSIRTimesSetup(Dialog *me);
- static DialogAction askSIRTimesNext(Dialog *me);
- static DialogAction askUseExistingMCSetup(Dialog *me);
- static DialogAction askUseExistingMCNext(Dialog *me);
- static DialogAction askMCHostSetup(Dialog *me);
- static DialogAction askMCHostNext(Dialog *me);
- static DialogAction askMCPortSetup(Dialog *me);
- static DialogAction askMCPortNext(Dialog *me);
- static DialogAction askMCDNSetup(Dialog *me);
- static DialogAction askMCDNNext(Dialog *me);
- static DialogAction askDisableSchemaCheckingSetup(Dialog *me);
- static DialogAction askDisableSchemaCheckingNext(Dialog *me);
- static DialogAction askMCAdminDomainSetup(Dialog *me);
- static DialogAction askMCAdminDomainNext(Dialog *me);
- static DialogAction askAdminDomainSetup(Dialog *me);
- static DialogAction askAdminDomainNext(Dialog *me);
- static DialogAction askUseExistingUGSetup(Dialog *me);
- static DialogAction askUseExistingUGNext(Dialog *me);
- static DialogAction askUGHostSetup(Dialog *me);
- static DialogAction askUGHostNext(Dialog *me);
- static DialogAction askUGPortSetup(Dialog *me);
- static DialogAction askUGPortNext(Dialog *me);
- static DialogAction askUGDNSetup(Dialog *me);
- static DialogAction askUGDNNext(Dialog *me);
- static DialogAction askUGSuffixSetup(Dialog *me);
- static DialogAction askUGSuffixNext(Dialog *me);
- static int
- isAValidDN(const char *dn_to_test)
- {
- int ret = 1;
- if (!dn_to_test || !*dn_to_test)
- {
- ret = 0;
- }
- else
- {
- char **rdnList = ldap_explode_dn(dn_to_test, 0);
- char **rdnNoTypes = ldap_explode_dn(dn_to_test, 1);
- if (!rdnList || !rdnList[0] || !rdnNoTypes || !rdnNoTypes[0] ||
- !*rdnNoTypes[0] || !strcasecmp(rdnList[0], rdnNoTypes[0]))
- {
- ret = 0;
- }
- if (rdnList)
- ldap_value_free(rdnList);
- if (rdnNoTypes)
- ldap_value_free(rdnNoTypes);
- }
- if ((ret == 1) && ds_dn_uses_LDAPv2_quoting(dn_to_test))
- {
- char *newdn = strdup(dn_to_test);
- dn_normalize_convert(newdn);
- char *oldlocaldn = UTF8ToLocal(dn_to_test);
- char *newlocaldn = UTF8ToLocal(newdn);
- free(newdn);
- NSString msg = NSString(
- "The given value [") + oldlocaldn + "] is quoted in the deprecated LDAPv2 style\n" +
- "quoting format. It will be automatically converted to use the\n" +
- "LDAPv3 style escaped format [" + newlocaldn + "].";
- DialogManagerType::showAlert(msg);
- nsSetupFree(oldlocaldn);
- nsSetupFree(newlocaldn);
- }
- return ret;
- }
- static int
- contains8BitChars(const char *s)
- {
- int ret = 0;
- if (s && *s)
- {
- for (; !ret && *s; ++s)
- {
- ret = (*s & 0x80);
- }
- }
- return ret;
- }
- static int
- rootDNPwdIsValid(const char *pwd)
- {
- if (!pwd || !*pwd || (strlen(pwd) < 8))
- return 0;
- return !contains8BitChars(pwd);
- }
- static int
- isValid(const char *s)
- {
- if (!s)
- return 1; // null is a valid response (means to accept default)
- int ret = 1;
- char *ncs = (char *)s; // cast away const-ness for ldaputf8 stuff
- // trim spaces from the beginning of the string
- while (*ncs && ldap_utf8isspace(ncs))
- LDAP_UTF8INC(ncs);
- if (!*ncs) // empty string or all spaces
- ret = 0;
- return ret;
- }
- static int
- isValidServerID(const char *s)
- {
- if (!s || !*s)
- return 0;
- if (!isValid(s))
- return 0;
- if (contains8BitChars(s))
- return 0;
- // server ID should contain alphanum, _, -, . since it will
- // be used for both a filename and a DN component
- const char *badChars = "`~!@#$%^&*()[]|\\\"\':;,+=/<>?";
- const char *p = s;
- for (; *p && !strchr(badChars, *p); ++p)
- ;
- if (!*p) // the string contains all valid chars
- return 1;
- return 0;
- }
- static int
- isValidYesNo(const char *s)
- {
- if (!s)
- return 1; // null means accept default
- const char *msg = 0;
- if (isValid(s))
- {
- int len = strlen(s);
- if (strncasecmp(s, "yes", len) && strncasecmp(s, "no", len))
- {
- msg = "Please type yes or no.";
- }
- }
- else
- {
- msg = "Please specify a valid string.";
- }
- if (msg)
- {
- DialogManagerType::showAlert(msg);
- return 0;
- }
- return 1;
- }
- static int
- dialogSetup (Dialog *me, const char *which, const char *defaultAns)
- {
- const char *ans = getManager(me)->getDefaultScript()->get(which);
- if (!ans)
- ans = getManager(me)->getAdminScript()->get(which);
- if (!ans)
- ans = getManager(me)->getBaseScript()->get(which);
-
- int status;
- if (ans == NULL)
- status = 0;
- else
- status = 1;
- /*
- int status = (int)ans; // 0 - there was already a value in the script
- // not zero - no value already in script
- */
- if (ans)
- me->setDefaultAns(ans);
- else if (defaultAns)
- me->setDefaultAns(defaultAns);
- return status;
- }
- DialogInput askSlapdPort(
- "The standard directory server network port number is 389. However, if\n"
- "you are not logged as the superuser, or port 389 is in use, the\n"
- "default value will be a random unused port number greater than 1024.\n"
- "If you want to use port 389, make sure that you are logged in as the\n"
- "superuser, that port 389 is not in use, and that you run the admin\n"
- "server as the superuser.\n",
- "Directory server network port",
- NULL,
- askSlapdPortSetup,
- askSlapdPortNext
- );
- static DialogAction
- askSlapdPortSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askSlapdPortSetup" << endl;
- #endif
- char tmp[10];
- int port = 389;
- const char *defPort =
- getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_PORT);
- if (defPort && *defPort && atoi(defPort) > 0)
- {
- PL_strncpyz(tmp, defPort, sizeof(tmp));
- port = atoi(defPort);
- }
- else
- PR_snprintf(tmp, sizeof(tmp), "%d", port);
- // see if default port is available
- if (InstUtil::portAvailable(port) == False)
- {
- // start with a random port number, and keep going until we find
- // an available port
- int origport = port = InstUtil::guessPort();
- while (InstUtil::portAvailable(port) == False)
- {
- ++port;
- if (port > MAXPORT)
- port = MINPORT;
- if (port == origport)
- {
- port = -1; // NO AVAILABLE PORTS!!!!!!!
- break;
- }
- }
- }
- if (port == -1) // NO AVAILABLE PORTS!!!!!!!
- {
- #if DEBUG > 1
- cerr << "Leaving askSlapdPortSetup DIALOG_ERROR" << endl;
- #endif
- return DIALOG_ERROR;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_PORT, (long)port);
- dialogSetup(me, SLAPD_KEY_SERVER_PORT, tmp);
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askSlapdPortSetup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- #if DEBUG > 1
- cerr << "Leaving askSlapdPortSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askSlapdPortNext(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askSlapdPortNext" << endl;
- #endif
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int port, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_PORT, tmp);
- port = atoi(tmp);
- PR_snprintf(testbuf, sizeof(testbuf), "%d", port);
- if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "OVERFLOW ERROR: Unable to bind to port %d\n"
- "Please choose another port between 1 and %d.\n\n",
- port, MAXPORT);
- err = -1;
- }
- else if (InstUtil::portAvailable(port) == False)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "ERROR: Unable to bind to port %d\n"
- "Please choose another port.\n\n", port);
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- #if DEBUG > 1
- cerr << "Leaving askSlapdPortNext" << endl;
- #endif
- return DIALOG_NEXT;
- }
- DialogInput askSlapdServerID(
- "Each instance of a directory server requires a unique identifier.\n"
- "Press Enter to accept the default, or type in another name and press\n"
- "Enter.\n",
- "Directory server identifier",
- NULL,
- askSlapdServerIDSetup,
- askSlapdServerIDNext
- );
- static DialogAction
- askSlapdServerIDSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askSlapdServerIDSetup" << endl;
- #endif
- // extract the hostname part of the FQDN
- const char *tmp = 0;
- char *basehost = 0;
- if ((tmp = getManager(me)->getBaseScript()->get(SLAPD_KEY_FULL_MACHINE_NAME))) {
- basehost = strdup(tmp);
- } else {
- basehost = strdup(InstUtil::guessHostname());
- }
- if (!basehost)
- return DIALOG_ERROR;
- char *ptr = strchr(basehost, '.');
- if (ptr)
- {
- *ptr = 0;
- }
- else
- {
- free(basehost);
- basehost = 0;
- }
- const char *ans =
- getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_IDENTIFIER);
- if (!ans && basehost)
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER,
- basehost);
- else if (!ans && !basehost)
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER,
- InstUtil::guessHostname());
- if (ans)
- {
- me->setDefaultAns(ans);
- }
- else if (basehost)
- {
- me->setDefaultAns(basehost);
- }
- else
- {
- me->setDefaultAns(InstUtil::guessHostname());
- }
- if (basehost)
- free(basehost);
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askSlapdServerIDSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_NEXT;
- }
- #if DEBUG > 1
- cerr << "Leaving askSlapdServerIDSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askSlapdServerIDNext(Dialog *me)
- {
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- if (!tmp)
- {
- err = -1;
- PR_snprintf(testbuf, sizeof(testbuf), "The name must not be empty");
- }
- else if (!isValid(tmp))
- {
- err = -1;
- PR_snprintf(testbuf, sizeof(testbuf), "Please specify a valid value for the name.");
- }
- else if (contains8BitChars(tmp))
- {
- err = -1;
- PR_snprintf(testbuf, sizeof(testbuf), "The server ID must contain 7 bit ascii only.");
- }
- else if (!isValidServerID(tmp))
- {
- err = -1;
- PR_snprintf(testbuf, sizeof(testbuf), "The server ID must be a valid filename and DN component.");
- }
- if (!err)
- {
- // see if an instance by the same name already exists
- NSString instanceDir = NSString(
- getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ROOT)
- ) + "/slapd-" + tmp;
- if (InstUtil::fileExists(instanceDir))
- {
- PR_snprintf(testbuf, sizeof(testbuf), "ERROR: a server instance named [%s] already exists."
- " Please choose a unique name.\n", tmp);
- err = -1;
- }
- }
- if (tmp)
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SERVER_IDENTIFIER, tmp);
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askMCAdminID(
- "Please enter the administrator ID for the Fedora configuration\n"
- "directory server. This is the ID typically used to log in to the\n"
- "console. You will also be prompted for the password.\n",
- "Fedora configuration directory server\nadministrator ID",
- "admin",
- askMCAdminIDSetup,
- askMCAdminIDNext
- );
- static DialogAction
- askMCAdminIDSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askMCAdminIDSetup" << endl;
- #endif
- if (getManager(me)->getAdminScript() &&
- getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_ID) &&
- getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_PWD))
- {
- // see if the MC Admin ID has been provided
- if (getManager(me)->getBaseScript() &&
- !(getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) &&
- getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_PWD)))
- {
- getManager(me)->getBaseScript()->set(
- SLAPD_KEY_SERVER_ADMIN_ID,
- getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_ID)
- );
- getManager(me)->getBaseScript()->set(
- SLAPD_KEY_SERVER_ADMIN_PWD,
- getManager(me)->getAdminScript()->get(SLAPD_KEY_ADMIN_SERVER_PWD)
- );
- }
- }
- dialogSetup(me, SLAPD_KEY_SERVER_ADMIN_ID, "admin");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askMCAdminIDSetup setup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- // this dialog is only used for creating the MC Admin; don't use it if
- // we will be using an existing MC i.e. we are not creating the MC host
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- {
- #if DEBUG > 1
- cerr << "Leaving askMCAdminIDSetup DIALOG_NEXT" << endl;
- #endif
- return action;
- }
- #if DEBUG > 1
- cerr << "Leaving askMCAdminIDSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askMCAdminIDNext(Dialog *me)
- {
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askMCAdminIDNext setup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- const char *adminUser;
- const char *adminPwd;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- adminUser = me->defaultAns();
- }
- else
- {
- adminUser = buf;
- }
- if (!isValid(adminUser))
- {
- DialogManagerType::showAlert("Please enter a valid ID.");
- return DIALOG_SAME;
- }
- else if (!isAValidDN(adminUser) && contains8BitChars(adminUser))
- {
- DialogManagerType::showAlert("The user ID value must be 7 bit ASCII only.");
- return DIALOG_SAME;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, adminUser);
- while (1)
- {
- // cerr << "before password in askMCAdminIDNext" << endl;
- me->showString("Password: ");
- // cerr << "after password in askMCAdminIDNext" << endl;
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- continue;
- }
- else if (contains8BitChars(inp))
- {
- DialogManagerType::showAlert("Password must contain 7 bit characters only.");
- return DIALOG_SAME;
- }
- else if (!isValid(inp))
- {
- DialogManagerType::showAlert("Please enter a valid password.");
- return DIALOG_SAME;
- }
- else
- {
- me->showString("Password (again): ");
- if (me->getPassword() == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- adminPwd = me->input();
- if (strcmp(inp,adminPwd))
- {
- DialogManagerType::showAlert("Passwords don't match.");
- return DIALOG_SAME;
- }
- break;
- }
- }
- free(inp);
- }
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, adminPwd);
- return DIALOG_NEXT;
- }
- DialogInput askSlapdSuffix(
- "The suffix is the root of your directory tree. You may have more than\n"
- "one suffix.\n",
- "Suffix",
- NULL,
- askSlapdSuffixSetup,
- askSlapdSuffixNext
- );
- static DialogAction
- askSlapdSuffixSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return action;
- if (!getManager(me)->getDefaultScript()->get(SLAPD_KEY_SUFFIX)) {
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_SUFFIX, getManager(me)->getDefaultSuffix());
- }
- dialogSetup(me, SLAPD_KEY_SUFFIX, getManager(me)->getDefaultSuffix());
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSlapdSuffixNext(Dialog *me)
- {
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SUFFIX, val);
- // check the value to see if it is a valid DN
- if (!isAValidDN(val))
- {
- DialogManagerType::showAlert("A suffix must be a valid DN.");
- return DIALOG_SAME;
- }
- else if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askSlapdRootDN(
- "Certain directory server operations require an administrative user.\n"
- "This user is referred to as the Directory Manager and typically has a\n"
- "bind Distinguished Name (DN) of cn=Directory Manager. Press Enter to\n"
- "accept the default value, or enter another DN. In either case, you\n"
- "will be prompted for the password for this user. The password must\n"
- "be at least 8 characters long.\n",
- "Directory Manager DN",
- DEFAULT_SLAPDUSER,
- askSlapdRootDNSetup,
- askSlapdRootDNNext
- );
- static DialogAction
- askSlapdRootDNSetup(Dialog *me)
- {
- if (!getManager(me)->getDefaultScript()->get(SLAPD_KEY_ROOTDN))
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDN,
- DEFAULT_SLAPDUSER);
- dialogSetup(me, SLAPD_KEY_ROOTDN, DEFAULT_SLAPDUSER);
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSlapdRootDNNext(Dialog *me)
- {
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askSlapdRootDNNext setup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- const char *slapdUser;
- const char *slapdPwd;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- slapdUser = me->defaultAns();
- }
- else
- {
- slapdUser = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDN, slapdUser);
- // check the value to see if it is a valid DN
- if (!isAValidDN(slapdUser))
- {
- DialogManagerType::showAlert("The Directory Manager must be a valid DN.");
- return DIALOG_SAME;
- }
- else if (!isValid(slapdUser))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- // cerr << "before password in askSlapdRootDNNext" << endl;
- me->showString("Password: ");
- // cerr << "after password in askSlapdRootDNNext" << endl;
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- continue;
- }
- else if (contains8BitChars(inp))
- {
- DialogManagerType::showAlert("Password must contain 7 bit characters only.");
- return DIALOG_SAME;
- }
- else if (!isValid(inp))
- {
- DialogManagerType::showAlert("Please enter a valid password.");
- return DIALOG_SAME;
- }
- else
- {
- me->showString("Password (again): ");
- if (me->getPassword() == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- slapdPwd = me->input();
- if (strcmp(inp,slapdPwd))
- {
- DialogManagerType::showAlert("Passwords don't match.");
- return DIALOG_SAME;
- }
- else if (!rootDNPwdIsValid(inp))
- {
- DialogManagerType::showAlert("Password must be at least 8 characters long");
- return DIALOG_SAME;
- }
- break;
- }
- }
- free(inp);
- }
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ROOTDNPWD, slapdPwd);
- return DIALOG_NEXT;
- }
- DialogYesNo askSample(
- "You may install some sample entries in this directory instance. These\n"
- "entries will be installed in a separate suffix and will not interfere\n"
- "with the normal operation of the directory server.\n",
- "Do you want to install the sample entries?",
- "No",
- askSampleSetup,
- askSampleNext
- );
- static DialogAction
- askSampleSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSampleNext(Dialog *me)
- {
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_SAMPLE_ENTRIES, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- return DIALOG_NEXT;
- }
- DialogInput askPopulate(
- "You may wish to populate your new directory instance with some data.\n"
- "You may already have a file in LDIF format to use or some suggested\n"
- "entries can be added. If you want to import entries from an LDIF\n"
- "file, you may type in the full path and filename at the prompt. If\n"
- "you want the install program to add the suggested entries, type the\n"
- "word suggest at the prompt. The suggested entries are common\n"
- "container entries under your specified suffix, such as ou=People and\n"
- "ou=Groups, which are commonly used to hold the entries for the persons\n"
- "and groups in your organization. If you do not want to add any of\n"
- "these entries, type the word none at the prompt.\n",
- "Type the full path and filename, the word suggest, or the word none\n",
- "none",
- askPopulateSetup,
- askPopulateNext
- );
- static DialogAction
- askPopulateSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER))
- return action;
- // if setting up a UG host, by default setup the suggested entries
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_INSTALL_LDIF_FILE,
- "suggest");
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES,
- "Yes");
- }
- dialogSetup(me, SLAPD_KEY_INSTALL_LDIF_FILE, "none");
- // max input buffer size is sizeof(Dialog::_buf)-1
- // Dialog::_buf is defined as char[MED_BUF]
- me->setInputLen(MED_BUF-1); // it seems to get reset somewhere . . .
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askPopulateNext(Dialog *me)
- {
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER))
- return DIALOG_NEXT;
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- if (buf && !strncasecmp(buf, "none", strlen(buf)))
- {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES, "No");
- getManager(me)->getDefaultScript()->
- set(SLAPD_KEY_INSTALL_LDIF_FILE, "none");
- }
- else if (buf && !strncasecmp(buf, "suggest", strlen(buf)))
- {
- getManager(me)->getDefaultScript()->
- set(SLAPD_KEY_INSTALL_LDIF_FILE, "suggest");
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ADD_ORG_ENTRIES, "Yes");
- } else {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_INSTALL_LDIF_FILE, buf);
- if (!InstUtil::fileExists(buf))
- {
- NSString msg = NSString("The specified filename ") + buf + "\n" +
- "does not exist. Please try again.\n";
- DialogManagerType::showAlert(msg);
- return DIALOG_SAME;
- }
- else
- {
- getManager(me)->getDefaultScript()->
- set(SLAPD_KEY_ADD_ORG_ENTRIES, "Yes");
- getManager(me)->getDefaultScript()->
- set(SLAPD_KEY_INSTALL_LDIF_FILE, buf);
- }
- }
- return DIALOG_NEXT;
- }
- DialogInput askOrgSize(
- "Your directory will be populated with entries based on the size of\n"
- "your organization. The choices are small or large. Please specify 1\n"
- "for small and 2 for large.\n",
- "Organization size (1 or 2)",
- "1",
- askOrgSizeSetup,
- askOrgSizeNext
- );
- static DialogAction
- askOrgSizeSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER))
- return action;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_ADD_ORG_ENTRIES))
- return action;
- else if (dialogSetup(me, SLAPD_KEY_ORG_SIZE, "1") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askOrgSizeNext(Dialog *me)
- {
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER))
- return DIALOG_NEXT;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_ADD_ORG_ENTRIES))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int num, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_ORG_SIZE, tmp);
- num = atoi(tmp);
- if (num != 1 && num != 2)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "Please enter a 1 or a 2\n\n");
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askReplication(
- "Replication is used to duplicate all or part of a directory server to\n"
- "another directory server. This can be used for failsafe purposes, to\n"
- "ensure that the directory data is always online and up-to-date in case\n"
- "one server goes down. It is also useful for distributing directory\n"
- "data from a central main repository to remote directory servers.\n",
- "Do you want to configure this directory server\nto use replication?",
- "No",
- askReplicationSetup,
- askReplicationNext
- );
- static DialogAction
- askReplicationSetup(Dialog *me)
- {
- me = me;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askReplicationNext(Dialog *me)
- {
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_REPLICATION, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION))
- {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_SUPPLIER, "No");
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_CONSUMER, "No");
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askCIR(
- "You may want to set up your directory server as a consumer server to\n"
- "receive replicated entries from another directory server. The first\n"
- "two of the following methods configure this server as a consumer:\n\n"
- "1) The supplier server will push its entries to this server (SIR)\n"
- "2) This server will pull the entries from the supplier (CIR)\n"
- "3) This server will not be a consumer for replication (NONE)\n",
- "Do you want to set up this server as a consumer\n"
- "for replication? (1, 2, or 3)",
- "3",
- askCIRSetup,
- askCIRNext
- );
- static DialogAction
- askCIRSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION))
- return DIALOG_NEXT;
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "3";
- }
- int val = atoi(buf);
- if (!val || val < 1 || val > 3)
- {
- DialogManagerType::showAlert("Please enter a 1, 2, or 3.");
- return DIALOG_SAME;
- }
- else if (val == 3)
- {
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_CONSUMER, buf);
- return DIALOG_NEXT;
- }
- DialogYesNo askSIR(
- "You may want to set up your directory server as a supplier server to\n"
- "replicate its entries to another directory server. The first two of\n"
- "the following methods configure this server as a supplier:\n\n"
- "1) This server will push its entries to another one (SIR)\n"
- "2) Another server will pull entries from this one (CIR)\n"
- "3) This server will not be a supplier for replication (NONE)\n",
- "Do you want to set up this server as a supplier\n"
- "for replication? (1, 2, or 3)",
- "3",
- askSIRSetup,
- askSIRNext
- );
- static DialogAction
- askSIRSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_REPLICATION))
- return DIALOG_NEXT;
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "3";
- }
- int val = atoi(buf);
- if (!val || val < 1 || val > 3)
- {
- DialogManagerType::showAlert("Please enter a 1, 2, or 3.");
- return DIALOG_SAME;
- }
- else if (val == 3)
- {
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SETUP_SUPPLIER, buf);
- return DIALOG_NEXT;
- }
- DialogInput askCIRHost(
- "Please specify the host name of the server from which the replicated\n"
- "entries will be copied.\n",
- "Supplier host name",
- 0,
- askCIRHostSetup,
- askCIRHostNext
- );
- static DialogAction
- askCIRHostSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- else if (dialogSetup(me, SLAPD_KEY_CIR_HOST, 0) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRHostNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_HOST, tmp);
- if (!tmp || !isValid(tmp))
- {
- DialogManagerType::showAlert("Please enter a valid hostname");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askCIRPort(
- "Please specify the port of the server from which the replicated\n"
- "entries will be copied.\n",
- "Supplier port",
- "389",
- askCIRPortSetup,
- askCIRPortNext
- );
- static DialogAction
- askCIRPortSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- const char *defaultPort = "389";
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_CIR_SECURITY_ON))
- defaultPort = "636";
- if (dialogSetup(me, SLAPD_KEY_CIR_PORT, defaultPort) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRPortNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int port, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_PORT, tmp);
- port = atoi(tmp);
- PR_snprintf(testbuf, sizeof(testbuf), "%d", port);
- if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "OVERFLOW ERROR: Unable to bind to port %d\n"
- "Please choose another port between 1 and %d.\n\n",
- port, MAXPORT);
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askCIRDN(
- "Replication requires that this consumer has access to the portion of\n"
- "the remote directory to be replicated. This requires a bind DN and\n"
- "password for access to the supplier. You will first be asked for the\n"
- "bind DN, then the password.\n",
- "Replication DN",
- NULL,
- askCIRDNSetup,
- askCIRDNNext
- );
- static DialogAction
- askCIRDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_CIR_BINDDN, getManager(me)->getConsumerDN()) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRDNNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
- const char *slapdUser;
- char *slapdPwd = 0;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- slapdUser = me->defaultAns();
- }
- else
- {
- slapdUser = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_BINDDN, slapdUser);
- // check to see if it is a valid DN
- if (!isAValidDN(slapdUser))
- {
- DialogManagerType::showAlert("The consumer must be a valid DN.");
- return DIALOG_SAME;
- }
- else if (!isValid(slapdUser))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- free(inp);
- continue;
- }
- else
- {
- slapdPwd = inp;
- break;
- }
- }
- }
- if (slapdPwd)
- {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_BINDDNPWD, slapdPwd);
- free(slapdPwd);
- }
- return DIALOG_NEXT;
- }
- DialogInput askCIRSuffix(
- "Please enter the full DN of the part of the tree to replicate,\n"
- "including the suffix (e.g. ou=People, o=company.com).\n",
- "Enter the directory path",
- NULL,
- askCIRSuffixSetup,
- askCIRSuffixNext
- );
- static DialogAction
- askCIRSuffixSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
-
- if (dialogSetup(me, SLAPD_KEY_CIR_SUFFIX, getManager(me)->getDefaultSuffix()) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRSuffixNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
-
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_SUFFIX, val);
- // check val to see if it is a valid DN
- if (!isAValidDN(val))
- {
- DialogManagerType::showAlert("The suffix must be a valid DN.");
- return DIALOG_SAME;
- }
- if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- int status;
- if ((status = getManager(me)->verifyRemoteLdap(
- SLAPD_KEY_CIR_HOST,
- SLAPD_KEY_CIR_PORT,
- SLAPD_KEY_CIR_SUFFIX,
- SLAPD_KEY_CIR_BINDDN,
- SLAPD_KEY_CIR_BINDDNPWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not connect to ldap://"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_HOST)
- << ":"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_PORT)
- << "/"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_CIR_BINDDN)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The replication agreement will be created anyway. Proceeding..."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_NEXT;
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askCIRSSL(
- "You may use SSL authentication for replication if you have enabled it\n"
- "on the remote server.\n",
- "Do you want to use SSL?",
- "No",
- askCIRSSLSetup,
- askCIRSSLNext
- );
- static DialogAction
- askCIRSSLSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRSSLNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_SECURITY_ON, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- return DIALOG_NEXT;
- }
- DialogInput askCIRInterval(
- "Please specify the time interval to check the remote server for new\n"
- "entries to be replicated. Use the directory server console to set up\n"
- "more fine-grained control. Specify the time in minutes. Use a 0\n"
- "(zero) to indicate that changes should be propagated immediately all\n"
- "the time.\n",
- "Replication Sync Interval (in minutes)",
- "10",
- askCIRIntervalSetup,
- askCIRIntervalNext
- );
- static DialogAction
- askCIRIntervalSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_CIR_INTERVAL, "10") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRIntervalNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int interval, err = 0;
-
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
-
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_INTERVAL, tmp);
-
- interval = atoi(tmp);
- if (!isdigit((*tmp)) || interval < 0)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "Please specify an integer greater than or equal to 0");
- err = -1;
- }
-
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
-
- return DIALOG_NEXT;
- }
- DialogInput askChangeLogSuffix(
- "Changes to the database will be kept under a separate suffix in the\n"
- "directory tree. These changes are used to replicate changes to other\n"
- "directory servers.\n",
- "Changelog suffix",
- "cn=changelog",
- askChangeLogSuffixSetup,
- askChangeLogSuffixNext
- );
- static DialogAction
- askChangeLogSuffixSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER))
- return action;
-
- if (dialogSetup(me, SLAPD_KEY_CHANGELOGSUFFIX, "cn=changelog") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askChangeLogSuffixNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER))
- return DIALOG_NEXT;
-
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CHANGELOGSUFFIX, val);
- // check to see if val is a valid DN
- if (!isAValidDN(val))
- {
- DialogManagerType::showAlert("The ChangeLog suffix must be a valid DN");
- return DIALOG_SAME;
- }
- else if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askChangeLogDir(
- "Changes to the main database will be kept in a separate database\n"
- "stored in a separate directory path, usually under your server\n"
- "instance directory.\n",
- "Changelog database\n"
- "directory",
- NULL,
- askChangeLogDirSetup,
- askChangeLogDirNext
- );
- static DialogAction
- askChangeLogDirSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER))
- return action;
-
- NSString dir = NSString(
- getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ROOT)
- ) + "/slapd-" +
- getManager(me)->getDefaultScript()->get(SLAPD_KEY_SERVER_IDENTIFIER) +
- "/logs/changelogdb";
- if (dialogSetup(me, SLAPD_KEY_CHANGELOGDIR, dir) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askChangeLogDirNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER))
- return DIALOG_NEXT;
-
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CHANGELOGDIR, val);
- if (InstUtil::dirExists(val) && !InstUtil::dirWritable(val))
- {
- DialogManagerType::showAlert("You do not have access to that directory. Please try again.");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askReplicationDN(
- "In order to allow remote servers to replicate new entries to this\n"
- "server, the remote server must have the ability to bind to this server\n"
- "as some entity with permission to do so. The Supplier DN is the DN of\n"
- "the entity the remote server will use to connect to this server to\n"
- "supply updates. The Supplier DN also requires a password which you\n"
- "will be prompted for after the DN.\n",
- "Supplier Bind DN",
- "cn=supplier",
- askReplicationDNSetup,
- askReplicationDNNext
- );
- static DialogAction
- askReplicationDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "1"))
- return action;
-
- if (dialogSetup(me, SLAPD_KEY_REPLICATIONDN, "cn=supplier") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askReplicationDNNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "1"))
- return DIALOG_NEXT;
-
- const char *replicationdn;
- const char *replicationpw;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- replicationdn = me->defaultAns();
- }
- else
- {
- replicationdn = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_REPLICATIONDN, replicationdn);
- // check to see if it is a valid DN
- if (!isAValidDN(replicationdn))
- {
- DialogManagerType::showAlert("The Supplier Bind DN must be a valid DN");
- return DIALOG_SAME;
- }
- if (!isValid(replicationdn))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- continue;
- }
- else if (contains8BitChars(inp))
- {
- DialogManagerType::showAlert("Password must contain 7 bit characters only.");
- return DIALOG_SAME;
- }
- else if (!isValid(inp))
- {
- DialogManagerType::showAlert("Please enter a valid password.");
- return DIALOG_SAME;
- }
- else
- {
- me->showString("Password (again): ");
- if (me->getPassword() == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- replicationpw = me->input();
- if (strcmp(inp,replicationpw))
- {
- DialogManagerType::showAlert("Passwords don't match.");
- return DIALOG_SAME;
- }
- break;
- }
- }
- free(inp);
- }
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_REPLICATIONPWD, replicationpw);
- return DIALOG_NEXT;
- }
- DialogInput askConsumerDN(
- "In order to allow remote servers to replicate new entries from this\n"
- "server, the remote server must have the ability to bind to this server\n"
- "as some entity with permission to do so. The Consumer DN is the DN of\n"
- "the entity the remote server will use to connect to this server to\n"
- "pull the new entries. This entity will have access to the entire\n"
- "database as well as the changelog entries. The Consumer DN also\n"
- "requires a password which you will be prompted for after the DN. If\n"
- "you leave this entry blank, no consumer bind DN will be created. The\n"
- "default is no consumer bind DN.\n",
- "Consumer Bind DN",
- NULL,
- askConsumerDNSetup,
- askConsumerDNNext
- );
- static DialogAction
- askConsumerDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "2"))
- return action;
-
- if (dialogSetup(me, SLAPD_KEY_CONSUMERDN, 0) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askConsumerDNNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "2"))
- return DIALOG_NEXT;
-
- const char *consumerdn;
- const char *consumerpw;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- consumerdn = me->defaultAns();
- }
- else
- {
- consumerdn = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CONSUMERDN, consumerdn);
- if (!consumerdn || !*consumerdn ||
- !strncasecmp(consumerdn, "none", strlen(consumerdn)))
- {
- getManager(me)->getDefaultScript()->remove(SLAPD_KEY_CONSUMERDN);
- return DIALOG_NEXT;
- }
- // check to see if it is a valid dn
- if (!isAValidDN(consumerdn))
- {
- DialogManagerType::showAlert("The Consumer Bind DN must be a valid DN");
- return DIALOG_SAME;
- }
- else if (!isValid(consumerdn))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- continue;
- }
- else if (contains8BitChars(inp))
- {
- DialogManagerType::showAlert("Password must contain 7 bit characters only.");
- return DIALOG_SAME;
- }
- else if (!isValid(inp))
- {
- DialogManagerType::showAlert("Please enter a valid password.");
- return DIALOG_SAME;
- }
- else
- {
- me->showString("Password (again): ");
- if (me->getPassword() == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- consumerpw = me->input();
- if (strcmp(inp,consumerpw))
- {
- DialogManagerType::showAlert("Passwords don't match.");
- return DIALOG_SAME;
- }
- break;
- }
- }
- free(inp);
- }
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CONSUMERPWD, consumerpw);
- return DIALOG_NEXT;
- }
- DialogInput askSIRHost(
- "Please specify the host name of the server to which the replicated\n"
- "entries will be pushed.\n",
- "Consumer host name",
- 0,
- askSIRHostSetup,
- askSIRHostNext
- );
- static DialogAction
- askSIRHostSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- else if (dialogSetup(me, SLAPD_KEY_SIR_HOST, 0) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRHostNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_HOST, tmp);
- if (!tmp || !isValid(tmp))
- {
- DialogManagerType::showAlert("Please enter a valid hostname");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askSIRPort(
- "Please specify the port of the server to which the replicated entries\n"
- "will be pushed.\n",
- "Consumer port",
- "389",
- askSIRPortSetup,
- askSIRPortNext
- );
- static DialogAction
- askSIRPortSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- const char *defaultPort = "389";
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_SIR_SECURITY_ON))
- defaultPort = "636";
- if (dialogSetup(me, SLAPD_KEY_SIR_PORT, defaultPort) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRPortNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int port, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_PORT, tmp);
- port = atoi(tmp);
- PR_snprintf(testbuf, sizeof(testbuf), "%d", port);
- if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "OVERFLOW ERROR: Unable to bind to port %d\n"
- "Please choose another port between 1 and %d.\n\n",
- port, MAXPORT);
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askSIRDN(
- "Replication requires that this supplier has access to the portion of\n"
- "the remote directory to be replicated. This requires a bind DN and\n"
- "password for access to the consumer. You will first be asked for the\n"
- "bind DN, then the password. This is the same as the Supplier DN on\n"
- "the consumer.\n",
- "Replication DN on the Consumer",
- "cn=supplier",
- askSIRDNSetup,
- askSIRDNNext
- );
- static DialogAction
- askSIRDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_SIR_BINDDN, "cn=supplier") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRDNNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
- const char *slapdUser;
- char *slapdPwd = 0;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- slapdUser = me->defaultAns();
- }
- else
- {
- slapdUser = buf;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_BINDDN, slapdUser);
- // check to see if it is a valid dn
- if (!isAValidDN(slapdUser))
- {
- DialogManagerType::showAlert("The Consumer Replication DN must be a valid DN");
- return DIALOG_SAME;
- }
- else if (!isValid(slapdUser))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- free(inp);
- continue;
- }
- else
- {
- slapdPwd = inp;
- break;
- }
- }
- }
- if (slapdPwd)
- {
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_BINDDNPWD, slapdPwd);
- free(slapdPwd);
- }
- return DIALOG_NEXT;
- }
- DialogInput askSIRSuffix(
- "Please enter the full DN of the part of the tree to replicate,\n"
- "including the suffix (e.g. ou=People, o=company.com).\n",
- "Directory path (DN)",
- NULL,
- askSIRSuffixSetup,
- askSIRSuffixNext
- );
- static DialogAction
- askSIRSuffixSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_SIR_SUFFIX, getManager(me)->getDefaultSuffix()) &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRSuffixNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_SUFFIX, val);
- // check to see if it is a valid dn
- if (!isAValidDN(val))
- {
- DialogManagerType::showAlert("The suffix must be a valid DN");
- return DIALOG_SAME;
- }
- else if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- int status;
- if ((status = getManager(me)->verifyRemoteLdap(
- SLAPD_KEY_SIR_HOST,
- SLAPD_KEY_SIR_PORT,
- SLAPD_KEY_SIR_SUFFIX,
- SLAPD_KEY_SIR_BINDDN,
- SLAPD_KEY_SIR_BINDDNPWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not connect to ldap://"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_HOST)
- << ":"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_PORT)
- << "/"
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_BINDDN)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The replication agreement will be created anyway. Proceeding..."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_NEXT;
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askSIRSSL(
- "You may use SSL authentication for replication if you have enabled it\n"
- "on the remote server.\n",
- "Do you want to use SSL?",
- "No",
- askSIRSSLSetup,
- askSIRSSLNext
- );
- static DialogAction
- askSIRSSLSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRSSLNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_SECURITY_ON, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- return DIALOG_NEXT;
- }
- DialogInput askCIRDays(
- "Please enter the days of the week on which you would like replication\n"
- "to occur. The days are specified by a number. For example, use 0 for\n"
- "Sunday, 1 for Monday, etc. Use 6 for Saturday. You may not specify a\n"
- "number greater than 6 or less than 0. The numbers should be entered\n"
- "one after another in a list. For example, 0123 would be Sunday,\n"
- "Monday, Tuesday, and Wednesday. 06 would be Sunday and Saturday. The\n"
- "default is everyday.\n",
- "Enter the replication days",
- "all",
- askCIRDaysSetup,
- askCIRDaysNext
- );
- static DialogAction
- askCIRDaysSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_CIR_DAYS, "all") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- const char *tmp;
- if ((tmp = getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_DAYS)) &&
- !*tmp)
- me->setDefaultAns("all");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRDaysNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_DAYS, val);
- int status = 0;
- ostrstream msg;
- char realval[8] = "-------";
- if (!strncasecmp(val, "all", strlen(val)))
- strcpy(realval, ""); // default is everyday
- else
- {
- for (const char *ptr = val; *ptr; ++ptr)
- {
- if (!isdigit(*ptr))
- {
- msg << "The string [" << val << "] contains non-digit characters."
- << " Please re enter the string." << ends;
- status = 1;
- break;
- }
- int ival = (int)(*ptr) - (int)'0';
- if (ival > 6)
- {
- msg << "The string contains an invalid value [" << ival << "]."
- << " Please re enter the string." << ends;
- status = 2;
- break;
- }
- // this step makes sure we get the numbers in order with no duplicates
- realval[ival] = *ptr;
- }
- if (status)
- {
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- // realval now contains a string like
- // 0---4-6, but we really want 046
- int index = 0;
- for (char *p2 = realval; *p2; ++p2)
- {
- if (*p2 != '-')
- realval[index++] = *p2;
- }
- realval[index] = 0;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_DAYS, realval);
- return DIALOG_NEXT;
- }
- DialogInput askSIRDays(
- "Please enter the days of the week on which you would like replication\n"
- "to occur. The days are specified by a number. For example, use 0 for\n"
- "Sunday, 1 for Monday, etc. Use 6 for Saturday. You may not specify a\n"
- "number greater than 6 or less than 0. The numbers should be entered\n"
- "one after another in a list. For example, 0123 would be Sunday,\n"
- "Monday, Tuesday, and Wednesday. 06 would be Sunday and Saturday. The\n"
- "default is everyday.\n",
- "Enter the replication days",
- "all",
- askSIRDaysSetup,
- askSIRDaysNext
- );
- static DialogAction
- askSIRDaysSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_SIR_DAYS, "all") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- const char *tmp;
- if ((tmp = getManager(me)->getDefaultScript()->get(SLAPD_KEY_SIR_DAYS)) &&
- !*tmp)
- me->setDefaultAns("all");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRDaysNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_DAYS, val);
- int status = 0;
- ostrstream msg;
- char realval[8] = "-------";
- if (!strncasecmp(val, "all", strlen(val)))
- strcpy(realval, ""); // default is everyday
- else
- {
- for (const char *ptr = val; *ptr; ++ptr)
- {
- if (!isdigit(*ptr))
- {
- msg << "The string [" << val << "] contains non-digit characters."
- << " Please re enter the string." << ends;
- status = 1;
- break;
- }
- int ival = (int)(*ptr) - (int)'0';
- if (ival > 6)
- {
- msg << "The string contains an invalid value [" << ival << "]."
- << " Please re enter the string." << ends;
- status = 2;
- break;
- }
- // this step makes sure we get the numbers in order with no duplicates
- realval[ival] = *ptr;
- }
- if (status)
- {
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- // realval now contains a string like
- // 0---4-6, but we really want 046
- int index = 0;
- for (char *p2 = realval; *p2; ++p2)
- {
- if (*p2 != '-')
- realval[index++] = *p2;
- }
- realval[index] = 0;
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_DAYS, realval);
- return DIALOG_NEXT;
- }
- DialogInput askCIRTimes(
- "Please enter the time of day you would like replication to occur. The\n"
- "time is specified as a range in the form HHMM-HHMM in 24 hour time.\n"
- "HH represents the hour portion of the time, and MM the minutes.\n"
- "Numbers less than 10 should be preceeded by a 0. For example, to\n"
- "enable replication between 1 am and 4:30 am, specify 0100-0430. To\n"
- "specify 11 am to 9 pm, use 1100-2100. 12 am to 12:59 am is specified\n"
- "as 0000-0059. The default is all day.\n",
- "Enter the replication times",
- "all day",
- askCIRTimesSetup,
- askCIRTimesNext
- );
- static DialogAction
- askCIRTimesSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_CIR_TIMES, "all day") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askCIRTimesNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_CONSUMER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_CONSUMER), "2"))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- if (!strncasecmp(val, "all day", strlen(val)))
- {
- val = "";
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_CIR_TIMES, val);
- return DIALOG_NEXT;
- }
- int status = 0;
- ostrstream msg;
- int pos = 0;
- // format should be HHMM-HHMM
- int maxvals[9] = {0, 23, 0, 59, 0, 0, 23, 0, 59};
- char teststr[3]; // 2 digits plus \0
- int testindex = 0;
- for (const char *ptr = val; *ptr; ++ptr, ++pos)
- {
- // position 4 should contain the '-'
- if (pos == 4 && *ptr != '-')
- {
- msg << "The time specification [" << val << "] is invalid.\n"
- << "Please re enter the string." << ends;
- status = 1;
- break;
- }
- else if (pos == 4)
- continue;
- if (!isdigit(*ptr) && pos != 4)
- {
- msg << "The time specification [" << val << "] contains non-digit characters.\n"
- << "Please re enter the string." << ends;
- status = 2;
- break;
- }
- teststr[testindex++] = *ptr;
- if (pos == 1 || pos == 3 || pos == 6 || pos == 8)
- {
- teststr[testindex] = 0;
- testindex = 0;
- if (teststr[0] == '0')
- teststr[0] = ' ';
- int ival = atoi(teststr);
- if (ival > maxvals[pos])
- {
- msg << "The string contains an invalid value [" << ival << "].\n"
- << "Please re enter the string." << ends;
- status = 3;
- break;
- }
- }
- }
- if (pos != 9)
- {
- msg << "The string [" << val << "] is invalid.\n"
- << "Please re enter the string." << ends;
- status = 4;
- }
- if (status)
- {
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askSIRTimes(
- "Please enter the time of day you would like replication to occur. The\n"
- "time is specified as a range in the form HHMM-HHMM in 24 hour time.\n"
- "HH represents the hour portion of the time, and MM the minutes.\n"
- "Numbers less than 10 should be preceeded by a 0. For example, to\n"
- "enable replication between 1 am and 4:30 am, specify 0100-0430. To\n"
- "specify 11 am to 9 pm, use 1100-2100. 12 am to 12:59 am is specified\n"
- "as 0000-0059. The default is all day.\n",
- "Enter the replication times",
- "all day",
- askSIRTimesSetup,
- askSIRTimesNext
- );
- static DialogAction
- askSIRTimesSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return action;
- if (dialogSetup(me, SLAPD_KEY_SIR_TIMES, "all day") &&
- getManager(me)->installMode() == Silent)
- return DIALOG_ERROR;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askSIRTimesNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_SETUP_SUPPLIER) ||
- strcmp(getManager(me)->getDefaultScript()->get(SLAPD_KEY_SETUP_SUPPLIER), "1"))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- if (!strncasecmp(val, "all day", strlen(val)))
- {
- val = "";
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SIR_TIMES, val);
- return DIALOG_NEXT;
- }
- int status = 0;
- ostrstream msg;
- int pos = 0;
- // format should be HHMM-HHMM
- int maxvals[9] = {0, 23, 0, 59, 0, 0, 23, 0, 59};
- char teststr[3]; // 2 digits plus \0
- int testindex = 0;
- for (const char *ptr = val; *ptr; ++ptr, ++pos)
- {
- // position 4 should contain the '-'
- if (pos == 4 && *ptr != '-')
- {
- msg << "The time specification [" << val << "] is invalid.\n"
- << "Please re enter the string." << ends;
- status = 1;
- break;
- }
- else if (pos == 4)
- continue;
- if (!isdigit(*ptr) && pos != 4)
- {
- msg << "The time specification [" << val << "] contains non-digit characters.\n"
- << "Please re enter the string." << ends;
- status = 2;
- break;
- }
- teststr[testindex++] = *ptr;
- if (pos == 1 || pos == 3 || pos == 6 || pos == 8)
- {
- teststr[testindex] = 0;
- testindex = 0;
- if (teststr[0] == '0')
- teststr[0] = ' ';
- int ival = atoi(teststr);
- if (ival > maxvals[pos])
- {
- msg << "The string contains an invalid value [" << ival << "].\n"
- << "Please re enter the string." << ends;
- status = 3;
- break;
- }
- }
- }
- if (pos != 9)
- {
- msg << "The string [" << val << "] is invalid.\n"
- << "Please re enter the string." << ends;
- status = 4;
- }
- if (status)
- {
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askUseExistingMC(
- "Fedora server information is stored in the Fedora configuration\n"
- "directory server, which you may have already set up. If so, you\n"
- "should configure this server to be managed by the configuration\n"
- "server. To do so, the following information about the configuration\n"
- "server is required: the fully qualified host name of the form\n"
- "<hostname>.<domainname>(e.g. hostname.domain.com), the port number,\n"
- "the suffix, and the DN and password of a user having permission to\n"
- "write the configuration information, usually the Fedora\n"
- "configuration directory administrator.\n\n"
- "If you want to install this software as a standalone server, or if you\n"
- "want this instance to serve as your Fedora configuration directory\n"
- "server, press Enter.\n",
- "Do you want to register this software with an existing\n"
- "Fedora configuration directory server?",
- "No",
- askUseExistingMCSetup,
- askUseExistingMCNext
- );
- static DialogAction
- askUseExistingMCSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askUseExistingMCSetup" << endl;
- #endif
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (action != DIALOG_PREV)
- {
- if (getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL))
- {
- // tell the instance creator not to create the Config entries
- // new instance
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_USE_EXISTING_MC, "Yes");
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "No");
- }
- else
- {
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_USE_EXISTING_MC, "No");
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "Yes");
- }
- }
- dialogSetup(me, SLAPD_KEY_USE_EXISTING_MC, "No");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askUseExistingMCSetup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- #if DEBUG > 1
- cerr << "Leaving askUseExistingMCSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askUseExistingMCNext(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askUseExistingMCNext" << endl;
- #endif
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_EXISTING_MC, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- #if DEBUG > 1
- cerr << "Leaving askUseExistingMCNext" << endl;
- #endif
- return DIALOG_NEXT;
- }
- DialogInput askMCHost(
- "Enter the fully qualified domain name of the Fedora configuration\n"
- "directory server host in the form <hostname>.<domainname>\n"
- "(e.g. hostname.domain.com).\n",
- "Fedora configuration directory server\nhost name",
- 0,
- askMCHostSetup,
- askMCHostNext
- );
- static DialogAction
- askMCHostSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return action;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askMCHostNext(Dialog *me)
- {
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_K_LDAP_HOST, tmp);
- if (!tmp || !isValid(tmp))
- {
- DialogManagerType::showAlert("Please enter a valid hostname");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askMCPort(
- "Please specify the port number on which the Fedora configuration\n"
- "directory server listens.\n",
- "Fedora configuration directory server\nport number",
- "389",
- askMCPortSetup,
- askMCPortNext
- );
- static DialogAction
- askMCPortSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return action;
-
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askMCPortNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int port, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_K_LDAP_PORT, tmp);
- port = atoi(tmp);
- PR_snprintf(testbuf, sizeof(testbuf), "%d", port);
- if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "OVERFLOW ERROR: Unable to bind to port %d\n"
- "Please choose another port between 1 and %d.\n\n",
- port, MAXPORT);
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askMCDN(
- "To write configuration information into the Fedora configuration\n"
- "directory, you must bind to the server as an entity with the\n"
- "appropriate permissions. Usually, the Fedora configuration\n"
- "directory administrator is used for this purpose, although you can\n"
- "give other directory accounts the proper access.\n",
- "Fedora configuration directory server\nadministrator ID",
- 0,
- askMCDNSetup,
- askMCDNNext
- );
- static DialogAction
- askMCDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return action;
- dialogSetup(me, SLAPD_KEY_SERVER_ADMIN_ID, "admin");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askMCDNNext(Dialog *me)
- {
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
- const char *slapdUser;
- char *slapdPwd = 0;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- slapdUser = me->defaultAns();
- }
- else
- {
- slapdUser = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, slapdUser);
- if (!isValid(slapdUser))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- free(inp);
- continue;
- }
- else
- {
- slapdPwd = inp;
- break;
- }
- }
- }
- if (slapdPwd)
- {
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, slapdPwd);
- free(slapdPwd);
- int status;
- if ((status = getManager(me)->verifyRemoteLdap(
- SLAPD_KEY_K_LDAP_HOST,
- SLAPD_KEY_K_LDAP_PORT,
- SLAPD_KEY_BASE_SUFFIX,
- SLAPD_KEY_SERVER_ADMIN_ID,
- SLAPD_KEY_SERVER_ADMIN_PWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not connect to ldap://"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST)
- << ":"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT)
- << "/"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The installation cannot proceed."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- else if ((getManager(me)->installType() < Custom) &&
- (status = getManager(me)->verifyAdminDomain(
- SLAPD_KEY_K_LDAP_HOST,
- SLAPD_KEY_K_LDAP_PORT,
- SLAPD_KEY_BASE_SUFFIX,
- SLAPD_KEY_ADMIN_DOMAIN,
- SLAPD_KEY_SERVER_ADMIN_ID,
- SLAPD_KEY_SERVER_ADMIN_PWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not find the Admin Domain "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)
- << " in the server" << endl << "ldap://"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST)
- << ":"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT)
- << "/"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID)
- << " status = " << status << endl
- << "You may need to re-run setup in Custom mode in order to specify"
- << endl
- << "the correct Admin Domain."
- << endl
- << "The installation cannot proceed."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- }
- // tell the instance creator not to create the config entries in the
- // new instance
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_SLAPD_CONFIG_FOR_MC, "No");
- return DIALOG_NEXT;
- }
- DialogYesNo askDisableSchemaChecking(
- "If you are going to import an old database immediately after or during\n"
- "installation, and you think you may have problems with your old\n"
- "schema, you may want to turn off schema checking until after the\n"
- "import. If you choose to do this, schema checking will remain off\n"
- "until you manually turn it back on. Fedora recommends that you turn\n"
- "it back on as soon as possible.\n",
- "Do you want to disable schema checking?",
- "No",
- askDisableSchemaCheckingSetup,
- askDisableSchemaCheckingNext
- );
- static DialogAction
- askDisableSchemaCheckingSetup(Dialog *me)
- {
- me = me;
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askDisableSchemaCheckingNext(Dialog *me)
- {
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_DISABLE_SCHEMA_CHECKING, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- return DIALOG_NEXT;
- }
- DialogInput askMCAdminDomain(
- "The Administration Domain is a part of the configuration directory\n"
- "server used to store information about Fedora software. If you are\n"
- "managing multiple software releases at the same time, or managing\n"
- "information about multiple domains, you may use the Administration\n"
- "Domain to keep them separate.\n\n"
- "If you are not using administrative domains, press Enter to select the\n"
- "default. Otherwise, enter some descriptive, unique name for the\n"
- "administration domain, such as the name of the organization responsible\n"
- "for managing the domain.\n",
- "Administration Domain",
- NULL,
- askMCAdminDomainSetup,
- askMCAdminDomainNext
- );
- static DialogAction
- askMCAdminDomainSetup(Dialog *me)
- {
- if (!getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)) {
- getManager(me)->getBaseScript()->set(
- SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain());
- }
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- {
- #if DEBUG > 1
- cerr << "leaving askMCAdminDomainSetup " << action << endl;
- #endif
- return action;
- }
- // if we are creating the Configuration server, the admin domain will not
- // yet exist, and we need to ask the user to create one. Otherwise, we are
- // installing into an existing one
- dialogSetup(me, SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain());
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askMCAdminDomainNext(Dialog *me)
- {
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
- const char *buf;
- int status = 0;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getBaseScript()->set(SLAPD_KEY_ADMIN_DOMAIN, val);
- if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- else if (isAValidDN(val))
- {
- DialogManagerType::showAlert("A DN is not allowed here. Please enter a valid string.");
- return DIALOG_SAME;
- }
- else if ((status = getManager(me)->verifyAdminDomain(
- SLAPD_KEY_K_LDAP_HOST,
- SLAPD_KEY_K_LDAP_PORT,
- SLAPD_KEY_BASE_SUFFIX,
- SLAPD_KEY_ADMIN_DOMAIN,
- SLAPD_KEY_SERVER_ADMIN_ID,
- SLAPD_KEY_SERVER_ADMIN_PWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not find the Admin Domain "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)
- << " in the server" << endl << "ldap://"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_HOST)
- << ":"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_PORT)
- << "/"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_BASE_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The installation cannot proceed."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askAdminDomain(
- "The Administration Domain is a part of the configuration directory\n"
- "server used to store information about Fedora software. If you are\n"
- "managing multiple software releases at the same time, or managing\n"
- "information about multiple domains, you may use the Administration\n"
- "Domain to keep them separate.\n\n"
- "If you are not using administrative domains, press Enter to select the\n"
- "default. Otherwise, enter some descriptive, unique name for the\n"
- "administration domain, such as the name of the organization responsible\n"
- "for managing the domain.\n",
- "Administration Domain",
- NULL,
- askAdminDomainSetup,
- askAdminDomainNext
- );
- static DialogAction
- askAdminDomainSetup(Dialog *me)
- {
- if (!getManager(me)->getBaseScript()->get(SLAPD_KEY_ADMIN_DOMAIN)) {
- getManager(me)->getBaseScript()->set(
- SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain());
- }
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return action;
- // if we are creating the Configuration server, the admin domain will not
- // yet exist, and we need to ask the user to create one. Otherwise, we are
- // installing into an existing one
- dialogSetup(me, SLAPD_KEY_ADMIN_DOMAIN, getManager(me)->getDNSDomain());
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askAdminDomainNext(Dialog *me)
- {
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getBaseScript()->set(SLAPD_KEY_ADMIN_DOMAIN, val);
- if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- if (isAValidDN(val))
- {
- DialogManagerType::showAlert("A DN is not allowed here. Please enter a valid string.");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogYesNo askUseExistingUG(
- "If you already have a directory server you want to use to store your\n"
- "data, such as user and group information, answer Yes to the following\n"
- "question. You will be prompted for the host, port, suffix, and bind\n"
- "DN to use for that directory server.\n\n"
- "If you want this directory server to store your data, answer No.\n",
- "Do you want to use another directory to store your data?",
- "No",
- askUseExistingUGSetup,
- askUseExistingUGNext
- );
- static DialogAction
- askUseExistingUGSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askUseExistingUGSetup" << endl;
- #endif
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- // if this server is not an MC host, it must be a UG host
- if (getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_MC))
- {
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_USE_EXISTING_UG, "No");
- #if DEBUG > 1
- cerr << "Leaving askUseExistingUGSetup DIALOG_NEXT" << endl;
- #endif
- return action;
- }
- else if (getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_LDAP_URL))
- {
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_USE_EXISTING_UG, "Yes");
- }
- else
- {
- getManager(me)->getDefaultScript()->set(
- SLAPD_KEY_USE_EXISTING_UG, "No");
- }
- dialogSetup(me, SLAPD_KEY_USE_EXISTING_UG, "No");
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- {
- #if DEBUG > 1
- cerr << "Leaving askUseExistingUGSetup DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- #if DEBUG > 1
- cerr << "Leaving askUseExistingUGSetup DIALOG_SAME" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askUseExistingUGNext(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askUseExistingUGNext" << endl;
- #endif
- const char *buf = me->input();
- if (!buf || !*buf)
- {
- buf = me->defaultAns();
- if (!buf || !*buf)
- buf = "No";
- }
- getManager(me)->getDefaultScript()->set(SLAPD_KEY_USE_EXISTING_UG, buf);
- if (!isValidYesNo(buf))
- return DIALOG_SAME;
- #if DEBUG > 1
- cerr << "Leaving askUseExistingUGNext DIALOG_NEXT" << endl;
- #endif
- return DIALOG_NEXT;
- }
- DialogInput askUGHost(
- "Enter the fully qualified domain name of the user directory host of\n"
- "the form <hostname>.<domainname> (e.g. hostname.domain.com).\n",
- "User directory host name",
- 0,
- askUGHostSetup,
- askUGHostNext
- );
- static DialogAction
- askUGHostSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return action;
- dialogSetup(me, SLAPD_KEY_UG_HOST, 0);
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askUGHostNext(Dialog *me)
- {
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_HOST, tmp);
- if (!tmp || !isValid(tmp))
- {
- DialogManagerType::showAlert("Please enter a valid hostname");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askUGPort(
- "Please specify the port number on which the user directory listens.\n",
- "User directory port number",
- "389",
- askUGPortSetup,
- askUGPortNext
- );
- static DialogAction
- askUGPortSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return action;
-
- dialogSetup(me, SLAPD_KEY_UG_PORT, me->defaultAns());
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askUGPortNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return DIALOG_NEXT;
-
- const char *buf = me->input();
- const char *tmp;
- char testbuf[1024];
- int port, err = 0;
- if (buf[0] == 0)
- {
- tmp = me->defaultAns();
- }
- else
- {
- tmp = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_PORT, tmp);
- port = atoi(tmp);
- PR_snprintf(testbuf, sizeof(testbuf), "%d", port);
- if (strncmp(testbuf, tmp, 6) || port > MAXPORT || port < 1)
- {
- PR_snprintf(testbuf, sizeof(testbuf), "OVERFLOW ERROR: Unable to bind to port %d\n"
- "Please choose another port between 1 and %d.\n\n",
- port, MAXPORT);
- err = -1;
- }
- if (err)
- {
- DialogManagerType::showAlert(testbuf);
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askUGDN(
- "In order to add and modify information in the user directory, you must\n"
- "be able to bind to the server as an entity with the correct\n"
- "permissions. This user is usually the Directory Manager, although\n"
- "other users may be given the proper access. You will also be asked to\n"
- "provide the password.\n",
- "User directory administrator ID",
- 0,
- askUGDNSetup,
- askUGDNNext
- );
- static DialogAction
- askUGDNSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return action;
- dialogSetup(me, SLAPD_KEY_USER_GROUP_ADMIN_ID, DEFAULT_SLAPDUSER);
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askUGDNNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return DIALOG_NEXT;
- const char *slapdUser;
- char *slapdPwd = 0;
- const char *buf;
- buf = me->input();
- if (buf[0] == 0)
- {
- slapdUser = me->defaultAns();
- }
- else
- {
- slapdUser = buf;
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_USER_GROUP_ADMIN_ID, slapdUser);
- if (!isValid(slapdUser))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- while (1)
- {
- me->showString("Password: ");
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- free(inp);
- continue;
- }
- else
- {
- slapdPwd = inp;
- break;
- }
- }
- }
- if (slapdPwd)
- {
- getManager(me)->getBaseScript()->set(SLAPD_KEY_USER_GROUP_ADMIN_PWD, slapdPwd);
- free(slapdPwd);
- int status;
- if ((status = getManager(me)->verifyRemoteLdap(
- SLAPD_KEY_UG_HOST,
- SLAPD_KEY_UG_PORT,
- SLAPD_KEY_UG_SUFFIX,
- SLAPD_KEY_USER_GROUP_ADMIN_ID,
- SLAPD_KEY_USER_GROUP_ADMIN_PWD
- ))
- )
- {
- ostrstream msg;
- msg << "Could not connect to ldap://"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_HOST)
- << ":"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_PORT)
- << "/"
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_UG_SUFFIX)
- << endl << "for bind DN "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_ADMIN_ID)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The installation cannot proceed."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- }
- return DIALOG_NEXT;
- }
- DialogInput askUGSuffix(
- "Please specify the suffix for the user directory server.\n",
- "User directory server suffix",
- NULL,
- askUGSuffixSetup,
- askUGSuffixNext
- );
- static DialogAction
- askUGSuffixSetup(Dialog *me)
- {
- DialogAction action = DIALOG_NEXT;
- long actionval = 0;
- me->getUserData(ACTION, actionval);
- action = (DialogAction)actionval;
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return action;
- dialogSetup(me, SLAPD_KEY_UG_SUFFIX, getManager(me)->getDefaultSuffix());
- long setupval = 0;
- if (me->getUserData(SETUP_DEFAULTS, setupval) == SETUP_ONLY ||
- setupval == SETUP_ONLY)
- return DIALOG_NEXT;
- return DIALOG_SAME;
- }
- static DialogAction
- askUGSuffixNext(Dialog *me)
- {
- if (!getManager(me)->featureIsEnabled(SLAPD_KEY_USE_EXISTING_UG))
- return DIALOG_NEXT;
- const char *buf;
- NSString val;
- buf = me->input();
- if (buf[0] == 0)
- val = me->defaultAns();
- else
- val = buf;
- getManager(me)->getBaseScript()->set(SLAPD_KEY_UG_SUFFIX, val);
- // check to see if it is a valid dn
- if (!isAValidDN(val))
- {
- DialogManagerType::showAlert("The suffix must be a valid DN");
- return DIALOG_SAME;
- }
- if (!isValid(val))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- return DIALOG_NEXT;
- }
- DialogInput askReconfigMCAdminPwd(
- (const char*)0,
- "Fedora configuration directory server\nadministrator ID",
- (const char*)0,
- askReconfigMCAdminPwdSetup,
- askReconfigMCAdminPwdNext
- );
- static DialogAction
- askReconfigMCAdminPwdSetup(Dialog *me)
- {
- #if DEBUG > 1
- cerr << "Entering askReconfigMCAdminPwdSetup" << endl;
- #endif
- NSString msg = NSString(
- "In order to reconfigure your installation, the Configuration Directory\n"
- "Administrator password is required. Here is your current information:\n\n"
- "Configuration Directory: ") +
- getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL) + "\n" +
- "Configuration Administrator ID: " +
- getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID) + "\n" +
- "\nAt the prompt, please enter the password for the Configuration Administrator.\n";
- me->setText(msg);
- me->setDefaultAns(getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID));
- #if DEBUG > 1
- cerr << "Leaving askReconfigMCAdminPwdSetup" << endl;
- #endif
- return DIALOG_SAME;
- }
- static DialogAction
- askReconfigMCAdminPwdNext(Dialog *me)
- {
- const char *buf;
- buf = me->input();
- if (!buf || buf[0] == 0)
- {
- buf = me->defaultAns();
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_ID, buf);
- if (!isValid(buf))
- {
- DialogManagerType::showAlert("Please enter a valid string.");
- return DIALOG_SAME;
- }
- me->showString("Password: ");
- while (1)
- {
- if (me->getPassword () == 0)
- {
- return DIALOG_PREV;
- }
- else
- {
- char *inp = strdup(me->input());
- if (inp[0] == 0)
- {
- me->showString("Password: ");
- continue;
- }
- else if (contains8BitChars(inp))
- {
- DialogManagerType::showAlert("Password must contain 7 bit characters only.");
- return DIALOG_SAME;
- }
- else if (!isValid(inp))
- {
- DialogManagerType::showAlert("Please enter a valid password.");
- return DIALOG_SAME;
- }
- else
- {
- int status;
- if ((status = authLdapUser(
- getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL),
- getManager(me)->getBaseScript()->get(SLAPD_KEY_SERVER_ADMIN_ID),
- inp, 0, 0)))
- {
- ostrstream msg;
- msg << "Could not connect to "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_K_LDAP_URL)
- << endl << "for ID "
- << getManager(me)->getBaseScript()->get(SLAPD_KEY_USER_GROUP_ADMIN_ID)
- << " status = " << status << endl
- << "Please check your typing. If you have mis-typed, you can backup"
- << endl
- << "and retype. Otherwise, the remote server may be down at this time."
- << endl
- << "The reconfiguration cannot proceed."
- << endl << ends;
- DialogManagerType::showAlert(msg.str());
- delete [] msg.str();
- return DIALOG_SAME;
- }
- }
- getManager(me)->getBaseScript()->set(SLAPD_KEY_SERVER_ADMIN_PWD, inp);
- free(inp);
- break;
- }
- }
- return DIALOG_NEXT;
- }
|