mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
Use the profile returned by GINA before calling LoadUserProfileW()
Destroy the environment when not needed anymore Better cleanup in case of error svn path=/trunk/; revision=28316
This commit is contained in:
parent
e65bdff8a0
commit
92e384aee9
2 changed files with 62 additions and 53 deletions
|
@ -37,6 +37,7 @@ StartTaskManager(
|
||||||
IN OUT PWLSESSION Session)
|
IN OUT PWLSESSION Session)
|
||||||
{
|
{
|
||||||
LPVOID lpEnvironment;
|
LPVOID lpEnvironment;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
if (!Session->Gina.Functions.WlxStartApplication)
|
if (!Session->Gina.Functions.WlxStartApplication)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -49,11 +50,14 @@ StartTaskManager(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Session->Gina.Functions.WlxStartApplication(
|
ret = Session->Gina.Functions.WlxStartApplication(
|
||||||
Session->Gina.Context,
|
Session->Gina.Context,
|
||||||
L"Default",
|
L"Default",
|
||||||
lpEnvironment,
|
lpEnvironment,
|
||||||
L"taskmgr.exe");
|
L"taskmgr.exe");
|
||||||
|
|
||||||
|
DestroyEnvironmentBlock(lpEnvironment);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
@ -167,26 +171,41 @@ static BOOL
|
||||||
HandleLogon(
|
HandleLogon(
|
||||||
IN OUT PWLSESSION Session)
|
IN OUT PWLSESSION Session)
|
||||||
{
|
{
|
||||||
PROFILEINFOW ProfileInfo = { 0, };
|
PROFILEINFOW ProfileInfo;
|
||||||
LPVOID lpEnvironment = NULL;
|
LPVOID lpEnvironment = NULL;
|
||||||
BOOLEAN Old;
|
BOOLEAN Old;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
/* Loading personal settings */
|
||||||
|
DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS);
|
||||||
|
ProfileInfo.hProfile = INVALID_HANDLE_VALUE;
|
||||||
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
||||||
{
|
{
|
||||||
|
if (Session->Profile == NULL
|
||||||
|
|| (Session->Profile->dwType != WLX_PROFILE_TYPE_V1_0
|
||||||
|
&& Session->Profile->dwType != WLX_PROFILE_TYPE_V2_0))
|
||||||
|
{
|
||||||
|
ERR("WL: Wrong profile\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load the user profile */
|
/* Load the user profile */
|
||||||
|
ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW));
|
||||||
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
||||||
ProfileInfo.dwFlags = 0;
|
ProfileInfo.dwFlags = 0;
|
||||||
ProfileInfo.lpUserName = Session->MprNotifyInfo.pszUserName;
|
ProfileInfo.lpUserName = Session->MprNotifyInfo.pszUserName;
|
||||||
ProfileInfo.lpProfilePath = Session->Profile.pszProfile;
|
ProfileInfo.lpProfilePath = Session->Profile->pszProfile;
|
||||||
ProfileInfo.lpDefaultPath = Session->Profile.pszNetworkDefaultUserProfile;
|
if (Session->Profile->dwType >= WLX_PROFILE_TYPE_V2_0)
|
||||||
ProfileInfo.lpServerName = Session->Profile.pszServerName;
|
{
|
||||||
ProfileInfo.lpPolicyPath = Session->Profile.pszPolicy;
|
ProfileInfo.lpDefaultPath = Session->Profile->pszNetworkDefaultUserProfile;
|
||||||
ProfileInfo.hProfile = NULL;
|
ProfileInfo.lpServerName = Session->Profile->pszServerName;
|
||||||
|
ProfileInfo.lpPolicyPath = Session->Profile->pszPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
|
if (!LoadUserProfileW(Session->UserToken, &ProfileInfo))
|
||||||
{
|
{
|
||||||
ERR("WL: LoadUserProfileW() failed\n");
|
ERR("WL: LoadUserProfileW() failed\n");
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,16 +215,12 @@ HandleLogon(
|
||||||
Session->UserToken,
|
Session->UserToken,
|
||||||
TRUE))
|
TRUE))
|
||||||
{
|
{
|
||||||
ERR("WL: CreateEnvironmentBlock() failed\n");
|
WARN("WL: CreateEnvironmentBlock() failed\n");
|
||||||
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
goto cleanup;
|
||||||
{
|
|
||||||
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
|
||||||
CloseHandle(Session->UserToken);
|
|
||||||
Session->UserToken = NULL;
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
/* FIXME: Append variables of Session->Profile->pszEnvironment */
|
||||||
}
|
|
||||||
/* FIXME: use Session->Profile.pszEnvironment */
|
//DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
|
||||||
/* FIXME: UpdatePerUserSystemParameters(0, TRUE); */
|
/* FIXME: UpdatePerUserSystemParameters(0, TRUE); */
|
||||||
|
|
||||||
/* Get privilege */
|
/* Get privilege */
|
||||||
|
@ -213,19 +228,11 @@ HandleLogon(
|
||||||
/* FIXME: reverting to lower privileges after creating user shell? */
|
/* FIXME: reverting to lower privileges after creating user shell? */
|
||||||
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old);
|
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old);
|
||||||
|
|
||||||
//DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_LOADINGYOURPERSONALSETTINGS);
|
|
||||||
//DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
|
|
||||||
|
|
||||||
/* Set default language */
|
/* Set default language */
|
||||||
if (!SetDefaultLanguage(TRUE))
|
if (!SetDefaultLanguage(TRUE))
|
||||||
{
|
{
|
||||||
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
WARN("WL: SetDefaultLanguage() failed\n");
|
||||||
{
|
goto cleanup;
|
||||||
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
|
||||||
CloseHandle(Session->UserToken);
|
|
||||||
Session->UserToken = NULL;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Session->Gina.Functions.WlxActivateUserShell(
|
if (!Session->Gina.Functions.WlxActivateUserShell(
|
||||||
|
@ -234,34 +241,36 @@ HandleLogon(
|
||||||
NULL, /* FIXME */
|
NULL, /* FIXME */
|
||||||
lpEnvironment))
|
lpEnvironment))
|
||||||
{
|
{
|
||||||
if (0 == (Session->Options & WLX_LOGON_OPT_NO_PROFILE))
|
//WCHAR StatusMsg[256];
|
||||||
{
|
WARN("WL: WlxActivateUserShell() failed\n");
|
||||||
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
//LoadStringW(hAppInstance, IDS_FAILEDACTIVATEUSERSHELL, StatusMsg, sizeof(StatusMsg));
|
||||||
CloseHandle(Session->UserToken);
|
//MessageBoxW(0, StatusMsg, NULL, MB_ICONERROR);
|
||||||
Session->UserToken = NULL;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
/*if(!GinaInst->Functions->WlxActivateUserShell(GinaInst->Context,
|
|
||||||
L"WinSta0\\Default",
|
|
||||||
NULL,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
LoadString(hAppInstance, IDS_FAILEDACTIVATEUSERSHELL, StatusMsg, 256 * sizeof(WCHAR));
|
|
||||||
MessageBox(0, StatusMsg, NULL, MB_ICONERROR);
|
|
||||||
SetEvent(hShutdownEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
WaitForSingleObject(hShutdownEvent, INFINITE);
|
|
||||||
CloseHandle(hShutdownEvent);
|
|
||||||
|
|
||||||
RemoveStatusMessage(Session);
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!InitializeScreenSaver(Session))
|
if (!InitializeScreenSaver(Session))
|
||||||
WARN("WL: Failed to initialize screen saver\n");
|
WARN("WL: Failed to initialize screen saver\n");
|
||||||
|
|
||||||
return TRUE;
|
Session->hProfileInfo = ProfileInfo.hProfile;
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
HeapFree(GetProcessHeap(), 0, Session->Profile);
|
||||||
|
Session->Profile = NULL;
|
||||||
|
if (!ret
|
||||||
|
&& ProfileInfo.hProfile != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
|
||||||
|
}
|
||||||
|
if (lpEnvironment)
|
||||||
|
DestroyEnvironmentBlock(lpEnvironment);
|
||||||
|
RemoveStatusMessage(Session);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
Session->UserToken = NULL;
|
||||||
|
CloseHandle(Session->UserToken);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EWX_ACTION_MASK 0xffffffeb
|
#define EWX_ACTION_MASK 0xffffffeb
|
||||||
|
@ -347,7 +356,7 @@ HandleLogoff(
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//UnloadUserProfile(Session->UserToken, ProfileInfo.hProfile);
|
//UnloadUserProfile(Session->UserToken, Session->hProfileInfo);
|
||||||
//CloseHandle(Session->UserToken);
|
//CloseHandle(Session->UserToken);
|
||||||
//UpdatePerUserSystemParameters(0, FALSE);
|
//UpdatePerUserSystemParameters(0, FALSE);
|
||||||
Session->LogonStatus = WKSTA_IS_LOGGED_OFF;
|
Session->LogonStatus = WKSTA_IS_LOGGED_OFF;
|
||||||
|
@ -562,7 +571,6 @@ DispatchSAS(
|
||||||
{
|
{
|
||||||
PSID LogonSid = NULL; /* FIXME */
|
PSID LogonSid = NULL; /* FIXME */
|
||||||
|
|
||||||
ZeroMemory(&Session->Profile, sizeof(Session->Profile));
|
|
||||||
Session->Options = 0;
|
Session->Options = 0;
|
||||||
|
|
||||||
wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS(
|
wlxAction = (DWORD)Session->Gina.Functions.WlxLoggedOutSAS(
|
||||||
|
|
|
@ -134,6 +134,7 @@ typedef struct _WLSESSION
|
||||||
HDESK ScreenSaverDesktop;
|
HDESK ScreenSaverDesktop;
|
||||||
LUID LogonId;
|
LUID LogonId;
|
||||||
HANDLE UserToken;
|
HANDLE UserToken;
|
||||||
|
HANDLE hProfileInfo;
|
||||||
DWORD LogonStatus;
|
DWORD LogonStatus;
|
||||||
DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
|
DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ typedef struct _WLSESSION
|
||||||
/* Logon informations */
|
/* Logon informations */
|
||||||
DWORD Options;
|
DWORD Options;
|
||||||
WLX_MPR_NOTIFY_INFO MprNotifyInfo;
|
WLX_MPR_NOTIFY_INFO MprNotifyInfo;
|
||||||
WLX_PROFILE_V2_0 Profile;
|
WLX_PROFILE_V2_0 *Profile;
|
||||||
} WLSESSION, *PWLSESSION;
|
} WLSESSION, *PWLSESSION;
|
||||||
|
|
||||||
extern HINSTANCE hAppInstance;
|
extern HINSTANCE hAppInstance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue