refactor: simplify path policy and TUI reducers
hermetic-ci / test (push) Canceled after 0s

This commit is contained in:
proxyctl coordinator
2026-08-30 11:17:41 +08:00
parent 8928986830
commit 2786b03b96
9 changed files with 189 additions and 117 deletions
+2 -18
View File
@@ -20,6 +20,7 @@ import (
"syscall"
"unicode/utf8"
"proxyctl/internal/pathutil"
"proxyctl/internal/profile"
"proxyctl/internal/securefs"
"proxyctl/internal/target"
@@ -194,24 +195,7 @@ func ResolveConfiguration(environment profile.IdentityEnvironment) (Configuratio
return Configuration{CommandName: "gsettings", UID: owner.UID, GID: owner.GID, Username: owner.Username, HomeDir: owner.HomeDir, ConfigDir: configDir, DataDir: dataDir, CacheDir: cacheDir, RuntimeDir: runtimeDir, SessionBus: sessionBus, StateFile: filepath.Join(stateDir, "proxyctl", "gnome.json"), TrustedRoot: trustedRoot}, nil
}
func ResolveConfigurationForCurrentProcess() (Configuration, error) {
return ResolveConfiguration(systemEnvironment{})
}
type systemEnvironment struct{}
func (systemEnvironment) CurrentUser() (profile.UserIdentity, error) {
return profile.SystemCurrentUser()
}
func (systemEnvironment) LookupUser(name string) (profile.UserIdentity, error) {
return profile.SystemLookupUser(name)
}
func (systemEnvironment) LookupEnv(name string) (string, bool) { return os.LookupEnv(name) }
func pathWithin(path, parent string) bool {
relative, err := filepath.Rel(parent, path)
return err == nil && relative != ".." && !strings.HasPrefix(relative, ".."+string(filepath.Separator))
}
func pathWithin(path, parent string) bool { return pathutil.Within(path, parent) }
type settings struct {
Mode string `json:"mode"`