mirror of
https://github.com/reactos/reactos.git
synced 2026-06-09 17:33:50 +08:00
[WINLOGON] Close all the user network connections only at logoff (#8324)
Per-user network connections (to shared drives...) are restored at user logon: `HandleLogon() -> RestoreAllConnections()`. These connections should be closed only at user logoff, in `HandleLogoff()`, instead of inside the common logoff/shutdown thread, which is also invoked at... shutdown! - Isolate the network connections closing inside a `CloseAllConnections()` helper (which also performs the necessary user thread impersonation). - Invoke this helper directly inside `HandleLogoff()`, and also re-enable the `IDS_CLOSINGNETWORKCONNECTIONS` message display.
This commit is contained in:
@@ -429,7 +429,8 @@ PlayEventSound(
|
|||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
RestoreAllConnections(PWLSESSION Session)
|
RestoreAllConnections(
|
||||||
|
_In_ PWLSESSION Session)
|
||||||
{
|
{
|
||||||
DWORD dRet;
|
DWORD dRet;
|
||||||
HANDLE hEnum;
|
HANDLE hEnum;
|
||||||
@@ -441,9 +442,7 @@ RestoreAllConnections(PWLSESSION Session)
|
|||||||
|
|
||||||
UserProfile = (Session && Session->UserToken);
|
UserProfile = (Session && Session->UserToken);
|
||||||
if (!UserProfile)
|
if (!UserProfile)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!ImpersonateLoggedOnUser(Session->UserToken))
|
if (!ImpersonateLoggedOnUser(Session->UserToken))
|
||||||
{
|
{
|
||||||
@@ -471,7 +470,7 @@ RestoreAllConnections(PWLSESSION Session)
|
|||||||
dSize = 0x1000;
|
dSize = 0x1000;
|
||||||
dCount = -1;
|
dCount = -1;
|
||||||
|
|
||||||
memset(lpRes, 0, dSize);
|
ZeroMemory(lpRes, dSize);
|
||||||
dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
|
dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
|
||||||
if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
|
if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
|
||||||
{
|
{
|
||||||
@@ -491,6 +490,17 @@ quit:
|
|||||||
RevertToSelf();
|
RevertToSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
CloseAllConnections(
|
||||||
|
_In_ PWLSESSION Session)
|
||||||
|
{
|
||||||
|
if (!Session->UserToken || !ImpersonateLoggedOnUser(Session->UserToken))
|
||||||
|
return;
|
||||||
|
WNetClearConnections(NULL);
|
||||||
|
RevertToSelf();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* Frees the Profile information structure (WLX_PROFILE_V1_0
|
* Frees the Profile information structure (WLX_PROFILE_V1_0
|
||||||
@@ -757,9 +767,6 @@ LogoffShutdownThread(
|
|||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cancel all the user connections */
|
|
||||||
WNetClearConnections(NULL);
|
|
||||||
|
|
||||||
if (UserToken)
|
if (UserToken)
|
||||||
RevertToSelf();
|
RevertToSelf();
|
||||||
|
|
||||||
@@ -1036,15 +1043,18 @@ HandleLogoff(
|
|||||||
|
|
||||||
PlayLogoffShutdownSound(Session, WLX_SHUTTINGDOWN(wlxAction));
|
PlayLogoffShutdownSound(Session, WLX_SHUTTINGDOWN(wlxAction));
|
||||||
|
|
||||||
|
/* Close all user network connections */
|
||||||
|
DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_CLOSINGNETWORKCONNECTIONS);
|
||||||
|
CloseAllConnections(Session);
|
||||||
|
// TODO: Do any other user-specific network-related cleaning:
|
||||||
|
// user-added NetAPI message aliases; user cached credentials (remote login)...
|
||||||
|
|
||||||
SetWindowStationUser(Session->InteractiveWindowStation,
|
SetWindowStationUser(Session->InteractiveWindowStation,
|
||||||
&LuidNone, NULL, 0);
|
&LuidNone, NULL, 0);
|
||||||
|
|
||||||
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOGGINGOFF);
|
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOGGINGOFF);
|
||||||
CallNotificationDlls(Session, LogoffHandler);
|
CallNotificationDlls(Session, LogoffHandler);
|
||||||
|
|
||||||
// FIXME: Closing network connections!
|
|
||||||
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_CLOSINGNETWORKCONNECTIONS);
|
|
||||||
|
|
||||||
/* Kill remaining COM processes that may have been started by logoff scripts */
|
/* Kill remaining COM processes that may have been started by logoff scripts */
|
||||||
hThread = CreateThread(psa, 0, KillComProcesses, (PVOID)Session->UserToken, 0, NULL);
|
hThread = CreateThread(psa, 0, KillComProcesses, (PVOID)Session->UserToken, 0, NULL);
|
||||||
if (hThread)
|
if (hThread)
|
||||||
|
|||||||
Reference in New Issue
Block a user