| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339 |
- /** 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;
- }
- DialogYesNo 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");
- me->setInputLen(1024); // 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;
- }
|