mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 23:40:13 +00:00
Windows: Make use of SMB interface a runtime decision
Add 'smb_Enabled' and 'RDR_Initialized' flag variables. Default smb_Enabled to true and RDR_Initialized to false. Add registry value "SMBInterfaceEnabled" to permit disabling the SMB interface. If the redirector interface is initialized (a future set of patchsets will add it) disable the SMB interface at runtime. Change-Id: I354e121001d942421aa98490b62b710ac175051f Reviewed-on: http://gerrit.openafs.org/5337 Reviewed-by: Jeffrey Altman <jaltman@openafs.org> Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
parent
f7d0e800eb
commit
070383939d
@ -117,6 +117,10 @@ extern long rx_mtu;
|
||||
|
||||
extern HANDLE WaitToTerminate;
|
||||
|
||||
extern int RDR_Initialized;
|
||||
|
||||
extern afs_uint32 smb_Enabled;
|
||||
|
||||
#define DFS_SUPPORT 1
|
||||
#define LOG_PACKET 1
|
||||
#undef NOTSERVICE
|
||||
|
@ -77,6 +77,7 @@ int cm_logChunkSize;
|
||||
int cm_chunkSize;
|
||||
|
||||
int smb_UseV3 = 1;
|
||||
afs_uint32 smb_Enabled = 1;
|
||||
|
||||
int LANadapter;
|
||||
|
||||
@ -1497,14 +1498,25 @@ int afsd_InitSMB(char **reasonP, void *aMBfunc)
|
||||
smb_AsyncStoreSize = CM_CONFIGDEFAULT_ASYNCSTORESIZE;
|
||||
afsi_log("SMBAsyncStoreSize = %d", smb_AsyncStoreSize);
|
||||
|
||||
dummyLen = sizeof(DWORD);
|
||||
code = RegQueryValueEx(parmKey, "SMBInterfaceEnabled", NULL, NULL,
|
||||
(BYTE *) &dwValue, &dummyLen);
|
||||
if (code == ERROR_SUCCESS)
|
||||
smb_Enabled = dwValue ? 1 : 0;
|
||||
afsi_log("SMBInterfaceEnabled = %d", smb_Enabled);
|
||||
|
||||
RegCloseKey (parmKey);
|
||||
}
|
||||
|
||||
if ( smb_Enabled ) {
|
||||
/* Do this last so that we don't handle requests before init is done.
|
||||
* Here we initialize the SMB listener.
|
||||
*/
|
||||
smb_Init(afsd_logp, smb_UseV3, numSvThreads, aMBfunc);
|
||||
afsi_log("smb_Init complete");
|
||||
} else {
|
||||
afsi_log("smb_Init skipped");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ extern HANDLE afsi_file;
|
||||
|
||||
static int powerEventsRegistered = 0;
|
||||
extern int powerStateSuspended = 0;
|
||||
extern int RDR_Initialized = 0;
|
||||
|
||||
static VOID (WINAPI* pRtlCaptureContext)(PCONTEXT ContextRecord) = NULL;
|
||||
|
||||
@ -401,7 +402,7 @@ afsd_ServiceControlHandlerEx(
|
||||
/* This is the message delivered once all devices are up */
|
||||
afsi_log("SERVICE_CONTROL_APMRESUMEAUTOMATIC");
|
||||
powerStateSuspended = 0;
|
||||
if (osVersion.dwMajorVersion >= 6) {
|
||||
if (smb_Enabled && osVersion.dwMajorVersion >= 6) {
|
||||
smb_SetLanAdapterChangeDetected();
|
||||
}
|
||||
dwRet = NO_ERROR;
|
||||
@ -1326,12 +1327,23 @@ afsd_Main(DWORD argc, LPTSTR *argv)
|
||||
/* Notify any volume status handlers that the cache manager has started */
|
||||
cm_VolStatus_Service_Started();
|
||||
|
||||
/*
|
||||
* Set the default for the SMB interface based upon the state of the
|
||||
* Redirector interface.
|
||||
*/
|
||||
smb_Enabled = !RDR_Initialized;
|
||||
|
||||
code = afsd_InitSMB(&reason, MessageBox);
|
||||
if (code != 0) {
|
||||
if (smb_Enabled && code != 0) {
|
||||
afsi_log("afsd_InitSMB failed: %s (code = %d)", reason, code);
|
||||
osi_panic(reason, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (!smb_Enabled && !RDR_Initialized) {
|
||||
afsi_log("Neither RDR nor SMB interfaces available");
|
||||
osi_panic(reason, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
/* allow an exit to be called post smb initialization */
|
||||
hHookDll = cm_LoadAfsdHookLib();
|
||||
if (hHookDll)
|
||||
|
@ -147,17 +147,20 @@ void cm_InitConn(void)
|
||||
* We base our values on those while making sure we leave
|
||||
* enough time for overhead.
|
||||
*/
|
||||
if (ConnDeadtimeout == 0) {
|
||||
ConnDeadtimeout = (unsigned short) ((RDRtimeout / 2) < 50 ? (RDRtimeout / 2) : 50);
|
||||
afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
|
||||
}
|
||||
if (HardDeadtimeout == 0) {
|
||||
HardDeadtimeout = (unsigned short) (RDRtimeout > 125 ? 120 : (RDRtimeout - 5));
|
||||
afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
|
||||
}
|
||||
if (IdleDeadtimeout == 0) {
|
||||
IdleDeadtimeout = (unsigned short) ConnDeadtimeout;
|
||||
afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
|
||||
if (smb_Enabled) {
|
||||
afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
|
||||
if (ConnDeadtimeout == 0) {
|
||||
ConnDeadtimeout = (unsigned short) ((RDRtimeout / 2) < 50 ? (RDRtimeout / 2) : 50);
|
||||
afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
|
||||
}
|
||||
if (HardDeadtimeout == 0) {
|
||||
HardDeadtimeout = (unsigned short) (RDRtimeout > 125 ? 120 : (RDRtimeout - 5));
|
||||
afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
|
||||
}
|
||||
if (IdleDeadtimeout == 0) {
|
||||
IdleDeadtimeout = (unsigned short) ConnDeadtimeout;
|
||||
afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
|
||||
}
|
||||
}
|
||||
osi_EndOnce(&once);
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ void cm_IpAddrDaemon(long parm)
|
||||
Result = NotifyAddrChange(NULL,NULL);
|
||||
if (Result == NO_ERROR && daemon_ShutdownFlag == 0) {
|
||||
lastIPAddrChange = osi_Time();
|
||||
smb_SetLanAdapterChangeDetected();
|
||||
if (smb_Enabled)
|
||||
smb_SetLanAdapterChangeDetected();
|
||||
cm_SetLanAdapterChangeDetected();
|
||||
thrd_ResetEvent(cm_IPAddrDaemon_ShutdownEvent);
|
||||
}
|
||||
|
@ -10390,6 +10390,9 @@ int smb_NetbiosInit(int locked)
|
||||
int lana_found = 0;
|
||||
lana_number_t lanaNum;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return 0;
|
||||
|
||||
if (!locked)
|
||||
lock_ObtainMutex(&smb_StartedLock);
|
||||
|
||||
@ -10574,6 +10577,9 @@ void smb_StartListeners(int locked)
|
||||
int lpid;
|
||||
thread_t phandle;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return;
|
||||
|
||||
if (!locked)
|
||||
lock_ObtainMutex(&smb_StartedLock);
|
||||
|
||||
@ -10614,6 +10620,9 @@ void smb_StartListeners(int locked)
|
||||
|
||||
void smb_RestartListeners(int locked)
|
||||
{
|
||||
if (!smb_Enabled)
|
||||
return;
|
||||
|
||||
if (!locked)
|
||||
lock_ObtainMutex(&smb_StartedLock);
|
||||
|
||||
@ -10668,6 +10677,9 @@ void smb_StopListeners(int locked)
|
||||
NCB *ncbp;
|
||||
int lana, l;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return;
|
||||
|
||||
if (!locked)
|
||||
lock_ObtainMutex(&smb_StartedLock);
|
||||
|
||||
@ -10721,6 +10733,9 @@ void smb_Init(osi_log_t *logp, int useV3,
|
||||
char eventName[MAX_PATH];
|
||||
int startListeners = 0;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return;
|
||||
|
||||
smb_MBfunc = aMBfunc;
|
||||
|
||||
smb_useV3 = useV3;
|
||||
@ -11081,6 +11096,9 @@ void smb_Shutdown(void)
|
||||
afs_uint32 i;
|
||||
smb_vc_t *vcp;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return;
|
||||
|
||||
/*fprintf(stderr, "Entering smb_Shutdown\n");*/
|
||||
|
||||
/* setup the NCB system */
|
||||
@ -11323,10 +11341,12 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
|
||||
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
|
||||
|
||||
|
||||
if (!smb_Enabled)
|
||||
goto done;
|
||||
|
||||
sprintf(output, "begin dumping smb_waitingLockRequest_t\r\n");
|
||||
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
|
||||
|
||||
|
||||
for ( wlrp = smb_allWaitingLocks; wlrp; wlrp = (smb_waitingLockRequest_t *) osi_QNext(&wlrp->q)) {
|
||||
smb_waitingLock_t *lockp;
|
||||
|
||||
@ -11454,6 +11474,7 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
|
||||
sprintf(output, "done dumping DEAD smb_vc_t\r\n");
|
||||
WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
|
||||
|
||||
done:
|
||||
if (lock)
|
||||
lock_ReleaseRead(&smb_rctLock);
|
||||
return 0;
|
||||
@ -11462,6 +11483,10 @@ int smb_DumpVCP(FILE *outputFile, char *cookie, int lock)
|
||||
long smb_IsNetworkStarted(void)
|
||||
{
|
||||
long rc;
|
||||
|
||||
if (!smb_Enabled)
|
||||
return 0;
|
||||
|
||||
lock_ObtainWrite(&smb_globalLock);
|
||||
rc = (smb_ListenerState == SMB_LISTENER_STARTED && smbShutdownFlag == 0);
|
||||
lock_ReleaseWrite(&smb_globalLock);
|
||||
|
Loading…
Reference in New Issue
Block a user