Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afssvrcfg / afscfg.h
1 /*
2  * Copyright (C) 1998  Transarc Corporation.
3  * All rights reserved.
4  *
5  */
6
7 #ifndef _H_AFSCFG_H_
8 #define _H_AFSCFG_H_
9
10
11 extern "C" {
12 #include <afs\afs_cfgAdmin.h>
13 #include <afs\afs_utilAdmin.h>
14 }
15 #include <WINNT\afsapplib.h>
16 #include <tchar.h>
17 #include <crtdbg.h>
18 #include "hourglass.h"
19 #include "toolbox.h"
20 #include "logfile.h"
21 #include "char_conv.h"
22 #include "validation.h"
23
24
25 #define ASSERT(x)               _ASSERTE((x))
26
27 #define LOG_FILE_NAME   "afs_server_config_log.txt"
28
29
30 // Enum for the steps in the wizard.  Used to index into the array of steps.
31 enum StateID {
32    sidSTEP_ONE,
33    sidSTEP_TWO,
34    sidSTEP_THREE,
35    sidSTEP_FOUR,
36    sidSTEP_FIVE,
37    sidSTEP_SIX,
38    sidSTEP_SEVEN,
39    sidSTEP_EIGHT,
40    sidSTEP_NINE,
41    sidSTEP_TEN,
42    sidSTEP_ELEVEN,
43    sidSTEP_TWELVE
44 };
45
46
47 // These are the possible states for a configuration step.
48 // The first 4 are mutually exclusive.  The last one can
49 // be combined with any of the others, though it doesn't
50 // mean anything to combine it with CS_NULL.
51 #define CS_NULL                                 0               // NULL state
52 #define CS_DONT_CONFIGURE               1               // Do not perform the configuration step
53 #define CS_CONFIGURE                    2               // Perform the configuration step
54 #define CS_ALREADY_CONFIGURED   3               // The step has already been performed, so we don't 
55                                                                                 // need to do it.
56 #define CS_UNCONFIGURE                  4               // Unconfigure the step
57 #define CS_DISABLED                             32              // The step cannot be performed because it is dependent
58                                                                                 // on some other step that is not to be performed and 
59                                                                                 // has not already been performed.
60
61 // I know I could have used an enum for this, but then tacking on the CS_DISABLED
62 // flag to the enum would have been a bit sleazy.
63 typedef int CONFIG_STATE;
64
65 // Timeout values
66 #define BOSSERVER_START_TIMEOUT     2 * 60      // 2 minutes in seconds
67 #define BOSSERVER_STOP_TIMEOUT      30 * 60     // 30 minutes in seconds
68
69 // Sizes for various arrays
70 #define MAX_PARTITION_NAME_LEN          8       //cfg_maxPartitionNameLen
71 #define MAX_MACHINE_NAME_LEN            128 //AFS_MAX_SERVER_NAME_LEN
72 #define MAX_CELL_NAME_LEN                       64
73 #define MAX_SERVER_PW_LEN                       32
74 #define MAX_ADMIN_NAME_LEN                      256
75 #define MAX_ADMIN_PW_LEN                        32
76 #define MAX_UID_LEN                                     12
77
78
79 /*
80  *      This sturcture contains all of the information needed to configure
81  *      a machine.
82  */
83 struct CFG_DATA {
84         BOOL bWizard;
85         
86         CONFIG_STATE configFS;                  // File server
87         CONFIG_STATE configDB;                  // Database server
88         CONFIG_STATE configBak;                 // Backup server
89         CONFIG_STATE configPartition;   // Create a partition
90         CONFIG_STATE configRootVolumes; // Create root.afs and root.cell
91         CONFIG_STATE configRep;                 // Replicate root.afs and root.cell
92         CONFIG_STATE configSCS;                 // System Control server
93         CONFIG_STATE configSCC;                 // System Control client
94
95         BOOL bLastDBServer;
96
97     UINT nRootAfsID;                            // Volume ID of root.afs
98     UINT nRootCellID;                           // Volume ID of root.cell
99
100         BOOL bRootAfsExists;
101         BOOL bRootCellExists;
102  
103     // If we cannot determine if the root volumes exist, then this 
104     // variable will be FALSE.
105     BOOL bRootVolumesExistanceKnown;
106         
107     BOOL bRootAfsReplicated;
108         BOOL bRootCellReplicated;
109     BOOL bRootVolumesReplicationKnown;
110
111         // Partition info
112         TCHAR chDeviceName;                             // Just the drive to use
113         TCHAR szPartitionName[MAX_PARTITION_NAME_LEN + 1];
114
115         // Sys control machine if configuring as a system control client and also to
116         // use to propagate CellServDB, if configuring a db server
117         TCHAR szSysControlMachine[MAX_MACHINE_NAME_LEN + 1];
118
119         // Server and Cell information
120         TCHAR szCellName[MAX_CELL_NAME_LEN + 1];
121         TCHAR szServerPW[MAX_SERVER_PW_LEN + 1];
122         TCHAR szAdminName[MAX_ADMIN_NAME_LEN + 1];
123         TCHAR szAdminPW[MAX_ADMIN_PW_LEN + 1];
124         TCHAR szAdminUID[MAX_UID_LEN + 1];
125         BOOL bUseNextUid;
126         BOOL bFirstServer;
127         BOOL bAuthServerRunning;                // Only used when bFirstServer is true
128         BOOL bAdminPrincipalCreated;    // Only used when bFirstServer is true
129
130         // This machine's local name
131         TCHAR szLocalName[MAX_MACHINE_NAME_LEN + 1];
132
133         // This machine's hostname
134         TCHAR szHostname[MAX_MACHINE_NAME_LEN + 1];
135
136         // Hostname of machine to get CellServDB from
137         TCHAR szCellServDbHostname[MAX_MACHINE_NAME_LEN + 1];
138
139         // Is the AFS Client configured?
140         BOOL bValidClientInfo;
141         TCHAR szClientCellName[MAX_CELL_NAME_LEN + 1];
142         unsigned nClientVersion;
143
144         // Does this machine have valid config info?
145         BOOL bValidServerInfo;
146
147     // Can we reuse the admin name and password?
148     // For use by config manager - if false we will prompt user to login.
149     BOOL bReuseAdminInfo;
150
151     // Handle of the thread performing a salvage
152     HANDLE hSalvageThread;
153     TCHAR szSalvageLogFileName[_MAX_PATH];
154 };
155
156
157 // Must include this after the definition of CONFIG_STATE;
158 #include "cfg_utils.h"
159
160
161 // These are defined in afscfg.cpp
162 extern LPWIZARD g_pWiz;                 // The wizard
163 extern LPPROPSHEET g_pSheet;    // The config tool property sheet
164 extern CFG_DATA g_CfgData;              // The config data
165
166 extern void *g_hToken;                  // Current token obtained by this app
167 extern void *g_hCell;                   // Handle to the cell we are configuring into
168 extern void *g_hClient;                 // Client's config library handle
169 extern void *g_hServer;                 // Server's config library handle
170
171 extern size_t g_nNumStates;
172 extern UINT g_StateDesc[];              // Res ID's of descriptions of each wizard step
173
174 extern LOGFILE g_LogFile;               // Our log file
175
176 BOOL CALLBACK WizStep_Common_DlgProc (HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
177 BOOL QueryCancelWiz();
178 BOOL GetLibHandles(afs_status_t *pStatus);
179 BOOL GetHandles(HWND hParentDlg);   // More convenient version if you only need to know if it succeeded
180
181
182 /*
183  *      Accessor functions for g_CfgData__________________________________________
184  */
185
186 // TCHAR versions
187 TCHAR GetDeviceName();
188 LPTSTR GetPartitionName();
189 LPTSTR GetHostName();
190 LPTSTR GetSysControlMachine();
191 LPTSTR GetCellName();
192 LPTSTR GetServerPW();
193 LPTSTR GetAdminName();
194 LPTSTR GetAdminPW();
195 LPTSTR GetAdminUID();
196 LPTSTR GetLocalName();
197 LPTSTR GetHostname();
198 LPTSTR GetCellServDbHostname();
199 LPTSTR GetClientCellName();
200 LPTSTR GetClientNetbiosName();
201 LPTSTR GetSalvageLogFileName();
202
203 // char versions
204 char GetDeviceNameA();
205 char *GetPartitionNameA();
206 char *GetSysControlMachineA();
207 char *GetCellNameA();
208 char *GetServerPWA();
209 char *GetAdminNameA();
210 char *GetAdminPWA();
211 char *GetAdminUIDA();
212 char *GetLocalNameA();
213 char *GetHostnameA();
214 char *GetCellServDbHostnameA();
215 char *GetClientCellNameA();
216 char *GetClientNetbiosNameA();
217 char *GetSalvageLogFileNameA();
218
219 #endif  // _H_AFSCFG_H_
220