Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(computer): install beside the Codex Windows sandbox
jeffreyb284500b6487
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex 15abf3d0..aa7e3c56 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -150,6 +150,14 @@ forward slashes, as a lowercase SHA-256 digest. Private files are checked againsthe current SID and ACL, not POSIX permission bits. Writing a separate credentialdoes not change the permissions of an existing parent directory.+The installer and the Daemon refuse a private path when another account can+replace one of its parent directories. One exception applies: the Codex Windows+sandbox may hold that right on a parent, such as AppData. The sandbox acts+through the `CodexSandboxUsers` group and the capability SIDs in+`%USERPROFILE%\.codex\cap_sid`. A sandboxed Codex command can therefore replace+such a parent; Linger accepts this so it installs beside Codex. Private paths+themselves still grant access only to the current user and SYSTEM.+Process recovery uses the creation time and a held process handle, so a reusedprocess ID is never mistaken for the original. Ordinary tasks are held by a JobObject; managed services are held by a separate supervisor process. An upgradediff --git a/apps/computer/local-daemon/internal/platform/privatefs/privatefs_windows.go b/apps/computer/local-daemon/internal/platform/privatefs/privatefs_windows.goindex d28f03bf..220a7244 100644--- a/apps/computer/local-daemon/internal/platform/privatefs/privatefs_windows.go+++ b/apps/computer/local-daemon/internal/platform/privatefs/privatefs_windows.go@@ -3,6 +3,7 @@package privatefsimport (+ "encoding/json""errors""fmt""os"@@ -198,6 +199,7 @@ func validateAncestorDescriptor(sd *windows.SECURITY_DESCRIPTOR, volumeRoot boolif err != nil {return err}+ var sandbox map[string]booltrusted := func(sid *windows.SID) bool {return sid != nil && (windows.EqualSid(sid, user) || sid.IsWellKnown(windows.WinLocalSystemSid) || sid.IsWellKnown(windows.WinBuiltinAdministratorsSid) ||sid.String() == "S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464") // Windows TrustedInstaller@@ -230,13 +232,55 @@ func validateAncestorDescriptor(sd *windows.SECURITY_DESCRIPTOR, volumeRoot boolif volumeRoot {replaceMask &^= windows.DELETE}- if !trusted(sid) && ace.Mask&replaceMask != 0 {- return errors.New("ancestor permits another user to replace private paths")+ if trusted(sid) || ace.Mask&replaceMask == 0 {+ continue+ }+ if sandbox == nil {+ sandbox = codexSandboxSIDs()+ }+ if !sandbox[sid.String()] {+ return fmt.Errorf("ancestor permits another user (%s) to replace private paths", sid.String())}}return nil}+// codexSandboxSIDs returns the principals the Codex Windows sandbox grants on+// its writable roots: the sandbox users group and the capability SIDs Codex+// records in its default home. Linger accepts that a sandboxed Codex+// command may replace an ancestor such as AppData; private paths themselves+// stay owner-only. The set is read on demand so grants Codex adds while the+// Daemon runs are recognized.+func codexSandboxSIDs() map[string]bool {+ sids := map[string]bool{}+ if sid, _, _, err := windows.LookupSID("", "CodexSandboxUsers"); err == nil {+ sids[sid.String()] = true+ }+ profile, err := windows.GetCurrentProcessToken().GetUserProfileDirectory()+ if err != nil {+ return sids+ }+ data, err := os.ReadFile(filepath.Join(profile, ".codex", "cap_sid"))+ if err != nil {+ return sids+ }+ var caps struct {+ Workspace string `json:"workspace"`+ WorkspaceByCWD map[string]string `json:"workspace_by_cwd"`+ WritableRootByPath map[string]string `json:"writable_root_by_path"`+ }+ if json.Unmarshal(data, &caps) != nil {+ return sids+ }+ sids[caps.Workspace] = true+ for _, roots := range []map[string]string{caps.WorkspaceByCWD, caps.WritableRootByPath} {+ for _, sid := range roots {+ sids[sid] = true+ }+ }+ return sids+}+func CheckPath(path, kind string, ownerOnly bool) error {if kind != "file" && kind != "directory" {return errors.New("invalid private path kind")diff --git a/scripts/local-computer-windows-bootstrap.ps1 b/scripts/local-computer-windows-bootstrap.ps1index 7165bb01..cf3135ef 100644--- a/scripts/local-computer-windows-bootstrap.ps1+++ b/scripts/local-computer-windows-bootstrap.ps1@@ -155,6 +155,23 @@ function Write-LingerNote([string]$Text) {# seconds. Only a fully successful walk is remembered.$LingerTrustedDirectories = @{}+# The Codex Windows sandbox grants its sandbox users group and the capability+# SIDs recorded in its default home write access to its writable roots, which+# can include AppData. Linger accepts that a sandboxed Codex command may replace+# such an ancestor; product paths themselves stay private to the user.+function Get-LingerCodexSandboxSids {+ $sids = @()+ try { $sids += (New-Object Security.Principal.NTAccount('CodexSandboxUsers')).Translate([Security.Principal.SecurityIdentifier]).Value } catch {}+ $capFile = Join-Path ([Environment]::GetFolderPath('UserProfile')) '.codex\cap_sid'+ try { $caps = [IO.File]::ReadAllText($capFile) | ConvertFrom-Json } catch { return $sids }+ if ($caps.workspace) { $sids += [string]$caps.workspace }+ foreach ($roots in @($caps.workspace_by_cwd, $caps.writable_root_by_path)) {+ if ($roots) { $sids += @($roots.PSObject.Properties | ForEach-Object { [string]$_.Value }) }+ }+ return $sids+}+$LingerCodexSandboxSids = @(Get-LingerCodexSandboxSids)+function Assert-LingerAncestors([string]$Path) {$cursor = Get-LingerFullPath $Path$walked = @()@@ -176,8 +193,9 @@ function Assert-LingerAncestors([string]$Path) {# remain protected by the FILE_DELETE_CHILD and ACL-change checks.if ($cursor -eq [IO.Path]::GetPathRoot($cursor)) { $replaceRights = $replaceRights -band (-bnot 0x00010000) }if (-not $inheritOnly -and $access.AccessControlType -eq [Security.AccessControl.AccessControlType]::Allow -and- $access.IdentityReference.Value -notin $trustedOwners -and ([int]$access.FileSystemRights -band $replaceRights) -ne 0) {- throw "Install ancestor can be replaced by another user: $cursor"+ $access.IdentityReference.Value -notin $trustedOwners -and $access.IdentityReference.Value -notin $LingerCodexSandboxSids -and+ ([int]$access.FileSystemRights -band $replaceRights) -ne 0) {+ throw "Install ancestor can be replaced by another user ($($access.IdentityReference.Value)): $cursor"}}$parent = [IO.Path]::GetDirectoryName($cursor)