diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-04-13 03:23:28 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-04-13 03:30:19 +0900 |
| commit | 31b7ddd122d54c36edb101d2c8bdf230651f27d4 (patch) | |
| tree | 2dd0623bfa0d410d83aabfc51d276df3a14ef3e8 /cmd/fpkg/app.go | |
| parent | c460892cbdfa66a2cf1f0ebcec59cf550e67962e (diff) | |
fst: improve config
The config struct more or less "grew" to what it is today. This change moves things around to make more sense and fixes nonsensical comments describing obsolete behaviour.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/fpkg/app.go')
| -rw-r--r-- | cmd/fpkg/app.go | 90 |
1 files changed, 47 insertions, 43 deletions
diff --git a/cmd/fpkg/app.go b/cmd/fpkg/app.go index facf2dc2..72468700 100644 --- a/cmd/fpkg/app.go +++ b/cmd/fpkg/app.go @@ -19,7 +19,7 @@ type appInfo struct { // passed through to [fst.Config] ID string `json:"id"` // passed through to [fst.Config] - AppID int `json:"app_id"` + Identity int `json:"identity"` // passed through to [fst.Config] Groups []string `json:"groups,omitempty"` // passed through to [fst.Config] @@ -64,57 +64,61 @@ type appInfo struct { func (app *appInfo) toFst(pathSet *appPathSet, argv []string, flagDropShell bool) *fst.Config { config := &fst.Config{ - ID: app.ID, + ID: app.ID, + Path: argv[0], Args: argv, - Confinement: fst.ConfinementConfig{ - AppID: app.AppID, - Groups: app.Groups, - Username: "fortify", - Inner: path.Join("/data/data", app.ID), - Outer: pathSet.homeDir, - Shell: shellPath, - Sandbox: &fst.SandboxConfig{ - Hostname: formatHostname(app.Name), - Devel: app.Devel, - Userns: app.Userns, - Net: app.Net, - Device: app.Device, - Tty: app.Tty || flagDropShell, - MapRealUID: app.MapRealUID, - DirectWayland: app.DirectWayland, - Filesystem: []*fst.FilesystemConfig{ - {Src: path.Join(pathSet.nixPath, "store"), Dst: "/nix/store", Must: true}, - {Src: pathSet.metaPath, Dst: path.Join(fst.Tmp, "app"), Must: true}, - {Src: "/etc/resolv.conf"}, - {Src: "/sys/block"}, - {Src: "/sys/bus"}, - {Src: "/sys/class"}, - {Src: "/sys/dev"}, - {Src: "/sys/devices"}, - }, - Link: [][2]string{ - {app.CurrentSystem, "/run/current-system"}, - {"/run/current-system/sw/bin", "/bin"}, - {"/run/current-system/sw/bin", "/usr/bin"}, - }, - Etc: path.Join(pathSet.cacheDir, "etc"), - AutoEtc: true, + + Enablements: app.Enablements, + + SystemBus: app.SystemBus, + SessionBus: app.SessionBus, + DirectWayland: app.DirectWayland, + + Username: "fortify", + Shell: shellPath, + Data: pathSet.homeDir, + Dir: path.Join("/data/data", app.ID), + + Identity: app.Identity, + Groups: app.Groups, + + Container: &fst.ContainerConfig{ + Hostname: formatHostname(app.Name), + Devel: app.Devel, + Userns: app.Userns, + Net: app.Net, + Device: app.Device, + Tty: app.Tty || flagDropShell, + MapRealUID: app.MapRealUID, + Filesystem: []*fst.FilesystemConfig{ + {Src: path.Join(pathSet.nixPath, "store"), Dst: "/nix/store", Must: true}, + {Src: pathSet.metaPath, Dst: path.Join(fst.Tmp, "app"), Must: true}, + {Src: "/etc/resolv.conf"}, + {Src: "/sys/block"}, + {Src: "/sys/bus"}, + {Src: "/sys/class"}, + {Src: "/sys/dev"}, + {Src: "/sys/devices"}, }, - ExtraPerms: []*fst.ExtraPermConfig{ - {Path: dataHome, Execute: true}, - {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true}, + Link: [][2]string{ + {app.CurrentSystem, "/run/current-system"}, + {"/run/current-system/sw/bin", "/bin"}, + {"/run/current-system/sw/bin", "/usr/bin"}, }, - SystemBus: app.SystemBus, - SessionBus: app.SessionBus, - Enablements: app.Enablements, + Etc: path.Join(pathSet.cacheDir, "etc"), + AutoEtc: true, + }, + ExtraPerms: []*fst.ExtraPermConfig{ + {Path: dataHome, Execute: true}, + {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true}, }, } if app.Multiarch { - config.Confinement.Sandbox.Seccomp |= seccomp.FilterMultiarch + config.Container.Seccomp |= seccomp.FilterMultiarch } if app.Bluetooth { - config.Confinement.Sandbox.Seccomp |= seccomp.FilterBluetooth + config.Container.Seccomp |= seccomp.FilterBluetooth } return config } |
