[PR #11222] [MERGED] Add a file for storing elevated-only state #28458

Open
opened 2026-01-31 09:28:39 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11222
Author: @zadjii-msft
Created: 9/14/2021
Status: Merged
Merged: 11/13/2021
Merged by: @lhecker

Base: mainHead: dev/migrie/f/just-elevated-state-2


📝 Commits (10+)

  • 6be6972 This is everything from dev/migrie/f/non-terminal-content-elevation-warning for specifically ElevatedState
  • c106f64 🤦
  • 51e0473 minor nits
  • da0cc7b todo! in the code
  • 4e69a32 bunch of new allowed words
  • 6757452 fix the tests
  • a4acdeb blindly remove ElevatedState
  • 5685063 Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2
  • 9b3b9e0 remove baseapplicationstate and just merge it back in
  • 507a48e Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2

📊 Changes

15 files changed (+511 additions, -265 deletions)

View changed files

📝 .github/actions/spelling/allow/allow.txt (+1 -0)
📝 .github/actions/spelling/allow/apis.txt (+7 -0)
📝 .github/actions/spelling/allow/names.txt (+1 -0)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+21 -38)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+0 -3)
📝 src/cascadia/TerminalSettingsModel/ApplicationState.cpp (+231 -80)
📝 src/cascadia/TerminalSettingsModel/ApplicationState.h (+40 -25)
📝 src/cascadia/TerminalSettingsModel/ApplicationState.idl (+4 -1)
📝 src/cascadia/TerminalSettingsModel/FileUtils.cpp (+137 -82)
📝 src/cascadia/TerminalSettingsModel/FileUtils.h (+3 -33)
📝 src/cascadia/TerminalSettingsModel/JsonUtils.h (+0 -1)
📝 src/cascadia/TerminalSettingsModel/pch.h (+3 -0)
📝 src/cascadia/WindowsTerminal/AppHost.cpp (+30 -2)
📝 src/types/inc/utils.hpp (+1 -0)
📝 src/types/utils.cpp (+32 -0)

📄 Description

Summary of the Pull Request

This creates an elevated-state.json that lives in %LOCALAPPDATA% next to state.json, that's only writable when elevated. It doesn't use this file for anything, it just puts the framework down for use later.

It's just like ApplicationState. We'll use it the same way.

It's readable when unelevated, which is nice, but not writable. If you're dumb and try to write to the file when unelevated, it'll just silently do nothing.

If we try opening the file and find out the permissions are different, we'll blow the file away entirely. This is to prevent someone from renaming the original file (which they can do unelevated), then slapping a new file that's writable by them down in it's place.

References

  • We're going to use this in #11096, but these PRs need to be broken up.

PR Checklist

  • Closes nothing
  • I work here
  • Tests added/passed
  • Requires documentation to be updated - maybe? not sure we have docs on state.json at all yet

Validation Steps Performed

I've played with this much more in dev/migrie/f/non-terminal-content-elevation-warning

followed by #11308, #11310

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11222 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 9/14/2021 **Status:** ✅ Merged **Merged:** 11/13/2021 **Merged by:** [@lhecker](https://github.com/lhecker) **Base:** `main` ← **Head:** `dev/migrie/f/just-elevated-state-2` --- ### 📝 Commits (10+) - [`6be6972`](https://github.com/microsoft/terminal/commit/6be697221d6c2b0099535cc9ac9fce5ab5e97f8d) This is everything from dev/migrie/f/non-terminal-content-elevation-warning for specifically ElevatedState - [`c106f64`](https://github.com/microsoft/terminal/commit/c106f64bc7f07b46a315593d7b86a9efbde92120) :facepalm: - [`51e0473`](https://github.com/microsoft/terminal/commit/51e0473560aacf68884817308a8d14624c72808a) minor nits - [`da0cc7b`](https://github.com/microsoft/terminal/commit/da0cc7bae56998878062b0ea98d70a013f9c78cb) todo! in the code - [`4e69a32`](https://github.com/microsoft/terminal/commit/4e69a32de765590e459cbb9fcb84b2adbe56377c) bunch of new allowed words - [`6757452`](https://github.com/microsoft/terminal/commit/6757452d6d051839771dbf1bdf4925c105184ba2) fix the tests - [`a4acdeb`](https://github.com/microsoft/terminal/commit/a4acdeb5f20dd85f9d32c4ff8d3cc59a5718bbb3) blindly remove ElevatedState - [`5685063`](https://github.com/microsoft/terminal/commit/56850639c5c969b7f8fff53b8092a31bdd1c652f) Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2 - [`9b3b9e0`](https://github.com/microsoft/terminal/commit/9b3b9e010928ddb16d8d37393c6516ade03c04c3) remove baseapplicationstate and just merge it back in - [`507a48e`](https://github.com/microsoft/terminal/commit/507a48ed68a6f536bad018e01f01daeae8289ae4) Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-elevated-state-2 ### 📊 Changes **15 files changed** (+511 additions, -265 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/allow.txt` (+1 -0) 📝 `.github/actions/spelling/allow/apis.txt` (+7 -0) 📝 `.github/actions/spelling/allow/names.txt` (+1 -0) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+21 -38) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+0 -3) 📝 `src/cascadia/TerminalSettingsModel/ApplicationState.cpp` (+231 -80) 📝 `src/cascadia/TerminalSettingsModel/ApplicationState.h` (+40 -25) 📝 `src/cascadia/TerminalSettingsModel/ApplicationState.idl` (+4 -1) 📝 `src/cascadia/TerminalSettingsModel/FileUtils.cpp` (+137 -82) 📝 `src/cascadia/TerminalSettingsModel/FileUtils.h` (+3 -33) 📝 `src/cascadia/TerminalSettingsModel/JsonUtils.h` (+0 -1) 📝 `src/cascadia/TerminalSettingsModel/pch.h` (+3 -0) 📝 `src/cascadia/WindowsTerminal/AppHost.cpp` (+30 -2) 📝 `src/types/inc/utils.hpp` (+1 -0) 📝 `src/types/utils.cpp` (+32 -0) </details> ### 📄 Description ## Summary of the Pull Request This creates an `elevated-state.json` that lives in `%LOCALAPPDATA%` next to `state.json`, that's only writable when elevated. It doesn't _use_ this file for anything, it just puts the framework down for use later. It's _just like `ApplicationState`_. We'll use it the same way. It's readable when unelevated, which is nice, but not writable. If you're dumb and try to write to the file when unelevated, it'll just silently do nothing. If we try opening the file and find out the permissions are different, we'll _blow the file away entirely_. This is to prevent someone from renaming the original file (which they can do unelevated), then slapping a new file that's writable by them down in it's place. ## References * We're going to use this in #11096, but these PRs need to be broken up. ## PR Checklist * [x] Closes nothing * [x] I work here * [x] Tests added/passed * [ ] Requires documentation to be updated - maybe? not sure we have docs on `state.json` at all yet ## Validation Steps Performed I've played with this much more in `dev/migrie/f/non-terminal-content-elevation-warning` ###### followed by #11308, #11310 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:28:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28458