Repository navigation
fix(service): scope the Windows logon trigger and stop blaming elevation for the denial #4483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2303,9 +2303,12 @@ export function buildWindowsTaskXml( | |
| // keeps spaces intact, and /b (batch mode) suppresses script error popups. | ||
| const escapedLauncherArgs = taskXmlString(`/b /nologo "${launcher}"`); | ||
| // `UserId` is optional in the schema, and omitting it makes a SessionStateChangeTrigger | ||
| // fire for ANY account's session change. Production registration resolves and passes the | ||
| // installing account SID explicitly; the optional parameter remains only for deterministic | ||
| // builders/tests, and the live validator rejects an unscoped recovery trigger. | ||
| // fire for ANY account's session change. An unscoped LogonTrigger is read as "any user's | ||
| // logon", which a non-elevated user may not register: schtasks /create answers "Access is | ||
| // denied" for a task whose design (InteractiveToken + LeastPrivilege) needs no elevation | ||
| // (#4425). Production registration resolves and passes the installing account SID | ||
| // explicitly; the optional parameter remains only for deterministic builders/tests, and | ||
| // the live validator rejects an unscoped recovery trigger. | ||
| const sessionUserIdElement = sessionTriggerUserId | ||
| ? `\n <UserId>${taskXmlString(sessionTriggerUserId)}</UserId>` | ||
| : ""; | ||
|
|
@@ -2316,7 +2319,7 @@ export function buildWindowsTaskXml( | |
| </RegistrationInfo> | ||
| <Triggers> | ||
| <LogonTrigger> | ||
| <Enabled>true</Enabled> | ||
| <Enabled>true</Enabled>${sessionUserIdElement} | ||
| </LogonTrigger> | ||
|
Comment on lines
2321
to
2323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This changes the Windows Task Scheduler service contract in AGENTS.md reference: src/AGENTS.md:L10-L11 Useful? React with 👍 / 👎. |
||
| ${WINDOWS_SESSION_RECOVERY_STATE_CHANGES.map(stateChange => `<SessionStateChangeTrigger> | ||
| <Enabled>true</Enabled>${sessionUserIdElement} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guidance is selected for every access-denied
schtasksinvocation, not just/create;src/service.tsroutes/run,/end,/query, and/deletefailures through the same formatter. For example, an access denial during service uninstall now incorrectly says elevation cannot help and tells the user to retry installation, even though the scoped task definition is irrelevant to deletion and elevated permissions may be the remedy. Branch onoperationand retain create-specific wording only for the owned create case.Useful? React with 👍 / 👎.