winnt-dont-do-unneeded-version-check-20010918
[openafs.git] / src / WINNT / afssvrcfg / afscfg.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * INCLUDES _________________________________________________________________
12  *
13  */
14
15 extern "C" {
16 #include <afs/param.h>
17 #include <afs/stds.h>
18 }
19
20 #include "afscfg.h"
21 #include "resource.h"
22 #include "graphics.h"
23 #include <string.h>
24 #include "get_cur_config.h"
25 #include "partition_utils.h"
26 extern "C" {
27 #include <afs\dirpath.h>
28 #include <afs\afs_clientAdmin.h>
29 }
30
31
32 /*
33  * DEFINITIONS _________________________________________________________________
34  *
35  */
36
37
38 /*
39  * PROTOTYPES _________________________________________________________________
40  *
41  */
42 static void SetConfigDefaults();
43 static void RunCfgTool();
44 static void RunWizard();
45 static void CloseLibHandles(BOOL bExiting = FALSE);
46
47 void RegisterWizardHelp();
48 void RegisterConfigToolHelp();
49
50 // These are the prototypes for the dialog procs of each wizard page.
51 BOOL CALLBACK IntroPageDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
52 BOOL CALLBACK InfoPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
53 BOOL CALLBACK InfoPage2DlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
54 BOOL CALLBACK FileServerPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
55 BOOL CALLBACK DBServerPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
56 BOOL CALLBACK BackupPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
57 BOOL CALLBACK PartitionPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
58 BOOL CALLBACK RootAfsPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
59 BOOL CALLBACK ReplicationPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
60 BOOL CALLBACK SysControlPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
61 BOOL CALLBACK ConfigServerPageDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp);
62
63
64 static WIZARD_STATE g_aStates[] = {
65     { sidSTEP_ONE,              IDD_INTRO_PAGE,                                 (DLGPROC)IntroPageDlgProc, 0 },
66     { sidSTEP_TWO,              IDD_INFO_PAGE,                                  (DLGPROC)InfoPageDlgProc, 0 },
67     { sidSTEP_THREE,    IDD_INFO_PAGE2_FIRST_SERVER,    (DLGPROC)InfoPage2DlgProc, 0 },
68         { sidSTEP_FOUR,         IDD_INFO_PAGE2_NOT_FIRST_SERVER,(DLGPROC)InfoPage2DlgProc, 0 },
69     { sidSTEP_FIVE,             IDD_FILE_SERVER_PAGE,                   (DLGPROC)FileServerPageDlgProc, 0 },
70     { sidSTEP_SIX,              IDD_DB_SERVER_PAGE,                             (DLGPROC)DBServerPageDlgProc, 0 },
71         { sidSTEP_SEVEN,        IDD_BACKUP_SERVER_PAGE,                 (DLGPROC)BackupPageDlgProc, 0 },
72     { sidSTEP_EIGHT,    IDD_PARTITION_PAGE,                             (DLGPROC)PartitionPageDlgProc, 0 },
73         { sidSTEP_NINE,         IDD_ROOT_VOLUMES_PAGE,                  (DLGPROC)RootAfsPageDlgProc, 0 },
74         { sidSTEP_TEN,          IDD_REPLICATION_PAGE,                   (DLGPROC)ReplicationPageDlgProc, 0 },
75         { sidSTEP_ELEVEN,       IDD_SYS_CONTROL_PAGE,                   (DLGPROC)SysControlPageDlgProc, 0 },
76         { sidSTEP_TWELVE,       IDD_CONFIG_SERVER_PAGE,                 (DLGPROC)ConfigServerPageDlgProc, 0 }
77 };
78
79 size_t g_nNumStates = sizeof(g_aStates) / sizeof(g_aStates[0]);
80
81
82 // Res ID's of text descriptions of each state
83 UINT g_StateDesc[] = {
84         IDS_INTRO_PAGE,
85         IDS_INFO_PAGE,
86         IDS_INFO_PAGE2,
87         IDS_INFO_PAGE2,
88         IDS_FS_PAGE,
89         IDS_DB_PAGE,
90         IDS_BK_PAGE,
91         IDS_PARTITION_PAGE,
92         IDS_ROOT_AFS_PAGE,
93         IDS_REP_PAGE,
94         IDS_SC_PAGE,
95         IDS_CONFIG_PAGE
96 };
97
98
99
100 /*
101  * EXPORTED VARIABLES _________________________________________________________________
102  *
103  */
104 LPWIZARD g_pWiz = NULL;
105 LPPROPSHEET g_pSheet = NULL;
106
107 CFG_DATA g_CfgData;
108
109 void *g_hToken = 0;
110 void *g_hCell = 0;
111 void *g_hClient = 0;
112 void *g_hServer = 0;
113
114 static void *hClientCell = 0;
115
116 LOGFILE g_LogFile;
117
118
119
120 /*
121  * EXPORTED FUNCTIONS _________________________________________________________________
122  *
123  */
124 int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pszCmdLineA, int nCmdShow)
125 {
126         afs_status_t nStatus;
127
128         TaLocale_LoadCorrespondingModule (hInst);
129
130         // Tell the applib our application's name
131         TCHAR szAppName[cchRESOURCE];
132         AfsAppLib_SetAppName(GetResString(GetAppTitleID(), szAppName));
133
134         // Open the admin libraries
135         int nResult = afsclient_Init(&nStatus);
136         if (!nResult) {
137                 ShowError(0, nStatus, IDS_CANT_INIT_ADMIN_LIBS);
138                 return 0;
139         }
140
141         // Open the log file
142         char szLogPath[MAX_PATH];
143         sprintf(szLogPath, "%s\\%s", AFSDIR_SERVER_LOGS_DIRPATH, LOG_FILE_NAME);
144         if (!g_LogFile.Open(szLogPath))
145                 ShowError(0, 0, IDS_CANT_OPEN_LOG_FILE);
146
147         // Register the help file with the applib's help system
148         AfsAppLib_RegisterHelpFile(TEXT("TaAfsCfg.hlp"));
149
150     /* Start up sockets */
151     WSADATA WSAjunk;
152     WSAStartup(0x0101, &WSAjunk);
153
154         memset(&g_CfgData, 0, sizeof(CFG_DATA));
155
156         // Get this machine's local name
157         char szLocalName[sizeof(g_CfgData.szLocalName) / sizeof(TCHAR)];
158     if (gethostname(szLocalName, sizeof(szLocalName)) != 0) {
159                 ShowError(GetFocus(), WSAGetLastError(), IDS_ERROR_LOCAL_HOST_NAME);
160                 return 0;
161         }
162     CopyAnsiToString(g_CfgData.szLocalName, szLocalName);
163
164         // Turn the local name into a host name
165     struct hostent *pHostEnt = gethostbyname(szLocalName);
166     if (!pHostEnt) {
167                 ShowError(GetFocus(), WSAGetLastError(), IDS_ERROR_HOST_NAME);
168                 return 0;
169         }
170     CopyAnsiToString(g_CfgData.szHostname, pHostEnt->h_name, sizeof(g_CfgData.szHostname));
171
172         RegisterFastListClass();
173
174         // Get current config status
175         BOOL bCanceled = FALSE;
176         DWORD dwStatus = GetCurrentConfig(NULL, bCanceled);
177         if (dwStatus || bCanceled) {
178                 if (!bCanceled)
179                 ShowError(GetFocus(), dwStatus, IDS_CONFIG_CHECK_FAILED);
180                 return 0;
181         }
182
183         // Run the appropriate interface
184         if ((strstr(_strlwr(pszCmdLineA), "wizard") != 0))
185                 RunWizard();
186         else
187                 RunCfgTool();
188
189         FreePartitionTable();
190
191         // Disconnect from the config and admin libraries
192         CloseLibHandles(TRUE);
193
194         return 0;
195 }
196
197 /*
198  *      This is a dialog proc that is shared by all of the wizard pages.  It
199  *      handles things that are common to all of them.  Each page also has its
200  *      own dialog proc.
201  */
202 BOOL CALLBACK WizStep_Common_DlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp)
203 {
204         // Get the dialog's resource ID
205         int nIDD = GetWindowLong(hRHS, GWL_ID);
206         
207         if (AfsAppLib_HandleHelp(nIDD, hRHS, msg, wp, lp))
208                 return TRUE;
209         
210         switch (msg) {
211                 case WM_INITDIALOG:     MakeBold(hRHS, IDC_TITLE);
212                                                         RedrawGraphic();
213                                                         break;
214
215                 case WM_COMMAND:
216                         switch (LOWORD(wp)) {
217                                 case IDCANCEL:
218                                         QueryCancelWiz();
219                                         return TRUE;
220                         }
221                         break;
222         }
223
224         return FALSE;
225 }
226
227 BOOL QueryCancelWiz()
228 {
229         int nChoice = Message(MB_YESNO, IDS_WIZARD_APP_TITLE, IDS_CANCEL_DESC);
230         if (nChoice == IDYES) {
231                 g_LogFile.Write("User has chosen to cancel the program.\r\n");
232                 if (g_pWiz)
233                         g_pWiz->Show(FALSE);
234                 return TRUE;
235         }
236
237         return FALSE;
238 }
239
240
241 /*
242  *  Accessor functions for the g_CfgData variable.  There are versions
243  *  for both TCHARs and char *'s.
244  */
245 TCHAR GetDeviceName()           { return g_CfgData.chDeviceName; }
246 LPTSTR GetPartitionName()       { return g_CfgData.szPartitionName; }
247 LPTSTR GetHostName()            { return g_CfgData.szHostname; }
248 LPTSTR GetSysControlMachine()   { return g_CfgData.szSysControlMachine; }
249 LPTSTR GetCellName()            { return g_CfgData.szCellName; }
250 LPTSTR GetServerPW()            { return g_CfgData.szServerPW; }
251 LPTSTR GetAdminName()           { return g_CfgData.szAdminName; }
252 LPTSTR GetAdminPW()             { return g_CfgData.szAdminPW; }
253 LPTSTR GetAdminUID()            { return g_CfgData.szAdminUID; }
254 LPTSTR GetLocalName()           { return g_CfgData.szLocalName; }
255 LPTSTR GetHostname()            { return g_CfgData.szHostname; }
256 LPTSTR GetCellServDbHostname()  { return g_CfgData.szCellServDbHostname; }
257 LPTSTR GetClientCellName()      { return g_CfgData.szClientCellName; }
258 LPTSTR GetSalvageLogFileName()  { return g_CfgData.szSalvageLogFileName; }
259
260 LPTSTR GetClientNetbiosName()
261 {
262     static TCHAR szValue[MAX_MACHINE_NAME_LEN + 1];
263
264     lstrcpy(szValue, g_CfgData.szLocalName);
265
266     szValue[11] = TEXT('\0');
267
268     for (LPTSTR pch = szValue; *pch != TEXT('\0'); pch++) {
269         if (*pch == TEXT('.')) {
270             *pch = TEXT('\0');
271             break;
272         }
273     }
274     lstrcat(szValue, TEXT("-AFS"));
275
276     return szValue;
277 }
278
279 char GetDeviceNameA()
280 {
281     static char szValueA[2];
282
283     TCHAR devName[2] = TEXT("X");
284     devName[0] = g_CfgData.chDeviceName;
285
286     CopyStringToAnsi(szValueA, devName);
287
288     return szValueA[0];
289 }
290
291 char *GetPartitionNameA()
292 {
293     static char szValueA[MAX_PARTITION_NAME_LEN + 1];
294
295     CopyStringToAnsi(szValueA, g_CfgData.szPartitionName);
296
297     return szValueA;
298 }
299
300 char *GetSysControlMachineA()
301 {
302     static char szValueA[MAX_MACHINE_NAME_LEN + 1];
303
304     CopyStringToAnsi(szValueA, g_CfgData.szSysControlMachine);
305
306     return szValueA;
307 }
308
309 char *GetCellNameA()
310 {
311     static char szValueA[MAX_CELL_NAME_LEN + 1];
312
313     CopyStringToAnsi(szValueA, g_CfgData.szCellName);
314
315     return szValueA;
316 }
317
318 char *GetServerPWA()
319 {
320     static char szValueA[MAX_SERVER_PW_LEN + 1];
321
322     CopyStringToAnsi(szValueA, g_CfgData.szServerPW);
323
324     return szValueA;
325 }
326
327 char *GetAdminNameA()
328 {
329     static char szValueA[MAX_ADMIN_NAME_LEN + 1];
330
331     CopyStringToAnsi(szValueA, g_CfgData.szAdminName);
332
333     return szValueA;
334 }
335
336 char *GetAdminPWA()
337 {
338     static char szValueA[MAX_ADMIN_PW_LEN + 1];
339
340     CopyStringToAnsi(szValueA, g_CfgData.szAdminPW);
341
342     return szValueA;
343 }
344
345 char *GetAdminUIDA()
346 {
347     static char szValueA[MAX_UID_LEN + 1];
348
349     CopyStringToAnsi(szValueA, g_CfgData.szAdminUID);
350
351     return szValueA;
352 }
353
354 char *GetLocalNameA()
355 {
356     static char szValueA[MAX_MACHINE_NAME_LEN + 1];
357
358     CopyStringToAnsi(szValueA, g_CfgData.szLocalName);
359
360     return szValueA;
361 }
362
363 char *GetHostnameA()
364 {
365     static char szValueA[MAX_MACHINE_NAME_LEN + 1];
366
367     CopyStringToAnsi(szValueA, g_CfgData.szHostname);
368
369     return szValueA;
370 }
371
372 char *GetCellServDbHostnameA()
373 {
374     static char szValueA[MAX_MACHINE_NAME_LEN + 1];
375
376     CopyStringToAnsi(szValueA, g_CfgData.szCellServDbHostname);
377
378     return szValueA;
379 }
380
381 char *GetClientCellNameA()
382 {
383     static char szValueA[MAX_CELL_NAME_LEN + 1];
384
385     CopyStringToAnsi(szValueA, g_CfgData.szClientCellName);
386
387     return szValueA;
388 }
389
390 char *GetClientNetbiosNameA()
391 {
392     static char szValueA[MAX_MACHINE_NAME_LEN + 1];
393     char *dotp;
394
395     CopyStringToAnsi(szValueA, g_CfgData.szLocalName);
396
397     szValueA[11] = '\0';
398
399     if ((dotp = strchr(szValueA, '.')) != NULL) {
400         *dotp = '\0';
401     }
402     strcat(szValueA, "-AFS");
403
404     return szValueA;
405 }
406
407 char *GetSalvageLogFileNameA()
408 {
409     static char szValueA[_MAX_PATH];
410
411     CopyStringToAnsi(szValueA, g_CfgData.szSalvageLogFileName);
412
413     return szValueA;
414 }
415
416
417 BOOL GetLibHandles(afs_status_t *pStatus)
418 {
419         ASSERT(g_CfgData.szHostname[0]);
420
421         int nResult;
422         
423         // ************************* NOTE ********************************
424         // * You MUST have already determined whether or not the host
425         // * and client config info is valid before calling this function.
426         // ***************************************************************
427
428         // This function can be called at any time to get handles to the cell and
429         // the config library.  It will try to get the most powerful handle to the
430         // cell that it can, and then use that to open the config library.  If the
431         // libraries are already open, it will close them first.  Two handles to
432         // the config library will be opened, one to the server to be configured,
433         // and one to the client machine we are configuring from.  
434         
435         // There are two types of cell handles, NULL and Standard.  A null handle
436         // can make calls to any server except DB servers.  We need this primarily
437         // to talk to the bos server to determine the machine's current configuration,
438         // and to configure the client information if it is not already.  A standard 
439         // handle can talk to any server.  Standard handles can be either authenticated 
440         // or unauthenticated.
441
442         // Close all current handles
443         CloseLibHandles();
444
445         g_LogFile.Write("Getting handles to the cell and the config library.\r\n");
446
447     if (!hClientCell) {
448         // Start by getting a null cell handle and using it to open the client
449         // connection to the config library.
450         g_LogFile.Write("Opening a NULL cell handle to use with the client config library handle.\r\n");
451         nResult = afsclient_NullCellOpen(&hClientCell, pStatus);
452         if (!nResult) {
453             g_LogFile.Write("Failed to open a NULL cell handle: %lx.\r\n", (unsigned long)*pStatus);
454                 return FALSE;
455         }
456     
457         // Get the client handle.  We never need a better handle than this
458         // for the client, and so this handle will never be upgraded.
459         g_LogFile.Write("Getting config handle for the client.\r\n");
460         if (!cfg_HostOpen(hClientCell, GetHostnameA(), &g_hClient, pStatus)) {
461             g_LogFile.Write("Failed to get config handle:  %lx.\r\n", (unsigned long)*pStatus);
462                 return FALSE;
463         }
464     }
465
466         // Now we need to get the most powerful cell handle that we can and use it
467         // to open the config library for the server.
468
469         // If the client info is valid and we know what cell the server should be in,
470         // and the client has that cell in its CellServDB, then we can get a Standard cell
471         // handle.  However there is an exception: if this is the first server in the 
472         // cell then there may not yet be an authentication server to talk to.  In that
473         // case we use a null cell handle.
474     if (g_CfgData.bValidClientInfo &&   // Client config is valid
475         g_CfgData.szCellName[0] &&      // We have a cell name
476         (!g_CfgData.bFirstServer || g_CfgData.bAuthServerRunning))  // Auth server is running
477     {
478                 g_LogFile.Write("Opening a non-NULL cell handle to use with the server config library handle.\r\n");
479
480         // Do we have the user info necessary to authenticate?
481         BOOL bHaveUserInfo = g_CfgData.szAdminName[0] && g_CfgData.szAdminPW[0];
482
483                 // Open a standard cell handle.  szAdminName and szAdminPW will either be NULL, or
484                 // if they have been entered by the user, will be the admin name and password strings.
485                 if ((!g_CfgData.bFirstServer || g_CfgData.bAdminPrincipalCreated) && bHaveUserInfo) {
486                         g_LogFile.Write("Getting tokens in cell %s for user '%s'.\r\n", GetCellNameA(), GetAdminNameA());
487                         nResult = afsclient_TokenGetNew(GetCellNameA(), GetAdminNameA(), GetAdminPWA(), &g_hToken, pStatus);
488                 } else {
489                         g_LogFile.Write("Getting unauthenticated tokens for cell '%s'.\r\n", GetCellNameA());
490                         nResult = afsclient_TokenGetNew(GetCellNameA(), "", "", &g_hToken, pStatus);
491                 }
492
493                 if (!nResult) {
494                         g_LogFile.Write("Failed to get tokens for the specified cell:  %lx.\r\n", (unsigned long)*pStatus);
495                         return FALSE;
496                 }
497
498                 // If the admin name and password are NULL, then this will be an unauthenticated
499                 // connection to the cell.
500                 g_LogFile.Write("Getting cell handle for cell %s.\r\n", GetCellNameA());
501                 nResult = afsclient_CellOpen(GetCellNameA(), g_hToken, &g_hCell, pStatus);
502                 if (!nResult) {
503             g_LogFile.Write("Failed to open the cell:  %lx.\r\n", (unsigned long)*pStatus);
504                         return FALSE;
505                 }
506         } else {
507         g_LogFile.Write("Opening a NULL cell handle to use with the server config library handle.\r\n");
508         nResult = afsclient_NullCellOpen(&g_hCell, pStatus);
509         if (!nResult) {
510             g_LogFile.Write("Failed to open a NULL cell handle:  %lx.\r\n", (unsigned long)*pStatus);
511                 return FALSE;
512         }
513     }
514
515         // Get the server handle
516         g_LogFile.Write("Getting config library handle for the server.\r\n");
517         if (!cfg_HostOpen(g_hCell, GetHostnameA(), &g_hServer, pStatus)) {
518         g_LogFile.Write("Failed to get config library handle for the server:  %lx.\r\n", (unsigned long)*pStatus);
519                 return FALSE;
520         }
521
522         return TRUE;
523 }
524
525 BOOL GetHandles(HWND hParentDlg)
526 {
527     afs_status_t nStatus;
528
529     if (!GetLibHandles(&nStatus)) {
530         ShowError(hParentDlg, nStatus, IDS_GET_TOKENS_ERROR);
531         g_CfgData.szAdminPW[0] = 0;
532         return FALSE;
533     }
534
535     return TRUE;
536 }
537
538
539 /*
540  * Static FUNCTIONS _________________________________________________________________
541  *
542  */
543 static void CloseLibHandles(BOOL bExiting)
544 {
545      afs_status_t nStatus;
546
547         // We will close them in the reverse order of their creation.
548
549         if (g_hServer) {
550                 cfg_HostClose(g_hServer, &nStatus);
551                 g_hServer = 0;
552         }
553
554         if (g_hCell) {
555                 afsclient_CellClose(g_hCell, &nStatus);
556                 g_hCell = 0;
557         }
558
559         if (g_hToken) {
560                 afsclient_TokenClose(g_hToken, &nStatus);
561                 g_hToken = 0;
562         }
563
564     // Only close the client cfg and cell handles if we are exiting.
565         if (bExiting) {
566         if (g_hClient) {
567                 cfg_HostClose(g_hClient, &nStatus);
568                 g_hClient = 0;
569         }
570
571         if (hClientCell) {
572                 afsclient_CellClose(hClientCell, &nStatus);
573                 hClientCell = 0;
574         }
575     }
576 }
577
578 static void SetConfigDefaults()
579 {
580         if (g_CfgData.bWizard) {
581                 if (g_CfgData.configFS == CS_NULL)
582                         g_CfgData.configFS = CS_CONFIGURE;
583
584                 if (g_CfgData.configDB == CS_NULL)
585                         g_CfgData.configDB = CS_CONFIGURE;
586                 
587                 if (g_CfgData.configBak == CS_NULL)
588                         g_CfgData.configBak = CS_CONFIGURE;
589
590                 if (g_CfgData.configPartition == CS_NULL)
591                         g_CfgData.configPartition = CS_CONFIGURE;
592
593                 if (g_CfgData.configRootVolumes == CS_NULL)
594                         g_CfgData.configRootVolumes = CS_CONFIGURE;
595
596                 if (g_CfgData.configRep == CS_NULL)
597                         g_CfgData.configRep = CS_CONFIGURE;
598
599                 if (g_CfgData.configSCS == CS_NULL)
600                         g_CfgData.configSCS = CS_DONT_CONFIGURE;
601
602                 if (g_CfgData.configSCC == CS_NULL)
603                         g_CfgData.configSCC = CS_DONT_CONFIGURE;
604         }
605
606         lstrcpy(g_CfgData.szAdminName, TEXT("admin"));
607         lstrcpy(g_CfgData.szAdminUID, TEXT("0"));
608
609         g_CfgData.bUseNextUid = TRUE;
610 }
611
612         
613 // Prototypes for each property page's dialog proc
614 BOOL CALLBACK PartitionsPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
615 BOOL CALLBACK ServicesPageDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
616
617 static void RunCfgTool()
618 {
619         // If the client info is invalid, then the config tool cannot run.  Inform the user and
620         // ask if they want to run the wizard instead.
621         if (!g_CfgData.bValidClientInfo) {
622                 int nChoice = MsgBox(0, IDS_NEED_CLIENT_INFO, GetAppTitleID(), MB_YESNO | MB_ICONSTOP);
623                 if (nChoice == IDYES)
624                         RunWizard();
625                 return;
626         }
627
628         // If the server info is invalid, then the config tool cannot run.  The Wizard must be run
629         // to initially configure the server.  Inform the user and ask if they want to run the wizard instead.
630         if (!g_CfgData.bValidServerInfo) {
631                 int nChoice = MsgBox(0, IDS_NEED_SERVER_INFO, GetAppTitleID(), MB_OKCANCEL | MB_ICONEXCLAMATION);
632                 if (nChoice == IDOK)
633                         RunWizard();
634                 return;
635         }
636
637         g_CfgData.bWizard = FALSE;
638
639         SetConfigDefaults();
640
641         RegisterConfigToolHelp();
642
643         // Create the prop sheet
644         g_pSheet = PropSheet_Create(IDS_CFG_TOOL_APP_TITLE, TRUE);
645         
646         // Add the pages
647         PropSheet_AddTab(g_pSheet, IDS_PARTITIONS_PAGE_TITLE, IDD_PARTITIONS_PAGE, (DLGPROC)PartitionsPageDlgProc, 0, TRUE, TRUE);
648         PropSheet_AddTab(g_pSheet, IDS_SERVICES_PAGE_TITLE, IDD_SERVICES_PAGE, (DLGPROC)ServicesPageDlgProc, 0, TRUE);
649
650         // Let the user see it
651         PropSheet_ShowModal(g_pSheet);
652 }
653
654 static void RunWizard()
655 {
656         g_CfgData.bWizard = TRUE;
657
658     SetConfigDefaults();
659
660         RegisterWizardHelp();
661         
662         g_pWiz = new WIZARD;
663         g_pWiz->SetDialogTemplate(IDD_WIZARD, IDC_WIZARD_LEFTPANE, IDC_WIZARD_RIGHTPANE, IDBACK, IDNEXT);
664         g_pWiz->SetGraphic(IDB_GRAPHIC_16, IDB_GRAPHIC_256);
665         g_pWiz->SetStates(g_aStates, g_nNumStates);
666         g_pWiz->SetGraphicCallback(PaintPageGraphic);
667
668         g_pWiz->SetState(sidSTEP_ONE);
669         g_pWiz->Show();
670
671         delete g_pWiz;
672
673         g_pWiz = 0;
674 }
675