win-xp-sp2-20040325

Support for punching holes in the Win XP SP2 Firewall
for AFS Cache Manager Callbacks
This commit is contained in:
Jeffrey Altman 2004-03-26 06:39:23 +00:00 committed by Jeffrey Altman
parent 2e455c3702
commit df33edc049
2 changed files with 38 additions and 12 deletions

View File

@ -571,6 +571,27 @@ int afsd_InitCM(char **reasonP)
afsi_log("rx_SetMaxMTU %d successful", rx_mtu);
}
/* Open Microsoft Firewall to allow in port 7001 */
{
HKEY hk;
DWORD dwDisp;
TCHAR value = TEXT("7001:UDP:*:Enabled:AFS Cache Manager Callback");
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\GloballyOpenP",
0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
{
RegSetValueEx (hk, TEXT("7001:UDP"), NULL, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
RegCloseKey (hk);
}
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenP",
0, TEXT("container"), 0, KEY_SET_VALUE, NULL, &hk, &dwDisp) == ERROR_SUCCESS)
{
RegSetValueEx (hk, TEXT("7001:UDP"), NULL, REG_SZ, (PBYTE)value, sizeof(TCHAR) * (1+lstrlen(value)));
RegCloseKey (hk);
}
}
/* initialize RX, and tell it to listen to port 7001, which is used for
* callback RPC messages.
*/

View File

@ -40,6 +40,8 @@
extern void afsi_log(char *pattern, ...);
HANDLE hAFSDMainThread = NULL;
HANDLE WaitToTerminate;
int GlobalStatus;
@ -189,7 +191,7 @@ afsd_ServiceControlHandlerEx(
ServiceStatus.dwWin32ExitCode = NO_ERROR;
ServiceStatus.dwCheckPoint = 1;
ServiceStatus.dwWaitHint = 10000;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT;
ServiceStatus.dwControlsAccepted = 0;
SetServiceStatus(StatusHandle, &ServiceStatus);
SetEvent(WaitToTerminate);
dwRet = NO_ERROR;
@ -317,7 +319,9 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
{
long code;
char *reason;
#ifdef JUMP
int jmpret;
#endif /* JUMP */
HANDLE hInitHookDll;
AfsdInitHook initHook;
@ -331,6 +335,8 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
GlobalStatus = 0;
afsi_start();
WaitToTerminate = CreateEvent(NULL, TRUE, FALSE, TEXT("afsd_service_WaitToTerminate"));
if ( GetLastError() == ERROR_ALREADY_EXISTS )
afsi_log("Event Object Already Exists: %s", TEXT("afsd_service_WaitToTerminate"));
@ -365,8 +371,6 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
PowerNotificationThreadCreate();
#endif
afsi_start();
/* allow an exit to be called prior to any initialization */
hInitHookDll = LoadLibrary(AFSD_HOOK_DLL);
if (hInitHookDll)
@ -459,13 +463,6 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
WaitForSingleObject(WaitToTerminate, INFINITE);
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
ServiceStatus.dwWin32ExitCode = NO_ERROR;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 5000;
ServiceStatus.dwControlsAccepted = 0;
SetServiceStatus(StatusHandle, &ServiceStatus);
{
HANDLE h; char *ptbuf[1];
h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
@ -483,7 +480,10 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
/* Remove the ExceptionFilter */
SetUnhandledExceptionFilter(NULL);
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
if ( hInitHookDll )
FreeLibrary(hInitHookDll);
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = GlobalStatus ? ERROR_EXCEPTION_IN_SERVICE : NO_ERROR;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
@ -511,12 +511,17 @@ main(void)
if (status == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
{
DWORD tid;
CreateThread(NULL, 0, afsdMain_thread, 0, 0, &tid);
hAFSDMainThread = CreateThread(NULL, 0, afsdMain_thread, 0, 0, &tid);
printf("Hit <Enter> to terminate OpenAFS Client Service\n");
getchar();
SetEvent(WaitToTerminate);
}
}
if ( hAFSDMainThread ) {
WaitForSingleObject( hAFSDMainThread, INFINITE );
CloseHandle( hAFSDMainThread );
}
return(0);
}