mirror of
https://github.com/reactos/reactos
synced 2025-10-06 00:12:51 +02: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
|
||||
VOID
|
||||
RestoreAllConnections(PWLSESSION Session)
|
||||
RestoreAllConnections(
|
||||
_In_ PWLSESSION Session)
|
||||
{
|
||||
DWORD dRet;
|
||||
HANDLE hEnum;
|
||||
@@ -441,9 +442,7 @@ RestoreAllConnections(PWLSESSION Session)
|
||||
|
||||
UserProfile = (Session && Session->UserToken);
|
||||
if (!UserProfile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ImpersonateLoggedOnUser(Session->UserToken))
|
||||
{
|
||||
@@ -471,7 +470,7 @@ RestoreAllConnections(PWLSESSION Session)
|
||||
dSize = 0x1000;
|
||||
dCount = -1;
|
||||
|
||||
memset(lpRes, 0, dSize);
|
||||
ZeroMemory(lpRes, dSize);
|
||||
dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
|
||||
if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
|
||||
{
|
||||
@@ -491,6 +490,17 @@ quit:
|
||||
RevertToSelf();
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
CloseAllConnections(
|
||||
_In_ PWLSESSION Session)
|
||||
{
|
||||
if (!Session->UserToken || !ImpersonateLoggedOnUser(Session->UserToken))
|
||||
return;
|
||||
WNetClearConnections(NULL);
|
||||
RevertToSelf();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Frees the Profile information structure (WLX_PROFILE_V1_0
|
||||
@@ -757,9 +767,6 @@ LogoffShutdownThread(
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
/* Cancel all the user connections */
|
||||
WNetClearConnections(NULL);
|
||||
|
||||
if (UserToken)
|
||||
RevertToSelf();
|
||||
|
||||
@@ -1036,15 +1043,18 @@ HandleLogoff(
|
||||
|
||||
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,
|
||||
&LuidNone, NULL, 0);
|
||||
|
||||
// DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOGGINGOFF);
|
||||
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 */
|
||||
hThread = CreateThread(psa, 0, KillComProcesses, (PVOID)Session->UserToken, 0, NULL);
|
||||
if (hThread)
|
||||
|
Reference in New Issue
Block a user