extern afs_int32 cryptall;
extern int cm_enableServerLocks;
+extern int cm_deleteReadOnly;
osi_log_t *afsd_logp;
if ( afsi_log_useTimestamp ) {
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, d, sizeof(d));
- StringCbPrintfA(u, sizeof(u), "%s %s: %s\n", d, t, s);
+ StringCbPrintfA(u, sizeof(u), "%s %s: %s\r\n", d, t, s);
if (afsi_file != INVALID_HANDLE_VALUE)
WriteFile(afsi_file, u, (DWORD)strlen(u), &zilch, NULL);
#ifdef NOTSERVICE
HKEY hkMSV10;
HKEY hkClient;
DWORD dwType;
- DWORD dwSize;
+ DWORD dwSize, dwAllocSize;
DWORD dwValue;
PBYTE pHostNames = NULL, pName = NULL;
BOOL bNameFound = FALSE;
&hkMSV10) == ERROR_SUCCESS )
{
if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0,
- &dwType, NULL, &dwSize) == ERROR_SUCCESS) {
- dwSize += strlen(cm_NetbiosName) + 1;
- pHostNames = malloc(dwSize);
+ &dwType, NULL, &dwAllocSize) == ERROR_SUCCESS) {
+ dwAllocSize += 1 /* in case the source string is not nul terminated */
+ + strlen(cm_NetbiosName) + 2;
+ pHostNames = malloc(dwAllocSize);
+ dwSize = dwAllocSize;
if (RegQueryValueEx( hkMSV10, "BackConnectionHostNames", 0, &dwType,
pHostNames, &dwSize) == ERROR_SUCCESS) {
- for (pName = pHostNames; *pName ; pName += strlen(pName) + 1)
+ for (pName = pHostNames;
+ (pName - pHostNames < dwSize) && *pName ;
+ pName += strlen(pName) + 1)
{
if ( !stricmp(pName, cm_NetbiosName) ) {
bNameFound = TRUE;
size_t size = strlen(cm_NetbiosName) + 2;
if ( !pHostNames ) {
pHostNames = malloc(size);
- dwSize = size;
pName = pHostNames;
}
StringCbCopyA(pName, size, cm_NetbiosName);
*pName = '\0'; /* add a second nul terminator */
dwType = REG_MULTI_SZ;
+ dwSize = pName - pHostNames + 1;
RegSetValueEx( hkMSV10, "BackConnectionHostNames", 0, dwType, pHostNames, dwSize);
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE,
}
-#if !defined(DJGPP)
static void afsd_InitServerPreferences(void)
{
HKEY hkPrefs = 0;
RegCloseKey(hkPrefs);
}
}
-#endif /* DJGPP */
/*
* AFSD Initialization
if (rx_enable_process_stats)
afsi_log("RX Process Statistics gathering is enabled");
- dummyLen = sizeof(ConnDeadtimeout);
- code = RegQueryValueEx(parmKey, "ConnDeadTimeout", NULL, NULL,
- (BYTE *) &ConnDeadtimeout, &dummyLen);
- afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
-
- dummyLen = sizeof(HardDeadtimeout);
- code = RegQueryValueEx(parmKey, "HardDeadTimeout", NULL, NULL,
- (BYTE *) &HardDeadtimeout, &dummyLen);
- afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
-
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckDownInterval", NULL, NULL,
(BYTE *) &dwValue, &dummyLen);
afsi_log("EnableServerLocks: server requested");
break;
}
+
+ dummyLen = sizeof(DWORD);
+ code = RegQueryValueEx(parmKey, "DeleteReadOnly", NULL, NULL,
+ (BYTE *) &dwValue, &dummyLen);
+ if (code == ERROR_SUCCESS) {
+ cm_deleteReadOnly = (unsigned short) dwValue;
+ }
+ afsi_log("CM DeleteReadOnly is %u", cm_deleteReadOnly);
+
RegCloseKey (parmKey);
/* Call lanahelper to get Netbios name, lan adapter number and gateway flag */
* which is used for callback RPC messages.
*/
code = rx_Init(htons(cm_callbackport));
+ if (code != 0) {
+ afsi_log("rx_Init code %x - retrying with a random port number", code);
+ code = rx_Init(0);
+ }
afsi_log("rx_Init code %x", code);
if (code != 0) {
- *reasonP = "afsd: failed to init rx client on port 7001";
+ *reasonP = "afsd: failed to init rx client";
return -1;
}
code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
if (code != 0 && !cm_freelanceEnabled)
{
- *reasonP = "can't find root cell name in afsd.ini";
+ *reasonP = "can't find root cell name in CellServDB";
return -1;
}
else if (cm_freelanceEnabled)
/* Initialize the RPC server for session keys */
RpcInit();
-#if !defined(DJGPP)
afsd_InitServerPreferences();
-#endif
+ return 0;
+}
+
+int afsd_ShutdownCM(void)
+{
+ cm_ReleaseSCache(cm_data.rootSCachep);
+
return 0;
}
/* this should really be in an init daemon from here on down */
if (!cm_freelanceEnabled) {
+ int attempts = 10;
+
osi_Log0(afsd_logp, "Loading Root Volume from cell");
- code = cm_GetVolumeByName(cm_data.rootCellp, cm_rootVolumeName, cm_rootUserp,
- &req, CM_FLAG_CREATE, &cm_data.rootVolumep);
- afsi_log("cm_GetVolumeByName code %x root vol %x", code,
- (code ? (cm_volume_t *)-1 : cm_data.rootVolumep));
+ do {
+ code = cm_GetVolumeByName(cm_data.rootCellp, cm_rootVolumeName, cm_rootUserp,
+ &req, CM_FLAG_CREATE, &cm_data.rootVolumep);
+ afsi_log("cm_GetVolumeByName code %x root vol %x", code,
+ (code ? (cm_volume_t *)-1 : cm_data.rootVolumep));
+ } while (code && --attempts);
if (code != 0) {
*reasonP = "can't find root volume in root cell";
return -1;
void
GenerateMiniDump(PEXCEPTION_POINTERS ep)
{
+ if (IsDebuggerPresent())
+ return;
+
if (ep == NULL)
{
// Generate exception to get proper context in dump