Skip to content

Commit 2aaa0b9

Browse files
committed
[winlogon]
- Implement restarting the shell in case of a failure. kudos to hpoussin svn path=/trunk/; revision=51520
1 parent 5f8889d commit 2aaa0b9

File tree

1 file changed

+50
-21
lines changed
  • reactos/base/system/winlogon

1 file changed

+50
-21
lines changed

reactos/base/system/winlogon/sas.c

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,37 @@ StartTaskManager(
5555
return ret;
5656
}
5757

58+
static BOOL
59+
StartUserShell(
60+
IN OUT PWLSESSION Session)
61+
{
62+
LPVOID lpEnvironment = NULL;
63+
BOOLEAN Old;
64+
BOOL ret;
65+
66+
/* Create environment block for the user */
67+
if (!CreateEnvironmentBlock(&lpEnvironment, Session->UserToken, TRUE))
68+
{
69+
WARN("WL: CreateEnvironmentBlock() failed\n");
70+
return FALSE;
71+
}
72+
73+
/* Get privilege */
74+
/* FIXME: who should do it? winlogon or gina? */
75+
/* FIXME: reverting to lower privileges after creating user shell? */
76+
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old);
77+
78+
ret = Session->Gina.Functions.WlxActivateUserShell(
79+
Session->Gina.Context,
80+
L"Default",
81+
NULL, /* FIXME */
82+
lpEnvironment);
83+
84+
DestroyEnvironmentBlock(lpEnvironment);
85+
return ret;
86+
}
87+
88+
5889
BOOL
5990
SetDefaultLanguage(
6091
IN BOOL UserProfile)
@@ -167,8 +198,6 @@ HandleLogon(
167198
IN OUT PWLSESSION Session)
168199
{
169200
PROFILEINFOW ProfileInfo;
170-
LPVOID lpEnvironment = NULL;
171-
BOOLEAN Old;
172201
BOOL ret = FALSE;
173202

174203
/* Loading personal settings */
@@ -211,13 +240,6 @@ HandleLogon(
211240
goto cleanup;
212241
}
213242

214-
/* Create environment block for the user */
215-
if (!CreateEnvironmentBlock(&lpEnvironment, Session->UserToken, TRUE))
216-
{
217-
WARN("WL: CreateEnvironmentBlock() failed\n");
218-
goto cleanup;
219-
}
220-
221243
DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_APPLYINGYOURPERSONALSETTINGS);
222244
UpdatePerUserSystemParameters(0, TRUE);
223245

@@ -228,16 +250,7 @@ HandleLogon(
228250
goto cleanup;
229251
}
230252

231-
/* Get privilege */
232-
/* FIXME: who should do it? winlogon or gina? */
233-
/* FIXME: reverting to lower privileges after creating user shell? */
234-
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &Old);
235-
236-
if (!Session->Gina.Functions.WlxActivateUserShell(
237-
Session->Gina.Context,
238-
L"Default",
239-
NULL, /* FIXME */
240-
lpEnvironment))
253+
if (!StartUserShell(Session))
241254
{
242255
//WCHAR StatusMsg[256];
243256
WARN("WL: WlxActivateUserShell() failed\n");
@@ -264,8 +277,6 @@ HandleLogon(
264277
{
265278
UnloadUserProfile(WLSession->UserToken, ProfileInfo.hProfile);
266279
}
267-
if (lpEnvironment)
268-
DestroyEnvironmentBlock(lpEnvironment);
269280
RemoveStatusMessage(Session);
270281
if (!ret)
271282
{
@@ -942,12 +953,30 @@ SASWindowProc(
942953
{
943954
return HandleMessageBeep(lParam);
944955
}
956+
case LN_SHELL_EXITED:
957+
{
958+
/* lParam is the exit code */
959+
if(lParam != 1)
960+
{
961+
SetTimer(hwndDlg, 1, 1000, NULL);
962+
}
963+
break;
964+
}
945965
default:
946966
{
947967
ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam);
948968
}
949969
}
950970
return 0;
971+
}
972+
case WM_TIMER:
973+
{
974+
if (wParam == 1)
975+
{
976+
KillTimer(hwndDlg, 1);
977+
StartUserShell(Session);
978+
}
979+
break;
951980
}
952981
case WLX_WM_SAS:
953982
{

0 commit comments

Comments
 (0)