Adopt common v0.8.0 and preserve canceled hardware settings

This commit is contained in:
Storm Dragon committed 2026-11-16 20:10:47 -05:00
1 parent b21fceb311
commit 5dfa038706
410 files changed
+5353 -4803

No files matched your search

+1 -1
View File
@@ -126,7 +126,7 @@ func TestHelperReadinessBypassesDiagnosticBackpressure(t *testing.T) {
t.Fatalf("readiness publications before logging = %d, want 1", readyCount)
}
manager := New(nil)
if !manager.restart_running_helper(child, prefix{}, Settings{}) || !manager.helper_unconfirmed("helper") {
if !manager.restartRunningHelper(child, prefix{}, Settings{}) || !manager.helperUnconfirmed("helper") {
t.Fatal("lost exclusion mismatch fallback under diagnostic backpressure")
}
output.finish()
+1 -1
View File
@@ -28,7 +28,7 @@ type helperFile struct {
// A pressure-vessel wineserver cannot see the host's /usr. Publish complete,
// immutable helper sets in the home-mounted state directory. Never overwrite
// an older set: running processes may still have its sidecar mapped.
func stage_helper(helper string, environment map[string]string) (string, error) {
func stageHelper(helper string, environment map[string]string) (string, error) {
if _, present := environment["PRESSURE_VESSEL_RUNTIME"]; !present {
return helper, nil
}
+4 -4
View File
@@ -19,15 +19,15 @@ func TestManagerReadsSettingsSourceAtEachPoll(t *testing.T) {
root := t.TempDir()
procRoot := filepath.Join(root, "proc")
loader := filepath.Join(root, "wine")
write_helper_file(t, loader, "loader")
writeHelperFile(t, loader, "loader")
base := filepath.Join(procRoot, "101")
write_helper_file(t, filepath.Join(base, "cmdline"), "launcher.exe\x00")
write_helper_file(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
writeHelperFile(t, filepath.Join(base, "cmdline"), "launcher.exe\x00")
writeHelperFile(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
if err := os.Symlink(loader, filepath.Join(base, "exe")); err != nil {
t.Fatal(err)
}
helper := filepath.Join(root, "helper")
write_helper_file(t, helper, "#!/bin/sh\nexec sleep 30\n")
writeHelperFile(t, helper, "#!/bin/sh\nexec sleep 30\n")
current := Settings{}
reads := 0
+18 -18
View File
@@ -73,13 +73,13 @@ type Manager struct {
unconfirmed map[string]bool
}
func (manager *Manager) helper_unconfirmed(helper string) bool {
func (manager *Manager) helperUnconfirmed(helper string) bool {
manager.unconfirmedMu.Lock()
defer manager.unconfirmedMu.Unlock()
return manager.unconfirmed[helper]
}
func (manager *Manager) mark_unconfirmed(helper string) {
func (manager *Manager) markUnconfirmed(helper string) {
manager.unconfirmedMu.Lock()
defer manager.unconfirmedMu.Unlock()
if manager.unconfirmed == nil {
@@ -177,7 +177,7 @@ func (manager *Manager) run(ctx context.Context) {
}
}
func (manager *Manager) current_settings() Settings {
func (manager *Manager) currentSettings() Settings {
if manager.SettingsSource == nil {
return Settings{}
}
@@ -189,7 +189,7 @@ func (manager *Manager) poll(active map[string]*process) {
// Read the live settings once per poll. Restart decisions and every
// spawn in this poll use this snapshot, so a value applied between
// polls governs the next poll and spawn without a reader restart.
settings := manager.current_settings()
settings := manager.currentSettings()
discovered := discover(manager.procRoot, uint32(os.Getuid()))
for path, source := range discovered {
child := active[path]
@@ -209,7 +209,7 @@ func (manager *Manager) poll(active map[string]*process) {
child.next = now.Add(backoff(child.failures))
child.cmd = nil
default:
if manager.restart_running_helper(child, source, settings) {
if manager.restartRunningHelper(child, source, settings) {
stop(child)
} else {
continue
@@ -233,19 +233,19 @@ func (manager *Manager) poll(active map[string]*process) {
}
}
// restart_running_helper decides whether a running helper must restart to
// restartRunningHelper decides whether a running helper must restart to
// gain protection it lacks. Restarts only ever add protection: a wholesale
// helper never restarts here, and removing a listing or clearing the
// global switch never downgrades a running helper.
func (manager *Manager) restart_running_helper(child *process, source prefix, settings Settings) bool {
func (manager *Manager) restartRunningHelper(child *process, source prefix, settings Settings) bool {
if child.controllerOnly {
return false
}
if wholesale_controller_only(settings) || manager.helper_unconfirmed(child.launchedHelper) {
if wholesaleControllerOnly(settings) || manager.helperUnconfirmed(child.launchedHelper) {
return true
}
if child.readySeen.Load() && int(child.readyExclusions.Load()) != len(child.exclusions) {
manager.mark_unconfirmed(child.launchedHelper)
manager.markUnconfirmed(child.launchedHelper)
manager.logger.Warn("Wine accessibility helper did not confirm hook exclusions; restarting without dialog reading",
"sent", len(child.exclusions), "reported", child.readyExclusions.Load())
return true
@@ -253,7 +253,7 @@ func (manager *Manager) restart_running_helper(child *process, source prefix, se
// A newly listed program that is currently discovered but lacks its
// flag restarts the helper once, in the same mode, now carrying it.
// Listings for programs that are not running wait for the next spawn.
for _, name := range exclusion_names(settings) {
for _, name := range exclusionNames(settings) {
if source.programs[name] && !child.exclusions[name] {
return true
}
@@ -269,13 +269,13 @@ func backoff(failures int) time.Duration {
}
func (manager *Manager) launch(child *process, source prefix, now time.Time, settings Settings) error {
helper, err := stage_helper(manager.helper, source.environment)
helper, err := stageHelper(manager.helper, source.environment)
if err != nil {
return err
}
controllerOnly := child.controllerOnly || wholesale_controller_only(settings) ||
manager.helper_unconfirmed(helper)
arguments := helper_arguments(controllerOnly, settings)
controllerOnly := child.controllerOnly || wholesaleControllerOnly(settings) ||
manager.helperUnconfirmed(helper)
arguments := helperArguments(controllerOnly, settings)
cmd := exec.Command(helper, arguments...)
diagnostics := newHelperDiagnostics()
generation := child.generation.Add(1)
@@ -322,7 +322,7 @@ func (manager *Manager) launch(child *process, source prefix, now time.Time, set
child.controllerOnly = controllerOnly
child.launchedHelper = helper
child.exclusions = make(map[string]bool)
for _, name := range exclusion_names(settings) {
for _, name := range exclusionNames(settings) {
child.exclusions[name] = true
}
logger := manager.logger.With("helper_pid", cmd.Process.Pid)
@@ -472,10 +472,10 @@ func discover(root string, uid uint32) map[string]prefix {
if !filepath.IsAbs(path) {
continue
}
loader := wine_loader(exe, environment["WINELOADER"])
programs := map[string]bool{program_name(string(commandLine)): true}
loader := wineLoader(exe, environment["WINELOADER"])
programs := map[string]bool{programName(string(commandLine)): true}
if previous, ok := result[path]; ok {
previous.programs[program_name(string(commandLine))] = true
previous.programs[programName(string(commandLine))] = true
continue
}
result[path] = prefix{path: path, loader: loader, environment: environment, programs: programs}
+9 -9
View File
@@ -13,12 +13,12 @@ import (
"git.stormux.org/storm/cthulhu/internal/config"
)
func program_name(commandLine string) string {
func programName(commandLine string) string {
name := strings.SplitN(commandLine, "\x00", 2)[0]
return filepath.Base(strings.ReplaceAll(strings.ToLower(strings.TrimSpace(name)), "\\", "/"))
}
func wine_loader(exe, configured string) string {
func wineLoader(exe, configured string) string {
if executable(configured) {
// Protontricks' proxy requires its own runtime environment. Join the
// existing server with the actual Proton loader instead.
@@ -55,13 +55,13 @@ func wine_loader(exe, configured string) string {
return ""
}
// wholesale_controller_only reports whether the whole helper must run
// wholesaleControllerOnly reports whether the whole helper must run
// without dialog reading. Only the global controller-only switch and the
// environment override select it here; a helper binary remembered as
// unconfirmed (see Manager.helper_unconfirmed) is the third trigger. A
// unconfirmed (see Manager.helperUnconfirmed) is the third trigger. A
// listed program by itself never selects wholesale mode: the helper gates
// it natively while other programs in the prefix keep dialog reading.
func wholesale_controller_only(settings Settings) bool {
func wholesaleControllerOnly(settings Settings) bool {
if settings.ControllerOnly {
return true
}
@@ -69,12 +69,12 @@ func wholesale_controller_only(settings Settings) bool {
return override != "" && override != "0"
}
// exclusion_names returns the hook-exclusion program names exactly as the
// exclusionNames returns the hook-exclusion program names exactly as the
// helper will store them: validated at the process boundary, lowercased,
// deduplicated case-insensitively, and sorted. The validation mirrors the
// helper's own rules so the count sent here matches the count its ready
// record reports.
func exclusion_names(settings Settings) []string {
func exclusionNames(settings Settings) []string {
seen := make(map[string]bool, len(settings.ExcludedPrograms))
var names []string
for _, name := range settings.ExcludedPrograms {
@@ -92,9 +92,9 @@ func exclusion_names(settings Settings) []string {
return names
}
func helper_arguments(controllerOnly bool, settings Settings) []string {
func helperArguments(controllerOnly bool, settings Settings) []string {
var arguments []string
for _, name := range exclusion_names(settings) {
for _, name := range exclusionNames(settings) {
arguments = append(arguments, "--exclude-hook-program", name)
}
if controllerOnly {
+28 -28
View File
@@ -13,7 +13,7 @@ import (
"time"
)
func write_helper_file(t *testing.T, path, data string) {
func writeHelperFile(t *testing.T, path, data string) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
@@ -28,11 +28,11 @@ func TestProtonLoaderBypassesProxy(t *testing.T) {
loader := filepath.Join(root, "Proton", "files", "bin", "wine")
preloader := filepath.Join(root, "Proton", "files", "lib", "wine", "i386-unix", "wine64-preloader")
proxy := filepath.Join(root, "proxy", "wine")
write_helper_file(t, loader, "loader")
write_helper_file(t, preloader, "preloader")
write_helper_file(t, proxy, "#!/bin/sh\n# PROTONTRICKS_STEAM_RUNTIME\n")
writeHelperFile(t, loader, "loader")
writeHelperFile(t, preloader, "preloader")
writeHelperFile(t, proxy, "#!/bin/sh\n# PROTONTRICKS_STEAM_RUNTIME\n")
for _, configured := range []string{"", proxy, loader} {
if got := wine_loader(preloader, configured); got != loader {
if got := wineLoader(preloader, configured); got != loader {
t.Fatalf("loader = %q, want %q", got, loader)
}
}
@@ -44,10 +44,10 @@ func TestContainerHelperPublishesImmutableCompleteSets(t *testing.T) {
helper := filepath.Join(root, "installed", "wine-access.exe")
names := []string{"wine-access.exe", "wine-access.exe.so", "wine-access-menu.dll", "wine-access-menu32.dll", "wine-access-menu-host32.exe"}
for _, name := range names {
write_helper_file(t, filepath.Join(filepath.Dir(helper), name), name)
writeHelperFile(t, filepath.Join(filepath.Dir(helper), name), name)
}
environment := map[string]string{"PRESSURE_VESSEL_RUNTIME": "runtime"}
original, err := stage_helper(helper, environment)
original, err := stageHelper(helper, environment)
if err != nil {
t.Fatal(err)
}
@@ -60,8 +60,8 @@ func TestContainerHelperPublishesImmutableCompleteSets(t *testing.T) {
t.Fatalf("incomplete set: %s: %v", name, err)
}
}
write_helper_file(t, helper+".so", "new sidecar")
updated, err := stage_helper(helper, environment)
writeHelperFile(t, helper+".so", "new sidecar")
updated, err := stageHelper(helper, environment)
if err != nil || updated == original {
t.Fatalf("updated set = %q, %v", updated, err)
}
@@ -69,17 +69,17 @@ func TestContainerHelperPublishesImmutableCompleteSets(t *testing.T) {
if string(data) != "wine-access.exe.so" {
t.Fatal("old sidecar overwritten")
}
write_helper_file(t, updated+".so", "tampered")
if _, err := stage_helper(helper, environment); err == nil {
writeHelperFile(t, updated+".so", "tampered")
if _, err := stageHelper(helper, environment); err == nil {
t.Fatal("accepted modified staging")
}
if err := os.Remove(helper + ".so"); err != nil {
t.Fatal(err)
}
if _, err := stage_helper(helper, environment); err == nil {
if _, err := stageHelper(helper, environment); err == nil {
t.Fatal("accepted incomplete source set")
}
if got, err := stage_helper(helper, nil); err != nil || got != helper {
if got, err := stageHelper(helper, nil); err != nil || got != helper {
t.Fatalf("ordinary Wine = %q, %v", got, err)
}
}
@@ -90,23 +90,23 @@ func TestListedProgramDoesNotForceWholesaleMode(t *testing.T) {
// never add the prefix-wide --no-dialog-reader, or ordinary programs in
// the same prefix lose dialog reading.
listed := Settings{ExcludedPrograms: []string{"Game.EXE", "game.exe"}}
if wholesale_controller_only(listed) {
if wholesaleControllerOnly(listed) {
t.Fatal("listed programs selected wholesale mode")
}
arguments := helper_arguments(wholesale_controller_only(listed), listed)
arguments := helperArguments(wholesaleControllerOnly(listed), listed)
if len(arguments) != 2 || arguments[0] != "--exclude-hook-program" || arguments[1] != "game.exe" {
t.Fatalf("mixed-prefix arguments = %v", arguments)
}
global := Settings{ControllerOnly: true, ExcludedPrograms: []string{"Game.exe"}}
if !wholesale_controller_only(global) {
if !wholesaleControllerOnly(global) {
t.Fatal("global controller-only switch ignored")
}
arguments = helper_arguments(true, global)
arguments = helperArguments(true, global)
if arguments[len(arguments)-1] != "--no-dialog-reader" {
t.Fatalf("global arguments = %v", arguments)
}
t.Setenv("WINE_ACCESS_NO_DIALOG_READER", "1")
if !wholesale_controller_only(Settings{}) {
if !wholesaleControllerOnly(Settings{}) {
t.Fatal("environment override ignored")
}
}
@@ -122,7 +122,7 @@ func TestHelperArgumentsValidateProgramNames(t *testing.T) {
"--exclude-hook-program", "café.exe",
"--exclude-hook-program", "game.exe",
}
if got := helper_arguments(false, settings); !reflect.DeepEqual(got, want) {
if got := helperArguments(false, settings); !reflect.DeepEqual(got, want) {
t.Fatalf("validated helper arguments = %q, want %q", got, want)
}
}
@@ -144,7 +144,7 @@ func TestLaunchForwardsProtonSyncAndKeepsReaderBus(t *testing.T) {
root := t.TempDir()
output := filepath.Join(root, "environment")
helper := filepath.Join(root, "helper")
write_helper_file(t, helper, "#!/bin/sh\nenv > \"$TEST_WINE_ENV\"\n")
writeHelperFile(t, helper, "#!/bin/sh\nenv > \"$TEST_WINE_ENV\"\n")
t.Setenv("TEST_WINE_ENV", output)
t.Setenv("DBUS_SESSION_BUS_ADDRESS", "unix:path=/reader/bus")
manager := New(nil)
@@ -176,19 +176,19 @@ func TestDiscoverMixedPrefixKeepsOrdinaryProgramsReadable(t *testing.T) {
root := t.TempDir()
procRoot := filepath.Join(root, "proc")
loader := filepath.Join(root, "wine")
write_helper_file(t, loader, "loader")
writeHelperFile(t, loader, "loader")
makeProcess := func(pid, program string) {
t.Helper()
base := filepath.Join(procRoot, pid)
write_helper_file(t, filepath.Join(base, "cmdline"), program+"\x00")
write_helper_file(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
writeHelperFile(t, filepath.Join(base, "cmdline"), program+"\x00")
writeHelperFile(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
if err := os.Symlink(loader, filepath.Join(base, "exe")); err != nil {
t.Fatal(err)
}
}
makeProcess("101", "launcher.exe")
helper := filepath.Join(root, "helper")
write_helper_file(t, helper, "#!/bin/sh\nexec sleep 30\n")
writeHelperFile(t, helper, "#!/bin/sh\nexec sleep 30\n")
current := Settings{ExcludedPrograms: []string{"GAME.exe"}}
manager := New(nil)
manager.helper, manager.procRoot = helper, procRoot
@@ -279,10 +279,10 @@ func TestUnconfirmedHelperRestartsWholesaleOnceAndIsRemembered(t *testing.T) {
root := t.TempDir()
procRoot := filepath.Join(root, "proc")
loader := filepath.Join(root, "wine")
write_helper_file(t, loader, "loader")
writeHelperFile(t, loader, "loader")
base := filepath.Join(procRoot, "101")
write_helper_file(t, filepath.Join(base, "cmdline"), "launcher.exe\x00")
write_helper_file(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
writeHelperFile(t, filepath.Join(base, "cmdline"), "launcher.exe\x00")
writeHelperFile(t, filepath.Join(base, "environ"), "WINEPREFIX="+root+"\x00")
if err := os.Symlink(loader, filepath.Join(base, "exe")); err != nil {
t.Fatal(err)
}
@@ -291,7 +291,7 @@ func TestUnconfirmedHelperRestartsWholesaleOnceAndIsRemembered(t *testing.T) {
script := "#!/bin/sh\n" +
"echo 'wine-access: ready {\"reader\":\"org.example.Reader\",\"controls_enabled\":true,\"hook_exclusions\":0}' >&2\n" +
"exec sleep 30\n"
write_helper_file(t, helper, script)
writeHelperFile(t, helper, script)
manager := New(nil)
manager.helper, manager.procRoot = helper, procRoot
manager.SettingsSource = func() Settings {